From 6fc8e0ac72b1fb55205dea0633be3e8dafae20c3 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Thu, 12 Feb 2026 15:02:25 +0800 Subject: [PATCH 1/4] [dotnet-svcutil] extract and modernize Microsoft.Xml importer/exporter logic to reduce FrameworkFork dependencies and migrate to System.Xml types. --- .../CodeDomFixup/ArrayOfXElementTypeHelper.cs | 16 +- .../CodeDomVisitors/NamespaceFixer.cs | 25 - .../SpecialIXmlSerializableRemapper.cs | 2 +- .../CodeDomVisitors/XmlDomAttributeFixer.cs | 2 +- .../src/CodeDomFixup/MethodCreationHelper.cs | 2 +- src/dotnet-svcutil/lib/src/CodeSerializer.cs | 4 +- .../Microsoft.Xml/External/Extensions.cs | 2 +- .../Microsoft.Xml/Xml/AsyncHelper.cs | 2 +- .../Microsoft.Xml/Xml/Base64Decoder.cs | 240 - .../Microsoft.Xml/Xml/Base64Encoder.cs | 142 - .../Microsoft.Xml/Xml/BinHexDecoder.cs | 238 - .../Microsoft.Xml/Xml/BinHexEncoder.cs | 93 - .../Xml/BinaryXml/BinXmlToken.cs | 84 - .../Microsoft.Xml/Xml/BinaryXml/SqlUtils.cs | 1147 -- .../Xml/BinaryXml/XmlBinaryReader.cs | 4509 -------- .../Xml/BinaryXml/XmlBinaryReaderAsync.cs | 97 - .../Microsoft.Xml/Xml/BitStack.cs | 2 +- .../FrameworkFork/Microsoft.Xml/Xml/Bits.cs | 2 +- .../Microsoft.Xml/Xml/BufferBuilder.cs | 2 +- .../Microsoft.Xml/Xml/ByteStack.cs | 2 +- .../Microsoft.Xml/Xml/Cache/Shape.cs | 298 - .../Microsoft.Xml/Xml/Cache/ShapeGenerator.cs | 199 - .../Xml/Cache/XPathDocumentBuilder.cs | 929 -- .../Xml/Cache/XPathDocumentIterator.cs | 304 - .../Xml/Cache/XPathDocumentNavigator.cs | 1055 -- .../Xml/Cache/XPathDocumentView.cs | 819 -- .../Microsoft.Xml/Xml/Cache/XPathNode.cs | 515 - .../Xml/Cache/XPathNodeHelper.cs | 762 -- .../Xml/Cache/XPathNodeInfoAtom.cs | 515 - .../Microsoft.Xml/Xml/Cache/XPathNodeView.cs | 156 - .../Cache/XPathNodeViewPropertyDescriptor.cs | 98 - .../Xml/Core/CharEntityEncoderFallback.cs | 219 - .../Xml/Core/ConformanceLevel.cs | 22 - .../Microsoft.Xml/Xml/Core/DtdProcessing.cs | 23 - .../Microsoft.Xml/Xml/Core/EntityHandling.cs | 21 - .../Xml/Core/HtmlEncodedRawTextWriter.cs | 1003 -- .../Microsoft.Xml/Xml/Core/HtmlTernaryTree.cs | 92 - .../Xml/Core/HtmlUtf8RawTextWriter.cs | 999 -- .../Microsoft.Xml/Xml/Core/IDtdInfo.cs | 240 - .../Microsoft.Xml/Xml/Core/IDtdParser.cs | 19 - .../Xml/Core/IDtdParserAdapter.cs | 67 - .../Xml/Core/IRemovableWriter.cs | 25 - .../Xml/Core/IValidationEventHandling.cs | 20 - .../Xml/Core/IncrementalReadDecoders.cs | 126 - .../Xml/Core/NamespaceHandling.cs | 27 - .../Microsoft.Xml/Xml/Core/NewLineHandling.cs | 31 - .../Xml/Core/QueryOutputWriter.cs | 368 - .../Xml/Core/QueryOutputWriterV1.cs | 331 - .../Xml/Core/ReadContentAsBinaryHelper.cs | 506 - .../Core/ReadContentAsBinaryHelperAsync.cs | 423 - .../Xml/Core/ReadOnlyTernaryTree.cs | 119 - .../Microsoft.Xml/Xml/Core/ReadState.cs | 27 - .../Xml/Core/SecureStringHasher.cs | 114 - .../Xml/Core/TextEncodedRawTextWriter.cs | 165 - .../Core/TextRawTextWriterGenerator.cxxbak | 143 - .../Xml/Core/TextUtf8RawTextWriter.cs | 159 - .../Xml/Core/ValidatingReaderNodeData.cs | 238 - .../Microsoft.Xml/Xml/Core/ValidationType.cs | 39 - .../Xml/Core/WhiteSpaceHandling.cs | 21 - .../Xml/Core/XmlAsyncCheckReader.cs | 1103 -- .../Xml/Core/XmlAutoDetectWriter.cs | 440 - .../Xml/Core/XmlCharCheckingReader.cs | 706 -- .../Xml/Core/XmlCharCheckingReaderAsync.cs | 437 - .../Xml/Core/XmlCharCheckingWriter.cs | 592 - .../Xml/Core/XmlConfiguration.cs | 34 - .../Xml/Core/XmlEncodedRawTextWriter.cs | 2046 ---- .../Microsoft.Xml/Xml/Core/XmlEventCache.cs | 665 -- .../Xml/Core/XmlParserContext.cs | 213 - .../Xml/Core/XmlRawTextWriterGenerator.cxxbak | 1927 ---- .../Microsoft.Xml/Xml/Core/XmlRawWriter.cs | 325 - .../Microsoft.Xml/Xml/Core/XmlReader.cs | 2012 ---- .../Microsoft.Xml/Xml/Core/XmlReaderAsync.cs | 437 - .../Xml/Core/XmlReaderSettings.cs | 784 -- .../Microsoft.Xml/Xml/Core/XmlSpace.cs | 21 - .../Xml/Core/XmlSubtreeReader.cs | 1582 --- .../Xml/Core/XmlSubtreeReaderAsync.cs | 651 -- .../Microsoft.Xml/Xml/Core/XmlTextEncoder.cs | 590 - .../Microsoft.Xml/Xml/Core/XmlTextReader.cs | 475 - .../Xml/Core/XmlTextReaderImpl.cs | 9871 ----------------- .../Xml/Core/XmlTextReaderImplHelpers.cs | 802 -- .../Microsoft.Xml/Xml/Core/XmlTextWriter.cs | 1753 --- .../Xml/Core/XmlUtf8RawTextWriter.cs | 1921 ---- .../Xml/Core/XmlValidatingReader.cs | 356 - .../Xml/Core/XmlValidatingReaderImpl.cs | 1213 -- .../Xml/Core/XmlWellformedWriter.cs | 2295 ---- .../Xml/Core/XmlWellformedWriterHelpers.cs | 530 - .../Xml/Core/XmlWrappingReader.cs | 175 - .../Xml/Core/XmlWrappingReaderAsync.cs | 36 - .../Xml/Core/XmlWrappingWriter.cs | 253 - .../Microsoft.Xml/Xml/Core/XmlWriter.cs | 752 -- .../Xml/Core/XmlWriterSettings.cs | 787 -- .../Xml/Core/XsdCachingReader.cs | 781 -- .../Xml/Core/XsdCachingReaderAsync.cs | 148 - .../Xml/Core/XsdValidatingReader.cs | 2642 ----- .../Xml/Core/XsdValidatingReaderAsync.cs | 876 -- .../Xml/Core/util/TernaryTreeGenerator.cs | 467 - .../Xml/Dom/DocumentSchemaValidator.cs | 828 -- .../Xml/Dom/DocumentXPathNavigator.cs | 2452 ---- .../Xml/Dom/DocumentXmlWriter.cs | 615 - .../Microsoft.Xml/Xml/Dom/DomNameTable.cs | 129 - .../Microsoft.Xml/Xml/Dom/XPathNodeList.cs | 131 - .../Microsoft.Xml/Xml/Dom/XmlAttribute.cs | 421 - .../Xml/Dom/XmlAttributeCollection.cs | 416 - .../Microsoft.Xml/Xml/Dom/XmlCDATASection.cs | 118 - .../Microsoft.Xml/Xml/Dom/XmlCharacterData.cs | 231 - .../Xml/Dom/XmlChildEnumerator.cs | 69 - .../Microsoft.Xml/Xml/Dom/XmlChildNodes.cs | 58 - .../Microsoft.Xml/Xml/Dom/XmlComment.cs | 59 - .../Microsoft.Xml/Xml/Dom/XmlDeclaration.cs | 174 - .../Microsoft.Xml/Xml/Dom/XmlDocument.cs | 1780 --- .../Xml/Dom/XmlDocumentFragment.cs | 200 - .../Microsoft.Xml/Xml/Dom/XmlDocumentType.cs | 160 - .../Microsoft.Xml/Xml/Dom/XmlDomTextWriter.cs | 54 - .../Microsoft.Xml/Xml/Dom/XmlElement.cs | 638 -- .../Microsoft.Xml/Xml/Dom/XmlElementList.cs | 399 - .../Microsoft.Xml/Xml/Dom/XmlEntity.cs | 166 - .../Xml/Dom/XmlEntityReference.cs | 216 - .../Xml/Dom/XmlEventChangedAction.cs | 21 - .../Xml/Dom/XmlImplementation.cs | 51 - .../Microsoft.Xml/Xml/Dom/XmlLinkedNode.cs | 63 - .../Microsoft.Xml/Xml/Dom/XmlLoader.cs | 1010 -- .../Microsoft.Xml/Xml/Dom/XmlName.cs | 317 - .../Dom/XmlNamedNodeMap.SmallXmlNodeList.cs | 199 - .../Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.cs | 228 - .../Microsoft.Xml/Xml/Dom/XmlNode.cs | 1465 --- .../Xml/Dom/XmlNodeChangedEventArgs.cs | 40 - .../Xml/Dom/XmlNodeChangedEventHandler.cs | 10 - .../Microsoft.Xml/Xml/Dom/XmlNodeList.cs | 36 - .../Microsoft.Xml/Xml/Dom/XmlNodeReader.cs | 1952 ---- .../Microsoft.Xml/Xml/Dom/XmlNotation.cs | 96 - .../Xml/Dom/XmlProcessingInstruction.cs | 109 - .../Xml/Dom/XmlSignificantWhitespace.cs | 137 - .../Microsoft.Xml/Xml/Dom/XmlText.cs | 163 - .../Xml/Dom/XmlUnspecifiedAttribute.cs | 90 - .../Microsoft.Xml/Xml/Dom/XmlWhitespace.cs | 137 - .../Microsoft.Xml/Xml/EmptyEnumerator.cs | 2 +- .../Microsoft.Xml/Xml/HWStack.cs | 2 +- .../Xml/IApplicationResourceStreamResolver.cs | 2 +- .../Microsoft.Xml/Xml/IHasXmlNode.cs | 2 +- .../Xml/IXmlNamespaceResolver.cs | 39 - .../Microsoft.Xml/Xml/IxmlLineInfo.cs | 2 +- .../Microsoft.Xml/Xml/LineInfo.cs | 2 +- .../Microsoft.Xml/Xml/MtNameTable.cs | 2 +- .../Microsoft.Xml/Xml/NameTable.cs | 2 +- .../FrameworkFork/Microsoft.Xml/Xml/Ref.cs | 2 +- .../Xml/Resolvers/XmlKnownDtds.cs | 22 - .../Xml/Resolvers/XmlPreloadedResolver.cs | 384 - .../Resolvers/XmlPreloadedResolverAsync.cs | 52 - .../Xml/Resolvers/XmlSystemPathResolver.cs | 52 - .../Advanced/SchemaImporterExtension.cs | 8 +- .../Xml/Serialization/CodeExporter.cs | 7 +- .../Serialization/CodeGenerationOptions.cs | 4 +- .../Xml/Serialization/CodeGenerator.cs | 6 +- .../Xml/Serialization/CodeIdentifier.cs | 3 +- .../Xml/Serialization/CodeIdentifiers.cs | 3 +- .../Xml/Serialization/Compilation.cs | 4 +- .../Xml/Serialization/IXmlSerializable.cs | 6 +- .../Xml/Serialization/IXmlTextParser.cs | 3 +- .../Xml/Serialization/ImportContext.cs | 6 +- .../Xml/Serialization/IndentedWriter.cs | 4 +- .../Xml/Serialization/Mappings.cs | 8 +- .../Microsoft.Xml/Xml/Serialization/Models.cs | 3 +- .../Xml/Serialization/NameTable.cs | 4 +- .../Xml/Serialization/NamespaceList.cs | 56 + .../Serialization/PrimitiveXmlSerializers.cs | 98 +- .../Xml/Serialization/SchemaHelper.cs | 27 + .../Xml/Serialization/SchemaImporter.cs | 7 +- .../Xml/Serialization/SchemaObjectWriter.cs | 15 +- .../Serialization/SoapAttributeAttribute.cs | 3 +- .../Serialization/SoapAttributeOverrides.cs | 5 +- .../Xml/Serialization/SoapAttributes.cs | 3 +- .../Xml/Serialization/SoapCodeExporter.cs | 24 +- .../Xml/Serialization/SoapElementAttribute.cs | 3 +- .../Xml/Serialization/SoapEnumAttribute.cs | 3 +- .../Xml/Serialization/SoapIgnoreAttribute.cs | 3 +- .../Xml/Serialization/SoapIncludeAttribute.cs | 3 +- .../Serialization/SoapReflectionImporter.cs | 9 +- .../Xml/Serialization/SoapSchemaExporter.cs | 7 +- .../Xml/Serialization/SoapSchemaImporter.cs | 112 +- .../Xml/Serialization/SoapSchemaMember.cs | 3 +- .../Xml/Serialization/SoapTypeAttribute.cs | 3 +- .../Xml/Serialization/SourceInfo.cs | 5 +- .../Xml/Serialization/TypeExtensions.cs | 4 +- .../Microsoft.Xml/Xml/Serialization/Types.cs | 20 +- .../Serialization/XmlAnyAttributeAttribute.cs | 5 +- .../Serialization/XmlAnyElementAttribute.cs | 5 +- .../Serialization/XmlAnyElementAttributes.cs | 3 +- .../Xml/Serialization/XmlArrayAttribute.cs | 5 +- .../Serialization/XmlArrayItemAttribute.cs | 5 +- .../Serialization/XmlArrayItemAttributes.cs | 3 +- .../Serialization/XmlAttributeAttribute.cs | 5 +- .../Serialization/XmlAttributeOverrides.cs | 5 +- .../Xml/Serialization/XmlAttributes.cs | 3 +- .../XmlChoiceIdentifierAttribute.cs | 5 +- .../Xml/Serialization/XmlCodeExporter.cs | 52 +- .../Xml/Serialization/XmlCountingReader.cs | 5 +- .../Xml/Serialization/XmlCustomFormatter.cs | 29 +- .../Xml/Serialization/XmlElementAttribute.cs | 5 +- .../Xml/Serialization/XmlElementAttributes.cs | 3 +- .../Xml/Serialization/XmlEnumAttribute.cs | 3 +- .../Xml/Serialization/XmlIgnoreAttribute.cs | 3 +- .../Xml/Serialization/XmlIncludeAttribute.cs | 3 +- .../Xml/Serialization/XmlMapping.cs | 6 +- .../Xml/Serialization/XmlMemberMapping.cs | 3 +- .../Xml/Serialization/XmlMembersMapping.cs | 3 +- .../XmlNamespaceDeclarationsAttribute.cs | 5 +- .../Serialization/XmlReflectionImporter.cs | 15 +- .../Xml/Serialization/XmlReflectionMember.cs | 3 +- .../Xml/Serialization/XmlRootAttribute.cs | 5 +- .../Xml/Serialization/XmlSchemaExporter.cs | 16 +- .../Xml/Serialization/XmlSchemaImporter.cs | 93 +- .../XmlSchemaProviderAttribute.cs | 5 +- .../Xml/Serialization/XmlSchemas.cs | 40 +- .../XmlSerializationGeneratedCode.cs | 3 +- .../Serialization/XmlSerializationILGen.cs | 3 +- .../Serialization/XmlSerializationReader.cs | 12 +- .../Serialization/XmlSerializationWriter.cs | 11 +- .../XmlSerializationWriterILGen.cs | 7 +- .../Xml/Serialization/XmlSerializer.cs | 9 +- .../XmlSerializerAssemblyAttribute.cs | 3 +- .../Xml/Serialization/XmlSerializerFactory.cs | 7 +- .../Serialization/XmlSerializerNamespaces.cs | 32 +- .../XmlSerializerVersionAttribute.cs | 3 +- .../Xml/Serialization/XmlTextAttribute.cs | 3 +- .../Xml/Serialization/XmlTypeAttribute.cs | 3 +- .../Xml/Serialization/XmlTypeMapping.cs | 3 +- .../Xml/Serialization/_Events.cs | 3 +- .../Microsoft.Xml/Xml/ValidateNames.cs | 4 +- .../Xml/XPath/IXPathNavigable.cs | 11 - .../Xml/XPath/Internal/AbsoluteQuery.cs | 37 - .../Xml/XPath/Internal/AstNode.cs | 28 - .../Xml/XPath/Internal/AttributeQuery.cs | 78 - .../Microsoft.Xml/Xml/XPath/Internal/Axis.cs | 83 - .../Xml/XPath/Internal/BooleanExpr.cs | 71 - .../Xml/XPath/Internal/BooleanFunctions.cs | 102 - .../Xml/XPath/Internal/CacheAxisQuery.cs | 68 - .../Xml/XPath/Internal/CacheChildrenQuery.cs | 159 - .../Xml/XPath/Internal/CacheOutputQuery.cs | 86 - .../Xml/XPath/Internal/ChildrenQuery.cs | 81 - .../Xml/XPath/Internal/ClonableStack.cs | 39 - .../Xml/XPath/Internal/CompiledXpathExpr.cs | 226 - .../Xml/XPath/Internal/ContextQuery.cs | 60 - .../Xml/XPath/Internal/DescendantBaseQuery.cs | 79 - .../Internal/DescendantOverDescendantQuery.cs | 102 - .../Xml/XPath/Internal/DescendantQuery.cs | 74 - .../Xml/XPath/Internal/DocumentOrderQuery.cs | 42 - .../Xml/XPath/Internal/EmptyQuery.cs | 27 - .../Xml/XPath/Internal/ExtensionQuery.cs | 133 - .../Xml/XPath/Internal/Filter.cs | 30 - .../Xml/XPath/Internal/FilterQuery.cs | 198 - .../XPath/Internal/ForwardPositionQuery.cs | 45 - .../Xml/XPath/Internal/Function.cs | 125 - .../Xml/XPath/Internal/FunctionQuery.cs | 137 - .../Microsoft.Xml/Xml/XPath/Internal/Group.cs | 27 - .../Xml/XPath/Internal/GroupQuery.cs | 37 - .../Xml/XPath/Internal/IDQuery.cs | 77 - .../Xml/XPath/Internal/IteratorFilter.cs | 49 - .../Xml/XPath/Internal/LogicalExpr.cs | 446 - .../Xml/XPath/Internal/MergeFilterQuery.cs | 84 - .../Xml/XPath/Internal/NamespaceQuery.cs | 82 - .../Xml/XPath/Internal/NodeFunctions.cs | 123 - .../Xml/XPath/Internal/NumberFunctions.cs | 133 - .../Xml/XPath/Internal/NumericExpr.cs | 87 - .../Xml/XPath/Internal/Operand.cs | 41 - .../Xml/XPath/Internal/OperandQuery.cs | 37 - .../Xml/XPath/Internal/Operator.cs | 88 - .../Xml/XPath/Internal/ParentQuery.cs | 42 - .../Microsoft.Xml/Xml/XPath/Internal/Query.cs | 264 - .../Xml/XPath/Internal/ResetableIterator.cs | 47 - .../XPath/Internal/ReversePositionQuery.cs | 26 - .../Microsoft.Xml/Xml/XPath/Internal/Root.cs | 18 - .../Xml/XPath/Internal/SortQuery.cs | 234 - .../Xml/XPath/Internal/StringFunctions.cs | 285 - .../Xml/XPath/Internal/UnionExpr.cs | 179 - .../Xml/XPath/Internal/ValueQuery.cs | 26 - .../Xml/XPath/Internal/Variable.cs | 28 - .../Xml/XPath/Internal/VariableQuery.cs | 80 - .../XPath/Internal/XPathAncestorIterator.cs | 45 - .../Xml/XPath/Internal/XPathAncestorQuery.cs | 87 - .../Xml/XPath/Internal/XPathArrayIterator.cs | 90 - .../Xml/XPath/Internal/XPathAxisIterator.cs | 93 - .../Xml/XPath/Internal/XPathChildIterator.cs | 38 - .../XPath/Internal/XPathDescendantIterator.cs | 69 - .../Xml/XPath/Internal/XPathEmptyIterator.cs | 44 - .../Xml/XPath/Internal/XPathMultyIterator.cs | 187 - .../Xml/XPath/Internal/XPathParser.cs | 889 -- .../Xml/XPath/Internal/XPathScanner.cs | 406 - .../XPath/Internal/XPathSelectionIterator.cs | 60 - .../Xml/XPath/Internal/XPathSelfQuery.cs | 32 - .../XPath/Internal/XPathSingletonIterator.cs | 73 - .../Xml/XPath/Internal/XmlIteratorQuery.cs | 58 - .../Xml/XPath/Internal/baseaxisquery.cs | 155 - .../Xml/XPath/Internal/followingquery.cs | 86 - .../Xml/XPath/Internal/followingsibling.cs | 119 - .../Xml/XPath/Internal/precedingquery.cs | 108 - .../Xml/XPath/Internal/precedingsibling.cs | 92 - .../Xml/XPath/Internal/querybuilder.cs | 542 - .../Microsoft.Xml/Xml/XPath/XPathDocument.cs | 472 - .../Microsoft.Xml/Xml/XPath/XPathException.cs | 91 - .../Microsoft.Xml/Xml/XPath/XPathExpr.cs | 82 - .../Microsoft.Xml/Xml/XPath/XPathItem.cs | 44 - .../Xml/XPath/XPathNamespaceScope.cs | 15 - .../Microsoft.Xml/Xml/XPath/XPathNavigator.cs | 2291 ---- .../Xml/XPath/XPathNavigatorKeyComparer.cs | 66 - .../Xml/XPath/XPathNavigatorReader.cs | 1340 --- .../Xml/XPath/XPathNodeIterator.cs | 135 - .../Microsoft.Xml/Xml/XPath/XPathNodeType.cs | 22 - .../Microsoft.Xml/Xml/XmlCharType.cs | 4 +- .../Microsoft.Xml/Xml/XmlComplianceUtil.cs | 2 +- .../Microsoft.Xml/Xml/XmlConvert.cs | 1883 ---- .../Microsoft.Xml/Xml/XmlEncoding.cs | 2 +- .../Microsoft.Xml/Xml/XmlException.cs | 4 +- .../Microsoft.Xml/Xml/XmlNameTable.cs | 51 - .../Microsoft.Xml/Xml/XmlNamespaceManager.cs | 373 - .../Microsoft.Xml/Xml/XmlNamespaceScope.cs | 34 - .../Microsoft.Xml/Xml/XmlNodeOrder.cs | 2 +- .../Microsoft.Xml/Xml/XmlNodeType.cs | 223 - .../Microsoft.Xml/Xml/XmlNullResolver.cs | 2 +- .../Microsoft.Xml/Xml/XmlQualifiedName.cs | 246 - .../Microsoft.Xml/Xml/XmlReservedNS.cs | 2 +- .../Microsoft.Xml/Xml/XmlResolver.cs | 2 +- .../Microsoft.Xml/Xml/XmlResolverAsync.cs | 2 +- .../Microsoft.Xml/Xml/XmlUrlResolver.cs | 2 +- .../Microsoft.Xml/Xml/XmlXapResolver.cs | 2 +- .../Xml/Xslt/XsltArgumentList.cs | 101 - .../Microsoft.Xml/Xml/Xslt/XsltCommand.cs | 199 - .../Microsoft.Xml/Xml/Xslt/XsltContext.cs | 43 - .../Microsoft.Xml/Xml/Xslt/XsltSettings.cs | 82 - .../Microsoft.Xml/Xml/schema/AstTree.cs | 733 -- .../Microsoft.Xml/Xml/schema/BaseProcessor.cs | 295 - .../Microsoft.Xml/Xml/schema/BitSet.cs | 273 - .../Microsoft.Xml/Xml/schema/ChameleonKey.cs | 78 - .../Xml/schema/CompiledIdentityConstraint.cs | 97 - .../Xml/schema/ConstraintStruct.cs | 552 - .../Xml/schema/ContentValidator.cs | 2360 ---- .../Xml/schema/DatatypeImplementation.cs | 3998 ------- .../Microsoft.Xml/Xml/schema/DtdParser.cs | 3691 ------ .../Microsoft.Xml/Xml/schema/FacetChecker.cs | 1732 --- .../Xml/schema/GenerateConverter.cs | 1118 -- .../Xml/schema/IXmlSchemaInfo.cs | 38 - .../Inference/XmlSchemaInferenceException.cs | 65 - .../Xml/schema/Inference/infer.cs | 2544 ----- .../Microsoft.Xml/Xml/schema/NamespaceList.cs | 414 - .../Microsoft.Xml/Xml/schema/Parser.cs | 480 - .../Microsoft.Xml/Xml/schema/ParserAsync.cs | 67 - .../Microsoft.Xml/Xml/schema/Preprocessor.cs | 2215 ---- .../Microsoft.Xml/Xml/schema/SchemaAttDef.cs | 228 - .../Microsoft.Xml/Xml/schema/SchemaBuilder.cs | 21 - .../Xml/schema/SchemaCollectionCompiler.cs | 2769 ----- .../schema/SchemaCollectionPreprocessor.cs | 1834 --- .../Xml/schema/SchemaDeclBase.cs | 138 - .../Xml/schema/SchemaElementDecl.cs | 253 - .../Microsoft.Xml/Xml/schema/SchemaEntity.cs | 185 - .../Microsoft.Xml/Xml/schema/SchemaInfo.cs | 474 - .../Microsoft.Xml/Xml/schema/SchemaNames.cs | 614 - .../Xml/schema/SchemaNamespaceManager.cs | 64 - .../Xml/schema/SchemaNotation.cs | 41 - .../Xml/schema/SchemaSetCompiler.cs | 3281 ------ .../Microsoft.Xml/Xml/schema/SchemaType.cs | 18 - .../Xml/schema/ValidationEventArgs.cs | 54 - .../Xml/schema/ValidationEventHandler.cs | 14 - .../Microsoft.Xml/Xml/schema/XdrBuilder.cs | 1833 --- .../Xml/schema/XmlAtomicValue.cs | 414 - .../Microsoft.Xml/Xml/schema/XmlSchema.cs | 756 -- .../Microsoft.Xml/Xml/schema/XmlSchemaAll.cs | 42 - .../Xml/schema/XmlSchemaAnnotated.cs | 73 - .../Xml/schema/XmlSchemaAnnotation.cs | 69 - .../Microsoft.Xml/Xml/schema/XmlSchemaAny.cs | 133 - .../Xml/schema/XmlSchemaAnyAttribute.cs | 130 - .../Xml/schema/XmlSchemaAppInfo.cs | 45 - .../Xml/schema/XmlSchemaAttribute.cs | 233 - .../Xml/schema/XmlSchemaAttributeGroup.cs | 134 - .../Xml/schema/XmlSchemaAttributeGroupRef.cs | 33 - .../Xml/schema/XmlSchemaChoice.cs | 46 - .../Xml/schema/XmlSchemaCollection.cs | 519 - .../schema/XmlSchemaCompilationSettings.cs | 32 - .../Xml/schema/XmlSchemaComplexContent.cs | 52 - .../XmlSchemaComplexContentExtension.cs | 79 - .../XmlSchemaComplexContentRestriction.cs | 78 - .../Xml/schema/XmlSchemaComplexType.cs | 658 -- .../Xml/schema/XmlSchemaContent.cs | 21 - .../Xml/schema/XmlSchemaContentModel.cs | 27 - .../Xml/schema/XmlSchemaContentProcessing.cs | 44 - .../Xml/schema/XmlSchemaContentType.cs | 23 - .../Xml/schema/XmlSchemaDatatype.cs | 458 - .../Xml/schema/XmlSchemaDerivationMethod.cs | 71 - .../Xml/schema/XmlSchemaDocumentation.cs | 59 - .../Xml/schema/XmlSchemaElement.cs | 386 - .../Xml/schema/XmlSchemaException.cs | 194 - .../Xml/schema/XmlSchemaExternal.cs | 88 - .../Xml/schema/XmlSchemaFacet.cs | 183 - .../Microsoft.Xml/Xml/schema/XmlSchemaForm.cs | 39 - .../Xml/schema/XmlSchemaGroup.cs | 106 - .../Xml/schema/XmlSchemaGroupRef.cs | 56 - .../Xml/schema/XmlSchemaGroupbase.cs | 28 - .../Xml/schema/XmlSchemaIdentityConstraint.cs | 143 - .../Xml/schema/XmlSchemaImport.cs | 49 - .../Xml/schema/XmlSchemaInclude.cs | 39 - .../Microsoft.Xml/Xml/schema/XmlSchemaInfo.cs | 192 - .../Xml/schema/XmlSchemaNotation.cs | 71 - .../Xml/schema/XmlSchemaObject.cs | 123 - .../Xml/schema/XmlSchemaObjectCollection.cs | 236 - .../Xml/schema/XmlSchemaObjectTable.cs | 419 - .../Xml/schema/XmlSchemaParticle.cs | 198 - .../Xml/schema/XmlSchemaRedefine.cs | 83 - .../Xml/schema/XmlSchemaSequence.cs | 45 - .../Microsoft.Xml/Xml/schema/XmlSchemaSet.cs | 1637 --- .../Xml/schema/XmlSchemaSimpleContent.cs | 33 - .../schema/XmlSchemaSimpleContentExtension.cs | 61 - .../XmlSchemaSimpleContentRestriction.cs | 96 - .../Xml/schema/XmlSchemaSimpleType.cs | 70 - .../Xml/schema/XmlSchemaSimpleTypeContent.cs | 18 - .../Xml/schema/XmlSchemaSimpleTypeList.cs | 61 - .../schema/XmlSchemaSimpleTypeRestriction.cs | 75 - .../Xml/schema/XmlSchemaSimpleTypeUnion.cs | 72 - .../Xml/schema/XmlSchemaSubstitutionGroup.cs | 43 - .../Microsoft.Xml/Xml/schema/XmlSchemaType.cs | 361 - .../Microsoft.Xml/Xml/schema/XmlSchemaUse.cs | 45 - .../schema/XmlSchemaValidationException.cs | 99 - .../Xml/schema/XmlSchemaValidator.cs | 2900 ----- .../Xml/schema/XmlSchemaValidity.cs | 24 - .../Xml/schema/XmlSeverityType.cs | 22 - .../Xml/schema/XmlTokenizedType.cs | 28 - .../Microsoft.Xml/Xml/schema/XmlTypeCode.cs | 179 - .../Xml/schema/XmlValueConverter.cs | 3733 ------- .../Microsoft.Xml/Xml/schema/XsdBuilder.cs | 2609 ----- .../Microsoft.Xml/Xml/schema/XsdDateTime.cs | 1099 -- .../Microsoft.Xml/Xml/schema/XsdDuration.cs | 726 -- .../Microsoft.Xml/Xml/schema/autovalidator.cs | 125 - .../Microsoft.Xml/Xml/schema/basevalidator.cs | 366 - .../Microsoft.Xml/Xml/schema/dtdvalidator.cs | 629 -- .../Xml/schema/validationstate.cs | 53 - .../Microsoft.Xml/Xml/schema/xdrvalidator.cs | 702 -- .../Microsoft.Xml/Xml/schema/xsdvalidator.cs | 1170 -- .../Runtime/Serialization/Attributes.cs | 2 +- .../Serialization/ClassDataContract.cs | 4 +- .../Runtime/Serialization/CodeExporter.cs | 6 +- .../Runtime/Serialization/CodeGenerator.cs | 2 +- .../Serialization/CollectionDataContract.cs | 4 +- .../Runtime/Serialization/DataContract.cs | 6 +- .../Serialization/DataContractResolver.cs | 2 +- .../Serialization/DataContractSerializer.cs | 4 +- .../DataContractSerializerSettings.cs | 2 +- .../Runtime/Serialization/DataContractSet.cs | 4 +- .../Runtime/Serialization/DataMember.cs | 2 +- .../Serialization/DateTimeOffsetAdapter.cs | 2 +- .../Serialization/DictionaryGlobals.cs | 4 +- .../Runtime/Serialization/EnumDataContract.cs | 2 +- .../Serialization/ExceptionDataContract.cs | 2 +- .../Serialization/ExtensionDataObject.cs | 2 +- .../Serialization/ExtensionDataReader.cs | 2 +- .../System/Runtime/Serialization/Globals.cs | 8 +- .../Serialization/HybridObjectCache.cs | 2 +- .../KnownTypeDataContractResolver.cs | 2 +- .../Serialization/ObjectReferenceStack.cs | 2 +- .../Serialization/PrimitiveDataContract.cs | 2 +- .../Runtime/Serialization/SchemaExporter.cs | 6 +- .../Runtime/Serialization/SchemaHelper.cs | 6 +- .../Runtime/Serialization/SchemaImporter.cs | 8 +- .../Runtime/Serialization/ScopedKnownTypes.cs | 4 +- .../Serialization/SpecialTypeDataContract.cs | 2 +- .../Runtime/Serialization/XmlDataContract.cs | 8 +- .../XmlFormatGeneratorStatics.cs | 2 +- .../Serialization/XmlFormatReaderGenerator.cs | 4 +- .../Serialization/XmlFormatWriterGenerator.cs | 4 +- .../Serialization/XmlObjectSerializer.cs | 8 +- .../XmlObjectSerializerContext.cs | 4 +- .../XmlObjectSerializerReadContext.cs | 6 +- .../XmlObjectSerializerWriteContext.cs | 4 +- .../XmlObjectSerializerWriteContextComplex.cs | 2 +- .../Serialization/XmlReaderDelegator.cs | 4 +- .../Serialization/XmlSerializableReader.cs | 6 +- .../Serialization/XmlSerializableServices.cs | 2 +- .../Serialization/XmlSerializableWriter.cs | 2 +- .../Serialization/XmlWriterDelegator.cs | 2 +- .../Serialization/XsdDataContractImporter.cs | 6 +- .../System/Xml/ArrayHelper.cs | 6 +- .../System/Xml/BytesWithOffset.cs | 2 +- .../System/Xml/EncodingStreamWrapper.cs | 2 +- .../System/Xml/IStreamProvider.cs | 2 +- .../System/Xml/IXmlDictionary.cs | 13 - .../System/Xml/PrefixHandle.cs | 253 - .../System/Xml/StringHandle.cs | 297 - .../System/Xml/UniqueId.cs | 489 - .../System/Xml/ValueHandle.cs | 927 -- .../System/Xml/XmlBaseReader.cs | 2940 ----- .../System/Xml/XmlBaseWriter.cs | 2 +- .../System/Xml/XmlBinaryNodeType.cs | 453 +- .../System/Xml/XmlBinaryReader.cs | 1531 --- .../System/Xml/XmlBinaryReaderSession.cs | 132 - .../System/Xml/XmlBinaryWriter.cs | 1635 --- .../System/Xml/XmlBinaryWriterSession.cs | 262 - .../System/Xml/XmlBufferReader.cs | 1397 --- .../System/Xml/XmlConverter.cs | 6 +- .../System/Xml/XmlDictionary.cs | 124 - .../Xml/XmlDictionaryAsyncCheckWriter.cs | 2 +- .../System/Xml/XmlDictionaryReader.cs | 1716 --- .../System/Xml/XmlDictionaryReaderQuotas.cs | 194 - .../System/Xml/XmlDictionaryString.cs | 144 - .../System/Xml/XmlDictionaryWriter.cs | 843 -- .../System/Xml/XmlExceptionHelper.cs | 295 +- .../System/Xml/XmlNodeWriter.cs | 2 +- .../System/Xml/XmlStreamNodeWriter.cs | 2 +- .../System/Xml/XmlUTF8TextReader.cs | 1463 --- .../System/Xml/XmlUTF8TextWriter.cs | 828 -- .../Diagnostics/DiagnosticTraceBase.cs | 2 +- .../Diagnostics/DictionaryTraceRecord.cs | 2 +- .../Runtime/Diagnostics/EtwDiagnosticTrace.cs | 2 +- .../Runtime/Diagnostics/StringTraceRecord.cs | 2 +- .../System/Runtime/Diagnostics/TraceRecord.cs | 2 +- .../Diagnostics/ExceptionUtility.cs | 2 +- .../IdentityModel/CanonicalFormWriter.cs | 2 +- .../System/IdentityModel/DictionaryManager.cs | 2 +- .../System/IdentityModel/ISecurityElement.cs | 2 +- .../ISignatureValueSecurityElement.cs | 2 +- .../IdentityModel/IdentityModelDictionary.cs | 2 +- .../System/IdentityModel/Security/WSTrust.cs | 2 +- .../Selectors/SecurityTokenResolver.cs | 2 +- .../Selectors/SecurityTokenSerializer.cs | 2 +- .../IdentityModel/SignatureResourcePool.cs | 2 +- .../System/IdentityModel/SignedXml.cs | 2 +- .../IdentityModel/Tokens/KeyInfoSerializer.cs | 2 +- .../IdentityModel/Tokens/SamlAssertion.cs | 2 +- .../IdentityModel/Tokens/SamlSecurityToken.cs | 6 +- .../IdentityModel/Tokens/SamlSerializer.cs | 2 +- .../IdentityModel/Tokens/WSSecurityJan2004.cs | 2 +- .../IdentityModel/Tokens/WSSecurityXXX2005.cs | 2 +- .../IdentityModel/Tokens/XmlDsigSep2000.cs | 2 +- .../IdentityModel/Tokens/XmlEncApr2001.cs | 2 +- .../System/IdentityModel/XD.cs | 2 +- .../System/IdentityModel/XmlBuffer.cs | 2 +- .../ServiceModel/Channels/AddressHeader.cs | 2 +- .../Channels/AddressHeaderCollection.cs | 2 +- .../ServiceModel/Channels/Addressing.cs | 2 +- .../Channels/AddressingVersion.cs | 2 +- .../AsymmetricSecurityBindingElement.cs | 2 +- .../Channels/BinaryMessageEncoder.cs | 2 +- .../BinaryMessageEncodingBindingElement.cs | 2 +- .../ServiceModel/Channels/BinaryVersion.cs | 2 +- .../ServiceModel/Channels/BodyWriter.cs | 2 +- .../Channels/BufferedMessageData.cs | 2 +- .../Channels/BufferedMessageWriter.cs | 2 +- .../Channels/CompositeDuplexBindingElement.cs | 2 +- .../CompositeDuplexBindingElementImporter.cs | 2 +- .../Channels/ContentOnlyMessage.cs | 2 +- .../Channels/ContextBindingElementImporter.cs | 4 +- .../Channels/ContextBindingElementPolicy.cs | 2 +- .../ServiceModel/Channels/EncoderHelpers.cs | 2 +- .../Channels/HttpResponseMessageHelper.cs | 2 +- .../Channels/HttpTransportBindingElement.cs | 2 +- .../Channels/HttpsTransportBindingElement.cs | 2 +- .../ITransportTokenAssertionProvider.cs | 2 +- .../System/ServiceModel/Channels/Message.cs | 2 +- .../ServiceModel/Channels/MessageBuffer.cs | 2 +- .../MessageEncodingBindingElementImporter.cs | 4 +- .../ServiceModel/Channels/MessageFault.cs | 2 +- .../ServiceModel/Channels/MessageHeader.cs | 2 +- .../Channels/MessageHeaderInfo.cs | 2 +- .../ServiceModel/Channels/MessageHeaders.cs | 2 +- .../MtomMessageEncodingBindingElement.cs | 2 +- .../Channels/OneWayBindingElement.cs | 2 +- .../Channels/OneWayBindingElementImporter.cs | 2 +- .../Channels/PrivacyNoticeBindingElement.cs | 2 +- .../PrivacyNoticeBindingElementImporter.cs | 2 +- .../Channels/ReliableSessionBindingElement.cs | 2 +- .../ReliableSessionBindingElementImporter.cs | 2 +- .../Channels/RequestReplyCorrelator.cs | 2 +- .../SecurityAttributeGenerationHelper.cs | 2 +- .../Channels/SecurityBindingElement.cs | 2 +- .../SecurityBindingElementImporter.cs | 2 +- .../Channels/SessionConnectionReader.cs | 2 +- .../SslStreamSecurityBindingElement.cs | 2 +- .../Channels/StandardBindingImporter.cs | 4 +- .../SymmetricSecurityBindingElement.cs | 2 +- .../Channels/TextMessageEncoder.cs | 2 +- .../TextMessageEncodingBindingElement.cs | 2 +- .../Channels/TransactionFlowBindingElement.cs | 2 +- .../TransactionFlowBindingElementImporter.cs | 2 +- .../Channels/TransportBindingElement.cs | 2 +- .../TransportBindingElementImporter.cs | 4 +- .../Channels/TransportDefaults.cs | 2 +- .../Channels/TransportOutputChannel.cs | 2 +- .../Channels/UdpTransportBindingElement.cs | 2 +- .../Channels/UdpTransportImporter.cs | 4 +- .../UnrecognizedAssertionsBindingElement.cs | 2 +- .../UseManagedPresentationBindingElement.cs | 2 +- ...nagedPresentationBindingElementImporter.cs | 2 +- .../WindowsStreamSecurityBindingElement.cs | 2 +- .../Channels/XmlSerializerImportOptions.cs | 6 +- .../BindingElementExtensionElement.cs | 2 +- .../Configuration/SecurityElement.cs | 2 +- .../Configuration/SecurityElementBase.cs | 2 +- .../System/ServiceModel/DXD.cs | 2 +- ...ntractSerializerMessageContractImporter.cs | 6 +- ...DataContractSerializerOperationBehavior.cs | 2 +- .../Description/IWsdlImportExtension.cs | 4 +- .../ImportedPolicyConversionContext.cs | 2 +- .../Description/MessageContractExporter.cs | 6 +- .../Description/MessageContractImporter.cs | 24 +- .../Description/MessageDescription.cs | 2 +- .../MessageHeaderDescriptionCollection.cs | 2 +- .../MessagePartDescriptionCollection.cs | 2 +- .../Description/MetadataExchangeClient.cs | 4 +- .../Description/MetadataImporter.cs | 2 +- .../Description/MetadataLocation.cs | 2 +- .../Description/MetadataReference.cs | 6 +- .../Description/MetadataSection.cs | 8 +- .../ServiceModel/Description/MetadataSet.cs | 112 +- .../Description/PolicyAssertionCollection.cs | 2 +- .../Description/PolicyConversionContext.cs | 2 +- .../ServiceModel/Description/PolicyReader.cs | 2 +- .../ServiceModel/Description/SchemaHelper.cs | 4 +- .../Description/ServiceEndpointCollection.cs | 2 +- .../Description/ServiceMetadataExtension.cs | 4 +- .../Description/ServiceReflector.cs | 2 +- .../ServiceModel/Description/SoapHelper.cs | 2 +- .../ServiceModel/Description/TypeLoader.cs | 2 +- .../WsdlContractConversionContext.cs | 4 +- .../WsdlEndpointConversionContext.cs | 2 +- .../ServiceModel/Description/WsdlExporter.cs | 8 +- .../ServiceModel/Description/WsdlImporter.cs | 4 +- .../XmlSerializerOperationBehavior.cs | 4 +- .../XmlSerializerOperationGenerator.cs | 11 +- .../Diagnostics/ActivityIdHeader.cs | 2 +- .../Diagnostics/EventTraceActivityHelper.cs | 2 +- .../ServiceModel/Diagnostics/MessageLogger.cs | 2 +- .../Diagnostics/MessageTraceRecord.cs | 2 +- .../Diagnostics/MessageTransmitTraceRecord.cs | 2 +- .../ServiceModel/Dispatcher/ChannelHandler.cs | 2 +- .../ServiceModel/Dispatcher/ClientRuntime.cs | 2 +- ...ataContractSerializerOperationFormatter.cs | 2 +- .../Dispatcher/DuplexChannelBinder.cs | 2 +- .../Dispatcher/EndpointAddressProcessor.cs | 4 +- .../ServiceModel/Dispatcher/FaultFormatter.cs | 2 +- .../ServiceModel/Dispatcher/MessageRpc.cs | 2 +- .../Dispatcher/OperationFormatter.cs | 2 +- .../Dispatcher/PrimitiveOperationFormatter.cs | 2 +- .../Dispatcher/StreamFormatter.cs | 4 +- .../Dispatcher/XmlSerializerFaultFormatter.cs | 4 +- .../XmlSerializerObjectSerializer.cs | 4 +- .../XmlSerializerOperationFormatter.cs | 6 +- .../ServiceModel/DnsEndpointIdentity.cs | 4 +- .../System/ServiceModel/EndpointAddress.cs | 2 +- .../System/ServiceModel/EndpointIdentity.cs | 2 +- .../System/ServiceModel/EnvelopeVersion.cs | 2 +- .../FederatedMessageSecurityOverHttp.cs | 2 +- .../System/ServiceModel/HttpBindingBase.cs | 2 +- .../MustUnderstandSoapException.cs | 2 +- .../System/ServiceModel/NetHttpBinding.cs | 2 +- .../System/ServiceModel/NetHttpsBinding.cs | 2 +- .../ServiceModel/NetNamedPipeBinding.cs | 2 +- .../System/ServiceModel/NetTcpBinding.cs | 2 +- .../ServiceModel/ReliableMessagingVersion.cs | 2 +- .../Security/BinaryNegotiation.cs | 2 +- .../Security/ChannelProtectionRequirements.cs | 2 +- .../ServiceModel/Security/EncryptedData.cs | 2 +- .../ServiceModel/Security/EncryptedKey.cs | 2 +- .../ServiceModel/Security/EncryptedType.cs | 2 +- .../Security/MessagePartSpecification.cs | 2 +- .../ServiceModel/Security/NonceToken.cs | 2 +- .../Security/ReceiveSecurityHeader.cs | 2 +- .../ServiceModel/Security/ReferenceList.cs | 2 +- .../Security/RequestSecurityToken.cs | 2 +- .../Security/RequestSecurityTokenResponse.cs | 2 +- .../RequestSecurityTokenResponseCollection.cs | 2 +- .../ScopedMessagePartSpecification.cs | 2 +- .../Security/SecureConversationDriver.cs | 2 +- .../Security/SecureConversationVersion.cs | 2 +- .../Security/SecurityAlgorithmSuite.cs | 2 +- .../SecurityContextKeyIdentifierClause.cs | 2 +- .../ServiceModel/Security/SecurityHeader.cs | 2 +- .../Security/SecurityStandardsManager.cs | 2 +- .../Security/SecurityTimestamp.cs | 2 +- .../ServiceModel/Security/SecurityUtils.cs | 2 +- .../ServiceModel/Security/SecurityVersion.cs | 2 +- .../Security/SendSecurityHeader.cs | 2 +- .../Security/SignatureConfirmationElement.cs | 2 +- .../Security/SignatureTargetIdManager.cs | 2 +- .../Tokens/DerivedKeySecurityToken.cs | 2 +- .../Tokens/GenericXmlSecurityToken.cs | 2 +- .../ISecurityContextSecurityTokenCache.cs | 2 +- .../Tokens/IssuedSecurityTokenParameters.cs | 2 +- .../Tokens/SecurityContextCookieSerializer.cs | 2 +- .../Tokens/SecurityContextSecurityToken.cs | 2 +- .../Tokens/WrappedKeySecurityToken.cs | 2 +- .../ServiceModel/Security/TrustDriver.cs | 2 +- .../ServiceModel/Security/TrustVersion.cs | 2 +- .../Security/WSKeyInfoSerializer.cs | 12 +- .../Security/WSSecureConversation.cs | 2 +- .../Security/WSSecureConversationDec2005.cs | 2 +- .../Security/WSSecureConversationFeb2005.cs | 2 +- .../Security/WSSecurityJan2004.cs | 2 +- ...SSecurityOneDotOneReceiveSecurityHeader.cs | 2 +- .../WSSecurityOneDotOneSendSecurityHeader.cs | 2 +- .../ServiceModel/Security/WSSecurityPolicy.cs | 2 +- .../Security/WSSecurityPolicy11.cs | 2 +- .../Security/WSSecurityPolicy12.cs | 2 +- .../Security/WSSecurityTokenSerializer.cs | 2 +- .../Security/WSSecurityXXX2005.cs | 2 +- .../System/ServiceModel/Security/WSTrust.cs | 2 +- .../ServiceModel/Security/WSTrustDec2005.cs | 2 +- .../ServiceModel/Security/WSTrustFeb2005.cs | 2 +- .../Security/WSUtilitySpecificationVersion.cs | 2 +- .../System/ServiceModel/Security/XmlHelper.cs | 2 +- .../ServiceModel/ServiceModelDictionary.cs | 2 +- .../ServiceModel/SpnEndpointIdentity.cs | 2 +- .../System/ServiceModel/UdpBinding.cs | 2 +- .../ServiceModel/UpnEndpointIdentity.cs | 2 +- .../WS2007FederationHttpBinding.cs | 2 +- .../System/ServiceModel/WS2007HttpBinding.cs | 2 +- .../WSAddressing10ProblemHeaderQNameFault.cs | 2 +- .../ServiceModel/WSFederationHttpBinding.cs | 2 +- .../System/ServiceModel/WSHttpBinding.cs | 2 +- .../System/ServiceModel/WSHttpBindingBase.cs | 2 +- .../X509CertificateEndpointIdentity.cs | 4 +- .../System/ServiceModel/XD.cs | 2 +- .../System/ServiceModel/XmlBuffer.cs | 2 +- .../System/ServiceModel/XmlUtil.cs | 2 +- .../Configuration/WebServicesSection.cs | 2 +- .../Description/HttpFormatExtensions.cs | 2 +- .../Description/MimeFormatExtensions.cs | 2 +- .../Description/ServiceDescription.cs | 10 +- .../Description/ServiceDescriptionImporter.cs | 6 +- .../ServiceDescriptionSerializer.cs | 3884 +++---- .../Description/ServiceDescriptions.cs | 2 +- .../Description/Soap12FormatExtensions.cs | 4 +- .../Description/SoapFormatExtensions.cs | 6 +- .../Description/WebReferenceOptions.cs | 68 +- .../System.Web.Services/Services/Soap.cs | 2 +- src/dotnet-svcutil/lib/src/ImportModule.cs | 6 +- .../lib/src/Metadata/MetadataConstants.cs | 2 +- .../src/Metadata/MetadataDocumentLoader.cs | 2 +- .../lib/src/Metadata/MetadataDocumentSaver.cs | 4 +- .../lib/src/Metadata/MetadataFileInfo.cs | 2 +- .../lib/src/Metadata/ServiceDescriptor.cs | 2 +- src/dotnet-svcutil/lib/src/XmlStrings.cs | 2 +- .../lib/src/dotnet-svcutil-lib.csproj | 1 + 737 files changed, 3291 insertions(+), 165236 deletions(-) delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Decoder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Encoder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexDecoder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexEncoder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/BinXmlToken.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/SqlUtils.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/Shape.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/ShapeGenerator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentBuilder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentNavigator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentView.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNode.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeHelper.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeInfoAtom.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeView.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeViewPropertyDescriptor.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/CharEntityEncoderFallback.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ConformanceLevel.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/DtdProcessing.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/EntityHandling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlEncodedRawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlTernaryTree.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlUtf8RawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdInfo.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParser.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParserAdapter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IRemovableWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IValidationEventHandling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IncrementalReadDecoders.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NamespaceHandling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NewLineHandling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriterV1.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelper.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelperAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadOnlyTernaryTree.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadState.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/SecureStringHasher.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextEncodedRawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextRawTextWriterGenerator.cxxbak delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextUtf8RawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidatingReaderNodeData.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidationType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/WhiteSpaceHandling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAsyncCheckReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAutoDetectWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlConfiguration.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEncodedRawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEventCache.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlParserContext.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawTextWriterGenerator.cxxbak delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderSettings.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSpace.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextEncoder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImpl.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImplHelpers.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlUtf8RawTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReaderImpl.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriterHelpers.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriterSettings.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReaderAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/util/TernaryTreeGenerator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentSchemaValidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXPathNavigator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXmlWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DomNameTable.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XPathNodeList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttributeCollection.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCDATASection.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCharacterData.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildEnumerator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildNodes.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlComment.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDeclaration.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocument.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentFragment.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDomTextWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElement.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElementList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntity.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntityReference.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEventChangedAction.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlImplementation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLinkedNode.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLoader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlName.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.SmallXmlNodeList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNode.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventArgs.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventHandler.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNotation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlProcessingInstruction.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlSignificantWhitespace.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlText.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlUnspecifiedAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlWhitespace.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IXmlNamespaceResolver.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlKnownDtds.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolver.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolverAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlSystemPathResolver.cs create mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NamespaceList.cs create mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaHelper.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/IXPathNavigable.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AbsoluteQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AstNode.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AttributeQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Axis.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanFunctions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheAxisQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheChildrenQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheOutputQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ChildrenQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ClonableStack.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CompiledXpathExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ContextQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantBaseQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantOverDescendantQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DocumentOrderQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/EmptyQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ExtensionQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Filter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FilterQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ForwardPositionQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Function.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FunctionQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Group.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/GroupQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IDQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IteratorFilter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/LogicalExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/MergeFilterQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NamespaceQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NodeFunctions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumberFunctions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumericExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operand.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/OperandQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ParentQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Query.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ResetableIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ReversePositionQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Root.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/SortQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/StringFunctions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/UnionExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ValueQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Variable.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/VariableQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathArrayIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAxisIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathChildIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathDescendantIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathEmptyIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathMultyIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathParser.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathScanner.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelectionIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelfQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSingletonIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XmlIteratorQuery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/baseaxisquery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingquery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingsibling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingquery.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingsibling.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/querybuilder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathDocument.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathException.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathExpr.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathItem.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNamespaceScope.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorKeyComparer.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeIterator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlConvert.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNameTable.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceManager.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceScope.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlQualifiedName.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltArgumentList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltCommand.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltContext.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltSettings.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/AstTree.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BaseProcessor.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BitSet.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ChameleonKey.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/CompiledIdentityConstraint.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ConstraintStruct.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ContentValidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DatatypeImplementation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DtdParser.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/FacetChecker.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/GenerateConverter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/IXmlSchemaInfo.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/XmlSchemaInferenceException.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/infer.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/NamespaceList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Parser.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ParserAsync.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Preprocessor.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaAttDef.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaBuilder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionCompiler.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionPreprocessor.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaDeclBase.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaElementDecl.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaEntity.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaInfo.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNames.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNamespaceManager.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNotation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaSetCompiler.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventArgs.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventHandler.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XdrBuilder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlAtomicValue.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchema.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAll.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotated.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAny.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnyAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAppInfo.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroup.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroupRef.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaChoice.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCollection.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCompilationSettings.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContent.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentExtension.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentRestriction.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContent.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentModel.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentProcessing.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDatatype.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDerivationMethod.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDocumentation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaElement.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaException.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaExternal.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaFacet.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaForm.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroup.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupRef.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupbase.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaIdentityConstraint.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaImport.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInclude.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInfo.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaNotation.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObject.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectCollection.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectTable.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaParticle.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaRedefine.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSequence.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSet.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContent.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentExtension.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentRestriction.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeContent.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeList.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeRestriction.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeUnion.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSubstitutionGroup.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaUse.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidationException.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidity.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSeverityType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTokenizedType.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTypeCode.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlValueConverter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdBuilder.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDateTime.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDuration.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/autovalidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/basevalidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/dtdvalidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/validationstate.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xdrvalidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xsdvalidator.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IXmlDictionary.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/PrefixHandle.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/StringHandle.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/UniqueId.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ValueHandle.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReaderSession.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriterSession.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBufferReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionary.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReaderQuotas.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryString.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryWriter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextReader.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextWriter.cs diff --git a/src/dotnet-svcutil/lib/src/CodeDomFixup/ArrayOfXElementTypeHelper.cs b/src/dotnet-svcutil/lib/src/CodeDomFixup/ArrayOfXElementTypeHelper.cs index e8fd091aa64..982c329a7c3 100644 --- a/src/dotnet-svcutil/lib/src/CodeDomFixup/ArrayOfXElementTypeHelper.cs +++ b/src/dotnet-svcutil/lib/src/CodeDomFixup/ArrayOfXElementTypeHelper.cs @@ -134,13 +134,13 @@ private static CodeTypeDeclaration CreateArrayOfXmlElementClass(CodeNamespace ns classToGen.IsPartial = true; classToGen.TypeAttributes = s_isInternal ? TypeAttributes.NotPublic : TypeAttributes.Public; - CodeAttributeDeclaration xmlSchemaProviderAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(Microsoft.Xml.Serialization.XmlSchemaProviderAttribute)), + CodeAttributeDeclaration xmlSchemaProviderAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(System.Xml.Serialization.XmlSchemaProviderAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(null)), new CodeAttributeArgument("IsAny", new CodePrimitiveExpression(true))); classToGen.CustomAttributes.Add(xmlSchemaProviderAttribute); classToGen.BaseTypes.Add(new CodeTypeReference(typeof(Object))); - classToGen.BaseTypes.Add(new CodeTypeReference(typeof(Microsoft.Xml.Serialization.IXmlSerializable))); + classToGen.BaseTypes.Add(new CodeTypeReference(typeof(System.Xml.Serialization.IXmlSerializable))); CodeConstructor ctor = new CodeConstructor(); ctor.Attributes = MemberAttributes.Public; @@ -191,7 +191,7 @@ private static void AddGetSchemaMethod(CodeTypeDeclaration classToGen) getSchemaMethod.Attributes = MemberAttributes.Public; getSchemaMethod.Name = "GetSchema"; getSchemaMethod.ImplementationTypes.Add(classToGen.BaseTypes[1]); - getSchemaMethod.ReturnType = new CodeTypeReference(typeof(Microsoft.Xml.Schema.XmlSchema)); + getSchemaMethod.ReturnType = new CodeTypeReference(typeof(System.Xml.Schema.XmlSchema)); CodeThrowExceptionStatement throwException = new CodeThrowExceptionStatement( new CodeObjectCreateExpression( @@ -209,7 +209,7 @@ private static void AddWriteXml(CodeTypeDeclaration classToGen) writeXml.Attributes = MemberAttributes.Public; writeXml.ImplementationTypes.Add(classToGen.BaseTypes[1]); - writeXml.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(Microsoft.Xml.XmlWriter)), "writer")); + writeXml.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(System.Xml.XmlWriter)), "writer")); CodeVariableDeclarationStatement enumeratorDec = new CodeVariableDeclarationStatement( CreateTypeReference("System.Collections.Generic.IEnumerator`1", xelementType), "e", @@ -219,7 +219,7 @@ private static void AddWriteXml(CodeTypeDeclaration classToGen) CodeVariableReferenceExpression eRef = new CodeVariableReferenceExpression("e"); CodePropertyReferenceExpression eCurrent = new CodePropertyReferenceExpression(eRef, "Current"); - CodeCastExpression iXmlSerCast = new CodeCastExpression(new CodeTypeReference(typeof(Microsoft.Xml.Serialization.IXmlSerializable)), eCurrent); + CodeCastExpression iXmlSerCast = new CodeCastExpression(new CodeTypeReference(typeof(System.Xml.Serialization.IXmlSerializable)), eCurrent); CodeMethodInvokeExpression codeWrite = new CodeMethodInvokeExpression(iXmlSerCast, "WriteXml", new CodeVariableReferenceExpression("writer")); CodeIterationStatement codeFor = new CodeIterationStatement(); @@ -240,11 +240,11 @@ private static void AddReadXml(CodeTypeDeclaration classToGen) readXml.Attributes = MemberAttributes.Public; readXml.ImplementationTypes.Add(classToGen.BaseTypes[1]); - readXml.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(Microsoft.Xml.XmlReader)), "reader")); + readXml.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(System.Xml.XmlReader)), "reader")); CodeVariableReferenceExpression reader = new CodeVariableReferenceExpression("reader"); CodePropertyReferenceExpression readerNodeType = new CodePropertyReferenceExpression(reader, "NodeType"); - CodeTypeReferenceExpression xmlNodeType = new CodeTypeReferenceExpression(typeof(Microsoft.Xml.XmlNodeType)); + CodeTypeReferenceExpression xmlNodeType = new CodeTypeReferenceExpression(typeof(System.Xml.XmlNodeType)); CodePropertyReferenceExpression xmlNodeTypeEndElement = new CodePropertyReferenceExpression(xmlNodeType, "EndElement"); CodeBinaryOperatorExpression notEq = new CodeBinaryOperatorExpression(readerNodeType, CodeBinaryOperatorType.IdentityInequality, xmlNodeTypeEndElement); @@ -261,7 +261,7 @@ private static void AddReadXml(CodeTypeDeclaration classToGen) new CodeTypeReference(xelementType), "elem", new CodeObjectCreateExpression(new CodeTypeReference(xelementType), new CodePrimitiveExpression("default"))); - CodeCastExpression iXmlSerCast = new CodeCastExpression(new CodeTypeReference(typeof(Microsoft.Xml.Serialization.IXmlSerializable)), new CodeVariableReferenceExpression("elem")); + CodeCastExpression iXmlSerCast = new CodeCastExpression(new CodeTypeReference(typeof(System.Xml.Serialization.IXmlSerializable)), new CodeVariableReferenceExpression("elem")); CodeMethodInvokeExpression codeRead = new CodeMethodInvokeExpression(iXmlSerCast, "ReadXml", new CodeVariableReferenceExpression("reader")); diff --git a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/NamespaceFixer.cs b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/NamespaceFixer.cs index 5538540d974..4c4fb3309e5 100644 --- a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/NamespaceFixer.cs +++ b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/NamespaceFixer.cs @@ -11,25 +11,12 @@ namespace Microsoft.Tools.ServiceModel.Svcutil { internal class NamespaceFixup : CodeDomVisitor { - private static string s_microsoftXml = "Microsoft.Xml"; - private static string s_systemXml = "System.Xml"; private static string s_microsoftCodeDom = "Microsoft.CodeDom"; private static string s_systemCodeDom = "System.CodeDom"; - private Dictionary _xmlTypes = new Dictionary(); private Dictionary _codeDomTypes = new Dictionary(); public NamespaceFixup() { - // Microsoft.Xml.dll - var msxmlTypes = TypeLoader.LoadTypes(typeof(Microsoft.Xml.XmlDocument).GetTypeInfo().Assembly, Verbosity.Silent); - foreach (var type in msxmlTypes) - { - if (type.FullName.Contains(s_microsoftXml)) - { - _xmlTypes[type.FullName] = type; - } - } - // Microsoft.CodeDom var mscodedomTypes = TypeLoader.LoadTypes(typeof(Microsoft.CodeDom.CodeObject).GetTypeInfo().Assembly, Verbosity.Silent); @@ -45,10 +32,6 @@ public NamespaceFixup() protected override void Visit(CodeAttributeDeclaration attr) { base.Visit(attr); - if (attr.Name.Contains(s_microsoftXml) && _xmlTypes.ContainsKey(attr.Name)) - { - attr.Name = attr.Name.Replace(s_microsoftXml, s_systemXml); - } if (attr.Name.Contains(s_microsoftCodeDom) && _codeDomTypes.ContainsKey(attr.Name)) { attr.Name = attr.Name.Replace(s_microsoftCodeDom, s_systemCodeDom); @@ -58,10 +41,6 @@ protected override void Visit(CodeAttributeDeclaration attr) protected override void Visit(CodeComment comment) { base.Visit(comment); - if (comment.Text.Contains(s_microsoftXml) && _xmlTypes.ContainsKey(comment.Text)) - { - comment.Text = comment.Text.Replace(s_microsoftXml, s_systemXml); - } if (comment.Text.Contains(s_microsoftCodeDom) && _codeDomTypes.ContainsKey(comment.Text)) { comment.Text = comment.Text.Replace(s_microsoftCodeDom, s_systemCodeDom); @@ -71,10 +50,6 @@ protected override void Visit(CodeComment comment) protected override void Visit(CodeTypeReference typeref) { base.Visit(typeref); - if (typeref.BaseType.Contains(s_microsoftXml) && _xmlTypes.ContainsKey(typeref.BaseType)) - { - typeref.BaseType = typeref.BaseType.Replace(s_microsoftXml, s_systemXml); - } if (typeref.BaseType.Contains(s_microsoftCodeDom) && _codeDomTypes.ContainsKey(typeref.BaseType)) { typeref.BaseType = typeref.BaseType.Replace(s_microsoftCodeDom, s_systemCodeDom); diff --git a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/SpecialIXmlSerializableRemapper.cs b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/SpecialIXmlSerializableRemapper.cs index c752a2572bc..dc83304a400 100644 --- a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/SpecialIXmlSerializableRemapper.cs +++ b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/SpecialIXmlSerializableRemapper.cs @@ -72,7 +72,7 @@ private static bool IsIXmlSerializableType(CodeTypeDeclaration typeDecl) { foreach (CodeTypeReference typeRef in typeDecl.BaseTypes) { - if (CodeDomHelpers.MatchType(typeRef)) + if (CodeDomHelpers.MatchType(typeRef)) return true; } return false; diff --git a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/XmlDomAttributeFixer.cs b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/XmlDomAttributeFixer.cs index 75d4ba97077..ffa344ce57a 100644 --- a/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/XmlDomAttributeFixer.cs +++ b/src/dotnet-svcutil/lib/src/CodeDomFixup/CodeDomVisitors/XmlDomAttributeFixer.cs @@ -10,7 +10,7 @@ namespace Microsoft.Tools.ServiceModel.Svcutil internal class XmlDomAttributeFixer : CodeDomVisitor { // removes members of the affected type - private static readonly Type[] s_filteredTypes = new Type[] { typeof(Microsoft.Xml.XmlAttribute), }; + private static readonly Type[] s_filteredTypes = new Type[] { typeof(System.Xml.XmlAttribute), }; protected override void Visit(CodeTypeDeclaration type) { base.Visit(type); diff --git a/src/dotnet-svcutil/lib/src/CodeDomFixup/MethodCreationHelper.cs b/src/dotnet-svcutil/lib/src/CodeDomFixup/MethodCreationHelper.cs index 9cfa4aaaad6..7f5fd303dde 100644 --- a/src/dotnet-svcutil/lib/src/CodeDomFixup/MethodCreationHelper.cs +++ b/src/dotnet-svcutil/lib/src/CodeDomFixup/MethodCreationHelper.cs @@ -12,7 +12,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace Microsoft.Tools.ServiceModel.Svcutil { diff --git a/src/dotnet-svcutil/lib/src/CodeSerializer.cs b/src/dotnet-svcutil/lib/src/CodeSerializer.cs index f4dc06fe021..c86fb5f666f 100644 --- a/src/dotnet-svcutil/lib/src/CodeSerializer.cs +++ b/src/dotnet-svcutil/lib/src/CodeSerializer.cs @@ -11,8 +11,8 @@ using System.Linq; using System.ServiceModel.Description; using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using WsdlNS = System.Web.Services.Description; namespace Microsoft.Tools.ServiceModel.Svcutil diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/External/Extensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/External/Extensions.cs index 5b352761a8e..d1e776ec21c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/External/Extensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/External/Extensions.cs @@ -5,7 +5,7 @@ using System.IO; using System.Reflection; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/AsyncHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/AsyncHelper.cs index 1b7139879f1..b3846402ae6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/AsyncHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/AsyncHelper.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Decoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Decoder.cs deleted file mode 100644 index e1af019c54a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Decoder.cs +++ /dev/null @@ -1,240 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - - internal class Base64Decoder : IncrementalReadDecoder - { - // - // Fields - // - private byte[] _buffer; - private int _startIndex; - private int _curIndex; - private int _endIndex; - - private int _bits; - private int _bitsFilled; - - private static readonly String s_charsBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - private static readonly byte[] s_mapBase64 = ConstructMapBase64(); - private const int MaxValidChar = (int)'z'; - private const byte Invalid = unchecked((byte)-1); - - // - // IncrementalReadDecoder interface - // - internal override int DecodedCount - { - get - { - return _curIndex - _startIndex; - } - } - - internal override bool IsFull - { - get - { - return _curIndex == _endIndex; - } - } - - internal override unsafe int Decode(char[] chars, int startPos, int len) - { - if (chars == null) - { - throw new ArgumentNullException("chars"); - } - if (len < 0) - { - throw new ArgumentOutOfRangeException("len"); - } - if (startPos < 0) - { - throw new ArgumentOutOfRangeException("startPos"); - } - if (chars.Length - startPos < len) - { - throw new ArgumentOutOfRangeException("len"); - } - - if (len == 0) - { - return 0; - } - int bytesDecoded, charsDecoded; - fixed (char* pChars = &chars[startPos]) - { - fixed (byte* pBytes = &_buffer[_curIndex]) - { - Decode(pChars, pChars + len, pBytes, pBytes + (_endIndex - _curIndex), out charsDecoded, out bytesDecoded); - } - } - _curIndex += bytesDecoded; - return charsDecoded; - } - - internal override unsafe int Decode(string str, int startPos, int len) - { - if (str == null) - { - throw new ArgumentNullException("str"); - } - if (len < 0) - { - throw new ArgumentOutOfRangeException("len"); - } - if (startPos < 0) - { - throw new ArgumentOutOfRangeException("startPos"); - } - if (str.Length - startPos < len) - { - throw new ArgumentOutOfRangeException("len"); - } - - if (len == 0) - { - return 0; - } - int bytesDecoded, charsDecoded; - fixed (char* pChars = str) - { - fixed (byte* pBytes = &_buffer[_curIndex]) - { - Decode(pChars + startPos, pChars + startPos + len, pBytes, pBytes + (_endIndex - _curIndex), out charsDecoded, out bytesDecoded); - } - } - _curIndex += bytesDecoded; - return charsDecoded; - } - - internal override void Reset() - { - _bitsFilled = 0; - _bits = 0; - } - - internal override void SetNextOutputBuffer(Array buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(count >= 0); - Debug.Assert(index >= 0); - Debug.Assert(buffer.Length - index >= count); - Debug.Assert((buffer as byte[]) != null); - - _buffer = (byte[])buffer; - _startIndex = index; - _curIndex = index; - _endIndex = index + count; - } - - // - // Private methods - // - private static byte[] ConstructMapBase64() - { - byte[] mapBase64 = new byte[MaxValidChar + 1]; - for (int i = 0; i < mapBase64.Length; i++) - { - mapBase64[i] = Invalid; - } - for (int i = 0; i < s_charsBase64.Length; i++) - { - mapBase64[(int)s_charsBase64[i]] = (byte)i; - } - return mapBase64; - } - - private unsafe void Decode(char* pChars, char* pCharsEndPos, - byte* pBytes, byte* pBytesEndPos, - out int charsDecoded, out int bytesDecoded) - { -#if DEBUG - Debug.Assert(pCharsEndPos - pChars >= 0); - Debug.Assert(pBytesEndPos - pBytes >= 0); -#endif - - // walk hex digits pairing them up and shoving the value of each pair into a byte - byte* pByte = pBytes; - char* pChar = pChars; - int b = _bits; - int bFilled = _bitsFilled; - XmlCharType xmlCharType = XmlCharType.Instance; - while (pChar < pCharsEndPos && pByte < pBytesEndPos) - { - char ch = *pChar; - // end? - if (ch == '=') - { - break; - } - pChar++; - - // ignore white space - if ((xmlCharType.charProperties[ch] & XmlCharType.fWhitespace) != 0) - { // if ( xmlCharType.IsWhiteSpace(ch) ) { - continue; - } - - int digit; - if (ch > 122 || (digit = s_mapBase64[ch]) == Invalid) - { - throw new XmlException(ResXml.Xml_InvalidBase64Value, new string(pChars, 0, (int)(pCharsEndPos - pChars))); - } - - b = (b << 6) | digit; - bFilled += 6; - - if (bFilled >= 8) - { - // get top eight valid bits - *pByte++ = (byte)((b >> (bFilled - 8)) & 0xFF); - bFilled -= 8; - - if (pByte == pBytesEndPos) - { - goto Return; - } - } - } - - if (pChar < pCharsEndPos && *pChar == '=') - { - bFilled = 0; - // ignore padding chars - do - { - pChar++; - } while (pChar < pCharsEndPos && *pChar == '='); - - // ignore whitespace after the padding chars - if (pChar < pCharsEndPos) - { - do - { - if (!((xmlCharType.charProperties[*pChar++] & XmlCharType.fWhitespace) != 0)) - { // if ( !( xmlCharType.IsWhiteSpace( chars[charPos++] ) ) ) { - throw new XmlException(ResXml.Xml_InvalidBase64Value, new string(pChars, 0, (int)(pCharsEndPos - pChars))); - } - } while (pChar < pCharsEndPos); - } - } - - Return: - _bits = b; - _bitsFilled = bFilled; - - bytesDecoded = (int)(pByte - pBytes); - charsDecoded = (int)(pChar - pChars); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Encoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Encoder.cs deleted file mode 100644 index 142208825a0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Base64Encoder.cs +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System.Text; -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - - internal abstract partial class Base64Encoder - { - private byte[] _leftOverBytes; - private int _leftOverBytesCount; - private char[] _charsLine; - - internal const int Base64LineSize = 76; - internal const int LineSizeInBytes = Base64LineSize / 4 * 3; - - internal Base64Encoder() - { - _charsLine = new char[Base64LineSize]; - } - - internal abstract void WriteChars(char[] chars, int index, int count); - - internal void Encode(byte[] buffer, int index, int count) - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - // encode left-over buffer - if (_leftOverBytesCount > 0) - { - int i = _leftOverBytesCount; - while (i < 3 && count > 0) - { - _leftOverBytes[i++] = buffer[index++]; - count--; - } - - // the total number of buffer we have is less than 3 -> return - if (count == 0 && i < 3) - { - _leftOverBytesCount = i; - return; - } - - // encode the left-over buffer and write out - int leftOverChars = Convert.ToBase64CharArray(_leftOverBytes, 0, 3, _charsLine, 0); - WriteChars(_charsLine, 0, leftOverChars); - } - - // store new left-over buffer - _leftOverBytesCount = count % 3; - if (_leftOverBytesCount > 0) - { - count -= _leftOverBytesCount; - if (_leftOverBytes == null) - { - _leftOverBytes = new byte[3]; - } - for (int i = 0; i < _leftOverBytesCount; i++) - { - _leftOverBytes[i] = buffer[index + count + i]; - } - } - - // encode buffer in 76 character long chunks - int endIndex = index + count; - int chunkSize = LineSizeInBytes; - while (index < endIndex) - { - if (index + chunkSize > endIndex) - { - chunkSize = endIndex - index; - } - int charCount = Convert.ToBase64CharArray(buffer, index, chunkSize, _charsLine, 0); - WriteChars(_charsLine, 0, charCount); - - index += chunkSize; - } - } - - internal void Flush() - { - if (_leftOverBytesCount > 0) - { - int leftOverChars = Convert.ToBase64CharArray(_leftOverBytes, 0, _leftOverBytesCount, _charsLine, 0); - WriteChars(_charsLine, 0, leftOverChars); - _leftOverBytesCount = 0; - } - } - } - - internal partial class XmlRawWriterBase64Encoder : Base64Encoder - { - private XmlRawWriter _rawWriter; - - internal XmlRawWriterBase64Encoder(XmlRawWriter rawWriter) - { - _rawWriter = rawWriter; - } - - internal override void WriteChars(char[] chars, int index, int count) - { - _rawWriter.WriteRaw(chars, index, count); - } - } - - internal partial class XmlTextWriterBase64Encoder : Base64Encoder - { - private XmlTextEncoder _xmlTextEncoder; - - internal XmlTextWriterBase64Encoder(XmlTextEncoder xmlTextEncoder) - { - _xmlTextEncoder = xmlTextEncoder; - } - - internal override void WriteChars(char[] chars, int index, int count) - { - _xmlTextEncoder.WriteRaw(chars, index, count); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexDecoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexDecoder.cs deleted file mode 100644 index 02b8655c96d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexDecoder.cs +++ /dev/null @@ -1,238 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - internal class BinHexDecoder : IncrementalReadDecoder - { - // - // Fields - // - private byte[] _buffer; - private int _startIndex; - private int _curIndex; - private int _endIndex; - private bool _hasHalfByteCached; - private byte _cachedHalfByte; - - // - // IncrementalReadDecoder interface - // - internal override int DecodedCount - { - get - { - return _curIndex - _startIndex; - } - } - - internal override bool IsFull - { - get - { - return _curIndex == _endIndex; - } - } - - internal override unsafe int Decode(char[] chars, int startPos, int len) - { - if (chars == null) - { - throw new ArgumentNullException("chars"); - } - if (len < 0) - { - throw new ArgumentOutOfRangeException("len"); - } - if (startPos < 0) - { - throw new ArgumentOutOfRangeException("startPos"); - } - if (chars.Length - startPos < len) - { - throw new ArgumentOutOfRangeException("len"); - } - - if (len == 0) - { - return 0; - } - int bytesDecoded, charsDecoded; - fixed (char* pChars = &chars[startPos]) - { - fixed (byte* pBytes = &_buffer[_curIndex]) - { - Decode(pChars, pChars + len, pBytes, pBytes + (_endIndex - _curIndex), - ref _hasHalfByteCached, ref _cachedHalfByte, out charsDecoded, out bytesDecoded); - } - } - _curIndex += bytesDecoded; - return charsDecoded; - } - - internal override unsafe int Decode(string str, int startPos, int len) - { - if (str == null) - { - throw new ArgumentNullException("str"); - } - if (len < 0) - { - throw new ArgumentOutOfRangeException("len"); - } - if (startPos < 0) - { - throw new ArgumentOutOfRangeException("startPos"); - } - if (str.Length - startPos < len) - { - throw new ArgumentOutOfRangeException("len"); - } - - if (len == 0) - { - return 0; - } - int bytesDecoded, charsDecoded; - fixed (char* pChars = str) - { - fixed (byte* pBytes = &_buffer[_curIndex]) - { - Decode(pChars + startPos, pChars + startPos + len, pBytes, pBytes + (_endIndex - _curIndex), - ref _hasHalfByteCached, ref _cachedHalfByte, out charsDecoded, out bytesDecoded); - } - } - _curIndex += bytesDecoded; - return charsDecoded; - } - - internal override void Reset() - { - _hasHalfByteCached = false; - _cachedHalfByte = 0; - } - - internal override void SetNextOutputBuffer(Array buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(count >= 0); - Debug.Assert(index >= 0); - Debug.Assert(buffer.Length - index >= count); - Debug.Assert((buffer as byte[]) != null); - - _buffer = (byte[])buffer; - _startIndex = index; - _curIndex = index; - _endIndex = index + count; - } - - // - // Static methods - // - public static unsafe byte[] Decode(char[] chars, bool allowOddChars) - { - if (chars == null) - { - throw new ArgumentNullException("chars"); - } - - int len = chars.Length; - if (len == 0) - { - return new byte[0]; - } - - byte[] bytes = new byte[(len + 1) / 2]; - int bytesDecoded, charsDecoded; - bool hasHalfByteCached = false; - byte cachedHalfByte = 0; - - fixed (char* pChars = &chars[0]) - { - fixed (byte* pBytes = &bytes[0]) - { - Decode(pChars, pChars + len, pBytes, pBytes + bytes.Length, ref hasHalfByteCached, ref cachedHalfByte, out charsDecoded, out bytesDecoded); - } - } - - if (hasHalfByteCached && !allowOddChars) - { - throw new XmlException(ResXml.Xml_InvalidBinHexValueOddCount, new string(chars)); - } - - if (bytesDecoded < bytes.Length) - { - byte[] tmp = new byte[bytesDecoded]; - Array.Copy(bytes, 0, tmp, 0, bytesDecoded); - bytes = tmp; - } - - return bytes; - } - - // - // Private methods - // - - private static unsafe void Decode(char* pChars, char* pCharsEndPos, - byte* pBytes, byte* pBytesEndPos, - ref bool hasHalfByteCached, ref byte cachedHalfByte, - out int charsDecoded, out int bytesDecoded) - { -#if DEBUG - Debug.Assert(pCharsEndPos - pChars >= 0); - Debug.Assert(pBytesEndPos - pBytes >= 0); -#endif - - char* pChar = pChars; - byte* pByte = pBytes; - XmlCharType xmlCharType = XmlCharType.Instance; - while (pChar < pCharsEndPos && pByte < pBytesEndPos) - { - byte halfByte; - char ch = *pChar++; - - if (ch >= 'a' && ch <= 'f') - { - halfByte = (byte)(ch - 'a' + 10); - } - else if (ch >= 'A' && ch <= 'F') - { - halfByte = (byte)(ch - 'A' + 10); - } - else if (ch >= '0' && ch <= '9') - { - halfByte = (byte)(ch - '0'); - } - else if ((xmlCharType.charProperties[ch] & XmlCharType.fWhitespace) != 0) - { // else if ( xmlCharType.IsWhiteSpace( ch ) ) { - continue; - } - else - { - throw new XmlException(ResXml.Xml_InvalidBinHexValue, new string(pChars, 0, (int)(pCharsEndPos - pChars))); - } - - if (hasHalfByteCached) - { - *pByte++ = (byte)((cachedHalfByte << 4) + halfByte); - hasHalfByteCached = false; - } - else - { - cachedHalfByte = halfByte; - hasHalfByteCached = true; - } - } - - bytesDecoded = (int)(pByte - pBytes); - charsDecoded = (int)(pChar - pChars); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexEncoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexEncoder.cs deleted file mode 100644 index 3209909779a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinHexEncoder.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml -{ - using System; - - internal static partial class BinHexEncoder - { - private const string s_hexDigits = "0123456789ABCDEF"; - private const int CharsChunkSize = 128; - - internal static void Encode(byte[] buffer, int index, int count, XmlWriter writer) - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - char[] chars = new char[(count * 2) < CharsChunkSize ? (count * 2) : CharsChunkSize]; - int endIndex = index + count; - while (index < endIndex) - { - int cnt = (count < CharsChunkSize / 2) ? count : CharsChunkSize / 2; - int charCount = Encode(buffer, index, cnt, chars); - writer.WriteRaw(chars, 0, charCount); - index += cnt; - count -= cnt; - } - } - - internal static string Encode(byte[] inArray, int offsetIn, int count) - { - if (null == inArray) - { - throw new ArgumentNullException("inArray"); - } - if (0 > offsetIn) - { - throw new ArgumentOutOfRangeException("offsetIn"); - } - if (0 > count) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > inArray.Length - offsetIn) - { - throw new ArgumentOutOfRangeException("count"); - } - - char[] outArray = new char[2 * count]; - int lenOut = Encode(inArray, offsetIn, count, outArray); - return new String(outArray, 0, lenOut); - } - - private static int Encode(byte[] inArray, int offsetIn, int count, char[] outArray) - { - int curOffsetOut = 0, offsetOut = 0; - byte b; - int lengthOut = outArray.Length; - - for (int j = 0; j < count; j++) - { - b = inArray[offsetIn++]; - outArray[curOffsetOut++] = s_hexDigits[b >> 4]; - if (curOffsetOut == lengthOut) - { - break; - } - outArray[curOffsetOut++] = s_hexDigits[b & 0xF]; - if (curOffsetOut == lengthOut) - { - break; - } - } - return curOffsetOut - offsetOut; - } // function - } // class -} // namespace diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/BinXmlToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/BinXmlToken.cs deleted file mode 100644 index 126599947e7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/BinXmlToken.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - /* These are the tokens used by the Yukon BinaryXml protocol */ - internal enum BinXmlToken - { - Error = 0, - NotImpl = -2, - EOF = -1, - XmlDecl = 0xFE, - Encoding = 0xFD, - DocType = 0xFC, - System = 0xFB, - Public = 0xFA, - Subset = 0xF9, - Element = 0xF8, - EndElem = 0xF7, - Attr = 0xF6, - EndAttrs = 0xF5, - PI = 0xF4, - Comment = 0xF3, - CData = 0xF2, - EndCData = 0xF1, - Name = 0xF0, - QName = 0xEF, - XmlText = 0xED, - Nest = 0xEC, - EndNest = 0xEB, - Extn = 0xEA, - NmFlush = 0xE9, - SQL_BIT = 0x06, - SQL_TINYINT = 0x07, - SQL_SMALLINT = 0x1, - SQL_INT = 0x02, - SQL_BIGINT = 0x08, - SQL_REAL = 0x03, - SQL_FLOAT = 0x04, - SQL_MONEY = 0x05, - SQL_SMALLMONEY = 0x14, - SQL_DATETIME = 0x12, - SQL_SMALLDATETIME = 0x13, - SQL_DECIMAL = 0x0A, - SQL_NUMERIC = 0x0B, - SQL_UUID = 0x09, - SQL_VARBINARY = 0x0F, - SQL_BINARY = 0x0C, - SQL_IMAGE = 0x17, - SQL_CHAR = 0x0D, - SQL_VARCHAR = 0x10, - SQL_TEXT = 0x16, - SQL_NVARCHAR = 0x11, - SQL_NCHAR = 0x0E, - SQL_NTEXT = 0x18, - SQL_UDT = 0x1B, - XSD_KATMAI_DATE = 0x7F, - XSD_KATMAI_DATETIME = 0x7E, - XSD_KATMAI_TIME = 0x7D, - XSD_KATMAI_DATEOFFSET = 0x7C, - XSD_KATMAI_DATETIMEOFFSET = 0x7B, - XSD_KATMAI_TIMEOFFSET = 0x7A, - XSD_BOOLEAN = 0x86, - XSD_TIME = 0x81, - XSD_DATETIME = 0x82, - XSD_DATE = 0x83, - XSD_BINHEX = 0x84, - XSD_BASE64 = 0x85, - XSD_DECIMAL = 0x87, - XSD_BYTE = 0x88, - XSD_UNSIGNEDSHORT = 0x89, - XSD_UNSIGNEDINT = 0x8A, - XSD_UNSIGNEDLONG = 0x8B, - XSD_QNAME = 0x8C, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/SqlUtils.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/SqlUtils.cs deleted file mode 100644 index a471a4b48d3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/SqlUtils.cs +++ /dev/null @@ -1,1147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - // This is mostly just a copy of code in SqlTypes.SqlDecimal - internal struct BinXmlSqlDecimal - { - internal byte m_bLen; - internal byte m_bPrec; - internal byte m_bScale; - internal byte m_bSign; - internal uint m_data1; - internal uint m_data2; - internal uint m_data3; - internal uint m_data4; - - public bool IsPositive - { - get - { - return (m_bSign == 0); - } - } - - private static readonly byte s_NUMERIC_MAX_PRECISION = 38; // Maximum precision of numeric - private static readonly byte s_maxPrecision = s_NUMERIC_MAX_PRECISION; // max SS precision - private static readonly byte s_maxScale = s_NUMERIC_MAX_PRECISION; // max SS scale - - private static readonly int s_cNumeMax = 4; - private static readonly long s_lInt32Base = ((long)1) << 32; // 2**32 - private static readonly ulong s_ulInt32Base = ((ulong)1) << 32; // 2**32 - private static readonly ulong s_ulInt32BaseForMod = s_ulInt32Base - 1; // 2**32 - 1 (0xFFF...FF) - internal static readonly ulong x_llMax = Int64.MaxValue; // Max of Int64 - //private static readonly uint x_ulBase10 = 10; - private static readonly double s_DUINT_BASE = (double)s_lInt32Base; // 2**32 - private static readonly double s_DUINT_BASE2 = s_DUINT_BASE * s_DUINT_BASE; // 2**64 - private static readonly double s_DUINT_BASE3 = s_DUINT_BASE2 * s_DUINT_BASE; // 2**96 - //private static readonly double DMAX_NUME = 1.0e+38; // Max value of numeric - //private static readonly uint DBL_DIG = 17; // Max decimal digits of double - //private static readonly byte x_cNumeDivScaleMin = 6; // Minimum result scale of numeric division - // Array of multipliers for lAdjust and Ceiling/Floor. - private static readonly uint[] s_rgulShiftBase = new uint[9] { - 10, - 10 * 10, - 10 * 10 * 10, - 10 * 10 * 10 * 10, - 10 * 10 * 10 * 10 * 10, - 10 * 10 * 10 * 10 * 10 * 10, - 10 * 10 * 10 * 10 * 10 * 10 * 10, - 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10, - 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 - }; - - public BinXmlSqlDecimal(byte[] data, int offset, bool trim) - { - byte b = data[offset]; - switch (b) - { - case 7: m_bLen = 1; break; - case 11: m_bLen = 2; break; - case 15: m_bLen = 3; break; - case 19: m_bLen = 4; break; - default: throw new XmlException(ResXml.XmlBinary_InvalidSqlDecimal, (string[])null); - } - m_bPrec = data[offset + 1]; - m_bScale = data[offset + 2]; - m_bSign = 0 == data[offset + 3] ? (byte)1 : (byte)0; - m_data1 = UIntFromByteArray(data, offset + 4); - m_data2 = (m_bLen > 1) ? UIntFromByteArray(data, offset + 8) : 0; - m_data3 = (m_bLen > 2) ? UIntFromByteArray(data, offset + 12) : 0; - m_data4 = (m_bLen > 3) ? UIntFromByteArray(data, offset + 16) : 0; - if (m_bLen == 4 && m_data4 == 0) - m_bLen = 3; - if (m_bLen == 3 && m_data3 == 0) - m_bLen = 2; - if (m_bLen == 2 && m_data2 == 0) - m_bLen = 1; - AssertValid(); - if (trim) - { - TrimTrailingZeros(); - AssertValid(); - } - } - - public void Write(Stream strm) - { - strm.WriteByte((byte)(this.m_bLen * 4 + 3)); - strm.WriteByte(this.m_bPrec); - strm.WriteByte(this.m_bScale); - strm.WriteByte(0 == this.m_bSign ? (byte)1 : (byte)0); - WriteUI4(this.m_data1, strm); - if (this.m_bLen > 1) - { - WriteUI4(this.m_data2, strm); - if (this.m_bLen > 2) - { - WriteUI4(this.m_data3, strm); - if (this.m_bLen > 3) - { - WriteUI4(this.m_data4, strm); - } - } - } - } - - private void WriteUI4(uint val, Stream strm) - { - strm.WriteByte((byte)(val & 0xFF)); - strm.WriteByte((byte)((val >> 8) & 0xFF)); - strm.WriteByte((byte)((val >> 16) & 0xFF)); - strm.WriteByte((byte)((val >> 24) & 0xFF)); - } - - private static uint UIntFromByteArray(byte[] data, int offset) - { - int val = (data[offset]) << 0; - val |= (data[offset + 1]) << 8; - val |= (data[offset + 2]) << 16; - val |= (data[offset + 3]) << 24; - return unchecked((uint)val); - } - - // check whether is zero - private bool FZero() - { - return (m_data1 == 0) && (m_bLen <= 1); - } - // Store data back from rguiData[] to m_data* - private void StoreFromWorkingArray(uint[] rguiData) - { - Debug.Assert(rguiData.Length == 4); - m_data1 = rguiData[0]; - m_data2 = rguiData[1]; - m_data3 = rguiData[2]; - m_data4 = rguiData[3]; - } - - // Find the case where we overflowed 10**38, but not 2**128 - private bool FGt10_38(uint[] rglData) - { - //Debug.Assert(rglData.Length == 4, "rglData.Length == 4", "Wrong array length: " + rglData.Length.ToString()); - return rglData[3] >= 0x4b3b4ca8L && ((rglData[3] > 0x4b3b4ca8L) || (rglData[2] > 0x5a86c47aL) || (rglData[2] == 0x5a86c47aL) && (rglData[1] >= 0x098a2240L)); - } - - - // Multi-precision one super-digit divide in place. - // U = U / D, - // R = U % D - // Length of U can decrease - private static void MpDiv1(uint[] rgulU, // InOut| U - ref int ciulU, // InOut| # of digits in U - uint iulD, // In | D - out uint iulR // Out | R - ) - { - Debug.Assert(rgulU.Length == s_cNumeMax); - - uint ulCarry = 0; - ulong dwlAccum; - ulong ulD = (ulong)iulD; - int idU = ciulU; - - Debug.Assert(iulD != 0, "iulD != 0", "Divided by zero!"); - Debug.Assert(iulD > 0, "iulD > 0", "Invalid data: less than zero"); - Debug.Assert(ciulU > 0, "ciulU > 0", "No data in the array"); - while (idU > 0) - { - idU--; - dwlAccum = (((ulong)ulCarry) << 32) + (ulong)(rgulU[idU]); - rgulU[idU] = (uint)(dwlAccum / ulD); - ulCarry = (uint)(dwlAccum - (ulong)rgulU[idU] * ulD); // (ULONG) (dwlAccum % iulD) - } - - iulR = ulCarry; - MpNormalize(rgulU, ref ciulU); - } - // Normalize multi-precision number - remove leading zeroes - private static void MpNormalize(uint[] rgulU, // In | Number - ref int ciulU // InOut| # of digits - ) - { - while (ciulU > 1 && rgulU[ciulU - 1] == 0) - ciulU--; - } - - // AdjustScale() - // - // Adjust number of digits to the right of the decimal point. - // A positive adjustment increases the scale of the numeric value - // while a negative adjustment decreases the scale. When decreasing - // the scale for the numeric value, the remainder is checked and - // rounded accordingly. - // - internal void AdjustScale(int digits, bool fRound) - { - uint ulRem; //Remainder when downshifting - uint ulShiftBase; //What to multiply by to effect scale adjust - bool fNeedRound = false; //Do we really need to round? - byte bNewScale, bNewPrec; - int lAdjust = digits; - - //If downshifting causes truncation of data - if (lAdjust + m_bScale < 0) - throw new XmlException(ResXml.SqlTypes_ArithTruncation, (string)null); - - //If uphifting causes scale overflow - if (lAdjust + m_bScale > s_NUMERIC_MAX_PRECISION) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - bNewScale = (byte)(lAdjust + m_bScale); - bNewPrec = (byte)(Math.Min(s_NUMERIC_MAX_PRECISION, Math.Max(1, lAdjust + m_bPrec))); - if (lAdjust > 0) - { - m_bScale = bNewScale; - m_bPrec = bNewPrec; - while (lAdjust > 0) - { - //if lAdjust>=9, downshift by 10^9 each time, otherwise by the full amount - if (lAdjust >= 9) - { - ulShiftBase = s_rgulShiftBase[8]; - lAdjust -= 9; - } - else - { - ulShiftBase = s_rgulShiftBase[lAdjust - 1]; - lAdjust = 0; - } - - MultByULong(ulShiftBase); - } - } - else if (lAdjust < 0) - { - do - { - if (lAdjust <= -9) - { - ulShiftBase = s_rgulShiftBase[8]; - lAdjust += 9; - } - else - { - ulShiftBase = s_rgulShiftBase[-lAdjust - 1]; - lAdjust = 0; - } - - ulRem = DivByULong(ulShiftBase); - } while (lAdjust < 0); - - // Do we really need to round? - fNeedRound = (ulRem >= ulShiftBase / 2); - m_bScale = bNewScale; - m_bPrec = bNewPrec; - } - - AssertValid(); - - // After adjusting, if the result is 0 and remainder is less than 5, - // set the sign to be positive and return. - if (fNeedRound && fRound) - { - // If remainder is 5 or above, increment/decrement by 1. - AddULong(1); - } - else if (FZero()) - this.m_bSign = 0; - } - // AddULong() - // - // Add ulAdd to this numeric. The result will be returned in *this. - // - // Parameters: - // this - IN Operand1 & OUT Result - // ulAdd - IN operand2. - // - private void AddULong(uint ulAdd) - { - ulong dwlAccum = (ulong)ulAdd; - int iData; // which UI4 in this we are on - int iDataMax = (int)m_bLen; // # of UI4s in this - uint[] rguiData = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - - // Add, starting at the LS UI4 until out of UI4s or no carry - iData = 0; - do - { - dwlAccum += (ulong)rguiData[iData]; - rguiData[iData] = (uint)dwlAccum; // equivalent to mod x_dwlBaseUI4 - dwlAccum >>= 32; // equivalent to dwlAccum /= x_dwlBaseUI4; - if (0 == dwlAccum) - { - StoreFromWorkingArray(rguiData); - return; - } - - iData++; - } while (iData < iDataMax); - - // There is carry at the end - Debug.Assert(dwlAccum < s_ulInt32Base, "dwlAccum < x_lInt32Base", ""); - - // Either overflowed - if (iData == s_cNumeMax) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - // Or need to extend length by 1 UI4 - rguiData[iData] = (uint)dwlAccum; - m_bLen++; - if (FGt10_38(rguiData)) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - StoreFromWorkingArray(rguiData); - } - // multiply by a long integer - private void MultByULong(uint uiMultiplier) - { - int iDataMax = m_bLen; // How many UI4s currently in *this - ulong dwlAccum = 0; // accumulated sum - ulong dwlNextAccum = 0; // accumulation past dwlAccum - int iData; // which UI4 in *This we are on. - uint[] rguiData = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - - for (iData = 0; iData < iDataMax; iData++) - { - Debug.Assert(dwlAccum < s_ulInt32Base); - - ulong ulTemp = (ulong)rguiData[iData]; - - dwlNextAccum = ulTemp * (ulong)uiMultiplier; - dwlAccum += dwlNextAccum; - if (dwlAccum < dwlNextAccum) // Overflow of int64 add - dwlNextAccum = s_ulInt32Base; // how much to add to dwlAccum after div x_dwlBaseUI4 - else - dwlNextAccum = 0; - - rguiData[iData] = (uint)dwlAccum; // equivalent to mod x_dwlBaseUI4 - dwlAccum = (dwlAccum >> 32) + dwlNextAccum; // equivalent to div x_dwlBaseUI4 - } - - // If any carry, - if (dwlAccum != 0) - { - // Either overflowed - Debug.Assert(dwlAccum < s_ulInt32Base, "dwlAccum < x_dwlBaseUI4", "Integer overflow"); - if (iDataMax == s_cNumeMax) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - // Or extend length by one uint - rguiData[iDataMax] = (uint)dwlAccum; - m_bLen++; - } - - if (FGt10_38(rguiData)) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - StoreFromWorkingArray(rguiData); - } - // DivByULong() - // - // Divide numeric value by a ULONG. The result will be returned - // in the dividend *this. - // - // Parameters: - // this - IN Dividend & OUT Result - // ulDivisor - IN Divisor - // Returns: - OUT Remainder - // - internal uint DivByULong(uint iDivisor) - { - ulong dwlDivisor = (ulong)iDivisor; - ulong dwlAccum = 0; //Accumulated sum - uint ulQuotientCur = 0; // Value of the current UI4 of the quotient - bool fAllZero = true; // All of the quotient (so far) has been 0 - int iData; //Which UI4 currently on - - // Check for zero divisor. - if (dwlDivisor == 0) - throw new XmlException(ResXml.SqlTypes_DivideByZero, (string)null); - - // Copy into array, so that we can iterate through the data - uint[] rguiData = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - - // Start from the MS UI4 of quotient, divide by divisor, placing result - // in quotient and carrying the remainder. - //DEVNOTE DWORDLONG sufficient accumulator since: - // Accum < Divisor <= 2^32 - 1 at start each loop - // initially,and mod end previous loop - // Accum*2^32 < 2^64 - 2^32 - // multiply both side by 2^32 (x_dwlBaseUI4) - // Accum*2^32 + m_rgulData < 2^64 - // rglData < 2^32 - for (iData = m_bLen; iData > 0; iData--) - { - Debug.Assert(dwlAccum < dwlDivisor); - dwlAccum = (dwlAccum << 32) + (ulong)(rguiData[iData - 1]); // dwlA*x_dwlBaseUI4 + rglData - Debug.Assert((dwlAccum / dwlDivisor) < s_ulInt32Base); - - //Update dividend to the quotient. - ulQuotientCur = (uint)(dwlAccum / dwlDivisor); - rguiData[iData - 1] = ulQuotientCur; - - //Remainder to be carried to the next lower significant byte. - dwlAccum = dwlAccum % dwlDivisor; - - // While current part of quotient still 0, reduce length - fAllZero = fAllZero && (ulQuotientCur == 0); - if (fAllZero) - m_bLen--; - } - - StoreFromWorkingArray(rguiData); - - // If result is 0, preserve sign but set length to 5 - if (fAllZero) - m_bLen = 1; - - AssertValid(); - - // return the remainder - Debug.Assert(dwlAccum < s_ulInt32Base); - return (uint)dwlAccum; - } - - //Determine the number of uints needed for a numeric given a precision - //Precision Length - // 0 invalid - // 1-9 1 - // 10-19 2 - // 20-28 3 - // 29-38 4 - // The array in Shiloh. Listed here for comparison. - //private static readonly byte[] rgCLenFromPrec = new byte[] {5,5,5,5,5,5,5,5,5,9,9,9,9,9, - // 9,9,9,9,9,13,13,13,13,13,13,13,13,13,17,17,17,17,17,17,17,17,17,17}; - private static readonly byte[] s_rgCLenFromPrec = new byte[] { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 - }; - private static byte CLenFromPrec(byte bPrec) - { - Debug.Assert(bPrec <= s_maxPrecision && bPrec > 0, "bPrec <= MaxPrecision && bPrec > 0", "Invalid numeric precision"); - return s_rgCLenFromPrec[bPrec - 1]; - } - - private static char ChFromDigit(uint uiDigit) - { - Debug.Assert(uiDigit < 10); - return (char)(uiDigit + '0'); - } - - public Decimal ToDecimal() - { - if ((int)m_data4 != 0 || m_bScale > 28) - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - - return new Decimal((int)m_data1, (int)m_data2, (int)m_data3, !IsPositive, m_bScale); - } - - private void TrimTrailingZeros() - { - uint[] rgulNumeric = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - int culLen = m_bLen; - uint ulRem; //Remainder of a division by x_ulBase10, i.e.,least significant digit - - // special-case 0 - if (culLen == 1 && rgulNumeric[0] == 0) - { - m_bScale = 0; - return; - } - - while (m_bScale > 0 && (culLen > 1 || rgulNumeric[0] != 0)) - { - MpDiv1(rgulNumeric, ref culLen, 10, out ulRem); - if (ulRem == 0) - { - m_data1 = rgulNumeric[0]; - m_data2 = rgulNumeric[1]; - m_data3 = rgulNumeric[2]; - m_data4 = rgulNumeric[3]; - m_bScale--; - } - else - { - break; - } - } - if (m_bLen == 4 && m_data4 == 0) - m_bLen = 3; - if (m_bLen == 3 && m_data3 == 0) - m_bLen = 2; - if (m_bLen == 2 && m_data2 == 0) - m_bLen = 1; - } - - public override String ToString() - { - AssertValid(); - - // Make local copy of data to avoid modifying input. - uint[] rgulNumeric = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - int culLen = m_bLen; - char[] pszTmp = new char[s_NUMERIC_MAX_PRECISION + 1]; //Local Character buffer to hold - //the decimal digits, from the - //lowest significant to highest significant - - int iDigits = 0;//Number of significant digits - uint ulRem; //Remainder of a division by x_ulBase10, i.e.,least significant digit - - // Build the final numeric string by inserting the sign, reversing - // the order and inserting the decimal number at the correct position - - //Retrieve each digit from the lowest significant digit - while (culLen > 1 || rgulNumeric[0] != 0) - { - MpDiv1(rgulNumeric, ref culLen, 10, out ulRem); - //modulo x_ulBase10 is the lowest significant digit - pszTmp[iDigits++] = ChFromDigit(ulRem); - } - - // if scale of the number has not been - // reached pad remaining number with zeros. - while (iDigits <= m_bScale) - { - pszTmp[iDigits++] = ChFromDigit(0); - } - - bool fPositive = IsPositive; - - // Increment the result length if negative (need to add '-') - int uiResultLen = fPositive ? iDigits : iDigits + 1; - - // Increment the result length if scale > 0 (need to add '.') - if (m_bScale > 0) - uiResultLen++; - - char[] szResult = new char[uiResultLen]; - int iCurChar = 0; - - if (!fPositive) - szResult[iCurChar++] = '-'; - - while (iDigits > 0) - { - if (iDigits-- == m_bScale) - szResult[iCurChar++] = '.'; - szResult[iCurChar++] = pszTmp[iDigits]; - } - - AssertValid(); - - return new String(szResult); - } - - - // Is this RE numeric valid? - [System.Diagnostics.Conditional("DEBUG")] - private void AssertValid() - { - // Scale,Prec in range - Debug.Assert(m_bScale <= s_NUMERIC_MAX_PRECISION, "m_bScale <= NUMERIC_MAX_PRECISION", "In AssertValid"); - Debug.Assert(m_bScale <= m_bPrec, "m_bScale <= m_bPrec", "In AssertValid"); - Debug.Assert(m_bScale >= 0, "m_bScale >= 0", "In AssertValid"); - Debug.Assert(m_bPrec > 0, "m_bPrec > 0", "In AssertValid"); - Debug.Assert(CLenFromPrec(m_bPrec) >= m_bLen, "CLenFromPrec(m_bPrec) >= m_bLen", "In AssertValid"); - Debug.Assert(m_bLen <= s_cNumeMax, "m_bLen <= x_cNumeMax", "In AssertValid"); - - uint[] rglData = new uint[4] { m_data1, m_data2, m_data3, m_data4 }; - - // highest UI4 is non-0 unless value "zero" - if (rglData[m_bLen - 1] == 0) - { - Debug.Assert(m_bLen == 1, "m_bLen == 1", "In AssertValid"); - } - - // All UI4s from length to end are 0 - for (int iulData = m_bLen; iulData < s_cNumeMax; iulData++) - Debug.Assert(rglData[iulData] == 0, "rglData[iulData] == 0", "In AssertValid"); - } - } - - internal struct BinXmlSqlMoney - { - private long _data; - - public BinXmlSqlMoney(int v) { _data = v; } - public BinXmlSqlMoney(long v) { _data = v; } - - public Decimal ToDecimal() - { - bool neg; - ulong v; - if (_data < 0) - { - neg = true; - v = (ulong)unchecked(-_data); - } - else - { - neg = false; - v = (ulong)_data; - } - // SQL Server stores money8 as ticks of 1/10000. - const byte MoneyScale = 4; - return new Decimal(unchecked((int)v), unchecked((int)(v >> 32)), 0, neg, MoneyScale); - } - - public override String ToString() - { - Decimal money = ToDecimal(); - // Formatting of SqlMoney: At least two digits after decimal point - return money.ToString("#0.00##", CultureInfo.InvariantCulture); - } - } - - internal abstract class BinXmlDateTime - { - private const int MaxFractionDigits = 7; - - static internal int[] KatmaiTimeScaleMultiplicator = new int[8] { - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100, - 10, - 1, - }; - - private static void Write2Dig(StringBuilder sb, int val) - { - Debug.Assert(val >= 0 && val < 100); - sb.Append((char)('0' + (val / 10))); - sb.Append((char)('0' + (val % 10))); - } - private static void Write4DigNeg(StringBuilder sb, int val) - { - Debug.Assert(val > -10000 && val < 10000); - if (val < 0) - { - val = -val; - sb.Append('-'); - } - Write2Dig(sb, val / 100); - Write2Dig(sb, val % 100); - } - - private static void Write3Dec(StringBuilder sb, int val) - { - Debug.Assert(val >= 0 && val < 1000); - int c3 = val % 10; - val /= 10; - int c2 = val % 10; - val /= 10; - int c1 = val; - sb.Append('.'); - sb.Append((char)('0' + c1)); - sb.Append((char)('0' + c2)); - sb.Append((char)('0' + c3)); - } - - private static void WriteDate(StringBuilder sb, int yr, int mnth, int day) - { - Write4DigNeg(sb, yr); - sb.Append('-'); - Write2Dig(sb, mnth); - sb.Append('-'); - Write2Dig(sb, day); - } - - private static void WriteTime(StringBuilder sb, int hr, int min, int sec, int ms) - { - Write2Dig(sb, hr); - sb.Append(':'); - Write2Dig(sb, min); - sb.Append(':'); - Write2Dig(sb, sec); - if (ms != 0) - { - Write3Dec(sb, ms); - } - } - - private static void WriteTimeFullPrecision(StringBuilder sb, int hr, int min, int sec, int fraction) - { - Write2Dig(sb, hr); - sb.Append(':'); - Write2Dig(sb, min); - sb.Append(':'); - Write2Dig(sb, sec); - if (fraction != 0) - { - int fractionDigits = MaxFractionDigits; - while (fraction % 10 == 0) - { - fractionDigits--; - fraction /= 10; - } - char[] charArray = new char[fractionDigits]; - while (fractionDigits > 0) - { - fractionDigits--; - charArray[fractionDigits] = (char)(fraction % 10 + '0'); - fraction /= 10; - } - sb.Append('.'); - sb.Append(charArray); - } - } - - private static void WriteTimeZone(StringBuilder sb, TimeSpan zone) - { - bool negTimeZone = true; - if (zone.Ticks < 0) - { - negTimeZone = false; - zone = zone.Negate(); - } - WriteTimeZone(sb, negTimeZone, zone.Hours, zone.Minutes); - } - - private static void WriteTimeZone(StringBuilder sb, bool negTimeZone, int hr, int min) - { - if (hr == 0 && min == 0) - { - sb.Append('Z'); - } - else - { - sb.Append(negTimeZone ? '+' : '-'); - Write2Dig(sb, hr); - sb.Append(':'); - Write2Dig(sb, min); - } - } - - private static void BreakDownXsdDateTime(long val, out int yr, out int mnth, out int day, out int hr, out int min, out int sec, out int ms) - { - if (val < 0) - goto Error; - long date = val / 4; // trim indicator bits - ms = (int)(date % 1000); - date /= 1000; - sec = (int)(date % 60); - date /= 60; - min = (int)(date % 60); - date /= 60; - hr = (int)(date % 24); - date /= 24; - day = (int)(date % 31) + 1; - date /= 31; - mnth = (int)(date % 12) + 1; - date /= 12; - yr = (int)(date - 9999); - if (yr < -9999 || yr > 9999) - goto Error; - return; - Error: - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - } - - private static void BreakDownXsdDate(long val, out int yr, out int mnth, out int day, out bool negTimeZone, out int hr, out int min) - { - if (val < 0) - goto Error; - val = val / 4; // trim indicator bits - int totalMin = (int)(val % (29 * 60)) - 60 * 14; - long totalDays = val / (29 * 60); - - if (negTimeZone = (totalMin < 0)) - totalMin = -totalMin; - - min = totalMin % 60; - hr = totalMin / 60; - - day = (int)(totalDays % 31) + 1; - totalDays /= 31; - mnth = (int)(totalDays % 12) + 1; - yr = (int)(totalDays / 12) - 9999; - if (yr < -9999 || yr > 9999) - goto Error; - return; - Error: - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - } - - private static void BreakDownXsdTime(long val, out int hr, out int min, out int sec, out int ms) - { - if (val < 0) - goto Error; - val = val / 4; // trim indicator bits - ms = (int)(val % 1000); - val /= 1000; - sec = (int)(val % 60); - val /= 60; - min = (int)(val % 60); - hr = (int)(val / 60); - if (0 > hr || hr > 23) - goto Error; - return; - Error: - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - } - - public static string XsdDateTimeToString(long val) - { - int yr; int mnth; int day; int hr; int min; int sec; int ms; - BreakDownXsdDateTime(val, out yr, out mnth, out day, out hr, out min, out sec, out ms); - StringBuilder sb = new StringBuilder(20); - WriteDate(sb, yr, mnth, day); - sb.Append('T'); - WriteTime(sb, hr, min, sec, ms); - sb.Append('Z'); - return sb.ToString(); - } - public static DateTime XsdDateTimeToDateTime(long val) - { - int yr; int mnth; int day; int hr; int min; int sec; int ms; - BreakDownXsdDateTime(val, out yr, out mnth, out day, out hr, out min, out sec, out ms); - return new DateTime(yr, mnth, day, hr, min, sec, ms, DateTimeKind.Utc); - } - - public static string XsdDateToString(long val) - { - int yr; int mnth; int day; int hr; int min; bool negTimeZ; - BreakDownXsdDate(val, out yr, out mnth, out day, out negTimeZ, out hr, out min); - StringBuilder sb = new StringBuilder(20); - WriteDate(sb, yr, mnth, day); - WriteTimeZone(sb, negTimeZ, hr, min); - return sb.ToString(); - } - public static DateTime XsdDateToDateTime(long val) - { - int yr; int mnth; int day; int hr; int min; bool negTimeZ; - BreakDownXsdDate(val, out yr, out mnth, out day, out negTimeZ, out hr, out min); - DateTime d = new DateTime(yr, mnth, day, 0, 0, 0, DateTimeKind.Utc); - // adjust for timezone - int adj = (negTimeZ ? -1 : 1) * ((hr * 60) + min); - return TimeZoneInfo.ConvertTime(d.AddMinutes(adj), TimeZoneInfo.Local); - } - - public static string XsdTimeToString(long val) - { - int hr; int min; int sec; int ms; - BreakDownXsdTime(val, out hr, out min, out sec, out ms); - StringBuilder sb = new StringBuilder(16); - WriteTime(sb, hr, min, sec, ms); - sb.Append('Z'); - return sb.ToString(); - } - public static DateTime XsdTimeToDateTime(long val) - { - int hr; int min; int sec; int ms; - BreakDownXsdTime(val, out hr, out min, out sec, out ms); - return new DateTime(1, 1, 1, hr, min, sec, ms, DateTimeKind.Utc); - } - - public static string SqlDateTimeToString(int dateticks, uint timeticks) - { - DateTime dateTime = SqlDateTimeToDateTime(dateticks, timeticks); - string format = (dateTime.Millisecond != 0) ? "yyyy/MM/dd\\THH:mm:ss.ffff" : "yyyy/MM/dd\\THH:mm:ss"; - return dateTime.ToString(format, CultureInfo.InvariantCulture); - } - public static DateTime SqlDateTimeToDateTime(int dateticks, uint timeticks) - { - DateTime SQLBaseDate = new DateTime(1900, 1, 1); - //long millisecond = (long)(((ulong)timeticks * 20 + (ulong)3) / (ulong)6); - long millisecond = (long)(timeticks / s_SQLTicksPerMillisecond + 0.5); - return SQLBaseDate.Add(new TimeSpan(dateticks * TimeSpan.TicksPerDay + - millisecond * TimeSpan.TicksPerMillisecond)); - } - - // Number of (100ns) ticks per time unit - private static readonly double s_SQLTicksPerMillisecond = 0.3; - public static readonly int SQLTicksPerSecond = 300; - public static readonly int SQLTicksPerMinute = SQLTicksPerSecond * 60; - public static readonly int SQLTicksPerHour = SQLTicksPerMinute * 60; - private static readonly int s_SQLTicksPerDay = SQLTicksPerHour * 24; - - - public static string SqlSmallDateTimeToString(short dateticks, ushort timeticks) - { - DateTime dateTime = SqlSmallDateTimeToDateTime(dateticks, timeticks); - return dateTime.ToString("yyyy/MM/dd\\THH:mm:ss", CultureInfo.InvariantCulture); - } - public static DateTime SqlSmallDateTimeToDateTime(short dateticks, ushort timeticks) - { - return SqlDateTimeToDateTime((int)dateticks, (uint)(timeticks * SQLTicksPerMinute)); - } - - // Conversions of the Katmai date & time types to DateTime - public static DateTime XsdKatmaiDateToDateTime(byte[] data, int offset) - { - // Katmai SQL type "DATE" - long dateTicks = GetKatmaiDateTicks(data, ref offset); - DateTime dt = new DateTime(dateTicks); - return dt; - } - - public static DateTime XsdKatmaiDateTimeToDateTime(byte[] data, int offset) - { - // Katmai SQL type "DATETIME2" - long timeTicks = GetKatmaiTimeTicks(data, ref offset); - long dateTicks = GetKatmaiDateTicks(data, ref offset); - DateTime dt = new DateTime(dateTicks + timeTicks); - return dt; - } - - public static DateTime XsdKatmaiTimeToDateTime(byte[] data, int offset) - { - // TIME without zone is stored as DATETIME2 - return XsdKatmaiDateTimeToDateTime(data, offset); - } - - public static DateTime XsdKatmaiDateOffsetToDateTime(byte[] data, int offset) - { - // read the timezoned value into DateTimeOffset and then convert to local time - return XsdKatmaiDateOffsetToDateTimeOffset(data, offset).LocalDateTime; - } - - public static DateTime XsdKatmaiDateTimeOffsetToDateTime(byte[] data, int offset) - { - // read the timezoned value into DateTimeOffset and then convert to local time - return XsdKatmaiDateTimeOffsetToDateTimeOffset(data, offset).LocalDateTime; - } - - public static DateTime XsdKatmaiTimeOffsetToDateTime(byte[] data, int offset) - { - // read the timezoned value into DateTimeOffset and then convert to local time - return XsdKatmaiTimeOffsetToDateTimeOffset(data, offset).LocalDateTime; - } - - // Conversions of the Katmai date & time types to DateTimeOffset - public static DateTimeOffset XsdKatmaiDateToDateTimeOffset(byte[] data, int offset) - { - // read the value into DateTime and then convert it to DateTimeOffset, which adds local time zone - return (DateTimeOffset)XsdKatmaiDateToDateTime(data, offset); - } - - public static DateTimeOffset XsdKatmaiDateTimeToDateTimeOffset(byte[] data, int offset) - { - // read the value into DateTime and then convert it to DateTimeOffset, which adds local time zone - return (DateTimeOffset)XsdKatmaiDateTimeToDateTime(data, offset); - } - - public static DateTimeOffset XsdKatmaiTimeToDateTimeOffset(byte[] data, int offset) - { - // read the value into DateTime and then convert it to DateTimeOffset, which adds local time zone - return (DateTimeOffset)XsdKatmaiTimeToDateTime(data, offset); - } - - public static DateTimeOffset XsdKatmaiDateOffsetToDateTimeOffset(byte[] data, int offset) - { - // DATE with zone is stored as DATETIMEOFFSET - return XsdKatmaiDateTimeOffsetToDateTimeOffset(data, offset); - } - - public static DateTimeOffset XsdKatmaiDateTimeOffsetToDateTimeOffset(byte[] data, int offset) - { - // Katmai SQL type "DATETIMEOFFSET" - long timeTicks = GetKatmaiTimeTicks(data, ref offset); - long dateTicks = GetKatmaiDateTicks(data, ref offset); - long zoneTicks = GetKatmaiTimeZoneTicks(data, offset); - // The DATETIMEOFFSET values are serialized in UTC, but DateTimeOffset takes adjusted time -> we need to add zoneTicks - DateTimeOffset dto = new DateTimeOffset(dateTicks + timeTicks + zoneTicks, new TimeSpan(zoneTicks)); - return dto; - } - - public static DateTimeOffset XsdKatmaiTimeOffsetToDateTimeOffset(byte[] data, int offset) - { - // TIME with zone is stored as DATETIMEOFFSET - return XsdKatmaiDateTimeOffsetToDateTimeOffset(data, offset); - } - - // Conversions of the Katmai date & time types to string - public static string XsdKatmaiDateToString(byte[] data, int offset) - { - DateTime dt = XsdKatmaiDateToDateTime(data, offset); - StringBuilder sb = new StringBuilder(10); - WriteDate(sb, dt.Year, dt.Month, dt.Day); - return sb.ToString(); - } - - public static string XsdKatmaiDateTimeToString(byte[] data, int offset) - { - DateTime dt = XsdKatmaiDateTimeToDateTime(data, offset); - StringBuilder sb = new StringBuilder(33); - WriteDate(sb, dt.Year, dt.Month, dt.Day); - sb.Append('T'); - WriteTimeFullPrecision(sb, dt.Hour, dt.Minute, dt.Second, GetFractions(dt)); - return sb.ToString(); - } - - public static string XsdKatmaiTimeToString(byte[] data, int offset) - { - DateTime dt = XsdKatmaiTimeToDateTime(data, offset); - StringBuilder sb = new StringBuilder(16); - WriteTimeFullPrecision(sb, dt.Hour, dt.Minute, dt.Second, GetFractions(dt)); - return sb.ToString(); - } - - public static string XsdKatmaiDateOffsetToString(byte[] data, int offset) - { - DateTimeOffset dto = XsdKatmaiDateOffsetToDateTimeOffset(data, offset); - StringBuilder sb = new StringBuilder(16); - WriteDate(sb, dto.Year, dto.Month, dto.Day); - WriteTimeZone(sb, dto.Offset); - return sb.ToString(); - } - - public static string XsdKatmaiDateTimeOffsetToString(byte[] data, int offset) - { - DateTimeOffset dto = XsdKatmaiDateTimeOffsetToDateTimeOffset(data, offset); - StringBuilder sb = new StringBuilder(39); - WriteDate(sb, dto.Year, dto.Month, dto.Day); - sb.Append('T'); - WriteTimeFullPrecision(sb, dto.Hour, dto.Minute, dto.Second, GetFractions(dto)); - WriteTimeZone(sb, dto.Offset); - return sb.ToString(); - } - - public static string XsdKatmaiTimeOffsetToString(byte[] data, int offset) - { - DateTimeOffset dto = XsdKatmaiTimeOffsetToDateTimeOffset(data, offset); - StringBuilder sb = new StringBuilder(22); - WriteTimeFullPrecision(sb, dto.Hour, dto.Minute, dto.Second, GetFractions(dto)); - WriteTimeZone(sb, dto.Offset); - return sb.ToString(); - } - - // Helper methods for the Katmai date & time types - private static long GetKatmaiDateTicks(byte[] data, ref int pos) - { - int p = pos; - pos = p + 3; - return (data[p] | data[p + 1] << 8 | data[p + 2] << 16) * TimeSpan.TicksPerDay; - } - - private static long GetKatmaiTimeTicks(byte[] data, ref int pos) - { - int p = pos; - byte scale = data[p]; - long timeTicks; - p++; - if (scale <= 2) - { - timeTicks = data[p] | (data[p + 1] << 8) | (data[p + 2] << 16); - pos = p + 3; - } - else if (scale <= 4) - { - timeTicks = data[p] | (data[p + 1] << 8) | (data[p + 2] << 16); - timeTicks |= ((long)data[p + 3] << 24); - pos = p + 4; - } - else if (scale <= 7) - { - timeTicks = data[p] | (data[p + 1] << 8) | (data[p + 2] << 16); - timeTicks |= ((long)data[p + 3] << 24) | ((long)data[p + 4] << 32); - pos = p + 5; - } - else - { - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - } - return timeTicks * KatmaiTimeScaleMultiplicator[scale]; - } - - private static long GetKatmaiTimeZoneTicks(byte[] data, int pos) - { - return (short)(data[pos] | data[pos + 1] << 8) * TimeSpan.TicksPerMinute; - } - - private static int GetFractions(DateTime dt) - { - return (int)(dt.Ticks - new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second).Ticks); - } - - private static int GetFractions(DateTimeOffset dt) - { - return (int)(dt.Ticks - new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second).Ticks); - } - - /* - const long SqlDateTicks2Ticks = (long)10000 * 1000 * 60 * 60 * 24; - const long SqlBaseDate = 693595; - - public static void DateTime2SqlDateTime(DateTime datetime, out int dateticks, out uint timeticks) { - dateticks = (int)(datetime.Ticks / SqlDateTicks2Ticks) - 693595; - double time = (double)(datetime.Ticks % SqlDateTicks2Ticks); - time = time / 10000; // adjust to ms - time = time * 0.3 + .5; // adjust to sqlticks (and round correctly) - timeticks = (uint)time; - } - public static void DateTime2SqlSmallDateTime(DateTime datetime, out short dateticks, out ushort timeticks) { - dateticks = (short)((int)(datetime.Ticks / SqlDateTicks2Ticks) - 693595); - int time = (int)(datetime.Ticks % SqlDateTicks2Ticks); - timeticks = (ushort)(time / (10000 * 1000 * 60)); // adjust to min - } - public static long DateTime2XsdTime(DateTime datetime) { - // adjust to ms - return (datetime.TimeOfDay.Ticks / 10000) * 4 + 0; - } - public static long DateTime2XsdDateTime(DateTime datetime) { - long t = datetime.TimeOfDay.Ticks / 10000; - t += (datetime.Day-1) * (long)1000*60*60*24; - t += (datetime.Month-1) * (long)1000*60*60*24*31; - int year = datetime.Year; - if (year < -9999 || year > 9999) - throw new XmlException(Res.SqlTypes_ArithOverflow, (string)null); - t += (datetime.Year+9999) * (long)1000*60*60*24*31*12; - return t*4 + 2; - } - public static long DateTime2XsdDate(DateTime datetime) { - // compute local offset - long tzOffset = -TimeZone.CurrentTimeZone.GetUtcOffset(datetime).Ticks / TimeSpan.TicksPerMinute; - tzOffset += 14*60; - // adjust datetime to UTC - datetime = TimeZone.CurrentTimeZone.ToUniversalTime(datetime); - - Debug.Assert( tzOffset >= 0 ); - - int year = datetime.Year; - if (year < -9999 || year > 9999) - throw new XmlException(Res.SqlTypes_ArithOverflow, (string)null); - long t = (datetime.Day - 1) - + 31*(datetime.Month - 1) - + 31*12*((long)(year+9999)); - t *= (29*60); // adjust in timezone - t += tzOffset; - return t*4+1; - } - * */ - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReader.cs deleted file mode 100644 index 6f0c4f40d7a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReader.cs +++ /dev/null @@ -1,4509 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - - internal sealed partial class XmlSqlBinaryReader : XmlReader, IXmlNamespaceResolver - { - internal static readonly Type TypeOfObject = typeof(System.Object); - internal static readonly Type TypeOfString = typeof(System.String); - - private static volatile Type[] s_tokenTypeMap = null; - - private static byte[] s_xsdKatmaiTimeScaleToValueLengthMap = new byte[8] { - // length scale - 3, // 0 - 3, // 1 - 3, // 2 - 4, // 3 - 4, // 4 - 5, // 5 - 5, // 6 - 5, // 7 - }; - - private enum ScanState - { - Doc = 0, - XmlText = 1, - Attr = 2, - AttrVal = 3, - AttrValPseudoValue = 4, - Init = 5, - Error = 6, - EOF = 7, - Closed = 8 - } - - private static ReadState[] s_scanState2ReadState = { - ReadState.Interactive, - ReadState.Interactive, - ReadState.Interactive, - ReadState.Interactive, - ReadState.Interactive, - ReadState.Initial, - ReadState.Error, - ReadState.EndOfFile, - ReadState.Closed - }; - - // Note: also used by XmlBinaryWriter - internal struct QName - { - public string prefix; - public string localname; - public string namespaceUri; - - public QName(string prefix, string lname, string nsUri) - { - this.prefix = prefix; this.localname = lname; this.namespaceUri = nsUri; - } - public void Set(string prefix, string lname, string nsUri) - { - this.prefix = prefix; this.localname = lname; this.namespaceUri = nsUri; - } - - public void Clear() - { - this.prefix = this.localname = this.namespaceUri = String.Empty; - } - - public bool MatchNs(string lname, string nsUri) - { - return lname == this.localname && nsUri == this.namespaceUri; - } - public bool MatchPrefix(string prefix, string lname) - { - return lname == this.localname && prefix == this.prefix; - } - - public void CheckPrefixNS(string prefix, string namespaceUri) - { - if (this.prefix == prefix && this.namespaceUri != namespaceUri) - throw new XmlException(ResXml.XmlBinary_NoRemapPrefix, new String[] { prefix, this.namespaceUri, namespaceUri }); - } - - public override int GetHashCode() - { - return this.prefix.GetHashCode() ^ this.localname.GetHashCode(); - } - - public int GetNSHashCode(SecureStringHasher hasher) - { - return hasher.GetHashCode(this.namespaceUri) ^ hasher.GetHashCode(this.localname); - } - - - public override bool Equals(object other) - { - if (other is QName) - { - QName that = (QName)other; - return this == that; - } - return false; - } - - public override string ToString() - { - if (prefix.Length == 0) - return this.localname; - else - return this.prefix + ":" + this.localname; - } - - public static bool operator ==(QName a, QName b) - { - return ((a.prefix == b.prefix) - && (a.localname == b.localname) - && (a.namespaceUri == b.namespaceUri)); - } - - public static bool operator !=(QName a, QName b) - { - return !(a == b); - } - }; - - private struct ElemInfo - { - public QName name; - public string xmlLang; - public XmlSpace xmlSpace; - public bool xmlspacePreserve; - public NamespaceDecl nsdecls; - - public void Set(QName name, bool xmlspacePreserve) - { - this.name = name; - this.xmlLang = null; - this.xmlSpace = XmlSpace.None; - this.xmlspacePreserve = xmlspacePreserve; - } - public NamespaceDecl Clear() - { - NamespaceDecl nsdecls = this.nsdecls; - this.nsdecls = null; - return nsdecls; - } - }; - - private struct AttrInfo - { - public QName name; - public string val; - public int contentPos; - public int hashCode; - public int prevHash; - - public void Set(QName n, string v) - { - this.name = n; - this.val = v; - this.contentPos = 0; - this.hashCode = 0; - this.prevHash = 0; - } - public void Set(QName n, int pos) - { - this.name = n; - this.val = null; - this.contentPos = pos; - this.hashCode = 0; - this.prevHash = 0; - } - - public void GetLocalnameAndNamespaceUri(out string localname, out string namespaceUri) - { - localname = this.name.localname; - namespaceUri = this.name.namespaceUri; - } - - public int GetLocalnameAndNamespaceUriAndHash(SecureStringHasher hasher, out string localname, out string namespaceUri) - { - localname = this.name.localname; - namespaceUri = this.name.namespaceUri; - return this.hashCode = this.name.GetNSHashCode(hasher); - } - - public bool MatchNS(string localname, string namespaceUri) - { - return this.name.MatchNs(localname, namespaceUri); - } - - public bool MatchHashNS(int hash, string localname, string namespaceUri) - { - return this.hashCode == hash && this.name.MatchNs(localname, namespaceUri); - } - - public void AdjustPosition(int adj) - { - if (this.contentPos != 0) - this.contentPos += adj; - } - } - - private class NamespaceDecl - { - public string prefix; - public string uri; - public NamespaceDecl scopeLink; - public NamespaceDecl prevLink; - public int scope; - public bool implied; - - public NamespaceDecl(string prefix, string nsuri, - NamespaceDecl nextInScope, NamespaceDecl prevDecl, - int scope, bool implied) - { - this.prefix = prefix; - this.uri = nsuri; - this.scopeLink = nextInScope; - this.prevLink = prevDecl; - this.scope = scope; - this.implied = implied; - } - } - - // symbol and qname tables - private struct SymbolTables - { - public string[] symtable; - public int symCount; - public QName[] qnametable; - public int qnameCount; - public void Init() - { - this.symtable = new string[64]; - this.qnametable = new QName[16]; - this.symtable[0] = String.Empty; - this.symCount = 1; - this.qnameCount = 1; - } - } - private class NestedBinXml - { - public SymbolTables symbolTables; - public int docState; - public NestedBinXml next; - public NestedBinXml(SymbolTables symbolTables, int docState, NestedBinXml next) - { - this.symbolTables = symbolTables; - this.docState = docState; - this.next = next; - } - } - - // input data - private Stream _inStrm; - private byte[] _data; - private int _pos; - private int _mark; - private int _end; - private long _offset; // how much read and shift out of buffer - private bool _eof; - private bool _sniffed; - private bool _isEmpty; // short-tag element start tag - - private int _docState; // 0=>auto, 1=>doc/pre-dtd, 2=>doc/pre-elem, 3=>doc/instance -1=>doc/post-elem, 9=>frag - - // symbol and qname tables - private SymbolTables _symbolTables; - - private XmlNameTable _xnt; - private bool _xntFromSettings; - private string _xml; - private string _xmlns; - private string _nsxmlns; - - // base uri... - private string _baseUri; - - // current parse state - private ScanState _state; - private XmlNodeType _nodetype; - private BinXmlToken _token; - // current attribute - private int _attrIndex; - // index of current qname - private QName _qnameOther; - // saved qname of element (for MoveToElement) - private QName _qnameElement; - private XmlNodeType _parentNodeType; // use for MoveToElement() - // stack of current open element tags - private ElemInfo[] _elementStack; - private int _elemDepth; - // current attributes - private AttrInfo[] _attributes; - private int[] _attrHashTbl; - private int _attrCount; - private int _posAfterAttrs; - // xml:space - private bool _xmlspacePreserve; - // position/parse info for current typed token - private int _tokLen; - private int _tokDataPos; - private bool _hasTypedValue; - private System.Type _valueType; - // if it is a simple string value, we cache it - private string _stringValue; - // hashtable of current namespaces - private Dictionary _namespaces; - //Hashtable namespaces; - // linked list of pushed nametables (to support nested binary-xml documents) - private NestedBinXml _prevNameInfo; - // XmlTextReader to handle embeded text blocks - private XmlReader _textXmlReader; - // close input flag - private bool _closeInput; - - private bool _checkCharacters; - private bool _ignoreWhitespace; - private bool _ignorePIs; - private bool _ignoreComments; - private DtdProcessing _dtdProcessing; - - private SecureStringHasher _hasher; - private XmlCharType _xmlCharType; - private Encoding _unicode; - - // current version of the protocol - private byte _version; - - public XmlSqlBinaryReader(System.IO.Stream stream, byte[] data, int len, string baseUri, bool closeInput, XmlReaderSettings settings) - { - _unicode = System.Text.Encoding.Unicode; - _xmlCharType = XmlCharType.Instance; - - _xnt = settings.NameTable; - if (_xnt == null) - { - _xnt = new NameTable(); - _xntFromSettings = false; - } - else - { - _xntFromSettings = true; - } - _xml = _xnt.Add("xml"); - _xmlns = _xnt.Add("xmlns"); - _nsxmlns = _xnt.Add(XmlReservedNs.NsXmlNs); - _baseUri = baseUri; - _state = ScanState.Init; - _nodetype = XmlNodeType.None; - _token = BinXmlToken.Error; - _elementStack = new ElemInfo[16]; - //this.elemDepth = 0; - _attributes = new AttrInfo[8]; - _attrHashTbl = new int[8]; - //this.attrCount = 0; - //this.attrIndex = 0; - _symbolTables.Init(); - _qnameOther.Clear(); - _qnameElement.Clear(); - _xmlspacePreserve = false; - _hasher = new SecureStringHasher(); - _namespaces = new Dictionary(_hasher); - AddInitNamespace(String.Empty, String.Empty); - AddInitNamespace(_xml, _xnt.Add(XmlReservedNs.NsXml)); - AddInitNamespace(_xmlns, _nsxmlns); - _valueType = TypeOfString; - // init buffer position, etc - _inStrm = stream; - if (data != null) - { - Debug.Assert(len >= 2 && (data[0] == 0xdf && data[1] == 0xff)); - _data = data; - _end = len; - _pos = 2; - _sniffed = true; - } - else - { - _data = new byte[XmlReader.DefaultBufferSize]; - _end = stream.Read(_data, 0, XmlReader.DefaultBufferSize); - _pos = 0; - _sniffed = false; - } - - _mark = -1; - _eof = (0 == _end); - _offset = 0; - _closeInput = closeInput; - switch (settings.ConformanceLevel) - { - case ConformanceLevel.Auto: - _docState = 0; break; - case ConformanceLevel.Fragment: - _docState = 9; break; - case ConformanceLevel.Document: - _docState = 1; break; - } - _checkCharacters = settings.CheckCharacters; - _dtdProcessing = settings.DtdProcessing; - _ignoreWhitespace = settings.IgnoreWhitespace; - _ignorePIs = settings.IgnoreProcessingInstructions; - _ignoreComments = settings.IgnoreComments; - - if (s_tokenTypeMap == null) - GenerateTokenTypeMap(); - } - - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings = new XmlReaderSettings(); - if (_xntFromSettings) - { - settings.NameTable = _xnt; - } - // 0=>auto, 1=>doc/pre-dtd, 2=>doc/pre-elem, 3=>doc/instance -1=>doc/post-elem, 9=>frag - switch (_docState) - { - case 0: - settings.ConformanceLevel = ConformanceLevel.Auto; break; - case 9: - settings.ConformanceLevel = ConformanceLevel.Fragment; break; - default: - settings.ConformanceLevel = ConformanceLevel.Document; break; - } - settings.CheckCharacters = _checkCharacters; - settings.IgnoreWhitespace = _ignoreWhitespace; - settings.IgnoreProcessingInstructions = _ignorePIs; - settings.IgnoreComments = _ignoreComments; - settings.DtdProcessing = _dtdProcessing; - settings.CloseInput = _closeInput; - - settings.ReadOnly = true; - return settings; - } - } - - public override XmlNodeType NodeType - { - get - { - return _nodetype; - } - } - - public override string LocalName - { - get - { - return _qnameOther.localname; - } - } - - public override string NamespaceURI - { - get - { - return _qnameOther.namespaceUri; - } - } - - public override string Prefix - { - get - { - return _qnameOther.prefix; - } - } - - public override bool HasValue - { - get - { - if (ScanState.XmlText == _state) - return _textXmlReader.HasValue; - else - return XmlReader.HasValueInternal(_nodetype); - } - } - - public override string Value - { - get - { - if (null != _stringValue) - return _stringValue; - switch (_state) - { - case ScanState.Doc: - switch (_nodetype) - { - case XmlNodeType.DocumentType: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - return _stringValue = GetString(_tokDataPos, _tokLen); - - case XmlNodeType.CDATA: - return _stringValue = CDATAValue(); - - case XmlNodeType.XmlDeclaration: - return _stringValue = XmlDeclValue(); - - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return _stringValue = ValueAsString(_token); - } - break; - - case ScanState.XmlText: - return _textXmlReader.Value; - - case ScanState.Attr: - case ScanState.AttrValPseudoValue: - return _stringValue = GetAttributeText(_attrIndex - 1); - - case ScanState.AttrVal: - return _stringValue = ValueAsString(_token); - } - return String.Empty; - } - } - - public override int Depth - { - get - { - int adj = 0; - switch (_state) - { - case ScanState.Doc: - if (_nodetype == XmlNodeType.Element - || _nodetype == XmlNodeType.EndElement) - adj = -1; - break; - - case ScanState.XmlText: - adj = _textXmlReader.Depth; - break; - - case ScanState.Attr: - if (_parentNodeType != XmlNodeType.Element) - adj = 1; - break; - case ScanState.AttrVal: - case ScanState.AttrValPseudoValue: - if (_parentNodeType != XmlNodeType.Element) - adj = 1; - adj += 1; - break; - default: - return 0; - } - return _elemDepth + adj; - } - } - - public override string BaseURI - { - get - { - return _baseUri; - } - } - - public override bool IsEmptyElement - { - get - { - switch (_state) - { - case ScanState.Doc: - case ScanState.XmlText: - return _isEmpty; - default: - return false; - } - } - } - - public override XmlSpace XmlSpace - { - get - { - if (ScanState.XmlText != _state) - { - for (int i = _elemDepth; i >= 0; i--) - { - XmlSpace xs = _elementStack[i].xmlSpace; - if (xs != XmlSpace.None) - return xs; - } - return XmlSpace.None; - } - else - { - return _textXmlReader.XmlSpace; - } - } - } - - public override string XmlLang - { - get - { - if (ScanState.XmlText != _state) - { - for (int i = _elemDepth; i >= 0; i--) - { - string xl = _elementStack[i].xmlLang; - if (null != xl) - return xl; - } - return string.Empty; - } - else - { - return _textXmlReader.XmlLang; - } - } - } - - public override System.Type ValueType - { - get - { - return _valueType; - } - } - - public override int AttributeCount - { - get - { - switch (_state) - { - case ScanState.Doc: - // for compatibility with XmlTextReader - // we return the attribute count for the element - // when positioned on an attribute under that - // element... - case ScanState.Attr: - case ScanState.AttrVal: - case ScanState.AttrValPseudoValue: - return _attrCount; - case ScanState.XmlText: - return _textXmlReader.AttributeCount; - default: - return 0; - } - } - } - - public override string GetAttribute(string name, string ns) - { - if (ScanState.XmlText == _state) - { - return _textXmlReader.GetAttribute(name, ns); - } - else - { - if (null == name) - throw new ArgumentNullException("name"); - if (null == ns) - ns = String.Empty; - int index = LocateAttribute(name, ns); - if (-1 == index) - return null; - return GetAttribute(index); - } - } - - public override string GetAttribute(string name) - { - if (ScanState.XmlText == _state) - { - return _textXmlReader.GetAttribute(name); - } - else - { - int index = LocateAttribute(name); - if (-1 == index) - return null; - return GetAttribute(index); - } - } - - public override string GetAttribute(int i) - { - if (ScanState.XmlText == _state) - { - return _textXmlReader.GetAttribute(i); - } - else - { - if (i < 0 || i >= _attrCount) - throw new ArgumentOutOfRangeException("i"); - return GetAttributeText(i); - } - } - - public override bool MoveToAttribute(string name, string ns) - { - if (ScanState.XmlText == _state) - { - return UpdateFromTextReader(_textXmlReader.MoveToAttribute(name, ns)); - } - else - { - if (null == name) - throw new ArgumentNullException("name"); - if (null == ns) - ns = String.Empty; - int index = LocateAttribute(name, ns); - if ((-1 != index) && (_state < ScanState.Init)) - { - PositionOnAttribute(index + 1); - return true; - } - return false; - } - } - - public override bool MoveToAttribute(string name) - { - if (ScanState.XmlText == _state) - { - return UpdateFromTextReader(_textXmlReader.MoveToAttribute(name)); - } - else - { - int index = LocateAttribute(name); - if ((-1 != index) && (_state < ScanState.Init)) - { - PositionOnAttribute(index + 1); - return true; - } - return false; - } - } - - public override void MoveToAttribute(int i) - { - if (ScanState.XmlText == _state) - { - _textXmlReader.MoveToAttribute(i); - UpdateFromTextReader(true); - } - else - { - if (i < 0 || i >= _attrCount) - { - throw new ArgumentOutOfRangeException("i"); - } - PositionOnAttribute(i + 1); - } - } - - public override bool MoveToFirstAttribute() - { - if (ScanState.XmlText == _state) - { - return UpdateFromTextReader(_textXmlReader.MoveToFirstAttribute()); - } - else - { - if (_attrCount == 0) - return false; - // set up for walking attributes - PositionOnAttribute(1); - return true; - } - } - - public override bool MoveToNextAttribute() - { - switch (_state) - { - case ScanState.Doc: - case ScanState.Attr: - case ScanState.AttrVal: - case ScanState.AttrValPseudoValue: - if (_attrIndex >= _attrCount) - return false; - PositionOnAttribute(++_attrIndex); - return true; - - case ScanState.XmlText: - return UpdateFromTextReader(_textXmlReader.MoveToNextAttribute()); - - default: - return false; - } - } - - public override bool MoveToElement() - { - switch (_state) - { - case ScanState.Attr: - case ScanState.AttrVal: - case ScanState.AttrValPseudoValue: - _attrIndex = 0; - _qnameOther = _qnameElement; - if (XmlNodeType.Element == _parentNodeType) - _token = BinXmlToken.Element; - else if (XmlNodeType.XmlDeclaration == _parentNodeType) - _token = BinXmlToken.XmlDecl; - else if (XmlNodeType.DocumentType == _parentNodeType) - _token = BinXmlToken.DocType; - else - Debug.Fail("Unexpected parent NodeType"); - _nodetype = _parentNodeType; - _state = ScanState.Doc; - _pos = _posAfterAttrs; - _stringValue = null; - return true; - - case ScanState.XmlText: - return UpdateFromTextReader(_textXmlReader.MoveToElement()); - - default: - return false; - } - } - - public override bool EOF - { - get - { - return _state == ScanState.EOF; - } - } - - public override bool ReadAttributeValue() - { - _stringValue = null; - switch (_state) - { - case ScanState.Attr: - if (null == _attributes[_attrIndex - 1].val) - { - _pos = _attributes[_attrIndex - 1].contentPos; - BinXmlToken tok = RescanNextToken(); - if (BinXmlToken.Attr == tok || BinXmlToken.EndAttrs == tok) - { - return false; - } - _token = tok; - ReScanOverValue(tok); - _valueType = GetValueType(tok); - _state = ScanState.AttrVal; - } - else - { - _token = BinXmlToken.Error; - _valueType = TypeOfString; - _state = ScanState.AttrValPseudoValue; - } - _qnameOther.Clear(); - _nodetype = XmlNodeType.Text; - return true; - - case ScanState.AttrVal: - return false; - - case ScanState.XmlText: - return UpdateFromTextReader(_textXmlReader.ReadAttributeValue()); - - default: - return false; - } - } - - public override void Close() - { - _state = ScanState.Closed; - _nodetype = XmlNodeType.None; - _token = BinXmlToken.Error; - _stringValue = null; - if (null != _textXmlReader) - { - _textXmlReader.Close(); - _textXmlReader = null; - } - if (null != _inStrm && _closeInput) - _inStrm.Close(); - _inStrm = null; - _pos = _end = 0; - } - - public override XmlNameTable NameTable - { - get - { - return _xnt; - } - } - - public override string LookupNamespace(string prefix) - { - if (ScanState.XmlText == _state) - return _textXmlReader.LookupNamespace(prefix); - NamespaceDecl decl; - if (prefix != null && _namespaces.TryGetValue(prefix, out decl)) - { - Debug.Assert(decl != null); - return decl.uri; - } - return null; - } - - public override void ResolveEntity() - { - throw new NotSupportedException(); - } - - public override ReadState ReadState - { - get - { - return s_scanState2ReadState[(int)_state]; - } - } - - public override bool Read() - { - try - { - switch (_state) - { - case ScanState.Init: - return ReadInit(false); - - case ScanState.Doc: - return ReadDoc(); - - case ScanState.XmlText: - if (_textXmlReader.Read()) - { - return UpdateFromTextReader(true); - } - _state = ScanState.Doc; - _nodetype = XmlNodeType.None; - _isEmpty = false; - goto case ScanState.Doc; - - case ScanState.Attr: - case ScanState.AttrVal: - case ScanState.AttrValPseudoValue: - // clean up attribute stuff... - MoveToElement(); - goto case ScanState.Doc; - - default: - return false; - } - } - catch (OverflowException e) - { - _state = ScanState.Error; - throw new XmlException(e.Message, e); - } - catch - { - _state = ScanState.Error; - throw; - } - } - - // Use default implementation of and ReadContentAsString and ReadElementContentAsString - // (there is no benefit to providing a custom version) - // public override bool ReadElementContentAsString( string localName, string namespaceURI ) - // public override bool ReadElementContentAsString() - // public override bool ReadContentAsString() - - // Do setup work for ReadContentAsXXX methods - // If ready for a typed value read, returns true, otherwise returns - // false to indicate caller should go back to XmlReader.ReadContentAsXXX - // Special-Case: returns true and positioned on Element or EndElem to force parse of empty-string - private bool SetupContentAsXXX(string name) - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException(name); - } - switch (_state) - { - case ScanState.Doc: - if (this.NodeType == XmlNodeType.EndElement) - return true; - if (this.NodeType == XmlNodeType.ProcessingInstruction || this.NodeType == XmlNodeType.Comment) - { - while (Read() && (this.NodeType == XmlNodeType.ProcessingInstruction || this.NodeType == XmlNodeType.Comment)) - ; - if (this.NodeType == XmlNodeType.EndElement) - return true; - } - if (_hasTypedValue) - { - return true; - } - break; - case ScanState.Attr: - _pos = _attributes[_attrIndex - 1].contentPos; - BinXmlToken token = RescanNextToken(); - if (BinXmlToken.Attr == token || BinXmlToken.EndAttrs == token) - break; - _token = token; - ReScanOverValue(token); - return true; - case ScanState.AttrVal: - return true; - default: - break; - } - return false; - } - - private int FinishContentAsXXX(int origPos) - { - if (_state == ScanState.Doc) - { - // if we are already on a tag, then don't move - if (this.NodeType != XmlNodeType.Element && this.NodeType != XmlNodeType.EndElement) - { - // advance over PIs and Comments - Loop: - if (Read()) - { - switch (this.NodeType) - { - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - goto Loop; - - case XmlNodeType.Element: - case XmlNodeType.EndElement: - break; - - default: - throw ThrowNotSupported(ResXml.XmlBinary_ListsOfValuesNotSupported); - } - } - } - return _pos; - } - return origPos; - } - - public override bool ReadContentAsBoolean() - { - int origPos = _pos; - bool value = false; - try - { - if (SetupContentAsXXX("ReadContentAsBoolean")) - { - try - { - switch (_token) - { - case BinXmlToken.XSD_BOOLEAN: - value = 0 != _data[_tokDataPos]; - break; - - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Boolean")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToBoolean(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, null); - } - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsBoolean(); - } - - public override DateTime ReadContentAsDateTime() - { - int origPos = _pos; - DateTime value; - try - { - if (SetupContentAsXXX("ReadContentAsDateTime")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - value = ValueAsDateTime(); - break; - - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "DateTime")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToDateTime(String.Empty, XmlDateTimeSerializationMode.RoundtripKind); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsDateTime(); - } - - public override Double ReadContentAsDouble() - { - int origPos = _pos; - Double value; - try - { - if (SetupContentAsXXX("ReadContentAsDouble")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - value = ValueAsDouble(); - break; - - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Double")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToDouble(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsDouble(); - } - - public override float ReadContentAsFloat() - { - int origPos = _pos; - float value; - try - { - if (SetupContentAsXXX("ReadContentAsFloat")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - value = checked(((float)ValueAsDouble())); - break; - - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Float")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToSingle(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsFloat(); - } - - public override decimal ReadContentAsDecimal() - { - int origPos = _pos; - decimal value; - try - { - if (SetupContentAsXXX("ReadContentAsDecimal")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - value = ValueAsDecimal(); - break; - - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Decimal")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToDecimal(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsDecimal(); - } - - public override int ReadContentAsInt() - { - int origPos = _pos; - int value; - try - { - if (SetupContentAsXXX("ReadContentAsInt")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - value = checked((int)ValueAsLong()); - break; - - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Int32")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToInt32(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int32", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int32", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int32", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsInt(); - } - - public override long ReadContentAsLong() - { - int origPos = _pos; - long value; - try - { - if (SetupContentAsXXX("ReadContentAsLong")) - { - try - { - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - value = ValueAsLong(); - break; - - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_QNAME: - throw new InvalidCastException(string.Format(ResXml.XmlBinary_CastNotSupported, _token, "Int64")); - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - goto Fallback; - - case BinXmlToken.Element: - case BinXmlToken.EndElem: - return XmlConvert.ToInt64(String.Empty); - - default: - Debug.Fail("should never happen"); - goto Fallback; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int64", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int64", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int64", e, null); - } - - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - Fallback: - return base.ReadContentAsLong(); - } - - public override object ReadContentAsObject() - { - int origPos = _pos; - try - { - if (SetupContentAsXXX("ReadContentAsObject")) - { - object value; - try - { - if (this.NodeType == XmlNodeType.Element || this.NodeType == XmlNodeType.EndElement) - value = String.Empty; - else - value = this.ValueAsObject(_token, false); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Object", e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Object", e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Object", e, null); - } - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - //Fallback: - return base.ReadContentAsObject(); - } - - public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - int origPos = _pos; - try - { - if (SetupContentAsXXX("ReadContentAs")) - { - object value; - try - { - if (this.NodeType == XmlNodeType.Element || this.NodeType == XmlNodeType.EndElement) - { - value = String.Empty; - } - else if (returnType == this.ValueType || returnType == typeof(object)) - { - value = this.ValueAsObject(_token, false); - } - else - { - value = this.ValueAs(_token, returnType, namespaceResolver); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, null); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, null); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, null); - } - origPos = FinishContentAsXXX(origPos); - return value; - } - } - finally - { - _pos = origPos; - } - return base.ReadContentAs(returnType, namespaceResolver); - } - - ////////// - // IXmlNamespaceResolver - - System.Collections.Generic.IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - if (ScanState.XmlText == _state) - { - IXmlNamespaceResolver resolver = (IXmlNamespaceResolver)_textXmlReader; - return resolver.GetNamespacesInScope(scope); - } - else - { - Dictionary nstable = new Dictionary(); - if (XmlNamespaceScope.Local == scope) - { - // are we even inside an element? (depth==0 is where we have xml, and xmlns declared...) - if (_elemDepth > 0) - { - NamespaceDecl nsdecl = _elementStack[_elemDepth].nsdecls; - while (null != nsdecl) - { - nstable.Add(nsdecl.prefix, nsdecl.uri); - nsdecl = nsdecl.scopeLink; - } - } - } - else - { - foreach (NamespaceDecl nsdecl in _namespaces.Values) - { - // don't add predefined decls unless scope == all, then only add 'xml' - if (nsdecl.scope != -1 || (XmlNamespaceScope.All == scope && "xml" == nsdecl.prefix)) - { - // xmlns="" only ever reported via scope==local - if (nsdecl.prefix.Length > 0 || nsdecl.uri.Length > 0) - nstable.Add(nsdecl.prefix, nsdecl.uri); - } - } - } - return nstable; - } - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - if (ScanState.XmlText == _state) - { - IXmlNamespaceResolver resolver = (IXmlNamespaceResolver)_textXmlReader; - return resolver.LookupPrefix(namespaceName); - } - else - { - if (null == namespaceName) - return null; - - namespaceName = _xnt.Get(namespaceName); - if (null == namespaceName) - return null; - - for (int i = _elemDepth; i >= 0; i--) - { - NamespaceDecl nsdecl = _elementStack[i].nsdecls; - while (null != nsdecl) - { - if ((object)nsdecl.uri == (object)namespaceName) - return nsdecl.prefix; - nsdecl = nsdecl.scopeLink; - } - } - return null; - } - } - - ////////// - // Internal implementation methods - - private void VerifyVersion(int requiredVersion, BinXmlToken token) - { - if (_version < requiredVersion) - { - throw ThrowUnexpectedToken(token); - } - } - - private void AddInitNamespace(string prefix, string uri) - { - NamespaceDecl nsdecl = new NamespaceDecl(prefix, uri, _elementStack[0].nsdecls, null, -1, true); - _elementStack[0].nsdecls = nsdecl; - _namespaces.Add(prefix, nsdecl); - } - - private void AddName() - { - string txt = ParseText(); - int symNum = _symbolTables.symCount++; - string[] symtable = _symbolTables.symtable; - if (symNum == symtable.Length) - { - string[] n = new string[checked(symNum * 2)]; - System.Array.Copy(symtable, 0, n, 0, symNum); - _symbolTables.symtable = symtable = n; - } - symtable[symNum] = _xnt.Add(txt); - } - - private void AddQName() - { - int nsUri = ReadNameRef(); - int prefix = ReadNameRef(); - int lname = ReadNameRef(); - int qnameNum = _symbolTables.qnameCount++; - QName[] qnametable = _symbolTables.qnametable; - if (qnameNum == qnametable.Length) - { - QName[] n = new QName[checked(qnameNum * 2)]; - System.Array.Copy(qnametable, 0, n, 0, qnameNum); - _symbolTables.qnametable = qnametable = n; - } - string[] symtable = _symbolTables.symtable; - string prefixStr = symtable[prefix]; - string lnameStr; - string nsUriStr; - // xmlns attributes are encodes differently... - if (lname == 0) - { // xmlns attribute - // for some reason, sqlserver sometimes generates these... - if (prefix == 0 && nsUri == 0) - return; - // it is a real namespace decl, make sure it looks valid - if (!prefixStr.StartsWith("xmlns", StringComparison.Ordinal)) - goto BadDecl; - if (5 < prefixStr.Length) - { - if (6 == prefixStr.Length || ':' != prefixStr[5]) - goto BadDecl; - lnameStr = _xnt.Add(prefixStr.Substring(6)); - prefixStr = _xmlns; - } - else - { - lnameStr = prefixStr; - prefixStr = String.Empty; - } - nsUriStr = _nsxmlns; - } - else - { - lnameStr = symtable[lname]; - nsUriStr = symtable[nsUri]; - } - qnametable[qnameNum].Set(prefixStr, lnameStr, nsUriStr); - return; - BadDecl: - throw new XmlException(ResXml.Xml_BadNamespaceDecl, (string[])null); - } - - private void NameFlush() - { - _symbolTables.symCount = _symbolTables.qnameCount = 1; - Array.Clear(_symbolTables.symtable, 1, _symbolTables.symtable.Length - 1); - Array.Clear(_symbolTables.qnametable, 0, _symbolTables.qnametable.Length); - } - - private void SkipExtn() - { - int cb = ParseMB32(); - checked { _pos += cb; } - Fill(-1); - } - - private int ReadQNameRef() - { - int nameNum = ParseMB32(); - if (nameNum < 0 || nameNum >= _symbolTables.qnameCount) - throw new XmlException(ResXml.XmlBin_InvalidQNameID, String.Empty); - return nameNum; - } - - private int ReadNameRef() - { - int nameNum = ParseMB32(); - if (nameNum < 0 || nameNum >= _symbolTables.symCount) - throw new XmlException(ResXml.XmlBin_InvalidQNameID, String.Empty); - return nameNum; - } - - // pull more data from input stream - private bool FillAllowEOF() - { - if (_eof) - return false; - byte[] data = _data; - int pos = _pos; - int mark = _mark; - int end = _end; - if (mark == -1) - { - mark = pos; - } - if (mark >= 0 && mark < end) - { - Debug.Assert(_mark <= _end, "Mark should never be past End"); - Debug.Assert(_mark <= _pos, "Mark should never be after Pos"); - int cbKeep = end - mark; - if (cbKeep > 7 * (data.Length / 8)) - { - // grow buffer - byte[] newdata = new byte[checked(data.Length * 2)]; - System.Array.Copy(data, mark, newdata, 0, cbKeep); - _data = data = newdata; - } - else - { - System.Array.Copy(data, mark, data, 0, cbKeep); - } - pos -= mark; - end -= mark; - _tokDataPos -= mark; - for (int i = 0; i < _attrCount; i++) - { - _attributes[i].AdjustPosition(-mark); - // make sure it is still a valid range - Debug.Assert((_attributes[i].contentPos >= 0) && (_attributes[i].contentPos <= (end))); - } - _pos = pos; - _mark = 0; - _offset += mark; - } - else - { - Debug.Assert(_attrCount == 0); - _pos -= end; - _mark -= end; - _offset += end; - _tokDataPos -= end; - end = 0; - } - int cbFill = data.Length - end; - int cbRead = _inStrm.Read(data, end, cbFill); - _end = end + cbRead; - _eof = !(cbRead > 0); - return (cbRead > 0); - } - - // require must be < 1/8 buffer, or else Fill might not actually - // grab that much data - private void Fill_(int require) - { - Debug.Assert((_pos + require) >= _end); - while (FillAllowEOF() && ((_pos + require) >= _end)) - ; - if ((_pos + require) >= _end) - throw ThrowXmlException(ResXml.Xml_UnexpectedEOF1); - } - - // inline the common case - private void Fill(int require) - { - if ((_pos + require) >= _end) - Fill_(require); - } - - private byte ReadByte() - { - Fill(0); - return _data[_pos++]; - } - private ushort ReadUShort() - { - Fill(1); - int pos = _pos; byte[] data = _data; - ushort val = (ushort)(data[pos] + (data[pos + 1] << 8)); - _pos += 2; - return val; - } - - private int ParseMB32() - { - byte b = ReadByte(); - if (b > 127) - return ParseMB32_(b); - return b; - } - - private int ParseMB32_(byte b) - { - uint u, t; - u = (uint)b & (uint)0x7F; - Debug.Assert(0 != (b & 0x80)); - b = ReadByte(); - t = (uint)b & (uint)0x7F; - u = u + (t << 7); - if (b > 127) - { - b = ReadByte(); - t = (uint)b & (uint)0x7F; - u = u + (t << 14); - if (b > 127) - { - b = ReadByte(); - t = (uint)b & (uint)0x7F; - u = u + (t << 21); - if (b > 127) - { - b = ReadByte(); - // bottom 4 bits are all that are needed, - // but we are mapping to 'int', which only - // actually has space for 3 more bits. - t = (uint)b & (uint)0x07; - if (b > 7) - throw ThrowXmlException(ResXml.XmlBinary_ValueTooBig); - u = u + (t << 28); - } - } - } - return (int)u; - } - - // this assumes that we have already ensured that all - // necessary bytes are loaded in to the buffer - private int ParseMB32(int pos) - { - uint u, t; - byte[] data = _data; - byte b = data[pos++]; - u = (uint)b & (uint)0x7F; - if (b > 127) - { - b = data[pos++]; - t = (uint)b & (uint)0x7F; - u = u + (t << 7); - if (b > 127) - { - b = data[pos++]; - t = (uint)b & (uint)0x7F; - u = u + (t << 14); - if (b > 127) - { - b = data[pos++]; - t = (uint)b & (uint)0x7F; - u = u + (t << 21); - if (b > 127) - { - b = data[pos++]; - // last byte only has 4 significant digits - t = (uint)b & (uint)0x07; - if (b > 7) - throw ThrowXmlException(ResXml.XmlBinary_ValueTooBig); - u = u + (t << 28); - } - } - } - } - return (int)u; - } - - // we don't actually support MB64, since we use int for - // all our math anyway... - private int ParseMB64() - { - byte b = ReadByte(); - if (b > 127) - return ParseMB32_(b); - return b; - } - - private BinXmlToken PeekToken() - { - while ((_pos >= _end) && FillAllowEOF()) - ; - if (_pos >= _end) - return BinXmlToken.EOF; - return (BinXmlToken)_data[_pos]; - } - - private BinXmlToken ReadToken() - { - while ((_pos >= _end) && FillAllowEOF()) - ; - if (_pos >= _end) - return BinXmlToken.EOF; - return (BinXmlToken)_data[_pos++]; - } - - private BinXmlToken NextToken2(BinXmlToken token) - { - while (true) - { - switch (token) - { - case BinXmlToken.Name: - AddName(); - break; - case BinXmlToken.QName: - AddQName(); - break; - case BinXmlToken.NmFlush: - NameFlush(); - break; - case BinXmlToken.Extn: - SkipExtn(); - break; - default: - return token; - } - token = ReadToken(); - } - } - - private BinXmlToken NextToken1() - { - BinXmlToken token; - int pos = _pos; - if (pos >= _end) - token = ReadToken(); - else - { - token = (BinXmlToken)_data[pos]; - _pos = pos + 1; - } - // BinXmlToken.Name = 0xF0 - // BinXmlToken.QName = 0xEF - // BinXmlToken.Extn = 0xEA, - // BinXmlToken.NmFlush = 0xE9, - if (token >= BinXmlToken.NmFlush - && token <= BinXmlToken.Name) - return NextToken2(token); - return token; - } - - private BinXmlToken NextToken() - { - int pos = _pos; - if (pos < _end) - { - BinXmlToken t = (BinXmlToken)_data[pos]; - if (!(t >= BinXmlToken.NmFlush && t <= BinXmlToken.Name)) - { - _pos = pos + 1; - return t; - } - } - return NextToken1(); - } - - // peek next non-meta token - private BinXmlToken PeekNextToken() - { - BinXmlToken token = NextToken(); - if (BinXmlToken.EOF != token) - _pos--; - return token; - } - - // like NextToken() but meta-tokens are skipped (not reinterpreted) - private BinXmlToken RescanNextToken() - { - BinXmlToken token; - while (true) - { - token = ReadToken(); - switch (token) - { - case BinXmlToken.Name: - { - int cb = ParseMB32(); - checked { _pos += 2 * cb; } - break; - } - case BinXmlToken.QName: - ParseMB32(); - ParseMB32(); - ParseMB32(); - break; - case BinXmlToken.Extn: - { - int cb = ParseMB32(); - checked { _pos += cb; } - break; - } - case BinXmlToken.NmFlush: - break; - default: - return token; - } - } - } - - private string ParseText() - { - int oldmark = _mark; - try - { - if (oldmark < 0) - _mark = _pos; - int cch, pos; - cch = ScanText(out pos); - return GetString(pos, cch); - } - finally - { - if (oldmark < 0) - _mark = -1; - } - } - - private int ScanText(out int start) - { - int cch = ParseMB32(); - int oldmark = _mark; - int begin = _pos; - checked { _pos += cch * 2; } // cch = num utf-16 chars - if (_pos > _end) - Fill(-1); - // Fill call might have moved buffer - start = begin - (oldmark - _mark); - return cch; - } - - private string GetString(int pos, int cch) - { - Debug.Assert(pos >= 0 && cch >= 0); - if (checked(pos + (cch * 2)) > _end) - throw new XmlException(ResXml.Xml_UnexpectedEOF1, (string[])null); - if (cch == 0) - return String.Empty; - // GetStringUnaligned is _significantly_ faster than unicode.GetString() - // but since IA64 doesn't support unaligned reads, we can't do it if - // the address is not aligned properly. Since the byte[] will be aligned, - // we can detect address alignment my just looking at the offset - if ((pos & 1) == 0) - return GetStringAligned(_data, pos, cch); - else - return _unicode.GetString(_data, pos, checked(cch * 2)); - } - - private unsafe String GetStringAligned(byte[] data, int offset, int cch) - { - Debug.Assert((offset & 1) == 0); - fixed (byte* pb = data) - { - char* p = (char*)(pb + offset); - return new String(p, 0, cch); - } - } - - private string GetAttributeText(int i) - { - string val = _attributes[i].val; - - if (null != val) - return val; - else - { - int origPos = _pos; - try - { - _pos = _attributes[i].contentPos; - BinXmlToken token = RescanNextToken(); - if (BinXmlToken.Attr == token || BinXmlToken.EndAttrs == token) - { - return ""; - } - _token = token; - ReScanOverValue(token); - return ValueAsString(token); - } - finally - { - _pos = origPos; - } - } - } - - private int LocateAttribute(string name, string ns) - { - for (int i = 0; i < _attrCount; i++) - { - if (_attributes[i].name.MatchNs(name, ns)) - return i; - } - - return -1; - } - - private int LocateAttribute(string name) - { - string prefix, lname; - ValidateNames.SplitQName(name, out prefix, out lname); - - for (int i = 0; i < _attrCount; i++) - { - if (_attributes[i].name.MatchPrefix(prefix, lname)) - return i; - } - - return -1; - } - - private void PositionOnAttribute(int i) - { - // save element's qname - _attrIndex = i; - _qnameOther = _attributes[i - 1].name; - if (_state == ScanState.Doc) - { - _parentNodeType = _nodetype; - } - _token = BinXmlToken.Attr; - _nodetype = XmlNodeType.Attribute; - _state = ScanState.Attr; - _valueType = TypeOfObject; - _stringValue = null; - } - - private void GrowElements() - { - int newcount = _elementStack.Length * 2; - ElemInfo[] n = new ElemInfo[newcount]; - - System.Array.Copy(_elementStack, 0, n, 0, _elementStack.Length); - _elementStack = n; - } - - private void GrowAttributes() - { - int newcount = _attributes.Length * 2; - AttrInfo[] n = new AttrInfo[newcount]; - - System.Array.Copy(_attributes, 0, n, 0, _attrCount); - _attributes = n; - } - - private void ClearAttributes() - { - if (_attrCount != 0) - _attrCount = 0; - } - - private void PushNamespace(string prefix, string ns, bool implied) - { - if (prefix == "xml") - return; - int elemDepth = _elemDepth; - NamespaceDecl curDecl; - _namespaces.TryGetValue(prefix, out curDecl); - if (null != curDecl) - { - if (curDecl.uri == ns) - { - // if we see the nsdecl after we saw the first reference in this scope - // fix up 'implied' flag - if (!implied && curDecl.implied - && (curDecl.scope == elemDepth)) - { - curDecl.implied = false; - } - return; - } - // check that this doesn't conflict - _qnameElement.CheckPrefixNS(prefix, ns); - if (prefix.Length != 0) - { - for (int i = 0; i < _attrCount; i++) - { - if (_attributes[i].name.prefix.Length != 0) - _attributes[i].name.CheckPrefixNS(prefix, ns); - } - } - } - // actually add ns decl - NamespaceDecl decl = new NamespaceDecl(prefix, ns, - _elementStack[elemDepth].nsdecls, - curDecl, elemDepth, implied); - _elementStack[elemDepth].nsdecls = decl; - _namespaces[prefix] = decl; - } - - private void PopNamespaces(NamespaceDecl firstInScopeChain) - { - NamespaceDecl decl = firstInScopeChain; - while (null != decl) - { - if (null == decl.prevLink) - _namespaces.Remove(decl.prefix); - else - _namespaces[decl.prefix] = decl.prevLink; - NamespaceDecl next = decl.scopeLink; - // unlink chains for better gc behaviour - decl.prevLink = null; - decl.scopeLink = null; - decl = next; - } - } - - private void GenerateImpliedXmlnsAttrs() - { - QName name; - NamespaceDecl decl = _elementStack[_elemDepth].nsdecls; - while (null != decl) - { - if (decl.implied) - { - if (_attrCount == _attributes.Length) - GrowAttributes(); - if (decl.prefix.Length == 0) - name = new QName(string.Empty, _xmlns, _nsxmlns); - else - name = new QName(_xmlns, _xnt.Add(decl.prefix), _nsxmlns); - _attributes[_attrCount].Set(name, decl.uri); - _attrCount++; - } - decl = decl.scopeLink; - } - } - - private bool ReadInit(bool skipXmlDecl) - { - string err = null; - if (!_sniffed) - { - // check magic header - ushort magic = ReadUShort(); - if (magic != 0xFFDF) - { - err = ResXml.XmlBinary_InvalidSignature; - goto Error; - } - } - - // check protocol version - _version = ReadByte(); - if (_version != 0x1 && _version != 0x2) - { - err = ResXml.XmlBinary_InvalidProtocolVersion; - goto Error; - } - - // check encoding marker, 1200 == utf16 - if (1200 != ReadUShort()) - { - err = ResXml.XmlBinary_UnsupportedCodePage; - goto Error; - } - - _state = ScanState.Doc; - if (BinXmlToken.XmlDecl == PeekToken()) - { - _pos++; - _attributes[0].Set(new QName(string.Empty, _xnt.Add("version"), string.Empty), ParseText()); - _attrCount = 1; - if (BinXmlToken.Encoding == PeekToken()) - { - _pos++; - _attributes[1].Set(new QName(string.Empty, _xnt.Add("encoding"), string.Empty), ParseText()); - _attrCount++; - } - - byte standalone = ReadByte(); - switch (standalone) - { - case 0: - break; - case 1: - case 2: - _attributes[_attrCount].Set(new QName(string.Empty, _xnt.Add("standalone"), string.Empty), (standalone == 1) ? "yes" : "no"); - _attrCount++; - break; - default: - err = ResXml.XmlBinary_InvalidStandalone; - goto Error; - } - if (!skipXmlDecl) - { - QName xmlDeclQName = new QName(String.Empty, _xnt.Add("xml"), String.Empty); - _qnameOther = _qnameElement = xmlDeclQName; - _nodetype = XmlNodeType.XmlDeclaration; - _posAfterAttrs = _pos; - return true; - } - // else ReadDoc will clear the attributes for us - } - return ReadDoc(); - - Error: - _state = ScanState.Error; - throw new XmlException(err, (string[])null); - } - - private void ScanAttributes() - { - BinXmlToken token; - int xmlspace = -1; - int xmllang = -1; - - _mark = _pos; - string curDeclPrefix = null; - bool lastWasValue = false; - - while (BinXmlToken.EndAttrs != (token = NextToken())) - { - if (BinXmlToken.Attr == token) - { - // watch out for nsdecl with no actual content - if (null != curDeclPrefix) - { - PushNamespace(curDeclPrefix, string.Empty, false); - curDeclPrefix = null; - } - // do we need to grow the array? - if (_attrCount == _attributes.Length) - GrowAttributes(); - // note: ParseMB32 _must_ happen _before_ we grab this.pos... - QName n = _symbolTables.qnametable[ReadQNameRef()]; - _attributes[_attrCount].Set(n, (int)_pos); - if (n.prefix == "xml") - { - if (n.localname == "lang") - { - xmllang = _attrCount; - } - else if (n.localname == "space") - { - xmlspace = _attrCount; - } - } - else if (Ref.Equal(n.namespaceUri, _nsxmlns)) - { - // push namespace when we get the value - curDeclPrefix = n.localname; - if (curDeclPrefix == "xmlns") - curDeclPrefix = string.Empty; - } - else if (n.prefix.Length != 0) - { - if (n.namespaceUri.Length == 0) - throw new XmlException(ResXml.Xml_PrefixForEmptyNs, String.Empty); - this.PushNamespace(n.prefix, n.namespaceUri, true); - } - else if (n.namespaceUri.Length != 0) - { - throw ThrowXmlException(ResXml.XmlBinary_AttrWithNsNoPrefix, n.localname, n.namespaceUri); - } - _attrCount++; - lastWasValue = false; - } - else - { - // first scan over token to make sure it is a value token - ScanOverValue(token, true, true); - // don't allow lists of values - if (lastWasValue) - { - throw ThrowNotSupported(ResXml.XmlBinary_ListsOfValuesNotSupported); - } - - // if char checking is on, we need to scan text values to - // validate that they don't use invalid CharData, so we - // might as well store the saved string for quick attr value access - string val = _stringValue; - if (null != val) - { - _attributes[_attrCount - 1].val = val; - _stringValue = null; - } - // namespace decls can only have text values, and should only - // have a single value, so we just grab it here... - if (null != curDeclPrefix) - { - string nsuri = _xnt.Add(ValueAsString(token)); - PushNamespace(curDeclPrefix, nsuri, false); - curDeclPrefix = null; - } - lastWasValue = true; - } - } - - if (xmlspace != -1) - { - string val = GetAttributeText(xmlspace); - XmlSpace xs = XmlSpace.None; - if (val == "preserve") - xs = XmlSpace.Preserve; - else if (val == "default") - xs = XmlSpace.Default; - _elementStack[_elemDepth].xmlSpace = xs; - _xmlspacePreserve = (XmlSpace.Preserve == xs); - } - if (xmllang != -1) - { - _elementStack[_elemDepth].xmlLang = GetAttributeText(xmllang); - } - - if (_attrCount < 200) - SimpleCheckForDuplicateAttributes(); - else - HashCheckForDuplicateAttributes(); - } - - private void SimpleCheckForDuplicateAttributes() - { - for (int i = 0; i < _attrCount; i++) - { - string localname, namespaceUri; - _attributes[i].GetLocalnameAndNamespaceUri(out localname, out namespaceUri); - for (int j = i + 1; j < _attrCount; j++) - { - if (_attributes[j].MatchNS(localname, namespaceUri)) - throw new XmlException(ResXml.Xml_DupAttributeName, _attributes[i].name.ToString()); - } - } - } - - private void HashCheckForDuplicateAttributes() - { - int tblSize = 256; - while (tblSize < _attrCount) - tblSize = checked(tblSize * 2); - if (_attrHashTbl.Length < tblSize) - _attrHashTbl = new int[tblSize]; - for (int i = 0; i < _attrCount; i++) - { - string localname, namespaceUri; - int hash = _attributes[i].GetLocalnameAndNamespaceUriAndHash(_hasher, out localname, out namespaceUri); - int index = hash & (tblSize - 1); - int next = _attrHashTbl[index]; - _attrHashTbl[index] = i + 1; - _attributes[i].prevHash = next; - while (next != 0) - { - next--; - if (_attributes[next].MatchHashNS(hash, localname, namespaceUri)) - { - throw new XmlException(ResXml.Xml_DupAttributeName, _attributes[i].name.ToString()); - } - next = _attributes[next].prevHash; - } - } - Array.Clear(_attrHashTbl, 0, tblSize); - } - - private string XmlDeclValue() - { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < _attrCount; i++) - { - if (i > 0) - sb.Append(' '); - sb.Append(_attributes[i].name.localname); - sb.Append("=\""); - sb.Append(_attributes[i].val); - sb.Append('"'); - } - return sb.ToString(); - } - - private string CDATAValue() - { - Debug.Assert(_stringValue == null, "this.stringValue == null"); - Debug.Assert(_token == BinXmlToken.CData, "this.token == BinXmlToken.CData"); - String value = GetString(_tokDataPos, _tokLen); - StringBuilder sb = null; - while (PeekToken() == BinXmlToken.CData) - { - _pos++; // skip over token byte - if (sb == null) - { - sb = new StringBuilder(value.Length + value.Length / 2); - sb.Append(value); - } - sb.Append(ParseText()); - } - if (sb != null) - value = sb.ToString(); - _stringValue = value; - return value; - } - - private void FinishCDATA() - { - for (; ; ) - { - switch (PeekToken()) - { - case BinXmlToken.CData: - // skip - _pos++; - int pos; - ScanText(out pos); - // try again - break; - case BinXmlToken.EndCData: - // done... on to next token... - _pos++; - return; - default: - throw new XmlException(ResXml.XmlBin_MissingEndCDATA); - } - } - } - - private void FinishEndElement() - { - NamespaceDecl nsdecls = _elementStack[_elemDepth].Clear(); - this.PopNamespaces(nsdecls); - _elemDepth--; - } - - private bool ReadDoc() - { - switch (_nodetype) - { - case XmlNodeType.CDATA: - FinishCDATA(); - break; - case XmlNodeType.EndElement: - FinishEndElement(); - break; - case XmlNodeType.Element: - if (_isEmpty) - { - FinishEndElement(); - _isEmpty = false; - } - break; - } - - Read: - // clear existing state - _nodetype = XmlNodeType.None; - _mark = -1; - if (_qnameOther.localname.Length != 0) - _qnameOther.Clear(); - - ClearAttributes(); - _attrCount = 0; - _valueType = TypeOfString; - _stringValue = null; - _hasTypedValue = false; - - _token = NextToken(); - switch (_token) - { - case BinXmlToken.EOF: - if (_elemDepth > 0) - throw new XmlException(ResXml.Xml_UnexpectedEOF1, (string[])null); - _state = ScanState.EOF; - return false; - - case BinXmlToken.Element: - ImplReadElement(); - break; - - case BinXmlToken.EndElem: - ImplReadEndElement(); - break; - - case BinXmlToken.DocType: - ImplReadDoctype(); - if (_dtdProcessing == DtdProcessing.Ignore) - goto Read; - // nested, don't report doctype - if (_prevNameInfo != null) - goto Read; - break; - - case BinXmlToken.PI: - ImplReadPI(); - if (_ignorePIs) - goto Read; - break; - - case BinXmlToken.Comment: - ImplReadComment(); - if (_ignoreComments) - goto Read; - break; - - case BinXmlToken.CData: - ImplReadCDATA(); - break; - - case BinXmlToken.Nest: - ImplReadNest(); - // parse first token in nested document - _sniffed = false; - return ReadInit(true); - - case BinXmlToken.EndNest: - if (null == _prevNameInfo) - goto default; - ImplReadEndNest(); - return ReadDoc(); - - case BinXmlToken.XmlText: - ImplReadXmlText(); - break; - - // text values - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - ImplReadData(_token); - if (XmlNodeType.Text == _nodetype) - CheckAllowContent(); - else if (_ignoreWhitespace && !_xmlspacePreserve) - goto Read; // skip to next token - return true; - - default: - throw ThrowUnexpectedToken(_token); - } - - return true; - } - - private void ImplReadData(BinXmlToken tokenType) - { - Debug.Assert(_mark < 0); - _mark = _pos; - - switch (tokenType) - { - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - _valueType = TypeOfString; - _hasTypedValue = false; - break; - default: - _valueType = GetValueType(_token); - _hasTypedValue = true; - break; - } - - _nodetype = ScanOverValue(_token, false, true); - - // we don't support lists of values - BinXmlToken tNext = PeekNextToken(); - switch (tNext) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_UUID: - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.XSD_QNAME: - throw ThrowNotSupported(ResXml.XmlBinary_ListsOfValuesNotSupported); - default: - break; - } - } - - private void ImplReadElement() - { - if (3 != _docState || 9 != _docState) - { - switch (_docState) - { - case 0: - _docState = 9; - break; - case 1: - case 2: - _docState = 3; - break; - case -1: - throw ThrowUnexpectedToken(_token); - default: - break; - } - } - _elemDepth++; - if (_elemDepth == _elementStack.Length) - GrowElements(); - QName qname = _symbolTables.qnametable[ReadQNameRef()]; - _qnameOther = _qnameElement = qname; - _elementStack[_elemDepth].Set(qname, _xmlspacePreserve); - this.PushNamespace(qname.prefix, qname.namespaceUri, true); - BinXmlToken t = PeekNextToken(); - if (BinXmlToken.Attr == t) - { - ScanAttributes(); - t = PeekNextToken(); - } - GenerateImpliedXmlnsAttrs(); - if (BinXmlToken.EndElem == t) - { - NextToken(); // move over token... - _isEmpty = true; - } - else if (BinXmlToken.SQL_NVARCHAR == t) - { - if (_mark < 0) - _mark = _pos; - // skip over token byte - _pos++; - // is this a zero-length string? if yes, skip it. - // (It just indicates that this is _not_ an empty element) - // Also make sure that the following token is an EndElem - if (0 == ReadByte()) - { - if (BinXmlToken.EndElem != (BinXmlToken)ReadByte()) - { - Debug.Assert(_pos >= 3); - _pos -= 3; // jump back to start of NVarChar token - } - else - { - Debug.Assert(_pos >= 1); - _pos -= 1; // jump back to EndElem token - } - } - else - { - Debug.Assert(_pos >= 2); - _pos -= 2; // jump back to start of NVarChar token - } - } - _nodetype = XmlNodeType.Element; - _valueType = TypeOfObject; - _posAfterAttrs = _pos; - } - - private void ImplReadEndElement() - { - if (_elemDepth == 0) - throw ThrowXmlException(ResXml.Xml_UnexpectedEndTag); - int index = _elemDepth; - if (1 == index && 3 == _docState) - _docState = -1; - _qnameOther = _elementStack[index].name; - _xmlspacePreserve = _elementStack[index].xmlspacePreserve; - _nodetype = XmlNodeType.EndElement; - } - - private void ImplReadDoctype() - { - if (_dtdProcessing == DtdProcessing.Prohibit) - throw ThrowXmlException(ResXml.Xml_DtdIsProhibited); - // 0=>auto, 1=>doc/pre-dtd, 2=>doc/pre-elem, 3=>doc/instance -1=>doc/post-elem, 9=>frag - switch (_docState) - { - case 0: // 0=>auto - case 1: // 1=>doc/pre-dtd - break; - case 9: // 9=>frag - throw ThrowXmlException(ResXml.Xml_DtdNotAllowedInFragment); - default: // 2=>doc/pre-elem, 3=>doc/instance -1=>doc/post-elem - throw ThrowXmlException(ResXml.Xml_BadDTDLocation); - } - _docState = 2; - _qnameOther.localname = ParseText(); - if (BinXmlToken.System == PeekToken()) - { - _pos++; - _attributes[_attrCount++].Set(new QName(string.Empty, _xnt.Add("SYSTEM"), string.Empty), ParseText()); - } - if (BinXmlToken.Public == PeekToken()) - { - _pos++; - _attributes[_attrCount++].Set(new QName(string.Empty, _xnt.Add("PUBLIC"), string.Empty), ParseText()); - } - if (BinXmlToken.Subset == PeekToken()) - { - _pos++; - _mark = _pos; - _tokLen = ScanText(out _tokDataPos); - } - else - { - _tokLen = _tokDataPos = 0; - } - _nodetype = XmlNodeType.DocumentType; - _posAfterAttrs = _pos; - } - - private void ImplReadPI() - { - _qnameOther.localname = _symbolTables.symtable[ReadNameRef()]; - _mark = _pos; - _tokLen = ScanText(out _tokDataPos); - _nodetype = XmlNodeType.ProcessingInstruction; - } - - private void ImplReadComment() - { - _nodetype = XmlNodeType.Comment; - _mark = _pos; - _tokLen = ScanText(out _tokDataPos); - } - - private void ImplReadCDATA() - { - CheckAllowContent(); - _nodetype = XmlNodeType.CDATA; - _mark = _pos; - _tokLen = ScanText(out _tokDataPos); - } - - private void ImplReadNest() - { - CheckAllowContent(); - // push current nametables - _prevNameInfo = new NestedBinXml(_symbolTables, _docState, _prevNameInfo); - _symbolTables.Init(); - _docState = 0; // auto - } - - private void ImplReadEndNest() - { - NestedBinXml nested = _prevNameInfo; - _symbolTables = nested.symbolTables; - _docState = nested.docState; - _prevNameInfo = nested.next; - } - - private void ImplReadXmlText() - { - CheckAllowContent(); - string xmltext = ParseText(); - XmlNamespaceManager xnm = new XmlNamespaceManager(_xnt); - foreach (NamespaceDecl decl in _namespaces.Values) - { - if (decl.scope > 0) - { -#if DEBUG - if ((object)decl.prefix != (object)_xnt.Get(decl.prefix)) - throw new Exception("Prefix not interned: \'" + decl.prefix + "\'"); - if ((object)decl.uri != (object)_xnt.Get(decl.uri)) - throw new Exception("Uri not interned: \'" + decl.uri + "\'"); -#endif - xnm.AddNamespace(decl.prefix, decl.uri); - } - } - XmlReaderSettings settings = this.Settings; - settings.ReadOnly = false; - settings.NameTable = _xnt; - settings.DtdProcessing = DtdProcessing.Prohibit; - if (0 != _elemDepth) - { - settings.ConformanceLevel = ConformanceLevel.Fragment; - } - settings.ReadOnly = true; - XmlParserContext xpc = new XmlParserContext(_xnt, xnm, this.XmlLang, this.XmlSpace); - _textXmlReader = new XmlTextReaderImpl(xmltext, xpc, settings); - if (!_textXmlReader.Read() - || ((_textXmlReader.NodeType == XmlNodeType.XmlDeclaration) - && !_textXmlReader.Read())) - { - _state = ScanState.Doc; - ReadDoc(); - } - else - { - _state = ScanState.XmlText; - UpdateFromTextReader(); - } - } - - private void UpdateFromTextReader() - { - XmlReader r = _textXmlReader; - _nodetype = r.NodeType; - _qnameOther.prefix = r.Prefix; - _qnameOther.localname = r.LocalName; - _qnameOther.namespaceUri = r.NamespaceURI; - _valueType = r.ValueType; - _isEmpty = r.IsEmptyElement; - } - - private bool UpdateFromTextReader(bool needUpdate) - { - if (needUpdate) - UpdateFromTextReader(); - return needUpdate; - } - - private void CheckAllowContent() - { - switch (_docState) - { - case 0: // auto - _docState = 9; - break; - case 9: // conformance = fragment - case 3: - break; - default: - throw ThrowXmlException(ResXml.Xml_InvalidRootData); - } - } - - private void GenerateTokenTypeMap() - { - Type[] map = new Type[256]; - map[(int)BinXmlToken.XSD_BOOLEAN] = typeof(System.Boolean); - map[(int)BinXmlToken.SQL_TINYINT] = typeof(System.Byte); - map[(int)BinXmlToken.XSD_BYTE] = typeof(System.SByte); - map[(int)BinXmlToken.SQL_SMALLINT] = typeof(Int16); - map[(int)BinXmlToken.XSD_UNSIGNEDSHORT] = typeof(UInt16); - map[(int)BinXmlToken.XSD_UNSIGNEDINT] = typeof(UInt32); - map[(int)BinXmlToken.SQL_REAL] = typeof(Single); - map[(int)BinXmlToken.SQL_FLOAT] = typeof(Double); - map[(int)BinXmlToken.SQL_BIGINT] = typeof(Int64); - map[(int)BinXmlToken.XSD_UNSIGNEDLONG] = typeof(UInt64); - map[(int)BinXmlToken.XSD_QNAME] = typeof(XmlQualifiedName); - Type TypeOfInt32 = typeof(System.Int32); - map[(int)BinXmlToken.SQL_BIT] = TypeOfInt32; - map[(int)BinXmlToken.SQL_INT] = TypeOfInt32; - Type TypeOfDecimal = typeof(System.Decimal); - map[(int)BinXmlToken.SQL_SMALLMONEY] = TypeOfDecimal; - map[(int)BinXmlToken.SQL_MONEY] = TypeOfDecimal; - map[(int)BinXmlToken.SQL_DECIMAL] = TypeOfDecimal; - map[(int)BinXmlToken.SQL_NUMERIC] = TypeOfDecimal; - map[(int)BinXmlToken.XSD_DECIMAL] = TypeOfDecimal; - Type TypeOfDateTime = typeof(System.DateTime); - map[(int)BinXmlToken.SQL_SMALLDATETIME] = TypeOfDateTime; - map[(int)BinXmlToken.SQL_DATETIME] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_TIME] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_DATETIME] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_DATE] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_KATMAI_DATE] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_KATMAI_DATETIME] = TypeOfDateTime; - map[(int)BinXmlToken.XSD_KATMAI_TIME] = TypeOfDateTime; - Type TypeOfDateTimeOffset = typeof(System.DateTimeOffset); - map[(int)BinXmlToken.XSD_KATMAI_DATEOFFSET] = TypeOfDateTimeOffset; - map[(int)BinXmlToken.XSD_KATMAI_DATETIMEOFFSET] = TypeOfDateTimeOffset; - map[(int)BinXmlToken.XSD_KATMAI_TIMEOFFSET] = TypeOfDateTimeOffset; - Type TypeOfByteArray = typeof(System.Byte[]); - map[(int)BinXmlToken.SQL_VARBINARY] = TypeOfByteArray; - map[(int)BinXmlToken.SQL_BINARY] = TypeOfByteArray; - map[(int)BinXmlToken.SQL_IMAGE] = TypeOfByteArray; - map[(int)BinXmlToken.SQL_UDT] = TypeOfByteArray; - map[(int)BinXmlToken.XSD_BINHEX] = TypeOfByteArray; - map[(int)BinXmlToken.XSD_BASE64] = TypeOfByteArray; - map[(int)BinXmlToken.SQL_CHAR] = TypeOfString; - map[(int)BinXmlToken.SQL_VARCHAR] = TypeOfString; - map[(int)BinXmlToken.SQL_TEXT] = TypeOfString; - map[(int)BinXmlToken.SQL_NCHAR] = TypeOfString; - map[(int)BinXmlToken.SQL_NVARCHAR] = TypeOfString; - map[(int)BinXmlToken.SQL_NTEXT] = TypeOfString; - map[(int)BinXmlToken.SQL_UUID] = TypeOfString; - if (s_tokenTypeMap == null) - s_tokenTypeMap = map; - } - - private System.Type GetValueType(BinXmlToken token) - { - Type t = s_tokenTypeMap[(int)token]; - if (t == null) - throw ThrowUnexpectedToken(token); - return t; - } - - // helper method... - private void ReScanOverValue(BinXmlToken token) - { - ScanOverValue(token, true, false); - } - - private XmlNodeType ScanOverValue(BinXmlToken token, bool attr, bool checkChars) - { - if (token == BinXmlToken.SQL_NVARCHAR) - { - if (_mark < 0) - _mark = _pos; - _tokLen = ParseMB32(); - _tokDataPos = _pos; - checked { _pos += _tokLen * 2; } - Fill(-1); - // check chars (if this is the first pass and settings.CheckCharacters was set) - if (checkChars && _checkCharacters) - { - // check for invalid chardata - return CheckText(attr); - } - else if (!attr) - { // attribute values are always reported as Text - // check for whitespace-only text - return CheckTextIsWS(); - } - else - { - return XmlNodeType.Text; - } - } - else - { - return ScanOverAnyValue(token, attr, checkChars); - } - } - - private XmlNodeType ScanOverAnyValue(BinXmlToken token, bool attr, bool checkChars) - { - if (_mark < 0) - _mark = _pos; - checked - { - switch (token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.XSD_BOOLEAN: - case BinXmlToken.XSD_BYTE: - _tokDataPos = _pos; - _tokLen = 1; - _pos += 1; - break; - - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.XSD_UNSIGNEDSHORT: - _tokDataPos = _pos; - _tokLen = 2; - _pos += 2; - break; - - case BinXmlToken.SQL_INT: - case BinXmlToken.XSD_UNSIGNEDINT: - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_SMALLDATETIME: - _tokDataPos = _pos; - _tokLen = 4; - _pos += 4; - break; - - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.XSD_UNSIGNEDLONG: - case BinXmlToken.SQL_FLOAT: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_DATE: - _tokDataPos = _pos; - _tokLen = 8; - _pos += 8; - break; - - case BinXmlToken.SQL_UUID: - _tokDataPos = _pos; - _tokLen = 16; - _pos += 16; - break; - - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - _tokDataPos = _pos; - _tokLen = ParseMB64(); - _pos += _tokLen; - break; - - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_BINHEX: - case BinXmlToken.XSD_BASE64: - _tokLen = ParseMB64(); - _tokDataPos = _pos; - _pos += _tokLen; - break; - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - _tokLen = ParseMB64(); - _tokDataPos = _pos; - _pos += _tokLen; - if (checkChars && _checkCharacters) - { - // check for invalid chardata - Fill(-1); - string val = ValueAsString(token); - XmlConvert.VerifyCharData(val, ExceptionType.ArgumentException, ExceptionType.XmlException); - _stringValue = val; - } - break; - - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NTEXT: - return ScanOverValue(BinXmlToken.SQL_NVARCHAR, attr, checkChars); - - case BinXmlToken.XSD_QNAME: - _tokDataPos = _pos; - ParseMB32(); - break; - - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - VerifyVersion(2, token); - _tokDataPos = _pos; - _tokLen = GetXsdKatmaiTokenLength(token); - _pos += _tokLen; - break; - - default: - throw ThrowUnexpectedToken(token); - } - } - Fill(-1); - return XmlNodeType.Text; - } - - private unsafe XmlNodeType CheckText(bool attr) - { - Debug.Assert(_checkCharacters, "this.checkCharacters"); - // assert that size is an even number - Debug.Assert(0 == ((_pos - _tokDataPos) & 1), "Data size should not be odd"); - // grab local copy (perf) - XmlCharType xmlCharType = _xmlCharType; - - fixed (byte* pb = _data) - { - int end = _pos; - int pos = _tokDataPos; - - if (!attr) - { - // scan if this is whitespace - for (; ; ) - { - int posNext = pos + 2; - if (posNext > end) - return _xmlspacePreserve ? XmlNodeType.SignificantWhitespace : XmlNodeType.Whitespace; - if (pb[pos + 1] != 0 || (xmlCharType.charProperties[pb[pos]] & XmlCharType.fWhitespace) == 0) - break; - pos = posNext; - } - } - - for (; ; ) - { - char ch; - for (; ; ) - { - int posNext = pos + 2; - if (posNext > end) - return XmlNodeType.Text; - ch = (char)(pb[pos] | ((int)(pb[pos + 1]) << 8)); - if ((xmlCharType.charProperties[ch] & XmlCharType.fCharData) == 0) - break; - pos = posNext; - } - - if (!XmlCharType.IsHighSurrogate(ch)) - { - throw XmlConvert.CreateInvalidCharException(ch, '\0', ExceptionType.XmlException); - } - else - { - if ((pos + 4) > end) - { - throw ThrowXmlException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - char chNext = (char)(pb[pos + 2] | ((int)(pb[pos + 3]) << 8)); - if (!XmlCharType.IsLowSurrogate(chNext)) - { - throw XmlConvert.CreateInvalidSurrogatePairException(ch, chNext); - } - } - pos += 4; - } - } - } - - private XmlNodeType CheckTextIsWS() - { - Debug.Assert(!_checkCharacters, "!this.checkCharacters"); - byte[] data = _data; - // assert that size is an even number - Debug.Assert(0 == ((_pos - _tokDataPos) & 1), "Data size should not be odd"); - for (int pos = _tokDataPos; pos < _pos; pos += 2) - { - if (0 != data[pos + 1]) - goto NonWSText; - switch (data[pos]) - { - case 0x09: // tab - case 0x0A: // nl - case 0x0D: // cr - case 0x20: // space - break; - default: - goto NonWSText; - } - } - if (_xmlspacePreserve) - return XmlNodeType.SignificantWhitespace; - return XmlNodeType.Whitespace; - NonWSText: - return XmlNodeType.Text; - } - - private void CheckValueTokenBounds() - { - if ((_end - _tokDataPos) < _tokLen) - throw ThrowXmlException(ResXml.Xml_UnexpectedEOF1); - } - - private int GetXsdKatmaiTokenLength(BinXmlToken token) - { - byte scale; - switch (token) - { - case BinXmlToken.XSD_KATMAI_DATE: - // SQL Katmai type DATE = date(3b) - return 3; - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATETIME: - // SQL Katmai type DATETIME2 = scale(1b) + time(3-5b) + date(3b) - Fill(0); - scale = _data[_pos]; - return 4 + XsdKatmaiTimeScaleToValueLength(scale); - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - // SQL Katmai type DATETIMEOFFSET = scale(1b) + time(3-5b) + date(3b) + zone(2b) - Fill(0); - scale = _data[_pos]; - return 6 + XsdKatmaiTimeScaleToValueLength(scale); - default: - throw ThrowUnexpectedToken(_token); - } - } - - private int XsdKatmaiTimeScaleToValueLength(byte scale) - { - if (scale > 7) - { - throw new XmlException(ResXml.SqlTypes_ArithOverflow, (string)null); - } - return s_xsdKatmaiTimeScaleToValueLengthMap[scale]; - } - - private long ValueAsLong() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - { - byte v = _data[_tokDataPos]; - return v; - } - - case BinXmlToken.XSD_BYTE: - { - sbyte v = unchecked((sbyte)_data[_tokDataPos]); - return v; - } - - case BinXmlToken.SQL_SMALLINT: - return GetInt16(_tokDataPos); - - case BinXmlToken.SQL_INT: - return GetInt32(_tokDataPos); - - case BinXmlToken.SQL_BIGINT: - return GetInt64(_tokDataPos); - - case BinXmlToken.XSD_UNSIGNEDSHORT: - return GetUInt16(_tokDataPos); - - case BinXmlToken.XSD_UNSIGNEDINT: - return GetUInt32(_tokDataPos); - - case BinXmlToken.XSD_UNSIGNEDLONG: - { - ulong v = GetUInt64(_tokDataPos); - return checked((long)v); - } - - case BinXmlToken.SQL_REAL: - case BinXmlToken.SQL_FLOAT: - { - double v = ValueAsDouble(); - return (long)v; - } - - case BinXmlToken.SQL_MONEY: - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - case BinXmlToken.XSD_DECIMAL: - { - Decimal v = ValueAsDecimal(); - return (long)v; - } - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private ulong ValueAsULong() - { - if (BinXmlToken.XSD_UNSIGNEDLONG == _token) - { - CheckValueTokenBounds(); - return GetUInt64(_tokDataPos); - } - else - { - throw ThrowUnexpectedToken(_token); - } - } - - private Decimal ValueAsDecimal() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - return new Decimal(ValueAsLong()); - - case BinXmlToken.XSD_UNSIGNEDLONG: - return new Decimal(ValueAsULong()); - - case BinXmlToken.SQL_REAL: - return new Decimal(GetSingle(_tokDataPos)); - - case BinXmlToken.SQL_FLOAT: - return new Decimal(GetDouble(_tokDataPos)); - - case BinXmlToken.SQL_SMALLMONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt32(_tokDataPos)); - return v.ToDecimal(); - } - case BinXmlToken.SQL_MONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt64(_tokDataPos)); - return v.ToDecimal(); - } - - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - { - BinXmlSqlDecimal v = new BinXmlSqlDecimal(_data, _tokDataPos, _token == BinXmlToken.XSD_DECIMAL); - return v.ToDecimal(); - } - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private double ValueAsDouble() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - return (double)ValueAsLong(); - - case BinXmlToken.XSD_UNSIGNEDLONG: - return (double)ValueAsULong(); - - case BinXmlToken.SQL_REAL: - return GetSingle(_tokDataPos); - - case BinXmlToken.SQL_FLOAT: - return GetDouble(_tokDataPos); - - case BinXmlToken.SQL_SMALLMONEY: - case BinXmlToken.SQL_MONEY: - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - return (double)ValueAsDecimal(); - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private DateTime ValueAsDateTime() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.SQL_DATETIME: - { - int pos = _tokDataPos; - int dateticks; uint timeticks; - dateticks = GetInt32(pos); - timeticks = GetUInt32(pos + 4); - return BinXmlDateTime.SqlDateTimeToDateTime(dateticks, timeticks); - } - - case BinXmlToken.SQL_SMALLDATETIME: - { - int pos = _tokDataPos; - short dateticks; ushort timeticks; - dateticks = GetInt16(pos); - timeticks = GetUInt16(pos + 2); - return BinXmlDateTime.SqlSmallDateTimeToDateTime(dateticks, timeticks); - } - - case BinXmlToken.XSD_TIME: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdTimeToDateTime(time); - } - - case BinXmlToken.XSD_DATE: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdDateToDateTime(time); - } - - case BinXmlToken.XSD_DATETIME: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdDateTimeToDateTime(time); - } - - case BinXmlToken.XSD_KATMAI_DATE: - return BinXmlDateTime.XsdKatmaiDateToDateTime(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATETIME: - return BinXmlDateTime.XsdKatmaiDateTimeToDateTime(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_TIME: - return BinXmlDateTime.XsdKatmaiTimeToDateTime(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - return BinXmlDateTime.XsdKatmaiDateOffsetToDateTime(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - return BinXmlDateTime.XsdKatmaiDateTimeOffsetToDateTime(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - return BinXmlDateTime.XsdKatmaiTimeOffsetToDateTime(_data, _tokDataPos); - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private DateTimeOffset ValueAsDateTimeOffset() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - return BinXmlDateTime.XsdKatmaiDateOffsetToDateTimeOffset(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - return BinXmlDateTime.XsdKatmaiDateTimeOffsetToDateTimeOffset(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - return BinXmlDateTime.XsdKatmaiTimeOffsetToDateTimeOffset(_data, _tokDataPos); - - default: - throw ThrowUnexpectedToken(_token); - } - } - - - private string ValueAsDateTimeString() - { - CheckValueTokenBounds(); - switch (_token) - { - case BinXmlToken.SQL_DATETIME: - { - int pos = _tokDataPos; - int dateticks; uint timeticks; - dateticks = GetInt32(pos); - timeticks = GetUInt32(pos + 4); - return BinXmlDateTime.SqlDateTimeToString(dateticks, timeticks); - } - - case BinXmlToken.SQL_SMALLDATETIME: - { - int pos = _tokDataPos; - short dateticks; ushort timeticks; - dateticks = GetInt16(pos); - timeticks = GetUInt16(pos + 2); - return BinXmlDateTime.SqlSmallDateTimeToString(dateticks, timeticks); - } - - case BinXmlToken.XSD_TIME: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdTimeToString(time); - } - - case BinXmlToken.XSD_DATE: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdDateToString(time); - } - - case BinXmlToken.XSD_DATETIME: - { - long time = GetInt64(_tokDataPos); - return BinXmlDateTime.XsdDateTimeToString(time); - } - - case BinXmlToken.XSD_KATMAI_DATE: - return BinXmlDateTime.XsdKatmaiDateToString(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATETIME: - return BinXmlDateTime.XsdKatmaiDateTimeToString(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_TIME: - return BinXmlDateTime.XsdKatmaiTimeToString(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - return BinXmlDateTime.XsdKatmaiDateOffsetToString(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - return BinXmlDateTime.XsdKatmaiDateTimeOffsetToString(_data, _tokDataPos); - - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - return BinXmlDateTime.XsdKatmaiTimeOffsetToString(_data, _tokDataPos); - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private string ValueAsString(BinXmlToken token) - { - try - { - CheckValueTokenBounds(); - switch (token) - { - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - return GetString(_tokDataPos, _tokLen); - - case BinXmlToken.XSD_BOOLEAN: - { - if (0 == _data[_tokDataPos]) - return "false"; - else - return "true"; - } - - case BinXmlToken.SQL_BIT: - case BinXmlToken.SQL_TINYINT: - case BinXmlToken.SQL_SMALLINT: - case BinXmlToken.SQL_INT: - case BinXmlToken.SQL_BIGINT: - case BinXmlToken.XSD_BYTE: - case BinXmlToken.XSD_UNSIGNEDSHORT: - case BinXmlToken.XSD_UNSIGNEDINT: - return ValueAsLong().ToString(CultureInfo.InvariantCulture); - - case BinXmlToken.XSD_UNSIGNEDLONG: - return ValueAsULong().ToString(CultureInfo.InvariantCulture); - - case BinXmlToken.SQL_REAL: - return XmlConvert.ToString(GetSingle(_tokDataPos)); - - case BinXmlToken.SQL_FLOAT: - return XmlConvert.ToString(GetDouble(_tokDataPos)); - - case BinXmlToken.SQL_UUID: - { - int a; short b, c; - int pos = _tokDataPos; - a = GetInt32(pos); - b = GetInt16(pos + 4); - c = GetInt16(pos + 6); - Guid v = new Guid(a, b, c, _data[pos + 8], _data[pos + 9], _data[pos + 10], _data[pos + 11], _data[pos + 12], _data[pos + 13], _data[pos + 14], _data[pos + 15]); - return v.ToString(); - } - - case BinXmlToken.SQL_SMALLMONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt32(_tokDataPos)); - return v.ToString(); - } - case BinXmlToken.SQL_MONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt64(_tokDataPos)); - return v.ToString(); - } - - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - { - BinXmlSqlDecimal v = new BinXmlSqlDecimal(_data, _tokDataPos, token == BinXmlToken.XSD_DECIMAL); - return v.ToString(); - } - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - { - int pos = _tokDataPos; - int codepage = GetInt32(pos); - Encoding enc = System.Text.Encoding.GetEncoding(codepage); - return enc.GetString(_data, pos + 4, _tokLen - 4); - } - - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_BASE64: - { - return Convert.ToBase64String(_data, _tokDataPos, _tokLen); - } - - case BinXmlToken.XSD_BINHEX: - return BinHexEncoder.Encode(_data, _tokDataPos, _tokLen); - - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - return ValueAsDateTimeString(); - - case BinXmlToken.XSD_QNAME: - { - int nameNum = ParseMB32(_tokDataPos); - if (nameNum < 0 || nameNum >= _symbolTables.qnameCount) - throw new XmlException(ResXml.XmlBin_InvalidQNameID, String.Empty); - QName qname = _symbolTables.qnametable[nameNum]; - if (qname.prefix.Length == 0) - return qname.localname; - else - return String.Concat(qname.prefix, ":", qname.localname); - } - - default: - throw ThrowUnexpectedToken(_token); - } - } - catch - { - _state = ScanState.Error; - throw; - } - } - - private object ValueAsObject(BinXmlToken token, bool returnInternalTypes) - { - CheckValueTokenBounds(); - switch (token) - { - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - return GetString(_tokDataPos, _tokLen); - - case BinXmlToken.XSD_BOOLEAN: - return (0 != _data[_tokDataPos]); - - case BinXmlToken.SQL_BIT: - return (Int32)_data[_tokDataPos]; - - case BinXmlToken.SQL_TINYINT: - return _data[_tokDataPos]; - - case BinXmlToken.SQL_SMALLINT: - return GetInt16(_tokDataPos); - - case BinXmlToken.SQL_INT: - return GetInt32(_tokDataPos); - - case BinXmlToken.SQL_BIGINT: - return GetInt64(_tokDataPos); - - case BinXmlToken.XSD_BYTE: - { - sbyte v = unchecked((sbyte)_data[_tokDataPos]); - return v; - } - - case BinXmlToken.XSD_UNSIGNEDSHORT: - return GetUInt16(_tokDataPos); - - case BinXmlToken.XSD_UNSIGNEDINT: - return GetUInt32(_tokDataPos); - - case BinXmlToken.XSD_UNSIGNEDLONG: - return GetUInt64(_tokDataPos); - - case BinXmlToken.SQL_REAL: - return GetSingle(_tokDataPos); - - case BinXmlToken.SQL_FLOAT: - return GetDouble(_tokDataPos); - - case BinXmlToken.SQL_UUID: - { - int a; short b, c; - int pos = _tokDataPos; - a = GetInt32(pos); - b = GetInt16(pos + 4); - c = GetInt16(pos + 6); - Guid v = new Guid(a, b, c, _data[pos + 8], _data[pos + 9], _data[pos + 10], _data[pos + 11], _data[pos + 12], _data[pos + 13], _data[pos + 14], _data[pos + 15]); - return v.ToString(); - } - - case BinXmlToken.SQL_SMALLMONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt32(_tokDataPos)); - if (returnInternalTypes) - return v; - else - return v.ToDecimal(); - } - - case BinXmlToken.SQL_MONEY: - { - BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt64(_tokDataPos)); - if (returnInternalTypes) - return v; - else - return v.ToDecimal(); - } - - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - { - BinXmlSqlDecimal v = new BinXmlSqlDecimal(_data, _tokDataPos, token == BinXmlToken.XSD_DECIMAL); - if (returnInternalTypes) - return v; - else - return v.ToDecimal(); - } - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - { - int pos = _tokDataPos; - int codepage = GetInt32(pos); - Encoding enc = System.Text.Encoding.GetEncoding(codepage); - return enc.GetString(_data, pos + 4, _tokLen - 4); - } - - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BINHEX: - { - byte[] data = new byte[_tokLen]; - Array.Copy(_data, _tokDataPos, data, 0, _tokLen); - return data; - } - - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.XSD_TIME: - case BinXmlToken.XSD_DATE: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - return ValueAsDateTime(); - - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - return ValueAsDateTimeOffset(); - - case BinXmlToken.XSD_QNAME: - { - int nameNum = ParseMB32(_tokDataPos); - if (nameNum < 0 || nameNum >= _symbolTables.qnameCount) - throw new XmlException(ResXml.XmlBin_InvalidQNameID, String.Empty); - QName qname = _symbolTables.qnametable[nameNum]; - return new XmlQualifiedName(qname.localname, qname.namespaceUri); - } - - default: - throw ThrowUnexpectedToken(_token); - } - } - - private XmlValueConverter GetValueConverter(XmlTypeCode typeCode) - { - XmlSchemaSimpleType xsst = DatatypeImplementation.GetSimpleTypeFromTypeCode(typeCode); - return xsst.ValueConverter; - } - - private object ValueAs(BinXmlToken token, Type returnType, IXmlNamespaceResolver namespaceResolver) - { - object value; - CheckValueTokenBounds(); - switch (token) - { - case BinXmlToken.SQL_NCHAR: - case BinXmlToken.SQL_NVARCHAR: - case BinXmlToken.SQL_NTEXT: - value = GetValueConverter(XmlTypeCode.UntypedAtomic).ChangeType( - GetString(_tokDataPos, _tokLen), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_BOOLEAN: - value = GetValueConverter(XmlTypeCode.Boolean).ChangeType( - (0 != _data[_tokDataPos]), - returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_BIT: - value = GetValueConverter(XmlTypeCode.NonNegativeInteger).ChangeType( - (Int32)_data[_tokDataPos], - returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_TINYINT: - value = GetValueConverter(XmlTypeCode.UnsignedByte).ChangeType( - _data[_tokDataPos], - returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_SMALLINT: - { - int v = GetInt16(_tokDataPos); - value = GetValueConverter(XmlTypeCode.Short).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.SQL_INT: - { - int v = GetInt32(_tokDataPos); - value = GetValueConverter(XmlTypeCode.Int).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.SQL_BIGINT: - { - long v = GetInt64(_tokDataPos); - value = GetValueConverter(XmlTypeCode.Long).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.XSD_BYTE: - { - value = GetValueConverter(XmlTypeCode.Byte).ChangeType( - (int)unchecked((sbyte)_data[_tokDataPos]), - returnType, namespaceResolver); - break; - } - case BinXmlToken.XSD_UNSIGNEDSHORT: - { - int v = GetUInt16(_tokDataPos); - value = GetValueConverter(XmlTypeCode.UnsignedShort).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.XSD_UNSIGNEDINT: - { - long v = GetUInt32(_tokDataPos); - value = GetValueConverter(XmlTypeCode.UnsignedInt).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.XSD_UNSIGNEDLONG: - { - Decimal v = (Decimal)GetUInt64(_tokDataPos); - value = GetValueConverter(XmlTypeCode.UnsignedLong).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.SQL_REAL: - { - Single v = GetSingle(_tokDataPos); - value = GetValueConverter(XmlTypeCode.Float).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.SQL_FLOAT: - { - Double v = GetDouble(_tokDataPos); - value = GetValueConverter(XmlTypeCode.Double).ChangeType( - v, returnType, namespaceResolver); - break; - } - case BinXmlToken.SQL_UUID: - value = GetValueConverter(XmlTypeCode.String).ChangeType( - this.ValueAsString(token), returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_SMALLMONEY: - value = GetValueConverter(XmlTypeCode.Decimal).ChangeType( - (new BinXmlSqlMoney(GetInt32(_tokDataPos))).ToDecimal(), - returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_MONEY: - value = GetValueConverter(XmlTypeCode.Decimal).ChangeType( - (new BinXmlSqlMoney(GetInt64(_tokDataPos))).ToDecimal(), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_DECIMAL: - case BinXmlToken.SQL_DECIMAL: - case BinXmlToken.SQL_NUMERIC: - value = GetValueConverter(XmlTypeCode.Decimal).ChangeType( - (new BinXmlSqlDecimal(_data, _tokDataPos, token == BinXmlToken.XSD_DECIMAL)).ToDecimal(), - returnType, namespaceResolver); - break; - - case BinXmlToken.SQL_CHAR: - case BinXmlToken.SQL_VARCHAR: - case BinXmlToken.SQL_TEXT: - { - int pos = _tokDataPos; - int codepage = GetInt32(pos); - Encoding enc = System.Text.Encoding.GetEncoding(codepage); - value = GetValueConverter(XmlTypeCode.UntypedAtomic).ChangeType( - enc.GetString(_data, pos + 4, _tokLen - 4), - returnType, namespaceResolver); - break; - } - - case BinXmlToken.SQL_VARBINARY: - case BinXmlToken.SQL_BINARY: - case BinXmlToken.SQL_IMAGE: - case BinXmlToken.SQL_UDT: - case BinXmlToken.XSD_BASE64: - case BinXmlToken.XSD_BINHEX: - { - byte[] data = new byte[_tokLen]; - Array.Copy(_data, _tokDataPos, data, 0, _tokLen); - value = GetValueConverter(token == BinXmlToken.XSD_BINHEX ? XmlTypeCode.HexBinary : XmlTypeCode.Base64Binary).ChangeType( - data, returnType, namespaceResolver); - break; - } - - case BinXmlToken.SQL_DATETIME: - case BinXmlToken.SQL_SMALLDATETIME: - case BinXmlToken.XSD_DATETIME: - case BinXmlToken.XSD_KATMAI_DATE: - case BinXmlToken.XSD_KATMAI_DATETIME: - case BinXmlToken.XSD_KATMAI_TIME: - value = GetValueConverter(XmlTypeCode.DateTime).ChangeType( - ValueAsDateTime(), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_KATMAI_DATEOFFSET: - case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: - case BinXmlToken.XSD_KATMAI_TIMEOFFSET: - value = GetValueConverter(XmlTypeCode.DateTime).ChangeType( - ValueAsDateTimeOffset(), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_TIME: - value = GetValueConverter(XmlTypeCode.Time).ChangeType( - ValueAsDateTime(), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_DATE: - value = GetValueConverter(XmlTypeCode.Date).ChangeType( - ValueAsDateTime(), - returnType, namespaceResolver); - break; - - case BinXmlToken.XSD_QNAME: - { - int nameNum = ParseMB32(_tokDataPos); - if (nameNum < 0 || nameNum >= _symbolTables.qnameCount) - throw new XmlException(ResXml.XmlBin_InvalidQNameID, String.Empty); - QName qname = _symbolTables.qnametable[nameNum]; - value = GetValueConverter(XmlTypeCode.QName).ChangeType( - new XmlQualifiedName(qname.localname, qname.namespaceUri), - returnType, namespaceResolver); - break; - } - - default: - throw ThrowUnexpectedToken(_token); - } - return value; - } - - private Int16 GetInt16(int pos) - { - byte[] data = _data; - return (Int16)(data[pos] | data[pos + 1] << 8); - } - - private UInt16 GetUInt16(int pos) - { - byte[] data = _data; - return (UInt16)(data[pos] | data[pos + 1] << 8); - } - - private Int32 GetInt32(int pos) - { - byte[] data = _data; - return (Int32)(data[pos] | data[pos + 1] << 8 | data[pos + 2] << 16 | data[pos + 3] << 24); - } - - private UInt32 GetUInt32(int pos) - { - byte[] data = _data; - return (UInt32)(data[pos] | data[pos + 1] << 8 | data[pos + 2] << 16 | data[pos + 3] << 24); - } - - private Int64 GetInt64(int pos) - { - byte[] data = _data; - uint lo = (uint)(data[pos] | data[pos + 1] << 8 | data[pos + 2] << 16 | data[pos + 3] << 24); - uint hi = (uint)(data[pos + 4] | data[pos + 5] << 8 | data[pos + 6] << 16 | data[pos + 7] << 24); - return (Int64)((ulong)hi) << 32 | lo; - } - - private UInt64 GetUInt64(int pos) - { - byte[] data = _data; - uint lo = (uint)(data[pos] | data[pos + 1] << 8 | data[pos + 2] << 16 | data[pos + 3] << 24); - uint hi = (uint)(data[pos + 4] | data[pos + 5] << 8 | data[pos + 6] << 16 | data[pos + 7] << 24); - return (UInt64)((ulong)hi) << 32 | lo; - } - - private Single GetSingle(int offset) - { - byte[] data = _data; - uint tmp = (uint)(data[offset] - | data[offset + 1] << 8 - | data[offset + 2] << 16 - | data[offset + 3] << 24); - unsafe - { - return *((float*)&tmp); - } - } - - private Double GetDouble(int offset) - { - uint lo = (uint)(_data[offset + 0] - | _data[offset + 1] << 8 - | _data[offset + 2] << 16 - | _data[offset + 3] << 24); - uint hi = (uint)(_data[offset + 4] - | _data[offset + 5] << 8 - | _data[offset + 6] << 16 - | _data[offset + 7] << 24); - ulong tmp = ((ulong)hi) << 32 | lo; - unsafe - { - return *((double*)&tmp); - } - } - - private Exception ThrowUnexpectedToken(BinXmlToken token) - { - System.Diagnostics.Debug.WriteLine("Unhandled token: " + token.ToString()); - return ThrowXmlException(ResXml.XmlBinary_UnexpectedToken); - } - - private Exception ThrowXmlException(string res) - { - _state = ScanState.Error; - return new XmlException(res, (string[])null); - } - - // not currently used... - //Exception ThrowXmlException(string res, string arg1) { - // this.state = ScanState.Error; - // return new XmlException(res, new string[] {arg1} ); - //} - - private Exception ThrowXmlException(string res, string arg1, string arg2) - { - _state = ScanState.Error; - return new XmlException(res, new string[] { arg1, arg2 }); - } - - private Exception ThrowNotSupported(string res) - { - _state = ScanState.Error; - return new NotSupportedException(res); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReaderAsync.cs deleted file mode 100644 index 959dc688f7a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BinaryXml/XmlBinaryReaderAsync.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; -using Microsoft.Xml.Schema; -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - internal sealed partial class XmlSqlBinaryReader : XmlReader, IXmlNamespaceResolver - { - public override Task GetValueAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadContentAsObjectAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - throw new NotSupportedException(); - } - - public override Task MoveToContentAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadContentAsStringAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - throw new NotSupportedException(); - } - - public override Task ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - throw new NotSupportedException(); - } - - public override Task ReadElementContentAsObjectAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - throw new NotSupportedException(); - } - - public override Task ReadInnerXmlAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadOuterXmlAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadValueChunkAsync(char[] buffer, int index, int count) - { - throw new NotSupportedException(); - } - - public override Task SkipAsync() - { - throw new NotSupportedException(); - } - - public override Task ReadElementContentAsStringAsync() - { - throw new NotSupportedException(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BitStack.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BitStack.cs index f54bd418bbf..9d2ec82df2a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BitStack.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BitStack.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Bits.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Bits.cs index 7677c9e1b50..a131f2418ee 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Bits.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Bits.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BufferBuilder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BufferBuilder.cs index 74838a30da6..097895b1fea 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BufferBuilder.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/BufferBuilder.cs @@ -8,7 +8,7 @@ using System.Text; using System.Diagnostics; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ByteStack.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ByteStack.cs index 61982ae5671..e58231f9586 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ByteStack.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ByteStack.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/Shape.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/Shape.cs deleted file mode 100644 index a050a3937c7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/Shape.cs +++ /dev/null @@ -1,298 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#if ENABLEDATABINDING -using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Collections; -using System.Diagnostics; -using System.ComponentModel; -using System.Text; - -namespace Microsoft.Xml.XPath.DataBinding -{ - internal enum BindingType { - Text, - Element, - Attribute, - ElementNested, - Repeat, - Sequence, - Choice, - All - } - - internal sealed class Shape - { - string name; - BindingType bindingType; - ArrayList particles; // XmlSchemaElement or XmlSchemaAttribute - ArrayList subShapes; - Shape nestedShape; - PropertyDescriptor[] propertyDescriptors; - XmlSchemaElement containerDecl; - - static object[] emptyIList = new object[0]; - - public Shape(string name, BindingType bindingType) - { - this.name = name; - this.bindingType = bindingType; - } - - public string Name { - get { return this.name; } - set { this.name = value; } - } - - public BindingType BindingType { - get { return this.bindingType; } - set { this.bindingType = value; } - } - - public XmlSchemaElement ContainerDecl { - get { return this.containerDecl; } - set { this.containerDecl = value; } - } - - public bool IsNestedTable { - get { - switch (this.BindingType) { - case BindingType.ElementNested: - case BindingType.Repeat: - case BindingType.Sequence: - case BindingType.Choice: - case BindingType.All: - return true; - - default: - return false; - } - } - } - - public bool IsGroup { - get { - switch (this.BindingType) { - case BindingType.Sequence: - case BindingType.Choice: - case BindingType.All: - return true; - default: - return false; - } - } - } - - public XmlSchemaType SchemaType { - get { - switch (this.bindingType) { - case BindingType.Text: - case BindingType.Element: - case BindingType.ElementNested: { - Debug.Assert(this.particles.Count == 1); - XmlSchemaElement xse = (XmlSchemaElement)this.particles[0]; - return xse.ElementSchemaType; - } - - case BindingType.Attribute: { - Debug.Assert(this.particles.Count == 1); - XmlSchemaAttribute xsa = (XmlSchemaAttribute)this.particles[0]; - return xsa.AttributeSchemaType; - } - - default: - return null; - } - } - } - - public XmlSchemaElement XmlSchemaElement { - get { - switch (this.bindingType) { - case BindingType.Text: - case BindingType.Element: - case BindingType.ElementNested: { - Debug.Assert(this.particles.Count == 1); - return (XmlSchemaElement)this.particles[0]; - } - - default: - return this.containerDecl; - } - } - } - - public IList Particles { - get { - if (null == this.particles) - return emptyIList; - return this.particles; - } - } - - public IList SubShapes { - get { - if (null == this.subShapes) - return emptyIList; - return this.subShapes; - } - } - - public Shape SubShape(int i) { - return (Shape)SubShapes[i]; - } - - public Shape NestedShape { - get { - //Debug.Assert(this.bindingType == BindingType.ElementNested); - return this.nestedShape; - } - set { - this.nestedShape = value; - } - } - - public XmlQualifiedName AttributeName { - get { - Debug.Assert(this.bindingType == BindingType.Attribute); - XmlSchemaAttribute xsa = (XmlSchemaAttribute)this.particles[0]; - return xsa.QualifiedName; - } - } - - public void Clear() { - if (this.subShapes != null) { - this.subShapes.Clear(); - this.subShapes = null; - } - if (this.particles != null) { - this.particles.Clear(); - this.particles = null; - } - } - - public void AddParticle(XmlSchemaElement elem) { - if (null == this.particles) - this.particles = new ArrayList(); - Debug.Assert(this.bindingType != BindingType.Attribute); - this.particles.Add(elem); - } - - public void AddParticle(XmlSchemaAttribute elem) { - Debug.Assert(this.bindingType == BindingType.Attribute); - Debug.Assert(this.particles == null); - this.particles = new ArrayList(); - this.particles.Add(elem); - } - - public void AddSubShape(Shape shape) { - if (null == this.subShapes) - this.subShapes = new ArrayList(); - this.subShapes.Add(shape); - foreach (object p in shape.Particles) { - XmlSchemaElement xse = p as XmlSchemaElement; - if (null != xse) - AddParticle(xse); - } - } - - public void AddAttrShapeAt(Shape shape, int pos) { - if (null == this.subShapes) - this.subShapes = new ArrayList(); - this.subShapes.Insert(pos, shape); - } - - public string[] SubShapeNames() { - string[] names = new string[SubShapes.Count]; - for (int i=0; i 0) { - if (rootShape.BindingType != BindingType.Sequence) { - Shape s = new Shape(null, BindingType.Sequence); - s.AddSubShape(rootShape); - rootShape = s; - } - int pos = 0; - string[] names = rootShape.SubShapeNames(); - - ICollection attributes = complexType.AttributeUses.Values; - XmlSchemaAttribute[] xsaArray = new XmlSchemaAttribute[attributes.Count]; - attributes.CopyTo(xsaArray, 0); - Array.Sort(xsaArray, new XmlSchemaAttributeComparer()); - foreach(XmlSchemaAttribute xsa in xsaArray) { - string name = GenAttrName(xsa.QualifiedName, names); - Shape attrShape = new Shape(name, BindingType.Attribute); - attrShape.AddParticle(xsa); - rootShape.AddAttrShapeAt(attrShape, pos++); - } - } - - if (rootShape.BindingType != BindingType.Text) { - rootShape.Name = GenName(xseName); - rootShape.ContainerDecl = xse; - } - return rootShape; - } - else { // simple type - Shape s = new Shape(GenName(xseName), BindingType.Text); - s.AddParticle(xse); - return s; - } - } - - public Shape GenerateFromSchema(XmlSchemaAttribute xsa) { - Shape s = new Shape(GenName(xsa.QualifiedName), BindingType.Attribute); - s.AddParticle(xsa); - return s; - } - - Shape ProcessParticle(XmlSchemaParticle xsp, Shape parent) { - Shape s; - if (xsp == XmlSchemaParticle.Empty) { - return null; - } - if (xsp is XmlSchemaElement) { - s = ProcessParticleElement((XmlSchemaElement)xsp); - } - else if (xsp is XmlSchemaSequence) { - s = ProcessParticleGroup((XmlSchemaSequence)xsp, BindingType.Sequence); - } - else if (xsp is XmlSchemaChoice) { - s = ProcessParticleGroup((XmlSchemaChoice)xsp, BindingType.Choice); - } - else if (xsp is XmlSchemaAll) { - s = ProcessParticleGroup((XmlSchemaAll)xsp, BindingType.All); - } - else { //XmlSchemaAny - return null; //Ignore Any in the content model - } - if (xsp.MaxOccurs > 1) { - Shape rep = new Shape(s.Name, BindingType.Repeat); - rep.AddSubShape(s); - s = rep; - } - if (parent != null) - parent.AddSubShape(s); - return s; - } - - Shape ProcessParticleElement(XmlSchemaElement xse) { - // watch out for recursive schema - Shape s = (Shape)this.elementTypesProcessed[xse]; - if (null != s) - return s; - - bool complex = xse.ElementSchemaType is XmlSchemaComplexType; - s = new Shape(GenName(xse.QualifiedName), complex ? BindingType.ElementNested : BindingType.Element); - s.AddParticle(xse); - - if (complex) { - this.elementTypesProcessed.Add(xse, s); - s.NestedShape = GenerateFromSchema(xse); - this.elementTypesProcessed.Remove(xse); - } - return s; - } - - Shape ProcessParticleGroup(XmlSchemaGroupBase xsg, BindingType bt) { - Shape s = new Shape(null, bt); - StringBuilder sb = new StringBuilder(); - foreach (XmlSchemaParticle xsp in xsg.Items) { - Shape sub = ProcessParticle(xsp, s); - if (sub != null) { //sub can be null if the child particle is xs:any - if (sb.Length > 0) - sb.Append('_'); - sb.Append(sub.Name); - } - } - // need to also test if paretn != null for this to work - //if (s.IsGroup && s.SubShapes.Count == 1) { - // Shape sub = (Shape)s.SubShapes[0]; - // s.Clear(); - // return sub; - //} - s.Name = sb.ToString(); - return s; - } - - string GenName(XmlQualifiedName xqn) { - string ns = xqn.Namespace; - string ln = xqn.Name; - if (ns.Length != 0) { - string prefix = (null==this.nsResolver) ? null : this.nsResolver.LookupPrefix(ns); - if (prefix != null && prefix.Length != 0) - return String.Concat(prefix, ":", ln); - } - return ln; - } - - string GenAttrName(XmlQualifiedName xqn, string[] names) { - string name = GenName(xqn); - if (null != names) { - for (int i=0; i - /// Although the XPath data model does not differentiate between text and whitespace, Managed Xml 1.0 - /// does. Therefore, when building from an XmlReader, we must preserve these designations in order - /// to remain backwards-compatible. - /// - internal enum TextBlockType - { - None = 0, - Text = XPathNodeType.Text, - SignificantWhitespace = XPathNodeType.SignificantWhitespace, - Whitespace = XPathNodeType.Whitespace, - }; - - - /// - /// Implementation of XmlRawWriter that builds nodes in an XPathDocument. - /// - internal sealed class XPathDocumentBuilder : XmlRawWriter - { - private NodePageFactory _nodePageFact; // Creates non-namespace node pages - private NodePageFactory _nmspPageFact; // Creates namespace node pages - private TextBlockBuilder _textBldr; // Concatenates adjacent text blocks - - private Stack _stkNmsp; // In-scope namespaces - private XPathNodeInfoTable _infoTable; // Atomization table for shared node information - private XPathDocument _doc; // Currently building document - private IXmlLineInfo _lineInfo; // Line information provider - private XmlNameTable _nameTable; // Atomization table for all names in the document - private bool _atomizeNames; // True if all names should be atomized (false if they are pre-atomized) - - private XPathNode[] _pageNmsp; // Page of last in-scope namespace node - private int _idxNmsp; // Page index of last in-scope namespace node - private XPathNode[] _pageParent; // Page of last parent-type node (Element or Root) - private int _idxParent; // Page index of last parent-type node (Element or Root) - private XPathNode[] _pageSibling; // Page of previous sibling node (may be null if no previous sibling) - private int _idxSibling; // Page index of previous sibling node - private int _lineNumBase; // Line number from which offsets are computed - private int _linePosBase; // Line position from which offsets are computed - - private XmlQualifiedName _idAttrName; // Cached name of an ID attribute - private Hashtable _elemIdMap; // Map from element name to ID attribute name - private XPathNodeRef[] _elemNameIndex; // Elements with the same name are linked together so that they can be searched quickly - - private const int ElementIndexSize = 64; - - /// - /// Create a new XPathDocumentBuilder which creates nodes in "doc". - /// - public XPathDocumentBuilder(XPathDocument doc, IXmlLineInfo lineInfo, string baseUri, XPathDocument.LoadFlags flags) - { - // Allocate the initial node (for non-namespaces) page, and the initial namespace page - _nodePageFact.Init(256); - _nmspPageFact.Init(16); - - _stkNmsp = new Stack(); - - Initialize(doc, lineInfo, baseUri, flags); - } - - /// - /// Start construction of a new document. This must be called before any other methods are called. - /// It may also be called after Close(), in order to build further documents. - /// - public void Initialize(XPathDocument doc, IXmlLineInfo lineInfo, string baseUri, XPathDocument.LoadFlags flags) - { - XPathNode[] page; - int idx; - - _doc = doc; - _nameTable = doc.NameTable; - _atomizeNames = (flags & XPathDocument.LoadFlags.AtomizeNames) != 0; - _idxParent = _idxSibling = 0; - _elemNameIndex = new XPathNodeRef[ElementIndexSize]; - - // Prepare line number information - _textBldr.Initialize(lineInfo); - _lineInfo = lineInfo; - _lineNumBase = 0; - _linePosBase = 0; - - // Allocate the atomization table - _infoTable = new XPathNodeInfoTable(); - - // Allocate singleton collapsed text node - idx = NewNode(out page, XPathNodeType.Text, string.Empty, string.Empty, string.Empty, string.Empty); - _doc.SetCollapsedTextNode(page, idx); - - // Allocate xmlns:xml namespace node - _idxNmsp = NewNamespaceNode(out _pageNmsp, _nameTable.Add("xml"), _nameTable.Add(XmlReservedNs.NsXml), null, 0); - _doc.SetXmlNamespaceNode(_pageNmsp, _idxNmsp); - - if ((flags & XPathDocument.LoadFlags.Fragment) == 0) - { - // This tree has a document root node - _idxParent = NewNode(out _pageParent, XPathNodeType.Root, string.Empty, string.Empty, string.Empty, baseUri); - _doc.SetRootNode(_pageParent, _idxParent); - } - else - { - // This tree is an XQuery fragment (no document root node), so root will be next node in the current page - _doc.SetRootNode(_nodePageFact.NextNodePage, _nodePageFact.NextNodeIndex); - } - } - - - //----------------------------------------------- - // XmlWriter interface - //----------------------------------------------- - - /// - /// XPathDocument ignores the DocType information. - /// - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - } - - /// - /// Shortcut for calling WriteStartElement with elemType == null. - /// - public override void WriteStartElement(string prefix, string localName, string ns) - { - this.WriteStartElement(prefix, localName, ns, string.Empty); - } - - /// - /// Build an element node and attach it to its parent, if one exists. Make the element the new parent node. - /// - public void WriteStartElement(string prefix, string localName, string ns, string baseUri) - { - int hash; - Debug.Assert(prefix != null && localName != null && ns != null && localName.Length != 0 && baseUri != null); - - if (_atomizeNames) - { - prefix = _nameTable.Add(prefix); - localName = _nameTable.Add(localName); - ns = _nameTable.Add(ns); - } - - AddSibling(XPathNodeType.Element, localName, ns, prefix, baseUri); - _pageParent = _pageSibling; - _idxParent = _idxSibling; - _idxSibling = 0; - - // Link elements with the same name together - hash = (_pageParent[_idxParent].LocalNameHashCode & (ElementIndexSize - 1)); - _elemNameIndex[hash] = LinkSimilarElements(_elemNameIndex[hash].Page, _elemNameIndex[hash].Index, _pageParent, _idxParent); - - // If elements within this document might have IDs, then cache the name of the ID attribute, if one exists - if (_elemIdMap != null) - _idAttrName = (XmlQualifiedName)_elemIdMap[new XmlQualifiedName(localName, prefix)]; - } - - /// - /// Must be called when an element node's children have been fully enumerated. - /// - public override void WriteEndElement() - { - WriteEndElement(true); - } - - /// - /// Must be called when an element node's children have been fully enumerated. - /// - public override void WriteFullEndElement() - { - WriteEndElement(false); - } - - /// - /// Must be called when an element node's children have been fully enumerated. - /// - internal override void WriteEndElement(string prefix, string localName, string namespaceName) - { - WriteEndElement(true); - } - - /// - /// Must be called when an element node's children have been fully enumerated. - /// - internal override void WriteFullEndElement(string prefix, string localName, string namespaceName) - { - WriteEndElement(false); - } - - /// - /// Must be called when an element node's children have been fully enumerated. - /// - public void WriteEndElement(bool allowShortcutTag) - { - XPathNodeRef nodeRef; - Debug.Assert(_pageParent[_idxParent].NodeType == XPathNodeType.Element); - - // If element has no content-typed children except for the one about to be added, then - // its value is the same as its only text child's. - if (!_pageParent[_idxParent].HasContentChild) - { - switch (_textBldr.TextType) - { - case TextBlockType.Text: - // Collapsed text node can be created if text line number information can be encoded efficiently in parent node - if (_lineInfo != null) - { - // If collapsed text node is not on same line as parent, don't collapse text - if (_textBldr.LineNumber != _pageParent[_idxParent].LineNumber) - goto case TextBlockType.Whitespace; - - // If position is not within 256 of parent, don't collapse text - int posDiff = _textBldr.LinePosition - _pageParent[_idxParent].LinePosition; - if (posDiff < 0 || posDiff > XPathNode.MaxCollapsedPositionOffset) - goto case TextBlockType.Whitespace; - - // Set collapsed node line position offset - _pageParent[_idxParent].SetCollapsedLineInfoOffset(posDiff); - } - - // Set collapsed node text - _pageParent[_idxParent].SetCollapsedValue(_textBldr.ReadText()); - break; - - case TextBlockType.SignificantWhitespace: - case TextBlockType.Whitespace: - // Create separate whitespace node - CachedTextNode(); - _pageParent[_idxParent].SetValue(_pageSibling[_idxSibling].Value); - break; - - default: - // Empty value, so don't create collapsed text node - _pageParent[_idxParent].SetEmptyValue(allowShortcutTag); - break; - } - } - else - { - if (_textBldr.HasText) - { - // Element's last child (one of several) is a text or whitespace node - CachedTextNode(); - } - } - - // If namespaces were added to this element, - if (_pageParent[_idxParent].HasNamespaceDecls) - { - // Add it to the document's element --> namespace mapping - _doc.AddNamespace(_pageParent, _idxParent, _pageNmsp, _idxNmsp); - - // Restore the previous namespace chain - nodeRef = _stkNmsp.Pop(); - _pageNmsp = nodeRef.Page; - _idxNmsp = nodeRef.Index; - } - - // Make parent of this element the current element - _pageSibling = _pageParent; - _idxSibling = _idxParent; - _idxParent = _pageParent[_idxParent].GetParent(out _pageParent); - } - - /// - /// Shortcut for calling WriteStartAttribute with attrfType == null. - /// - public override void WriteStartAttribute(string prefix, string localName, string namespaceName) - { - Debug.Assert(!prefix.Equals("xmlns")); - Debug.Assert(_idxParent == 0 || _pageParent[_idxParent].NodeType == XPathNodeType.Element); - Debug.Assert(_idxSibling == 0 || _pageSibling[_idxSibling].NodeType == XPathNodeType.Attribute); - - if (_atomizeNames) - { - prefix = _nameTable.Add(prefix); - localName = _nameTable.Add(localName); - namespaceName = _nameTable.Add(namespaceName); - } - - AddSibling(XPathNodeType.Attribute, localName, namespaceName, prefix, string.Empty); - } - - /// - /// Attach the attribute's text or typed value to the previously constructed attribute node. - /// - public override void WriteEndAttribute() - { - Debug.Assert(_pageSibling[_idxSibling].NodeType == XPathNodeType.Attribute); - - _pageSibling[_idxSibling].SetValue(_textBldr.ReadText()); - - if (_idAttrName != null) - { - // If this is an ID attribute, - if (_pageSibling[_idxSibling].LocalName == _idAttrName.Name && - _pageSibling[_idxSibling].Prefix == _idAttrName.Namespace) - { - // Then add its value to the idValueMap map - Debug.Assert(_idxParent != 0, "ID attribute must have an element parent"); - _doc.AddIdElement(_pageSibling[_idxSibling].Value, _pageParent, _idxParent); - } - } - } - - /// - /// Map CData text into regular text. - /// - public override void WriteCData(string text) - { - WriteString(text, TextBlockType.Text); - } - - /// - /// Construct comment node. - /// - public override void WriteComment(string text) - { - AddSibling(XPathNodeType.Comment, string.Empty, string.Empty, string.Empty, string.Empty); - _pageSibling[_idxSibling].SetValue(text); - } - - /// - /// Shortcut for calling WriteProcessingInstruction with baseUri = string.Empty. - /// - public override void WriteProcessingInstruction(string name, string text) - { - this.WriteProcessingInstruction(name, text, string.Empty); - } - - /// - /// Construct pi node. - /// - public void WriteProcessingInstruction(string name, string text, string baseUri) - { - if (_atomizeNames) - name = _nameTable.Add(name); - - AddSibling(XPathNodeType.ProcessingInstruction, name, string.Empty, string.Empty, baseUri); - _pageSibling[_idxSibling].SetValue(text); - } - - /// - /// Write a whitespace text block. - /// - public override void WriteWhitespace(string ws) - { - WriteString(ws, TextBlockType.Whitespace); - } - - /// - /// Write an attribute or element text block. - /// - public override void WriteString(string text) - { - WriteString(text, TextBlockType.Text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count), TextBlockType.Text); - } - - /// - /// Map RawText to Text. This will lose entitization and won't roundtrip. - /// - public override void WriteRaw(string data) - { - WriteString(data, TextBlockType.Text); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count), TextBlockType.Text); - } - - /// - /// Write an element text block with the specified text type (whitespace, significant whitespace, or text). - /// - public void WriteString(string text, TextBlockType textType) - { - _textBldr.WriteTextBlock(text, textType); - } - - /// - /// Cache does not handle entity references. - /// - public override void WriteEntityRef(string name) - { - throw new NotImplementedException(); - } - - /// - /// Don't entitize, since the cache cannot represent character entities. - /// - public override void WriteCharEntity(char ch) - { - char[] chars = { ch }; - WriteString(new string(chars), TextBlockType.Text); - } - - /// - /// Don't entitize, since the cache cannot represent character entities. - /// - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - char[] chars = { highChar, lowChar }; - WriteString(new string(chars), TextBlockType.Text); - } - - /// - /// Signals the end of tree construction. - /// - public override void Close() - { - XPathNode[] page; - int idx; - - // If cached text exists, then create a text node at the top-level - if (_textBldr.HasText) - CachedTextNode(); - - // If document does not yet contain nodes, then an empty text node must have been created - idx = _doc.GetRootNode(out page); - if (idx == _nodePageFact.NextNodeIndex && page == _nodePageFact.NextNodePage) - { - AddSibling(XPathNodeType.Text, string.Empty, string.Empty, string.Empty, string.Empty); - _pageSibling[_idxSibling].SetValue(string.Empty); - } - } - - /// - /// Since output is not forwarded to another object, this does nothing. - /// - public override void Flush() - { - } - - - //----------------------------------------------- - // XmlRawWriter interface - //----------------------------------------------- - - /// - /// Write the xml declaration. This must be the first call after Open. - /// - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - // Ignore the xml declaration when building the cache - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - // Ignore the xml declaration when building the cache - } - - /// - /// Called as element node's children are about to be enumerated. - /// - internal override void StartElementContent() - { - Debug.Assert(_pageParent[_idxParent].NodeType == XPathNodeType.Element); - } - - /// - /// Build a namespace declaration node. Attach it to an element parent, if one was previously constructed. - /// All namespace declarations are linked together in an in-scope namespace tree. - /// - internal override void WriteNamespaceDeclaration(string prefix, string namespaceName) - { - XPathNode[] pageTemp, pageOverride, pageNew, pageOrig, pageCopy; - int idxTemp, idxOverride, idxNew, idxOrig, idxCopy; - Debug.Assert(_idxSibling == 0 || _pageSibling[_idxSibling].NodeType == XPathNodeType.Attribute); - Debug.Assert(!prefix.Equals("xmlns") && !namespaceName.Equals(XmlReservedNs.NsXmlNs)); - Debug.Assert(_idxParent == 0 || _idxNmsp != 0); - Debug.Assert(_idxParent == 0 || _pageParent[_idxParent].NodeType == XPathNodeType.Element); - - if (_atomizeNames) - prefix = _nameTable.Add(prefix); - - namespaceName = _nameTable.Add(namespaceName); - - // Does the new namespace override a previous namespace node? - pageOverride = _pageNmsp; - idxOverride = _idxNmsp; - while (idxOverride != 0) - { - if ((object)pageOverride[idxOverride].LocalName == (object)prefix) - { - // Need to clone all namespaces up until the overridden node in order to bypass it - break; - } - idxOverride = pageOverride[idxOverride].GetSibling(out pageOverride); - } - - // Create new namespace node and add it to front of namespace list - idxNew = NewNamespaceNode(out pageNew, prefix, namespaceName, _pageParent, _idxParent); - - if (idxOverride != 0) - { - // Bypass overriden node by cloning nodes in list leading to it - pageOrig = _pageNmsp; - idxOrig = _idxNmsp; - pageCopy = pageNew; - idxCopy = idxNew; - - while (idxOrig != idxOverride || pageOrig != pageOverride) - { - // Make a copy of the original namespace node - idxTemp = pageOrig[idxOrig].GetParent(out pageTemp); - idxTemp = NewNamespaceNode(out pageTemp, pageOrig[idxOrig].LocalName, pageOrig[idxOrig].Value, pageTemp, idxTemp); - - // Attach copy to chain of copied nodes - pageCopy[idxCopy].SetSibling(_infoTable, pageTemp, idxTemp); - - // Position on the new copy - pageCopy = pageTemp; - idxCopy = idxTemp; - - // Get next original sibling - idxOrig = pageOrig[idxOrig].GetSibling(out pageOrig); - } - - // Link farther up in the original chain, just past the last overriden node - idxOverride = pageOverride[idxOverride].GetSibling(out pageOverride); - - if (idxOverride != 0) - pageCopy[idxCopy].SetSibling(_infoTable, pageOverride, idxOverride); - else - Debug.Assert(prefix.Equals("xml"), "xmlns:xml namespace declaration should always be present in the list."); - } - else if (_idxParent != 0) - { - // Link new node directly to last in-scope namespace. No overrides necessary. - pageNew[idxNew].SetSibling(_infoTable, _pageNmsp, _idxNmsp); - } - else - { - // Floating namespace, so make this the root of the tree - _doc.SetRootNode(pageNew, idxNew); - } - - if (_idxParent != 0) - { - // If this is the first namespace on the current element, - if (!_pageParent[_idxParent].HasNamespaceDecls) - { - // Then save the last in-scope namespace on a stack so that EndElementNode can restore it. - _stkNmsp.Push(new XPathNodeRef(_pageNmsp, _idxNmsp)); - - // Mark element parent as having namespace nodes declared on it - _pageParent[_idxParent].HasNamespaceDecls = true; - } - - // New namespace is now last in-scope namespace - _pageNmsp = pageNew; - _idxNmsp = idxNew; - } - } - - - //----------------------------------------------- - // Custom Build Helper Methods - //----------------------------------------------- - - /// - /// Build ID lookup tables from the XSD schema or DTD. - /// - public void CreateIdTables(IDtdInfo dtdInfo) - { - // Extract the elements which has attribute defined as ID from the element declarations - foreach (IDtdAttributeListInfo attrList in dtdInfo.GetAttributeLists()) - { - IDtdAttributeInfo idAttribute = attrList.LookupIdAttribute(); - if (idAttribute != null) - { - if (_elemIdMap == null) - _elemIdMap = new Hashtable(); - - // Id was defined in DTD and DTD doesn't have notion of namespace so we should - // use prefix instead of namespace here. Schema already does this for us. - _elemIdMap.Add(new XmlQualifiedName(attrList.LocalName, attrList.Prefix), - new XmlQualifiedName(idAttribute.LocalName, idAttribute.Prefix)); - } - } - } - - /// - /// Link "prev" element with "next" element, which has a "similar" name. This increases the performance of searches by element name. - /// - private XPathNodeRef LinkSimilarElements(XPathNode[] pagePrev, int idxPrev, XPathNode[] pageNext, int idxNext) - { - // Set link on previous element - if (pagePrev != null) - pagePrev[idxPrev].SetSimilarElement(_infoTable, pageNext, idxNext); - - // Add next element to index - return new XPathNodeRef(pageNext, idxNext); - } - - /// - /// Helper method that constructs a new Namespace XPathNode. - /// - private int NewNamespaceNode(out XPathNode[] page, string prefix, string namespaceUri, XPathNode[] pageElem, int idxElem) - { - XPathNode[] pageNode; - int idxNode, lineNumOffset, linePosOffset; - XPathNodeInfoAtom info; - Debug.Assert(pageElem == null || pageElem[idxElem].NodeType == XPathNodeType.Element); - - // Allocate a page slot for the new XPathNode - _nmspPageFact.AllocateSlot(out pageNode, out idxNode); - - // Compute node's line number information - ComputeLineInfo(false, out lineNumOffset, out linePosOffset); - - // Obtain a XPathNodeInfoAtom object for this node - info = _infoTable.Create(prefix, string.Empty, string.Empty, string.Empty, - pageElem, pageNode, null, - _doc, _lineNumBase, _linePosBase); - - // Initialize the new node - pageNode[idxNode].Create(info, XPathNodeType.Namespace, idxElem); - pageNode[idxNode].SetValue(namespaceUri); - pageNode[idxNode].SetLineInfoOffsets(lineNumOffset, linePosOffset); - - page = pageNode; - return idxNode; - } - - /// - /// Helper method that constructs a new XPathNode. - /// - private int NewNode(out XPathNode[] page, XPathNodeType xptyp, string localName, string namespaceUri, string prefix, string baseUri) - { - XPathNode[] pageNode; - int idxNode, lineNumOffset, linePosOffset; - XPathNodeInfoAtom info; - Debug.Assert(xptyp != XPathNodeType.Namespace); - - // Allocate a page slot for the new XPathNode - _nodePageFact.AllocateSlot(out pageNode, out idxNode); - - // Compute node's line number information - ComputeLineInfo(XPathNavigator.IsText(xptyp), out lineNumOffset, out linePosOffset); - - // Obtain a XPathNodeInfoAtom object for this node - info = _infoTable.Create(localName, namespaceUri, prefix, baseUri, - _pageParent, pageNode, pageNode, - _doc, _lineNumBase, _linePosBase); - - // Initialize the new node - pageNode[idxNode].Create(info, xptyp, _idxParent); - pageNode[idxNode].SetLineInfoOffsets(lineNumOffset, linePosOffset); - - page = pageNode; - return idxNode; - } - - /// - /// Compute current node's line number information. - /// - private void ComputeLineInfo(bool isTextNode, out int lineNumOffset, out int linePosOffset) - { - int lineNum, linePos; - - if (_lineInfo == null) - { - lineNumOffset = 0; - linePosOffset = 0; - return; - } - - // Get line number info from TextBlockBuilder if current node is a text node - if (isTextNode) - { - lineNum = _textBldr.LineNumber; - linePos = _textBldr.LinePosition; - } - else - { - Debug.Assert(_lineInfo.HasLineInfo(), "HasLineInfo should have been checked before this."); - lineNum = _lineInfo.LineNumber; - linePos = _lineInfo.LinePosition; - } - - lineNumOffset = lineNum - _lineNumBase; - if (lineNumOffset < 0 || lineNumOffset > XPathNode.MaxLineNumberOffset) - { - _lineNumBase = lineNum; - lineNumOffset = 0; - } - - linePosOffset = linePos - _linePosBase; - if (linePosOffset < 0 || linePosOffset > XPathNode.MaxLinePositionOffset) - { - _linePosBase = linePos; - linePosOffset = 0; - } - } - - /// - /// Add a sibling node. If no previous sibling exists, add the node as the first child of the parent. - /// If no parent exists, make this node the root of the document. - /// - private void AddSibling(XPathNodeType xptyp, string localName, string namespaceUri, string prefix, string baseUri) - { - XPathNode[] pageNew; - int idxNew; - Debug.Assert(xptyp != XPathNodeType.Root && xptyp != XPathNodeType.Namespace); - - if (_textBldr.HasText) - CachedTextNode(); - - idxNew = NewNode(out pageNew, xptyp, localName, namespaceUri, prefix, baseUri); - - // this.idxParent is only 0 for the top-most node - if (_idxParent != 0) - { - // Set properties on parent - _pageParent[_idxParent].SetParentProperties(xptyp); - - if (_idxSibling == 0) - { - // This is the first child of the parent (so should be allocated immediately after parent) - Debug.Assert(_idxParent + 1 == idxNew || idxNew == 1); - } - else - { - // There is already a previous sibling - _pageSibling[_idxSibling].SetSibling(_infoTable, pageNew, idxNew); - } - } - - _pageSibling = pageNew; - _idxSibling = idxNew; - } - - /// - /// Creates a text node from cached text parts. - /// - private void CachedTextNode() - { - TextBlockType textType; - string text; - Debug.Assert(_textBldr.HasText || (_idxSibling == 0 && _idxParent == 0), "Cannot create empty text node unless it's a top-level text node."); - Debug.Assert(_idxSibling == 0 || !_pageSibling[_idxSibling].IsText, "Cannot create adjacent text nodes."); - - // Create a text node - textType = _textBldr.TextType; - text = _textBldr.ReadText(); - AddSibling((XPathNodeType)textType, string.Empty, string.Empty, string.Empty, string.Empty); - _pageSibling[_idxSibling].SetValue(text); - } - - /// - /// Allocates pages of nodes for the XPathDocumentBuilder. The initial pages and arrays are - /// fairly small. As each page fills, a new page that is twice as big is allocated. - /// The max size of a page is 65536 nodes, since XPathNode indexes are 16-bits. - /// - private struct NodePageFactory - { - private XPathNode[] _page; - private XPathNodePageInfo _pageInfo; - private int _pageSize; - - /// - /// Allocates and returns the initial node page. - /// - public void Init(int initialPageSize) - { - // 0th slot: Index 0 is reserved to mean "null node". Only use 0th slot to store PageInfo. - _pageSize = initialPageSize; - _page = new XPathNode[_pageSize]; - _pageInfo = new XPathNodePageInfo(null, 1); - _page[0].Create(_pageInfo); - } - - /// - /// Return the page on which the next node will be allocated. - /// - public XPathNode[] NextNodePage - { - get { return _page; } - } - - /// - /// Return the page index that the next node will be given. - /// - public int NextNodeIndex - { - get { return _pageInfo.NodeCount; } - } - - /// - /// Allocate the next slot in the current node page. Return a reference to the page and the index - /// of the allocated slot. - /// - public void AllocateSlot(out XPathNode[] page, out int idx) - { - page = _page; - idx = _pageInfo.NodeCount; - - // Allocate new page if necessary - if (++_pageInfo.NodeCount >= _page.Length) - { - if (_pageSize < (1 << 16)) - { - // New page shouldn't contain more slots than 16 bits can address - _pageSize *= 2; - } - _page = new XPathNode[_pageSize]; - _pageInfo.NextPage = _page; - _pageInfo = new XPathNodePageInfo(page, _pageInfo.PageNumber + 1); - _page[0].Create(_pageInfo); - } - } - } - - /// - /// This class concatenates adjacent text blocks and tracks TextBlockType and line number information. - /// - private struct TextBlockBuilder - { - private IXmlLineInfo _lineInfo; - private TextBlockType _textType; - private string _text; - private int _lineNum,_linePos; - - /// - /// Constructor. - /// - public void Initialize(IXmlLineInfo lineInfo) - { - _lineInfo = lineInfo; - _textType = TextBlockType.None; - } - - /// - /// Return the type of the cached text block. - /// - public TextBlockType TextType - { - get { return _textType; } - } - - /// - /// Returns true if text has been cached. - /// - public bool HasText - { - get { return _textType != TextBlockType.None; } - } - - /// - /// Returns the line number of the last text block to be cached. - /// - public int LineNumber - { - get { return _lineNum; } - } - - /// - /// Returns the line position of the last text block to be cached. - /// - public int LinePosition - { - get { return _linePos; } - } - - /// - /// Append a text block with the specified type. - /// - public void WriteTextBlock(string text, TextBlockType textType) - { - Debug.Assert((int)XPathNodeType.Text < (int)XPathNodeType.SignificantWhitespace); - Debug.Assert((int)XPathNodeType.SignificantWhitespace < (int)XPathNodeType.Whitespace); - - if (text.Length != 0) - { - if (_textType == TextBlockType.None) - { - _text = text; - _textType = textType; - - if (_lineInfo != null) - { - _lineNum = _lineInfo.LineNumber; - _linePos = _lineInfo.LinePosition; - } - } - else - { - _text = string.Concat(_text, text); - - // Determine whether text is Text, Whitespace, or SignificantWhitespace - if ((int)textType < (int)_textType) - _textType = textType; - } - } - } - - /// - /// Read all cached text, or string.Empty if no text has been cached, and clear the text block type. - /// - public string ReadText() - { - if (_textType == TextBlockType.None) - return string.Empty; - - _textType = TextBlockType.None; - return _text; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentIterator.cs deleted file mode 100644 index 4d14df8e100..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentIterator.cs +++ /dev/null @@ -1,304 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using System.Diagnostics; - -namespace MS.Internal.Xml.Cache -{ - /// - /// Base internal class of all XPathDocument XPathNodeIterator implementations. - /// - internal abstract class XPathDocumentBaseIterator : XPathNodeIterator - { - protected XPathDocumentNavigator ctxt; - protected int pos; - - /// - /// Create a new iterator that is initially positioned on the "ctxt" node. - /// - protected XPathDocumentBaseIterator(XPathDocumentNavigator ctxt) - { - this.ctxt = new XPathDocumentNavigator(ctxt); - } - - /// - /// Create a new iterator that is a copy of "iter". - /// - protected XPathDocumentBaseIterator(XPathDocumentBaseIterator iter) - { - this.ctxt = new XPathDocumentNavigator(iter.ctxt); - this.pos = iter.pos; - } - - /// - /// Return the current navigator. - /// - public override XPathNavigator Current - { - get { return this.ctxt; } - } - - /// - /// Return the iterator's current position. - /// - public override int CurrentPosition - { - get { return this.pos; } - } - } - - - /// - /// Iterate over all element children with a particular QName. - /// - internal class XPathDocumentElementChildIterator : XPathDocumentBaseIterator - { - private string _localName,_namespaceUri; - - /// - /// Create an iterator that ranges over all element children of "parent" having the specified QName. - /// - public XPathDocumentElementChildIterator(XPathDocumentNavigator parent, string name, string namespaceURI) : base(parent) - { - if (namespaceURI == null) throw new ArgumentNullException("namespaceURI"); - - _localName = parent.NameTable.Get(name); - _namespaceUri = namespaceURI; - } - - /// - /// Create a new iterator that is a copy of "iter". - /// - public XPathDocumentElementChildIterator(XPathDocumentElementChildIterator iter) : base(iter) - { - _localName = iter._localName; - _namespaceUri = iter._namespaceUri; - } - - /// - /// Create a copy of this iterator. - /// - public override XPathNodeIterator Clone() - { - return new XPathDocumentElementChildIterator(this); - } - - /// - /// Position the iterator to the next matching child. - /// - public override bool MoveNext() - { - if (this.pos == 0) - { - if (!this.ctxt.MoveToChild(_localName, _namespaceUri)) - return false; - } - else - { - if (!this.ctxt.MoveToNext(_localName, _namespaceUri)) - return false; - } - - this.pos++; - return true; - } - } - - - /// - /// Iterate over all content children with a particular XPathNodeType. - /// - internal class XPathDocumentKindChildIterator : XPathDocumentBaseIterator - { - private XPathNodeType _typ; - - /// - /// Create an iterator that ranges over all content children of "parent" having the specified XPathNodeType. - /// - public XPathDocumentKindChildIterator(XPathDocumentNavigator parent, XPathNodeType typ) : base(parent) - { - _typ = typ; - } - - /// - /// Create a new iterator that is a copy of "iter". - /// - public XPathDocumentKindChildIterator(XPathDocumentKindChildIterator iter) : base(iter) - { - _typ = iter._typ; - } - - /// - /// Create a copy of this iterator. - /// - public override XPathNodeIterator Clone() - { - return new XPathDocumentKindChildIterator(this); - } - - /// - /// Position the iterator to the next descendant. - /// - public override bool MoveNext() - { - if (this.pos == 0) - { - if (!this.ctxt.MoveToChild(_typ)) - return false; - } - else - { - if (!this.ctxt.MoveToNext(_typ)) - return false; - } - - this.pos++; - return true; - } - } - - - /// - /// Iterate over all element descendants with a particular QName. - /// - internal class XPathDocumentElementDescendantIterator : XPathDocumentBaseIterator - { - private XPathDocumentNavigator _end; - private string _localName,_namespaceUri; - private bool _matchSelf; - - /// - /// Create an iterator that ranges over all element descendants of "root" having the specified QName. - /// - public XPathDocumentElementDescendantIterator(XPathDocumentNavigator root, string name, string namespaceURI, bool matchSelf) : base(root) - { - if (namespaceURI == null) throw new ArgumentNullException("namespaceURI"); - - _localName = root.NameTable.Get(name); - _namespaceUri = namespaceURI; - _matchSelf = matchSelf; - - // Find the next non-descendant node that follows "root" in document order - if (root.NodeType != XPathNodeType.Root) - { - _end = new XPathDocumentNavigator(root); - _end.MoveToNonDescendant(); - } - } - - /// - /// Create a new iterator that is a copy of "iter". - /// - public XPathDocumentElementDescendantIterator(XPathDocumentElementDescendantIterator iter) : base(iter) - { - _end = iter._end; - _localName = iter._localName; - _namespaceUri = iter._namespaceUri; - _matchSelf = iter._matchSelf; - } - - /// - /// Create a copy of this iterator. - /// - public override XPathNodeIterator Clone() - { - return new XPathDocumentElementDescendantIterator(this); - } - - /// - /// Position the iterator to the next descendant. - /// - public override bool MoveNext() - { - if (_matchSelf) - { - _matchSelf = false; - - if (this.ctxt.IsElementMatch(_localName, _namespaceUri)) - { - this.pos++; - return true; - } - } - - if (!this.ctxt.MoveToFollowing(_localName, _namespaceUri, _end)) - return false; - - this.pos++; - return true; - } - } - - - /// - /// Iterate over all content descendants with a particular XPathNodeType. - /// - internal class XPathDocumentKindDescendantIterator : XPathDocumentBaseIterator - { - private XPathDocumentNavigator _end; - private XPathNodeType _typ; - private bool _matchSelf; - - /// - /// Create an iterator that ranges over all content descendants of "root" having the specified XPathNodeType. - /// - public XPathDocumentKindDescendantIterator(XPathDocumentNavigator root, XPathNodeType typ, bool matchSelf) : base(root) - { - _typ = typ; - _matchSelf = matchSelf; - - // Find the next non-descendant node that follows "root" in document order - if (root.NodeType != XPathNodeType.Root) - { - _end = new XPathDocumentNavigator(root); - _end.MoveToNonDescendant(); - } - } - - /// - /// Create a new iterator that is a copy of "iter". - /// - public XPathDocumentKindDescendantIterator(XPathDocumentKindDescendantIterator iter) : base(iter) - { - _end = iter._end; - _typ = iter._typ; - _matchSelf = iter._matchSelf; - } - - /// - /// Create a copy of this iterator. - /// - public override XPathNodeIterator Clone() - { - return new XPathDocumentKindDescendantIterator(this); - } - - /// - /// Position the iterator to the next descendant. - /// - public override bool MoveNext() - { - if (_matchSelf) - { - _matchSelf = false; - - if (this.ctxt.IsKindMatch(_typ)) - { - this.pos++; - return true; - } - } - - if (!this.ctxt.MoveToFollowing(_typ, _end)) - return false; - - this.pos++; - return true; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentNavigator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentNavigator.cs deleted file mode 100644 index 08c48df1777..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentNavigator.cs +++ /dev/null @@ -1,1055 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Collections; -using System.Globalization; -using System.Text; -using System.Diagnostics; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; - -namespace MS.Internal.Xml.Cache -{ - /// - /// This is the default XPath/XQuery data model cache implementation. It will be used whenever - /// the user does not supply his own XPathNavigator implementation. - /// - internal sealed class XPathDocumentNavigator : XPathNavigator, IXmlLineInfo - { - private XPathNode[] _pageCurrent; - private XPathNode[] _pageParent; - private int _idxCurrent; - private int _idxParent; - private string _atomizedLocalName; - - - //----------------------------------------------- - // Constructors - //----------------------------------------------- - - /// - /// Create a new navigator positioned on the specified current node. If the current node is a namespace or a collapsed - /// text node, then the parent is a virtualized parent (may be different than .Parent on the current node). - /// - public XPathDocumentNavigator(XPathNode[] pageCurrent, int idxCurrent, XPathNode[] pageParent, int idxParent) - { - Debug.Assert(pageCurrent != null && idxCurrent != 0); - Debug.Assert((pageParent == null) == (idxParent == 0)); - _pageCurrent = pageCurrent; - _pageParent = pageParent; - _idxCurrent = idxCurrent; - _idxParent = idxParent; - } - - /// - /// Copy constructor. - /// - public XPathDocumentNavigator(XPathDocumentNavigator nav) : this(nav._pageCurrent, nav._idxCurrent, nav._pageParent, nav._idxParent) - { - _atomizedLocalName = nav._atomizedLocalName; - } - - - //----------------------------------------------- - // XPathItem - //----------------------------------------------- - - /// - /// Get the string value of the current node, computed using data model dm:string-value rules. - /// If the node has a typed value, return the string representation of the value. If the node - /// is not a parent type (comment, text, pi, etc.), get its simple text value. Otherwise, - /// concatenate all text node descendants of the current node. - /// - public override string Value - { - get - { - string value; - XPathNode[] page, pageEnd; - int idx, idxEnd; - - // Try to get the pre-computed string value of the node - value = _pageCurrent[_idxCurrent].Value; - if (value != null) - return value; - -#if DEBUG - switch (_pageCurrent[_idxCurrent].NodeType) - { - case XPathNodeType.Namespace: - case XPathNodeType.Attribute: - case XPathNodeType.Comment: - case XPathNodeType.ProcessingInstruction: - Debug.Assert(false, "ReadStringValue() should have taken care of these node types."); - break; - - case XPathNodeType.Text: - Debug.Assert(_idxParent != 0 && _pageParent[_idxParent].HasCollapsedText, - "ReadStringValue() should have taken care of anything but collapsed text."); - break; - } -#endif - - // If current node is collapsed text, then parent element has a simple text value - if (_idxParent != 0) - { - Debug.Assert(_pageCurrent[_idxCurrent].NodeType == XPathNodeType.Text); - return _pageParent[_idxParent].Value; - } - - // Must be node with complex content, so concatenate the string values of all text descendants - string s = string.Empty; - StringBuilder bldr = null; - - // Get all text nodes which follow the current node in document order, but which are still descendants - page = pageEnd = _pageCurrent; - idx = idxEnd = _idxCurrent; - if (!XPathNodeHelper.GetNonDescendant(ref pageEnd, ref idxEnd)) - { - pageEnd = null; - idxEnd = 0; - } - - while (XPathNodeHelper.GetTextFollowing(ref page, ref idx, pageEnd, idxEnd)) - { - Debug.Assert(page[idx].NodeType == XPathNodeType.Element || page[idx].IsText); - - if (s.Length == 0) - { - s = page[idx].Value; - } - else - { - if (bldr == null) - { - bldr = new StringBuilder(); - bldr.Append(s); - } - bldr.Append(page[idx].Value); - } - } - - return (bldr != null) ? bldr.ToString() : s; - } - } - - - //----------------------------------------------- - // XPathNavigator - //----------------------------------------------- - - /// - /// Create a copy of this navigator, positioned to the same node in the tree. - /// - public override XPathNavigator Clone() - { - return new XPathDocumentNavigator(_pageCurrent, _idxCurrent, _pageParent, _idxParent); - } - - /// - /// Get the XPath node type of the current node. - /// - public override XPathNodeType NodeType - { - get { return _pageCurrent[_idxCurrent].NodeType; } - } - - /// - /// Get the local name portion of the current node's name. - /// - public override string LocalName - { - get { return _pageCurrent[_idxCurrent].LocalName; } - } - - /// - /// Get the namespace portion of the current node's name. - /// - public override string NamespaceURI - { - get { return _pageCurrent[_idxCurrent].NamespaceUri; } - } - - /// - /// Get the name of the current node. - /// - public override string Name - { - get { return _pageCurrent[_idxCurrent].Name; } - } - - /// - /// Get the prefix portion of the current node's name. - /// - public override string Prefix - { - get { return _pageCurrent[_idxCurrent].Prefix; } - } - - /// - /// Get the base URI of the current node. - /// - public override string BaseURI - { - get - { - XPathNode[] page; - int idx; - - if (_idxParent != 0) - { - // Get BaseUri of parent for attribute, namespace, and collapsed text nodes - page = _pageParent; - idx = _idxParent; - } - else - { - page = _pageCurrent; - idx = _idxCurrent; - } - - do - { - switch (page[idx].NodeType) - { - case XPathNodeType.Element: - case XPathNodeType.Root: - case XPathNodeType.ProcessingInstruction: - // BaseUri is always stored with Elements, Roots, and PIs - return page[idx].BaseUri; - } - - // Get BaseUri of parent - idx = page[idx].GetParent(out page); - } - while (idx != 0); - - return string.Empty; - } - } - - /// - /// Return true if this is an element which used a shortcut tag in its Xml 1.0 serialized form. - /// - public override bool IsEmptyElement - { - get { return _pageCurrent[_idxCurrent].AllowShortcutTag; } - } - - /// - /// Return the xml name table which was used to atomize all prefixes, local-names, and - /// namespace uris in the document. - /// - public override XmlNameTable NameTable - { - get { return _pageCurrent[_idxCurrent].Document.NameTable; } - } - - /// - /// Position the navigator on the first attribute of the current node and return true. If no attributes - /// can be found, return false. - /// - public override bool MoveToFirstAttribute() - { - XPathNode[] page = _pageCurrent; - int idx = _idxCurrent; - - if (XPathNodeHelper.GetFirstAttribute(ref _pageCurrent, ref _idxCurrent)) - { - // Save element parent in order to make node-order comparison simpler - _pageParent = page; - _idxParent = idx; - return true; - } - - return false; - } - - /// - /// If positioned on an attribute, move to its next sibling attribute. If no attributes can be found, - /// return false. - /// - public override bool MoveToNextAttribute() - { - return XPathNodeHelper.GetNextAttribute(ref _pageCurrent, ref _idxCurrent); - } - - /// - /// True if the current node has one or more attributes. - /// - public override bool HasAttributes - { - get { return _pageCurrent[_idxCurrent].HasAttribute; } - } - - /// - /// Position the navigator on the attribute with the specified name and return true. If no matching - /// attribute can be found, return false. Don't assume the name parts are atomized with respect - /// to this document. - /// - public override bool MoveToAttribute(string localName, string namespaceURI) - { - XPathNode[] page = _pageCurrent; - int idx = _idxCurrent; - - if ((object)localName != (object)_atomizedLocalName) - _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null; - - if (XPathNodeHelper.GetAttribute(ref _pageCurrent, ref _idxCurrent, _atomizedLocalName, namespaceURI)) - { - // Save element parent in order to make node-order comparison simpler - _pageParent = page; - _idxParent = idx; - return true; - } - - return false; - } - - /// - /// Position the navigator on the namespace within the specified scope. If no matching namespace - /// can be found, return false. - /// - public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) - { - XPathNode[] page; - int idx; - - if (namespaceScope == XPathNamespaceScope.Local) - { - // Get local namespaces only - idx = XPathNodeHelper.GetLocalNamespaces(_pageCurrent, _idxCurrent, out page); - } - else - { - // Get all in-scope namespaces - idx = XPathNodeHelper.GetInScopeNamespaces(_pageCurrent, _idxCurrent, out page); - } - - while (idx != 0) - { - // Don't include the xmlns:xml namespace node if scope is ExcludeXml - if (namespaceScope != XPathNamespaceScope.ExcludeXml || !page[idx].IsXmlNamespaceNode) - { - _pageParent = _pageCurrent; - _idxParent = _idxCurrent; - _pageCurrent = page; - _idxCurrent = idx; - return true; - } - - // Skip past xmlns:xml - idx = page[idx].GetSibling(out page); - } - - return false; - } - - /// - /// Position the navigator on the next namespace within the specified scope. If no matching namespace - /// can be found, return false. - /// - public override bool MoveToNextNamespace(XPathNamespaceScope scope) - { - XPathNode[] page = _pageCurrent, pageParent; - int idx = _idxCurrent, idxParent; - - // If current node is not a namespace node, return false - if (page[idx].NodeType != XPathNodeType.Namespace) - return false; - - while (true) - { - // Get next namespace sibling - idx = page[idx].GetSibling(out page); - - // If there are no more nodes, return false - if (idx == 0) - return false; - - switch (scope) - { - case XPathNamespaceScope.Local: - // Once parent changes, there are no longer any local namespaces - idxParent = page[idx].GetParent(out pageParent); - if (idxParent != _idxParent || (object)pageParent != (object)_pageParent) - return false; - break; - - case XPathNamespaceScope.ExcludeXml: - // If node is xmlns:xml, then skip it - if (page[idx].IsXmlNamespaceNode) - continue; - break; - } - - // Found a matching next namespace node, so return it - break; - } - - _pageCurrent = page; - _idxCurrent = idx; - return true; - } - - /// - /// If the current node is an attribute or namespace (not content), return false. Otherwise, - /// move to the next content node. Return false if there are no more content nodes. - /// - public override bool MoveToNext() - { - return XPathNodeHelper.GetContentSibling(ref _pageCurrent, ref _idxCurrent); - } - - /// - /// If the current node is an attribute or namespace (not content), return false. Otherwise, - /// move to the previous (sibling) content node. Return false if there are no previous content nodes. - /// - public override bool MoveToPrevious() - { - // If parent exists, then this is a namespace, an attribute, or a collapsed text node, all of which do - // not have previous siblings. - if (_idxParent != 0) - return false; - - return XPathNodeHelper.GetPreviousContentSibling(ref _pageCurrent, ref _idxCurrent); - } - - /// - /// Move to the first content-typed child of the current node. Return false if the current - /// node has no content children. - /// - public override bool MoveToFirstChild() - { - if (_pageCurrent[_idxCurrent].HasCollapsedText) - { - // Virtualize collapsed text nodes - _pageParent = _pageCurrent; - _idxParent = _idxCurrent; - _idxCurrent = _pageCurrent[_idxCurrent].Document.GetCollapsedTextNode(out _pageCurrent); - return true; - } - - return XPathNodeHelper.GetContentChild(ref _pageCurrent, ref _idxCurrent); - } - - /// - /// Position the navigator on the parent of the current node. If the current node has no parent, - /// return false. - /// - public override bool MoveToParent() - { - if (_idxParent != 0) - { - // 1. For attribute nodes, element parent is always stored in order to make node-order - // comparison simpler. - // 2. For namespace nodes, parent is always stored in navigator in order to virtualize - // XPath 1.0 namespaces. - // 3. For collapsed text nodes, element parent is always stored in navigator. - Debug.Assert(_pageParent != null); - _pageCurrent = _pageParent; - _idxCurrent = _idxParent; - _pageParent = null; - _idxParent = 0; - return true; - } - - return XPathNodeHelper.GetParent(ref _pageCurrent, ref _idxCurrent); - } - - /// - /// Position this navigator to the same position as the "other" navigator. If the "other" navigator - /// is not of the same type as this navigator, then return false. - /// - public override bool MoveTo(XPathNavigator other) - { - XPathDocumentNavigator that = other as XPathDocumentNavigator; - if (that != null) - { - _pageCurrent = that._pageCurrent; - _idxCurrent = that._idxCurrent; - _pageParent = that._pageParent; - _idxParent = that._idxParent; - return true; - } - return false; - } - - /// - /// Position to the navigator to the element whose id is equal to the specified "id" string. - /// - public override bool MoveToId(string id) - { - XPathNode[] page; - int idx; - - idx = _pageCurrent[_idxCurrent].Document.LookupIdElement(id, out page); - if (idx != 0) - { - // Move to ID element and clear parent state - Debug.Assert(page[idx].NodeType == XPathNodeType.Element); - _pageCurrent = page; - _idxCurrent = idx; - _pageParent = null; - _idxParent = 0; - return true; - } - - return false; - } - - /// - /// Returns true if this navigator is positioned to the same node as the "other" navigator. Returns false - /// if not, or if the "other" navigator is not the same type as this navigator. - /// - public override bool IsSamePosition(XPathNavigator other) - { - XPathDocumentNavigator that = other as XPathDocumentNavigator; - if (that != null) - { - return _idxCurrent == that._idxCurrent && _pageCurrent == that._pageCurrent && - _idxParent == that._idxParent && _pageParent == that._pageParent; - } - return false; - } - - /// - /// Returns true if the current node has children. - /// - public override bool HasChildren - { - get { return _pageCurrent[_idxCurrent].HasContentChild; } - } - - /// - /// Position the navigator on the root node of the current document. - /// - public override void MoveToRoot() - { - if (_idxParent != 0) - { - // Clear parent state - _pageParent = null; - _idxParent = 0; - } - _idxCurrent = _pageCurrent[_idxCurrent].GetRoot(out _pageCurrent); - } - - /// - /// Move to the first element child of the current node with the specified name. Return false - /// if the current node has no matching element children. - /// - public override bool MoveToChild(string localName, string namespaceURI) - { - if ((object)localName != (object)_atomizedLocalName) - _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null; - - return XPathNodeHelper.GetElementChild(ref _pageCurrent, ref _idxCurrent, _atomizedLocalName, namespaceURI); - } - - /// - /// Move to the first element sibling of the current node with the specified name. Return false - /// if the current node has no matching element siblings. - /// - public override bool MoveToNext(string localName, string namespaceURI) - { - if ((object)localName != (object)_atomizedLocalName) - _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null; - - return XPathNodeHelper.GetElementSibling(ref _pageCurrent, ref _idxCurrent, _atomizedLocalName, namespaceURI); - } - - /// - /// Move to the first content child of the current node with the specified type. Return false - /// if the current node has no matching children. - /// - public override bool MoveToChild(XPathNodeType type) - { - if (_pageCurrent[_idxCurrent].HasCollapsedText) - { - // Only XPathNodeType.Text and XPathNodeType.All matches collapsed text node - if (type != XPathNodeType.Text && type != XPathNodeType.All) - return false; - - // Virtualize collapsed text nodes - _pageParent = _pageCurrent; - _idxParent = _idxCurrent; - _idxCurrent = _pageCurrent[_idxCurrent].Document.GetCollapsedTextNode(out _pageCurrent); - return true; - } - - return XPathNodeHelper.GetContentChild(ref _pageCurrent, ref _idxCurrent, type); - } - - /// - /// Move to the first content sibling of the current node with the specified type. Return false - /// if the current node has no matching siblings. - /// - public override bool MoveToNext(XPathNodeType type) - { - return XPathNodeHelper.GetContentSibling(ref _pageCurrent, ref _idxCurrent, type); - } - - /// - /// Move to the next element that: - /// 1. Follows the current node in document order (includes descendants, unlike XPath following axis) - /// 2. Precedes "end" in document order (if end is null, then all following nodes in the document are considered) - /// 3. Has the specified QName - /// Return false if the current node has no matching following elements. - /// - public override bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end) - { - XPathNode[] pageEnd; - int idxEnd; - - if ((object)localName != (object)_atomizedLocalName) - _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null; - - // Get node on which scan ends (null if rest of document should be scanned) - idxEnd = GetFollowingEnd(end as XPathDocumentNavigator, false, out pageEnd); - - // If this navigator is positioned on a virtual node, then compute following of parent - if (_idxParent != 0) - { - if (!XPathNodeHelper.GetElementFollowing(ref _pageParent, ref _idxParent, pageEnd, idxEnd, _atomizedLocalName, namespaceURI)) - return false; - - _pageCurrent = _pageParent; - _idxCurrent = _idxParent; - _pageParent = null; - _idxParent = 0; - return true; - } - - return XPathNodeHelper.GetElementFollowing(ref _pageCurrent, ref _idxCurrent, pageEnd, idxEnd, _atomizedLocalName, namespaceURI); - } - - /// - /// Move to the next node that: - /// 1. Follows the current node in document order (includes descendants, unlike XPath following axis) - /// 2. Precedes "end" in document order (if end is null, then all following nodes in the document are considered) - /// 3. Has the specified XPathNodeType - /// Return false if the current node has no matching following nodes. - /// - public override bool MoveToFollowing(XPathNodeType type, XPathNavigator end) - { - XPathDocumentNavigator endTiny = end as XPathDocumentNavigator; - XPathNode[] page, pageEnd; - int idx, idxEnd; - - // If searching for text, make sure to handle collapsed text nodes correctly - if (type == XPathNodeType.Text || type == XPathNodeType.All) - { - if (_pageCurrent[_idxCurrent].HasCollapsedText) - { - // Positioned on an element with collapsed text, so return the virtual text node, assuming it's before "end" - if (endTiny != null && _idxCurrent == endTiny._idxParent && _pageCurrent == endTiny._pageParent) - { - // "end" is positioned to a virtual attribute, namespace, or text node - return false; - } - - _pageParent = _pageCurrent; - _idxParent = _idxCurrent; - _idxCurrent = _pageCurrent[_idxCurrent].Document.GetCollapsedTextNode(out _pageCurrent); - return true; - } - - if (type == XPathNodeType.Text) - { - // Get node on which scan ends (null if rest of document should be scanned, parent if positioned on virtual node) - idxEnd = GetFollowingEnd(endTiny, true, out pageEnd); - - // If this navigator is positioned on a virtual node, then compute following of parent - if (_idxParent != 0) - { - page = _pageParent; - idx = _idxParent; - } - else - { - page = _pageCurrent; - idx = _idxCurrent; - } - - // If ending node is a virtual node, and current node is its parent, then we're done - if (endTiny != null && endTiny._idxParent != 0 && idx == idxEnd && page == pageEnd) - return false; - - // Get all virtual (collapsed) and physical text nodes which follow the current node - if (!XPathNodeHelper.GetTextFollowing(ref page, ref idx, pageEnd, idxEnd)) - return false; - - if (page[idx].NodeType == XPathNodeType.Element) - { - // Virtualize collapsed text nodes - Debug.Assert(page[idx].HasCollapsedText); - _idxCurrent = page[idx].Document.GetCollapsedTextNode(out _pageCurrent); - _pageParent = page; - _idxParent = idx; - } - else - { - // Physical text node - Debug.Assert(page[idx].IsText); - _pageCurrent = page; - _idxCurrent = idx; - _pageParent = null; - _idxParent = 0; - } - return true; - } - } - - // Get node on which scan ends (null if rest of document should be scanned, parent + 1 if positioned on virtual node) - idxEnd = GetFollowingEnd(endTiny, false, out pageEnd); - - // If this navigator is positioned on a virtual node, then compute following of parent - if (_idxParent != 0) - { - if (!XPathNodeHelper.GetContentFollowing(ref _pageParent, ref _idxParent, pageEnd, idxEnd, type)) - return false; - - _pageCurrent = _pageParent; - _idxCurrent = _idxParent; - _pageParent = null; - _idxParent = 0; - return true; - } - - return XPathNodeHelper.GetContentFollowing(ref _pageCurrent, ref _idxCurrent, pageEnd, idxEnd, type); - } - - /// - /// Return an iterator that ranges over all children of the current node that match the specified XPathNodeType. - /// - public override XPathNodeIterator SelectChildren(XPathNodeType type) - { - return new XPathDocumentKindChildIterator(this, type); - } - - /// - /// Return an iterator that ranges over all children of the current node that match the specified QName. - /// - public override XPathNodeIterator SelectChildren(string name, string namespaceURI) - { - // If local name is wildcard, then call XPathNavigator.SelectChildren - if (name == null || name.Length == 0) - return base.SelectChildren(name, namespaceURI); - - return new XPathDocumentElementChildIterator(this, name, namespaceURI); - } - - /// - /// Return an iterator that ranges over all descendants of the current node that match the specified - /// XPathNodeType. If matchSelf is true, then also perform the match on the current node. - /// - public override XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf) - { - return new XPathDocumentKindDescendantIterator(this, type, matchSelf); - } - - /// - /// Return an iterator that ranges over all descendants of the current node that match the specified - /// QName. If matchSelf is true, then also perform the match on the current node. - /// - public override XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf) - { - // If local name is wildcard, then call XPathNavigator.SelectDescendants - if (name == null || name.Length == 0) - return base.SelectDescendants(name, namespaceURI, matchSelf); - - return new XPathDocumentElementDescendantIterator(this, name, namespaceURI, matchSelf); - } - - /// - /// Returns: - /// XmlNodeOrder.Unknown -- This navigator and the "other" navigator are not of the same type, or the - /// navigator's are not positioned on nodes in the same document. - /// XmlNodeOrder.Before -- This navigator's current node is before the "other" navigator's current node - /// in document order. - /// XmlNodeOrder.After -- This navigator's current node is after the "other" navigator's current node - /// in document order. - /// XmlNodeOrder.Same -- This navigator is positioned on the same node as the "other" navigator. - /// - public override XmlNodeOrder ComparePosition(XPathNavigator other) - { - XPathDocumentNavigator that = other as XPathDocumentNavigator; - if (that != null) - { - XPathDocument thisDoc = _pageCurrent[_idxCurrent].Document; - XPathDocument thatDoc = that._pageCurrent[that._idxCurrent].Document; - if ((object)thisDoc == (object)thatDoc) - { - int locThis = GetPrimaryLocation(); - int locThat = that.GetPrimaryLocation(); - - if (locThis == locThat) - { - locThis = GetSecondaryLocation(); - locThat = that.GetSecondaryLocation(); - - if (locThis == locThat) - return XmlNodeOrder.Same; - } - return (locThis < locThat) ? XmlNodeOrder.Before : XmlNodeOrder.After; - } - } - return XmlNodeOrder.Unknown; - } - - /// - /// Return true if the "other" navigator's current node is a descendant of this navigator's current node. - /// - public override bool IsDescendant(XPathNavigator other) - { - XPathDocumentNavigator that = other as XPathDocumentNavigator; - if (that != null) - { - XPathNode[] pageThat; - int idxThat; - - // If that current node's parent is virtualized, then start with the virtual parent - if (that._idxParent != 0) - { - pageThat = that._pageParent; - idxThat = that._idxParent; - } - else - { - idxThat = that._pageCurrent[that._idxCurrent].GetParent(out pageThat); - } - - while (idxThat != 0) - { - if (idxThat == _idxCurrent && pageThat == _pageCurrent) - return true; - idxThat = pageThat[idxThat].GetParent(out pageThat); - } - } - return false; - } - - /// - /// Construct a primary location for this navigator. The location is an integer that can be - /// easily compared with other locations in the same document in order to determine the relative - /// document order of two nodes. If two locations compare equal, then secondary locations should - /// be compared. - /// - private int GetPrimaryLocation() - { - // Is the current node virtualized? - if (_idxParent == 0) - { - // No, so primary location should be derived from current node - return XPathNodeHelper.GetLocation(_pageCurrent, _idxCurrent); - } - - // Yes, so primary location should be derived from parent node - return XPathNodeHelper.GetLocation(_pageParent, _idxParent); - } - - /// - /// Construct a secondary location for this navigator. This location should only be used if - /// primary locations previously compared equal. - /// - private int GetSecondaryLocation() - { - // Is the current node virtualized? - if (_idxParent == 0) - { - // No, so secondary location is int.MinValue (always first) - return int.MinValue; - } - - // Yes, so secondary location should be derived from current node - // This happens with attributes nodes, namespace nodes, collapsed text nodes, and atomic values - switch (_pageCurrent[_idxCurrent].NodeType) - { - case XPathNodeType.Namespace: - // Namespace nodes come first (make location negative, but greater than int.MinValue) - return int.MinValue + 1 + XPathNodeHelper.GetLocation(_pageCurrent, _idxCurrent); - - case XPathNodeType.Attribute: - // Attribute nodes come next (location is always positive) - return XPathNodeHelper.GetLocation(_pageCurrent, _idxCurrent); - - default: - // Collapsed text nodes are always last - return int.MaxValue; - } - } - - /// - /// Create a unique id for the current node. This is used by the generate-id() function. - /// - internal override string UniqueId - { - get - { - // 32-bit integer is split into 5-bit groups, the maximum number of groups is 7 - char[] buf = new char[1 + 7 + 1 + 7]; - int idx = 0; - int loc; - - // Ensure distinguishing attributes, namespaces and child nodes - buf[idx++] = NodeTypeLetter[(int)_pageCurrent[_idxCurrent].NodeType]; - - // If the current node is virtualized, code its parent - if (_idxParent != 0) - { - loc = (_pageParent[0].PageInfo.PageNumber - 1) << 16 | (_idxParent - 1); - do - { - buf[idx++] = UniqueIdTbl[loc & 0x1f]; - loc >>= 5; - } while (loc != 0); - buf[idx++] = '0'; - } - - // Code the node itself - loc = (_pageCurrent[0].PageInfo.PageNumber - 1) << 16 | (_idxCurrent - 1); - do - { - buf[idx++] = UniqueIdTbl[loc & 0x1f]; - loc >>= 5; - } while (loc != 0); - - return new string(buf, 0, idx); - } - } - - public override object UnderlyingObject - { - get - { - // Since we don't have any underlying PUBLIC object - // the best one we can return is a clone of the navigator. - // Note that it should be a clone as the user might Move the returned navigator - // around and thus cause unexpected behavior of the caller of this class (For example the validator) - return this.Clone(); - } - } - - //----------------------------------------------- - // IXmlLineInfo - //----------------------------------------------- - - /// - /// Return true if line number information is recorded in the cache. - /// - public bool HasLineInfo() - { - return _pageCurrent[_idxCurrent].Document.HasLineInfo; - } - - /// - /// Return the source line number of the current node. - /// - public int LineNumber - { - get - { - // If the current node is a collapsed text node, then return parent element's line number - if (_idxParent != 0 && NodeType == XPathNodeType.Text) - return _pageParent[_idxParent].LineNumber; - - return _pageCurrent[_idxCurrent].LineNumber; - } - } - - /// - /// Return the source line position of the current node. - /// - public int LinePosition - { - get - { - // If the current node is a collapsed text node, then get position from parent element - if (_idxParent != 0 && NodeType == XPathNodeType.Text) - return _pageParent[_idxParent].CollapsedLinePosition; - - return _pageCurrent[_idxCurrent].LinePosition; - } - } - - - //----------------------------------------------- - // Helper methods - //----------------------------------------------- - - /// - /// Get hashcode based on current position of the navigator. - /// - public int GetPositionHashCode() - { - return _idxCurrent ^ _idxParent; - } - - /// - /// Return true if navigator is positioned to an element having the specified name. - /// - public bool IsElementMatch(string localName, string namespaceURI) - { - if ((object)localName != (object)_atomizedLocalName) - _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null; - - // Cannot be an element if parent is stored - if (_idxParent != 0) - return false; - - return _pageCurrent[_idxCurrent].ElementMatch(_atomizedLocalName, namespaceURI); - } - - /// - /// Return true if navigator is positioned to a content node of the specified kind. Whitespace/SignficantWhitespace/Text are - /// all treated the same (i.e. they all match each other). - /// - public bool IsContentKindMatch(XPathNodeType typ) - { - return (((1 << (int)_pageCurrent[_idxCurrent].NodeType) & GetContentKindMask(typ)) != 0); - } - - /// - /// Return true if navigator is positioned to a node of the specified kind. Whitespace/SignficantWhitespace/Text are - /// all treated the same (i.e. they all match each other). - /// - public bool IsKindMatch(XPathNodeType typ) - { - return (((1 << (int)_pageCurrent[_idxCurrent].NodeType) & GetKindMask(typ)) != 0); - } - - /// - /// "end" is positioned on a node which terminates a following scan. Return the page and index of "end" if it - /// is positioned to a non-virtual node. If "end" is positioned to a virtual node: - /// 1. If useParentOfVirtual is true, then return the page and index of the virtual node's parent - /// 2. If useParentOfVirtual is false, then return the page and index of the virtual node's parent + 1. - /// - private int GetFollowingEnd(XPathDocumentNavigator end, bool useParentOfVirtual, out XPathNode[] pageEnd) - { - // If ending navigator is positioned to a node in another document, then return null - if (end != null && _pageCurrent[_idxCurrent].Document == end._pageCurrent[end._idxCurrent].Document) - { - // If the ending navigator is not positioned on a virtual node, then return its current node - if (end._idxParent == 0) - { - pageEnd = end._pageCurrent; - return end._idxCurrent; - } - - // If the ending navigator is positioned on an attribute, namespace, or virtual text node, then use the - // next physical node instead, as the results will be the same. - pageEnd = end._pageParent; - return (useParentOfVirtual) ? end._idxParent : end._idxParent + 1; - } - - // No following, so set pageEnd to null and return an index of 0 - pageEnd = null; - return 0; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentView.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentView.cs deleted file mode 100644 index 1b7ea1dd825..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathDocumentView.cs +++ /dev/null @@ -1,819 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#if ENABLEDATABINDING -using System; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; - -namespace Microsoft.Xml.XPath.DataBinding -{ - /// - public sealed class XPathDocumentView : IBindingList, ITypedList { - ArrayList rows; - Shape rowShape; - XPathNode ndRoot; - XPathDocument document; - string xpath; - IXmlNamespaceResolver namespaceResolver; - IXmlNamespaceResolver xpathResolver; - - // - // Constructors - // - - /// - public XPathDocumentView(XPathDocument document) - : this(document, (IXmlNamespaceResolver)null) { - } - - /// - public XPathDocumentView(XPathDocument document, IXmlNamespaceResolver namespaceResolver) { - if (null == document) - throw new ArgumentNullException("document"); - this.document = document; - this.ndRoot = document.Root; - if (null == this.ndRoot) - throw new ArgumentException("document"); - this.namespaceResolver = namespaceResolver; - ArrayList rows = new ArrayList(); - this.rows = rows; - Debug.Assert(XPathNodeType.Root == this.ndRoot.NodeType); - XPathNode nd = this.ndRoot.Child; - while (null != nd) { - if (XPathNodeType.Element == nd.NodeType) - rows.Add(nd); - nd = nd.Sibling; - } - DeriveShapeFromRows(); - } - - /// - public XPathDocumentView(XPathDocument document, string xpath) - : this(document, xpath, null, true) { - } - - /// - public XPathDocumentView(XPathDocument document, string xpath, IXmlNamespaceResolver namespaceResolver) - : this(document, xpath, namespaceResolver, false) { - } - - /// - public XPathDocumentView(XPathDocument document, string xpath, IXmlNamespaceResolver namespaceResolver, bool showPrefixes) { - if (null == document) - throw new ArgumentNullException("document"); - this.xpath = xpath; - this.document = document; - this.ndRoot = document.Root; - if (null == this.ndRoot) - throw new ArgumentException("document"); - this.ndRoot = document.Root; - this.xpathResolver = namespaceResolver; - if (showPrefixes) - this.namespaceResolver = namespaceResolver; - ArrayList rows = new ArrayList(); - this.rows = rows; - InitFromXPath(this.ndRoot, xpath); - } - - internal XPathDocumentView(XPathNode root, ArrayList rows, Shape rowShape) { - this.rows = rows; - this.rowShape = rowShape; - this.ndRoot = root; - } - - // - // public properties - - /// - public XPathDocument Document { get { return this.document; } } - - /// - public String XPath { get { return xpath; } } - - // - // IEnumerable Implementation - - /// - public IEnumerator GetEnumerator() { - return new RowEnumerator(this); - } - - // - // ICollection implementation - - /// - public int Count { - get { return this.rows.Count; } - } - - /// - public bool IsSynchronized { - get { return false ; } - } - - /// - public object SyncRoot { - get { return null; } - } - - /// - public void CopyTo(Array array, int index) { - object o; - ArrayList rows = this.rows; - for (int i=0; i < rows.Count; i++) - o = this[i]; // force creation lazy of row object - rows.CopyTo(array, index); - } - - /// - /// - /// strongly typed version of CopyTo, demanded by Fxcop. - /// - public void CopyTo(XPathNodeView[] array, int index) { - object o; - ArrayList rows = this.rows; - for (int i=0; i < rows.Count; i++) - o = this[i]; // force creation lazy of row object - rows.CopyTo(array, index); - } - - // - // IList Implementation - - /// - bool IList.IsReadOnly { - get { return true; } - } - - /// - bool IList.IsFixedSize { - get { return true; } - } - - /// - bool IList.Contains(object value) { - return this.rows.Contains(value); - } - - /// - void IList.Remove(object value) { - throw new NotSupportedException("IList.Remove"); - } - - /// - void IList.RemoveAt(int index) { - throw new NotSupportedException("IList.RemoveAt"); - } - - /// - void IList.Clear() { - throw new NotSupportedException("IList.Clear"); - } - - /// - int IList.Add(object value) { - throw new NotSupportedException("IList.Add"); - } - - /// - void IList.Insert(int index, object value) { - throw new NotSupportedException("IList.Insert"); - } - - /// - int IList.IndexOf( object value ) { - return this.rows.IndexOf(value); - } - - /// - object IList.this[int index] { - get { - object val = this.rows[index]; - if (val is XPathNodeView) - return val; - XPathNodeView xiv = FillRow((XPathNode)val, this.rowShape); - this.rows[index] = xiv; - return xiv; - } - set { - throw new NotSupportedException("IList.this[]"); - } - } - - /// - /// - /// strongly typed version of Contains, demanded by Fxcop. - /// - public bool Contains(XPathNodeView value) { - return this.rows.Contains(value); - } - - /// - /// - /// strongly typed version of Add, demanded by Fxcop. - /// - public int Add(XPathNodeView value) { - throw new NotSupportedException("IList.Add"); - } - - /// - /// - /// strongly typed version of Insert, demanded by Fxcop. - /// - public void Insert(int index, XPathNodeView value) { - throw new NotSupportedException("IList.Insert"); - } - - /// - /// - /// strongly typed version of IndexOf, demanded by Fxcop. - /// - public int IndexOf(XPathNodeView value) { - return this.rows.IndexOf(value); - } - - /// - /// - /// strongly typed version of Remove, demanded by Fxcop. - /// - public void Remove(XPathNodeView value) { - throw new NotSupportedException("IList.Remove"); - } - - /// - /// - /// strongly typed version of Item, demanded by Fxcop. - /// - public XPathNodeView this[int index] { - get { - object val = this.rows[index]; - XPathNodeView nodeView; - nodeView = val as XPathNodeView; - if (nodeView != null) { - return nodeView; - } - nodeView = FillRow((XPathNode)val, this.rowShape); - this.rows[index] = nodeView; - return nodeView; - } - set { - throw new NotSupportedException("IList.this[]"); - } - } - - // - // IBindingList Implementation - - /// - public bool AllowEdit { - get { return false; } - } - - /// - public bool AllowAdd { - get { return false; } - } - - /// - public bool AllowRemove { - get { return false; } - } - - /// - public bool AllowNew { - get { return false; } - } - - /// - public object AddNew() { - throw new NotSupportedException("IBindingList.AddNew"); - } - - /// - public bool SupportsChangeNotification { - get { return false; } - } - - /// - public event ListChangedEventHandler ListChanged { - add { - throw new NotSupportedException("IBindingList.ListChanged"); - } - remove { - throw new NotSupportedException("IBindingList.ListChanged"); - } - } - - /// - public bool SupportsSearching { - get { return false; } - } - - /// - public bool SupportsSorting { - get { return false; } - } - - /// - public bool IsSorted { - get { return false; } - } - - /// - public PropertyDescriptor SortProperty { - get { throw new NotSupportedException("IBindingList.SortProperty"); } - } - - /// - public ListSortDirection SortDirection { - get { throw new NotSupportedException("IBindingList.SortDirection"); } - } - - /// - public void AddIndex( PropertyDescriptor descriptor ) { - throw new NotSupportedException("IBindingList.AddIndex"); - } - - /// - public void ApplySort( PropertyDescriptor descriptor, ListSortDirection direction ) { - throw new NotSupportedException("IBindingList.ApplySort"); - } - - /// - public int Find(PropertyDescriptor propertyDescriptor, object key) { - throw new NotSupportedException("IBindingList.Find"); - } - - /// - public void RemoveIndex(PropertyDescriptor propertyDescriptor) { - throw new NotSupportedException("IBindingList.RemoveIndex"); - } - - /// - public void RemoveSort() { - throw new NotSupportedException("IBindingList.RemoveSort"); - } - - - // - // ITypedList Implementation - - /// - public string GetListName(PropertyDescriptor[] listAccessors) { - if( listAccessors == null ) { - return this.rowShape.Name; - } - else { - return listAccessors[listAccessors.Length-1].Name; - } - } - - /// - public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors) { - Shape shape = null; - if( listAccessors == null ) { - shape = this.rowShape; - } - else { - XPathNodeViewPropertyDescriptor propdesc = listAccessors[listAccessors.Length-1] as XPathNodeViewPropertyDescriptor; - if (null != propdesc) - shape = propdesc.Shape; - } - - if (null == shape) - throw new ArgumentException("listAccessors"); - return new PropertyDescriptorCollection(shape.PropertyDescriptors); - } - - - // - // Internal Implementation - - - internal Shape RowShape { get { return this.rowShape; } } - - internal void SetRows(ArrayList rows) { - Debug.Assert(this.rows == null); - this.rows = rows; - } - - - XPathNodeView FillRow(XPathNode ndRow, Shape shape) { - object[] columns; - XPathNode nd; - switch (shape.BindingType) { - case BindingType.Text: - case BindingType.Attribute: - columns = new object[1]; - columns[0] = ndRow; - return new XPathNodeView(this, ndRow, columns); - - case BindingType.Repeat: - columns = new object[1]; - nd = TreeNavigationHelper.GetContentChild(ndRow); - columns[0] = FillColumn(new ContentIterator(nd, shape), shape); - return new XPathNodeView(this, ndRow, columns); - - case BindingType.Sequence: - case BindingType.Choice: - case BindingType.All: - int subShapesCount = shape.SubShapes.Count; - columns = new object[subShapesCount]; - if (shape.BindingType == BindingType.Sequence - && shape.SubShape(0).BindingType == BindingType.Attribute) { - FillAttributes(ndRow, shape, columns); - } - Shape lastSubShape = (Shape)shape.SubShapes[subShapesCount - 1]; - if (lastSubShape.BindingType == BindingType.Text) { //Attributes followed by simpe content or mixed content - columns[subShapesCount - 1] = ndRow; - return new XPathNodeView(this, ndRow, columns); - } - else { - nd = TreeNavigationHelper.GetContentChild(ndRow); - return FillSubRow(new ContentIterator(nd, shape), shape, columns); - } - - default: - // should not map to a row -#if DEBUG - throw new NotSupportedException("Unable to bind row to: "+shape.BindingType.ToString()); -#else - throw new NotSupportedException(); -#endif - } - } - - void FillAttributes(XPathNode nd, Shape shape, object[] cols) { - int i = 0; - while (i < cols.Length) { - Shape attrShape = shape.SubShape(i); - if (attrShape.BindingType != BindingType.Attribute) - break; - XmlQualifiedName name = attrShape.AttributeName; - XPathNode ndAttr = nd.GetAttribute( name.Name, name.Namespace ); - if (null != ndAttr) - cols[i] = ndAttr; - i++; - } - } - - object FillColumn(ContentIterator iter, Shape shape) { - object val; - switch (shape.BindingType) { - case BindingType.Element: - val = iter.Node; - iter.Next(); - break; - - case BindingType.ElementNested: { - ArrayList rows = new ArrayList(); - rows.Add(iter.Node); - iter.Next(); - val = new XPathDocumentView(null, rows, shape.NestedShape); - break; - } - - case BindingType.Repeat: { - ArrayList rows = new ArrayList(); - Shape subShape = shape.SubShape(0); - if (subShape.BindingType == BindingType.ElementNested) { - Shape nestShape = subShape.NestedShape; - XPathDocumentView xivc = new XPathDocumentView(null, null, nestShape); - XPathNode nd; - while (null != (nd = iter.Node) - && subShape.IsParticleMatch(iter.Particle)) { - rows.Add(nd); - iter.Next(); - } - xivc.SetRows(rows); - val = xivc; - } - else { - XPathDocumentView xivc = new XPathDocumentView(null, null, subShape); - XPathNode nd; - while (null != (nd = iter.Node) - && shape.IsParticleMatch(iter.Particle)) { - rows.Add(xivc.FillSubRow(iter, subShape, null)); - } - xivc.SetRows(rows); - val = xivc; - } - break; - } - - case BindingType.Sequence: - case BindingType.Choice: - case BindingType.All: { - XPathDocumentView docview = new XPathDocumentView(null, null, shape); - ArrayList rows = new ArrayList(); - rows.Add(docview.FillSubRow(iter, shape, null)); - docview.SetRows(rows); - val = docview; - break; - } - - default: - case BindingType.Text: - case BindingType.Attribute: - throw new NotSupportedException(); - } - return val; - } - - XPathNodeView FillSubRow(ContentIterator iter, Shape shape, object[] columns) { - if (null == columns) { - int colCount = shape.SubShapes.Count; - if (0 == colCount) - colCount = 1; - columns = new object[colCount]; - } - - switch (shape.BindingType) { - case BindingType.Element: - columns[0] = FillColumn(iter, shape); - break; - - case BindingType.Sequence: { - int iPrev = -1; - int i; - while (null != iter.Node) { - i = shape.FindMatchingSubShape(iter.Particle); - if (i <= iPrev) - break; - columns[i] = FillColumn(iter, shape.SubShape(i)); - iPrev = i; - } - break; - } - - case BindingType.All: { - while (null != iter.Node) { - int i = shape.FindMatchingSubShape(iter.Particle); - if (-1 == i || null != columns[i]) - break; - columns[i] = FillColumn(iter, shape.SubShape(i)); - } - break; - } - - case BindingType.Choice: { - int i = shape.FindMatchingSubShape(iter.Particle); - if (-1 != i) { - columns[i] = FillColumn(iter, shape.SubShape(i)); - } - break; - } - - case BindingType.Repeat: - default: - // should not map to a row - throw new NotSupportedException(); - } - return new XPathNodeView(this, null, columns); - } - - // - // XPath support - // - - void InitFromXPath(XPathNode ndRoot, string xpath) { - XPathStep[] steps = ParseXPath(xpath, this.xpathResolver); - ArrayList rows = this.rows; - rows.Clear(); - PopulateFromXPath(ndRoot, steps, 0); - DeriveShapeFromRows(); - } - - void DeriveShapeFromRows() { - object schemaInfo = null; - for (int i=0; (i= xpath.Length) - throw new XmlException(Res.XmlDataBinding_XPathEnd, (string[])null); - if ('/' != xpath[pos]) - throw new XmlException(Res.XmlDataBinding_XPathRequireSlash, (string[])null); - pos++; - char ch = xpath[pos]; - if (ch == '.') { - pos++; - // again... - } - else if ('@' == ch) { - if (0 == i) - throw new XmlException(Res.XmlDataBinding_XPathAttrNotFirst, (string[])null); - pos++; - if (pos >= xpath.Length) - throw new XmlException(Res.XmlDataBinding_XPathEnd, (string[])null); - steps[i].name = ParseQName(xpath, ref pos, xnr); - steps[i].type = XPathNodeType.Attribute; - i++; - if (pos != xpath.Length) - throw new XmlException(Res.XmlDataBinding_XPathAttrLast, (string[])null); - break; - } - else { - steps[i].name = ParseQName(xpath, ref pos, xnr); - steps[i].type = XPathNodeType.Element; - i++; - if (pos == xpath.Length) - break; - } - } - Debug.Assert(i == steps.Length); - return steps; - } - - // Parse a QName from the string, and resolve prefix - XmlQualifiedName ParseQName(string xpath, ref int pos, IXmlNamespaceResolver xnr) { - string nm = ParseName(xpath, ref pos); - if (pos < xpath.Length && ':' == xpath[pos]) { - pos++; - string ns = (null==xnr) ? null : xnr.LookupNamespace(nm); - if (null == ns || 0 == ns.Length) - throw new XmlException(Res.Sch_UnresolvedPrefix, nm); - return new XmlQualifiedName(ParseName(xpath, ref pos), ns); - } - else { - return new XmlQualifiedName(nm); - } - } - - // Parse a NCNAME from the string - string ParseName(string xpath, ref int pos) { - char ch; - int start = pos++; - while (pos < xpath.Length - && '/' != (ch = xpath[pos]) - && ':' != ch) - pos++; - string nm = xpath.Substring(start, pos - start); - if (!XmlReader.IsName(nm)) - throw new XmlException(Res.Xml_InvalidNameChars, (string[])null); - return this.document.NameTable.Add(nm); - } - - - // - // Helper classes - // - - class ContentIterator { - XPathNode node; - ContentValidator contentValidator; - ValidationState currentState; - object currentParticle; - - public ContentIterator(XPathNode nd, Shape shape) { - this.node = nd; - XmlSchemaElement xse = shape.XmlSchemaElement; - Debug.Assert(null != xse); - SchemaElementDecl decl = xse.ElementDecl; - Debug.Assert(null != decl); - this.contentValidator = decl.ContentValidator; - this.currentState = new ValidationState(); - this.contentValidator.InitValidation(this.currentState); - this.currentState.ProcessContents = XmlSchemaContentProcessing.Strict; - if (nd != null) - Advance(); - } - - public XPathNode Node { get { return this.node; } } - public object Particle { get { return this.currentParticle; } } - - public bool Next() { - if (null != this.node) { - this.node = TreeNavigationHelper.GetContentSibling(this.node, XPathNodeType.Element); - if (node != null) - Advance(); - return null != this.node; - } - return false; - } - - private void Advance() { - XPathNode nd = this.node; - int errorCode; - this.currentParticle = this.contentValidator.ValidateElement(new XmlQualifiedName(nd.LocalName, nd.NamespaceUri), this.currentState, out errorCode); - if (null == this.currentParticle || 0 != errorCode) { - this.node = null; - } - } - } - - - // Helper class to implement enumerator over rows - // We can't just use ArrayList enumerator because - // sometims rows may be lazily constructed - sealed class RowEnumerator : IEnumerator { - XPathDocumentView collection; - int pos; - - internal RowEnumerator(XPathDocumentView collection) { - this.collection = collection; - this.pos = -1; - } - - public object Current { - get { - if (this.pos < 0 || this.pos >= this.collection.Count) - return null; - return this.collection[this.pos]; - } - } - - public void Reset() { - this.pos = -1; - } - - public bool MoveNext() { - this.pos++; - int max = this.collection.Count; - if (this.pos > max) - this.pos = max; - return this.pos < max; - } - } - } -} -#endif diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNode.cs deleted file mode 100644 index ea5b9f2ab88..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNode.cs +++ /dev/null @@ -1,515 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; - -namespace MS.Internal.Xml.Cache -{ - /// - /// Implementation of a Node in the XPath/XQuery data model. - /// 1. All nodes are stored in variable-size pages (max 65536 nodes/page) of XPathNode structures. - /// 2. Pages are sequentially numbered. Nodes are allocated in strict document order. - /// 3. Node references take the form of a (page, index) pair. - /// 4. Each node explicitly stores a parent and a sibling reference. - /// 5. If a node has one or more attributes and/or non-collapsed content children, then its first - /// child is stored in the next slot. If the node is in the last slot of a page, then its first - /// child is stored in the first slot of the next page. - /// 6. Attributes are linked together at the start of the child list. - /// 7. Namespaces are allocated in totally separate pages. Elements are associated with - /// declared namespaces via a hashtable map in the document. - /// 8. Name parts are always non-null (string.Empty for nodes without names) - /// 9. XPathNodeInfoAtom contains all information that is common to many nodes in a - /// document, and therefore is atomized to save space. This includes the document, the name, - /// the child, sibling, parent, and value pages, and the schema type. - /// 10. The node structure is 20 bytes in length. Out-of-line overhead is typically 2-4 bytes per node. - /// - internal struct XPathNode - { - private XPathNodeInfoAtom _info; // Atomized node information - private ushort _idxSibling; // Page index of sibling node - private ushort _idxParent; // Page index of parent node - private ushort _idxSimilar; // Page index of next node in document order that has local name with same hashcode - private ushort _posOffset; // Line position offset of node (added to LinePositionBase) - private uint _props; // Node properties (broken down into bits below) - private string _value; // String value of node - - private const uint NodeTypeMask = 0xF; - private const uint HasAttributeBit = 0x10; - private const uint HasContentChildBit = 0x20; - private const uint HasElementChildBit = 0x40; - private const uint HasCollapsedTextBit = 0x80; - private const uint AllowShortcutTagBit = 0x100; // True if this is an element that allows shortcut tag syntax - private const uint HasNmspDeclsBit = 0x200; // True if this is an element with namespace declarations declared on it - - private const uint LineNumberMask = 0x00FFFC00; // 14 bits for line number offset (0 - 16K) - private const int LineNumberShift = 10; - private const int CollapsedPositionShift = 24; // 8 bits for collapsed text position offset (0 - 256) - -#if DEBUG - public const int MaxLineNumberOffset = 0x20; - public const int MaxLinePositionOffset = 0x20; - public const int MaxCollapsedPositionOffset = 0x10; -#else - public const int MaxLineNumberOffset = 0x3FFF; - public const int MaxLinePositionOffset = 0xFFFF; - public const int MaxCollapsedPositionOffset = 0xFF; -#endif - - /// - /// Returns the type of this node - /// - public XPathNodeType NodeType - { - get { return (XPathNodeType)(_props & NodeTypeMask); } - } - - /// - /// Returns the namespace prefix of this node. If this node has no prefix, then the empty string - /// will be returned (never null). - /// - public string Prefix - { - get { return _info.Prefix; } - } - - /// - /// Returns the local name of this node. If this node has no name, then the empty string - /// will be returned (never null). - /// - public string LocalName - { - get { return _info.LocalName; } - } - - /// - /// Returns the name of this node. If this node has no name, then the empty string - /// will be returned (never null). - /// - public string Name - { - get - { - if (Prefix.Length == 0) - { - return LocalName; - } - else - { - return string.Concat(Prefix, ":", LocalName); - } - } - } - - /// - /// Returns the namespace part of this node's name. If this node has no name, then the empty string - /// will be returned (never null). - /// - public string NamespaceUri - { - get { return _info.NamespaceUri; } - } - - /// - /// Returns this node's document. - /// - public XPathDocument Document - { - get { return _info.Document; } - } - - /// - /// Returns this node's base Uri. This is string.Empty for all node kinds except Element, Root, and PI. - /// - public string BaseUri - { - get { return _info.BaseUri; } - } - - /// - /// Returns this node's source line number. - /// - public int LineNumber - { - get { return _info.LineNumberBase + (int)((_props & LineNumberMask) >> LineNumberShift); } - } - - /// - /// Return this node's source line position. - /// - public int LinePosition - { - get { return _info.LinePositionBase + (int)_posOffset; } - } - - /// - /// If this node is an element with collapsed text, then return the source line position of the node (the - /// source line number is the same as LineNumber). - /// - public int CollapsedLinePosition - { - get - { - Debug.Assert(HasCollapsedText, "Do not call CollapsedLinePosition unless HasCollapsedText is true."); - return LinePosition + (int)(_props >> CollapsedPositionShift); - } - } - - /// - /// Returns information about the node page. Only the 0th node on each page has this property defined. - /// - public XPathNodePageInfo PageInfo - { - get { return _info.PageInfo; } - } - - /// - /// Returns the root node of the current document. This always succeeds. - /// - public int GetRoot(out XPathNode[] pageNode) - { - return _info.Document.GetRootNode(out pageNode); - } - - /// - /// Returns the parent of this node. If this node has no parent, then 0 is returned. - /// - public int GetParent(out XPathNode[] pageNode) - { - pageNode = _info.ParentPage; - return _idxParent; - } - - /// - /// Returns the next sibling of this node. If this node has no next sibling, then 0 is returned. - /// - public int GetSibling(out XPathNode[] pageNode) - { - pageNode = _info.SiblingPage; - return _idxSibling; - } - - /// - /// Returns the next element in document order that has the same local name hashcode as this element. - /// If there are no similar elements, then 0 is returned. - /// - public int GetSimilarElement(out XPathNode[] pageNode) - { - pageNode = _info.SimilarElementPage; - return _idxSimilar; - } - - /// - /// Returns true if this node's name matches the specified localName and namespaceName. Assume - /// that localName has been atomized, but namespaceName has not. - /// - public bool NameMatch(string localName, string namespaceName) - { - Debug.Assert(localName == null || (object)Document.NameTable.Get(localName) == (object)localName, "localName must be atomized."); - - return (object)_info.LocalName == (object)localName && - _info.NamespaceUri == namespaceName; - } - - /// - /// Returns true if this is an Element node with a name that matches the specified localName and - /// namespaceName. Assume that localName has been atomized, but namespaceName has not. - /// - public bool ElementMatch(string localName, string namespaceName) - { - Debug.Assert(localName == null || (object)Document.NameTable.Get(localName) == (object)localName, "localName must be atomized."); - - return NodeType == XPathNodeType.Element && - (object)_info.LocalName == (object)localName && - _info.NamespaceUri == namespaceName; - } - - /// - /// Return true if this node is an xmlns:xml node. - /// - public bool IsXmlNamespaceNode - { - get - { - string localName = _info.LocalName; - return NodeType == XPathNodeType.Namespace && localName.Length == 3 && localName == "xml"; - } - } - - /// - /// Returns true if this node has a sibling. - /// - public bool HasSibling - { - get { return _idxSibling != 0; } - } - - /// - /// Returns true if this node has a collapsed text node as its only content-typed child. - /// - public bool HasCollapsedText - { - get { return (_props & HasCollapsedTextBit) != 0; } - } - - /// - /// Returns true if this node has at least one attribute. - /// - public bool HasAttribute - { - get { return (_props & HasAttributeBit) != 0; } - } - - /// - /// Returns true if this node has at least one content-typed child (attributes and namespaces - /// don't count). - /// - public bool HasContentChild - { - get { return (_props & HasContentChildBit) != 0; } - } - - /// - /// Returns true if this node has at least one element child. - /// - public bool HasElementChild - { - get { return (_props & HasElementChildBit) != 0; } - } - - /// - /// Returns true if this is an attribute or namespace node. - /// - public bool IsAttrNmsp - { - get - { - XPathNodeType xptyp = NodeType; - return xptyp == XPathNodeType.Attribute || xptyp == XPathNodeType.Namespace; - } - } - - /// - /// Returns true if this is a text or whitespace node. - /// - public bool IsText - { - get { return XPathNavigator.IsText(NodeType); } - } - - /// - /// Returns true if this node has local namespace declarations associated with it. Since all - /// namespace declarations are stored out-of-line in the owner Document, this property - /// can be consulted in order to avoid a lookup in the common case where this node has no - /// local namespace declarations. - /// - public bool HasNamespaceDecls - { - get { return (_props & HasNmspDeclsBit) != 0; } - set - { - if (value) _props |= HasNmspDeclsBit; - else unchecked { _props &= (byte)~((uint)HasNmspDeclsBit); } - } - } - - /// - /// Returns true if this node is an empty element that allows shortcut tag syntax. - /// - public bool AllowShortcutTag - { - get { return (_props & AllowShortcutTagBit) != 0; } - } - - /// - /// Cached hashcode computed over the local name of this element. - /// - public int LocalNameHashCode - { - get { return _info.LocalNameHashCode; } - } - - /// - /// Return the precomputed String value of this node (null if no value exists, i.e. document node, element node with complex content, etc). - /// - public string Value - { - get { return _value; } - } - - - //----------------------------------------------- - // Node construction - //----------------------------------------------- - - /// - /// Constructs the 0th XPathNode in each page, which contains only page information. - /// - public void Create(XPathNodePageInfo pageInfo) - { - _info = new XPathNodeInfoAtom(pageInfo); - } - - /// - /// Constructs a XPathNode. Later, the idxSibling and value fields may be fixed up. - /// - public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) - { - Debug.Assert(info != null && idxParent <= UInt16.MaxValue); - _info = info; - _props = (uint)xptyp; - _idxParent = (ushort)idxParent; - } - - /// - /// Set this node's line number information. - /// - public void SetLineInfoOffsets(int lineNumOffset, int linePosOffset) - { - Debug.Assert(lineNumOffset >= 0 && lineNumOffset <= MaxLineNumberOffset, "Line number offset too large or small: " + lineNumOffset); - Debug.Assert(linePosOffset >= 0 && linePosOffset <= MaxLinePositionOffset, "Line position offset too large or small: " + linePosOffset); - _props |= ((uint)lineNumOffset << LineNumberShift); - _posOffset = (ushort)linePosOffset; - } - - /// - /// Set the position offset of this element's collapsed text. - /// - public void SetCollapsedLineInfoOffset(int posOffset) - { - Debug.Assert(posOffset >= 0 && posOffset <= MaxCollapsedPositionOffset, "Collapsed text line position offset too large or small: " + posOffset); - _props |= ((uint)posOffset << CollapsedPositionShift); - } - - /// - /// Set this node's value. - /// - public void SetValue(string value) - { - _value = value; - } - - /// - /// Create an empty element value. - /// - public void SetEmptyValue(bool allowShortcutTag) - { - Debug.Assert(NodeType == XPathNodeType.Element); - _value = string.Empty; - if (allowShortcutTag) - _props |= AllowShortcutTagBit; - } - - /// - /// Create a collapsed text node on this element having the specified value. - /// - public void SetCollapsedValue(string value) - { - Debug.Assert(NodeType == XPathNodeType.Element); - _value = value; - _props |= HasContentChildBit | HasCollapsedTextBit; - } - - /// - /// This method is called when a new child is appended to this node's list of attributes and children. - /// The type of the new child is used to determine how various parent properties should be set. - /// - public void SetParentProperties(XPathNodeType xptyp) - { - if (xptyp == XPathNodeType.Attribute) - { - _props |= HasAttributeBit; - } - else - { - _props |= HasContentChildBit; - if (xptyp == XPathNodeType.Element) - _props |= HasElementChildBit; - } - } - - /// - /// Link this node to its next sibling. If "pageSibling" is different than the one stored in the InfoAtom, re-atomize. - /// - public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling) - { - Debug.Assert(pageSibling != null && idxSibling != 0 && idxSibling <= UInt16.MaxValue, "Bad argument"); - Debug.Assert(_idxSibling == 0, "SetSibling should not be called more than once."); - _idxSibling = (ushort)idxSibling; - - if (pageSibling != _info.SiblingPage) - { - // Re-atomize the InfoAtom - _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, - _info.ParentPage, pageSibling, _info.SimilarElementPage, - _info.Document, _info.LineNumberBase, _info.LinePositionBase); - } - } - - /// - /// Link this element to the next element in document order that shares a local name having the same hash code. - /// If "pageSimilar" is different than the one stored in the InfoAtom, re-atomize. - /// - public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) - { - Debug.Assert(pageSimilar != null && idxSimilar != 0 && idxSimilar <= UInt16.MaxValue, "Bad argument"); - Debug.Assert(_idxSimilar == 0, "SetSimilarElement should not be called more than once."); - _idxSimilar = (ushort)idxSimilar; - - if (pageSimilar != _info.SimilarElementPage) - { - // Re-atomize the InfoAtom - _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, - _info.ParentPage, _info.SiblingPage, pageSimilar, - _info.Document, _info.LineNumberBase, _info.LinePositionBase); - } - } - } - - - /// - /// A reference to a XPathNode is composed of two values: the page on which the node is located, and the node's - /// index in the page. - /// - internal struct XPathNodeRef - { - private XPathNode[] _page; - private int _idx; - - public static XPathNodeRef Null - { - get { return new XPathNodeRef(); } - } - - public XPathNodeRef(XPathNode[] page, int idx) - { - _page = page; - _idx = idx; - } - - public bool IsNull - { - get { return _page == null; } - } - - public XPathNode[] Page - { - get { return _page; } - } - - public int Index - { - get { return _idx; } - } - - public override int GetHashCode() - { - return XPathNodeHelper.GetLocation(_page, _idx); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeHelper.cs deleted file mode 100644 index 7ee98b29056..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeHelper.cs +++ /dev/null @@ -1,762 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; - -namespace MS.Internal.Xml.Cache -{ - /// - /// Library of XPathNode helper routines. - /// - internal abstract class XPathNodeHelper - { - /// - /// Return chain of namespace nodes. If specified node has no local namespaces, then 0 will be - /// returned. Otherwise, the first node in the chain is guaranteed to be a local namespace (its - /// parent is this node). Subsequent nodes may not have the same node as parent, so the caller will - /// need to test the parent in order to terminate a search that processes only local namespaces. - /// - public static int GetLocalNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) - { - if (pageElem[idxElem].HasNamespaceDecls) - { - // Only elements have namespace nodes - Debug.Assert(pageElem[idxElem].NodeType == XPathNodeType.Element); - return pageElem[idxElem].Document.LookupNamespaces(pageElem, idxElem, out pageNmsp); - } - pageNmsp = null; - return 0; - } - - /// - /// Return chain of in-scope namespace nodes for nodes of type Element. Nodes in the chain might not - /// have this element as their parent. Since the xmlns:xml namespace node is always in scope, this - /// method will never return 0 if the specified node is an element. - /// - public static int GetInScopeNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) - { - XPathDocument doc; - - // Only elements have namespace nodes - if (pageElem[idxElem].NodeType == XPathNodeType.Element) - { - doc = pageElem[idxElem].Document; - - // Walk ancestors, looking for an ancestor that has at least one namespace declaration - while (!pageElem[idxElem].HasNamespaceDecls) - { - idxElem = pageElem[idxElem].GetParent(out pageElem); - if (idxElem == 0) - { - // There are no namespace nodes declared on ancestors, so return xmlns:xml node - return doc.GetXmlNamespaceNode(out pageNmsp); - } - } - // Return chain of in-scope namespace nodes - return doc.LookupNamespaces(pageElem, idxElem, out pageNmsp); - } - pageNmsp = null; - return 0; - } - - /// - /// Return the first attribute of the specified node. If no attribute exist, do not - /// set pageNode or idxNode and return false. - /// - public static bool GetFirstAttribute(ref XPathNode[] pageNode, ref int idxNode) - { - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - if (pageNode[idxNode].HasAttribute) - { - GetChild(ref pageNode, ref idxNode); - Debug.Assert(pageNode[idxNode].NodeType == XPathNodeType.Attribute); - return true; - } - return false; - } - - /// - /// Return the next attribute sibling of the specified node. If the node is not itself an - /// attribute, or if there are no siblings, then do not set pageNode or idxNode and return false. - /// - public static bool GetNextAttribute(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page; - int idx; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - idx = pageNode[idxNode].GetSibling(out page); - if (idx != 0 && page[idx].NodeType == XPathNodeType.Attribute) - { - pageNode = page; - idxNode = idx; - return true; - } - return false; - } - - /// - /// Return the first content-typed child of the specified node. If the node has no children, or - /// if the node is not content-typed, then do not set pageNode or idxNode and return false. - /// - public static bool GetContentChild(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - if (page[idx].HasContentChild) - { - GetChild(ref page, ref idx); - - // Skip past attribute children - while (page[idx].NodeType == XPathNodeType.Attribute) - { - idx = page[idx].GetSibling(out page); - Debug.Assert(idx != 0); - } - - pageNode = page; - idxNode = idx; - return true; - } - return false; - } - - /// - /// Return the next content-typed sibling of the specified node. If the node has no siblings, or - /// if the node is not content-typed, then do not set pageNode or idxNode and return false. - /// - public static bool GetContentSibling(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - if (!page[idx].IsAttrNmsp) - { - idx = page[idx].GetSibling(out page); - if (idx != 0) - { - pageNode = page; - idxNode = idx; - return true; - } - } - return false; - } - - /// - /// Return the parent of the specified node. If the node has no parent, do not set pageNode - /// or idxNode and return false. - /// - public static bool GetParent(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - idx = page[idx].GetParent(out page); - if (idx != 0) - { - pageNode = page; - idxNode = idx; - return true; - } - return false; - } - - /// - /// Return a location integer that can be easily compared with other locations from the same document - /// in order to determine the relative document order of two nodes. - /// - public static int GetLocation(XPathNode[] pageNode, int idxNode) - { - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - Debug.Assert(idxNode <= UInt16.MaxValue); - Debug.Assert(pageNode[0].PageInfo.PageNumber <= Int16.MaxValue); - return (pageNode[0].PageInfo.PageNumber << 16) | idxNode; - } - - /// - /// Return the first element child of the specified node that has the specified name. If no such child exists, - /// then do not set pageNode or idxNode and return false. Assume that the localName has been atomized with respect - /// to this document's name table, but not the namespaceName. - /// - public static bool GetElementChild(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - // Only check children if at least one element child exists - if (page[idx].HasElementChild) - { - GetChild(ref page, ref idx); - Debug.Assert(idx != 0); - - // Find element with specified localName and namespaceName - do - { - if (page[idx].ElementMatch(localName, namespaceName)) - { - pageNode = page; - idxNode = idx; - return true; - } - idx = page[idx].GetSibling(out page); - } - while (idx != 0); - } - return false; - } - - /// - /// Return a following sibling element of the specified node that has the specified name. If no such - /// sibling exists, or if the node is not content-typed, then do not set pageNode or idxNode and - /// return false. Assume that the localName has been atomized with respect to this document's name table, - /// but not the namespaceName. - /// - public static bool GetElementSibling(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - // Elements should not be returned as "siblings" of attributes (namespaces don't link to elements, so don't need to check them) - if (page[idx].NodeType != XPathNodeType.Attribute) - { - while (true) - { - idx = page[idx].GetSibling(out page); - - if (idx == 0) - break; - - if (page[idx].ElementMatch(localName, namespaceName)) - { - pageNode = page; - idxNode = idx; - return true; - } - } - } - - return false; - } - - /// - /// Return the first child of the specified node that has the specified type (must be a content type). If no such - /// child exists, then do not set pageNode or idxNode and return false. - /// - public static bool GetContentChild(ref XPathNode[] pageNode, ref int idxNode, XPathNodeType typ) - { - XPathNode[] page = pageNode; - int idx = idxNode; - int mask; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - // Only check children if at least one content-typed child exists - if (page[idx].HasContentChild) - { - mask = XPathNavigator.GetContentKindMask(typ); - - GetChild(ref page, ref idx); - do - { - if (((1 << (int)page[idx].NodeType) & mask) != 0) - { - // Never return attributes, as Attribute is not a content type - if (typ == XPathNodeType.Attribute) - return false; - - pageNode = page; - idxNode = idx; - return true; - } - - idx = page[idx].GetSibling(out page); - } - while (idx != 0); - } - - return false; - } - - /// - /// Return a following sibling of the specified node that has the specified type. If no such - /// sibling exists, then do not set pageNode or idxNode and return false. - /// - public static bool GetContentSibling(ref XPathNode[] pageNode, ref int idxNode, XPathNodeType typ) - { - XPathNode[] page = pageNode; - int idx = idxNode; - int mask = XPathNavigator.GetContentKindMask(typ); - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - if (page[idx].NodeType != XPathNodeType.Attribute) - { - while (true) - { - idx = page[idx].GetSibling(out page); - - if (idx == 0) - break; - - if (((1 << (int)page[idx].NodeType) & mask) != 0) - { - Debug.Assert(typ != XPathNodeType.Attribute && typ != XPathNodeType.Namespace); - pageNode = page; - idxNode = idx; - return true; - } - } - } - - return false; - } - - /// - /// Return the first preceding sibling of the specified node. If no such sibling exists, then do not set - /// pageNode or idxNode and return false. - /// - public static bool GetPreviousContentSibling(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] pageParent = pageNode, pagePrec, pageAnc; - int idxParent = idxNode, idxPrec, idxAnc; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - Debug.Assert(pageNode[idxNode].NodeType != XPathNodeType.Attribute); - - // Since nodes are laid out in document order on pages, the algorithm is: - // 1. Get parent of current node - // 2. If no parent, then there is no previous sibling, so return false - // 3. Get node that immediately precedes the current node in document order - // 4. If preceding node is parent, then there is no previous sibling, so return false - // 5. Walk ancestors of preceding node, until parent of current node is found - idxParent = pageParent[idxParent].GetParent(out pageParent); - if (idxParent != 0) - { - idxPrec = idxNode - 1; - if (idxPrec == 0) - { - // Need to get previous page - pagePrec = pageNode[0].PageInfo.PreviousPage; - idxPrec = pagePrec.Length - 1; - } - else - { - // Previous node is on the same page - pagePrec = pageNode; - } - - // If parent node is previous node, then no previous sibling - if (idxParent == idxPrec && pageParent == pagePrec) - return false; - - // Find child of parent node by walking ancestor chain - pageAnc = pagePrec; - idxAnc = idxPrec; - do - { - pagePrec = pageAnc; - idxPrec = idxAnc; - idxAnc = pageAnc[idxAnc].GetParent(out pageAnc); - Debug.Assert(idxAnc != 0 && pageAnc != null); - } - while (idxAnc != idxParent || pageAnc != pageParent); - - // We found the previous sibling, but if it's an attribute node, then return false - if (pagePrec[idxPrec].NodeType != XPathNodeType.Attribute) - { - pageNode = pagePrec; - idxNode = idxPrec; - return true; - } - } - - return false; - } - - /// - /// Return a previous sibling element of the specified node that has the specified name. If no such - /// sibling exists, or if the node is not content-typed, then do not set pageNode or idxNode and - /// return false. Assume that the localName has been atomized with respect to this document's name table, - /// but not the namespaceName. - /// - public static bool GetPreviousElementSibling(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - if (page[idx].NodeType != XPathNodeType.Attribute) - { - while (true) - { - if (!GetPreviousContentSibling(ref page, ref idx)) - break; - - if (page[idx].ElementMatch(localName, namespaceName)) - { - pageNode = page; - idxNode = idx; - return true; - } - } - } - - return false; - } - - /// - /// Return a previous sibling of the specified node that has the specified type. If no such - /// sibling exists, then do not set pageNode or idxNode and return false. - /// - public static bool GetPreviousContentSibling(ref XPathNode[] pageNode, ref int idxNode, XPathNodeType typ) - { - XPathNode[] page = pageNode; - int idx = idxNode; - int mask = XPathNavigator.GetContentKindMask(typ); - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - while (true) - { - if (!GetPreviousContentSibling(ref page, ref idx)) - break; - - if (((1 << (int)page[idx].NodeType) & mask) != 0) - { - pageNode = page; - idxNode = idx; - return true; - } - } - - return false; - } - - /// - /// Return the attribute of the specified node that has the specified name. If no such attribute exists, - /// then do not set pageNode or idxNode and return false. Assume that the localName has been atomized with respect - /// to this document's name table, but not the namespaceName. - /// - public static bool GetAttribute(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName) - { - XPathNode[] page = pageNode; - int idx = idxNode; - Debug.Assert(pageNode != null && idxNode != 0, "Cannot pass null argument(s)"); - - // Find attribute with specified localName and namespaceName - if (page[idx].HasAttribute) - { - GetChild(ref page, ref idx); - do - { - if (page[idx].NameMatch(localName, namespaceName)) - { - pageNode = page; - idxNode = idx; - return true; - } - idx = page[idx].GetSibling(out page); - } - while (idx != 0 && page[idx].NodeType == XPathNodeType.Attribute); - } - - return false; - } - - /// - /// Get the next non-virtual (not collapsed text, not namespaces) node that follows the specified node in document order. - /// If no such node exists, then do not set pageNode or idxNode and return false. - /// - public static bool GetFollowing(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page = pageNode; - int idx = idxNode; - - do - { - // Next non-virtual node is in next slot within the page - if (++idx < page[0].PageInfo.NodeCount) - { - pageNode = page; - idxNode = idx; - return true; - } - - // Otherwise, start at the beginning of the next page - page = page[0].PageInfo.NextPage; - idx = 0; - } - while (page != null); - - return false; - } - - /// - /// Get the next element node that: - /// 1. Follows the current node in document order (includes descendants, unlike XPath following axis) - /// 2. Precedes the ending node in document order (if pageEnd is null, then all following nodes in the document are considered) - /// 3. Has the specified QName - /// If no such element exists, then do not set pageCurrent or idxCurrent and return false. - /// Assume that the localName has been atomized with respect to this document's name table, but not the namespaceName. - /// - public static bool GetElementFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd, string localName, string namespaceName) - { - XPathNode[] page = pageCurrent; - int idx = idxCurrent; - Debug.Assert(pageCurrent != null && idxCurrent != 0, "Cannot pass null argument(s)"); - - // If current node is an element having a matching name, - if (page[idx].NodeType == XPathNodeType.Element && (object)page[idx].LocalName == (object)localName) - { - // Then follow similar element name pointers - int idxPageEnd = 0; - int idxPageCurrent; - - if (pageEnd != null) - { - idxPageEnd = pageEnd[0].PageInfo.PageNumber; - idxPageCurrent = page[0].PageInfo.PageNumber; - - // If ending node is <= starting node in document order, then scan to end of document - if (idxPageCurrent > idxPageEnd || (idxPageCurrent == idxPageEnd && idx >= idxEnd)) - pageEnd = null; - } - - while (true) - { - idx = page[idx].GetSimilarElement(out page); - - if (idx == 0) - break; - - // Only scan to ending node - if (pageEnd != null) - { - idxPageCurrent = page[0].PageInfo.PageNumber; - if (idxPageCurrent > idxPageEnd) - break; - - if (idxPageCurrent == idxPageEnd && idx >= idxEnd) - break; - } - - if ((object)page[idx].LocalName == (object)localName && page[idx].NamespaceUri == namespaceName) - goto FoundNode; - } - - return false; - } - - // Since nodes are laid out in document order on pages, scan them sequentially - // rather than following links. - idx++; - do - { - if ((object)page == (object)pageEnd && idx <= idxEnd) - { - // Only scan to termination point - while (idx != idxEnd) - { - if (page[idx].ElementMatch(localName, namespaceName)) - goto FoundNode; - idx++; - } - break; - } - else - { - // Scan all nodes in the page - while (idx < page[0].PageInfo.NodeCount) - { - if (page[idx].ElementMatch(localName, namespaceName)) - goto FoundNode; - idx++; - } - } - - page = page[0].PageInfo.NextPage; - idx = 1; - } - while (page != null); - - return false; - - FoundNode: - // Found match - pageCurrent = page; - idxCurrent = idx; - return true; - } - - /// - /// Get the next node that: - /// 1. Follows the current node in document order (includes descendants, unlike XPath following axis) - /// 2. Precedes the ending node in document order (if pageEnd is null, then all following nodes in the document are considered) - /// 3. Has the specified XPathNodeType (but Attributes and Namespaces never match) - /// If no such node exists, then do not set pageCurrent or idxCurrent and return false. - /// - public static bool GetContentFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd, XPathNodeType typ) - { - XPathNode[] page = pageCurrent; - int idx = idxCurrent; - int mask = XPathNavigator.GetContentKindMask(typ); - Debug.Assert(pageCurrent != null && idxCurrent != 0, "Cannot pass null argument(s)"); - Debug.Assert(typ != XPathNodeType.Text, "Text should be handled by GetTextFollowing in order to take into account collapsed text."); - Debug.Assert(page[idx].NodeType != XPathNodeType.Attribute, "Current node should never be an attribute or namespace--caller should handle this case."); - - // Since nodes are laid out in document order on pages, scan them sequentially - // rather than following sibling/child/parent links. - idx++; - do - { - if ((object)page == (object)pageEnd && idx <= idxEnd) - { - // Only scan to termination point - while (idx != idxEnd) - { - if (((1 << (int)page[idx].NodeType) & mask) != 0) - goto FoundNode; - idx++; - } - break; - } - else - { - // Scan all nodes in the page - while (idx < page[0].PageInfo.NodeCount) - { - if (((1 << (int)page[idx].NodeType) & mask) != 0) - goto FoundNode; - idx++; - } - } - - page = page[0].PageInfo.NextPage; - idx = 1; - } - while (page != null); - - return false; - - FoundNode: - Debug.Assert(!page[idx].IsAttrNmsp, "GetContentFollowing should never return attributes or namespaces."); - - // Found match - pageCurrent = page; - idxCurrent = idx; - return true; - } - - /// - /// Scan all nodes that follow the current node in document order, but precede the ending node in document order. - /// Return two types of nodes with non-null text: - /// 1. Element parents of collapsed text nodes (since it is the element parent that has the collapsed text) - /// 2. Non-collapsed text nodes - /// If no such node exists, then do not set pageCurrent or idxCurrent and return false. - /// - public static bool GetTextFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd) - { - XPathNode[] page = pageCurrent; - int idx = idxCurrent; - Debug.Assert(pageCurrent != null && idxCurrent != 0, "Cannot pass null argument(s)"); - Debug.Assert(!page[idx].IsAttrNmsp, "Current node should never be an attribute or namespace--caller should handle this case."); - - // Since nodes are laid out in document order on pages, scan them sequentially - // rather than following sibling/child/parent links. - idx++; - do - { - if ((object)page == (object)pageEnd && idx <= idxEnd) - { - // Only scan to termination point - while (idx != idxEnd) - { - if (page[idx].IsText || (page[idx].NodeType == XPathNodeType.Element && page[idx].HasCollapsedText)) - goto FoundNode; - idx++; - } - break; - } - else - { - // Scan all nodes in the page - while (idx < page[0].PageInfo.NodeCount) - { - if (page[idx].IsText || (page[idx].NodeType == XPathNodeType.Element && page[idx].HasCollapsedText)) - goto FoundNode; - idx++; - } - } - - page = page[0].PageInfo.NextPage; - idx = 1; - } - while (page != null); - - return false; - - FoundNode: - // Found match - pageCurrent = page; - idxCurrent = idx; - return true; - } - - /// - /// Get the next non-virtual (not collapsed text, not namespaces) node that follows the specified node in document order, - /// but is not a descendant. If no such node exists, then do not set pageNode or idxNode and return false. - /// - public static bool GetNonDescendant(ref XPathNode[] pageNode, ref int idxNode) - { - XPathNode[] page = pageNode; - int idx = idxNode; - - // Get page, idx at which to end sequential scan of nodes - do - { - // If the current node has a sibling, - if (page[idx].HasSibling) - { - // Then that is the first non-descendant - pageNode = page; - idxNode = page[idx].GetSibling(out pageNode); - return true; - } - - // Otherwise, try finding a sibling at the parent level - idx = page[idx].GetParent(out page); - } - while (idx != 0); - - return false; - } - - /// - /// Return the page and index of the first child (attribute or content) of the specified node. - /// - private static void GetChild(ref XPathNode[] pageNode, ref int idxNode) - { - Debug.Assert(pageNode[idxNode].HasAttribute || pageNode[idxNode].HasContentChild, "Caller must check HasAttribute/HasContentChild on parent before calling GetChild."); - Debug.Assert(pageNode[idxNode].HasAttribute || !pageNode[idxNode].HasCollapsedText, "Text child is virtualized and therefore is not present in the physical node page."); - - if (++idxNode >= pageNode.Length) - { - // Child is first node on next page - pageNode = pageNode[0].PageInfo.NextPage; - idxNode = 1; - } - // Else child is next node on this page - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeInfoAtom.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeInfoAtom.cs deleted file mode 100644 index 02fb870c9a6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeInfoAtom.cs +++ /dev/null @@ -1,515 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; - -namespace MS.Internal.Xml.Cache -{ - /// - /// The 0th node in each page contains a non-null reference to an XPathNodePageInfo internal class that provides - /// information about that node's page. The other fields in the 0th node are undefined and should never - /// be used. - /// - sealed internal class XPathNodePageInfo - { - private int _pageNum; - private int _nodeCount; - private XPathNode[] _pagePrev; - private XPathNode[] _pageNext; - - /// - /// Constructor. - /// - public XPathNodePageInfo(XPathNode[] pagePrev, int pageNum) - { - _pagePrev = pagePrev; - _pageNum = pageNum; - _nodeCount = 1; // Every node page contains PageInfo at 0th position - } - - /// - /// Return the sequential page number of the page containing nodes that share this information atom. - /// - public int PageNumber - { - get { return _pageNum; } - } - - /// - /// Return the number of nodes allocated in this page. - /// - public int NodeCount - { - get { return _nodeCount; } - set { _nodeCount = value; } - } - - /// - /// Return the previous node page in the document. - /// - public XPathNode[] PreviousPage - { - get { return _pagePrev; } - } - - /// - /// Return the next node page in the document. - /// - public XPathNode[] NextPage - { - get { return _pageNext; } - set { _pageNext = value; } - } - } - - - /// - /// There is a great deal of redundancy in typical Xml documents. Even in documents with thousands or millions - /// of nodes, there are a small number of common names and types. And since nodes are allocated in pages in - /// document order, nodes on the same page with the same name and type are likely to have the same sibling and - /// parent pages as well. - /// Redundant information is shared by creating immutable, atomized objects. This is analogous to the - /// string.Intern() operation. If a node's name, type, or parent/sibling pages are modified, then a new - /// InfoAtom needs to be obtained, since other nodes may still be referencing the old InfoAtom. - /// - sealed internal class XPathNodeInfoAtom - { - private string _localName; - private string _namespaceUri; - private string _prefix; - private string _baseUri; - private XPathNode[] _pageParent; - private XPathNode[] _pageSibling; - private XPathNode[] _pageSimilar; - private XPathDocument _doc; - private int _lineNumBase; - private int _linePosBase; - private int _hashCode; - private int _localNameHash; - private XPathNodeInfoAtom _next; - private XPathNodePageInfo _pageInfo; - - - /// - /// Construct information for the 0th node in each page. The only field which is defined is this.pageInfo, - /// and it contains information about that page (pageNum, nextPage, etc.). - /// - public XPathNodeInfoAtom(XPathNodePageInfo pageInfo) - { - _pageInfo = pageInfo; - } - - /// - /// Construct a new shared information atom. This method should only be used by the XNodeInfoTable. - /// - public XPathNodeInfoAtom(string localName, string namespaceUri, string prefix, string baseUri, - XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, - XPathDocument doc, int lineNumBase, int linePosBase) - { - Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); - } - - /// - /// Initialize an existing shared information atom. This method should only be used by the XNodeInfoTable. - /// - public void Init(string localName, string namespaceUri, string prefix, string baseUri, - XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, - XPathDocument doc, int lineNumBase, int linePosBase) - { - Debug.Assert(localName != null && namespaceUri != null && prefix != null && doc != null); - - _localName = localName; - _namespaceUri = namespaceUri; - _prefix = prefix; - _baseUri = baseUri; - _pageParent = pageParent; - _pageSibling = pageSibling; - _pageSimilar = pageSimilar; - _doc = doc; - _lineNumBase = lineNumBase; - _linePosBase = linePosBase; - _next = null; - _pageInfo = null; - - _hashCode = 0; - _localNameHash = 0; - for (int i = 0; i < _localName.Length; i++) - _localNameHash += (_localNameHash << 7) ^ _localName[i]; - } - - /// - /// Returns information about the node page. Only the 0th node on each page has this property defined. - /// - public XPathNodePageInfo PageInfo - { - get { return _pageInfo; } - } - - /// - /// Return the local name part of nodes that share this information atom. - /// - public string LocalName - { - get { return _localName; } - } - - /// - /// Return the namespace name part of nodes that share this information atom. - /// - public string NamespaceUri - { - get { return _namespaceUri; } - } - - /// - /// Return the prefix name part of nodes that share this information atom. - /// - public string Prefix - { - get { return _prefix; } - } - - /// - /// Return the base Uri of nodes that share this information atom. - /// - public string BaseUri - { - get { return _baseUri; } - } - - /// - /// Return the page containing the next sibling of nodes that share this information atom. - /// - public XPathNode[] SiblingPage - { - get { return _pageSibling; } - } - - /// - /// Return the page containing the next element having a name which has same hashcode as this element. - /// - public XPathNode[] SimilarElementPage - { - get { return _pageSimilar; } - } - - /// - /// Return the page containing the parent of nodes that share this information atom. - /// - public XPathNode[] ParentPage - { - get { return _pageParent; } - } - - /// - /// Return the page containing the owner document of nodes that share this information atom. - /// - public XPathDocument Document - { - get { return _doc; } - } - - /// - /// Return the line number to which a line number offset stored in the XPathNode is added. - /// - public int LineNumberBase - { - get { return _lineNumBase; } - } - - /// - /// Return the line position to which a line position offset stored in the XPathNode is added. - /// - public int LinePositionBase - { - get { return _linePosBase; } - } - - /// - /// Return cached hash code of the local name of nodes which share this information atom. - /// - public int LocalNameHashCode - { - get { return _localNameHash; } - } - - /// - /// Link together InfoAtoms that hash to the same hashtable bucket (should only be used by XPathNodeInfoTable) - /// - public XPathNodeInfoAtom Next - { - get { return _next; } - set { _next = value; } - } - - /// - /// Return this information atom's hash code, previously computed for performance. - /// - public override int GetHashCode() - { - if (_hashCode == 0) - { - int hashCode; - - // Start with local name - hashCode = _localNameHash; - - // Add page indexes - if (_pageSibling != null) - hashCode += (hashCode << 7) ^ _pageSibling[0].PageInfo.PageNumber; - - if (_pageParent != null) - hashCode += (hashCode << 7) ^ _pageParent[0].PageInfo.PageNumber; - - if (_pageSimilar != null) - hashCode += (hashCode << 7) ^ _pageSimilar[0].PageInfo.PageNumber; - - // Save hashcode. Don't save 0, so that it won't ever be recomputed. - _hashCode = ((hashCode == 0) ? 1 : hashCode); - } - - return _hashCode; - } - - /// - /// Return true if this InfoAtom has the same values as another InfoAtom. - /// - public override bool Equals(object other) - { - XPathNodeInfoAtom that = other as XPathNodeInfoAtom; - Debug.Assert(that != null); - Debug.Assert((object)_doc == (object)that._doc); - Debug.Assert(_pageInfo == null); - - // Assume that name parts are atomized - if (this.GetHashCode() == that.GetHashCode()) - { - if ((object)_localName == (object)that._localName && - (object)_pageSibling == (object)that._pageSibling && - (object)_namespaceUri == (object)that._namespaceUri && - (object)_pageParent == (object)that._pageParent && - (object)_pageSimilar == (object)that._pageSimilar && - (object)_prefix == (object)that._prefix && - (object)_baseUri == (object)that._baseUri && - _lineNumBase == that._lineNumBase && - _linePosBase == that._linePosBase) - { - return true; - } - } - return false; - } - - /// - /// Return InfoAtom formatted as a string: - /// hash=xxx, {http://my.com}foo:bar, parent=1, sibling=1, lineNum=0, linePos=0 - /// - public override string ToString() - { - StringBuilder bldr = new StringBuilder(); - - bldr.Append("hash="); - bldr.Append(GetHashCode()); - bldr.Append(", "); - - if (_localName.Length != 0) - { - bldr.Append('{'); - bldr.Append(_namespaceUri); - bldr.Append('}'); - - if (_prefix.Length != 0) - { - bldr.Append(_prefix); - bldr.Append(':'); - } - - bldr.Append(_localName); - bldr.Append(", "); - } - - if (_pageParent != null) - { - bldr.Append("parent="); - bldr.Append(_pageParent[0].PageInfo.PageNumber); - bldr.Append(", "); - } - - if (_pageSibling != null) - { - bldr.Append("sibling="); - bldr.Append(_pageSibling[0].PageInfo.PageNumber); - bldr.Append(", "); - } - - if (_pageSimilar != null) - { - bldr.Append("similar="); - bldr.Append(_pageSimilar[0].PageInfo.PageNumber); - bldr.Append(", "); - } - - bldr.Append("lineNum="); - bldr.Append(_lineNumBase); - bldr.Append(", "); - - bldr.Append("linePos="); - bldr.Append(_linePosBase); - - return bldr.ToString(); - } - } - - - /// - /// An atomization table for XPathNodeInfoAtom. - /// - sealed internal class XPathNodeInfoTable - { - private XPathNodeInfoAtom[] _hashTable; - private int _sizeTable; - private XPathNodeInfoAtom _infoCached; - -#if DEBUG - private const int DefaultTableSize = 2; -#else - private const int DefaultTableSize = 32; -#endif - - /// - /// Constructor. - /// - public XPathNodeInfoTable() - { - _hashTable = new XPathNodeInfoAtom[DefaultTableSize]; - _sizeTable = 0; - } - - /// - /// Create a new XNodeInfoAtom and ensure it is atomized in the table. - /// - public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, - XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, - XPathDocument doc, int lineNumBase, int linePosBase) - { - XPathNodeInfoAtom info; - - // If this.infoCached already exists, then reuse it; else create new InfoAtom - if (_infoCached == null) - { - info = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, - pageParent, pageSibling, pageSimilar, - doc, lineNumBase, linePosBase); - } - else - { - info = _infoCached; - _infoCached = info.Next; - - info.Init(localName, namespaceUri, prefix, baseUri, - pageParent, pageSibling, pageSimilar, - doc, lineNumBase, linePosBase); - } - - return Atomize(info); - } - - - /// - /// Add a shared information item to the atomization table. If a matching item already exists, then that - /// instance is returned. Otherwise, a new item is created. Thus, if itemX and itemY have both been added - /// to the same InfoTable: - /// 1. itemX.Equals(itemY) != true - /// 2. (object) itemX != (object) itemY - /// - private XPathNodeInfoAtom Atomize(XPathNodeInfoAtom info) - { - XPathNodeInfoAtom infoNew, infoNext; - - // Search for existing XNodeInfoAtom in the table - infoNew = _hashTable[info.GetHashCode() & (_hashTable.Length - 1)]; - while (infoNew != null) - { - if (info.Equals(infoNew)) - { - // Found existing atom, so return that. Reuse "info". - info.Next = _infoCached; - _infoCached = info; - return infoNew; - } - infoNew = infoNew.Next; - } - - // Expand table and rehash if necessary - if (_sizeTable >= _hashTable.Length) - { - XPathNodeInfoAtom[] oldTable = _hashTable; - _hashTable = new XPathNodeInfoAtom[oldTable.Length * 2]; - - for (int i = 0; i < oldTable.Length; i++) - { - infoNew = oldTable[i]; - while (infoNew != null) - { - infoNext = infoNew.Next; - AddInfo(infoNew); - infoNew = infoNext; - } - } - } - - // Can't find an existing XNodeInfoAtom, so use the one that was passed in - AddInfo(info); - - return info; - } - - /// - /// Add a previously constructed InfoAtom to the table. If a collision occurs, then insert "info" - /// as the head of a linked list. - /// - private void AddInfo(XPathNodeInfoAtom info) - { - int idx = info.GetHashCode() & (_hashTable.Length - 1); - info.Next = _hashTable[idx]; - _hashTable[idx] = info; - _sizeTable++; - } - - /// - /// Return InfoAtomTable formatted as a string. - /// - public override string ToString() - { - StringBuilder bldr = new StringBuilder(); - XPathNodeInfoAtom infoAtom; - - for (int i = 0; i < _hashTable.Length; i++) - { - bldr.AppendFormat("{0,4}: ", i); - - infoAtom = _hashTable[i]; - - while (infoAtom != null) - { - if ((object)infoAtom != (object)_hashTable[i]) - bldr.Append("\n "); - - bldr.Append(infoAtom); - - infoAtom = infoAtom.Next; - } - - bldr.Append('\n'); - } - - return bldr.ToString(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeView.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeView.cs deleted file mode 100644 index e6e19f5c916..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeView.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#if ENABLEDATABINDING -using System; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; - -namespace Microsoft.Xml.XPath.DataBinding -{ - public sealed class XPathNodeView : IXPathNavigable, ICustomTypeDescriptor, INotifyPropertyChanged { - XPathDocumentView collection; - XPathNode rowNd; - object[] cols; - - internal XPathNodeView(XPathDocumentView col, XPathNode rowNd, object[] columns) { - this.collection = col; - this.rowNd = rowNd; - this.cols = columns; - } - - // - // local methods - - public XPathDocumentView XPathDocumentView { - get { return this.collection; } - } - - public object this[string fieldname] { - get { - if (null == fieldname) - throw new ArgumentNullException("fieldname"); - int col = this.collection.RowShape.FindNamedSubShape(fieldname); - if (col == -1) - throw new ArgumentException("fieldname"); - Debug.Assert(col >= 0 && col < this.cols.Length); - return this.cols[col]; - } - set { - throw new NotSupportedException(); - } - } - - public object this[int fieldIndex] { - get { - if (fieldIndex < 0 || fieldIndex >= this.cols.Length) - throw new ArgumentOutOfRangeException("fieldIndex"); - return this.cols[fieldIndex]; - } - set { - throw new NotSupportedException(); - } - } - - // - // IXPathNavigable Implementation - - /// - public XPathNavigator CreateNavigator() { - XPathNode nd = this.rowNd; - if (null != nd) - return new XPathDocumentNavigator(this.rowNd, null); - return null; - } - - // - // ICustomTypeDescriptor Implementation - - /// - public AttributeCollection GetAttributes() { - return new AttributeCollection((Attribute[])null); - } - - /// - public String GetClassName() { - return collection.RowShape.Name; - } - - /// - public String GetComponentName() { - return null; - } - - /// - public TypeConverter GetConverter() { - return null; - } - - /// - public EventDescriptor GetDefaultEvent() { - return null; - } - - /// - public PropertyDescriptor GetDefaultProperty() { - return null; - } - - /// - public object GetEditor(Type editorBaseType) { - return null; - } - - /// - public EventDescriptorCollection GetEvents() { - return null; - } - - /// - public EventDescriptorCollection GetEvents(Attribute[] attributes) { - return null; - } - - /// - public object GetPropertyOwner(PropertyDescriptor pd) { - return null; - } - - /// - public PropertyDescriptorCollection GetProperties() { - return collection.GetItemProperties(null); - } - - /// - public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { - return collection.GetItemProperties(null); - } - - - // - // INotifyPropertyChanged Implementation - - /// - public event PropertyChangedEventHandler PropertyChanged { - add { - throw new NotSupportedException("INotifyPropertyChanged.PropertyChanged"); - } - remove { - throw new NotSupportedException("INotifyPropertyChanged.PropertyChanged"); - } - } - - // - // internal implementation - - // used by XPathNodeViewPropertyDescriptor to access values - internal XPathDocumentView Collection { get { return this.collection; } } - internal object Column(int index) { return cols[index]; } - } -} -#endif diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeViewPropertyDescriptor.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeViewPropertyDescriptor.cs deleted file mode 100644 index 49edad845f0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Cache/XPathNodeViewPropertyDescriptor.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#if ENABLEDATABINDING -using System; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; - -namespace Microsoft.Xml.XPath.DataBinding -{ - internal class XPathNodeViewPropertyDescriptor : PropertyDescriptor { - Shape rowShape; - Shape colShape; - int colIndex; - - internal XPathNodeViewPropertyDescriptor(Shape rowShape) - : base( rowShape.Name, null) { - this.rowShape = rowShape; - this.colShape = rowShape; - this.colIndex = 0; - } - - internal XPathNodeViewPropertyDescriptor(Shape rowShape, Shape colShape, int colIndex) - : base( colShape.Name, null) { - this.rowShape = rowShape; - this.colShape = colShape; - this.colIndex = colIndex; - } - - public Shape Shape { - get { return colShape; } - } - - public override Type ComponentType { - get { return null; } - } - - public override string Name { - get { return this.colShape.Name; } - } - - public override bool IsReadOnly { - get { return true; } - } - - public override Type PropertyType { - get { - return this.colShape.IsNestedTable - ? typeof(XPathDocumentView) - : typeof(string); - } - } - - public override bool CanResetValue(object o) { - return false; - } - - public override object GetValue(object o) { - if (null == o) - throw new ArgumentNullException("XPathNodeViewPropertyDescriptor.GetValue"); - XPathNodeView xiv = (XPathNodeView)o; - if (xiv.Collection.RowShape != this.rowShape) - throw new ArgumentException("XPathNodeViewPropertyDescriptor.GetValue"); - object val = xiv.Column(this.colIndex); - XPathNode nd = val as XPathNode; - if (null != nd) { - XPathDocumentNavigator nav = new XPathDocumentNavigator(nd, null); - XmlSchemaType xst = nd.SchemaType; - XmlSchemaComplexType xsct = xst as XmlSchemaComplexType; - if (null == xst || ( (null != xsct) && xsct.IsMixed) ) { - return nav.InnerXml; - } - else { - return nav.TypedValue; - } - } - return val; - } - - public override void ResetValue(object o) { - throw new NotImplementedException(); - } - - public override void SetValue(object o, object value) { - throw new NotImplementedException(); - } - - public override bool ShouldSerializeValue(object o) { - return false; - } - } -} -#endif diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/CharEntityEncoderFallback.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/CharEntityEncoderFallback.cs deleted file mode 100644 index 1172ebe21af..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/CharEntityEncoderFallback.cs +++ /dev/null @@ -1,219 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - // - // CharEntityEncoderFallback - // - - internal class CharEntityEncoderFallback : EncoderFallback - { - private CharEntityEncoderFallbackBuffer _fallbackBuffer; - - private int[] _textContentMarks; - private int _endMarkPos; - private int _curMarkPos; - private int _startOffset; - - internal CharEntityEncoderFallback() - { - } - - public override EncoderFallbackBuffer CreateFallbackBuffer() - { - if (_fallbackBuffer == null) - { - _fallbackBuffer = new CharEntityEncoderFallbackBuffer(this); - } - return _fallbackBuffer; - } - - public override int MaxCharCount - { - get - { - return 12; - } - } - - internal int StartOffset - { - get - { - return _startOffset; - } - set - { - _startOffset = value; - } - } - - internal void Reset(int[] textContentMarks, int endMarkPos) - { - _textContentMarks = textContentMarks; - _endMarkPos = endMarkPos; - _curMarkPos = 0; - } - - internal bool CanReplaceAt(int index) - { - int mPos = _curMarkPos; - int charPos = _startOffset + index; - while (mPos < _endMarkPos && charPos >= _textContentMarks[mPos + 1]) - { - mPos++; - } - _curMarkPos = mPos; - - return (mPos & 1) != 0; - } - } - - // - // CharEntityFallbackBuffer - // - internal class CharEntityEncoderFallbackBuffer : EncoderFallbackBuffer - { - private CharEntityEncoderFallback _parent; - - private string _charEntity = string.Empty; - private int _charEntityIndex = -1; - - internal CharEntityEncoderFallbackBuffer(CharEntityEncoderFallback parent) - { - _parent = parent; - } - - public override bool Fallback(char charUnknown, int index) - { - // If we are already in fallback, throw, it's probably at the suspect character in charEntity - if (_charEntityIndex >= 0) - { - (new EncoderExceptionFallback()).CreateFallbackBuffer().Fallback(charUnknown, index); - } - - // find out if we can replace the character with entity - if (_parent.CanReplaceAt(index)) - { - // Create the replacement character entity - _charEntity = string.Format(CultureInfo.InvariantCulture, "&#x{0:X};", new object[] { (int)charUnknown }); - _charEntityIndex = 0; - return true; - } - else - { - EncoderFallbackBuffer errorFallbackBuffer = (new EncoderExceptionFallback()).CreateFallbackBuffer(); - errorFallbackBuffer.Fallback(charUnknown, index); - return false; - } - } - - public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) - { - // check input surrogate pair - if (!char.IsSurrogatePair(charUnknownHigh, charUnknownLow)) - { - throw XmlConvert.CreateInvalidSurrogatePairException(charUnknownHigh, charUnknownLow); - } - - // If we are already in fallback, throw, it's probably at the suspect character in charEntity - if (_charEntityIndex >= 0) - { - (new EncoderExceptionFallback()).CreateFallbackBuffer().Fallback(charUnknownHigh, charUnknownLow, index); - } - - if (_parent.CanReplaceAt(index)) - { - // Create the replacement character entity - _charEntity = string.Format(CultureInfo.InvariantCulture, "&#x{0:X};", new object[] { SurrogateCharToUtf32(charUnknownHigh, charUnknownLow) }); - _charEntityIndex = 0; - return true; - } - else - { - EncoderFallbackBuffer errorFallbackBuffer = (new EncoderExceptionFallback()).CreateFallbackBuffer(); - errorFallbackBuffer.Fallback(charUnknownHigh, charUnknownLow, index); - return false; - } - } - - public override char GetNextChar() - { - // Bug fix: 35637. The protocol using GetNextChar() and MovePrevious() called by Encoder is not well documented. - // Here we have to to signal to Encoder that the previous read was last character. Only AFTER we can - // mark ourself as done (-1). Otherwise MovePrevious() can still be called, but -1 is already incorrectly set - // and return false from MovePrevious(). Then Encoder swallowing the rest of the bytes. - if (_charEntityIndex == _charEntity.Length) - { - _charEntityIndex = -1; - } - if (_charEntityIndex == -1) - { - return (char)0; - } - else - { - Debug.Assert(_charEntityIndex < _charEntity.Length); - char ch = _charEntity[_charEntityIndex++]; - return ch; - } - } - - public override bool MovePrevious() - { - if (_charEntityIndex == -1) - { - return false; - } - else - { - // Could be == length if just read the last character - Debug.Assert(_charEntityIndex <= _charEntity.Length); - if (_charEntityIndex > 0) - { - _charEntityIndex--; - return true; - } - else - { - return false; - } - } - } - - - public override int Remaining - { - get - { - if (_charEntityIndex == -1) - { - return 0; - } - else - { - return _charEntity.Length - _charEntityIndex; - } - } - } - - public override void Reset() - { - _charEntityIndex = -1; - } - - private int SurrogateCharToUtf32(char highSurrogate, char lowSurrogate) - { - return XmlCharType.CombineSurrogateChar(lowSurrogate, highSurrogate); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ConformanceLevel.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ConformanceLevel.cs deleted file mode 100644 index dfa7225c536..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ConformanceLevel.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - public enum ConformanceLevel - { - // With conformance level Auto an XmlReader or XmlWriter automatically determines whether in incoming XML is an XML fragment or document. - Auto = 0, - - // Conformance level for XML fragment. An XML fragment can contain any node type that can be a child of an element, - // plus it can have a single XML declaration as its first node - Fragment = 1, - - // Conformance level for XML document as specified in XML 1.0 Specification - Document = 2, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/DtdProcessing.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/DtdProcessing.cs deleted file mode 100644 index 74b4ae6c146..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/DtdProcessing.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // DtdProcessing enumerations speficies how will an XmlReader handle DTDs in the XML document. - // - // Prohibit The XmlReader will throw an exception when it finds a ' 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - RawText("'; - } - - // For the HTML element, it should call this method with ns and prefix as String.Empty - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - elementScope.Push((byte)currentElementProperties); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - currentElementProperties = (ElementProperties)elementPropertySearch.FindCaseInsensitiveString(localName); - base.bufChars[bufPos++] = (char)'<'; - base.RawText(localName); - base.attrEndPos = bufPos; - } - else - { - // Since the HAS_NS has no impact to the ElementTextBlock behavior, - // we don't need to push it into the stack. - currentElementProperties = ElementProperties.HAS_NS; - base.WriteStartElement(prefix, localName, ns); - } - } - - // Output >. For HTML needs to output META info - internal override void StartElementContent() - { - base.bufChars[base.bufPos++] = (char)'>'; - - // Detect whether content is output - this.contentPos = this.bufPos; - - if ((currentElementProperties & ElementProperties.HEAD) != 0) - { - WriteMetaElement(); - } - } - - // end element with /> - // for HTML(ns.Length == 0) - // not an empty tag

- // empty tag - internal override void WriteEndElement(string prefix, string localName, string ns) - { - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if ((currentElementProperties & ElementProperties.EMPTY) == 0) - { - bufChars[base.bufPos++] = (char)'<'; - bufChars[base.bufPos++] = (char)'/'; - base.RawText(localName); - bufChars[base.bufPos++] = (char)'>'; - } - } - else - { - //xml content - base.WriteEndElement(prefix, localName, ns); - } - - currentElementProperties = (ElementProperties)elementScope.Pop(); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if ((currentElementProperties & ElementProperties.EMPTY) == 0) - { - bufChars[base.bufPos++] = (char)'<'; - bufChars[base.bufPos++] = (char)'/'; - base.RawText(localName); - bufChars[base.bufPos++] = (char)'>'; - } - } - else - { - //xml content - base.WriteFullEndElement(prefix, localName, ns); - } - - currentElementProperties = (ElementProperties)elementScope.Pop(); - } - - // 1. How the outputBooleanAttribute(fBOOL) and outputHtmlUriText(fURI) being set? - // When SA is called. - // - // BOOL_PARENT URI_PARENT Others - // fURI - // URI att false true false - // - // fBOOL - // BOOL att true false false - // - // How they change the attribute output behaviors? - // - // 1) fURI=true fURI=false - // SA a=" a=" - // AT HtmlURIText HtmlText - // EA " " - // - // 2) fBOOL=true fBOOL=false - // SA a a=" - // AT HtmlText output nothing - // EA output nothing " - // - // When they get reset? - // At the end of attribute. - - // 2. How the outputXmlTextElementScoped(fENs) and outputXmlTextattributeScoped(fANs) are set? - // fANs is in the scope of the fENs. - // - // SE(localName) SE(ns, pre, localName) SA(localName) SA(ns, pre, localName) - // fENs false(default) true(action) - // fANs false(default) false(default) false(default) true(action) - - // how they get reset? - // - // EE(localName) EE(ns, pre, localName) EENC(ns, pre, localName) EA(localName) EA(ns, pre, localName) - // fENs false(action) - // fANs false(action) - - // How they change the TextOutput? - // - // fENs | fANs Else - // AT XmlText HtmlText - // - // - // 3. Flags for processing &{ split situations - // - // When the flag is set? - // - // AT src[lastchar]='&' flag&{ = true; - // - // when it get result? - // - // AT method. - // - // How it changes the behaviors? - // - // flag&{=true - // - // AT if (src[0] == '{') { - // output "&{" - // } - // else { - // output & - // } - // - // EA output amp; - // - - // SA if (flagBOOL == false) { output =";} - // - // AT if (flagBOOL) { return}; - // if (flagNS) {XmlText;} { - // } - // else if (flagURI) { - // HtmlURIText; - // } - // else { - // HtmlText; - // } - // - - // AT if (flagNS) {XmlText;} { - // } - // else if (flagURI) { - // HtmlURIText; - // } - // else if (!flagBOOL) { - // HtmlText; //flag&{ handling - // } - // - // - // EA if (flagBOOL == false) { output " - // } - // else if (flag&{) { - // output amp; - // } - // - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if (base.attrEndPos == bufPos) - { - base.bufChars[bufPos++] = (char)' '; - } - base.RawText(localName); - - if ((currentElementProperties & (ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.NAME_PARENT)) != 0) - { - _currentAttributeProperties = (AttributeProperties)attributePropertySearch.FindCaseInsensitiveString(localName) & - (AttributeProperties)currentElementProperties; - - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - base.inAttributeValue = true; - return; - } - } - else - { - _currentAttributeProperties = AttributeProperties.DEFAULT; - } - - base.bufChars[bufPos++] = (char)'='; - base.bufChars[bufPos++] = (char)'"'; - } - else - { - base.WriteStartAttribute(prefix, localName, ns); - _currentAttributeProperties = AttributeProperties.DEFAULT; - } - - base.inAttributeValue = true; - } - - // Output the amp; at end of EndAttribute - public override void WriteEndAttribute() - { - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - base.attrEndPos = bufPos; - } - else - { - if (_endsWithAmpersand) - { - OutputRestAmps(); - _endsWithAmpersand = false; - } - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - base.bufChars[bufPos++] = (char)'"'; - } - base.inAttributeValue = false; - base.attrEndPos = bufPos; - } - - // HTML PI's use ">" to terminate rather than "?>". - public override void WriteProcessingInstruction(string target, string text) - { - Debug.Assert(target != null && target.Length != 0 && text != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[base.bufPos++] = (char)'<'; - bufChars[base.bufPos++] = (char)'?'; - base.RawText(target); - bufChars[base.bufPos++] = (char)' '; - - base.WriteCommentOrPi(text, '?'); - - base.bufChars[base.bufPos++] = (char)'>'; - - if (base.bufPos > base.bufLen) - { - FlushBuffer(); - } - } - - // Serialize either attribute or element text using HTML rules. - public override unsafe void WriteString(string text) - { - Debug.Assert(text != null); - - if (trackTextContent && inTextContent != true) { ChangeTextContentMark(true); } - - fixed (char* pSrc = text) - { - char* pSrcEnd = pSrc + text.Length; - if (base.inAttributeValue) - { - WriteHtmlAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteHtmlElementTextBlock(pSrc, pSrcEnd); - } - } - } - - public override void WriteEntityRef(string name) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteCharEntity(char ch) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override unsafe void WriteChars(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - if (trackTextContent && inTextContent != true) { ChangeTextContentMark(true); } - - fixed (char* pSrcBegin = &buffer[index]) - { - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrcBegin, pSrcBegin + count); - } - else - { - WriteElementTextBlock(pSrcBegin, pSrcBegin + count); - } - } - } - - // - // Private methods - // - - private void Init(XmlWriterSettings settings) - { - Debug.Assert((int)ElementProperties.URI_PARENT == (int)AttributeProperties.URI); - Debug.Assert((int)ElementProperties.BOOL_PARENT == (int)AttributeProperties.BOOLEAN); - Debug.Assert((int)ElementProperties.NAME_PARENT == (int)AttributeProperties.NAME); - - if (elementPropertySearch == null) - { - //elementPropertySearch should be init last for the mutli thread safe situation. - attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes); - elementPropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements); - } - - elementScope = new ByteStack(StackIncrement); - _uriEscapingBuffer = new byte[5]; - currentElementProperties = ElementProperties.DEFAULT; - - _mediaType = settings.MediaType; - _doNotEscapeUriAttributes = settings.DoNotEscapeUriAttributes; - } - - protected void WriteMetaElement() - { - base.RawText(""); - } - - // Justify the stack usage: - // - // Nested elements has following possible position combinations - // 1. Content1Content2 - // 2. Content2Content1 - // 3. ContentCotent2Content1 - // - // In the situation 2 and 3, the stored currentElementProrperties will be E2's, - // only the top of the stack is the real E1 element properties. - protected unsafe void WriteHtmlElementTextBlock(char* pSrc, char* pSrcEnd) - { - if ((currentElementProperties & ElementProperties.NO_ENTITIES) != 0) - { - base.RawText(pSrc, pSrcEnd); - } - else - { - base.WriteElementTextBlock(pSrc, pSrcEnd); - } - } - - protected unsafe void WriteHtmlAttributeTextBlock(char* pSrc, char* pSrcEnd) - { - if ((_currentAttributeProperties & (AttributeProperties.BOOLEAN | AttributeProperties.URI | AttributeProperties.NAME)) != 0) - { - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - //if output boolean attribute, ignore this call. - return; - } - - if ((_currentAttributeProperties & (AttributeProperties.URI | AttributeProperties.NAME)) != 0 && !_doNotEscapeUriAttributes) - { - WriteUriAttributeText(pSrc, pSrcEnd); - } - else - { - WriteHtmlAttributeText(pSrc, pSrcEnd); - } - } - else if ((currentElementProperties & ElementProperties.HAS_NS) != 0) - { - base.WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteHtmlAttributeText(pSrc, pSrcEnd); - } - } - - // - // &{ split cases - // 1). HtmlAttributeText("a&"); - // HtmlAttributeText("{b}"); - // - // 2). HtmlAttributeText("a&"); - // EndAttribute(); - - // 3).split with Flush by the user - // HtmlAttributeText("a&"); - // FlushBuffer(); - // HtmlAttributeText("{b}"); - - // - // Solutions: - // case 1)hold the & output as & - // if the next income character is {, output { - // else output amp; - // - - private unsafe void WriteHtmlAttributeText(char* pSrc, char* pSrcEnd) - { - if (_endsWithAmpersand) - { - if (pSrcEnd - pSrc > 0 && pSrc[0] != '{') - { - OutputRestAmps(); - } - _endsWithAmpersand = false; - } - - fixed (char* pDstBegin = bufChars) - { - char* pDst = pDstBegin + this.bufPos; - - char ch = (char)0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - - - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0))) - { - *pDst++ = (char)ch; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - if (pSrc + 1 == pSrcEnd) - { - _endsWithAmpersand = true; - } - else if (pSrc[1] != '{') - { - pDst = XmlEncodedRawTextWriter.AmpEntity(pDst); - break; - } - *pDst++ = (char)ch; - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '<': - case '>': - case '\'': - case (char)0x9: - *pDst++ = (char)ch; - break; - case (char)0xD: - // do not normalize new lines in attributes - just escape them - pDst = CarriageReturnEntity(pDst); - break; - case (char)0xA: - // do not normalize new lines in attributes - just escape them - pDst = LineFeedEntity(pDst); - break; - default: - EncodeChar(ref pSrc, pSrcEnd, ref pDst); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - private unsafe void WriteUriAttributeText(char* pSrc, char* pSrcEnd) - { - if (_endsWithAmpersand) - { - if (pSrcEnd - pSrc > 0 && pSrc[0] != '{') - { - OutputRestAmps(); - } - _endsWithAmpersand = false; - } - - fixed (char* pDstBegin = bufChars) - { - char* pDst = pDstBegin + this.bufPos; - - char ch = (char)0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch < 0x80)) - { - *pDst++ = (char)ch; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - if (pSrc + 1 == pSrcEnd) - { - _endsWithAmpersand = true; - } - else if (pSrc[1] != '{') - { - pDst = XmlEncodedRawTextWriter.AmpEntity(pDst); - break; - } - *pDst++ = (char)ch; - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '<': - case '>': - case '\'': - case (char)0x9: - *pDst++ = (char)ch; - break; - case (char)0xD: - // do not normalize new lines in attributes - just escape them - pDst = CarriageReturnEntity(pDst); - break; - case (char)0xA: - // do not normalize new lines in attributes - just escape them - pDst = LineFeedEntity(pDst); - break; - default: - const string hexDigits = "0123456789ABCDEF"; - fixed (byte* pUriEscapingBuffer = _uriEscapingBuffer) - { - byte* pByte = pUriEscapingBuffer; - byte* pEnd = pByte; - - XmlUtf8RawTextWriter.CharToUTF8(ref pSrc, pSrcEnd, ref pEnd); - - while (pByte < pEnd) - { - *pDst++ = (char)'%'; - *pDst++ = (char)hexDigits[*pByte >> 4]; - *pDst++ = (char)hexDigits[*pByte & 0xF]; - pByte++; - } - } - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // For handling &{ in Html text field. If & is not followed by {, it still needs to be escaped. - private void OutputRestAmps() - { - base.bufChars[bufPos++] = (char)'a'; - base.bufChars[bufPos++] = (char)'m'; - base.bufChars[bufPos++] = (char)'p'; - base.bufChars[bufPos++] = (char)';'; - } - } - - - // - // Indentation HtmlWriter only indent situations - // - // Here are all the cases: - // ELEMENT1 actions ELEMENT2 actions SC EE - // 1). SE SC store SE blockPro SE a). check ELEMENT1 blockPro - // EE if SE, EE are blocks b). true: check ELEMENT2 blockPro - // c). detect ELEMENT is SE, SC - // d). increase the indexlevel - // - // 2). SE SC, Store EE blockPro EE a). check stored blockPro - // EE if SE, EE are blocks b). true: indexLevel same - // - - - // - // This is an alternative way to make the output looks better - // - // Indentation HtmlWriter only indent situations - // - // Here are all the cases: - // ELEMENT1 actions ELEMENT2 actions Samples - // 1). SE SC store SE blockPro SE a). check ELEMENT1 blockPro (blockPos) - // b). true: check ELEMENT2 blockPro - // c). detect ELEMENT is SE, SC - // d). increase the indentLevel - // - // 2). EE Store EE blockPro SE a). check stored blockPro - // b). true: indentLevel same - // c). output block2 - // - // 3). EE same as above EE a). check stored blockPro - // b). true: --indentLevel - // c). output block2 - // - // 4). SE SC same as above EE a). check stored blockPro - // b). true: indentLevel no change - internal class HtmlEncodedRawTextWriterIndent : HtmlEncodedRawTextWriter - { - // - // Fields - // - private int _indentLevel; - - // for detecting SE SC sitution - private int _endBlockPos; - - // settings - private string _indentChars; - private bool _newLineOnAttributes; - - // - // Constructors - // - - - public HtmlEncodedRawTextWriterIndent(TextWriter writer, XmlWriterSettings settings) : base(writer, settings) - { - Init(settings); - } - - - public HtmlEncodedRawTextWriterIndent(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - Init(settings); - } - - // - // XmlRawWriter overrides - // - /// - /// Serialize the document type declaration. - /// - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - base.WriteDocType(name, pubid, sysid, subset); - - // Allow indentation after DocTypeDecl - _endBlockPos = base.bufPos; - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - base.elementScope.Push((byte)base.currentElementProperties); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - base.currentElementProperties = (ElementProperties)elementPropertySearch.FindCaseInsensitiveString(localName); - - if (_endBlockPos == base.bufPos && (base.currentElementProperties & ElementProperties.BLOCK_WS) != 0) - { - WriteIndent(); - } - _indentLevel++; - - base.bufChars[bufPos++] = (char)'<'; - } - else - { - base.currentElementProperties = ElementProperties.HAS_NS | ElementProperties.BLOCK_WS; - - if (_endBlockPos == base.bufPos) - { - WriteIndent(); - } - _indentLevel++; - - base.bufChars[base.bufPos++] = (char)'<'; - if (prefix.Length != 0) - { - base.RawText(prefix); - base.bufChars[base.bufPos++] = (char)':'; - } - } - base.RawText(localName); - base.attrEndPos = bufPos; - } - - internal override void StartElementContent() - { - base.bufChars[base.bufPos++] = (char)'>'; - - // Detect whether content is output - base.contentPos = base.bufPos; - - if ((currentElementProperties & ElementProperties.HEAD) != 0) - { - WriteIndent(); - WriteMetaElement(); - _endBlockPos = base.bufPos; - } - else if ((base.currentElementProperties & ElementProperties.BLOCK_WS) != 0) - { - // store the element block position - _endBlockPos = base.bufPos; - } - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - bool isBlockWs; - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - _indentLevel--; - - // If this element has block whitespace properties, - isBlockWs = (base.currentElementProperties & ElementProperties.BLOCK_WS) != 0; - if (isBlockWs) - { - // And if the last node to be output had block whitespace properties, - // And if content was output within this element, - if (_endBlockPos == base.bufPos && base.contentPos != base.bufPos) - { - // Then indent - WriteIndent(); - } - } - - base.WriteEndElement(prefix, localName, ns); - - // Reset contentPos in case of empty elements - base.contentPos = 0; - - // Mark end of element in buffer for element's with block whitespace properties - if (isBlockWs) - { - _endBlockPos = base.bufPos; - } - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - if (_newLineOnAttributes) - { - RawText(base.newLineChars); - _indentLevel++; - WriteIndent(); - _indentLevel--; - } - base.WriteStartAttribute(prefix, localName, ns); - } - - protected override void FlushBuffer() - { - // Make sure the buffer will reset the block position - _endBlockPos = (_endBlockPos == base.bufPos) ? 1 : 0; - base.FlushBuffer(); - } - - // - // Private methods - // - private void Init(XmlWriterSettings settings) - { - _indentLevel = 0; - _indentChars = settings.IndentChars; - _newLineOnAttributes = settings.NewLineOnAttributes; - } - - private void WriteIndent() - { - // -- suppress ws betw and - // -- don't suppress ws betw and - // text -- suppress ws betw and text (handled by wcharText method) - // -- suppress ws betw and PI - // -- suppress ws betw and comment - - // -- suppress ws betw and - // -- suppress ws betw and - // text -- suppress ws betw and text (handled by wcharText method) - // -- suppress ws betw and PI - // -- suppress ws betw and comment - - RawText(base.newLineChars); - for (int i = _indentLevel; i > 0; i--) - { - RawText(_indentChars); - } - } - } -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlTernaryTree.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlTernaryTree.cs deleted file mode 100644 index 509db65970b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlTernaryTree.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// This file is generated by TernaryTreeGenerator.cs, -// and is used by the TernaryTreeRO class. - -namespace Microsoft.Xml -{ - using System; - - // - // It contains the state for a ternary tree used to map HTML - // keywords to XSL output properties. - // - // Do not modify this file directly! (as if you could) - // - internal abstract class HtmlTernaryTree - { - internal static byte[] htmlElements = { - 73,4,147,0, 77,140,162,0, 71,0,0,0, 0,0,0,11, 68,4,85,0, 73,71,92,0, 86,81,0,0, - 0,0,0,64, 66,3,45,0, 82,21,55,0, 0,0,0,8, 65,0,0,0, 82,4,0,0, 69,0,0,0, - 65,0,0,0, 0,0,0,75, 68,7,8,0, 68,0,0,0, 82,0,0,0, 69,0,0,0, 83,0,0,0, - 83,0,0,0, 0,0,0,64, 0,0,0,1, 80,0,0,0, 80,0,0,0, 76,0,0,0, 69,0,0,0, - 84,0,0,0, 0,0,0,64, 65,0,9,0, 83,0,0,0, 69,0,0,0, 70,5,0,0, 79,0,0,0, - 78,0,0,0, 84,0,0,0, 0,0,0,72, 0,0,0,73, 76,0,10,0, 79,0,0,0, 67,0,0,0, - 75,0,0,0, 81,0,0,0, 85,0,0,0, 79,0,0,0, 84,0,0,0, 69,0,0,0, 0,0,0,65, - 79,0,0,0, 68,0,0,0, 89,0,0,0, 0,0,0,64, 67,0,0,0, 79,3,0,0, 76,0,0,0, - 0,0,22,72, 65,0,13,0, 80,0,0,0, 84,0,0,0, 73,0,0,0, 79,0,0,0, 78,0,0,0, - 0,0,0,64, 85,0,0,0, 84,0,0,0, 84,0,0,0, 79,0,0,0, 78,0,0,0, 0,0,0,2, - 69,0,0,0, 78,0,0,0, 84,0,0,0, 69,0,0,0, 82,0,0,0, 0,0,0,64, 68,0,8,0, - 0,0,0,64, 71,0,0,0, 82,0,0,0, 79,0,0,0, 85,0,0,0, 80,0,0,0, 0,0,0,64, - 69,0,0,0, 76,0,0,0, 0,0,0,65, 82,0,0,0, 0,0,0,66, 72,3,0,0, 50,31,33,0, - 0,0,0,64, 70,0,0,0, 79,8,16,0, 78,0,20,0, 84,0,0,0, 0,0,0,64, 84,2,0,0, - 0,0,0,64, 76,0,0,0, 0,0,0,66, 73,0,0,0, 69,0,0,0, 76,0,0,0, 68,0,0,0, - 83,0,0,0, 69,0,0,0, 84,0,0,0, 0,0,0,64, 82,0,0,0, 65,0,0,0, 77,0,0,0, - 69,0,0,0, 0,0,4,74, 82,0,0,0, 77,0,0,0, 0,0,0,65, 83,0,0,0, 69,0,0,0, - 84,0,0,0, 0,0,0,64, 49,0,0,0, 0,0,0,64, 54,2,8,0, 0,0,0,64, 52,2,4,0, - 0,0,0,64, 51,0,0,0, 0,0,0,64, 53,0,0,0, 0,0,0,64, 82,2,6,0, 0,0,0,74, - 69,0,0,0, 65,0,0,0, 68,0,0,0, 0,0,0,97, 84,0,0,0, 77,0,0,0, 76,0,0,0, - 0,0,0,64, 70,0,0,0, 82,0,0,0, 65,0,0,0, 77,0,0,0, 69,0,0,0, 0,0,0,64, - 80,4,84,0, 82,77,0,0, 69,0,0,0, 0,0,0,64, 77,5,37,0, 69,30,0,0, 84,32,0,0, - 65,0,0,0, 0,0,0,72, 76,0,0,0, 69,0,20,0, 71,0,0,0, 69,0,0,0, 78,0,0,0, - 68,0,0,0, 0,0,0,64, 78,0,7,0, 83,2,0,0, 0,0,0,65, 80,0,0,0, 85,0,0,0, - 84,0,0,0, 0,0,0,11, 83,0,0,0, 73,0,0,0, 78,0,0,0, 68,0,0,0, 69,0,0,0, - 88,0,0,0, 0,0,0,72, 73,0,0,0, 78,3,0,0, 75,0,0,0, 0,0,0,73, 0,0,0,64, - 65,0,0,0, 80,0,0,0, 0,0,0,64, 78,0,0,0, 85,0,0,0, 0,0,0,66, 79,3,0,0, - 76,18,24,0, 0,0,0,66, 78,0,0,0, 79,0,0,0, 83,7,0,0, 67,0,0,0, 82,0,0,0, - 73,0,0,0, 80,0,0,0, 84,0,0,0, 0,0,0,64, 70,0,0,0, 82,0,0,0, 65,0,0,0, - 77,0,0,0, 69,0,0,0, 83,0,0,0, 0,0,0,64, 66,0,0,0, 74,0,0,0, 69,0,0,0, - 67,0,0,0, 84,0,0,0, 0,0,0,3, 80,0,0,0, 84,0,0,0, 73,4,0,0, 79,0,0,0, - 78,0,0,0, 0,0,0,66, 71,0,0,0, 82,0,0,0, 79,0,0,0, 85,0,0,0, 80,0,0,0, - 0,0,0,66, 0,0,1,64, 65,0,0,0, 82,0,0,0, 65,0,0,0, 77,0,0,0, 0,0,0,72, - 84,3,65,0, 68,28,38,0, 0,0,0,66, 83,8,0,0, 69,6,15,0, 76,0,0,0, 69,0,0,0, - 67,0,0,0, 84,0,0,0, 0,0,0,2, 0,0,3,64, 81,0,0,0, 0,0,0,1, 67,0,0,0, - 82,0,0,0, 73,0,0,0, 80,0,0,0, 84,0,0,0, 0,0,0,19, 84,0,0,0, 89,4,0,0, - 76,0,0,0, 69,0,0,0, 0,0,0,80, 82,0,0,0, 73,0,0,0, 75,0,0,0, 69,0,0,0, - 0,0,0,64, 65,0,5,0, 66,0,0,0, 76,0,0,0, 69,0,0,0, 0,0,0,65, 66,0,0,0, - 79,0,0,0, 68,0,0,0, 89,0,0,0, 0,0,0,64, 72,5,19,0, 69,17,0,0, 65,0,0,0, - 68,0,0,0, 0,0,0,64, 70,5,0,0, 79,0,0,0, 79,0,0,0, 84,0,0,0, 0,0,0,64, - 69,0,0,0, 88,0,0,0, 84,0,0,0, 65,0,0,0, 82,0,0,0, 69,0,0,0, 65,0,0,0, - 0,0,0,2, 0,0,0,66, 82,2,0,0, 0,0,0,64, 73,0,0,0, 84,0,0,0, 76,0,0,0, - 69,0,0,0, 0,0,0,64, 85,0,3,0, 76,0,0,0, 0,0,0,66, 88,0,0,0, 77,0,0,0, - 80,0,0,0, 0,0,0,64, - }; - internal static byte[] htmlAttributes = { - 72,5,77,0, 82,0,0,0, 69,0,0,0, 70,0,0,0, 0,0,0,1, 67,12,40,0, 79,7,0,0, - 77,31,0,0, 80,0,0,0, 65,0,0,0, 67,0,0,0, 84,0,0,0, 0,0,0,2, 73,11,18,0, - 84,0,0,0, 69,0,0,0, 0,0,0,1, 65,0,0,0, 67,0,0,0, 84,0,0,0, 73,0,0,0, - 79,0,0,0, 78,0,0,0, 0,0,0,1, 72,0,0,0, 69,0,0,0, 67,0,0,0, 75,0,0,0, - 69,0,0,0, 68,0,0,0, 0,0,0,2, 76,0,0,0, 65,0,0,0, 83,0,0,0, 83,0,0,0, - 73,0,0,0, 68,0,0,0, 0,0,0,1, 68,0,0,0, 69,0,0,0, 66,0,0,0, 65,0,0,0, - 83,0,0,0, 69,0,0,0, 0,0,0,1, 68,0,28,0, 69,7,15,0, 67,0,22,0, 76,0,0,0, - 65,0,0,0, 82,0,0,0, 69,0,0,0, 0,0,0,2, 65,0,0,0, 84,0,0,0, 65,0,0,0, - 0,0,1,1, 83,0,0,0, 82,0,0,0, 67,0,0,0, 0,0,0,1, 73,0,0,0, 83,0,0,0, - 65,0,0,0, 66,0,0,0, 76,0,0,0, 69,0,0,0, 68,0,0,0, 0,0,0,2, 70,0,0,0, - 69,0,0,0, 82,0,0,0, 0,0,0,2, 70,0,0,0, 79,0,0,0, 82,0,0,0, 0,0,0,1, - 78,8,48,0, 79,36,0,0, 83,30,55,0, 72,0,0,0, 65,0,0,0, 68,0,0,0, 69,0,0,0, - 0,0,0,2, 77,9,0,0, 85,0,0,0, 76,0,0,0, 84,0,0,0, 73,0,0,0, 80,0,0,0, - 76,0,0,0, 69,0,0,0, 0,0,0,2, 73,0,6,0, 83,0,0,0, 77,0,0,0, 65,0,0,0, - 80,0,0,0, 0,0,0,2, 76,0,0,0, 79,0,0,0, 78,0,0,0, 71,0,0,0, 68,0,0,0, - 69,0,0,0, 83,0,0,0, 67,0,0,0, 0,0,0,1, 72,0,9,0, 82,0,0,0, 69,0,0,0, - 70,0,0,0, 0,0,0,2, 65,0,0,0, 77,0,0,0, 69,0,0,0, 0,0,0,1, 82,0,0,0, - 69,0,0,0, 83,0,0,0, 73,0,0,0, 90,0,0,0, 69,0,0,0, 0,0,0,2, 82,14,22,0, - 69,0,0,0, 65,0,0,0, 68,0,0,0, 79,0,0,0, 78,0,0,0, 76,0,0,0, 89,0,0,0, - 0,0,0,2, 87,0,0,0, 82,0,0,0, 65,0,0,0, 80,0,0,0, 0,0,0,2, 80,0,0,0, - 82,0,0,0, 79,0,0,0, 70,0,0,0, 73,0,0,0, 76,0,0,0, 69,0,0,0, 0,0,0,1, - 83,0,12,0, 82,3,0,0, 67,0,0,0, 0,0,0,1, 69,0,0,0, 76,0,0,0, 69,0,0,0, - 67,0,0,0, 84,0,0,0, 69,0,0,0, 68,0,0,0, 0,0,0,2, 85,0,0,0, 83,0,0,0, - 69,0,0,0, 77,0,0,0, 65,0,0,0, 80,0,0,0, 0,0,0,1, - }; - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlUtf8RawTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlUtf8RawTextWriter.cs deleted file mode 100644 index 9f129bd165b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/HtmlUtf8RawTextWriter.cs +++ /dev/null @@ -1,999 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -//using Microsoft.Xml.Query; -using System.Diagnostics; -using MS.Internal.Xml; - -namespace Microsoft.Xml -{ - using System; - - - internal class HtmlUtf8RawTextWriter : XmlUtf8RawTextWriter - { - // - // Fields - // - protected ByteStack elementScope; - protected ElementProperties currentElementProperties; - private AttributeProperties _currentAttributeProperties; - - private bool _endsWithAmpersand; - private byte[] _uriEscapingBuffer; - - // settings - private string _mediaType; - private bool _doNotEscapeUriAttributes; - - // - // Static fields - // - protected static TernaryTreeReadOnly elementPropertySearch; - protected static TernaryTreeReadOnly attributePropertySearch; - - // - // Constants - // - private const int StackIncrement = 10; - - // - // Constructors - // - - - - - - - - - public HtmlUtf8RawTextWriter(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - Init(settings); - } - - // - // XmlRawWriter implementation - // - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - // Ignore xml declaration - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - // Ignore xml declaration - } - - /// Html rules allow public ID without system ID and always output "html" - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - Debug.Assert(name != null && name.Length > 0); - - - - RawText("'; - } - - // For the HTML element, it should call this method with ns and prefix as String.Empty - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - elementScope.Push((byte)currentElementProperties); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - - currentElementProperties = (ElementProperties)elementPropertySearch.FindCaseInsensitiveString(localName); - base.bufBytes[bufPos++] = (byte)'<'; - base.RawText(localName); - base.attrEndPos = bufPos; - } - else - { - // Since the HAS_NS has no impact to the ElementTextBlock behavior, - // we don't need to push it into the stack. - currentElementProperties = ElementProperties.HAS_NS; - base.WriteStartElement(prefix, localName, ns); - } - } - - // Output >. For HTML needs to output META info - internal override void StartElementContent() - { - base.bufBytes[base.bufPos++] = (byte)'>'; - - // Detect whether content is output - this.contentPos = this.bufPos; - - if ((currentElementProperties & ElementProperties.HEAD) != 0) - { - WriteMetaElement(); - } - } - - // end element with /> - // for HTML(ns.Length == 0) - // not an empty tag

- // empty tag - internal override void WriteEndElement(string prefix, string localName, string ns) - { - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - - - if ((currentElementProperties & ElementProperties.EMPTY) == 0) - { - bufBytes[base.bufPos++] = (byte)'<'; - bufBytes[base.bufPos++] = (byte)'/'; - base.RawText(localName); - bufBytes[base.bufPos++] = (byte)'>'; - } - } - else - { - //xml content - base.WriteEndElement(prefix, localName, ns); - } - - currentElementProperties = (ElementProperties)elementScope.Pop(); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - - - if ((currentElementProperties & ElementProperties.EMPTY) == 0) - { - bufBytes[base.bufPos++] = (byte)'<'; - bufBytes[base.bufPos++] = (byte)'/'; - base.RawText(localName); - bufBytes[base.bufPos++] = (byte)'>'; - } - } - else - { - //xml content - base.WriteFullEndElement(prefix, localName, ns); - } - - currentElementProperties = (ElementProperties)elementScope.Pop(); - } - - // 1. How the outputBooleanAttribute(fBOOL) and outputHtmlUriText(fURI) being set? - // When SA is called. - // - // BOOL_PARENT URI_PARENT Others - // fURI - // URI att false true false - // - // fBOOL - // BOOL att true false false - // - // How they change the attribute output behaviors? - // - // 1) fURI=true fURI=false - // SA a=" a=" - // AT HtmlURIText HtmlText - // EA " " - // - // 2) fBOOL=true fBOOL=false - // SA a a=" - // AT HtmlText output nothing - // EA output nothing " - // - // When they get reset? - // At the end of attribute. - - // 2. How the outputXmlTextElementScoped(fENs) and outputXmlTextattributeScoped(fANs) are set? - // fANs is in the scope of the fENs. - // - // SE(localName) SE(ns, pre, localName) SA(localName) SA(ns, pre, localName) - // fENs false(default) true(action) - // fANs false(default) false(default) false(default) true(action) - - // how they get reset? - // - // EE(localName) EE(ns, pre, localName) EENC(ns, pre, localName) EA(localName) EA(ns, pre, localName) - // fENs false(action) - // fANs false(action) - - // How they change the TextOutput? - // - // fENs | fANs Else - // AT XmlText HtmlText - // - // - // 3. Flags for processing &{ split situations - // - // When the flag is set? - // - // AT src[lastchar]='&' flag&{ = true; - // - // when it get result? - // - // AT method. - // - // How it changes the behaviors? - // - // flag&{=true - // - // AT if (src[0] == '{') { - // output "&{" - // } - // else { - // output & - // } - // - // EA output amp; - // - - // SA if (flagBOOL == false) { output =";} - // - // AT if (flagBOOL) { return}; - // if (flagNS) {XmlText;} { - // } - // else if (flagURI) { - // HtmlURIText; - // } - // else { - // HtmlText; - // } - // - - // AT if (flagNS) {XmlText;} { - // } - // else if (flagURI) { - // HtmlURIText; - // } - // else if (!flagBOOL) { - // HtmlText; //flag&{ handling - // } - // - // - // EA if (flagBOOL == false) { output " - // } - // else if (flag&{) { - // output amp; - // } - // - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - - if (base.attrEndPos == bufPos) - { - base.bufBytes[bufPos++] = (byte)' '; - } - base.RawText(localName); - - if ((currentElementProperties & (ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.NAME_PARENT)) != 0) - { - _currentAttributeProperties = (AttributeProperties)attributePropertySearch.FindCaseInsensitiveString(localName) & - (AttributeProperties)currentElementProperties; - - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - base.inAttributeValue = true; - return; - } - } - else - { - _currentAttributeProperties = AttributeProperties.DEFAULT; - } - - base.bufBytes[bufPos++] = (byte)'='; - base.bufBytes[bufPos++] = (byte)'"'; - } - else - { - base.WriteStartAttribute(prefix, localName, ns); - _currentAttributeProperties = AttributeProperties.DEFAULT; - } - - base.inAttributeValue = true; - } - - // Output the amp; at end of EndAttribute - public override void WriteEndAttribute() - { - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - base.attrEndPos = bufPos; - } - else - { - if (_endsWithAmpersand) - { - OutputRestAmps(); - _endsWithAmpersand = false; - } - - - - base.bufBytes[bufPos++] = (byte)'"'; - } - base.inAttributeValue = false; - base.attrEndPos = bufPos; - } - - // HTML PI's use ">" to terminate rather than "?>". - public override void WriteProcessingInstruction(string target, string text) - { - Debug.Assert(target != null && target.Length != 0 && text != null); - - - - bufBytes[base.bufPos++] = (byte)'<'; - bufBytes[base.bufPos++] = (byte)'?'; - base.RawText(target); - bufBytes[base.bufPos++] = (byte)' '; - - base.WriteCommentOrPi(text, '?'); - - base.bufBytes[base.bufPos++] = (byte)'>'; - - if (base.bufPos > base.bufLen) - { - FlushBuffer(); - } - } - - // Serialize either attribute or element text using HTML rules. - public override unsafe void WriteString(string text) - { - Debug.Assert(text != null); - - - - fixed (char* pSrc = text) - { - char* pSrcEnd = pSrc + text.Length; - if (base.inAttributeValue) - { - WriteHtmlAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteHtmlElementTextBlock(pSrc, pSrcEnd); - } - } - } - - public override void WriteEntityRef(string name) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteCharEntity(char ch) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override unsafe void WriteChars(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - - - fixed (char* pSrcBegin = &buffer[index]) - { - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrcBegin, pSrcBegin + count); - } - else - { - WriteElementTextBlock(pSrcBegin, pSrcBegin + count); - } - } - } - - // - // Private methods - // - - private void Init(XmlWriterSettings settings) - { - Debug.Assert((int)ElementProperties.URI_PARENT == (int)AttributeProperties.URI); - Debug.Assert((int)ElementProperties.BOOL_PARENT == (int)AttributeProperties.BOOLEAN); - Debug.Assert((int)ElementProperties.NAME_PARENT == (int)AttributeProperties.NAME); - - if (elementPropertySearch == null) - { - //elementPropertySearch should be init last for the mutli thread safe situation. - attributePropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlAttributes); - elementPropertySearch = new TernaryTreeReadOnly(HtmlTernaryTree.htmlElements); - } - - elementScope = new ByteStack(StackIncrement); - _uriEscapingBuffer = new byte[5]; - currentElementProperties = ElementProperties.DEFAULT; - - _mediaType = settings.MediaType; - _doNotEscapeUriAttributes = settings.DoNotEscapeUriAttributes; - } - - protected void WriteMetaElement() - { - base.RawText(""); - } - - // Justify the stack usage: - // - // Nested elements has following possible position combinations - // 1. Content1Content2 - // 2. Content2Content1 - // 3. ContentCotent2Content1 - // - // In the situation 2 and 3, the stored currentElementProrperties will be E2's, - // only the top of the stack is the real E1 element properties. - protected unsafe void WriteHtmlElementTextBlock(char* pSrc, char* pSrcEnd) - { - if ((currentElementProperties & ElementProperties.NO_ENTITIES) != 0) - { - base.RawText(pSrc, pSrcEnd); - } - else - { - base.WriteElementTextBlock(pSrc, pSrcEnd); - } - } - - protected unsafe void WriteHtmlAttributeTextBlock(char* pSrc, char* pSrcEnd) - { - if ((_currentAttributeProperties & (AttributeProperties.BOOLEAN | AttributeProperties.URI | AttributeProperties.NAME)) != 0) - { - if ((_currentAttributeProperties & AttributeProperties.BOOLEAN) != 0) - { - //if output boolean attribute, ignore this call. - return; - } - - if ((_currentAttributeProperties & (AttributeProperties.URI | AttributeProperties.NAME)) != 0 && !_doNotEscapeUriAttributes) - { - WriteUriAttributeText(pSrc, pSrcEnd); - } - else - { - WriteHtmlAttributeText(pSrc, pSrcEnd); - } - } - else if ((currentElementProperties & ElementProperties.HAS_NS) != 0) - { - base.WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteHtmlAttributeText(pSrc, pSrcEnd); - } - } - - // - // &{ split cases - // 1). HtmlAttributeText("a&"); - // HtmlAttributeText("{b}"); - // - // 2). HtmlAttributeText("a&"); - // EndAttribute(); - - // 3).split with Flush by the user - // HtmlAttributeText("a&"); - // FlushBuffer(); - // HtmlAttributeText("{b}"); - - // - // Solutions: - // case 1)hold the & output as & - // if the next income character is {, output { - // else output amp; - // - - private unsafe void WriteHtmlAttributeText(char* pSrc, char* pSrcEnd) - { - if (_endsWithAmpersand) - { - if (pSrcEnd - pSrc > 0 && pSrc[0] != '{') - { - OutputRestAmps(); - } - _endsWithAmpersand = false; - } - - fixed (byte* pDstBegin = bufBytes) - { - byte* pDst = pDstBegin + this.bufPos; - - char ch = (char)0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch <= 0x7F)) - { - *pDst++ = (byte)ch; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - if (pSrc + 1 == pSrcEnd) - { - _endsWithAmpersand = true; - } - else if (pSrc[1] != '{') - { - pDst = XmlUtf8RawTextWriter.AmpEntity(pDst); - break; - } - *pDst++ = (byte)ch; - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '<': - case '>': - case '\'': - case (char)0x9: - *pDst++ = (byte)ch; - break; - case (char)0xD: - // do not normalize new lines in attributes - just escape them - pDst = CarriageReturnEntity(pDst); - break; - case (char)0xA: - // do not normalize new lines in attributes - just escape them - pDst = LineFeedEntity(pDst); - break; - default: - EncodeChar(ref pSrc, pSrcEnd, ref pDst); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - private unsafe void WriteUriAttributeText(char* pSrc, char* pSrcEnd) - { - if (_endsWithAmpersand) - { - if (pSrcEnd - pSrc > 0 && pSrc[0] != '{') - { - OutputRestAmps(); - } - _endsWithAmpersand = false; - } - - fixed (byte* pDstBegin = bufBytes) - { - byte* pDst = pDstBegin + this.bufPos; - - char ch = (char)0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch < 0x80)) - { - *pDst++ = (byte)ch; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - if (pSrc + 1 == pSrcEnd) - { - _endsWithAmpersand = true; - } - else if (pSrc[1] != '{') - { - pDst = XmlUtf8RawTextWriter.AmpEntity(pDst); - break; - } - *pDst++ = (byte)ch; - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '<': - case '>': - case '\'': - case (char)0x9: - *pDst++ = (byte)ch; - break; - case (char)0xD: - // do not normalize new lines in attributes - just escape them - pDst = CarriageReturnEntity(pDst); - break; - case (char)0xA: - // do not normalize new lines in attributes - just escape them - pDst = LineFeedEntity(pDst); - break; - default: - const string hexDigits = "0123456789ABCDEF"; - fixed (byte* pUriEscapingBuffer = _uriEscapingBuffer) - { - byte* pByte = pUriEscapingBuffer; - byte* pEnd = pByte; - - XmlUtf8RawTextWriter.CharToUTF8(ref pSrc, pSrcEnd, ref pEnd); - - while (pByte < pEnd) - { - *pDst++ = (byte)'%'; - *pDst++ = (byte)hexDigits[*pByte >> 4]; - *pDst++ = (byte)hexDigits[*pByte & 0xF]; - pByte++; - } - } - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // For handling &{ in Html text field. If & is not followed by {, it still needs to be escaped. - private void OutputRestAmps() - { - base.bufBytes[bufPos++] = (byte)'a'; - base.bufBytes[bufPos++] = (byte)'m'; - base.bufBytes[bufPos++] = (byte)'p'; - base.bufBytes[bufPos++] = (byte)';'; - } - } - - - // - // Indentation HtmlWriter only indent situations - // - // Here are all the cases: - // ELEMENT1 actions ELEMENT2 actions SC EE - // 1). SE SC store SE blockPro SE a). check ELEMENT1 blockPro - // EE if SE, EE are blocks b). true: check ELEMENT2 blockPro - // c). detect ELEMENT is SE, SC - // d). increase the indexlevel - // - // 2). SE SC, Store EE blockPro EE a). check stored blockPro - // EE if SE, EE are blocks b). true: indexLevel same - // - - - // - // This is an alternative way to make the output looks better - // - // Indentation HtmlWriter only indent situations - // - // Here are all the cases: - // ELEMENT1 actions ELEMENT2 actions Samples - // 1). SE SC store SE blockPro SE a). check ELEMENT1 blockPro (blockPos) - // b). true: check ELEMENT2 blockPro - // c). detect ELEMENT is SE, SC - // d). increase the indentLevel - // - // 2). EE Store EE blockPro SE a). check stored blockPro - // b). true: indentLevel same - // c). output block2 - // - // 3). EE same as above EE a). check stored blockPro - // b). true: --indentLevel - // c). output block2 - // - // 4). SE SC same as above EE a). check stored blockPro - // b). true: indentLevel no change - internal class HtmlUtf8RawTextWriterIndent : HtmlUtf8RawTextWriter - { - // - // Fields - // - private int _indentLevel; - - // for detecting SE SC sitution - private int _endBlockPos; - - // settings - private string _indentChars; - private bool _newLineOnAttributes; - - // - // Constructors - // - - - - - - - - public HtmlUtf8RawTextWriterIndent(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - Init(settings); - } - - // - // XmlRawWriter overrides - // - /// - /// Serialize the document type declaration. - /// - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - base.WriteDocType(name, pubid, sysid, subset); - - // Allow indentation after DocTypeDecl - _endBlockPos = base.bufPos; - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - - - base.elementScope.Push((byte)base.currentElementProperties); - - if (ns.Length == 0) - { - Debug.Assert(prefix.Length == 0); - - base.currentElementProperties = (ElementProperties)elementPropertySearch.FindCaseInsensitiveString(localName); - - if (_endBlockPos == base.bufPos && (base.currentElementProperties & ElementProperties.BLOCK_WS) != 0) - { - WriteIndent(); - } - _indentLevel++; - - base.bufBytes[bufPos++] = (byte)'<'; - } - else - { - base.currentElementProperties = ElementProperties.HAS_NS | ElementProperties.BLOCK_WS; - - if (_endBlockPos == base.bufPos) - { - WriteIndent(); - } - _indentLevel++; - - base.bufBytes[base.bufPos++] = (byte)'<'; - if (prefix.Length != 0) - { - base.RawText(prefix); - base.bufBytes[base.bufPos++] = (byte)':'; - } - } - base.RawText(localName); - base.attrEndPos = bufPos; - } - - internal override void StartElementContent() - { - base.bufBytes[base.bufPos++] = (byte)'>'; - - // Detect whether content is output - base.contentPos = base.bufPos; - - if ((currentElementProperties & ElementProperties.HEAD) != 0) - { - WriteIndent(); - WriteMetaElement(); - _endBlockPos = base.bufPos; - } - else if ((base.currentElementProperties & ElementProperties.BLOCK_WS) != 0) - { - // store the element block position - _endBlockPos = base.bufPos; - } - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - bool isBlockWs; - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - _indentLevel--; - - // If this element has block whitespace properties, - isBlockWs = (base.currentElementProperties & ElementProperties.BLOCK_WS) != 0; - if (isBlockWs) - { - // And if the last node to be output had block whitespace properties, - // And if content was output within this element, - if (_endBlockPos == base.bufPos && base.contentPos != base.bufPos) - { - // Then indent - WriteIndent(); - } - } - - base.WriteEndElement(prefix, localName, ns); - - // Reset contentPos in case of empty elements - base.contentPos = 0; - - // Mark end of element in buffer for element's with block whitespace properties - if (isBlockWs) - { - _endBlockPos = base.bufPos; - } - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - if (_newLineOnAttributes) - { - RawText(base.newLineChars); - _indentLevel++; - WriteIndent(); - _indentLevel--; - } - base.WriteStartAttribute(prefix, localName, ns); - } - - protected override void FlushBuffer() - { - // Make sure the buffer will reset the block position - _endBlockPos = (_endBlockPos == base.bufPos) ? 1 : 0; - base.FlushBuffer(); - } - - // - // Private methods - // - private void Init(XmlWriterSettings settings) - { - _indentLevel = 0; - _indentChars = settings.IndentChars; - _newLineOnAttributes = settings.NewLineOnAttributes; - } - - private void WriteIndent() - { - // -- suppress ws betw and - // -- don't suppress ws betw and - // text -- suppress ws betw and text (handled by wcharText method) - // -- suppress ws betw and PI - // -- suppress ws betw and comment - - // -- suppress ws betw and - // -- suppress ws betw and - // text -- suppress ws betw and text (handled by wcharText method) - // -- suppress ws betw and PI - // -- suppress ws betw and comment - - RawText(base.newLineChars); - for (int i = _indentLevel; i > 0; i--) - { - RawText(_indentChars); - } - } - } -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdInfo.cs deleted file mode 100644 index afae1ccbe28..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdInfo.cs +++ /dev/null @@ -1,240 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - // - // IDtdInfo interface - // - /// - /// This is an interface for a compiled DTD information. - /// It exposes information and functionality that XmlReader need in order to be able - /// to expand entities, add default attributes and correctly normalize attribute values - /// according to their data types. - /// - internal interface IDtdInfo - { - /// - /// DOCTYPE name - /// - XmlQualifiedName Name { get; } - - /// - /// Internal DTD subset as specified in the XML document - /// - string InternalDtdSubset { get; } - - /// - /// Returns true if the DTD contains any declaration of a default attribute - /// - bool HasDefaultAttributes { get; } - - /// - /// Returns true if the DTD contains any declaration of an attribute - /// whose type is other than CDATA - /// - bool HasNonCDataAttributes { get; } - - /// - /// Looks up a DTD attribute list definition by its name. - /// - /// The prefix of the attribute list to look for - /// The local name of the attribute list to look for - /// Interface representing an attribute list or null if none was found. - IDtdAttributeListInfo LookupAttributeList(string prefix, string localName); - - /// - /// Returns an enumerator of all attribute lists defined in the DTD. - /// - IEnumerable GetAttributeLists(); - - /// - /// Looks up a general DTD entity by its name. - /// - /// The name of the entity to look for - /// Interface representing an entity or null if none was found. - IDtdEntityInfo LookupEntity(string name); - }; - - // - // IDtdAttributeListInfo interface - // - /// - /// Exposes information about attributes declared in an attribute list in a DTD - /// that XmlReader need in order to be able to add default attributes - /// and correctly normalize attribute values according to their data types. - /// - internal interface IDtdAttributeListInfo - { - /// - /// Prefix of an element this attribute list belongs to. - /// - string Prefix { get; } - /// - /// Local name of an element this attribute list belongs to. - /// - string LocalName { get; } - /// - /// Returns true if the attribute list has some declared attributes with - /// type other than CDATA. - /// - bool HasNonCDataAttributes { get; } - /// - /// Looks up a DTD attribute definition by its name. - /// - /// The prefix of the attribute to look for - /// The local name of the attribute to look for - /// Interface representing an attribute or null is none was found - IDtdAttributeInfo LookupAttribute(string prefix, string localName); - /// - /// Returns enumeration of all default attributes - /// defined in this attribute list. - /// - /// Enumerator of default attribute. - IEnumerable LookupDefaultAttributes(); - /// - /// Looks up a ID attribute defined in the attribute list. Returns - /// null if the attribute list does define an ID attribute. - /// - IDtdAttributeInfo LookupIdAttribute(); - } - - // - // IDtdAttributeInfo interface - // - /// - /// Exposes information about an attribute declared in a DTD - /// that XmlReader need in order to be able to correctly normalize - /// the attribute value according to its data types. - /// - internal interface IDtdAttributeInfo - { - /// - /// The prefix of the attribute - /// - string Prefix { get; } - /// - /// The local name of the attribute - /// - string LocalName { get; } - /// - /// The line number of the DTD attribute definition - /// - int LineNumber { get; } - /// - /// The line position of the DTD attribute definition - /// - int LinePosition { get; } - /// - /// Returns true if the attribute is of a different type than CDATA - /// - bool IsNonCDataType { get; } - /// - /// Returns true if the attribute was declared in an external DTD subset - /// - bool IsDeclaredInExternal { get; } - /// - /// Returns true if the attribute is xml:space or xml:lang - /// - bool IsXmlAttribute { get; } - } - - // - // IDtdDefaultAttributeInfo interface - // - /// - /// Exposes information about a default attribute - /// declared in a DTD that XmlReader need in order to be able to add - /// this attribute to the XML document (it is not present already) - /// or correctly normalize the attribute value according to its data types. - /// - internal interface IDtdDefaultAttributeInfo : IDtdAttributeInfo - { - /// - /// The expanded default value of the attribute - /// the consumer assumes that all entity references - /// were already resolved in the value and that the value - /// is correctly normalized. - /// - string DefaultValueExpanded { get; } - /// - /// The typed default value of the attribute. - /// - object DefaultValueTyped { get; } /// - /// The line number of the default value (in the DTD) - /// - int ValueLineNumber { get; } - /// - /// The line position of the default value (in the DTD) - /// - int ValueLinePosition { get; } - } - - // - // IDtdEntityInfo interface - // - /// - /// Exposes information about a general entity - /// declared in a DTD that XmlReader need in order to be able - /// to expand the entity. - /// - internal interface IDtdEntityInfo - { - /// - /// The name of the entity - /// - string Name { get; } - /// - /// true if the entity is external (its value is in an external input) - /// - bool IsExternal { get; } - /// - /// true if the entity was declared in external DTD subset - /// - bool IsDeclaredInExternal { get; } - /// - /// true if this is an unparsed entity - /// - bool IsUnparsedEntity { get; } - /// - /// true if this is a parameter entity - /// - bool IsParameterEntity { get; } - /// - /// The base URI of the entity value - /// - string BaseUriString { get; } - /// - /// The URI of the XML document where the entity was declared - /// - string DeclaredUriString { get; } - /// - /// SYSTEM identifier (URI) of the entity value - only used for external entities - /// - string SystemId { get; } - /// - /// PUBLIC identifier of the entity value - only used for external entities - /// - string PublicId { get; } - /// - /// Replacement text of an entity. Valid only for internal entities. - /// - string Text { get; } - /// - /// The line number of the entity value - /// - int LineNumber { get; } - /// - /// The line position of the entity value - /// - int LinePosition { get; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParser.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParser.cs deleted file mode 100644 index ce91c7c10da..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParser.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using Microsoft.Xml; - -namespace Microsoft.Xml -{ - using System; - - - internal partial interface IDtdParser - { - IDtdInfo ParseInternalDtd(IDtdParserAdapter adapter, bool saveInternalSubset); - IDtdInfo ParseFreeFloatingDtd(string baseUri, string docTypeName, string publicId, string systemId, string internalSubset, IDtdParserAdapter adapter); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParserAdapter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParserAdapter.cs deleted file mode 100644 index 3420d371660..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IDtdParserAdapter.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.Text; -using Microsoft.Xml.Schema; - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - internal partial interface IDtdParserAdapter - { - XmlNameTable NameTable { get; } - IXmlNamespaceResolver NamespaceResolver { get; } - - Uri BaseUri { get; } - - char[] ParsingBuffer { get; } - int ParsingBufferLength { get; } - int CurrentPosition { get; set; } - int LineNo { get; } - int LineStartPosition { get; } - bool IsEof { get; } - int EntityStackLength { get; } - bool IsEntityEolNormalized { get; } - - int ReadData(); - - void OnNewLine(int pos); - - int ParseNumericCharRef(BufferBuilder internalSubsetBuilder); - int ParseNamedCharRef(bool expand, BufferBuilder internalSubsetBuilder); - void ParsePI(BufferBuilder sb); - void ParseComment(BufferBuilder sb); - - bool PushEntity(IDtdEntityInfo entity, out int entityId); - - bool PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId); - - bool PushExternalSubset(string systemId, string publicId); - - void PushInternalDtd(string baseUri, string internalDtd); - void OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo); - void OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo); - - void Throw(Exception e); - } - - internal interface IDtdParserAdapterWithValidation : IDtdParserAdapter - { - bool DtdValidation { get; } - IValidationEventHandling ValidationEventHandling { get; } - } - - internal interface IDtdParserAdapterV1 : IDtdParserAdapterWithValidation - { - bool V1CompatibilityMode { get; } - bool Normalization { get; } - bool Namespaces { get; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IRemovableWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IRemovableWriter.cs deleted file mode 100644 index c248a5694d6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IRemovableWriter.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - /// - /// Event which is used when a raw writer in a processing pipeline wishes to remove itself from the pipeline and - /// replace itself with another writer. - /// - internal delegate void OnRemoveWriter(XmlRawWriter writer); - - /// - /// This interface is implemented by writers which wish to remove themselves from the processing pipeline once they - /// have accomplished some work. An example would be the auto-detect writer, which removes itself from the pipeline - /// once it has determined whether to use the Xml or the Html output mode. - /// - internal interface IRemovableWriter - { - OnRemoveWriter OnRemoveWriterEvent { get; set; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IValidationEventHandling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IValidationEventHandling.cs deleted file mode 100644 index 2329482f869..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IValidationEventHandling.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - internal interface IValidationEventHandling - { - // This is a ValidationEventHandler, but it is not strongly typed due to dependencies on Microsoft.Xml.Schema - object EventHandler { get; } - - // The exception is XmlSchemaException, but it is not strongly typed due to dependencies on Microsoft.Xml.Schema - void SendEvent(Exception exception, XmlSeverityType severity); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IncrementalReadDecoders.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IncrementalReadDecoders.cs deleted file mode 100644 index d601f9515c7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/IncrementalReadDecoders.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - - // - // IncrementalReadDecoder abstract class - // - internal abstract class IncrementalReadDecoder - { - internal abstract int DecodedCount { get; } - internal abstract bool IsFull { get; } - internal abstract void SetNextOutputBuffer(Array array, int offset, int len); - internal abstract int Decode(char[] chars, int startPos, int len); - internal abstract int Decode(string str, int startPos, int len); - internal abstract void Reset(); - } - - // - // Dummy IncrementalReadDecoder - // - internal class IncrementalReadDummyDecoder : IncrementalReadDecoder - { - internal override int DecodedCount { get { return -1; } } - internal override bool IsFull { get { return false; } } - internal override void SetNextOutputBuffer(Array array, int offset, int len) { } - internal override int Decode(char[] chars, int startPos, int len) { return len; } - internal override int Decode(string str, int startPos, int len) { return len; } - internal override void Reset() { } - } - - // - // IncrementalReadDecoder for ReadChars - // - internal class IncrementalReadCharsDecoder : IncrementalReadDecoder - { - private char[] _buffer; - private int _startIndex; - private int _curIndex; - private int _endIndex; - - internal IncrementalReadCharsDecoder() - { - } - - internal override int DecodedCount - { - get - { - return _curIndex - _startIndex; - } - } - - internal override bool IsFull - { - get - { - return _curIndex == _endIndex; - } - } - - internal override int Decode(char[] chars, int startPos, int len) - { - Debug.Assert(chars != null); - Debug.Assert(len >= 0); - Debug.Assert(startPos >= 0); - Debug.Assert(chars.Length - startPos >= len); - - Debug.Assert(len > 0); - - int copyCount = _endIndex - _curIndex; - if (copyCount > len) - { - copyCount = len; - } - Buffer.BlockCopy(chars, startPos * 2, _buffer, _curIndex * 2, copyCount * 2); - _curIndex += copyCount; - - return copyCount; - } - - internal override int Decode(string str, int startPos, int len) - { - Debug.Assert(str != null); - Debug.Assert(len >= 0); - Debug.Assert(startPos >= 0); - Debug.Assert(str.Length - startPos >= len); - - Debug.Assert(len > 0); - - int copyCount = _endIndex - _curIndex; - if (copyCount > len) - { - copyCount = len; - } - str.CopyTo(startPos, _buffer, _curIndex, copyCount); - _curIndex += copyCount; - - return copyCount; - } - - internal override void Reset() - { - } - - internal override void SetNextOutputBuffer(Array buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(count >= 0); - Debug.Assert(index >= 0); - Debug.Assert(buffer.Length - index >= count); - - Debug.Assert((buffer as char[]) != null); - _buffer = (char[])buffer; - _startIndex = index; - _curIndex = index; - _endIndex = index + count; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NamespaceHandling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NamespaceHandling.cs deleted file mode 100644 index 07823f001fd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NamespaceHandling.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - // - // NamespaceHandling speficies how should the XmlWriter handle namespaces. - // - - [Flags] - public enum NamespaceHandling - { - // - // Default behavior - // - Default = 0x0, - - // - // Duplicate namespace declarations will be removed - // - OmitDuplicates = 0x1, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NewLineHandling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NewLineHandling.cs deleted file mode 100644 index aa75e838986..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/NewLineHandling.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // NewLineHandling speficies what will XmlWriter do with new line characters. The options are: - // Replace = Replaces all new line characters with XmlWriterSettings.NewLineChars so all new lines are the same; by default NewLineChars are "\r\n" - // Entitize = Replaces all new line characters that would be normalized away by a normalizing XmlReader with character entities - // None = Does not change the new line characters in input - // - // Following table shows what will happen with new line characters in detail: - // - // | In text node value | In attribute value | - // input to XmlWriter.WriteString() | \r\n \n \r \t | \r\n \n \r \t | - // ------------------------------------------------------------------------------------------------------------ - // NewLineHandling.Replace (default) | \r\n \r\n \r\n \t | &#D;&#A; &#A; &#D; | - // NewLineHandling.Entitize | &#D; \n &#D; \t | &#D;&#A; &#A; &#D; | - // NewLineHandling.None | \r\n \n \r \t | \r\n \n \r \t | - // ------------------------------------------------------------------------------------------------------------ - - // Specifies how end of line is handled in XmlWriter. - public enum NewLineHandling - { - Replace = 0, - Entitize = 1, - None = 2 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriter.cs deleted file mode 100644 index c978de08482..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriter.cs +++ /dev/null @@ -1,368 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Globalization; - using System.IO; - using System.Collections.Generic; - using Microsoft.Xml.Schema; - using System.Diagnostics; - - - /// - /// This writer wraps an XmlRawWriter and inserts additional lexical information into the resulting - /// Xml 1.0 document: - /// 1. CData sections - /// 2. DocType declaration - /// - /// It also performs well-formed document checks if standalone="yes" and/or a doc-type-decl is output. - /// - internal class QueryOutputWriter : XmlRawWriter - { - private XmlRawWriter _wrapped; - private bool _inCDataSection; - private Dictionary _lookupCDataElems; - private BitStack _bitsCData; - private XmlQualifiedName _qnameCData; - private bool _outputDocType,_checkWellFormedDoc,_hasDocElem,_inAttr; - private string _systemId,_publicId; - private int _depth; - - public QueryOutputWriter(XmlRawWriter writer, XmlWriterSettings settings) - { - _wrapped = writer; - - _systemId = settings.DocTypeSystem; - _publicId = settings.DocTypePublic; - - if (settings.OutputMethod == XmlOutputMethod.Xml) - { - // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is) - // Only check for well-formed document if output method is xml - if (_systemId != null) - { - _outputDocType = true; - _checkWellFormedDoc = true; - } - - // Check for well-formed document if standalone="yes" in an auto-generated xml declaration - if (settings.AutoXmlDeclaration && settings.Standalone == XmlStandalone.Yes) - _checkWellFormedDoc = true; - - if (settings.CDataSectionElements.Count > 0) - { - _bitsCData = new BitStack(); - _lookupCDataElems = new Dictionary(); - _qnameCData = new XmlQualifiedName(); - - // Add each element name to the lookup table - foreach (XmlQualifiedName name in settings.CDataSectionElements) - { - _lookupCDataElems[name] = 0; - } - - _bitsCData.PushBit(false); - } - } - else if (settings.OutputMethod == XmlOutputMethod.Html) - { - // Html output method should output doc-type-decl if system ID or public ID is defined - if (_systemId != null || _publicId != null) - _outputDocType = true; - } - } - - - //----------------------------------------------- - // XmlWriter interface - //----------------------------------------------- - - /// - /// Get and set the namespace resolver that's used by this RawWriter to resolve prefixes. - /// - internal override IXmlNamespaceResolver NamespaceResolver - { - get - { - return this.resolver; - } - set - { - this.resolver = value; - _wrapped.NamespaceResolver = value; - } - } - - /// - /// Write the xml declaration. This must be the first call. - /// - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - _wrapped.WriteXmlDeclaration(standalone); - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - _wrapped.WriteXmlDeclaration(xmldecl); - } - - /// - /// Return settings provided to factory. - /// - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = _wrapped.Settings; - - settings.ReadOnly = false; - settings.DocTypeSystem = _systemId; - settings.DocTypePublic = _publicId; - settings.ReadOnly = true; - - return settings; - } - } - - /// - /// Suppress this explicit call to WriteDocType if information was provided by XmlWriterSettings. - /// - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - if (_publicId == null && _systemId == null) - { - Debug.Assert(!_outputDocType); - _wrapped.WriteDocType(name, pubid, sysid, subset); - } - } - - /// - /// Check well-formedness, possibly output doc-type-decl, and determine whether this element is a - /// CData section element. - /// - public override void WriteStartElement(string prefix, string localName, string ns) - { - EndCDataSection(); - - if (_checkWellFormedDoc) - { - // Don't allow multiple document elements - if (_depth == 0 && _hasDocElem) - throw new XmlException(ResXml.Xml_NoMultipleRoots, string.Empty); - - _depth++; - _hasDocElem = true; - } - - // Output doc-type declaration immediately before first element is output - if (_outputDocType) - { - _wrapped.WriteDocType( - prefix.Length != 0 ? prefix + ":" + localName : localName, - _publicId, - _systemId, - null); - - _outputDocType = false; - } - - _wrapped.WriteStartElement(prefix, localName, ns); - - if (_lookupCDataElems != null) - { - // Determine whether this element is a CData section element - _qnameCData.Init(localName, ns); - _bitsCData.PushBit(_lookupCDataElems.ContainsKey(_qnameCData)); - } - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - EndCDataSection(); - - _wrapped.WriteEndElement(prefix, localName, ns); - - if (_checkWellFormedDoc) - _depth--; - - if (_lookupCDataElems != null) - _bitsCData.PopBit(); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - EndCDataSection(); - - _wrapped.WriteFullEndElement(prefix, localName, ns); - - if (_checkWellFormedDoc) - _depth--; - - if (_lookupCDataElems != null) - _bitsCData.PopBit(); - } - - internal override void StartElementContent() - { - _wrapped.StartElementContent(); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - _inAttr = true; - _wrapped.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteEndAttribute() - { - _inAttr = false; - _wrapped.WriteEndAttribute(); - } - - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - _wrapped.WriteNamespaceDeclaration(prefix, ns); - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return _wrapped.SupportsNamespaceDeclarationInChunks; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) - { - _wrapped.WriteStartNamespaceDeclaration(prefix); - } - - internal override void WriteEndNamespaceDeclaration() - { - _wrapped.WriteEndNamespaceDeclaration(); - } - - public override void WriteCData(string text) - { - _wrapped.WriteCData(text); - } - - public override void WriteComment(string text) - { - EndCDataSection(); - _wrapped.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - EndCDataSection(); - _wrapped.WriteProcessingInstruction(name, text); - } - - public override void WriteWhitespace(string ws) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(ws); - else - _wrapped.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(text); - else - _wrapped.WriteString(text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(new string(buffer, index, count)); - else - _wrapped.WriteChars(buffer, index, count); - } - - public override void WriteEntityRef(string name) - { - EndCDataSection(); - _wrapped.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - EndCDataSection(); - _wrapped.WriteCharEntity(ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - EndCDataSection(); - _wrapped.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(new string(buffer, index, count)); - else - _wrapped.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(data); - else - _wrapped.WriteRaw(data); - } - - public override void Close() - { - _wrapped.Close(); - - if (_checkWellFormedDoc && !_hasDocElem) - { - // Need at least one document element - throw new XmlException(ResXml.Xml_NoRoot, string.Empty); - } - } - - public override void Flush() - { - _wrapped.Flush(); - } - - - //----------------------------------------------- - // Helper methods - //----------------------------------------------- - - /// - /// Write CData text if element is a CData element. Return true if text should be written - /// within a CData section. - /// - private bool StartCDataSection() - { - Debug.Assert(!_inCDataSection); - if (_lookupCDataElems != null && _bitsCData.PeekBit()) - { - _inCDataSection = true; - return true; - } - return false; - } - - /// - /// No longer write CData text. - /// - private void EndCDataSection() - { - _inCDataSection = false; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriterV1.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriterV1.cs deleted file mode 100644 index b802bbe01b7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/QueryOutputWriterV1.cs +++ /dev/null @@ -1,331 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Diagnostics; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - /// - /// This writer wraps an XmlWriter that was not build using the XmlRawWriter architecture (such as XmlTextWriter or a custom XmlWriter) - /// for use in the XslCompilerTransform. Depending on the Xsl stylesheet output settings (which gets transfered to this writer via the - /// internal properties of XmlWriterSettings) this writer will inserts additional lexical information into the resulting Xml 1.0 document: - /// - /// 1. CData sections - /// 2. DocType declaration - /// 3. Standalone attribute - /// - /// It also calls WriteStateDocument if standalone="yes" and/or a DocType declaration is written out in order to enforce document conformance - /// checking. - /// - internal class QueryOutputWriterV1 : XmlWriter - { - private XmlWriter _wrapped; - private bool _inCDataSection; - private Dictionary _lookupCDataElems; - private BitStack _bitsCData; - private XmlQualifiedName _qnameCData; - private bool _outputDocType,_inAttr; - private string _systemId,_publicId; - private XmlStandalone _standalone; - - public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings) - { - _wrapped = writer; - - _systemId = settings.DocTypeSystem; - _publicId = settings.DocTypePublic; - - if (settings.OutputMethod == XmlOutputMethod.Xml) - { - bool documentConformance = false; - - // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is) - // Only check for well-formed document if output method is xml - if (_systemId != null) - { - documentConformance = true; - _outputDocType = true; - } - - // Check for well-formed document if standalone="yes" in an auto-generated xml declaration - if (settings.Standalone == XmlStandalone.Yes) - { - documentConformance = true; - _standalone = settings.Standalone; - } - - if (documentConformance) - { - if (settings.Standalone == XmlStandalone.Yes) - { - _wrapped.WriteStartDocument(true); - } - else - { - _wrapped.WriteStartDocument(); - } - } - - if (settings.CDataSectionElements != null && settings.CDataSectionElements.Count > 0) - { - _bitsCData = new BitStack(); - _lookupCDataElems = new Dictionary(); - _qnameCData = new XmlQualifiedName(); - - // Add each element name to the lookup table - foreach (XmlQualifiedName name in settings.CDataSectionElements) - { - _lookupCDataElems[name] = null; - } - - _bitsCData.PushBit(false); - } - } - else if (settings.OutputMethod == XmlOutputMethod.Html) - { - // Html output method should output doc-type-decl if system ID or public ID is defined - if (_systemId != null || _publicId != null) - _outputDocType = true; - } - } - - - //----------------------------------------------- - // XmlWriter interface - //----------------------------------------------- - - public override WriteState WriteState - { - get - { - return _wrapped.WriteState; - } - } - - public override void WriteStartDocument() - { - _wrapped.WriteStartDocument(); - } - - public override void WriteStartDocument(bool standalone) - { - _wrapped.WriteStartDocument(standalone); - } - - public override void WriteEndDocument() - { - _wrapped.WriteEndDocument(); - } - - /// - /// Suppress this explicit call to WriteDocType if information was provided by XmlWriterSettings. - /// - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - if (_publicId == null && _systemId == null) - { - Debug.Assert(!_outputDocType); - _wrapped.WriteDocType(name, pubid, sysid, subset); - } - } - - /// - /// Output doc-type-decl on the first element, and determine whether this element is a - /// CData section element. - /// - public override void WriteStartElement(string prefix, string localName, string ns) - { - EndCDataSection(); - - // Output doc-type declaration immediately before first element is output - if (_outputDocType) - { - WriteState ws = _wrapped.WriteState; - if (ws == WriteState.Start || ws == WriteState.Prolog) - { - _wrapped.WriteDocType( - prefix.Length != 0 ? prefix + ":" + localName : localName, - _publicId, - _systemId, - null); - } - _outputDocType = false; - } - - _wrapped.WriteStartElement(prefix, localName, ns); - - if (_lookupCDataElems != null) - { - // Determine whether this element is a CData section element - _qnameCData.Init(localName, ns); - _bitsCData.PushBit(_lookupCDataElems.ContainsKey(_qnameCData)); - } - } - - public override void WriteEndElement() - { - EndCDataSection(); - - _wrapped.WriteEndElement(); - - if (_lookupCDataElems != null) - _bitsCData.PopBit(); - } - - public override void WriteFullEndElement() - { - EndCDataSection(); - - _wrapped.WriteFullEndElement(); - - if (_lookupCDataElems != null) - _bitsCData.PopBit(); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - _inAttr = true; - _wrapped.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteEndAttribute() - { - _inAttr = false; - _wrapped.WriteEndAttribute(); - } - - public override void WriteCData(string text) - { - _wrapped.WriteCData(text); - } - - public override void WriteComment(string text) - { - EndCDataSection(); - _wrapped.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - EndCDataSection(); - _wrapped.WriteProcessingInstruction(name, text); - } - - public override void WriteWhitespace(string ws) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(ws); - else - _wrapped.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(text); - else - _wrapped.WriteString(text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(new string(buffer, index, count)); - else - _wrapped.WriteChars(buffer, index, count); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteBase64(buffer, index, count); - else - _wrapped.WriteBase64(buffer, index, count); - } - - public override void WriteEntityRef(string name) - { - EndCDataSection(); - _wrapped.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - EndCDataSection(); - _wrapped.WriteCharEntity(ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - EndCDataSection(); - _wrapped.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(new string(buffer, index, count)); - else - _wrapped.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - if (!_inAttr && (_inCDataSection || StartCDataSection())) - _wrapped.WriteCData(data); - else - _wrapped.WriteRaw(data); - } - - public override void Close() - { - _wrapped.Close(); - } - - public override void Flush() - { - _wrapped.Flush(); - } - - public override string LookupPrefix(string ns) - { - return _wrapped.LookupPrefix(ns); - } - - - //----------------------------------------------- - // Helper methods - //----------------------------------------------- - - /// - /// Write CData text if element is a CData element. Return true if text should be written - /// within a CData section. - /// - private bool StartCDataSection() - { - Debug.Assert(!_inCDataSection); - if (_lookupCDataElems != null && _bitsCData.PeekBit()) - { - _inCDataSection = true; - return true; - } - return false; - } - - /// - /// No longer write CData text. - /// - private void EndCDataSection() - { - _inCDataSection = false; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelper.cs deleted file mode 100644 index 3303ff253e1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelper.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - internal partial class ReadContentAsBinaryHelper - { - // Private enums - private enum State - { - None, - InReadContent, - InReadElementContent, - } - - // Fields - private XmlReader _reader; - private State _state; - private int _valueOffset; - private bool _isEnd; - - private bool _canReadValueChunk; - private char[] _valueChunk; - private int _valueChunkLength; - - private IncrementalReadDecoder _decoder; - private Base64Decoder _base64Decoder; - private BinHexDecoder _binHexDecoder; - - // Constants - private const int ChunkSize = 256; - - // Constructor - internal ReadContentAsBinaryHelper(XmlReader reader) - { - _reader = reader; - _canReadValueChunk = reader.CanReadValueChunk; - - if (_canReadValueChunk) - { - _valueChunk = new char[ChunkSize]; - } - } - - // Static methods - internal static ReadContentAsBinaryHelper CreateOrReset(ReadContentAsBinaryHelper helper, XmlReader reader) - { - if (helper == null) - { - return new ReadContentAsBinaryHelper(reader); - } - else - { - helper.Reset(); - return helper; - } - } - - // Internal methods - - internal int ReadContentAsBase64(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (!_reader.CanReadContentAs()) - { - throw _reader.CreateReadContentAsException("ReadContentAsBase64"); - } - if (!Init()) - { - return 0; - } - break; - case State.InReadContent: - // if we have a correct decoder, go read - if (_decoder == _base64Decoder) - { - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - break; - case State.InReadElementContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadContent); - - // setup base64 decoder - InitBase64Decoder(); - - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - - internal int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (!_reader.CanReadContentAs()) - { - throw _reader.CreateReadContentAsException("ReadContentAsBinHex"); - } - if (!Init()) - { - return 0; - } - break; - case State.InReadContent: - // if we have a correct decoder, go read - if (_decoder == _binHexDecoder) - { - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - break; - case State.InReadElementContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadContent); - - // setup binhex decoder - InitBinHexDecoder(); - - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - - internal int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (_reader.NodeType != XmlNodeType.Element) - { - throw _reader.CreateReadElementContentAsException("ReadElementContentAsBase64"); - } - if (!InitOnElement()) - { - return 0; - } - break; - case State.InReadContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - case State.InReadElementContent: - // if we have a correct decoder, go read - if (_decoder == _base64Decoder) - { - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - break; - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadElementContent); - - // setup base64 decoder - InitBase64Decoder(); - - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - - internal int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (_reader.NodeType != XmlNodeType.Element) - { - throw _reader.CreateReadElementContentAsException("ReadElementContentAsBinHex"); - } - if (!InitOnElement()) - { - return 0; - } - break; - case State.InReadContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - case State.InReadElementContent: - // if we have a correct decoder, go read - if (_decoder == _binHexDecoder) - { - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - break; - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadElementContent); - - // setup binhex decoder - InitBinHexDecoder(); - - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - - internal void Finish() - { - if (_state != State.None) - { - while (MoveToNextContentNode(true)) - ; - if (_state == State.InReadElementContent) - { - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - // move off the EndElement - _reader.Read(); - } - } - Reset(); - } - - internal void Reset() - { - _state = State.None; - _isEnd = false; - _valueOffset = 0; - } - - // Private methods - private bool Init() - { - // make sure we are on a content node - if (!MoveToNextContentNode(false)) - { - return false; - } - - _state = State.InReadContent; - _isEnd = false; - return true; - } - - private bool InitOnElement() - { - Debug.Assert(_reader.NodeType == XmlNodeType.Element); - bool isEmpty = _reader.IsEmptyElement; - - // move to content or off the empty element - _reader.Read(); - if (isEmpty) - { - return false; - } - - // make sure we are on a content node - if (!MoveToNextContentNode(false)) - { - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - // move off end element - _reader.Read(); - return false; - } - _state = State.InReadElementContent; - _isEnd = false; - return true; - } - - private void InitBase64Decoder() - { - if (_base64Decoder == null) - { - _base64Decoder = new Base64Decoder(); - } - else - { - _base64Decoder.Reset(); - } - _decoder = _base64Decoder; - } - - private void InitBinHexDecoder() - { - if (_binHexDecoder == null) - { - _binHexDecoder = new BinHexDecoder(); - } - else - { - _binHexDecoder.Reset(); - } - _decoder = _binHexDecoder; - } - - private int ReadContentAsBinary(byte[] buffer, int index, int count) - { - Debug.Assert(_decoder != null); - - if (_isEnd) - { - Reset(); - return 0; - } - _decoder.SetNextOutputBuffer(buffer, index, count); - - for (; ; ) - { - // use streaming ReadValueChunk if the reader supports it - if (_canReadValueChunk) - { - for (; ; ) - { - if (_valueOffset < _valueChunkLength) - { - int decodedCharsCount = _decoder.Decode(_valueChunk, _valueOffset, _valueChunkLength - _valueOffset); - _valueOffset += decodedCharsCount; - } - if (_decoder.IsFull) - { - return _decoder.DecodedCount; - } - Debug.Assert(_valueOffset == _valueChunkLength); - if ((_valueChunkLength = _reader.ReadValueChunk(_valueChunk, 0, ChunkSize)) == 0) - { - break; - } - _valueOffset = 0; - } - } - else - { - // read what is reader.Value - string value = _reader.Value; - int decodedCharsCount = _decoder.Decode(value, _valueOffset, value.Length - _valueOffset); - _valueOffset += decodedCharsCount; - - if (_decoder.IsFull) - { - return _decoder.DecodedCount; - } - } - - _valueOffset = 0; - - // move to next textual node in the element content; throw on sub elements - if (!MoveToNextContentNode(true)) - { - _isEnd = true; - return _decoder.DecodedCount; - } - } - } - - private int ReadElementContentAsBinary(byte[] buffer, int index, int count) - { - if (count == 0) - { - return 0; - } - // read binary - int decoded = ReadContentAsBinary(buffer, index, count); - if (decoded > 0) - { - return decoded; - } - - // if 0 bytes returned check if we are on a closing EndElement, throw exception if not - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - - // move off the EndElement - _reader.Read(); - _state = State.None; - return 0; - } - - private bool MoveToNextContentNode(bool moveIfOnContentNode) - { - do - { - switch (_reader.NodeType) - { - case XmlNodeType.Attribute: - return !moveIfOnContentNode; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.CDATA: - if (!moveIfOnContentNode) - { - return true; - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.EndEntity: - // skip comments, pis and end entity nodes - break; - case XmlNodeType.EntityReference: - if (_reader.CanResolveEntity) - { - _reader.ResolveEntity(); - break; - } - goto default; - default: - return false; - } - moveIfOnContentNode = false; - } while (_reader.Read()); - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelperAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelperAsync.cs deleted file mode 100644 index e8b49242972..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadContentAsBinaryHelperAsync.cs +++ /dev/null @@ -1,423 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - internal partial class ReadContentAsBinaryHelper - { - // Internal methods - - internal async Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (!_reader.CanReadContentAs()) - { - throw _reader.CreateReadContentAsException("ReadContentAsBase64"); - } - if (!await InitAsync().ConfigureAwait(false)) - { - return 0; - } - break; - case State.InReadContent: - // if we have a correct decoder, go read - if (_decoder == _base64Decoder) - { - // read more binary data - return await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - break; - case State.InReadElementContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadContent); - - // setup base64 decoder - InitBase64Decoder(); - - // read more binary data - return await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - - internal async Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (!_reader.CanReadContentAs()) - { - throw _reader.CreateReadContentAsException("ReadContentAsBinHex"); - } - if (!await InitAsync().ConfigureAwait(false)) - { - return 0; - } - break; - case State.InReadContent: - // if we have a correct decoder, go read - if (_decoder == _binHexDecoder) - { - // read more binary data - return await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - break; - case State.InReadElementContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadContent); - - // setup binhex decoder - InitBinHexDecoder(); - - // read more binary data - return await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - - internal async Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (_reader.NodeType != XmlNodeType.Element) - { - throw _reader.CreateReadElementContentAsException("ReadElementContentAsBase64"); - } - if (!await InitOnElementAsync().ConfigureAwait(false)) - { - return 0; - } - break; - case State.InReadContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - case State.InReadElementContent: - // if we have a correct decoder, go read - if (_decoder == _base64Decoder) - { - // read more binary data - return await ReadElementContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - break; - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadElementContent); - - // setup base64 decoder - InitBase64Decoder(); - - // read more binary data - return await ReadElementContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - - internal async Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - switch (_state) - { - case State.None: - if (_reader.NodeType != XmlNodeType.Element) - { - throw _reader.CreateReadElementContentAsException("ReadElementContentAsBinHex"); - } - if (!await InitOnElementAsync().ConfigureAwait(false)) - { - return 0; - } - break; - case State.InReadContent: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - case State.InReadElementContent: - // if we have a correct decoder, go read - if (_decoder == _binHexDecoder) - { - // read more binary data - return await ReadElementContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - break; - default: - Debug.Assert(false); - return 0; - } - - Debug.Assert(_state == State.InReadElementContent); - - // setup binhex decoder - InitBinHexDecoder(); - - // read more binary data - return await ReadElementContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - } - - internal async Task FinishAsync() - { - if (_state != State.None) - { - while (await MoveToNextContentNodeAsync(true).ConfigureAwait(false)) - ; - if (_state == State.InReadElementContent) - { - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - // move off the EndElement - await _reader.ReadAsync().ConfigureAwait(false); - } - } - Reset(); - } - - // Private methods - private async Task InitAsync() - { - // make sure we are on a content node - if (!await MoveToNextContentNodeAsync(false).ConfigureAwait(false)) - { - return false; - } - - _state = State.InReadContent; - _isEnd = false; - return true; - } - - private async Task InitOnElementAsync() - { - Debug.Assert(_reader.NodeType == XmlNodeType.Element); - bool isEmpty = _reader.IsEmptyElement; - - // move to content or off the empty element - await _reader.ReadAsync().ConfigureAwait(false); - if (isEmpty) - { - return false; - } - - // make sure we are on a content node - if (!await MoveToNextContentNodeAsync(false).ConfigureAwait(false)) - { - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - // move off end element - await _reader.ReadAsync().ConfigureAwait(false); - return false; - } - _state = State.InReadElementContent; - _isEnd = false; - return true; - } - - private async Task ReadContentAsBinaryAsync(byte[] buffer, int index, int count) - { - Debug.Assert(_decoder != null); - - if (_isEnd) - { - Reset(); - return 0; - } - _decoder.SetNextOutputBuffer(buffer, index, count); - - for (; ; ) - { - // use streaming ReadValueChunk if the reader supports it - if (_canReadValueChunk) - { - for (; ; ) - { - if (_valueOffset < _valueChunkLength) - { - int decodedCharsCount = _decoder.Decode(_valueChunk, _valueOffset, _valueChunkLength - _valueOffset); - _valueOffset += decodedCharsCount; - } - if (_decoder.IsFull) - { - return _decoder.DecodedCount; - } - Debug.Assert(_valueOffset == _valueChunkLength); - if ((_valueChunkLength = await _reader.ReadValueChunkAsync(_valueChunk, 0, ChunkSize).ConfigureAwait(false)) == 0) - { - break; - } - _valueOffset = 0; - } - } - else - { - // read what is reader.Value - string value = await _reader.GetValueAsync().ConfigureAwait(false); - int decodedCharsCount = _decoder.Decode(value, _valueOffset, value.Length - _valueOffset); - _valueOffset += decodedCharsCount; - - if (_decoder.IsFull) - { - return _decoder.DecodedCount; - } - } - - _valueOffset = 0; - - // move to next textual node in the element content; throw on sub elements - if (!await MoveToNextContentNodeAsync(true).ConfigureAwait(false)) - { - _isEnd = true; - return _decoder.DecodedCount; - } - } - } - - private async Task ReadElementContentAsBinaryAsync(byte[] buffer, int index, int count) - { - if (count == 0) - { - return 0; - } - // read binary - int decoded = await ReadContentAsBinaryAsync(buffer, index, count).ConfigureAwait(false); - if (decoded > 0) - { - return decoded; - } - - // if 0 bytes returned check if we are on a closing EndElement, throw exception if not - if (_reader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _reader.NodeType.ToString(), _reader as IXmlLineInfo); - } - - // move off the EndElement - await _reader.ReadAsync().ConfigureAwait(false); - _state = State.None; - return 0; - } - - private async Task MoveToNextContentNodeAsync(bool moveIfOnContentNode) - { - do - { - switch (_reader.NodeType) - { - case XmlNodeType.Attribute: - return !moveIfOnContentNode; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.CDATA: - if (!moveIfOnContentNode) - { - return true; - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.EndEntity: - // skip comments, pis and end entity nodes - break; - case XmlNodeType.EntityReference: - if (_reader.CanResolveEntity) - { - _reader.ResolveEntity(); - break; - } - goto default; - default: - return false; - } - moveIfOnContentNode = false; - } while (await _reader.ReadAsync().ConfigureAwait(false)); - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadOnlyTernaryTree.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadOnlyTernaryTree.cs deleted file mode 100644 index 2748ac52aa0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadOnlyTernaryTree.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - - // Array index to indicate the meaning of the each byte. - internal enum TernaryTreeByte { characterByte = 0, leftTree = 1, rightTree = 2, data = 3 }; - - // - // XSL HTML output method properties - // - // Keep the first four bits in sync, so that the element and attribute mask operation can be combined. - internal enum ElementProperties : uint { DEFAULT = 0, URI_PARENT = 1, BOOL_PARENT = 2, NAME_PARENT = 4, EMPTY = 8, NO_ENTITIES = 16, HEAD = 32, BLOCK_WS = 64, HAS_NS = 128 } - internal enum AttributeProperties : uint { DEFAULT = 0, URI = 1, BOOLEAN = 2, NAME = 4 } - - - /** - * TernaryTreeRO - * ------------- - * - * Ternary tree implementation used to make fast dictionary lookups in pre-generated - * ternary trees. - * - * Note: Only strings composed of ASCII characters can exist in the tree. - */ - /// - internal class TernaryTreeReadOnly - { - private byte[] _nodeBuffer; - - //define the array positions - - - /// - public TernaryTreeReadOnly(byte[] nodeBuffer) - { - _nodeBuffer = nodeBuffer; - } - - /* ---------------------------------------------------------------------------- - findStringI() - - Find a Unicode string in the ternary tree and return the data byte it's - mapped to. Find is case-insensitive. - */ - /// - public byte FindCaseInsensitiveString(String stringToFind) - { - //Debug.Assert(wszFind != null && wszFind.Length != 0); - - int stringPos = 0, nodePos = 0; - int charToFind, charInTheTree; - byte[] node = _nodeBuffer; - - charToFind = stringToFind[stringPos]; - - if (charToFind > 'z') return 0; // Ternary tree only stores ASCII strings - if (charToFind >= 'a') charToFind -= ('a' - 'A'); // Normalize to upper case - - while (true) - { - int pos = nodePos * 4; - - charInTheTree = node[pos + (int)TernaryTreeByte.characterByte]; - //Console.WriteLine("charToFind: {0},charInTheTree: {1}, nodePos: {2}", charToFind, charInTheTree, nodePos); - - if (charToFind < charInTheTree) - { - // If input character is less than the tree character, take the left branch - if (node[pos + (int)TernaryTreeByte.leftTree] == 0x0) - { - break; - } - nodePos = nodePos + node[pos + (int)TernaryTreeByte.leftTree]; - } - else if (charToFind > charInTheTree) - { - // If input character is greater than the tree character, take the right branch - if (node[pos + (int)TernaryTreeByte.rightTree] == 0x0) - break; - nodePos = nodePos + node[pos + (int)TernaryTreeByte.rightTree]; - } - else - { - // If input character is equal to the tree character, take the equal branch - if (charToFind == 0) - return node[pos + (int)TernaryTreeByte.data]; - - // The offset for the equal branch is always one - ++nodePos; - - // Move to the next input character - ++stringPos; - if (stringPos == stringToFind.Length) - { - charToFind = 0; - } - else - { - charToFind = stringToFind[stringPos]; - if (charToFind > 'z') return 0; // Ternary tree only stores ASCII strings - if (charToFind >= 'a') charToFind -= ('a' - 'A'); // Normalize to upper case - } - } - } - - // Return default - return 0; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadState.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadState.cs deleted file mode 100644 index 0bbb2785fe6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ReadState.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // Specifies the state of the XmlReader. - public enum ReadState - { - // The Read method has not been called yet. - Initial = 0, - - // Reading is in progress. - Interactive = 1, - - // An error occurred that prevents the XmlReader from continuing. - Error = 2, - - // The end of the stream has been reached successfully. - EndOfFile = 3, - - // The Close method has been called and the XmlReader is closed. - Closed = 4 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/SecureStringHasher.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/SecureStringHasher.cs deleted file mode 100644 index 870b5728e4d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/SecureStringHasher.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Security; - -namespace Microsoft.Xml -{ - // SecureStringHasher is a hash code provider for strings. The hash codes calculation starts with a seed (hasCodeRandomizer) which is usually - // different for each instance of SecureStringHasher. Since the hash code depend on the seed, the chance of hashtable DoS attack in case when - // someone passes in lots of strings that hash to the same hash code is greatly reduced. - // The SecureStringHasher implements IEqualityComparer for strings and therefore can be used in generic IDictionary. - internal class SecureStringHasher : IEqualityComparer - { - [SecurityCritical] - private delegate int HashCodeOfStringDelegate3(string s, int sLen, long additionalEntropy); - - [SecurityCritical] - private delegate int HashCodeOfStringDelegate1(string s); - - // Value is guaranteed to be null by the spec. - // No explicit assignment because it will require adding SecurityCritical on .cctor - // which could hurt the performance - [SecurityCritical] - private static HashCodeOfStringDelegate3 s_hashCodeDelegate3; - - [SecurityCritical] - private static HashCodeOfStringDelegate1 s_hashCodeDelegate1; - - private int _hashCodeRandomizer; - - public SecureStringHasher() - { - _hashCodeRandomizer = Environment.TickCount; - } - -#if false // This is here only for debugging of hashing issues - public SecureStringHasher( int hashCodeRandomizer ) { - this.hashCodeRandomizer = hashCodeRandomizer; - } -#endif - internal static SecureStringHasher Instance { get; } = new SecureStringHasher(); - - public bool Equals(String x, String y) - { - return String.Equals(x, y, StringComparison.Ordinal); - } - - [SecuritySafeCritical] - public int GetHashCode(String key) - { - if (s_hashCodeDelegate1 == null && s_hashCodeDelegate3 == null) - { - GetHashCodeDelegate(); - } - - if (s_hashCodeDelegate1 != null) - { - return s_hashCodeDelegate1(key); - } - - return s_hashCodeDelegate3(key, key.Length, _hashCodeRandomizer); - } - - [SecurityCritical] - private static int GetHashCodeOfString(string key, int sLen, long additionalEntropy) - { - int hashCode = unchecked((int)additionalEntropy); - // use key.Length to eliminate the rangecheck - for (int i = 0; i < key.Length; i++) - { - hashCode += (hashCode << 7) ^ key[i]; - } - // mix it a bit more - hashCode -= hashCode >> 17; - hashCode -= hashCode >> 11; - hashCode -= hashCode >> 5; - return hashCode; - } - - [SecuritySafeCritical] - private void GetHashCodeDelegate() - { - // If we find the Marvin hash method, we use that - // Otherwise, we use the old string hashing function. - // The Marvin hash method signature changed in netcore 2.1-pre to have a single argument and apparently was removed in 2.1 RTM. - // Note: calling Type.GetMethod with the exact param types does not always work, need to get the method info and check the parameters. - - MethodInfo getHashCodeMethodInfo = typeof(String).GetMethod("InternalMarvin32HashString", BindingFlags.NonPublic | BindingFlags.Static); - if (getHashCodeMethodInfo != null) - { - ParameterInfo[] paramTypes = getHashCodeMethodInfo.GetParameters(); - if (paramTypes.Length == 1 && paramTypes[0].ParameterType == typeof(string)) - { - s_hashCodeDelegate1 = (HashCodeOfStringDelegate1)getHashCodeMethodInfo.CreateDelegate(typeof(HashCodeOfStringDelegate1)); - } - else if (paramTypes.Length == 3 && paramTypes[0].ParameterType == typeof(string) && paramTypes[1].ParameterType == typeof(int) && paramTypes[2].ParameterType == typeof(long)) - { - s_hashCodeDelegate3 = (HashCodeOfStringDelegate3)getHashCodeMethodInfo.CreateDelegate(typeof(HashCodeOfStringDelegate3)); - } - } - - if (s_hashCodeDelegate1 == null && s_hashCodeDelegate3 == null) - { - // This will fall through and return a delegate to the old hash function - s_hashCodeDelegate3 = new HashCodeOfStringDelegate3(GetHashCodeOfString); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextEncodedRawTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextEncodedRawTextWriter.cs deleted file mode 100644 index 28a27689b1a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextEncodedRawTextWriter.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -//using Microsoft.Xml.Query; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - // Concrete implementation of XmlRawWriter interface that serializes text events as encoded - // text. All other non-text events are ignored. The general-purpose TextEncodedRawTextWriter uses the - // Encoder class to output to any encoding. The TextUtf8RawTextWriter class combined the encoding - // operation with serialization in order to achieve better performance. - // - internal class TextEncodedRawTextWriter : XmlEncodedRawTextWriter - { - // Construct an instance of this class that outputs text to the TextWriter interface. - public TextEncodedRawTextWriter(TextWriter writer, XmlWriterSettings settings) : base(writer, settings) - { - } - - - // Construct an instance of this class that serializes to a Stream interface. - public TextEncodedRawTextWriter(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - } - - - // - // XmlRawWriter - // - // Ignore Xml declaration - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - } - internal override void WriteXmlDeclaration(string xmldecl) - { - } - - // Ignore DTD - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - } - - // Ignore Elements - public override void WriteStartElement(string prefix, string localName, string ns) - { - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - } - - internal override void StartElementContent() - { - } - - // Ignore attributes - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - base.inAttributeValue = true; - } - - public override void WriteEndAttribute() - { - base.inAttributeValue = false; - } - - // Ignore namespace declarations - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return false; - } - } - - // Output content of CDATA sections as plain text without escaping - public override void WriteCData(string text) - { - base.WriteRaw(text); - } - - // Ignore comments - public override void WriteComment(string text) - { - } - - // Ignore processing instructions - public override void WriteProcessingInstruction(string name, string text) - { - } - - // Ignore entities - public override void WriteEntityRef(string name) - { - } - public override void WriteCharEntity(char ch) - { - } - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - } - - // Output text content without any escaping; ignore attribute values - public override void WriteWhitespace(string ws) - { - if (!base.inAttributeValue) - { - base.WriteRaw(ws); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteString(string textBlock) - { - if (!base.inAttributeValue) - { - base.WriteRaw(textBlock); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteChars(char[] buffer, int index, int count) - { - if (!base.inAttributeValue) - { - base.WriteRaw(buffer, index, count); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw(char[] buffer, int index, int count) - { - if (!base.inAttributeValue) - { - base.WriteRaw(buffer, index, count); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw(string data) - { - if (!base.inAttributeValue) - { - base.WriteRaw(data); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextRawTextWriterGenerator.cxxbak b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextRawTextWriterGenerator.cxxbak deleted file mode 100644 index 7a9525179d1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextRawTextWriterGenerator.cxxbak +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifdef _UTF8_TEXT_WRITER -#define _CLASS_NAME TextUtf8RawTextWriter -#define _BASE_CLASS_NAME XmlUtf8RawTextWriter -#endif - -#ifdef _ENCODED_TEXT_WRITER -#define _CLASS_NAME TextEncodedRawTextWriter -#define _BASE_CLASS_NAME XmlEncodedRawTextWriter -#endif - -using System; -using System.IO; -using System.Text; -//using Microsoft.Xml.Query; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml { - // Concrete implementation of XmlRawWriter interface that serializes text events as encoded - // text. All other non-text events are ignored. The general-purpose TextEncodedRawTextWriter uses the - // Encoder class to output to any encoding. The TextUtf8RawTextWriter class combined the encoding - // operation with serialization in order to achieve better performance. - // - internal class _CLASS_NAME : _BASE_CLASS_NAME { - -#ifdef _ENCODED_TEXT_WRITER - // Construct an instance of this class that outputs text to the TextWriter interface. - public _CLASS_NAME( TextWriter writer, XmlWriterSettings settings ) : base ( writer, settings ) { - } -#endif - - // Construct an instance of this class that serializes to a Stream interface. - public _CLASS_NAME( Stream stream, XmlWriterSettings settings ) : base( stream, settings ) { - } - - -// -// XmlRawWriter -// - // Ignore Xml declaration - internal override void WriteXmlDeclaration( XmlStandalone standalone ) { - } - internal override void WriteXmlDeclaration( string xmldecl ) { - } - - // Ignore DTD - public override void WriteDocType( string name, string pubid, string sysid, string subset ) { - } - - // Ignore Elements - public override void WriteStartElement( string prefix, string localName, string ns ) { - } - - internal override void WriteEndElement( string prefix, string localName, string ns ) { - } - - internal override void WriteFullEndElement( string prefix, string localName, string ns ) { - } - - internal override void StartElementContent() { - } - - // Ignore attributes - public override void WriteStartAttribute( string prefix, string localName, string ns ) { - base.inAttributeValue = true; - } - - public override void WriteEndAttribute() { - base.inAttributeValue = false; - } - - // Ignore namespace declarations - internal override void WriteNamespaceDeclaration( string prefix, string ns ) { - } - - internal override bool SupportsNamespaceDeclarationInChunks { - get { - return false; - } - } - - // Output content of CDATA sections as plain text without escaping - public override void WriteCData( string text ) { - base.WriteRaw( text ); - } - - // Ignore comments - public override void WriteComment( string text ) { - } - - // Ignore processing instructions - public override void WriteProcessingInstruction( string name, string text ) { - } - - // Ignore entities - public override void WriteEntityRef( string name ) { - } - public override void WriteCharEntity( char ch ) { - } - public override void WriteSurrogateCharEntity( char lowChar, char highChar ) { - } - - // Output text content without any escaping; ignore attribute values - public override void WriteWhitespace( string ws ) { - if ( !base.inAttributeValue ) { - base.WriteRaw( ws ); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteString( string textBlock ) { - if ( !base.inAttributeValue ) { - base.WriteRaw( textBlock ); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteChars( char[] buffer, int index, int count ) { - if ( !base.inAttributeValue ) { - base.WriteRaw( buffer, index, count ); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw( char[] buffer, int index, int count ) { - if ( !base.inAttributeValue ) { - base.WriteRaw( buffer, index, count ); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw( string data ) { - if ( !base.inAttributeValue ) { - base.WriteRaw( data ); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextUtf8RawTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextUtf8RawTextWriter.cs deleted file mode 100644 index ff2e2f3c6f3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/TextUtf8RawTextWriter.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -//using Microsoft.Xml.Query; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - // Concrete implementation of XmlRawWriter interface that serializes text events as encoded - // text. All other non-text events are ignored. The general-purpose TextEncodedRawTextWriter uses the - // Encoder class to output to any encoding. The TextUtf8RawTextWriter class combined the encoding - // operation with serialization in order to achieve better performance. - // - internal class TextUtf8RawTextWriter : XmlUtf8RawTextWriter - { - // Construct an instance of this class that serializes to a Stream interface. - public TextUtf8RawTextWriter(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - } - - - // - // XmlRawWriter - // - // Ignore Xml declaration - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - } - internal override void WriteXmlDeclaration(string xmldecl) - { - } - - // Ignore DTD - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - } - - // Ignore Elements - public override void WriteStartElement(string prefix, string localName, string ns) - { - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - } - - internal override void StartElementContent() - { - } - - // Ignore attributes - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - base.inAttributeValue = true; - } - - public override void WriteEndAttribute() - { - base.inAttributeValue = false; - } - - // Ignore namespace declarations - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return false; - } - } - - // Output content of CDATA sections as plain text without escaping - public override void WriteCData(string text) - { - base.WriteRaw(text); - } - - // Ignore comments - public override void WriteComment(string text) - { - } - - // Ignore processing instructions - public override void WriteProcessingInstruction(string name, string text) - { - } - - // Ignore entities - public override void WriteEntityRef(string name) - { - } - public override void WriteCharEntity(char ch) - { - } - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - } - - // Output text content without any escaping; ignore attribute values - public override void WriteWhitespace(string ws) - { - if (!base.inAttributeValue) - { - base.WriteRaw(ws); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteString(string textBlock) - { - if (!base.inAttributeValue) - { - base.WriteRaw(textBlock); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteChars(char[] buffer, int index, int count) - { - if (!base.inAttributeValue) - { - base.WriteRaw(buffer, index, count); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw(char[] buffer, int index, int count) - { - if (!base.inAttributeValue) - { - base.WriteRaw(buffer, index, count); - } - } - - // Output text content without any escaping; ignore attribute values - public override void WriteRaw(string data) - { - if (!base.inAttributeValue) - { - base.WriteRaw(data); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidatingReaderNodeData.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidatingReaderNodeData.cs deleted file mode 100644 index acd3a3053cc..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidatingReaderNodeData.cs +++ /dev/null @@ -1,238 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using System.Collections; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - internal class ValidatingReaderNodeData - { - private string _localName; - private string _namespaceUri; - private string _prefix; - private string _nameWPrefix; - - private string _rawValue; - private string _originalStringValue; // Original value - private int _depth; - private AttributePSVIInfo _attributePSVIInfo; //Used only for default attributes - private XmlNodeType _nodeType; - - private int _lineNo; - private int _linePos; - - public ValidatingReaderNodeData() - { - Clear(XmlNodeType.None); - } - - public ValidatingReaderNodeData(XmlNodeType nodeType) - { - Clear(nodeType); - } - - public string LocalName - { - get - { - return _localName; - } - set - { - _localName = value; - } - } - - public string Namespace - { - get - { - return _namespaceUri; - } - set - { - _namespaceUri = value; - } - } - - public string Prefix - { - get - { - return _prefix; - } - set - { - _prefix = value; - } - } - - public string GetAtomizedNameWPrefix(XmlNameTable nameTable) - { - if (_nameWPrefix == null) - { - if (_prefix.Length == 0) - { - _nameWPrefix = _localName; - } - else - { - _nameWPrefix = nameTable.Add(string.Concat(_prefix, ":", _localName)); - } - } - return _nameWPrefix; - } - - public int Depth - { - get - { - return _depth; - } - set - { - _depth = value; - } - } - - public string RawValue - { - get - { - return _rawValue; - } - set - { - _rawValue = value; - } - } - - public string OriginalStringValue - { - get - { - return _originalStringValue; - } - set - { - _originalStringValue = value; - } - } - - public XmlNodeType NodeType - { - get - { - return _nodeType; - } - set - { - _nodeType = value; - } - } - - public AttributePSVIInfo AttInfo - { - get - { - return _attributePSVIInfo; - } - set - { - _attributePSVIInfo = value; - } - } - - public int LineNumber - { - get - { - return _lineNo; - } - } - - public int LinePosition - { - get - { - return _linePos; - } - } - - internal void Clear(XmlNodeType nodeType) - { - _nodeType = nodeType; - _localName = string.Empty; - _prefix = string.Empty; - _namespaceUri = string.Empty; - _rawValue = string.Empty; - if (_attributePSVIInfo != null) - { - _attributePSVIInfo.Reset(); - } - _nameWPrefix = null; - _lineNo = 0; - _linePos = 0; - } - - internal void ClearName() - { - _localName = string.Empty; - _prefix = string.Empty; - _namespaceUri = string.Empty; - } - - internal void SetLineInfo(int lineNo, int linePos) - { - _lineNo = lineNo; - _linePos = linePos; - } - - internal void SetLineInfo(IXmlLineInfo lineInfo) - { - if (lineInfo != null) - { - _lineNo = lineInfo.LineNumber; - _linePos = lineInfo.LinePosition; - } - } - - internal void SetItemData(string localName, string prefix, string ns, string value) - { - _localName = localName; - _prefix = prefix; - _namespaceUri = ns; - _rawValue = value; - } - - internal void SetItemData(string localName, string prefix, string ns, int depth) - { - _localName = localName; - _prefix = prefix; - _namespaceUri = ns; - _depth = depth; - _rawValue = string.Empty; - } - - internal void SetItemData(string value) - { - SetItemData(value, value); - } - - internal void SetItemData(string value, string originalStringValue) - { - _rawValue = value; - _originalStringValue = originalStringValue; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidationType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidationType.cs deleted file mode 100644 index 94494b269d5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/ValidationType.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // Specifies the type of validation to perform in XmlValidatingReader or in XmlReaderSettings. - public enum ValidationType - { - // No validation will be performed. - None, - - // In XmlValidatingReader ValidationType.Auto does the following: - // 1) If there is no DTD or schema, it will parse the XML without validation. - // 2) If there is a DTD defined in a declaration, it will load the DTD and - // process the DTD declarations such that default attributes and general entities will - // be made available. General entities are only loaded and parsed if they are used (expanded). - // 3) If there is no declaration but there is an XSD "schemaLocation" attribute, - // it will load and process those XSD schemas and it will return any default attributes defined in those schemas. - // 4) If there is no declaration and no XSD "schemaLocation" attribute but there are some namespaces - // using the MSXML "x-schema:" URN prefix, it will load and process those schemas and it will return any default - // attributes defined in those schemas. - [Obsolete("Validation type should be specified as DTD or Schema.")] - Auto, - - // Validate according to DTD. - DTD, - - // Validate according to XDR. - [Obsolete("XDR Validation through XmlValidatingReader is obsoleted")] - XDR, - - // Validate according to W3C XSD schemas, including inline schemas. An error is returned if both XDR and XSD schemas - // are referenced from the same document. - Schema - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/WhiteSpaceHandling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/WhiteSpaceHandling.cs deleted file mode 100644 index def753fdab9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/WhiteSpaceHandling.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // Specifies how whitespace is handled in XmlTextReader. - public enum WhitespaceHandling - { - // Return all Whitespace and SignificantWhitespace nodes. This is the default. - All = 0, - - // Return just SignificantWhitespace, i.e. whitespace nodes that are in scope of xml:space="preserve" - Significant = 1, - - // Do not return any Whitespace or SignificantWhitespace nodes. - None = 2 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAsyncCheckReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAsyncCheckReader.cs deleted file mode 100644 index 18fec09e031..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAsyncCheckReader.cs +++ /dev/null @@ -1,1103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - - internal class XmlAsyncCheckReader : XmlReader - { - private readonly XmlReader _coreReader = null; - private Task _lastTask = AsyncHelper.DoneTask; - - internal XmlReader CoreReader - { - get - { - return _coreReader; - } - } - - public static XmlAsyncCheckReader CreateAsyncCheckWrapper(XmlReader reader) - { - if (reader is IXmlLineInfo) - { - if (reader is IXmlNamespaceResolver) - { -#if !FEATURE_NETCORE - if (reader is IXmlSchemaInfo) - { - return new XmlAsyncCheckReaderWithLineInfoNSSchema(reader); - } -#endif // !FEATURE_NETCORE - return new XmlAsyncCheckReaderWithLineInfoNS(reader); - } -#if !FEATURE_NETCORE - Debug.Assert(!(reader is IXmlSchemaInfo)); -#endif // !FEATURE_NETCORE - return new XmlAsyncCheckReaderWithLineInfo(reader); - } - else if (reader is IXmlNamespaceResolver) - { -#if !FEATURE_NETCORE - Debug.Assert(!(reader is IXmlSchemaInfo)); -#endif // !FEATURE_NETCORE - return new XmlAsyncCheckReaderWithNS(reader); - } -#if !FEATURE_NETCORE - Debug.Assert(!(reader is IXmlSchemaInfo)); -#endif // !FEATURE_NETCORE - return new XmlAsyncCheckReader(reader); - } - - public XmlAsyncCheckReader(XmlReader reader) - { - _coreReader = reader; - } - - private void CheckAsync() - { - if (!_lastTask.IsCompleted) - { - throw new InvalidOperationException(ResXml.Xml_AsyncIsRunningException); - } - } - - #region Sync Methods, Properties Check - - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings = _coreReader.Settings; - if (null != settings) - { - settings = settings.Clone(); - } - else - { - settings = new XmlReaderSettings(); - } - - settings.ReadOnly = true; - return settings; - } - } - - public override XmlNodeType NodeType - { - get - { - CheckAsync(); - return _coreReader.NodeType; - } - } - - public override string Name - { - get - { - CheckAsync(); - return _coreReader.Name; - } - } - - public override string LocalName - { - get - { - CheckAsync(); - return _coreReader.LocalName; - } - } - - public override string NamespaceURI - { - get - { - CheckAsync(); - return _coreReader.NamespaceURI; - } - } - - public override string Prefix - { - get - { - CheckAsync(); - return _coreReader.Prefix; - } - } - - public override bool HasValue - { - get - { - CheckAsync(); - return _coreReader.HasValue; - } - } - - public override string Value - { - get - { - CheckAsync(); - return _coreReader.Value; - } - } - - public override int Depth - { - get - { - CheckAsync(); - return _coreReader.Depth; - } - } - - public override string BaseURI - { - get - { - CheckAsync(); - return _coreReader.BaseURI; - } - } - - public override bool IsEmptyElement - { - get - { - CheckAsync(); - return _coreReader.IsEmptyElement; - } - } - - public override bool IsDefault - { - get - { - CheckAsync(); - return _coreReader.IsDefault; - } - } - - public override char QuoteChar - { - get - { - CheckAsync(); - return _coreReader.QuoteChar; - } - } - - public override XmlSpace XmlSpace - { - get - { - CheckAsync(); - return _coreReader.XmlSpace; - } - } - - public override string XmlLang - { - get - { - CheckAsync(); - return _coreReader.XmlLang; - } - } - -#if !FEATURE_NETCORE - public override IXmlSchemaInfo SchemaInfo - { - get - { - CheckAsync(); - return _coreReader.SchemaInfo; - } - } -#endif // !FEATURE_NETCORE - - public override System.Type ValueType - { - get - { - CheckAsync(); - return _coreReader.ValueType; - } - } - - public override object ReadContentAsObject() - { - CheckAsync(); - return _coreReader.ReadContentAsObject(); - } - - public override bool ReadContentAsBoolean() - { - CheckAsync(); - return _coreReader.ReadContentAsBoolean(); - } - - public override DateTime ReadContentAsDateTime() - { - CheckAsync(); - return _coreReader.ReadContentAsDateTime(); - } - - public override double ReadContentAsDouble() - { - CheckAsync(); - return _coreReader.ReadContentAsDouble(); - } - - public override float ReadContentAsFloat() - { - CheckAsync(); - return _coreReader.ReadContentAsFloat(); - } - - public override decimal ReadContentAsDecimal() - { - CheckAsync(); - return _coreReader.ReadContentAsDecimal(); - } - - public override int ReadContentAsInt() - { - CheckAsync(); - return _coreReader.ReadContentAsInt(); - } - - public override long ReadContentAsLong() - { - CheckAsync(); - return _coreReader.ReadContentAsLong(); - } - - public override string ReadContentAsString() - { - CheckAsync(); - return _coreReader.ReadContentAsString(); - } - - public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - CheckAsync(); - return _coreReader.ReadContentAs(returnType, namespaceResolver); - } - - public override object ReadElementContentAsObject() - { - CheckAsync(); - return _coreReader.ReadElementContentAsObject(); - } - - public override object ReadElementContentAsObject(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsObject(localName, namespaceURI); - } - - public override bool ReadElementContentAsBoolean() - { - CheckAsync(); - return _coreReader.ReadElementContentAsBoolean(); - } - - public override bool ReadElementContentAsBoolean(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsBoolean(localName, namespaceURI); - } - - public override DateTime ReadElementContentAsDateTime() - { - CheckAsync(); - return _coreReader.ReadElementContentAsDateTime(); - } - - public override DateTime ReadElementContentAsDateTime(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsDateTime(localName, namespaceURI); - } - - public override DateTimeOffset ReadContentAsDateTimeOffset() - { - CheckAsync(); - return _coreReader.ReadContentAsDateTimeOffset(); - } - - public override double ReadElementContentAsDouble() - { - CheckAsync(); - return _coreReader.ReadElementContentAsDouble(); - } - - public override double ReadElementContentAsDouble(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsDouble(localName, namespaceURI); - } - - public override float ReadElementContentAsFloat() - { - CheckAsync(); - return _coreReader.ReadElementContentAsFloat(); - } - - public override float ReadElementContentAsFloat(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsFloat(localName, namespaceURI); - } - - public override decimal ReadElementContentAsDecimal() - { - CheckAsync(); - return _coreReader.ReadElementContentAsDecimal(); - } - - public override decimal ReadElementContentAsDecimal(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsDecimal(localName, namespaceURI); - } - - public override int ReadElementContentAsInt() - { - CheckAsync(); - return _coreReader.ReadElementContentAsInt(); - } - - public override int ReadElementContentAsInt(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsInt(localName, namespaceURI); - } - - public override long ReadElementContentAsLong() - { - CheckAsync(); - return _coreReader.ReadElementContentAsLong(); - } - - public override long ReadElementContentAsLong(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsLong(localName, namespaceURI); - } - - public override string ReadElementContentAsString() - { - CheckAsync(); - return _coreReader.ReadElementContentAsString(); - } - - public override string ReadElementContentAsString(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAsString(localName, namespaceURI); - } - - public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - CheckAsync(); - return _coreReader.ReadElementContentAs(returnType, namespaceResolver); - } - - public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadElementContentAs(returnType, namespaceResolver, localName, namespaceURI); - } - - public override int AttributeCount - { - get - { - CheckAsync(); - return _coreReader.AttributeCount; - } - } - - public override string GetAttribute(string name) - { - CheckAsync(); - return _coreReader.GetAttribute(name); - } - - public override string GetAttribute(string name, string namespaceURI) - { - CheckAsync(); - return _coreReader.GetAttribute(name, namespaceURI); - } - - public override string GetAttribute(int i) - { - CheckAsync(); - return _coreReader.GetAttribute(i); - } - - public override string this[int i] - { - get - { - CheckAsync(); - return _coreReader[i]; - } - } - - public override string this[string name] - { - get - { - CheckAsync(); - return _coreReader[name]; - } - } - - public override string this[string name, string namespaceURI] - { - get - { - CheckAsync(); - return _coreReader[name, namespaceURI]; - } - } - - public override bool MoveToAttribute(string name) - { - CheckAsync(); - return _coreReader.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string name, string ns) - { - CheckAsync(); - return _coreReader.MoveToAttribute(name, ns); - } - - public override void MoveToAttribute(int i) - { - CheckAsync(); - _coreReader.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - CheckAsync(); - return _coreReader.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - CheckAsync(); - return _coreReader.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - CheckAsync(); - return _coreReader.MoveToElement(); - } - - public override bool ReadAttributeValue() - { - CheckAsync(); - return _coreReader.ReadAttributeValue(); - } - - public override bool Read() - { - CheckAsync(); - return _coreReader.Read(); - } - - public override bool EOF - { - get - { - CheckAsync(); - return _coreReader.EOF; - } - } - - public override void Close() - { - CheckAsync(); - _coreReader.Close(); - } - - public override ReadState ReadState - { - get - { - CheckAsync(); - return _coreReader.ReadState; - } - } - - public override void Skip() - { - CheckAsync(); - _coreReader.Skip(); - } - - public override XmlNameTable NameTable - { - get - { - CheckAsync(); - return _coreReader.NameTable; - } - } - - public override string LookupNamespace(string prefix) - { - CheckAsync(); - return _coreReader.LookupNamespace(prefix); - } - - public override bool CanResolveEntity - { - get - { - CheckAsync(); - return _coreReader.CanResolveEntity; - } - } - - public override void ResolveEntity() - { - CheckAsync(); - _coreReader.ResolveEntity(); - } - - public override bool CanReadBinaryContent - { - get - { - CheckAsync(); - return _coreReader.CanReadBinaryContent; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - CheckAsync(); - return _coreReader.ReadContentAsBase64(buffer, index, count); - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - CheckAsync(); - return _coreReader.ReadElementContentAsBase64(buffer, index, count); - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - CheckAsync(); - return _coreReader.ReadContentAsBinHex(buffer, index, count); - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - CheckAsync(); - return _coreReader.ReadElementContentAsBinHex(buffer, index, count); - } - - public override bool CanReadValueChunk - { - get - { - CheckAsync(); - return _coreReader.CanReadValueChunk; - } - } - - public override int ReadValueChunk(char[] buffer, int index, int count) - { - CheckAsync(); - return _coreReader.ReadValueChunk(buffer, index, count); - } - - public override string ReadString() - { - CheckAsync(); - return _coreReader.ReadString(); - } - - public override XmlNodeType MoveToContent() - { - CheckAsync(); - return _coreReader.MoveToContent(); - } - - public override void ReadStartElement() - { - CheckAsync(); - _coreReader.ReadStartElement(); - } - - public override void ReadStartElement(string name) - { - CheckAsync(); - _coreReader.ReadStartElement(name); - } - - public override void ReadStartElement(string localname, string ns) - { - CheckAsync(); - _coreReader.ReadStartElement(localname, ns); - } - - public override string ReadElementString() - { - CheckAsync(); - return _coreReader.ReadElementString(); - } - - public override string ReadElementString(string name) - { - CheckAsync(); - return _coreReader.ReadElementString(name); - } - - public override string ReadElementString(string localname, string ns) - { - CheckAsync(); - return _coreReader.ReadElementString(localname, ns); - } - - public override void ReadEndElement() - { - CheckAsync(); - _coreReader.ReadEndElement(); - } - - public override bool IsStartElement() - { - CheckAsync(); - return _coreReader.IsStartElement(); - } - - public override bool IsStartElement(string name) - { - CheckAsync(); - return _coreReader.IsStartElement(name); - } - - public override bool IsStartElement(string localname, string ns) - { - CheckAsync(); - return _coreReader.IsStartElement(localname, ns); - } - - public override bool ReadToFollowing(string name) - { - CheckAsync(); - return _coreReader.ReadToFollowing(name); - } - - public override bool ReadToFollowing(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadToFollowing(localName, namespaceURI); - } - - public override bool ReadToDescendant(string name) - { - CheckAsync(); - return _coreReader.ReadToDescendant(name); - } - - public override bool ReadToDescendant(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadToDescendant(localName, namespaceURI); - } - - public override bool ReadToNextSibling(string name) - { - CheckAsync(); - return _coreReader.ReadToNextSibling(name); - } - - public override bool ReadToNextSibling(string localName, string namespaceURI) - { - CheckAsync(); - return _coreReader.ReadToNextSibling(localName, namespaceURI); - } - - public override string ReadInnerXml() - { - CheckAsync(); - return _coreReader.ReadInnerXml(); - } - - public override string ReadOuterXml() - { - CheckAsync(); - return _coreReader.ReadOuterXml(); - } - - public override XmlReader ReadSubtree() - { - CheckAsync(); - XmlReader subtreeReader = _coreReader.ReadSubtree(); - return CreateAsyncCheckWrapper(subtreeReader); - } - - public override bool HasAttributes - { - get - { - CheckAsync(); - return _coreReader.HasAttributes; - } - } - - protected override void Dispose(bool disposing) - { - CheckAsync(); - //since it is protected method, we can't call coreReader.Dispose(disposing). - //Internal, it is always called to Dipose(true). So call coreReader.Dispose() is OK. - _coreReader.Dispose(); - } - - internal override XmlNamespaceManager NamespaceManager - { - get - { - CheckAsync(); - return _coreReader.NamespaceManager; - } - } - - internal override IDtdInfo DtdInfo - { - get - { - CheckAsync(); - return _coreReader.DtdInfo; - } - } - - #endregion - - #region Async Methods - - public override Task GetValueAsync() - { - CheckAsync(); - var task = _coreReader.GetValueAsync(); - _lastTask = task; - return task; - } - - public override Task ReadContentAsObjectAsync() - { - CheckAsync(); - var task = _coreReader.ReadContentAsObjectAsync(); - _lastTask = task; - return task; - } - - public override Task ReadContentAsStringAsync() - { - CheckAsync(); - var task = _coreReader.ReadContentAsStringAsync(); - _lastTask = task; - return task; - } - - public override Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - CheckAsync(); - var task = _coreReader.ReadContentAsAsync(returnType, namespaceResolver); - _lastTask = task; - return task; - } - - public override Task ReadElementContentAsObjectAsync() - { - CheckAsync(); - var task = _coreReader.ReadElementContentAsObjectAsync(); - _lastTask = task; - return task; - } - - public override Task ReadElementContentAsStringAsync() - { - CheckAsync(); - var task = _coreReader.ReadElementContentAsStringAsync(); - _lastTask = task; - return task; - } - - public override Task ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - CheckAsync(); - var task = _coreReader.ReadElementContentAsAsync(returnType, namespaceResolver); - _lastTask = task; - return task; - } - - public override Task ReadAsync() - { - CheckAsync(); - var task = _coreReader.ReadAsync(); - _lastTask = task; - return task; - } - - public override Task SkipAsync() - { - CheckAsync(); - var task = _coreReader.SkipAsync(); - _lastTask = task; - return task; - } - - public override Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - CheckAsync(); - var task = _coreReader.ReadContentAsBase64Async(buffer, index, count); - _lastTask = task; - return task; - } - - public override Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - CheckAsync(); - var task = _coreReader.ReadElementContentAsBase64Async(buffer, index, count); - _lastTask = task; - return task; - } - - public override Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - CheckAsync(); - var task = _coreReader.ReadContentAsBinHexAsync(buffer, index, count); - _lastTask = task; - return task; - } - - public override Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - CheckAsync(); - var task = _coreReader.ReadElementContentAsBinHexAsync(buffer, index, count); - _lastTask = task; - return task; - } - - public override Task ReadValueChunkAsync(char[] buffer, int index, int count) - { - CheckAsync(); - var task = _coreReader.ReadValueChunkAsync(buffer, index, count); - _lastTask = task; - return task; - } - - public override Task MoveToContentAsync() - { - CheckAsync(); - var task = _coreReader.MoveToContentAsync(); - _lastTask = task; - return task; - } - - public override Task ReadInnerXmlAsync() - { - CheckAsync(); - var task = _coreReader.ReadInnerXmlAsync(); - _lastTask = task; - return task; - } - - public override Task ReadOuterXmlAsync() - { - CheckAsync(); - var task = _coreReader.ReadOuterXmlAsync(); - _lastTask = task; - return task; - } - - #endregion - } - - internal class XmlAsyncCheckReaderWithNS : XmlAsyncCheckReader, IXmlNamespaceResolver - { - private readonly IXmlNamespaceResolver _readerAsIXmlNamespaceResolver; - - public XmlAsyncCheckReaderWithNS(XmlReader reader) - : base(reader) - { - _readerAsIXmlNamespaceResolver = (IXmlNamespaceResolver)reader; - } - - #region IXmlNamespaceResolver members - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _readerAsIXmlNamespaceResolver.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName); - } - #endregion - } - - internal class XmlAsyncCheckReaderWithLineInfo : XmlAsyncCheckReader, IXmlLineInfo - { - private readonly IXmlLineInfo _readerAsIXmlLineInfo; - - public XmlAsyncCheckReaderWithLineInfo(XmlReader reader) - : base(reader) - { - _readerAsIXmlLineInfo = (IXmlLineInfo)reader; - } - - #region IXmlLineInfo members - public virtual bool HasLineInfo() - { - return _readerAsIXmlLineInfo.HasLineInfo(); - } - - public virtual int LineNumber - { - get - { - return _readerAsIXmlLineInfo.LineNumber; - } - } - - public virtual int LinePosition - { - get - { - return _readerAsIXmlLineInfo.LinePosition; - } - } - #endregion - } - - internal class XmlAsyncCheckReaderWithLineInfoNS : XmlAsyncCheckReaderWithLineInfo, IXmlNamespaceResolver - { - private readonly IXmlNamespaceResolver _readerAsIXmlNamespaceResolver; - - public XmlAsyncCheckReaderWithLineInfoNS(XmlReader reader) - : base(reader) - { - _readerAsIXmlNamespaceResolver = (IXmlNamespaceResolver)reader; - } - - #region IXmlNamespaceResolver members - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _readerAsIXmlNamespaceResolver.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName); - } - #endregion - } - -#if !FEATURE_NETCORE - internal class XmlAsyncCheckReaderWithLineInfoNSSchema : XmlAsyncCheckReaderWithLineInfoNS, IXmlSchemaInfo - { - private readonly IXmlSchemaInfo _readerAsIXmlSchemaInfo; - - public XmlAsyncCheckReaderWithLineInfoNSSchema(XmlReader reader) - : base(reader) - { - _readerAsIXmlSchemaInfo = (IXmlSchemaInfo)reader; - } - - - #region IXmlSchemaInfo members - - XmlSchemaValidity IXmlSchemaInfo.Validity - { - get - { - return _readerAsIXmlSchemaInfo.Validity; - } - } - - bool IXmlSchemaInfo.IsDefault - { - get - { - return _readerAsIXmlSchemaInfo.IsDefault; - } - } - - bool IXmlSchemaInfo.IsNil - { - get - { - return _readerAsIXmlSchemaInfo.IsNil; - } - } - - XmlSchemaSimpleType IXmlSchemaInfo.MemberType - { - get - { - return _readerAsIXmlSchemaInfo.MemberType; - } - } - - XmlSchemaType IXmlSchemaInfo.SchemaType - { - get - { - return _readerAsIXmlSchemaInfo.SchemaType; - } - } - - XmlSchemaElement IXmlSchemaInfo.SchemaElement - { - get - { - return _readerAsIXmlSchemaInfo.SchemaElement; - } - } - - XmlSchemaAttribute IXmlSchemaInfo.SchemaAttribute - { - get - { - return _readerAsIXmlSchemaInfo.SchemaAttribute; - } - } - #endregion - } -#endif // !FEATURE_NETCORE -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAutoDetectWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAutoDetectWriter.cs deleted file mode 100644 index 6c287bc0cee..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlAutoDetectWriter.cs +++ /dev/null @@ -1,440 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml -{ - using System; - using System.Diagnostics; - using System.IO; - using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - - - /// - /// This writer implements XmlOutputMethod.AutoDetect. If the first element is "html", then output will be - /// directed to an Html writer. Otherwise, output will be directed to an Xml writer. - /// - internal class XmlAutoDetectWriter : XmlRawWriter, IRemovableWriter - { - private XmlRawWriter _wrapped; - private OnRemoveWriter _onRemove; - private XmlWriterSettings _writerSettings; - private XmlEventCache _eventCache; // Cache up events until first StartElement is encountered - private TextWriter _textWriter; - private Stream _strm; - - //----------------------------------------------- - // Constructors - //----------------------------------------------- - - private XmlAutoDetectWriter(XmlWriterSettings writerSettings) - { - Debug.Assert(writerSettings.OutputMethod == XmlOutputMethod.AutoDetect); - - _writerSettings = (XmlWriterSettings)writerSettings.Clone(); - _writerSettings.ReadOnly = true; - - // Start caching all events - _eventCache = new XmlEventCache(string.Empty, true); - } - - public XmlAutoDetectWriter(TextWriter textWriter, XmlWriterSettings writerSettings) - : this(writerSettings) - { - _textWriter = textWriter; - } - - public XmlAutoDetectWriter(Stream strm, XmlWriterSettings writerSettings) - : this(writerSettings) - { - _strm = strm; - } - - - //----------------------------------------------- - // IRemovableWriter interface - //----------------------------------------------- - - /// - /// This writer will raise this event once it has determined whether to replace itself with the Html or Xml writer. - /// - public OnRemoveWriter OnRemoveWriterEvent - { - get { return _onRemove; } - set { _onRemove = value; } - } - - - //----------------------------------------------- - // XmlWriter interface - //----------------------------------------------- - - public override XmlWriterSettings Settings - { - get { return _writerSettings; } - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - if (_wrapped == null) - { - // This is the first time WriteStartElement has been called, so create the Xml or Html writer - if (ns.Length == 0 && IsHtmlTag(localName)) - CreateWrappedWriter(XmlOutputMethod.Html); - else - CreateWrappedWriter(XmlOutputMethod.Xml); - } - _wrapped.WriteStartElement(prefix, localName, ns); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteEndAttribute() - { - Debug.Assert(_wrapped != null); - _wrapped.WriteEndAttribute(); - } - - public override void WriteCData(string text) - { - if (TextBlockCreatesWriter(text)) - _wrapped.WriteCData(text); - else - _eventCache.WriteCData(text); - } - - public override void WriteComment(string text) - { - if (_wrapped == null) - _eventCache.WriteComment(text); - else - _wrapped.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - if (_wrapped == null) - _eventCache.WriteProcessingInstruction(name, text); - else - _wrapped.WriteProcessingInstruction(name, text); - } - - public override void WriteWhitespace(string ws) - { - if (_wrapped == null) - _eventCache.WriteWhitespace(ws); - else - _wrapped.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - if (TextBlockCreatesWriter(text)) - _wrapped.WriteString(text); - else - _eventCache.WriteString(text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - WriteRaw(new string(buffer, index, count)); - } - - public override void WriteRaw(string data) - { - if (TextBlockCreatesWriter(data)) - _wrapped.WriteRaw(data); - else - _eventCache.WriteRaw(data); - } - - public override void WriteEntityRef(string name) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteCharEntity(ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteBase64(buffer, index, count); - } - - public override void WriteBinHex(byte[] buffer, int index, int count) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteBinHex(buffer, index, count); - } - - public override void Close() - { - // Flush any cached events to an Xml writer - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.Close(); - } - - public override void Flush() - { - // Flush any cached events to an Xml writer - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.Flush(); - } - - public override void WriteValue(object value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(string value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(bool value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(DateTime value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(DateTimeOffset value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(double value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(float value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(decimal value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(int value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - public override void WriteValue(long value) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteValue(value); - } - - //----------------------------------------------- - // XmlRawWriter interface - //----------------------------------------------- - - internal override IXmlNamespaceResolver NamespaceResolver - { - get - { - return this.resolver; - } - set - { - this.resolver = value; - - if (_wrapped == null) - _eventCache.NamespaceResolver = value; - else - _wrapped.NamespaceResolver = value; - } - } - - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - // Forces xml writer to be created - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteXmlDeclaration(standalone); - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - // Forces xml writer to be created - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteXmlDeclaration(xmldecl); - } - - internal override void StartElementContent() - { - Debug.Assert(_wrapped != null); - _wrapped.StartElementContent(); - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - Debug.Assert(_wrapped != null); - _wrapped.WriteEndElement(prefix, localName, ns); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - Debug.Assert(_wrapped != null); - _wrapped.WriteFullEndElement(prefix, localName, ns); - } - - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteNamespaceDeclaration(prefix, ns); - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return _wrapped.SupportsNamespaceDeclarationInChunks; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) - { - EnsureWrappedWriter(XmlOutputMethod.Xml); - _wrapped.WriteStartNamespaceDeclaration(prefix); - } - - internal override void WriteEndNamespaceDeclaration() - { - _wrapped.WriteEndNamespaceDeclaration(); - } - - //----------------------------------------------- - // Helper methods - //----------------------------------------------- - - /// - /// Return true if "tagName" == "html" (case-insensitive). - /// - private static bool IsHtmlTag(string tagName) - { - if (tagName.Length != 4) - return false; - - if (tagName[0] != 'H' && tagName[0] != 'h') - return false; - - if (tagName[1] != 'T' && tagName[1] != 't') - return false; - - if (tagName[2] != 'M' && tagName[2] != 'm') - return false; - - if (tagName[3] != 'L' && tagName[3] != 'l') - return false; - - return true; - } - - /// - /// If a wrapped writer has not yet been created, create one. - /// - private void EnsureWrappedWriter(XmlOutputMethod outMethod) - { - if (_wrapped == null) - CreateWrappedWriter(outMethod); - } - - /// - /// If the specified text consist only of whitespace, then cache the whitespace, as it is not enough to - /// force the creation of a wrapped writer. Otherwise, create a wrapped writer if one has not yet been - /// created and return true. - /// - private bool TextBlockCreatesWriter(string textBlock) - { - if (_wrapped == null) - { - // Whitespace-only text blocks aren't enough to determine Xml vs. Html - if (XmlCharType.Instance.IsOnlyWhitespace(textBlock)) - { - return false; - } - - // Non-whitespace text block selects Xml method - CreateWrappedWriter(XmlOutputMethod.Xml); - } - - return true; - } - - /// - /// Create either the Html or Xml writer and send any cached events to it. - /// - private void CreateWrappedWriter(XmlOutputMethod outMethod) - { - Debug.Assert(_wrapped == null); - - // Create either the Xml or Html writer - _writerSettings.ReadOnly = false; - _writerSettings.OutputMethod = outMethod; - - // If Indent was not set by the user, then default to True for Html - if (outMethod == XmlOutputMethod.Html && _writerSettings.IndentInternal == TriState.Unknown) - _writerSettings.Indent = true; - - _writerSettings.ReadOnly = true; - - if (_textWriter != null) - _wrapped = ((XmlWellFormedWriter)XmlWriter.Create(_textWriter, _writerSettings)).RawWriter; - else - _wrapped = ((XmlWellFormedWriter)XmlWriter.Create(_strm, _writerSettings)).RawWriter; - - // Send cached events to the new writer - _eventCache.EndEvents(); - _eventCache.EventsToWriter(_wrapped); - - // Send OnRemoveWriter event - if (_onRemove != null) - (this._onRemove)(_wrapped); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReader.cs deleted file mode 100644 index f83fef1a75e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReader.cs +++ /dev/null @@ -1,706 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - // - // XmlCharCheckingReaderWithNS - // - internal partial class XmlCharCheckingReader : XmlWrappingReader - { - // - // Private types - // - private enum State - { - Initial, - InReadBinary, - Error, - Interactive, // Interactive means other than ReadState.Initial and ReadState.Error; still needs to call - // underlying XmlReader to find out if the reported ReadState should be Interactive or EndOfFile - // NOTE: There is no Closed state here, which is a cause of bugs SQL BU Defect Tracking #533397 and #530403. They were resolved as Won't Fix because they are breaking changes. - }; - - // - // Fields - // - private State _state; - - // settings - private bool _checkCharacters; - private bool _ignoreWhitespace; - private bool _ignoreComments; - private bool _ignorePis; - private DtdProcessing _dtdProcessing; // -1 means do nothing - - private XmlNodeType _lastNodeType; - private XmlCharType _xmlCharType; - - private ReadContentAsBinaryHelper _readBinaryHelper; - - // - // Constructor - // - internal XmlCharCheckingReader(XmlReader reader, bool checkCharacters, bool ignoreWhitespace, bool ignoreComments, bool ignorePis, DtdProcessing dtdProcessing) - : base(reader) - { - Debug.Assert(checkCharacters || ignoreWhitespace || ignoreComments || ignorePis || (int)dtdProcessing != -1); - - _state = State.Initial; - - _checkCharacters = checkCharacters; - _ignoreWhitespace = ignoreWhitespace; - _ignoreComments = ignoreComments; - _ignorePis = ignorePis; - _dtdProcessing = dtdProcessing; - - _lastNodeType = XmlNodeType.None; - - if (checkCharacters) - { - _xmlCharType = XmlCharType.Instance; - } - } - - // - // XmlReader implementation - // - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings = reader.Settings; - if (settings == null) - { - settings = new XmlReaderSettings(); - } - else - { - settings = settings.Clone(); - } - - if (_checkCharacters) - { - settings.CheckCharacters = true; - } - if (_ignoreWhitespace) - { - settings.IgnoreWhitespace = true; - } - if (_ignoreComments) - { - settings.IgnoreComments = true; - } - if (_ignorePis) - { - settings.IgnoreProcessingInstructions = true; - } - if ((int)_dtdProcessing != -1) - { - settings.DtdProcessing = _dtdProcessing; - } - settings.ReadOnly = true; - return settings; - } - } - - public override bool MoveToAttribute(string name) - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string name, string ns) - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.MoveToAttribute(name, ns); - } - - public override void MoveToAttribute(int i) - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - base.reader.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.MoveToElement(); - } - - public override bool Read() - { - switch (_state) - { - case State.Initial: - _state = State.Interactive; - if (base.reader.ReadState == ReadState.Initial) - { - goto case State.Interactive; - } - break; - - case State.Error: - return false; - - case State.InReadBinary: - FinishReadBinary(); - _state = State.Interactive; - goto case State.Interactive; - - case State.Interactive: - if (!base.reader.Read()) - { - return false; - } - break; - - default: - Debug.Assert(false); - return false; - } - - XmlNodeType nodeType = base.reader.NodeType; - - if (!_checkCharacters) - { - switch (nodeType) - { - case XmlNodeType.Comment: - if (_ignoreComments) - { - return Read(); - } - break; - case XmlNodeType.Whitespace: - if (_ignoreWhitespace) - { - return Read(); - } - break; - case XmlNodeType.ProcessingInstruction: - if (_ignorePis) - { - return Read(); - } - break; - case XmlNodeType.DocumentType: - if (_dtdProcessing == DtdProcessing.Prohibit) - { - Throw(ResXml.Xml_DtdIsProhibitedEx, string.Empty); - } - else if (_dtdProcessing == DtdProcessing.Ignore) - { - return Read(); - } - break; - } - return true; - } - else - { - switch (nodeType) - { - case XmlNodeType.Element: - if (_checkCharacters) - { - // check element name - ValidateQName(base.reader.Prefix, base.reader.LocalName); - - // check values of attributes - if (base.reader.MoveToFirstAttribute()) - { - do - { - ValidateQName(base.reader.Prefix, base.reader.LocalName); - CheckCharacters(base.reader.Value); - } while (base.reader.MoveToNextAttribute()); - - base.reader.MoveToElement(); - } - } - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - if (_checkCharacters) - { - CheckCharacters(base.reader.Value); - } - break; - - case XmlNodeType.EntityReference: - if (_checkCharacters) - { - // check name - ValidateQName(base.reader.Name); - } - break; - - case XmlNodeType.ProcessingInstruction: - if (_ignorePis) - { - return Read(); - } - if (_checkCharacters) - { - ValidateQName(base.reader.Name); - CheckCharacters(base.reader.Value); - } - break; - - case XmlNodeType.Comment: - if (_ignoreComments) - { - return Read(); - } - if (_checkCharacters) - { - CheckCharacters(base.reader.Value); - } - break; - - case XmlNodeType.DocumentType: - if (_dtdProcessing == DtdProcessing.Prohibit) - { - Throw(ResXml.Xml_DtdIsProhibitedEx, string.Empty); - } - else if (_dtdProcessing == DtdProcessing.Ignore) - { - return Read(); - } - if (_checkCharacters) - { - ValidateQName(base.reader.Name); - CheckCharacters(base.reader.Value); - - string str; - str = base.reader.GetAttribute("SYSTEM"); - if (str != null) - { - CheckCharacters(str); - } - - str = base.reader.GetAttribute("PUBLIC"); - if (str != null) - { - int i; - if ((i = _xmlCharType.IsPublicId(str)) >= 0) - { - Throw(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(str, i)); - } - } - } - break; - - case XmlNodeType.Whitespace: - if (_ignoreWhitespace) - { - return Read(); - } - if (_checkCharacters) - { - CheckWhitespace(base.reader.Value); - } - break; - - case XmlNodeType.SignificantWhitespace: - if (_checkCharacters) - { - CheckWhitespace(base.reader.Value); - } - break; - - case XmlNodeType.EndElement: - if (_checkCharacters) - { - ValidateQName(base.reader.Prefix, base.reader.LocalName); - } - break; - - default: - break; - } - _lastNodeType = nodeType; - return true; - } - } - - public override ReadState ReadState - { - get - { - switch (_state) - { - case State.Initial: - return base.reader.ReadState == ReadState.Closed ? ReadState.Closed : ReadState.Initial; - case State.Error: - return ReadState.Error; - case State.InReadBinary: - case State.Interactive: - default: - return base.reader.ReadState; - } - } - } - - public override bool ReadAttributeValue() - { - if (_state == State.InReadBinary) - { - FinishReadBinary(); - } - return base.reader.ReadAttributeValue(); - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBase64Chunk calls into the base (wrapped) reader if possible, i.e. if it can read binary and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return base.ReadContentAsBase64(buffer, index, count); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return base.ReadContentAsBase64(buffer, index, count); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return base.ReadContentAsBinHex(buffer, index, count); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return base.ReadContentAsBinHex(buffer, index, count); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBase64Chunk calls into the base (wrapped) reader if possible, i.e. if it can read binary and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return base.ReadElementContentAsBase64(buffer, index, count); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return base.ReadElementContentAsBase64(buffer, index, count); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return base.ReadElementContentAsBinHex(buffer, index, count); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return base.ReadElementContentAsBinHex(buffer, index, count); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - // - // Private methods and properties - // - - private void Throw(string res, string arg) - { - _state = State.Error; - throw new XmlException(res, arg, (IXmlLineInfo)null); - } - - private void Throw(string res, string[] args) - { - _state = State.Error; - throw new XmlException(res, args, (IXmlLineInfo)null); - } - - private void CheckWhitespace(string value) - { - int i; - if ((i = _xmlCharType.IsOnlyWhitespaceWithPos(value)) != -1) - { - Throw(ResXml.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(value, i)); - } - } - - private void ValidateQName(string name) - { - string prefix, localName; - ValidateNames.ParseQNameThrow(name, out prefix, out localName); - } - - private void ValidateQName(string prefix, string localName) - { - try - { - if (prefix.Length > 0) - { - ValidateNames.ParseNCNameThrow(prefix); - } - ValidateNames.ParseNCNameThrow(localName); - } - catch - { - _state = State.Error; - throw; - } - } - - private void CheckCharacters(string value) - { - XmlConvert.VerifyCharData(value, ExceptionType.ArgumentException, ExceptionType.XmlException); - } - - private void FinishReadBinary() - { - _state = State.Interactive; - if (_readBinaryHelper != null) - { - _readBinaryHelper.Finish(); - } - } - } - - // - // XmlCharCheckingReaderWithNS - // - internal class XmlCharCheckingReaderWithNS : XmlCharCheckingReader, IXmlNamespaceResolver - { - internal IXmlNamespaceResolver readerAsNSResolver; - - internal XmlCharCheckingReaderWithNS(XmlReader reader, IXmlNamespaceResolver readerAsNSResolver, bool checkCharacters, bool ignoreWhitespace, bool ignoreComments, bool ignorePis, DtdProcessing dtdProcessing) - : base(reader, checkCharacters, ignoreWhitespace, ignoreComments, ignorePis, dtdProcessing) - { - Debug.Assert(readerAsNSResolver != null); - this.readerAsNSResolver = readerAsNSResolver; - } - // - // IXmlNamespaceResolver - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return readerAsNSResolver.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return readerAsNSResolver.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return readerAsNSResolver.LookupPrefix(namespaceName); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReaderAsync.cs deleted file mode 100644 index 48bf3abaf27..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingReaderAsync.cs +++ /dev/null @@ -1,437 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - // - // XmlCharCheckingReaderWithNS - // - internal partial class XmlCharCheckingReader : XmlWrappingReader - { - public override async Task ReadAsync() - { - switch (_state) - { - case State.Initial: - _state = State.Interactive; - if (base.reader.ReadState == ReadState.Initial) - { - goto case State.Interactive; - } - break; - - case State.Error: - return false; - - case State.InReadBinary: - await FinishReadBinaryAsync().ConfigureAwait(false); - _state = State.Interactive; - goto case State.Interactive; - - case State.Interactive: - if (!await base.reader.ReadAsync().ConfigureAwait(false)) - { - return false; - } - break; - - default: - Debug.Assert(false); - return false; - } - - XmlNodeType nodeType = base.reader.NodeType; - - if (!_checkCharacters) - { - switch (nodeType) - { - case XmlNodeType.Comment: - if (_ignoreComments) - { - return await ReadAsync().ConfigureAwait(false); - } - break; - case XmlNodeType.Whitespace: - if (_ignoreWhitespace) - { - return await ReadAsync().ConfigureAwait(false); - } - break; - case XmlNodeType.ProcessingInstruction: - if (_ignorePis) - { - return await ReadAsync().ConfigureAwait(false); - } - break; - case XmlNodeType.DocumentType: - if (_dtdProcessing == DtdProcessing.Prohibit) - { - Throw(ResXml.Xml_DtdIsProhibitedEx, string.Empty); - } - else if (_dtdProcessing == DtdProcessing.Ignore) - { - return await ReadAsync().ConfigureAwait(false); - } - break; - } - return true; - } - else - { - switch (nodeType) - { - case XmlNodeType.Element: - if (_checkCharacters) - { - // check element name - ValidateQName(base.reader.Prefix, base.reader.LocalName); - - // check values of attributes - if (base.reader.MoveToFirstAttribute()) - { - do - { - ValidateQName(base.reader.Prefix, base.reader.LocalName); - CheckCharacters(base.reader.Value); - } while (base.reader.MoveToNextAttribute()); - - base.reader.MoveToElement(); - } - } - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - if (_checkCharacters) - { - CheckCharacters(await base.reader.GetValueAsync().ConfigureAwait(false)); - } - break; - - case XmlNodeType.EntityReference: - if (_checkCharacters) - { - // check name - ValidateQName(base.reader.Name); - } - break; - - case XmlNodeType.ProcessingInstruction: - if (_ignorePis) - { - return await ReadAsync().ConfigureAwait(false); - } - if (_checkCharacters) - { - ValidateQName(base.reader.Name); - CheckCharacters(base.reader.Value); - } - break; - - case XmlNodeType.Comment: - if (_ignoreComments) - { - return await ReadAsync().ConfigureAwait(false); - } - if (_checkCharacters) - { - CheckCharacters(base.reader.Value); - } - break; - - case XmlNodeType.DocumentType: - if (_dtdProcessing == DtdProcessing.Prohibit) - { - Throw(ResXml.Xml_DtdIsProhibitedEx, string.Empty); - } - else if (_dtdProcessing == DtdProcessing.Ignore) - { - return await ReadAsync().ConfigureAwait(false); - } - if (_checkCharacters) - { - ValidateQName(base.reader.Name); - CheckCharacters(base.reader.Value); - - string str; - str = base.reader.GetAttribute("SYSTEM"); - if (str != null) - { - CheckCharacters(str); - } - - str = base.reader.GetAttribute("PUBLIC"); - if (str != null) - { - int i; - if ((i = _xmlCharType.IsPublicId(str)) >= 0) - { - Throw(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(str, i)); - } - } - } - break; - - case XmlNodeType.Whitespace: - if (_ignoreWhitespace) - { - return await ReadAsync().ConfigureAwait(false); - } - if (_checkCharacters) - { - CheckWhitespace(await base.reader.GetValueAsync().ConfigureAwait(false)); - } - break; - - case XmlNodeType.SignificantWhitespace: - if (_checkCharacters) - { - CheckWhitespace(await base.reader.GetValueAsync().ConfigureAwait(false)); - } - break; - - case XmlNodeType.EndElement: - if (_checkCharacters) - { - ValidateQName(base.reader.Prefix, base.reader.LocalName); - } - break; - - default: - break; - } - _lastNodeType = nodeType; - return true; - } - } - - public override async Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBase64Chunk calls into the base (wrapped) reader if possible, i.e. if it can read binary and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return await base.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return await base.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = await _readBinaryHelper.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override async Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return await base.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return await base.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = await _readBinaryHelper.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override async Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBase64Chunk calls into the base (wrapped) reader if possible, i.e. if it can read binary and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return await base.ReadElementContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return await base.ReadElementContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = await _readBinaryHelper.ReadElementContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - public override async Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - if (ReadState != ReadState.Interactive) - { - return 0; - } - - if (_state != State.InReadBinary) - { - // forward ReadBinHexChunk calls into the base (wrapped) reader if possible, i.e. if it can read chunks and we - // should not check characters - if (base.CanReadBinaryContent && (!_checkCharacters)) - { - _readBinaryHelper = null; - _state = State.InReadBinary; - return await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - } - // the wrapped reader cannot read chunks or we are on an element where we should check characters or ignore white spaces - else - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - } - else - { - // forward calls into wrapped reader - if (_readBinaryHelper == null) - { - return await base.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - } - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = State.Interactive; - - // call to the helper - int readCount = await _readBinaryHelper.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - - // turn on InReadBinary in again and return - _state = State.InReadBinary; - return readCount; - } - - private async Task FinishReadBinaryAsync() - { - _state = State.Interactive; - if (_readBinaryHelper != null) - { - await _readBinaryHelper.FinishAsync().ConfigureAwait(false); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingWriter.cs deleted file mode 100644 index cdaece9492c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlCharCheckingWriter.cs +++ /dev/null @@ -1,592 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - - - - - - - - - - - - - - - - - - - - - - - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; - - - - - - -namespace Microsoft.Xml -{ - using System; - - - // - // XmlCharCheckingWriter - // - internal partial class XmlCharCheckingWriter : XmlWrappingWriter - { - // - // Fields - // - private bool _checkValues; - private bool _checkNames; - private bool _replaceNewLines; - private string _newLineChars; - - private XmlCharType _xmlCharType; - // - // Constructor - // - internal XmlCharCheckingWriter(XmlWriter baseWriter, bool checkValues, bool checkNames, bool replaceNewLines, string newLineChars) - : base(baseWriter) - { - Debug.Assert(checkValues || replaceNewLines); - _checkValues = checkValues; - _checkNames = checkNames; - _replaceNewLines = replaceNewLines; - _newLineChars = newLineChars; - - if (checkValues) - { - _xmlCharType = XmlCharType.Instance; - } - } - - // - // XmlWriter implementation - // - - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings s = base.writer.Settings; - s = (s != null) ? (XmlWriterSettings)s.Clone() : new XmlWriterSettings(); - - if (_checkValues) - { - s.CheckCharacters = true; - } - if (_replaceNewLines) - { - s.NewLineHandling = NewLineHandling.Replace; - s.NewLineChars = _newLineChars; - } - s.ReadOnly = true; - return s; - } - } - - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - if (_checkNames) - { - ValidateQName(name); - } - if (_checkValues) - { - if (pubid != null) - { - int i; - if ((i = _xmlCharType.IsPublicId(pubid)) >= 0) - { - throw XmlConvert.CreateInvalidCharException(pubid, i); - } - } - if (sysid != null) - { - CheckCharacters(sysid); - } - if (subset != null) - { - CheckCharacters(subset); - } - } - if (_replaceNewLines) - { - sysid = ReplaceNewLines(sysid); - pubid = ReplaceNewLines(pubid); - subset = ReplaceNewLines(subset); - } - writer.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - if (_checkNames) - { - if (localName == null || localName.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyLocalName); - } - ValidateNCName(localName); - - if (prefix != null && prefix.Length > 0) - { - ValidateNCName(prefix); - } - } - writer.WriteStartElement(prefix, localName, ns); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - if (_checkNames) - { - if (localName == null || localName.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyLocalName); - } - ValidateNCName(localName); - - if (prefix != null && prefix.Length > 0) - { - ValidateNCName(prefix); - } - } - writer.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteCData(string text) - { - if (text != null) - { - if (_checkValues) - { - CheckCharacters(text); - } - if (_replaceNewLines) - { - text = ReplaceNewLines(text); - } - int i; - while ((i = text.IndexOf("]]>", StringComparison.Ordinal)) >= 0) - { - writer.WriteCData(text.Substring(0, i + 2)); - text = text.Substring(i + 2); - } - } - writer.WriteCData(text); - } - - public override void WriteComment(string text) - { - if (text != null) - { - if (_checkValues) - { - CheckCharacters(text); - text = InterleaveInvalidChars(text, '-', '-'); - } - if (_replaceNewLines) - { - text = ReplaceNewLines(text); - } - } - writer.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - if (_checkNames) - { - ValidateNCName(name); - } - if (text != null) - { - if (_checkValues) - { - CheckCharacters(text); - text = InterleaveInvalidChars(text, '?', '>'); - } - if (_replaceNewLines) - { - text = ReplaceNewLines(text); - } - } - writer.WriteProcessingInstruction(name, text); - } - - public override void WriteEntityRef(string name) - { - if (_checkNames) - { - ValidateQName(name); - } - writer.WriteEntityRef(name); - } - - public override void WriteWhitespace(string ws) - { - if (ws == null) - { - ws = string.Empty; - } - // "checkNames" is intentional here; if false, the whitespaces are checked in XmlWellformedWriter - if (_checkNames) - { - int i; - if ((i = _xmlCharType.IsOnlyWhitespaceWithPos(ws)) != -1) - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(ws, i))); - } - } - if (_replaceNewLines) - { - ws = ReplaceNewLines(ws); - } - writer.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - if (text != null) - { - if (_checkValues) - { - CheckCharacters(text); - } - if (_replaceNewLines && WriteState != WriteState.Attribute) - { - text = ReplaceNewLines(text); - } - } - writer.WriteString(text); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - writer.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (_checkValues) - { - CheckCharacters(buffer, index, count); - } - if (_replaceNewLines && WriteState != WriteState.Attribute) - { - string text = ReplaceNewLines(buffer, index, count); - if (text != null) - { - WriteString(text); - return; - } - } - writer.WriteChars(buffer, index, count); - } - - public override void WriteNmToken(string name) - { - if (_checkNames) - { - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - XmlConvert.VerifyNMTOKEN(name); - } - writer.WriteNmToken(name); - } - - public override void WriteName(string name) - { - if (_checkNames) - { - XmlConvert.VerifyQName(name, ExceptionType.XmlException); - } - writer.WriteName(name); - } - - public override void WriteQualifiedName(string localName, string ns) - { - if (_checkNames) - { - ValidateNCName(localName); - } - writer.WriteQualifiedName(localName, ns); - } - - - // - // Private methods - // - private void CheckCharacters(string str) - { - XmlConvert.VerifyCharData(str, ExceptionType.ArgumentException); - } - - private void CheckCharacters(char[] data, int offset, int len) - { - XmlConvert.VerifyCharData(data, offset, len, ExceptionType.ArgumentException); - } - - private void ValidateNCName(string ncname) - { - if (ncname.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - int len = ValidateNames.ParseNCName(ncname, 0); - if (len != ncname.Length) - { - throw new ArgumentException(string.Format(len == 0 ? ResXml.Xml_BadStartNameChar : ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(ncname, len))); - } - } - - private void ValidateQName(string name) - { - if (name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - int colonPos; - int len = ValidateNames.ParseQName(name, 0, out colonPos); - if (len != name.Length) - { - string res = (len == 0 || (colonPos > -1 && len == colonPos + 1)) ? ResXml.Xml_BadStartNameChar : ResXml.Xml_BadNameChar; - throw new ArgumentException(string.Format(res, XmlException.BuildCharExceptionArgs(name, len))); - } - } - - private string ReplaceNewLines(string str) - { - if (str == null) - { - return null; - } - - StringBuilder sb = null; - int start = 0; - int i; - for (i = 0; i < str.Length; i++) - { - char ch; - if ((ch = str[i]) >= 0x20) - { - continue; - } - if (ch == '\n') - { - if (_newLineChars == "\n") - { - continue; - } - if (sb == null) - { - sb = new StringBuilder(str.Length + 5); - } - sb.Append(str, start, i - start); - } - else if (ch == '\r') - { - if (i + 1 < str.Length && str[i + 1] == '\n') - { - if (_newLineChars == "\r\n") - { - i++; - continue; - } - if (sb == null) - { - sb = new StringBuilder(str.Length + 5); - } - sb.Append(str, start, i - start); - i++; - } - else - { - if (_newLineChars == "\r") - { - continue; - } - if (sb == null) - { - sb = new StringBuilder(str.Length + 5); - } - sb.Append(str, start, i - start); - } - } - else - { - continue; - } - sb.Append(_newLineChars); - start = i + 1; - } - - if (sb == null) - { - return str; - } - else - { - sb.Append(str, start, i - start); - return sb.ToString(); - } - } - - private string ReplaceNewLines(char[] data, int offset, int len) - { - if (data == null) - { - return null; - } - - StringBuilder sb = null; - int start = offset; - int endPos = offset + len; - int i; - for (i = offset; i < endPos; i++) - { - char ch; - if ((ch = data[i]) >= 0x20) - { - continue; - } - if (ch == '\n') - { - if (_newLineChars == "\n") - { - continue; - } - if (sb == null) - { - sb = new StringBuilder(len + 5); - } - sb.Append(data, start, i - start); - } - else if (ch == '\r') - { - if (i + 1 < endPos && data[i + 1] == '\n') - { - if (_newLineChars == "\r\n") - { - i++; - continue; - } - if (sb == null) - { - sb = new StringBuilder(len + 5); - } - sb.Append(data, start, i - start); - i++; - } - else - { - if (_newLineChars == "\r") - { - continue; - } - if (sb == null) - { - sb = new StringBuilder(len + 5); - } - sb.Append(data, start, i - start); - } - } - else - { - continue; - } - sb.Append(_newLineChars); - start = i + 1; - } - - if (sb == null) - { - return null; - } - else - { - sb.Append(data, start, i - start); - return sb.ToString(); - } - } - - // Interleave 2 adjacent invalid chars with a space. This is used for fixing invalid values of comments and PIs. - // Any "--" in comment must be replaced with "- -" and any "-" at the end must be appended with " ". - // Any "?>" in PI value must be replaced with "? >". - // This code has a bug SQL BU Defect Tracking #480848, which was triaged as Won't Fix because it is a breaking change - private string InterleaveInvalidChars(string text, char invChar1, char invChar2) - { - StringBuilder sb = null; - int start = 0; - int i; - for (i = 0; i < text.Length; i++) - { - if (text[i] != invChar2) - { - continue; - } - if (i > 0 && text[i - 1] == invChar1) - { - if (sb == null) - { - sb = new StringBuilder(text.Length + 5); - } - sb.Append(text, start, i - start); - sb.Append(' '); - start = i; - } - } - - // check last char & return - if (sb == null) - { - return (i == 0 || text[i - 1] != invChar1) ? text : (text + ' '); - } - else - { - sb.Append(text, start, i - start); - if (i > 0 && text[i - 1] == invChar1) - { - sb.Append(' '); - } - return sb.ToString(); - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlConfiguration.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlConfiguration.cs deleted file mode 100644 index 7d7532627c7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlConfiguration.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -// using System.Configuration; -using System.Globalization; -using Microsoft.Xml; - -namespace Microsoft.Xml.XmlConfiguration -{ - internal static class XmlConfigurationString - { - internal const string XmlReaderSectionName = "xmlReader"; - internal const string XsltSectionName = "xslt"; - - internal const string ProhibitDefaultResolverName = "prohibitDefaultResolver"; - internal const string LimitXPathComplexityName = "limitXPathComplexity"; - internal const string EnableMemberAccessForXslCompiledTransformName = "enableMemberAccessForXslCompiledTransform"; - - internal const string XmlConfigurationSectionName = "system.xml"; - - internal static string XmlReaderSectionPath = string.Format(CultureInfo.InvariantCulture, @"{0}/{1}", XmlConfigurationSectionName, XmlReaderSectionName); - internal static string XsltSectionPath = string.Format(CultureInfo.InvariantCulture, @"{0}/{1}", XmlConfigurationSectionName, XsltSectionName); - } - - public sealed class XmlReaderSection - { - internal static XmlResolver CreateDefaultResolver() - { - return new XmlUrlResolver(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEncodedRawTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEncodedRawTextWriter.cs deleted file mode 100644 index d93659055ad..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEncodedRawTextWriter.cs +++ /dev/null @@ -1,2046 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -// WARNING: This file is generated and should not be modified directly. Instead, -// modify XmlTextWriterGenerator.cxx and run gen.bat in the same directory. -// This batch file will execute the following commands: -// -// cl.exe /C /EP /D _XML_UTF8_TEXT_WRITER XmlRawTextWriterGenerator.cxx > XmlUtf8RawTextWriter.cs -// -// Because these two implementations of XmlTextWriter are so similar, the C++ preprocessor -// is used to generate each implementation from one template file, using macros and ifdefs. - -// Note: This file was generated without #define SILVERLIGHT - -using System; -using System.IO; -using Microsoft.Xml; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - // Concrete implementation of XmlWriter abstract class that serializes events as encoded XML - // text. The general-purpose XmlEncodedTextWriter uses the Encoder class to output to any - // encoding. The XmlUtf8TextWriter class combined the encoding operation with serialization - // in order to achieve better performance. - internal partial class XmlEncodedRawTextWriter : XmlRawWriter - { - // - // Fields - // -#if ASYNC - private readonly bool useAsync; -#endif - - // main buffer - protected byte[] bufBytes; - - // output stream - protected Stream stream; - - // encoding of the stream or text writer - protected Encoding encoding; - - // char type tables - protected XmlCharType xmlCharType = XmlCharType.Instance; - - // buffer positions - protected int bufPos = 1; // buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - protected int textPos = 1; // text end position; don't indent first element, pi, or comment - protected int contentPos; // element content end position - protected int cdataPos; // cdata end position - protected int attrEndPos; // end of the last attribute - protected int bufLen = BUFSIZE; - - // flags - protected bool writeToNull; - protected bool hadDoubleBracket; - protected bool inAttributeValue; - - protected int bufBytesUsed; - protected char[] bufChars; - - // encoder for encoding chars in specified encoding when writing to stream - protected Encoder encoder; - - // output text writer - protected TextWriter writer; - - // escaping of characters invalid in the output encoding - protected bool trackTextContent; - protected bool inTextContent; - private int _lastMarkPos; - private int[] _textContentMarks; // even indices contain text content start positions - // odd indices contain markup start positions - private CharEntityEncoderFallback _charEntityFallback; - - // writer settings - protected NewLineHandling newLineHandling; - protected bool closeOutput; - protected bool omitXmlDeclaration; - protected string newLineChars; - protected bool checkCharacters; - - protected XmlStandalone standalone; - protected XmlOutputMethod outputMethod; - - protected bool autoXmlDeclaration; - protected bool mergeCDataSections; - - // - // Constants - // - private const int BUFSIZE = 2048 * 3; // Should be greater than default FileStream size (4096), otherwise the FileStream will try to cache the data - private const int ASYNCBUFSIZE = 64 * 1024; // Set async buffer size to 64KB - private const int OVERFLOW = 32; // Allow overflow in order to reduce checks when writing out constant size markup - private const int INIT_MARKS_COUNT = 64; - - // - // Constructors - // - // Construct and initialize an instance of this class. - protected XmlEncodedRawTextWriter(XmlWriterSettings settings) - { -#if ASYNC - useAsync = settings.Async; -#endif - - // copy settings - newLineHandling = settings.NewLineHandling; - omitXmlDeclaration = settings.OmitXmlDeclaration; - newLineChars = settings.NewLineChars; - checkCharacters = settings.CheckCharacters; - closeOutput = settings.CloseOutput; - - standalone = settings.Standalone; - outputMethod = settings.OutputMethod; - mergeCDataSections = settings.MergeCDataSections; - - if (checkCharacters && newLineHandling == NewLineHandling.Replace) - { - ValidateContentChars(newLineChars, "NewLineChars", false); - } - } - - // Construct an instance of this class that outputs text to the TextWriter interface. - public XmlEncodedRawTextWriter(TextWriter writer, XmlWriterSettings settings) : this(settings) - { - Debug.Assert(writer != null && settings != null); - - this.writer = writer; - this.encoding = writer.Encoding; - - this.bufChars = new char[bufLen + OVERFLOW]; - - // Write the xml declaration - if (settings.AutoXmlDeclaration) - { - WriteXmlDeclaration(standalone); - autoXmlDeclaration = true; - } - } - - // Construct an instance of this class that serializes to a Stream interface. - public XmlEncodedRawTextWriter(Stream stream, XmlWriterSettings settings) : this(settings) - { - Debug.Assert(stream != null && settings != null); - - this.stream = stream; - this.encoding = settings.Encoding; - - bufChars = new char[bufLen + OVERFLOW]; - - bufBytes = new byte[bufChars.Length]; - bufBytesUsed = 0; - - // Init escaping of characters not fitting into the target encoding - trackTextContent = true; - inTextContent = false; - _lastMarkPos = 0; - _textContentMarks = new int[INIT_MARKS_COUNT]; - _textContentMarks[0] = 1; - - _charEntityFallback = new CharEntityEncoderFallback(); - this.encoding = (Encoding)settings.Encoding.Clone(); - - encoder = encoding.GetEncoder(); - - if (!stream.CanSeek || stream.Position == 0) - { - byte[] bom = encoding.GetPreamble(); - if (bom.Length != 0) - { - this.stream.Write(bom, 0, bom.Length); - } - } - - // Write the xml declaration - if (settings.AutoXmlDeclaration) - { - WriteXmlDeclaration(standalone); - autoXmlDeclaration = true; - } - } - - // - // XmlWriter implementation - // - // Returns settings the writer currently applies. - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = new XmlWriterSettings(); - - settings.Encoding = this.encoding; - settings.OmitXmlDeclaration = this.omitXmlDeclaration; - settings.NewLineHandling = this.newLineHandling; - settings.NewLineChars = this.newLineChars; - settings.CloseOutput = this.closeOutput; - settings.ConformanceLevel = ConformanceLevel.Auto; - settings.CheckCharacters = checkCharacters; - - settings.AutoXmlDeclaration = autoXmlDeclaration; - settings.Standalone = standalone; - settings.OutputMethod = outputMethod; - - settings.ReadOnly = true; - return settings; - } - } - - // Write the xml declaration. This must be the first call. - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - // Output xml declaration only if user allows it and it was not already output - if (!omitXmlDeclaration && !autoXmlDeclaration) - { - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - RawText(""); - } - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - // Output xml declaration only if user allows it and it was not already output - if (!omitXmlDeclaration && !autoXmlDeclaration) - { - WriteProcessingInstruction("xml", xmldecl); - } - } - - // Serialize the document type declaration. - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - Debug.Assert(name != null && name.Length > 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - RawText("'; - } - - // Serialize the beginning of an element start tag: " 0); - Debug.Assert(prefix != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'<'; - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufChars[this.bufPos++] = (char)':'; - } - - RawText(localName); - - attrEndPos = bufPos; - } - - // Serialize the end of an element start tag in preparation for content serialization: ">" - internal override void StartElementContent() - { - bufChars[bufPos++] = (char)'>'; - - // StartElementContent is always called; therefore, in order to allow shortcut syntax, we save the - // position of the '>' character. If WriteEndElement is called and no other characters have been - // output, then the '>' character can be be overwritten with the shortcut syntax " />". - contentPos = bufPos; - } - - // Serialize an element end tag: "", if content was output. Otherwise, serialize - // the shortcut syntax: " />". - internal override void WriteEndElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if (contentPos != bufPos) - { - // Content has been output, so can't use shortcut syntax - bufChars[bufPos++] = (char)'<'; - bufChars[bufPos++] = (char)'/'; - - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufChars[bufPos++] = (char)':'; - } - RawText(localName); - bufChars[bufPos++] = (char)'>'; - } - else - { - // Use shortcut syntax; overwrite the already output '>' character - bufPos--; - bufChars[bufPos++] = (char)' '; - bufChars[bufPos++] = (char)'/'; - bufChars[bufPos++] = (char)'>'; - } - } - - // Serialize a full element end tag: "" - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'<'; - bufChars[bufPos++] = (char)'/'; - - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufChars[bufPos++] = (char)':'; - } - RawText(localName); - bufChars[bufPos++] = (char)'>'; - } - - // Serialize an attribute tag using double quotes around the attribute value: 'prefix:localName="' - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if (attrEndPos == bufPos) - { - bufChars[bufPos++] = (char)' '; - } - - if (prefix != null && prefix.Length > 0) - { - RawText(prefix); - bufChars[bufPos++] = (char)':'; - } - RawText(localName); - bufChars[bufPos++] = (char)'='; - bufChars[bufPos++] = (char)'"'; - - inAttributeValue = true; - } - - // Serialize the end of an attribute value using double quotes: '"' - public override void WriteEndAttribute() - { - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - bufChars[bufPos++] = (char)'"'; - inAttributeValue = false; - attrEndPos = bufPos; - } - - internal override void WriteNamespaceDeclaration(string prefix, string namespaceName) - { - Debug.Assert(prefix != null && namespaceName != null); - - this.WriteStartNamespaceDeclaration(prefix); - this.WriteString(namespaceName); - this.WriteEndNamespaceDeclaration(); - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return true; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) - { - Debug.Assert(prefix != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - // VSTFDEVDIV bug #583965: Inconsistency between Silverlight 2 and Dev10 in the way a single xmlns attribute is serialized - // Resolved as: Won't fix (breaking change) - - if (prefix.Length == 0) - { - RawText(" xmlns=\""); - } - else - { - RawText(" xmlns:"); - RawText(prefix); - bufChars[bufPos++] = (char)'='; - bufChars[bufPos++] = (char)'"'; - } - - inAttributeValue = true; - if (trackTextContent && inTextContent != true) { ChangeTextContentMark(true); } - } - - internal override void WriteEndNamespaceDeclaration() - { - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - inAttributeValue = false; - - bufChars[bufPos++] = (char)'"'; - attrEndPos = bufPos; - } - - // Serialize a CData section. If the "]]>" pattern is found within - // the text, replace it with "]]>". - public override void WriteCData(string text) - { - Debug.Assert(text != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - if (mergeCDataSections && bufPos == cdataPos) - { - // Merge adjacent cdata sections - overwrite the "]]>" characters - Debug.Assert(bufPos >= 4); - bufPos -= 3; - } - else - { - // Start a new cdata section - bufChars[bufPos++] = (char)'<'; - bufChars[bufPos++] = (char)'!'; - bufChars[bufPos++] = (char)'['; - bufChars[bufPos++] = (char)'C'; - bufChars[bufPos++] = (char)'D'; - bufChars[bufPos++] = (char)'A'; - bufChars[bufPos++] = (char)'T'; - bufChars[bufPos++] = (char)'A'; - bufChars[bufPos++] = (char)'['; - } - - WriteCDataSection(text); - - bufChars[bufPos++] = (char)']'; - bufChars[bufPos++] = (char)']'; - bufChars[bufPos++] = (char)'>'; - - textPos = bufPos; - cdataPos = bufPos; - } - - // Serialize a comment. - public override void WriteComment(string text) - { - Debug.Assert(text != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'<'; - bufChars[bufPos++] = (char)'!'; - bufChars[bufPos++] = (char)'-'; - bufChars[bufPos++] = (char)'-'; - - WriteCommentOrPi(text, '-'); - - bufChars[bufPos++] = (char)'-'; - bufChars[bufPos++] = (char)'-'; - bufChars[bufPos++] = (char)'>'; - } - - // Serialize a processing instruction. - public override void WriteProcessingInstruction(string name, string text) - { - Debug.Assert(name != null && name.Length > 0); - Debug.Assert(text != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'<'; - bufChars[bufPos++] = (char)'?'; - RawText(name); - - if (text.Length > 0) - { - bufChars[bufPos++] = (char)' '; - WriteCommentOrPi(text, '?'); - } - - bufChars[bufPos++] = (char)'?'; - bufChars[bufPos++] = (char)'>'; - } - - // Serialize an entity reference. - public override void WriteEntityRef(string name) - { - Debug.Assert(name != null && name.Length > 0); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'&'; - RawText(name); - bufChars[bufPos++] = (char)';'; - - if (bufPos > bufLen) - { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a character entity reference. - public override void WriteCharEntity(char ch) - { - string strVal = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); - - if (checkCharacters && !xmlCharType.IsCharData(ch)) - { - // we just have a single char, not a surrogate, therefore we have to pass in '\0' for the second char - throw XmlConvert.CreateInvalidCharException(ch, '\0'); - } - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - bufChars[bufPos++] = (char)'&'; - bufChars[bufPos++] = (char)'#'; - bufChars[bufPos++] = (char)'x'; - RawText(strVal); - bufChars[bufPos++] = (char)';'; - - if (bufPos > bufLen) - { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a whitespace node. - - public override unsafe void WriteWhitespace(string ws) - { - Debug.Assert(ws != null); - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - fixed (char* pSrc = ws) - { - char* pSrcEnd = pSrc + ws.Length; - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteElementTextBlock(pSrc, pSrcEnd); - } - } - } - - // Serialize either attribute or element text using XML rules. - - public override unsafe void WriteString(string text) - { - Debug.Assert(text != null); - if (trackTextContent && inTextContent != true) { ChangeTextContentMark(true); } - - fixed (char* pSrc = text) - { - char* pSrcEnd = pSrc + text.Length; - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteElementTextBlock(pSrc, pSrcEnd); - } - } - } - - // Serialize surrogate character entity. - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - int surrogateChar = XmlCharType.CombineSurrogateChar(lowChar, highChar); - - bufChars[bufPos++] = (char)'&'; - bufChars[bufPos++] = (char)'#'; - bufChars[bufPos++] = (char)'x'; - RawText(surrogateChar.ToString("X", NumberFormatInfo.InvariantInfo)); - bufChars[bufPos++] = (char)';'; - textPos = bufPos; - } - - // Serialize either attribute or element text using XML rules. - // Arguments are validated in the XmlWellformedWriter layer. - - public override unsafe void WriteChars(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - if (trackTextContent && inTextContent != true) { ChangeTextContentMark(true); } - - fixed (char* pSrcBegin = &buffer[index]) - { - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrcBegin, pSrcBegin + count); - } - else - { - WriteElementTextBlock(pSrcBegin, pSrcBegin + count); - } - } - } - - // Serialize raw data. - // Arguments are validated in the XmlWellformedWriter layer - - public override unsafe void WriteRaw(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - fixed (char* pSrcBegin = &buffer[index]) - { - WriteRawWithCharChecking(pSrcBegin, pSrcBegin + count); - } - - textPos = bufPos; - } - - // Serialize raw data. - - public override unsafe void WriteRaw(string data) - { - Debug.Assert(data != null); - - if (trackTextContent && inTextContent != false) { ChangeTextContentMark(false); } - - fixed (char* pSrcBegin = data) - { - WriteRawWithCharChecking(pSrcBegin, pSrcBegin + data.Length); - } - - textPos = bufPos; - } - - // Flush all bytes in the buffer to output and close the output stream or writer. - public override void Close() - { - try - { - FlushBuffer(); - FlushEncoder(); - } - finally - { - // Future calls to Close or Flush shouldn't write to Stream or Writer - writeToNull = true; - - if (stream != null) - { - try - { - stream.Flush(); - } - finally - { - try - { - if (closeOutput) - { - stream.Close(); - } - } - finally - { - stream = null; - } - } - } - - else if (writer != null) - { - try - { - writer.Flush(); - } - finally - { - try - { - if (closeOutput) - { - writer.Dispose(); - } - } - finally - { - writer = null; - } - } - } - } - } - - // Flush all characters in the buffer to output and call Flush() on the output object. - public override void Flush() - { - FlushBuffer(); - FlushEncoder(); - - if (stream != null) - { - stream.Flush(); - } - else if (writer != null) - { - writer.Flush(); - } - } - - // - // Implementation methods - // - // Flush all characters in the buffer to output. Do not flush the output object. - protected virtual void FlushBuffer() - { - try - { - // Output all characters (except for previous characters stored at beginning of buffer) - if (!writeToNull) - { - Debug.Assert(stream != null || writer != null); - - if (stream != null) - { - if (trackTextContent) - { - _charEntityFallback.Reset(_textContentMarks, _lastMarkPos); - // reset text content tracking - - if ((_lastMarkPos & 1) != 0) - { - // If the previous buffer ended inside a text content we need to preserve that info - // which means the next index to which we write has to be even - _textContentMarks[1] = 1; - _lastMarkPos = 1; - } - else - { - _lastMarkPos = 0; - } - Debug.Assert(_textContentMarks[0] == 1); - } - EncodeChars(1, bufPos, true); - } - else - { - // Write text to TextWriter - writer.Write(bufChars, 1, bufPos - 1); - } - } - } - catch - { - // Future calls to flush (i.e. when Close() is called) don't attempt to write to stream - writeToNull = true; - throw; - } - finally - { - // Move last buffer character to the beginning of the buffer (so that previous character can always be determined) - bufChars[0] = bufChars[bufPos - 1]; - - // Reset buffer position - textPos = (textPos == bufPos) ? 1 : 0; - attrEndPos = (attrEndPos == bufPos) ? 1 : 0; - contentPos = 0; // Needs to be zero, since overwriting '>' character is no longer possible - cdataPos = 0; // Needs to be zero, since overwriting ']]>' characters is no longer possible - bufPos = 1; // Buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - } - } - - private void EncodeChars(int startOffset, int endOffset, bool writeAllToStream) - { - // Write encoded text to stream - int chEnc; - int bEnc; - bool completed; - while (startOffset < endOffset) - { - if (_charEntityFallback != null) - { - _charEntityFallback.StartOffset = startOffset; - } - encoder.Convert(bufChars, startOffset, endOffset - startOffset, bufBytes, bufBytesUsed, bufBytes.Length - bufBytesUsed, false, out chEnc, out bEnc, out completed); - startOffset += chEnc; - bufBytesUsed += bEnc; - if (bufBytesUsed >= (bufBytes.Length - 16)) - { - stream.Write(bufBytes, 0, bufBytesUsed); - bufBytesUsed = 0; - } - } - if (writeAllToStream && bufBytesUsed > 0) - { - stream.Write(bufBytes, 0, bufBytesUsed); - bufBytesUsed = 0; - } - } - - private void FlushEncoder() - { - Debug.Assert(bufPos == 1); - if (stream != null) - { - int chEnc; - int bEnc; - bool completed; - // decode no chars, just flush - encoder.Convert(bufChars, 1, 0, bufBytes, 0, bufBytes.Length, true, out chEnc, out bEnc, out completed); - if (bEnc != 0) - { - stream.Write(bufBytes, 0, bEnc); - } - } - } - - // Serialize text that is part of an attribute value. The '&', '<', '>', and '"' characters - // are entitized. - - protected unsafe void WriteAttributeTextBlock(char* pSrc, char* pSrcEnd) - { - fixed (char* pDstBegin = bufChars) - { - char* pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0))) - { - *pDst = (char)ch; - pDst++; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - pDst = AmpEntity(pDst); - break; - case '<': - pDst = LtEntity(pDst); - break; - case '>': - pDst = GtEntity(pDst); - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '\'': - *pDst = (char)ch; - pDst++; - break; - case (char)0x9: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (char)ch; - pDst++; - } - else - { - // escape tab in attributes - pDst = TabEntity(pDst); - } - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (char)ch; - pDst++; - } - else - { - // escape new lines in attributes - pDst = CarriageReturnEntity(pDst); - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (char)ch; - pDst++; - } - else - { - // escape new lines in attributes - pDst = LineFeedEntity(pDst); - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // Serialize text that is part of element content. The '&', '<', and '>' characters - // are entitized. - - protected unsafe void WriteElementTextBlock(char* pSrc, char* pSrcEnd) - { - fixed (char* pDstBegin = bufChars) - { - char* pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0))) - { - *pDst = (char)ch; - pDst++; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - pDst = AmpEntity(pDst); - break; - case '<': - pDst = LtEntity(pDst); - break; - case '>': - pDst = GtEntity(pDst); - break; - case '"': - case '\'': - case (char)0x9: - *pDst = (char)ch; - pDst++; - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case (char)0xD: - switch (newLineHandling) - { - case NewLineHandling.Replace: - // Replace "\r\n", or "\r" with NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - break; - - case NewLineHandling.Entitize: - // Entitize 0xD - pDst = CarriageReturnEntity(pDst); - break; - case NewLineHandling.None: - *pDst = (char)ch; - pDst++; - break; - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - textPos = bufPos; - contentPos = 0; - } - } - - protected unsafe void RawText(string s) - { - Debug.Assert(s != null); - - fixed (char* pSrcBegin = s) - { - RawText(pSrcBegin, pSrcBegin + s.Length); - } - } - - protected unsafe void RawText(char* pSrcBegin, char* pSrcEnd) - { - fixed (char* pDstBegin = bufChars) - { - char* pDst = pDstBegin + this.bufPos; - char* pSrc = pSrcBegin; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + this.bufLen) - { - pDstEnd = pDstBegin + this.bufLen; - } - - while (pDst < pDstEnd && ((ch = *pSrc) < XmlCharType.SurHighStart)) - { - pSrc++; - *pDst = (char)ch; - pDst++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - } - - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteRawWithCharChecking(char* pSrcBegin, char* pSrcEnd) - { - fixed (char* pDstBegin = bufChars) - { - char* pSrc = pSrcBegin; - char* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fText) != 0))) - { - *pDst = (char)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case ']': - case '<': - case '&': - case (char)0x9: - *pDst = (char)ch; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCommentOrPi(string text, int stopChar) - { - if (text.Length == 0) - { - if (bufPos >= bufLen) - { - FlushBuffer(); - } - return; - } - // write text - fixed (char* pSrcBegin = text) - - fixed (char* pDstBegin = bufChars) - { - char* pSrc = pSrcBegin; - - char* pSrcEnd = pSrcBegin + text.Length; - - char* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fText) != 0) && ch != stopChar)) - { - *pDst = (char)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case '-': - *pDst = (char)'-'; - pDst++; - if (ch == stopChar) - { - // Insert space between adjacent dashes or before comment's end dashes - if (pSrc + 1 == pSrcEnd || *(pSrc + 1) == '-') - { - *pDst = (char)' '; - pDst++; - } - } - break; - case '?': - *pDst = (char)'?'; - pDst++; - if (ch == stopChar) - { - // Processing instruction: insert space between adjacent '?' and '>' - if (pSrc + 1 < pSrcEnd && *(pSrc + 1) == '>') - { - *pDst = (char)' '; - pDst++; - } - } - break; - case ']': - *pDst = (char)']'; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case '<': - case '&': - case (char)0x9: - *pDst = (char)ch; - pDst++; - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCDataSection(string text) - { - if (text.Length == 0) - { - if (bufPos >= bufLen) - { - FlushBuffer(); - } - return; - } - - // write text - - fixed (char* pSrcBegin = text) - - fixed (char* pDstBegin = bufChars) - { - char* pSrc = pSrcBegin; - - char* pSrcEnd = pSrcBegin + text.Length; - - char* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - char* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch != ']')) - { - *pDst = (char)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case '>': - if (hadDoubleBracket && pDst[-1] == (char)']') - { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - // The characters "]]>" were found within the CData text - pDst = RawEndCData(pDst); - pDst = RawStartCData(pDst); - } - *pDst = (char)'>'; - pDst++; - break; - case ']': - if (pDst[-1] == (char)']') - { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - hadDoubleBracket = true; - } - else - { - hadDoubleBracket = false; - } - *pDst = (char)']'; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (char)ch; - pDst++; - } - break; - case '&': - case '<': - case '"': - case '\'': - case (char)0x9: - *pDst = (char)ch; - pDst++; - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - private static unsafe char* EncodeSurrogate(char* pSrc, char* pSrcEnd, char* pDst) - { - Debug.Assert(XmlCharType.IsSurrogate(*pSrc)); - - int ch = *pSrc; - if (ch <= XmlCharType.SurHighEnd) - { - if (pSrc + 1 < pSrcEnd) - { - int lowChar = pSrc[1]; - if (lowChar >= XmlCharType.SurLowStart && - (/*LocalAppContextSwitches.DontThrowOnInvalidSurrogatePairs ||*/ lowChar <= XmlCharType.SurLowEnd)) - { - pDst[0] = (char)ch; - pDst[1] = (char)lowChar; - pDst += 2; - - return pDst; - } - throw XmlConvert.CreateInvalidSurrogatePairException((char)lowChar, (char)ch); - } - throw new ArgumentException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - throw XmlConvert.CreateInvalidHighSurrogateCharException((char)ch); - } - - private unsafe char* InvalidXmlChar(int ch, char* pDst, bool entitize) - { - Debug.Assert(!xmlCharType.IsWhiteSpace((char)ch)); - Debug.Assert(!xmlCharType.IsAttributeValueChar((char)ch)); - - if (checkCharacters) - { - // This method will never be called on surrogates, so it is ok to pass in '\0' to the CreateInvalidCharException - throw XmlConvert.CreateInvalidCharException((char)ch, '\0'); - } - else - { - if (entitize) - { - return CharEntity(pDst, (char)ch); - } - else - { - *pDst = (char)ch; - pDst++; - - return pDst; - } - } - } - - internal unsafe void EncodeChar(ref char* pSrc, char* pSrcEnd, ref char* pDst) - { - int ch = *pSrc; - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { *pDst = (char)ch; pDst++; pSrc++; }; - } - - protected void ChangeTextContentMark(bool value) - { - Debug.Assert(inTextContent != value); - Debug.Assert(inTextContent || ((_lastMarkPos & 1) == 0)); - inTextContent = value; - if (_lastMarkPos + 1 == _textContentMarks.Length) - { - GrowTextContentMarks(); - } - _textContentMarks[++_lastMarkPos] = this.bufPos; - } - - private void GrowTextContentMarks() - { - Debug.Assert(_lastMarkPos + 1 == _textContentMarks.Length); - int[] newTextContentMarks = new int[_textContentMarks.Length * 2]; - Array.Copy(_textContentMarks, newTextContentMarks, _textContentMarks.Length); - _textContentMarks = newTextContentMarks; - } - - // Write NewLineChars to the specified buffer position and return an updated position. - - protected unsafe char* WriteNewLine(char* pDst) - { - fixed (char* pDstBegin = bufChars) - { - bufPos = (int)(pDst - pDstBegin); - // Let RawText do the real work - RawText(newLineChars); - return pDstBegin + bufPos; - } - } - - // Following methods do not check whether pDst is beyond the bufSize because the buffer was allocated with a OVERFLOW to accomodate - // for the writes of small constant-length string as below. - - // Entitize '<' as "<". Return an updated pointer. - - protected static unsafe char* LtEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'l'; - pDst[2] = (char)'t'; - pDst[3] = (char)';'; - return pDst + 4; - } - - // Entitize '>' as ">". Return an updated pointer. - - protected static unsafe char* GtEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'g'; - pDst[2] = (char)'t'; - pDst[3] = (char)';'; - return pDst + 4; - } - - // Entitize '&' as "&". Return an updated pointer. - - protected static unsafe char* AmpEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'a'; - pDst[2] = (char)'m'; - pDst[3] = (char)'p'; - pDst[4] = (char)';'; - return pDst + 5; - } - - // Entitize '"' as """. Return an updated pointer. - - protected static unsafe char* QuoteEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'q'; - pDst[2] = (char)'u'; - pDst[3] = (char)'o'; - pDst[4] = (char)'t'; - pDst[5] = (char)';'; - return pDst + 6; - } - - // Entitize '\t' as " ". Return an updated pointer. - - protected static unsafe char* TabEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'#'; - pDst[2] = (char)'x'; - pDst[3] = (char)'9'; - pDst[4] = (char)';'; - return pDst + 5; - } - - // Entitize 0xa as " ". Return an updated pointer. - - protected static unsafe char* LineFeedEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'#'; - pDst[2] = (char)'x'; - pDst[3] = (char)'A'; - pDst[4] = (char)';'; - return pDst + 5; - } - - // Entitize 0xd as " ". Return an updated pointer. - - protected static unsafe char* CarriageReturnEntity(char* pDst) - { - pDst[0] = (char)'&'; - pDst[1] = (char)'#'; - pDst[2] = (char)'x'; - pDst[3] = (char)'D'; - pDst[4] = (char)';'; - return pDst + 5; - } - - private static unsafe char* CharEntity(char* pDst, char ch) - { - string s = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); - pDst[0] = (char)'&'; - pDst[1] = (char)'#'; - pDst[2] = (char)'x'; - pDst += 3; - - fixed (char* pSrc = s) - { - char* pS = pSrc; - while ((*pDst++ = (char)*pS++) != 0) ; - } - - pDst[-1] = (char)';'; - return pDst; - } - - // Write "" to the specified buffer. Return an updated pointer. - - protected static unsafe char* RawEndCData(char* pDst) - { - pDst[0] = (char)']'; - pDst[1] = (char)']'; - pDst[2] = (char)'>'; - return pDst + 3; - } - - protected unsafe void ValidateContentChars(string chars, string propertyName, bool allowOnlyWhitespace) - { - if (allowOnlyWhitespace) - { - if (!xmlCharType.IsOnlyWhitespace(chars)) - { - throw new ArgumentException(string.Format(ResXml.Xml_IndentCharsNotWhitespace, propertyName)); - } - } - else - { - string error = null; - for (int i = 0; i < chars.Length; i++) - { - if (!xmlCharType.IsTextChar(chars[i])) - { - switch (chars[i]) - { - case '\n': - case '\r': - case '\t': - continue; - case '<': - case '&': - case ']': - error = string.Format(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(chars, i)); - goto Error; - default: - if (XmlCharType.IsHighSurrogate(chars[i])) - { - if (i + 1 < chars.Length) - { - if (XmlCharType.IsLowSurrogate(chars[i + 1])) - { - i++; - continue; - } - } - error = ResXml.Xml_InvalidSurrogateMissingLowChar; - goto Error; - } - else if (XmlCharType.IsLowSurrogate(chars[i])) - { - error = string.Format(ResXml.Xml_InvalidSurrogateHighChar, ((uint)chars[i]).ToString("X", CultureInfo.InvariantCulture)); - goto Error; - } - continue; - } - } - } - return; - - Error: - throw new ArgumentException(string.Format(ResXml.Xml_InvalidCharsInIndent, new string[] { propertyName, error })); - } - } - } - - // Same as base text writer class except that elements, attributes, comments, and pi's are indented. - internal partial class XmlEncodedRawTextWriterIndent : XmlEncodedRawTextWriter - { - // - // Fields - // - protected int indentLevel; - protected bool newLineOnAttributes; - protected string indentChars; - - protected bool mixedContent; - private BitStack _mixedContentStack; - - protected ConformanceLevel conformanceLevel = ConformanceLevel.Auto; - - // - // Constructors - // - - public XmlEncodedRawTextWriterIndent(TextWriter writer, XmlWriterSettings settings) : base(writer, settings) - { - Init(settings); - } - - public XmlEncodedRawTextWriterIndent(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - Init(settings); - } - - // - // XmlWriter methods - // - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = base.Settings; - - settings.ReadOnly = false; - settings.Indent = true; - settings.IndentChars = indentChars; - settings.NewLineOnAttributes = newLineOnAttributes; - settings.ReadOnly = true; - - return settings; - } - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - // Add indentation - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - base.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - // Add indentation - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - indentLevel++; - _mixedContentStack.PushBit(mixedContent); - - base.WriteStartElement(prefix, localName, ns); - } - - internal override void StartElementContent() - { - // If this is the root element and we're writing a document - // do not inherit the mixedContent flag into the root element. - // This is to allow for whitespace nodes on root level - // without disabling indentation for the whole document. - if (indentLevel == 1 && conformanceLevel == ConformanceLevel.Document) - { - mixedContent = false; - } - else - { - mixedContent = _mixedContentStack.PeekBit(); - } - base.StartElementContent(); - } - - internal override void OnRootElement(ConformanceLevel currentConformanceLevel) - { - // Just remember the current conformance level - conformanceLevel = currentConformanceLevel; - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - // Add indentation - indentLevel--; - if (!mixedContent && base.contentPos != base.bufPos) - { - // There was content, so try to indent - if (base.textPos != base.bufPos) - { - WriteIndent(); - } - } - mixedContent = _mixedContentStack.PopBit(); - - base.WriteEndElement(prefix, localName, ns); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - // Add indentation - indentLevel--; - if (!mixedContent && base.contentPos != base.bufPos) - { - // There was content, so try to indent - if (base.textPos != base.bufPos) - { - WriteIndent(); - } - } - mixedContent = _mixedContentStack.PopBit(); - - base.WriteFullEndElement(prefix, localName, ns); - } - - // Same as base class, plus possible indentation. - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - // Add indentation - if (newLineOnAttributes) - { - WriteIndent(); - } - - base.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteCData(string text) - { - mixedContent = true; - base.WriteCData(text); - } - - public override void WriteComment(string text) - { - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - - base.WriteComment(text); - } - - public override void WriteProcessingInstruction(string target, string text) - { - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - - base.WriteProcessingInstruction(target, text); - } - - public override void WriteEntityRef(string name) - { - mixedContent = true; - base.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - mixedContent = true; - base.WriteCharEntity(ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - mixedContent = true; - base.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteWhitespace(string ws) - { - mixedContent = true; - base.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - mixedContent = true; - base.WriteString(text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - mixedContent = true; - base.WriteChars(buffer, index, count); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - mixedContent = true; - base.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - mixedContent = true; - base.WriteRaw(data); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - mixedContent = true; - base.WriteBase64(buffer, index, count); - } - - // - // Private methods - // - private void Init(XmlWriterSettings settings) - { - indentLevel = 0; - indentChars = settings.IndentChars; - newLineOnAttributes = settings.NewLineOnAttributes; - _mixedContentStack = new BitStack(); - - // check indent characters that they are valid XML characters - if (base.checkCharacters) - { - if (newLineOnAttributes) - { - base.ValidateContentChars(indentChars, "IndentChars", true); - base.ValidateContentChars(newLineChars, "NewLineChars", true); - } - else - { - base.ValidateContentChars(indentChars, "IndentChars", false); - if (base.newLineHandling != NewLineHandling.Replace) - { - base.ValidateContentChars(newLineChars, "NewLineChars", false); - } - } - } - } - - // Add indentation to output. Write newline and then repeat IndentChars for each indent level. - private void WriteIndent() - { - RawText(base.newLineChars); - for (int i = indentLevel; i > 0; i--) - { - RawText(indentChars); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEventCache.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEventCache.cs deleted file mode 100644 index 6aa6d5263c4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlEventCache.cs +++ /dev/null @@ -1,665 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - - /// - /// Caches sequence of XmlEvents so that they can be replayed later. - /// - internal sealed class XmlEventCache : XmlRawWriter - { - private List _pages; // All event pages - private XmlEvent[] _pageCurr; // Page that is currently being built - private int _pageSize; // Number of events in pageCurr - private bool _hasRootNode; // True if the cached document has a root node, false if it's a fragment - private StringBuilder _singleText; // If document consists of a single text node, cache it here rather than creating pages - private string _baseUri; // Base Uri of document - - private enum XmlEventType - { - Unknown = 0, - DocType, - StartElem, - StartAttr, - EndAttr, - CData, - Comment, - PI, - Whitespace, - String, - Raw, - EntRef, - CharEnt, - SurrCharEnt, - Base64, - BinHex, - XmlDecl1, - XmlDecl2, - StartContent, - EndElem, - FullEndElem, - Nmsp, - EndBase64, - Close, - Flush, - Dispose, - } - -#if DEBUG - private const int InitialPageSize = 4; -#else - private const int InitialPageSize = 32; -#endif - - public XmlEventCache(string baseUri, bool hasRootNode) - { - _baseUri = baseUri; - _hasRootNode = hasRootNode; - } - - public void EndEvents() - { - if (_singleText.Length == 0) - AddEvent(XmlEventType.Unknown); - } - - - //----------------------------------------------- - // XmlEventCache methods - //----------------------------------------------- - - /// - /// Return Base Uri of the document. - /// - public string BaseUri - { - get { return _baseUri; } - } - - /// - /// Return true if the cached document has a root node, false if it's a fragment. - /// - public bool HasRootNode - { - get { return _hasRootNode; } - } - - /// - /// Replay all cached events to an XmlWriter. - /// - public void EventsToWriter(XmlWriter writer) - { - XmlEvent[] page; - int idxPage, idxEvent; - byte[] bytes; - char[] chars; - XmlRawWriter rawWriter; - - // Special-case single text node at the top-level - if (_singleText.Length != 0) - { - writer.WriteString(_singleText.ToString()); - return; - } - - rawWriter = writer as XmlRawWriter; - - // Loop over set of pages - for (idxPage = 0; idxPage < _pages.Count; idxPage++) - { - page = _pages[idxPage]; - - // Loop over events in each page - for (idxEvent = 0; idxEvent < page.Length; idxEvent++) - { - switch (page[idxEvent].EventType) - { - case XmlEventType.Unknown: - // No more events - Debug.Assert(idxPage + 1 == _pages.Count); - return; - - case XmlEventType.DocType: - writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string)page[idxEvent].Object); - break; - - case XmlEventType.StartElem: - writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3); - break; - - case XmlEventType.StartAttr: - writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3); - break; - - case XmlEventType.EndAttr: - writer.WriteEndAttribute(); - break; - - case XmlEventType.CData: - writer.WriteCData(page[idxEvent].String1); - break; - - case XmlEventType.Comment: - writer.WriteComment(page[idxEvent].String1); - break; - - case XmlEventType.PI: - writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2); - break; - - case XmlEventType.Whitespace: - writer.WriteWhitespace(page[idxEvent].String1); - break; - - case XmlEventType.String: - writer.WriteString(page[idxEvent].String1); - break; - - case XmlEventType.Raw: - writer.WriteRaw(page[idxEvent].String1); - break; - - case XmlEventType.EntRef: - writer.WriteEntityRef(page[idxEvent].String1); - break; - - case XmlEventType.CharEnt: - writer.WriteCharEntity((char)page[idxEvent].Object); - break; - - case XmlEventType.SurrCharEnt: - chars = (char[])page[idxEvent].Object; - writer.WriteSurrogateCharEntity(chars[0], chars[1]); - break; - - case XmlEventType.Base64: - bytes = (byte[])page[idxEvent].Object; - writer.WriteBase64(bytes, 0, bytes.Length); - break; - - case XmlEventType.BinHex: - bytes = (byte[])page[idxEvent].Object; - writer.WriteBinHex(bytes, 0, bytes.Length); - break; - - case XmlEventType.XmlDecl1: - if (rawWriter != null) - rawWriter.WriteXmlDeclaration((XmlStandalone)page[idxEvent].Object); - break; - - case XmlEventType.XmlDecl2: - if (rawWriter != null) - rawWriter.WriteXmlDeclaration(page[idxEvent].String1); - break; - - case XmlEventType.StartContent: - if (rawWriter != null) - rawWriter.StartElementContent(); - break; - - case XmlEventType.EndElem: - if (rawWriter != null) - rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3); - else - writer.WriteEndElement(); - break; - - case XmlEventType.FullEndElem: - if (rawWriter != null) - rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3); - else - writer.WriteFullEndElement(); - break; - - case XmlEventType.Nmsp: - if (rawWriter != null) - rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2); - else - writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2); - break; - - case XmlEventType.EndBase64: - if (rawWriter != null) - rawWriter.WriteEndBase64(); - break; - - case XmlEventType.Close: - writer.Close(); - break; - - case XmlEventType.Flush: - writer.Flush(); - break; - - case XmlEventType.Dispose: - ((IDisposable)writer).Dispose(); - break; - - default: - Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType); - break; - } - } - } - - Debug.Assert(false, "Unknown event should be added to end of event sequence."); - } - - /// - /// Concatenate all element text and atomic value events and return the resulting string. - /// - public string EventsToString() - { - StringBuilder bldr; - XmlEvent[] page; - int idxPage, idxEvent; - bool inAttr; - - // Special-case single text node at the top-level - if (_singleText.Length != 0) - return _singleText.ToString(); - - bldr = new StringBuilder(); - - // Loop over set of pages - inAttr = false; - for (idxPage = 0; idxPage < _pages.Count; idxPage++) - { - page = _pages[idxPage]; - - // Loop over events in each page - for (idxEvent = 0; idxEvent < page.Length; idxEvent++) - { - switch (page[idxEvent].EventType) - { - case XmlEventType.Unknown: - // No more events - Debug.Assert(idxPage + 1 == _pages.Count); - return bldr.ToString(); - - case XmlEventType.String: - case XmlEventType.Whitespace: - case XmlEventType.Raw: - case XmlEventType.CData: - // Append text - if (!inAttr) - bldr.Append(page[idxEvent].String1); - break; - - case XmlEventType.StartAttr: - // Don't append text or atomic values if they appear within attributes - inAttr = true; - break; - - case XmlEventType.EndAttr: - // No longer in an attribute - inAttr = false; - break; - } - } - } - - Debug.Assert(false, "Unknown event should be added to end of event sequence."); - return string.Empty; - } - - - //----------------------------------------------- - // XmlWriter interface - //----------------------------------------------- - - public override XmlWriterSettings Settings - { - get { return null; } - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - AddEvent(XmlEventType.DocType, name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - AddEvent(XmlEventType.StartElem, prefix, localName, ns); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - AddEvent(XmlEventType.StartAttr, prefix, localName, ns); - } - - public override void WriteEndAttribute() - { - AddEvent(XmlEventType.EndAttr); - } - - public override void WriteCData(string text) - { - AddEvent(XmlEventType.CData, text); - } - - public override void WriteComment(string text) - { - AddEvent(XmlEventType.Comment, text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - AddEvent(XmlEventType.PI, name, text); - } - - public override void WriteWhitespace(string ws) - { - AddEvent(XmlEventType.Whitespace, ws); - } - - public override void WriteString(string text) - { - // Special-case single text node at the top level - if (_pages == null) - { - _singleText.Append(text); - } - else - { - AddEvent(XmlEventType.String, text); - } - } - - public override void WriteChars(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - WriteRaw(new string(buffer, index, count)); - } - - public override void WriteRaw(string data) - { - AddEvent(XmlEventType.Raw, data); - } - - public override void WriteEntityRef(string name) - { - AddEvent(XmlEventType.EntRef, name); - } - - public override void WriteCharEntity(char ch) - { - AddEvent(XmlEventType.CharEnt, (object)ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - // Save high and low characters - char[] chars = { lowChar, highChar }; - AddEvent(XmlEventType.SurrCharEnt, (object)chars); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - AddEvent(XmlEventType.Base64, (object)ToBytes(buffer, index, count)); - } - - public override void WriteBinHex(byte[] buffer, int index, int count) - { - AddEvent(XmlEventType.BinHex, (object)ToBytes(buffer, index, count)); - } - - public override void Close() - { - AddEvent(XmlEventType.Close); - } - - public override void Flush() - { - AddEvent(XmlEventType.Flush); - } - - /// - /// All other WriteValue methods are implemented by XmlWriter to delegate to WriteValue(object) or WriteValue(string), so - /// only these two methods need to be implemented. - /// - public override void WriteValue(object value) - { - WriteString(XmlUntypedConverter.Untyped.ToString(value, this.resolver)); - } - - public override void WriteValue(string value) - { - WriteString(value); - } - - protected override void Dispose(bool disposing) - { - try - { - if (disposing) - { - AddEvent(XmlEventType.Dispose); - } - } - finally - { - base.Dispose(disposing); - } - } - - - //----------------------------------------------- - // XmlRawWriter interface - //----------------------------------------------- - - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - AddEvent(XmlEventType.XmlDecl1, (object)standalone); - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - AddEvent(XmlEventType.XmlDecl2, xmldecl); - } - - internal override void StartElementContent() - { - AddEvent(XmlEventType.StartContent); - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - AddEvent(XmlEventType.EndElem, prefix, localName, ns); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - AddEvent(XmlEventType.FullEndElem, prefix, localName, ns); - } - - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - AddEvent(XmlEventType.Nmsp, prefix, ns); - } - - internal override void WriteEndBase64() - { - AddEvent(XmlEventType.EndBase64); - } - - - //----------------------------------------------- - // Helper methods - //----------------------------------------------- - - private void AddEvent(XmlEventType eventType) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType); - } - - private void AddEvent(XmlEventType eventType, string s1) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType, s1); - } - - private void AddEvent(XmlEventType eventType, string s1, string s2) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType, s1, s2); - } - - private void AddEvent(XmlEventType eventType, string s1, string s2, string s3) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType, s1, s2, s3); - } - - private void AddEvent(XmlEventType eventType, string s1, string s2, string s3, object o) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType, s1, s2, s3, o); - } - - private void AddEvent(XmlEventType eventType, object o) - { - int idx = NewEvent(); - _pageCurr[idx].InitEvent(eventType, o); - } - - private int NewEvent() - { - if (_pages == null) - { - _pages = new List(); - _pageCurr = new XmlEvent[InitialPageSize]; - _pages.Add(_pageCurr); - - if (_singleText.Length != 0) - { - // Review: There is no need to concatenate the strings here - _pageCurr[0].InitEvent(XmlEventType.String, _singleText.ToString()); - _pageSize++; - _singleText.Clear(); - } - } - else if (_pageSize >= _pageCurr.Length) - { - // Create new page - _pageCurr = new XmlEvent[_pageSize * 2]; - _pages.Add(_pageCurr); - _pageSize = 0; - } - - return _pageSize++; - } - - /// - /// Create a standalone buffer that doesn't need an index or count passed along with it. - /// - private static byte[] ToBytes(byte[] buffer, int index, int count) - { - if (index != 0 || count != buffer.Length) - { - if (buffer.Length - index > count) - count = buffer.Length - index; - - byte[] bufferNew = new byte[count]; - Array.Copy(buffer, index, bufferNew, 0, count); - - return bufferNew; - } - - return buffer; - } - - - /// - /// Caches information for XML events like BeginElement, String, and EndAttribute so that they can be replayed later. - /// - private struct XmlEvent - { - private XmlEventType _eventType; - private string _s1; - private string _s2; - private string _s3; - private object _o; - - public void InitEvent(XmlEventType eventType) - { - _eventType = eventType; - } - - public void InitEvent(XmlEventType eventType, string s1) - { - _eventType = eventType; - _s1 = s1; - } - - public void InitEvent(XmlEventType eventType, string s1, string s2) - { - _eventType = eventType; - _s1 = s1; - _s2 = s2; - } - - public void InitEvent(XmlEventType eventType, string s1, string s2, string s3) - { - _eventType = eventType; - _s1 = s1; - _s2 = s2; - _s3 = s3; - } - - public void InitEvent(XmlEventType eventType, string s1, string s2, string s3, object o) - { - _eventType = eventType; - _s1 = s1; - _s2 = s2; - _s3 = s3; - _o = o; - } - - public void InitEvent(XmlEventType eventType, object o) - { - _eventType = eventType; - _o = o; - } - - public XmlEventType EventType - { - get { return _eventType; } - } - - public string String1 - { - get { return _s1; } - } - - public string String2 - { - get { return _s2; } - } - - public string String3 - { - get { return _s3; } - } - - public object Object - { - get { return _o; } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlParserContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlParserContext.cs deleted file mode 100644 index d797aa8dd38..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlParserContext.cs +++ /dev/null @@ -1,213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xml; -using System.Text; -using System; - -namespace Microsoft.Xml -{ - using System; - - // Specifies the context that the XmLReader will use for xml fragment - public class XmlParserContext - { - private XmlNameTable _nt = null; - private XmlNamespaceManager _nsMgr = null; - private String _docTypeName = String.Empty; - private String _pubId = String.Empty; - private String _sysId = String.Empty; - private String _internalSubset = String.Empty; - private String _xmlLang = String.Empty; - private XmlSpace _xmlSpace; - private String _baseURI = String.Empty; - private Encoding _encoding = null; - - public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String xmlLang, XmlSpace xmlSpace) - : this(nt, nsMgr, null, null, null, null, String.Empty, xmlLang, xmlSpace) - { - // Intentionally Empty - } - - public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String xmlLang, XmlSpace xmlSpace, Encoding enc) - : this(nt, nsMgr, null, null, null, null, String.Empty, xmlLang, xmlSpace, enc) - { - // Intentionally Empty - } - - public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName, - String pubId, String sysId, String internalSubset, String baseURI, - String xmlLang, XmlSpace xmlSpace) - : this(nt, nsMgr, docTypeName, pubId, sysId, internalSubset, baseURI, xmlLang, xmlSpace, null) - { - // Intentionally Empty - } - - public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName, - String pubId, String sysId, String internalSubset, String baseURI, - String xmlLang, XmlSpace xmlSpace, Encoding enc) - { - if (nsMgr != null) - { - if (nt == null) - { - _nt = nsMgr.NameTable; - } - else - { - if ((object)nt != (object)nsMgr.NameTable) - { - throw new XmlException(ResXml.Xml_NotSameNametable, string.Empty); - } - _nt = nt; - } - } - else - { - _nt = nt; - } - - _nsMgr = nsMgr; - _docTypeName = (null == docTypeName ? String.Empty : docTypeName); - _pubId = (null == pubId ? String.Empty : pubId); - _sysId = (null == sysId ? String.Empty : sysId); - _internalSubset = (null == internalSubset ? String.Empty : internalSubset); - _baseURI = (null == baseURI ? String.Empty : baseURI); - _xmlLang = (null == xmlLang ? String.Empty : xmlLang); - _xmlSpace = xmlSpace; - _encoding = enc; - } - - public XmlNameTable NameTable - { - get - { - return _nt; - } - set - { - _nt = value; - } - } - - public XmlNamespaceManager NamespaceManager - { - get - { - return _nsMgr; - } - set - { - _nsMgr = value; - } - } - - public String DocTypeName - { - get - { - return _docTypeName; - } - set - { - _docTypeName = (null == value ? String.Empty : value); - } - } - - public String PublicId - { - get - { - return _pubId; - } - set - { - _pubId = (null == value ? String.Empty : value); - } - } - - public String SystemId - { - get - { - return _sysId; - } - set - { - _sysId = (null == value ? String.Empty : value); - } - } - - public String BaseURI - { - get - { - return _baseURI; - } - set - { - _baseURI = (null == value ? String.Empty : value); - } - } - - public String InternalSubset - { - get - { - return _internalSubset; - } - set - { - _internalSubset = (null == value ? String.Empty : value); - } - } - - public String XmlLang - { - get - { - return _xmlLang; - } - set - { - _xmlLang = (null == value ? String.Empty : value); - } - } - - public XmlSpace XmlSpace - { - get - { - return _xmlSpace; - } - set - { - _xmlSpace = value; - } - } - - public Encoding Encoding - { - get - { - return _encoding; - } - set - { - _encoding = value; - } - } - - internal bool HasDtdInfo - { - get - { - return (_internalSubset != string.Empty || _pubId != string.Empty || _sysId != string.Empty); - } - } - } // class XmlContext -} // namespace Microsoft.Xml - - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawTextWriterGenerator.cxxbak b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawTextWriterGenerator.cxxbak deleted file mode 100644 index 2e1b7bc0a8b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawTextWriterGenerator.cxxbak +++ /dev/null @@ -1,1927 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifdef SILVERLIGHT -// Note: This file was generated with #define SILVERLIGHT -#else -// Note: This file was generated without #define SILVERLIGHT -#endif - -#ifdef _XML_UTF8_TEXT_WRITER -#define _CLASS_NAME XmlUtf8RawTextWriter -#define _CLASS_NAME_INDENT XmlUtf8RawTextWriterIndent -#define _BUFFER bufBytes -#define _BUFFER_TYPE byte -#define _ENCODE_CHAR(entitizeInvalidChars) \ - /* Surrogate character */ \ - if ( XmlCharType.IsSurrogate( ch ) ) { \ - pDst = EncodeSurrogate( pSrc, pSrcEnd, pDst ); \ - pSrc += 2; \ - } \ - /* Invalid XML character */ \ - else if ( ch <= 0x7F || ch >= 0xFFFE ) { \ - pDst = InvalidXmlChar( ch, pDst, entitizeInvalidChars ); \ - pSrc++; \ - } \ - /* Multibyte UTF8 character */ \ - else { \ - pDst = EncodeMultibyteUTF8( ch, pDst ); \ - pSrc++; \ - } - -#define _SET_TEXT_CONTENT_MARK(value) -#endif - -#ifdef _XML_ENCODED_TEXT_WRITER -#define _CLASS_NAME XmlEncodedRawTextWriter -#define _CLASS_NAME_INDENT XmlEncodedRawTextWriterIndent -#define _BUFFER bufChars -#define _BUFFER_TYPE char -#define _ENCODE_CHAR(entitizeInvalidChars) \ - /* Surrogate character */ \ - if ( XmlCharType.IsSurrogate( ch ) ) { \ - pDst = EncodeSurrogate( pSrc, pSrcEnd, pDst ); \ - pSrc += 2; \ - } \ - /* Invalid XML character */ \ - else if ( ch <= 0x7F || ch >= 0xFFFE ) { \ - pDst = InvalidXmlChar( ch, pDst, entitizeInvalidChars ); \ - pSrc++; \ - } \ - /* Other character between SurLowEnd and 0xFFFE */ \ - else { \ - *pDst = (char)ch; \ - pDst++; \ - pSrc++; \ - } \ - -#define _SET_TEXT_CONTENT_MARK(value) \ - if ( trackTextContent && inTextContent != value ) { \ - ChangeTextContentMark( value ); \ - } - -#endif - -#define XMLCHARTYPE_TEST(ch, flag) ( ( xmlCharType.charProperties[ch] & XmlCharType.##flag ) != 0 ) -#define XMLCHARTYPE_ISATTRIBUTEVALUECHAR(ch) XMLCHARTYPE_TEST(ch, fAttrValue) -#define XMLCHARTYPE_ISTEXT(ch) XMLCHARTYPE_TEST(ch, fText) - - -using System; -using System.IO; -using Microsoft.Xml; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml { - - // Concrete implementation of XmlWriter abstract class that serializes events as encoded XML - // text. The general-purpose XmlEncodedTextWriter uses the Encoder class to output to any - // encoding. The XmlUtf8TextWriter class combined the encoding operation with serialization - // in order to achieve better performance. - internal class _CLASS_NAME : XmlRawWriter { -// -// Fields -// - // main buffer - protected byte[] bufBytes; - - // output stream - protected Stream stream; - - // encoding of the stream or text writer - protected Encoding encoding; - - // char type tables - protected XmlCharType xmlCharType = XmlCharType.Instance; - - // buffer positions - protected int bufPos = 1; // buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - protected int textPos = 1; // text end position; don't indent first element, pi, or comment - protected int contentPos; // element content end position - protected int cdataPos; // cdata end position - protected int attrEndPos; // end of the last attribute - protected int bufLen = BUFSIZE; - - // flags - protected bool writeToNull; - protected bool hadDoubleBracket; - protected bool inAttributeValue; - -#ifdef _XML_ENCODED_TEXT_WRITER - protected int bufBytesUsed; - protected char[] bufChars; - - // encoder for encoding chars in specified encoding when writing to stream - protected Encoder encoder; - - // output text writer - protected TextWriter writer; - - // escaping of characters invalid in the output encoding - protected bool trackTextContent; - protected bool inTextContent; - private int lastMarkPos; - private int[] textContentMarks; // even indices contain text content start positions - // odd indices contain markup start positions - private CharEntityEncoderFallback charEntityFallback; - -#endif - - // writer settings - protected NewLineHandling newLineHandling; - protected bool closeOutput; - protected bool omitXmlDeclaration; - protected string newLineChars; - protected bool checkCharacters; - protected XmlStandalone standalone; - protected XmlOutputMethod outputMethod; - protected bool autoXmlDeclaration; - protected bool mergeCDataSections; - -// -// Constants -// - private const int BUFSIZE = 2048 * 3; // Should be greater than default FileStream size (4096), otherwise the FileStream will try to cache the data - private const int OVERFLOW = 32; // Allow overflow in order to reduce checks when writing out constant size markup - private const int INIT_MARKS_COUNT = 64; - -// -// Constructors -// - // Construct and initialize an instance of this class. - protected _CLASS_NAME( XmlWriterSettings settings ) { - // copy settings - newLineHandling = settings.NewLineHandling; - omitXmlDeclaration = settings.OmitXmlDeclaration; - newLineChars = settings.NewLineChars; - checkCharacters = settings.CheckCharacters; - closeOutput = settings.CloseOutput; - - standalone = settings.Standalone; - outputMethod = settings.OutputMethod; - mergeCDataSections = settings.MergeCDataSections; - - if ( checkCharacters && newLineHandling == NewLineHandling.Replace ) { - ValidateContentChars( newLineChars, "NewLineChars", false ); - } - } - -#ifdef _XML_ENCODED_TEXT_WRITER - // Construct an instance of this class that outputs text to the TextWriter interface. - public _CLASS_NAME( TextWriter writer, XmlWriterSettings settings ) : this( settings ) { - Debug.Assert( writer != null && settings != null ); - - this.writer = writer; - this.encoding = writer.Encoding; - // the buffer is allocated will OVERFLOW in order to reduce checks when writing out constant size markup - this.bufChars = new _BUFFER_TYPE[BUFSIZE + OVERFLOW]; - - // Write the xml declaration - if (settings.AutoXmlDeclaration ) { - WriteXmlDeclaration( standalone ); - autoXmlDeclaration = true; - } - } -#endif - - // Construct an instance of this class that serializes to a Stream interface. - public _CLASS_NAME( Stream stream, XmlWriterSettings settings ) : this( settings ) { - Debug.Assert( stream != null && settings != null ); - - this.stream = stream; - this.encoding = settings.Encoding; - -#ifdef _XML_UTF8_TEXT_WRITER - // the buffer is allocated will OVERFLOW in order to reduce checks when writing out constant size markup - bufBytes = new _BUFFER_TYPE[ BUFSIZE + OVERFLOW ]; - - // Output UTF-8 byte order mark if Encoding object wants it - if ( !stream.CanSeek || stream.Position == 0 ) { - byte[] bom = encoding.GetPreamble(); - if ( bom.Length != 0 ) { - Buffer.BlockCopy( bom, 0, bufBytes, 1, bom.Length ); - bufPos += bom.Length; - textPos += bom.Length; - } - } -#else - // the buffer is allocated will OVERFLOW in order to reduce checks when writing out constant size markup - bufChars = new _BUFFER_TYPE[ BUFSIZE + OVERFLOW ]; - bufBytes = new byte[ bufChars.Length ]; - bufBytesUsed = 0; - - // Init escaping of characters not fitting into the target encoding - trackTextContent = true; - inTextContent = false; - lastMarkPos = 0; - textContentMarks = new int[INIT_MARKS_COUNT]; - textContentMarks[0] = 1; - - charEntityFallback = new CharEntityEncoderFallback(); - this.encoding = (Encoding)settings.Encoding.Clone(); - encoding.EncoderFallback = charEntityFallback; - - encoder = encoding.GetEncoder(); - - if ( !stream.CanSeek || stream.Position == 0 ) { - byte[] bom = encoding.GetPreamble(); - if ( bom.Length != 0 ) { - this.stream.Write( bom, 0, bom.Length ); - } - } -#endif - - // Write the xml declaration - if ( settings.AutoXmlDeclaration ) { - WriteXmlDeclaration( standalone ); - autoXmlDeclaration = true; - } - } - -// -// XmlWriter implementation -// - // Returns settings the writer currently applies. - public override XmlWriterSettings Settings { - get { - XmlWriterSettings settings = new XmlWriterSettings(); - - settings.Encoding = this.encoding; - settings.OmitXmlDeclaration = this.omitXmlDeclaration; - settings.NewLineHandling = this.newLineHandling; - settings.NewLineChars = this.newLineChars; - settings.CloseOutput = this.closeOutput; - settings.ConformanceLevel = ConformanceLevel.Auto; - settings.CheckCharacters = checkCharacters; - - settings.AutoXmlDeclaration = autoXmlDeclaration; - settings.Standalone = standalone; - settings.OutputMethod = outputMethod; - settings.ReadOnly = true; - return settings; - - } - } - - // Write the xml declaration. This must be the first call. - internal override void WriteXmlDeclaration( XmlStandalone standalone ) { - // Output xml declaration only if user allows it and it was not already output - if ( !omitXmlDeclaration && !autoXmlDeclaration ) { - - _SET_TEXT_CONTENT_MARK(false) - - RawText( "" ); - } - } - - internal override void WriteXmlDeclaration( string xmldecl ) { - // Output xml declaration only if user allows it and it was not already output - if ( !omitXmlDeclaration && !autoXmlDeclaration ) { - WriteProcessingInstruction( "xml", xmldecl ); - } - } - - // Serialize the document type declaration. - public override void WriteDocType( string name, string pubid, string sysid, string subset ) { - Debug.Assert( name != null && name.Length > 0 ); - - _SET_TEXT_CONTENT_MARK(false) - - RawText( "'; - } - - // Serialize the beginning of an element start tag: " 0 ); - Debug.Assert( prefix != null ); - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - if ( prefix != null && prefix.Length != 0 ) { - RawText( prefix ); - _BUFFER[this.bufPos++] = (_BUFFER_TYPE) ':'; - } - - RawText( localName ); - - attrEndPos = bufPos; - } - - // Serialize the end of an element start tag in preparation for content serialization: ">" - internal override void StartElementContent() { - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - - // StartElementContent is always called; therefore, in order to allow shortcut syntax, we save the - // position of the '>' character. If WriteEndElement is called and no other characters have been - // output, then the '>' character can be be overwritten with the shortcut syntax " />". - contentPos = bufPos; - } - - // Serialize an element end tag: "", if content was output. Otherwise, serialize - // the shortcut syntax: " />". - internal override void WriteEndElement( string prefix, string localName, string ns ) { - Debug.Assert( localName != null && localName.Length > 0 ); - Debug.Assert( prefix != null ); - - _SET_TEXT_CONTENT_MARK(false) - - if ( contentPos != bufPos ) { - // Content has been output, so can't use shortcut syntax - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '/'; - - if ( prefix != null && prefix.Length != 0) { - RawText( prefix ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) ':'; - } - RawText( localName ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - } - else { - // Use shortcut syntax; overwrite the already output '>' character - bufPos--; - _BUFFER[bufPos++] = (_BUFFER_TYPE) ' '; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '/'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - } - } - - // Serialize a full element end tag: "" - internal override void WriteFullEndElement( string prefix, string localName, string ns ) { - Debug.Assert( localName != null && localName.Length > 0 ); - Debug.Assert( prefix != null ); - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '/'; - - if ( prefix != null && prefix.Length != 0) { - RawText( prefix ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) ':'; - } - RawText( localName ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - } - - // Serialize an attribute tag using double quotes around the attribute value: 'prefix:localName="' - public override void WriteStartAttribute( string prefix, string localName, string ns ) { - Debug.Assert( localName != null && localName.Length > 0 ); - Debug.Assert( prefix != null ); - - _SET_TEXT_CONTENT_MARK(false) - - if ( attrEndPos == bufPos ) { - _BUFFER[bufPos++] = (_BUFFER_TYPE) ' '; - } - - if ( prefix != null && prefix.Length > 0 ) { - RawText( prefix ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) ':'; - } - RawText( localName ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) '='; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '"'; - - inAttributeValue = true; - } - - // Serialize the end of an attribute value using double quotes: '"' - public override void WriteEndAttribute() { - _SET_TEXT_CONTENT_MARK(false) - _BUFFER[bufPos++] = (_BUFFER_TYPE) '"'; - inAttributeValue = false; - attrEndPos = bufPos; - } - - internal override void WriteNamespaceDeclaration( string prefix, string namespaceName ) { - Debug.Assert( prefix != null && namespaceName != null ); - - this.WriteStartNamespaceDeclaration( prefix ); - this.WriteString( namespaceName ); - this.WriteEndNamespaceDeclaration(); - } - - internal override bool SupportsNamespaceDeclarationInChunks { - get { - return true; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) { - Debug.Assert( prefix != null ); - - _SET_TEXT_CONTENT_MARK(false) - - // VSTFDEVDIV bug #583965: Inconsistency between Silverlight 2 and Dev10 in the way a single xmlns attribute is serialized - // Resolved as: Won't fix (breaking change) - if ( prefix.Length == 0 ) { - RawText( " xmlns=\"" ); - } - else { - RawText( " xmlns:" ); - RawText( prefix ); - _BUFFER[bufPos++] = (_BUFFER_TYPE)'='; - _BUFFER[bufPos++] = (_BUFFER_TYPE)'"'; - } - - inAttributeValue = true; - _SET_TEXT_CONTENT_MARK(true) - } - - internal override void WriteEndNamespaceDeclaration() { - _SET_TEXT_CONTENT_MARK(false) - inAttributeValue = false; - - _BUFFER[bufPos++] = (_BUFFER_TYPE)'"'; - attrEndPos = bufPos; - } - - // Serialize a CData section. If the "]]>" pattern is found within - // the text, replace it with "]]>". - public override void WriteCData( string text ) { - Debug.Assert( text != null ); - - _SET_TEXT_CONTENT_MARK(false) - - if ( mergeCDataSections && bufPos == cdataPos ) { - // Merge adjacent cdata sections - overwrite the "]]>" characters - Debug.Assert( bufPos >= 4 ); - bufPos -= 3; - } - else { - // Start a new cdata section - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '!'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '['; - _BUFFER[bufPos++] = (_BUFFER_TYPE) 'C'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) 'D'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) 'A'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) 'T'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) 'A'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '['; - } - - WriteCDataSection( text ); - - _BUFFER[bufPos++] = (_BUFFER_TYPE) ']'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) ']'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - - textPos = bufPos; - cdataPos = bufPos; - } - - // Serialize a comment. - public override void WriteComment( string text ) { - Debug.Assert( text != null ); - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '!'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '-'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '-'; - - WriteCommentOrPi( text, '-' ); - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '-'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '-'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - } - - // Serialize a processing instruction. - public override void WriteProcessingInstruction( string name, string text ) { - Debug.Assert( name != null && name.Length > 0 ); - Debug.Assert( text != null ); - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '<'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '?'; - RawText( name ); - - if ( text.Length > 0 ) { - _BUFFER[bufPos++] = (_BUFFER_TYPE) ' '; - WriteCommentOrPi( text, '?' ); - } - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '?'; - _BUFFER[bufPos++] = (_BUFFER_TYPE) '>'; - } - - // Serialize an entity reference. - public override void WriteEntityRef( string name ) { - Debug.Assert( name != null && name.Length > 0 ); - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE) '&'; - RawText( name ); - _BUFFER[bufPos++] = (_BUFFER_TYPE) ';'; - - if ( bufPos > bufLen ) { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a character entity reference. - public override void WriteCharEntity( char ch ) { - string strVal = ((int)ch).ToString( "X", NumberFormatInfo.InvariantInfo ); - - if ( checkCharacters && !xmlCharType.IsCharData( ch ) ) { - // we just have a single char, not a surrogate, therefore we have to pass in '\0' for the second char - throw XmlConvert.CreateInvalidCharException( ch, '\0' ); - } - - _SET_TEXT_CONTENT_MARK(false) - - _BUFFER[bufPos++] = (_BUFFER_TYPE)'&'; - _BUFFER[bufPos++] = (_BUFFER_TYPE)'#'; - _BUFFER[bufPos++] = (_BUFFER_TYPE)'x'; - RawText( strVal ); - _BUFFER[bufPos++] = (_BUFFER_TYPE)';'; - - if ( bufPos > bufLen ) { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a whitespace node. - public override unsafe void WriteWhitespace( string ws ) { - Debug.Assert( ws != null ); - _SET_TEXT_CONTENT_MARK(false) - - fixed ( char * pSrc = ws ) { - char * pSrcEnd = pSrc + ws.Length; - if ( inAttributeValue) { - WriteAttributeTextBlock( pSrc, pSrcEnd ); - } - else { - WriteElementTextBlock( pSrc, pSrcEnd ); - } - } - } - - // Serialize either attribute or element text using XML rules. - public override unsafe void WriteString( string text ) { - Debug.Assert( text != null ); - _SET_TEXT_CONTENT_MARK(true) - - fixed ( char * pSrc = text ) { - char * pSrcEnd = pSrc + text.Length; - if ( inAttributeValue) { - WriteAttributeTextBlock( pSrc, pSrcEnd ); - } - else { - WriteElementTextBlock( pSrc, pSrcEnd ); - } - } - } - - // Serialize surrogate character entity. - public override void WriteSurrogateCharEntity( char lowChar, char highChar ) { - _SET_TEXT_CONTENT_MARK(false) - int surrogateChar = XmlCharType.CombineSurrogateChar( lowChar, highChar ); - - _BUFFER[bufPos++] = (_BUFFER_TYPE)'&'; - _BUFFER[bufPos++] = (_BUFFER_TYPE)'#'; - _BUFFER[bufPos++] = (_BUFFER_TYPE)'x'; - RawText( surrogateChar.ToString( "X", NumberFormatInfo.InvariantInfo ) ); - _BUFFER[bufPos++] = (_BUFFER_TYPE)';'; - textPos = bufPos; - } - - // Serialize either attribute or element text using XML rules. - // Arguments are validated in the XmlWellformedWriter layer. - public override unsafe void WriteChars( char[] buffer, int index, int count ) { - Debug.Assert( buffer != null ); - Debug.Assert( index >= 0 ); - Debug.Assert( count >= 0 && index + count <= buffer.Length ); - - _SET_TEXT_CONTENT_MARK(true) - - fixed ( char * pSrcBegin = &buffer[index] ) { - if ( inAttributeValue ) { - WriteAttributeTextBlock( pSrcBegin, pSrcBegin + count ); - } - else { - WriteElementTextBlock( pSrcBegin, pSrcBegin + count ); - } - } - } - - // Serialize raw data. - // Arguments are validated in the XmlWellformedWriter layer - public override unsafe void WriteRaw( char[] buffer, int index, int count ) { - Debug.Assert( buffer != null ); - Debug.Assert( index >= 0 ); - Debug.Assert( count >= 0 && index + count <= buffer.Length ); - - _SET_TEXT_CONTENT_MARK(false) - - fixed ( char * pSrcBegin = &buffer[index] ) { - WriteRawWithCharChecking( pSrcBegin, pSrcBegin + count ); - } - textPos = bufPos; - } - - // Serialize raw data. - public override unsafe void WriteRaw( string data ) { - Debug.Assert( data != null ); - - _SET_TEXT_CONTENT_MARK(false) - - fixed ( char * pSrcBegin = data ) { - WriteRawWithCharChecking( pSrcBegin, pSrcBegin + data.Length ); - } - textPos = bufPos; - } - - // Flush all bytes in the buffer to output and close the output stream or writer. - public override void Close() { - try { - FlushBuffer(); - FlushEncoder(); - } - finally { - // Future calls to Close or Flush shouldn't write to Stream or Writer - writeToNull = true; - - if ( stream != null ) { - try { - stream.Flush(); - } - finally { - try { - if ( closeOutput ) { - stream.Close(); - } - } - finally { - stream = null; - } - } - } -#ifndef _XML_UTF8_TEXT_WRITER - else if ( writer != null ) { - try { - writer.Flush(); - } - finally { - try { - if ( closeOutput ) { - writer.Close(); - } - } - finally { - writer = null; - } - } - } -#endif - } - } - - // Flush all characters in the buffer to output and call Flush() on the output object. - public override void Flush() { - FlushBuffer(); - FlushEncoder(); -#ifdef _XML_UTF8_TEXT_WRITER - if ( stream != null ) { - stream.Flush(); - } -#else - if ( stream != null ) { - stream.Flush(); - } - else if ( writer != null ) { - writer.Flush(); - } -#endif - } - -// -// Implementation methods -// - // Flush all characters in the buffer to output. Do not flush the output object. - protected virtual void FlushBuffer() { - try { - // Output all characters (except for previous characters stored at beginning of buffer) - if ( !writeToNull ) { -#ifdef _XML_UTF8_TEXT_WRITER - Debug.Assert( stream != null); - stream.Write( bufBytes, 1, bufPos - 1 ); -#else - Debug.Assert( stream != null || writer != null ); - - if ( stream != null ) { - if ( trackTextContent ) { - charEntityFallback.Reset( textContentMarks, lastMarkPos ); - // reset text content tracking - - if ((lastMarkPos & 1) != 0) { - // If the previous buffer ended inside a text content we need to preserve that info - // which means the next index to which we write has to be even - textContentMarks[1] = 1; - lastMarkPos = 1; - } - else { - lastMarkPos = 0; - } - Debug.Assert( textContentMarks[0] == 1 ); - } - EncodeChars( 1, bufPos, true ); - } - else { - // Write text to TextWriter - writer.Write( bufChars, 1, bufPos - 1 ); - } -#endif - } - } - catch { - // Future calls to flush (i.e. when Close() is called) don't attempt to write to stream - writeToNull = true; - throw; - } - finally { - // Move last buffer character to the beginning of the buffer (so that previous character can always be determined) - _BUFFER[0] = _BUFFER[bufPos - 1]; - -#ifdef _XML_UTF8_TEXT_WRITER - if ( IsSurrogateByte( _BUFFER[0] ) ) { - // Last character was the first byte in a surrogate encoding, so move last three - // bytes of encoding to the beginning of the buffer. - _BUFFER[1] = _BUFFER[bufPos]; - _BUFFER[2] = _BUFFER[bufPos + 1]; - _BUFFER[3] = _BUFFER[bufPos + 2]; - } -#endif - - // Reset buffer position - textPos = (textPos == bufPos) ? 1 : 0; - attrEndPos = (attrEndPos == bufPos) ? 1 : 0; - contentPos = 0; // Needs to be zero, since overwriting '>' character is no longer possible - cdataPos = 0; // Needs to be zero, since overwriting ']]>' characters is no longer possible - bufPos = 1; // Buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - } - } - -#if _XML_UTF8_TEXT_WRITER - private void FlushEncoder() { - // intentionally empty - } -#else - private void EncodeChars( int startOffset, int endOffset, bool writeAllToStream ) { - // Write encoded text to stream - int chEnc; - int bEnc; - bool completed; - while ( startOffset < endOffset ) { - if ( charEntityFallback != null ) { - charEntityFallback.StartOffset = startOffset; - } - encoder.Convert( bufChars, startOffset, endOffset - startOffset, bufBytes, bufBytesUsed, bufBytes.Length - bufBytesUsed, false, out chEnc, out bEnc, out completed ); - startOffset += chEnc; - bufBytesUsed += bEnc; - if ( bufBytesUsed >= ( bufBytes.Length - 16 ) ) { - stream.Write( bufBytes, 0, bufBytesUsed ); - bufBytesUsed = 0; - } - } - if ( writeAllToStream && bufBytesUsed > 0 ) { - stream.Write( bufBytes, 0, bufBytesUsed ); - bufBytesUsed = 0; - } - } - - private void FlushEncoder() { - Debug.Assert( bufPos == 1 ); - if ( stream != null ) { - int chEnc; - int bEnc; - bool completed; - // decode no chars, just flush - encoder.Convert( bufChars, 1, 0, bufBytes, 0, bufBytes.Length, true, out chEnc, out bEnc, out completed ); - if ( bEnc != 0 ) { - stream.Write( bufBytes, 0, bEnc ); - } - } - } -#endif - - // Serialize text that is part of an attribute value. The '&', '<', '>', and '"' characters - // are entitized. - protected unsafe void WriteAttributeTextBlock( char *pSrc, char *pSrcEnd ) { - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - _BUFFER_TYPE * pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + bufLen ) { - pDstEnd = pDstBegin + bufLen; - } - -#if _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) && ch <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) ) ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; - pSrc++; - } - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch ( ch ) { - case '&': - pDst = AmpEntity( pDst ); - break; - case '<': - pDst = LtEntity( pDst ); - break; - case '>': - pDst = GtEntity( pDst ); - break; - case '"': - pDst = QuoteEntity( pDst ); - break; - case '\'': - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - case (char)0x9: - if ( newLineHandling == NewLineHandling.None ) { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - else { - // escape tab in attributes - pDst = TabEntity( pDst ); - } - break; - case (char)0xD: - if ( newLineHandling == NewLineHandling.None ) { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - else { - // escape new lines in attributes - pDst = CarriageReturnEntity( pDst ); - } - break; - case (char)0xA: - if ( newLineHandling == NewLineHandling.None ) { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - else { - // escape new lines in attributes - pDst = LineFeedEntity( pDst ); - } - break; - default: - _ENCODE_CHAR(true); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // Serialize text that is part of element content. The '&', '<', and '>' characters - // are entitized. - protected unsafe void WriteElementTextBlock( char *pSrc, char *pSrcEnd ) { - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - _BUFFER_TYPE * pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + bufLen ) { - pDstEnd = pDstBegin + bufLen; - } - -#if _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) && ch <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) ) ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; - pSrc++; - } - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch ( ch ) { - case '&': - pDst = AmpEntity( pDst ); - break; - case '<': - pDst = LtEntity( pDst ); - break; - case '>': - pDst = GtEntity( pDst ); - break; - case '"': - case '\'': - case (char)0x9: - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - case (char)0xA: - if ( newLineHandling == NewLineHandling.Replace ) { - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case (char)0xD: - switch ( newLineHandling ) { - case NewLineHandling.Replace: - // Replace "\r\n", or "\r" with NewLineChars - if ( pSrc[1] == '\n' ) { - pSrc++; - } - pDst = WriteNewLine( pDst ); - break; - case NewLineHandling.Entitize: - // Entitize 0xD - pDst = CarriageReturnEntity( pDst ); - break; - case NewLineHandling.None: - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - } - break; - default: - _ENCODE_CHAR(true); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - textPos = bufPos; - contentPos = 0; - } - } - - protected unsafe void RawText( string s ) { - Debug.Assert( s != null ); - fixed ( char * pSrcBegin = s ) { - RawText( pSrcBegin, pSrcBegin + s.Length ); - } - } - - protected unsafe void RawText( char * pSrcBegin, char * pSrcEnd ) { - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - _BUFFER_TYPE * pDst = pDstBegin + this.bufPos; - char * pSrc = pSrcBegin; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + this.bufLen ) { - pDstEnd = pDstBegin + this.bufLen; - } - -#ifdef _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( ( ch = *pSrc ) <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( ( ch = *pSrc ) < XmlCharType.SurHighStart ) ) { -#endif - pSrc++; - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - _ENCODE_CHAR(false); - } - - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteRawWithCharChecking( char * pSrcBegin, char * pSrcEnd ) { - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - char * pSrc = pSrcBegin; - _BUFFER_TYPE * pDst = pDstBegin + bufPos; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + bufLen ) { - pDstEnd = pDstBegin + bufLen; - } - -#ifdef _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISTEXT( ( ch = *pSrc ) ) && ch <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISTEXT( ( ch = *pSrc ) ) ) ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; - pSrc++; - } - - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch ( ch ) { - case ']': - case '<': - case '&': - case (char)0x9: - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - case (char)0xD: - if ( newLineHandling == NewLineHandling.Replace ) { - // Normalize "\r\n", or "\r" to NewLineChars - if ( pSrc[1] == '\n' ) { - pSrc++; - } - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case (char)0xA: - if ( newLineHandling == NewLineHandling.Replace ) { - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - default: - _ENCODE_CHAR(false); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCommentOrPi( string text, int stopChar ) { - if ( text.Length == 0 ) { - if ( bufPos >= bufLen ) { - FlushBuffer(); - } - return; - } - // write text - fixed ( char * pSrcBegin = text ) - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - char * pSrc = pSrcBegin; - char * pSrcEnd = pSrcBegin + text.Length; - _BUFFER_TYPE * pDst = pDstBegin + bufPos; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + bufLen ) { - pDstEnd = pDstBegin + bufLen; - } - -#ifdef _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISTEXT( ( ch = *pSrc ) ) && ch != stopChar && ch <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISTEXT( ( ch = *pSrc ) ) && ch != stopChar ) ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; - pSrc++; - } - - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch ( ch ) { - case '-': - *pDst = (_BUFFER_TYPE) '-'; - pDst++; - if ( ch == stopChar ) { - // Insert space between adjacent dashes or before comment's end dashes - if ( pSrc + 1 == pSrcEnd || *(pSrc + 1)== '-' ) { - *pDst = (_BUFFER_TYPE) ' '; - pDst++; - } - } - break; - case '?': - *pDst = (_BUFFER_TYPE) '?'; - pDst++; - if ( ch == stopChar ) { - // Processing instruction: insert space between adjacent '?' and '>' - if ( pSrc + 1 < pSrcEnd && *(pSrc + 1)== '>' ) { - *pDst = (_BUFFER_TYPE) ' '; - pDst++; - } - } - break; - case ']': - *pDst = (_BUFFER_TYPE) ']'; - pDst++; - break; - case (char)0xD: - if ( newLineHandling == NewLineHandling.Replace ) { - // Normalize "\r\n", or "\r" to NewLineChars - if ( pSrc[1] == '\n' ) { - pSrc++; - } - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case (char)0xA: - if ( newLineHandling == NewLineHandling.Replace ) { - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case '<': - case '&': - case (char)0x9: - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - default: - _ENCODE_CHAR(false); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCDataSection( string text ) { - if ( text.Length == 0 ) { - if ( bufPos >= bufLen ) { - FlushBuffer(); - } - return; - } - // write text - fixed ( char * pSrcBegin = text ) - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - char * pSrc = pSrcBegin; - char * pSrcEnd = pSrcBegin + text.Length; - _BUFFER_TYPE * pDst = pDstBegin + bufPos; - - int ch = 0; - for (;;) { - _BUFFER_TYPE * pDstEnd = pDst + ( pSrcEnd - pSrc ); - if ( pDstEnd > pDstBegin + bufLen ) { - pDstEnd = pDstBegin + bufLen; - } - -#ifdef _XML_UTF8_TEXT_WRITER - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) && ch != ']' && ch <= 0x7F ) ) { -#else - while ( pDst < pDstEnd && ( XMLCHARTYPE_ISATTRIBUTEVALUECHAR( ( ch = *pSrc ) ) && ch != ']' ) ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; - pSrc++; - } - - Debug.Assert( pSrc <= pSrcEnd ); - - // end of value - if ( pSrc >= pSrcEnd ) { - break; - } - - // end of buffer - if ( pDst >= pDstEnd ) { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch ( ch ) { - case '>': - if ( hadDoubleBracket && pDst[-1] == (_BUFFER_TYPE) ']') { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - // The characters "]]>" were found within the CData text - pDst = RawEndCData( pDst ); - pDst = RawStartCData( pDst ); - } - *pDst = (_BUFFER_TYPE) '>'; - pDst++; - break; - case ']': - if ( pDst[-1] == (_BUFFER_TYPE)']' ) { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - hadDoubleBracket = true; - } - else { - hadDoubleBracket = false; - } - *pDst = (_BUFFER_TYPE)']'; - pDst++; - break; - case (char)0xD: - if ( newLineHandling == NewLineHandling.Replace ) { - // Normalize "\r\n", or "\r" to NewLineChars - if ( pSrc[1] == '\n' ) { - pSrc++; - } - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case (char)0xA: - if ( newLineHandling == NewLineHandling.Replace ) { - pDst = WriteNewLine( pDst ); - } - else { - *pDst = (_BUFFER_TYPE)ch; - pDst++; - } - break; - case '&': - case '<': - case '"': - case '\'': - case (char)0x9: - *pDst = (_BUFFER_TYPE)ch; - pDst++; - break; - default: - _ENCODE_CHAR(false); - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - -#ifdef _XML_UTF8_TEXT_WRITER - // Returns true if UTF8 encoded byte is first of four bytes that encode a surrogate pair. - // To do this, detect the bit pattern 11110xxx. - private static bool IsSurrogateByte( byte b ) { - return (b & 0xF8) == 0xF0; - } -#endif - - private static unsafe _BUFFER_TYPE* EncodeSurrogate( char* pSrc, char* pSrcEnd, _BUFFER_TYPE* pDst ) { - Debug.Assert( XmlCharType.IsSurrogate( *pSrc ) ); - - int ch = *pSrc; - if ( ch <= XmlCharType.SurHighEnd ) { - if ( pSrc + 1 < pSrcEnd ) { - int lowChar = pSrc[1]; - if ( lowChar >= XmlCharType.SurLowStart ) { -#ifdef _XML_UTF8_TEXT_WRITER - // Calculate Unicode scalar value for easier manipulations (see section 3.7 in Unicode spec) - // The scalar value repositions surrogate values to start at 0x10000. - - ch = XmlCharType.CombineSurrogateChar( lowChar, ch ); - - pDst[0] = (byte)( 0xF0 | ( ch >> 18 ) ); - pDst[1] = (byte)( 0x80 | ( ch >> 12 ) & 0x3F ); - pDst[2] = (byte)( 0x80 | ( ch >> 6 ) & 0x3F ); - pDst[3] = (byte)( 0x80 | ch & 0x3F); - pDst += 4; -#else - pDst[0] = (char)ch; - pDst[1] = (char)lowChar; - pDst += 2; -#endif - return pDst; - } - throw XmlConvert.CreateInvalidSurrogatePairException( (char)lowChar, (char)ch ); - } - throw new ArgumentException( Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar ) ); - } - throw XmlConvert.CreateInvalidHighSurrogateCharException( (char)ch ); - } - - private unsafe _BUFFER_TYPE* InvalidXmlChar( int ch, _BUFFER_TYPE* pDst, bool entitize ) { - Debug.Assert( !xmlCharType.IsWhiteSpace( (char)ch ) ); - Debug.Assert( !xmlCharType.IsAttributeValueChar( (char)ch ) ); - - if ( checkCharacters ) { - // This method will never be called on surrogates, so it is ok to pass in '\0' to the CreateInvalidCharException - throw XmlConvert.CreateInvalidCharException( (char)ch, '\0' ); - } - else { - if ( entitize ) { - return CharEntity( pDst, (char)ch ); - } - else { -#ifdef _XML_UTF8_TEXT_WRITER - if ( ch < 0x80 ) { -#endif - *pDst = (_BUFFER_TYPE)ch; - pDst++; -#ifdef _XML_UTF8_TEXT_WRITER - } - else { - pDst = EncodeMultibyteUTF8( ch, pDst ); - } -#endif - return pDst; - } - } - } - - internal unsafe void EncodeChar(ref char* pSrc, char*pSrcEnd, ref _BUFFER_TYPE* pDst) { - int ch = *pSrc; - _ENCODE_CHAR(false); - } - -#ifdef _XML_UTF8_TEXT_WRITER - internal static unsafe byte* EncodeMultibyteUTF8( int ch, byte* pDst ) { - Debug.Assert( ch >= 0x80 && !XmlCharType.IsSurrogate( ch ) ); - - /* UTF8-2: If ch is in 0x80-0x7ff range, then use 2 bytes to encode it */ \ - if ( ch < 0x800 ) { - *pDst = (byte)( unchecked((sbyte)0xC0) | (ch >> 6) ); - } - /* UTF8-3: If ch is anything else, then default to using 3 bytes to encode it. */ - else { - *pDst = (byte)( unchecked((sbyte)0xE0) | ( ch >> 12 ) ); - pDst++; - - *pDst = (byte)( unchecked((sbyte)0x80) | ( ch >> 6 ) & 0x3F); - } - pDst++; - *pDst = (byte)( 0x80 | ch & 0x3F ); - return pDst + 1; - } - - // Encode *pSrc as a sequence of UTF8 bytes. Write the bytes to pDst and return an updated pointer. - internal static unsafe void CharToUTF8( ref char * pSrc, char * pSrcEnd, ref byte * pDst ) { - int ch = *pSrc; - if ( ch <= 0x7F ) { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - else if ( XmlCharType.IsSurrogate( ch ) ) { - pDst = EncodeSurrogate( pSrc, pSrcEnd, pDst ); - pSrc += 2; - } - else { - pDst = EncodeMultibyteUTF8( ch, pDst ); - pSrc++; - } - } - -#endif - -#ifdef _XML_ENCODED_TEXT_WRITER - - protected void ChangeTextContentMark( bool value ) { - Debug.Assert( inTextContent != value ); - Debug.Assert( inTextContent || ((lastMarkPos & 1) == 0) ); - inTextContent = value; - if ( lastMarkPos + 1 == textContentMarks.Length ) { - GrowTextContentMarks(); - } - textContentMarks[++lastMarkPos] = this.bufPos; - } - - private void GrowTextContentMarks() { - Debug.Assert( lastMarkPos + 1 == textContentMarks.Length ); - int[] newTextContentMarks = new int[ textContentMarks.Length * 2 ]; - Array.Copy( textContentMarks, newTextContentMarks, textContentMarks.Length ); - textContentMarks = newTextContentMarks; - } - -#endif - - // Write NewLineChars to the specified buffer position and return an updated position. - protected unsafe _BUFFER_TYPE * WriteNewLine( _BUFFER_TYPE * pDst ) { - fixed ( _BUFFER_TYPE * pDstBegin = _BUFFER ) { - bufPos = (int) (pDst - pDstBegin); - // Let RawText do the real work - RawText( newLineChars ); - return pDstBegin + bufPos; - } - } - - // Following methods do not check whether pDst is beyond the bufSize because the buffer was allocated with a OVERFLOW to accomodate - // for the writes of small constant-length string as below. - - // Entitize '<' as "<". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * LtEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'l'; - pDst[2] = (_BUFFER_TYPE)'t'; - pDst[3] = (_BUFFER_TYPE)';'; - return pDst + 4; - } - - // Entitize '>' as ">". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * GtEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'g'; - pDst[2] = (_BUFFER_TYPE)'t'; - pDst[3] = (_BUFFER_TYPE)';'; - return pDst + 4; - } - - // Entitize '&' as "&". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * AmpEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'a'; - pDst[2] = (_BUFFER_TYPE)'m'; - pDst[3] = (_BUFFER_TYPE)'p'; - pDst[4] = (_BUFFER_TYPE)';'; - return pDst + 5; - } - - // Entitize '"' as """. Return an updated pointer. - protected static unsafe _BUFFER_TYPE * QuoteEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'q'; - pDst[2] = (_BUFFER_TYPE)'u'; - pDst[3] = (_BUFFER_TYPE)'o'; - pDst[4] = (_BUFFER_TYPE)'t'; - pDst[5] = (_BUFFER_TYPE)';'; - return pDst + 6; - } - - // Entitize '\t' as " ". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * TabEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'#'; - pDst[2] = (_BUFFER_TYPE)'x'; - pDst[3] = (_BUFFER_TYPE)'9'; - pDst[4] = (_BUFFER_TYPE)';'; - return pDst + 5; - } - - // Entitize 0xa as " ". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * LineFeedEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'#'; - pDst[2] = (_BUFFER_TYPE)'x'; - pDst[3] = (_BUFFER_TYPE)'A'; - pDst[4] = (_BUFFER_TYPE)';'; - return pDst + 5; - } - - // Entitize 0xd as " ". Return an updated pointer. - protected static unsafe _BUFFER_TYPE * CarriageReturnEntity( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'#'; - pDst[2] = (_BUFFER_TYPE)'x'; - pDst[3] = (_BUFFER_TYPE)'D'; - pDst[4] = (_BUFFER_TYPE)';'; - return pDst + 5; - } - - private static unsafe _BUFFER_TYPE * CharEntity( _BUFFER_TYPE * pDst, char ch ) { - string s = ((int)ch).ToString( "X",NumberFormatInfo.InvariantInfo ); - pDst[0] = (_BUFFER_TYPE)'&'; - pDst[1] = (_BUFFER_TYPE)'#'; - pDst[2] = (_BUFFER_TYPE)'x'; - pDst += 3; - - fixed ( char *pSrc = s ) { - char *pS = pSrc; - while ( ( *pDst++ = (_BUFFER_TYPE)*pS++ ) != 0 ); - } - - pDst[-1] = (_BUFFER_TYPE)';'; - return pDst; - } - - // Write "" to the specified buffer. Return an updated pointer. - protected static unsafe _BUFFER_TYPE * RawEndCData( _BUFFER_TYPE * pDst ) { - pDst[0] = (_BUFFER_TYPE)']'; - pDst[1] = (_BUFFER_TYPE)']'; - pDst[2] = (_BUFFER_TYPE)'>'; - return pDst + 3; - } - - protected unsafe void ValidateContentChars( string chars, string propertyName, bool allowOnlyWhitespace ) { - if ( allowOnlyWhitespace ) { - if ( !xmlCharType.IsOnlyWhitespace( chars ) ) { - throw new ArgumentException( Res.GetString( Res.Xml_IndentCharsNotWhitespace, propertyName ) ); - } - } - else { - string error = null; - for ( int i = 0; i < chars.Length; i++ ) { - if ( !xmlCharType.IsTextChar( chars[i] ) ) { - switch ( chars[i] ) { - case '\n': - case '\r': - case '\t': - continue; - case '<': - case '&': - case ']': - error = Res.GetString( Res.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs( chars, i ) ); - goto Error; - default: - if ( XmlCharType.IsHighSurrogate(chars[i]) ) { - if ( i + 1 < chars.Length ) { - if ( XmlCharType.IsLowSurrogate(chars[i + 1]) ) { - i++; - continue; - } - } - error = Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar ); - goto Error; - } - else if ( XmlCharType.IsLowSurrogate(chars[i]) ) { - error = Res.GetString( Res.Xml_InvalidSurrogateHighChar, ((uint)chars[i]).ToString( "X", CultureInfo.InvariantCulture ) ); - goto Error; - } - continue; - } - } - } - return; - - Error: - throw new ArgumentException( Res.GetString( Res.Xml_InvalidCharsInIndent, new string[] { propertyName, error } ) ); - } - } - } - - // Same as base text writer class except that elements, attributes, comments, and pi's are indented. - internal class _CLASS_NAME_INDENT : _CLASS_NAME { -// -// Fields -// - protected int indentLevel; - protected bool newLineOnAttributes; - protected string indentChars; - - protected bool mixedContent; - private BitStack mixedContentStack; - - protected ConformanceLevel conformanceLevel = ConformanceLevel.Auto; - -// -// Constructors -// - -#ifdef _XML_ENCODED_TEXT_WRITER - public _CLASS_NAME_INDENT( TextWriter writer, XmlWriterSettings settings ) : base( writer, settings ) { - Init( settings ); - } -#endif - - public _CLASS_NAME_INDENT( Stream stream, XmlWriterSettings settings ) : base( stream, settings ) { - Init( settings ); - } - -// -// XmlWriter methods -// - public override XmlWriterSettings Settings { - get { - XmlWriterSettings settings = base.Settings; - - settings.ReadOnly = false; - settings.Indent = true; - settings.IndentChars = indentChars; - settings.NewLineOnAttributes = newLineOnAttributes; - settings.ReadOnly = true; - - return settings; - } - } - - public override void WriteDocType( string name, string pubid, string sysid, string subset ) { - // Add indentation - if ( !mixedContent && base.textPos != base.bufPos) { - WriteIndent(); - } - base.WriteDocType( name, pubid, sysid, subset ); - } - - public override void WriteStartElement( string prefix, string localName, string ns ) { - Debug.Assert( localName != null && localName.Length != 0 && prefix != null && ns != null ); - - // Add indentation - if ( !mixedContent && base.textPos != base.bufPos) { - WriteIndent(); - } - indentLevel++; - mixedContentStack.PushBit( mixedContent ); - - base.WriteStartElement( prefix, localName, ns ); - } - - internal override void StartElementContent() { - // If this is the root element and we're writing a document - // do not inherit the mixedContent flag into the root element. - // This is to allow for whitespace nodes on root level - // without disabling indentation for the whole document. - if (indentLevel == 1 && conformanceLevel == ConformanceLevel.Document) { - mixedContent = false; - } - else { - mixedContent = mixedContentStack.PeekBit(); - } - base.StartElementContent(); - } - - internal override void OnRootElement(ConformanceLevel currentConformanceLevel) { - // Just remember the current conformance level - conformanceLevel = currentConformanceLevel; - } - - internal override void WriteEndElement(string prefix, string localName, string ns) { - // Add indentation - indentLevel--; - if ( !mixedContent && base.contentPos != base.bufPos ) { - // There was content, so try to indent - if ( base.textPos != base.bufPos ) { - WriteIndent(); - } - } - mixedContent = mixedContentStack.PopBit(); - - base.WriteEndElement( prefix, localName, ns ); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) { - // Add indentation - indentLevel--; - if ( !mixedContent && base.contentPos != base.bufPos ) { - // There was content, so try to indent - if ( base.textPos != base.bufPos ) { - WriteIndent(); - } - } - mixedContent = mixedContentStack.PopBit(); - - base.WriteFullEndElement( prefix, localName, ns ); - } - - // Same as base class, plus possible indentation. - public override void WriteStartAttribute( string prefix, string localName, string ns ) { - // Add indentation - if ( newLineOnAttributes ) { - WriteIndent(); - } - - base.WriteStartAttribute( prefix, localName, ns ); - } - - public override void WriteCData( string text ) { - mixedContent = true; - base.WriteCData( text ); - } - - public override void WriteComment( string text ) { - if ( !mixedContent && base.textPos != base.bufPos ) { - WriteIndent(); - } - - base.WriteComment( text ); - } - - public override void WriteProcessingInstruction( string target, string text ) { - if ( !mixedContent && base.textPos != base.bufPos ) { - WriteIndent(); - } - - base.WriteProcessingInstruction( target, text ); - } - - public override void WriteEntityRef( string name ) { - mixedContent = true; - base.WriteEntityRef( name ); - } - - public override void WriteCharEntity( char ch ) { - mixedContent = true; - base.WriteCharEntity( ch ); - } - - public override void WriteSurrogateCharEntity( char lowChar, char highChar ) { - mixedContent = true; - base.WriteSurrogateCharEntity( lowChar, highChar ); - } - - public override void WriteWhitespace( string ws ) { - mixedContent = true; - base.WriteWhitespace( ws ); - } - - public override void WriteString( string text ) { - mixedContent = true; - base.WriteString( text ); - } - - public override void WriteChars( char[] buffer, int index, int count ) { - mixedContent = true; - base.WriteChars( buffer, index, count ); - } - - public override void WriteRaw( char[] buffer, int index, int count ) { - mixedContent = true; - base.WriteRaw( buffer, index, count ); - } - - public override void WriteRaw( string data ) { - mixedContent = true; - base.WriteRaw( data ); - } - - public override void WriteBase64( byte[] buffer, int index, int count ) { - mixedContent = true; - base.WriteBase64( buffer, index, count ); - } - -// -// Private methods -// - private void Init( XmlWriterSettings settings ) { - indentLevel = 0; - indentChars = settings.IndentChars; - newLineOnAttributes = settings.NewLineOnAttributes; - mixedContentStack = new BitStack(); - - // check indent characters that they are valid XML characters - if ( base.checkCharacters ) { - if ( newLineOnAttributes ) { - base.ValidateContentChars( indentChars, "IndentChars", true ); - base.ValidateContentChars( newLineChars, "NewLineChars", true ); - } - else { - base.ValidateContentChars( indentChars, "IndentChars", false ); - if ( base.newLineHandling != NewLineHandling.Replace ) { - base.ValidateContentChars( newLineChars, "NewLineChars", false ); - } - } - } - } - - // Add indentation to output. Write newline and then repeat IndentChars for each indent level. - private void WriteIndent() { - RawText( base.newLineChars ); - for ( int i = indentLevel; i > 0; i-- ) { - RawText( indentChars ); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawWriter.cs deleted file mode 100644 index 2333d771a3c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlRawWriter.cs +++ /dev/null @@ -1,325 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Diagnostics; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; -using System.Collections; - -namespace Microsoft.Xml -{ - using System; - - - /// - /// Implementations of XmlRawWriter are intended to be wrapped by the XmlWellFormedWriter. The - /// well-formed writer performs many checks in behalf of the raw writer, and keeps state that the - /// raw writer otherwise would have to keep. Therefore, the well-formed writer will call the - /// XmlRawWriter using the following rules, in order to make raw writers easier to implement: - /// - /// 1. The well-formed writer keeps a stack of element names, and always calls - /// WriteEndElement(string, string, string) instead of WriteEndElement(). - /// 2. The well-formed writer tracks namespaces, and will pass himself in via the - /// WellformedWriter property. It is used in the XmlRawWriter's implementation of IXmlNamespaceResolver. - /// Thus, LookupPrefix does not have to be implemented. - /// 3. The well-formed writer tracks write states, so the raw writer doesn't need to. - /// 4. The well-formed writer will always call StartElementContent. - /// 5. The well-formed writer will always call WriteNamespaceDeclaration for namespace nodes, - /// rather than calling WriteStartAttribute(). If the writer is supporting namespace declarations in chunks - /// (SupportsNamespaceDeclarationInChunks is true), the XmlWellFormedWriter will call WriteStartNamespaceDeclaration, - /// then any method that can be used to write out a value of an attribute (WriteString, WriteChars, WriteRaw, WriteCharEntity...) - /// and then WriteEndNamespaceDeclaration - instead of just a single WriteNamespaceDeclaration call. This feature will be - /// supported by raw writers serializing to text that wish to preserve the attribute value escaping etc. - /// 6. The well-formed writer guarantees a well-formed document, including correct call sequences, - /// correct namespaces, and correct document rule enforcement. - /// 7. All element and attribute names will be fully resolved and validated. Null will never be - /// passed for any of the name parts. - /// 8. The well-formed writer keeps track of xml:space and xml:lang. - /// 9. The well-formed writer verifies NmToken, Name, and QName values and calls WriteString(). - /// - internal abstract partial class XmlRawWriter : XmlWriter - { - // - // Fields - // - // base64 converter - protected XmlRawWriterBase64Encoder base64Encoder; - - // namespace resolver - protected IXmlNamespaceResolver resolver; - - // - // XmlWriter implementation - // - - // Raw writers do not have to track whether this is a well-formed document. - public override void WriteStartDocument() - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteStartDocument(bool standalone) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteEndDocument() - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - } - - // Raw writers do not have to keep a stack of element names. - public override void WriteEndElement() - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // Raw writers do not have to keep a stack of element names. - public override void WriteFullEndElement() - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // By default, convert base64 value to string and call WriteString. - public override void WriteBase64(byte[] buffer, int index, int count) - { - if (base64Encoder == null) - { - base64Encoder = new XmlRawWriterBase64Encoder(this); - } - // Encode will call WriteRaw to write out the encoded characters - base64Encoder.Encode(buffer, index, count); - } - - // Raw writers do not have to keep track of namespaces. - public override string LookupPrefix(string ns) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // Raw writers do not have to keep track of write states. - public override WriteState WriteState - { - get - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - } - - // Raw writers do not have to keep track of xml:space. - public override XmlSpace XmlSpace - { - get { throw new InvalidOperationException(ResXml.Xml_InvalidOperation); } - } - - // Raw writers do not have to keep track of xml:lang. - public override string XmlLang - { - get { throw new InvalidOperationException(ResXml.Xml_InvalidOperation); } - } - - // Raw writers do not have to verify NmToken values. - public override void WriteNmToken(string name) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // Raw writers do not have to verify Name values. - public override void WriteName(string name) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // Raw writers do not have to verify QName values. - public override void WriteQualifiedName(string localName, string ns) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // Forward call to WriteString(string). - public override void WriteCData(string text) - { - WriteString(text); - } - - // Forward call to WriteString(string). - public override void WriteCharEntity(char ch) - { - WriteString(new string(new char[] { ch })); - } - - // Forward call to WriteString(string). - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - WriteString(new string(new char[] { lowChar, highChar })); - } - - // Forward call to WriteString(string). - public override void WriteWhitespace(string ws) - { - WriteString(ws); - } - - // Forward call to WriteString(string). - public override void WriteChars(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - // Forward call to WriteString(string). - public override void WriteRaw(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - // Forward call to WriteString(string). - public override void WriteRaw(string data) - { - WriteString(data); - } - - // Override in order to handle Xml simple typed values and to pass resolver for QName values - public override void WriteValue(object value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - WriteString(XmlUntypedConverter.Untyped.ToString(value, resolver)); - } - - // Override in order to handle Xml simple typed values and to pass resolver for QName values - public override void WriteValue(string value) - { - WriteString(value); - } - - public override void WriteValue(DateTimeOffset value) - { - // For compatibility with custom writers, XmlWriter writes DateTimeOffset as DateTime. - // Our internal writers should use the DateTimeOffset-String conversion from XmlConvert. - WriteString(XmlConvert.ToString(value)); - } - - // Copying to XmlRawWriter is not currently supported. - public override void WriteAttributes(XmlReader reader, bool defattr) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteNode(XmlReader reader, bool defattr) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override void WriteNode(Microsoft.Xml.XPath.XPathNavigator navigator, bool defattr) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - // - // XmlRawWriter methods and properties - // - - // Get and set the namespace resolver that's used by this RawWriter to resolve prefixes. - internal virtual IXmlNamespaceResolver NamespaceResolver - { - get - { - return resolver; - } - set - { - resolver = value; - } - } - - // Write the xml declaration. This must be the first call. - internal virtual void WriteXmlDeclaration(XmlStandalone standalone) - { - } - internal virtual void WriteXmlDeclaration(string xmldecl) - { - } - - // Called after an element's attributes have been enumerated, but before any children have been - // enumerated. This method must always be called, even for empty elements. - - internal abstract void StartElementContent(); - - // Called before a root element is written (before the WriteStartElement call) - // the conformanceLevel specifies the current conformance level the writer is operating with. - internal virtual void OnRootElement(ConformanceLevel conformanceLevel) { } - - // WriteEndElement() and WriteFullEndElement() overloads, in which caller gives the full name of the - // element, so that raw writers do not need to keep a stack of element names. This method should - // always be called instead of WriteEndElement() or WriteFullEndElement() without parameters. - - internal abstract void WriteEndElement(string prefix, string localName, string ns); - - internal virtual void WriteFullEndElement(string prefix, string localName, string ns) - { - WriteEndElement(prefix, localName, ns); - } - - internal virtual void WriteQualifiedName(string prefix, string localName, string ns) - { - if (prefix.Length != 0) - { - WriteString(prefix); - WriteString(":"); - } - WriteString(localName); - } - - // This method must be called instead of WriteStartAttribute() for namespaces. - - internal abstract void WriteNamespaceDeclaration(string prefix, string ns); - - // When true, the XmlWellFormedWriter will call: - // 1) WriteStartNamespaceDeclaration - // 2) any method that can be used to write out a value of an attribute: WriteString, WriteChars, WriteRaw, WriteCharEntity... - // 3) WriteEndNamespaceDeclaration - // instead of just a single WriteNamespaceDeclaration call. - // - // This feature will be supported by raw writers serializing to text that wish to preserve the attribute value escaping and entities. - internal virtual bool SupportsNamespaceDeclarationInChunks - { - get - { - return false; - } - } - - internal virtual void WriteStartNamespaceDeclaration(string prefix) - { - throw new NotSupportedException(); - } - - internal virtual void WriteEndNamespaceDeclaration() - { - throw new NotSupportedException(); - } - - // This is called when the remainder of a base64 value should be output. - internal virtual void WriteEndBase64() - { - // The Flush will call WriteRaw to write out the rest of the encoded characters - base64Encoder.Flush(); - } - - internal virtual void Close(WriteState currentState) - { - Close(); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReader.cs deleted file mode 100644 index 32335e8b25f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReader.cs +++ /dev/null @@ -1,2012 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System.IO; -using System.Text; -using System.Security; -using System.Diagnostics; -using System.Collections; -using System.Globalization; -// using System.Security.Permissions; -using Microsoft.Xml.Schema; -using System.Runtime.Versioning; - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - // Represents a reader that provides fast, non-cached forward only stream access to XML data. - [DebuggerDisplay("{debuggerDisplayProxy}")] - public abstract partial class XmlReader : IDisposable - { - static private uint s_isTextualNodeBitmap = 0x6018; // 00 0110 0000 0001 1000 - // 0 None, - // 0 Element, - // 0 Attribute, - // 1 Text, - // 1 CDATA, - // 0 EntityReference, - // 0 Entity, - // 0 ProcessingInstruction, - // 0 Comment, - // 0 Document, - // 0 DocumentType, - // 0 DocumentFragment, - // 0 Notation, - // 1 Whitespace, - // 1 SignificantWhitespace, - // 0 EndElement, - // 0 EndEntity, - // 0 XmlDeclaration - - static private uint s_canReadContentAsBitmap = 0x1E1BC; // 01 1110 0001 1011 1100 - // 0 None, - // 0 Element, - // 1 Attribute, - // 1 Text, - // 1 CDATA, - // 1 EntityReference, - // 0 Entity, - // 1 ProcessingInstruction, - // 1 Comment, - // 0 Document, - // 0 DocumentType, - // 0 DocumentFragment, - // 0 Notation, - // 1 Whitespace, - // 1 SignificantWhitespace, - // 1 EndElement, - // 1 EndEntity, - // 0 XmlDeclaration - - static private uint s_hasValueBitmap = 0x2659C; // 10 0110 0101 1001 1100 - // 0 None, - // 0 Element, - // 1 Attribute, - // 1 Text, - // 1 CDATA, - // 0 EntityReference, - // 0 Entity, - // 1 ProcessingInstruction, - // 1 Comment, - // 0 Document, - // 1 DocumentType, - // 0 DocumentFragment, - // 0 Notation, - // 1 Whitespace, - // 1 SignificantWhitespace, - // 0 EndElement, - // 0 EndEntity, - // 1 XmlDeclaration - - // - // Constants - // - internal const int DefaultBufferSize = 4096; - internal const int BiggerBufferSize = 8192; - internal const int MaxStreamLengthForDefaultBufferSize = 64 * 1024; // 64kB - - internal const int AsyncBufferSize = 64 * 1024; //64KB - - // Settings - public virtual XmlReaderSettings Settings - { - get - { - return null; - } - } - - // Node Properties - // Get the type of the current node. - public abstract XmlNodeType NodeType { get; } - - // Gets the name of the current node, including the namespace prefix. - public virtual string Name - { - get - { - if (Prefix.Length == 0) - { - return LocalName; - } - else - { - return NameTable.Add(string.Concat(Prefix, ":", LocalName)); - } - } - } - - // Gets the name of the current node without the namespace prefix. - public abstract string LocalName { get; } - - // Gets the namespace URN (as defined in the W3C Namespace Specification) of the current namespace scope. - public abstract string NamespaceURI { get; } - - // Gets the namespace prefix associated with the current node. - public abstract string Prefix { get; } - - // Gets a value indicating whether - public virtual bool HasValue - { - get - { - return HasValueInternal(this.NodeType); - } - } - - // Gets the text value of the current node. - public abstract string Value { get; } - - // Gets the depth of the current node in the XML element stack. - public abstract int Depth { get; } - - // Gets the base URI of the current node. - public abstract string BaseURI { get; } - - // Gets a value indicating whether the current node is an empty element (for example, ). - public abstract bool IsEmptyElement { get; } - - // Gets a value indicating whether the current node is an attribute that was generated from the default value defined - // in the DTD or schema. - public virtual bool IsDefault - { - get - { - return false; - } - } - - // Gets the quotation mark character used to enclose the value of an attribute node. - public virtual char QuoteChar - { - get - { - return '"'; - } - } - - // Gets the current xml:space scope. - public virtual XmlSpace XmlSpace - { - get - { - return XmlSpace.None; - } - } - - // Gets the current xml:lang scope. - public virtual string XmlLang - { - get - { - return string.Empty; - } - } - - // returns the schema info interface of the reader - public virtual IXmlSchemaInfo SchemaInfo - { - get - { - return this as IXmlSchemaInfo; - } - } - - // returns the type of the current node - public virtual System.Type ValueType - { - get - { - return typeof(string); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and returns the content as the most appropriate type (by default as string). Stops at start tags and end tags. - public virtual object ReadContentAsObject() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsObject"); - } - return InternalReadContentAsString(); - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a boolean. Stops at start tags and end tags. - public virtual bool ReadContentAsBoolean() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsBoolean"); - } - try - { - return XmlConvert.ToBoolean(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a DateTime. Stops at start tags and end tags. - public virtual DateTime ReadContentAsDateTime() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsDateTime"); - } - try - { - return XmlConvert.ToDateTime(InternalReadContentAsString(), XmlDateTimeSerializationMode.RoundtripKind); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a DateTimeOffset. Stops at start tags and end tags. - public virtual DateTimeOffset ReadContentAsDateTimeOffset() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsDateTimeOffset"); - } - try - { - return XmlConvert.ToDateTimeOffset(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTimeOffset", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a double. Stops at start tags and end tags. - public virtual double ReadContentAsDouble() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsDouble"); - } - try - { - return XmlConvert.ToDouble(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a float. Stops at start tags and end tags. - public virtual float ReadContentAsFloat() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsFloat"); - } - try - { - return XmlConvert.ToSingle(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a decimal. Stops at start tags and end tags. - public virtual decimal ReadContentAsDecimal() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsDecimal"); - } - try - { - return XmlConvert.ToDecimal(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to an int. Stops at start tags and end tags. - public virtual int ReadContentAsInt() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsInt"); - } - try - { - return XmlConvert.ToInt32(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to a long. Stops at start tags and end tags. - public virtual long ReadContentAsLong() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsLong"); - } - try - { - return XmlConvert.ToInt64(InternalReadContentAsString()); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and returns the content as a string. Stops at start tags and end tags. - public virtual string ReadContentAsString() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsString"); - } - return InternalReadContentAsString(); - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to the requested type. Stops at start tags and end tags. - public virtual object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAs"); - } - - string strContentValue = InternalReadContentAsString(); - if (returnType == typeof(string)) - { - return strContentValue; - } - else - { - try - { - return XmlUntypedConverter.Untyped.ChangeType(strContentValue, returnType, (namespaceResolver == null ? this as IXmlNamespaceResolver : namespaceResolver)); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - } - - // Returns the content of the current element as the most appropriate type. Moves to the node following the element's end tag. - public virtual object ReadElementContentAsObject() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsObject")) - { - object value = ReadContentAsObject(); - FinishReadElementContentAsXxx(); - return value; - } - return string.Empty; - } - - // Checks local name and namespace of the current element and returns its content as the most appropriate type. Moves to the node following the element's end tag. - public virtual object ReadElementContentAsObject(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsObject(); - } - - // Returns the content of the current element as a boolean. Moves to the node following the element's end tag. - public virtual bool ReadElementContentAsBoolean() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsBoolean")) - { - bool value = ReadContentAsBoolean(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToBoolean(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as a boolean. Moves to the node following the element's end tag. - public virtual bool ReadElementContentAsBoolean(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsBoolean(); - } - - // Returns the content of the current element as a DateTime. Moves to the node following the element's end tag. - public virtual DateTime ReadElementContentAsDateTime() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsDateTime")) - { - DateTime value = ReadContentAsDateTime(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToDateTime(string.Empty, XmlDateTimeSerializationMode.RoundtripKind); - } - - // Checks local name and namespace of the current element and returns its content as a DateTime. - // Moves to the node following the element's end tag. - public virtual DateTime ReadElementContentAsDateTime(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsDateTime(); - } - - // Returns the content of the current element as a double. Moves to the node following the element's end tag. - public virtual double ReadElementContentAsDouble() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsDouble")) - { - double value = ReadContentAsDouble(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToDouble(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as a double. - // Moves to the node following the element's end tag. - public virtual double ReadElementContentAsDouble(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsDouble(); - } - - // Returns the content of the current element as a float. Moves to the node following the element's end tag. - public virtual float ReadElementContentAsFloat() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsFloat")) - { - float value = ReadContentAsFloat(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToSingle(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as a float. - // Moves to the node following the element's end tag. - public virtual float ReadElementContentAsFloat(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsFloat(); - } - - // Returns the content of the current element as a decimal. Moves to the node following the element's end tag. - public virtual decimal ReadElementContentAsDecimal() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsDecimal")) - { - decimal value = ReadContentAsDecimal(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToDecimal(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as a decimal. - // Moves to the node following the element's end tag. - public virtual decimal ReadElementContentAsDecimal(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsDecimal(); - } - - // Returns the content of the current element as an int. Moves to the node following the element's end tag. - public virtual int ReadElementContentAsInt() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsInt")) - { - int value = ReadContentAsInt(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToInt32(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as an int. - // Moves to the node following the element's end tag. - public virtual int ReadElementContentAsInt(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsInt(); - } - - // Returns the content of the current element as a long. Moves to the node following the element's end tag. - public virtual long ReadElementContentAsLong() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsLong")) - { - long value = ReadContentAsLong(); - FinishReadElementContentAsXxx(); - return value; - } - return XmlConvert.ToInt64(string.Empty); - } - - // Checks local name and namespace of the current element and returns its content as a long. - // Moves to the node following the element's end tag. - public virtual long ReadElementContentAsLong(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsLong(); - } - - // Returns the content of the current element as a string. Moves to the node following the element's end tag. - public virtual string ReadElementContentAsString() - { - if (SetupReadElementContentAsXxx("ReadElementContentAsString")) - { - string value = ReadContentAsString(); - FinishReadElementContentAsXxx(); - return value; - } - return string.Empty; - } - - // Checks local name and namespace of the current element and returns its content as a string. - // Moves to the node following the element's end tag. - public virtual string ReadElementContentAsString(string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAsString(); - } - - // Returns the content of the current element as the requested type. Moves to the node following the element's end tag. - public virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (SetupReadElementContentAsXxx("ReadElementContentAs")) - { - object value = ReadContentAs(returnType, namespaceResolver); - FinishReadElementContentAsXxx(); - return value; - } - return (returnType == typeof(string)) ? string.Empty : XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver); - } - - // Checks local name and namespace of the current element and returns its content as the requested type. - // Moves to the node following the element's end tag. - public virtual object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI) - { - CheckElement(localName, namespaceURI); - return ReadElementContentAs(returnType, namespaceResolver); - } - - // Attribute Accessors - // The number of attributes on the current node. - public abstract int AttributeCount { get; } - - // Gets the value of the attribute with the specified Name - public abstract string GetAttribute(string name); - - // Gets the value of the attribute with the LocalName and NamespaceURI - public abstract string GetAttribute(string name, string namespaceURI); - - // Gets the value of the attribute with the specified index. - public abstract string GetAttribute(int i); - - // Gets the value of the attribute with the specified index. - public virtual string this[int i] - { - get - { - return GetAttribute(i); - } - } - - // Gets the value of the attribute with the specified Name. - public virtual string this[string name] - { - get - { - return GetAttribute(name); - } - } - - // Gets the value of the attribute with the LocalName and NamespaceURI - public virtual string this[string name, string namespaceURI] - { - get - { - return GetAttribute(name, namespaceURI); - } - } - - // Moves to the attribute with the specified Name. - public abstract bool MoveToAttribute(string name); - - // Moves to the attribute with the specified LocalName and NamespaceURI. - public abstract bool MoveToAttribute(string name, string ns); - - // Moves to the attribute with the specified index. - public virtual void MoveToAttribute(int i) - { - if (i < 0 || i >= AttributeCount) - { - throw new ArgumentOutOfRangeException("i"); - } - MoveToElement(); - MoveToFirstAttribute(); - int j = 0; - while (j < i) - { - MoveToNextAttribute(); - j++; - } - } - - // Moves to the first attribute of the current node. - public abstract bool MoveToFirstAttribute(); - - // Moves to the next attribute. - public abstract bool MoveToNextAttribute(); - - // Moves to the element that contains the current attribute node. - public abstract bool MoveToElement(); - - // Parses the attribute value into one or more Text and/or EntityReference node types. - - public abstract bool ReadAttributeValue(); - - // Moving through the Stream - // Reads the next node from the stream. - - public abstract bool Read(); - - // Returns true when the XmlReader is positioned at the end of the stream. - public abstract bool EOF { get; } - - // Closes the stream/TextReader (if CloseInput==true), changes the ReadState to Closed, and sets all the properties back to zero/empty string. - public virtual void Close() { } - - // Returns the read state of the XmlReader. - public abstract ReadState ReadState { get; } - - // Skips to the end tag of the current element. - public virtual void Skip() - { - if (ReadState != ReadState.Interactive) - { - return; - } - SkipSubtree(); - } - - // Gets the XmlNameTable associated with the XmlReader. - public abstract XmlNameTable NameTable { get; } - - // Resolves a namespace prefix in the current element's scope. - public abstract string LookupNamespace(string prefix); - - // Returns true if the XmlReader can expand general entities. - public virtual bool CanResolveEntity - { - get - { - return false; - } - } - - // Resolves the entity reference for nodes of NodeType EntityReference. - public abstract void ResolveEntity(); - - // Binary content access methods - // Returns true if the reader supports call to ReadContentAsBase64, ReadElementContentAsBase64, ReadContentAsBinHex and ReadElementContentAsBinHex. - public virtual bool CanReadBinaryContent - { - get - { - return false; - } - } - - // Returns decoded bytes of the current base64 text content. Call this methods until it returns 0 to get all the data. - public virtual int ReadContentAsBase64(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadContentAsBase64")); - } - - // Returns decoded bytes of the current base64 element content. Call this methods until it returns 0 to get all the data. - public virtual int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadElementContentAsBase64")); - } - - // Returns decoded bytes of the current binhex text content. Call this methods until it returns 0 to get all the data. - public virtual int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadContentAsBinHex")); - } - - // Returns decoded bytes of the current binhex element content. Call this methods until it returns 0 to get all the data. - public virtual int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadElementContentAsBinHex")); - } - - // Text streaming methods - - // Returns true if the XmlReader supports calls to ReadValueChunk. - public virtual bool CanReadValueChunk - { - get - { - return false; - } - } - - // Returns a chunk of the value of the current node. Call this method in a loop to get all the data. - // Use this method to get a streaming access to the value of the current node. - public virtual int ReadValueChunk(char[] buffer, int index, int count) - { - throw new NotSupportedException(ResXml.Xml_ReadValueChunkNotSupported); - } - - // Virtual helper methods - // Reads the contents of an element as a string. Stops of comments, PIs or entity references. - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public virtual string ReadString() - { - if (this.ReadState != ReadState.Interactive) - { - return string.Empty; - } - this.MoveToElement(); - if (this.NodeType == XmlNodeType.Element) - { - if (this.IsEmptyElement) - { - return string.Empty; - } - else if (!this.Read()) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - if (this.NodeType == XmlNodeType.EndElement) - { - return string.Empty; - } - } - string result = string.Empty; - while (IsTextualNode(this.NodeType)) - { - result += this.Value; - if (!this.Read()) - { - break; - } - } - return result; - } - - // Checks whether the current node is a content (non-whitespace text, CDATA, Element, EndElement, EntityReference - // or EndEntity) node. If the node is not a content node, then the method skips ahead to the next content node or - // end of file. Skips over nodes of type ProcessingInstruction, DocumentType, Comment, Whitespace and SignificantWhitespace. - public virtual XmlNodeType MoveToContent() - { - do - { - switch (this.NodeType) - { - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - case XmlNodeType.Element: - case XmlNodeType.EndElement: - case XmlNodeType.CDATA: - case XmlNodeType.Text: - case XmlNodeType.EntityReference: - case XmlNodeType.EndEntity: - return this.NodeType; - } - } while (Read()); - return this.NodeType; - } - - // Checks that the current node is an element and advances the reader to the next node. - public virtual void ReadStartElement() - { - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - Read(); - } - - // Checks that the current content node is an element with the given Name and advances the reader to the next node. - public virtual void ReadStartElement(string name) - { - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (this.Name == name) - { - Read(); - } - else - { - throw new XmlException(ResXml.Xml_ElementNotFound, name, this as IXmlLineInfo); - } - } - - // Checks that the current content node is an element with the given LocalName and NamespaceURI - // and advances the reader to the next node. - public virtual void ReadStartElement(string localname, string ns) - { - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (this.LocalName == localname && this.NamespaceURI == ns) - { - Read(); - } - else - { - throw new XmlException(ResXml.Xml_ElementNotFoundNs, new string[2] { localname, ns }, this as IXmlLineInfo); - } - } - - // Reads a text-only element. - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public virtual string ReadElementString() - { - string result = string.Empty; - - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (!this.IsEmptyElement) - { - Read(); - result = ReadString(); - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_UnexpectedNodeInSimpleContent, new string[] { this.NodeType.ToString(), "ReadElementString" }, this as IXmlLineInfo); - } - Read(); - } - else - { - Read(); - } - return result; - } - - // Checks that the Name property of the element found matches the given string before reading a text-only element. - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public virtual string ReadElementString(string name) - { - string result = string.Empty; - - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (this.Name != name) - { - throw new XmlException(ResXml.Xml_ElementNotFound, name, this as IXmlLineInfo); - } - - if (!this.IsEmptyElement) - { - //Read(); - result = ReadString(); - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - Read(); - } - else - { - Read(); - } - return result; - } - - // Checks that the LocalName and NamespaceURI properties of the element found matches the given strings - // before reading a text-only element. - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public virtual string ReadElementString(string localname, string ns) - { - string result = string.Empty; - if (MoveToContent() != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (this.LocalName != localname || this.NamespaceURI != ns) - { - throw new XmlException(ResXml.Xml_ElementNotFoundNs, new string[2] { localname, ns }, this as IXmlLineInfo); - } - - if (!this.IsEmptyElement) - { - //Read(); - result = ReadString(); - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - Read(); - } - else - { - Read(); - } - - return result; - } - // Checks that the current content node is an end tag and advances the reader to the next node. - public virtual void ReadEndElement() - { - if (MoveToContent() != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - Read(); - } - - // Calls MoveToContent and tests if the current content node is a start tag or empty element tag (XmlNodeType.Element). - public virtual bool IsStartElement() - { - return MoveToContent() == XmlNodeType.Element; - } - - // Calls MoveToContentand tests if the current content node is a start tag or empty element tag (XmlNodeType.Element) and if the - // Name property of the element found matches the given argument. - public virtual bool IsStartElement(string name) - { - return (MoveToContent() == XmlNodeType.Element) && - (this.Name == name); - } - - // Calls MoveToContent and tests if the current content node is a start tag or empty element tag (XmlNodeType.Element) and if - // the LocalName and NamespaceURI properties of the element found match the given strings. - public virtual bool IsStartElement(string localname, string ns) - { - return (MoveToContent() == XmlNodeType.Element) && - (this.LocalName == localname && this.NamespaceURI == ns); - } - - // Reads to the following element with the given Name. - public virtual bool ReadToFollowing(string name) - { - if (name == null || name.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(name, "name"); - } - // atomize name - name = NameTable.Add(name); - - // find following element with that name - while (Read()) - { - if (NodeType == XmlNodeType.Element && Ref.Equal(name, Name)) - { - return true; - } - } - return false; - } - - // Reads to the following element with the given LocalName and NamespaceURI. - public virtual bool ReadToFollowing(string localName, string namespaceURI) - { - if (localName == null || localName.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName"); - } - if (namespaceURI == null) - { - throw new ArgumentNullException("namespaceURI"); - } - - // atomize local name and namespace - localName = NameTable.Add(localName); - namespaceURI = NameTable.Add(namespaceURI); - - // find following element with that name - while (Read()) - { - if (NodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI)) - { - return true; - } - } - return false; - } - - // Reads to the first descendant of the current element with the given Name. - public virtual bool ReadToDescendant(string name) - { - if (name == null || name.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(name, "name"); - } - // save the element or root depth - int parentDepth = Depth; - if (NodeType != XmlNodeType.Element) - { - // adjust the depth if we are on root node - if (ReadState == ReadState.Initial) - { - Debug.Assert(parentDepth == 0); - parentDepth--; - } - else - { - return false; - } - } - else if (IsEmptyElement) - { - return false; - } - - // atomize name - name = NameTable.Add(name); - - // find the descendant - while (Read() && Depth > parentDepth) - { - if (NodeType == XmlNodeType.Element && Ref.Equal(name, Name)) - { - return true; - } - } - Debug.Assert(NodeType == XmlNodeType.EndElement || NodeType == XmlNodeType.None || ReadState == ReadState.Error); - return false; - } - - // Reads to the first descendant of the current element with the given LocalName and NamespaceURI. - public virtual bool ReadToDescendant(string localName, string namespaceURI) - { - if (localName == null || localName.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName"); - } - if (namespaceURI == null) - { - throw new ArgumentNullException("namespaceURI"); - } - // save the element or root depth - int parentDepth = Depth; - if (NodeType != XmlNodeType.Element) - { - // adjust the depth if we are on root node - if (ReadState == ReadState.Initial) - { - Debug.Assert(parentDepth == 0); - parentDepth--; - } - else - { - return false; - } - } - else if (IsEmptyElement) - { - return false; - } - - // atomize local name and namespace - localName = NameTable.Add(localName); - namespaceURI = NameTable.Add(namespaceURI); - - // find the descendant - while (Read() && Depth > parentDepth) - { - if (NodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI)) - { - return true; - } - } - Debug.Assert(NodeType == XmlNodeType.EndElement); - return false; - } - - // Reads to the next sibling of the current element with the given Name. - public virtual bool ReadToNextSibling(string name) - { - if (name == null || name.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(name, "name"); - } - - // atomize name - name = NameTable.Add(name); - - // find the next sibling - XmlNodeType nt; - do - { - if (!SkipSubtree()) - { - break; - } - nt = NodeType; - if (nt == XmlNodeType.Element && Ref.Equal(name, Name)) - { - return true; - } - } while (nt != XmlNodeType.EndElement && !EOF); - return false; - } - - // Reads to the next sibling of the current element with the given LocalName and NamespaceURI. - public virtual bool ReadToNextSibling(string localName, string namespaceURI) - { - if (localName == null || localName.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName"); - } - if (namespaceURI == null) - { - throw new ArgumentNullException("namespaceURI"); - } - - // atomize local name and namespace - localName = NameTable.Add(localName); - namespaceURI = NameTable.Add(namespaceURI); - - // find the next sibling - XmlNodeType nt; - do - { - if (!SkipSubtree()) - { - break; - } - nt = NodeType; - if (nt == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI)) - { - return true; - } - } while (nt != XmlNodeType.EndElement && !EOF); - return false; - } - - // Returns true if the given argument is a valid Name. - public static bool IsName(string str) - { - if (str == null) - { - throw new NullReferenceException(); - } - return ValidateNames.IsNameNoNamespaces(str); - } - - // Returns true if the given argument is a valid NmToken. - public static bool IsNameToken(string str) - { - if (str == null) - { - throw new NullReferenceException(); - } - return ValidateNames.IsNmtokenNoNamespaces(str); - } - - // Returns the inner content (including markup) of an element or attribute as a string. - public virtual string ReadInnerXml() - { - if (ReadState != ReadState.Interactive) - { - return string.Empty; - } - if ((this.NodeType != XmlNodeType.Attribute) && (this.NodeType != XmlNodeType.Element)) - { - Read(); - return string.Empty; - } - - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlWriter xtw = CreateWriterForInnerOuterXml(sw); - - try - { - if (this.NodeType == XmlNodeType.Attribute) - { - ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar; - WriteAttributeValue(xtw); - } - if (this.NodeType == XmlNodeType.Element) - { - this.WriteNode(xtw, false); - } - } - finally - { - xtw.Close(); - } - return sw.ToString(); - } - - // Writes the content (inner XML) of the current node into the provided XmlWriter. - private void WriteNode(XmlWriter xtw, bool defattr) - { - Debug.Assert(xtw is XmlTextWriter); - int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth; - while (this.Read() && (d < this.Depth)) - { - switch (this.NodeType) - { - case XmlNodeType.Element: - xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI); - ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar; - xtw.WriteAttributes(this, defattr); - if (this.IsEmptyElement) - { - xtw.WriteEndElement(); - } - break; - case XmlNodeType.Text: - xtw.WriteString(this.Value); - break; - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - xtw.WriteWhitespace(this.Value); - break; - case XmlNodeType.CDATA: - xtw.WriteCData(this.Value); - break; - case XmlNodeType.EntityReference: - xtw.WriteEntityRef(this.Name); - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.ProcessingInstruction: - xtw.WriteProcessingInstruction(this.Name, this.Value); - break; - case XmlNodeType.DocumentType: - xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value); - break; - case XmlNodeType.Comment: - xtw.WriteComment(this.Value); - break; - case XmlNodeType.EndElement: - xtw.WriteFullEndElement(); - break; - } - } - if (d == this.Depth && this.NodeType == XmlNodeType.EndElement) - { - Read(); - } - } - - // Writes the attribute into the provided XmlWriter. - private void WriteAttributeValue(XmlWriter xtw) - { - string attrName = this.Name; - while (ReadAttributeValue()) - { - if (this.NodeType == XmlNodeType.EntityReference) - { - xtw.WriteEntityRef(this.Name); - } - else - { - xtw.WriteString(this.Value); - } - } - this.MoveToAttribute(attrName); - } - - // Returns the current element and its descendants or an attribute as a string. - public virtual string ReadOuterXml() - { - if (ReadState != ReadState.Interactive) - { - return string.Empty; - } - if ((this.NodeType != XmlNodeType.Attribute) && (this.NodeType != XmlNodeType.Element)) - { - Read(); - return string.Empty; - } - - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlWriter xtw = CreateWriterForInnerOuterXml(sw); - - try - { - if (this.NodeType == XmlNodeType.Attribute) - { - xtw.WriteStartAttribute(this.Prefix, this.LocalName, this.NamespaceURI); - WriteAttributeValue(xtw); - xtw.WriteEndAttribute(); - } - else - { - xtw.WriteNode(this, false); - } - } - finally - { - xtw.Close(); - } - return sw.ToString(); - } - - private XmlWriter CreateWriterForInnerOuterXml(StringWriter sw) - { - XmlTextWriter w = new XmlTextWriter(sw); - // This is a V1 hack; we can put a custom implementation of ReadOuterXml on XmlTextReader/XmlValidatingReader - SetNamespacesFlag(w); - return w; - } - - private void SetNamespacesFlag(XmlTextWriter xtw) - { - XmlTextReader tr = this as XmlTextReader; - if (tr != null) - { - xtw.Namespaces = tr.Namespaces; - } - else - { -#pragma warning disable 618 - XmlValidatingReader vr = this as XmlValidatingReader; - if (vr != null) - { - xtw.Namespaces = vr.Namespaces; - } - } -#pragma warning restore 618 - } - - // Returns an XmlReader that will read only the current element and its descendants and then go to EOF state. - public virtual XmlReader ReadSubtree() - { - if (NodeType != XmlNodeType.Element) - { - throw new InvalidOperationException(ResXml.Xml_ReadSubtreeNotOnElement); - } - return new XmlSubtreeReader(this); - } - - // Returns true when the current node has any attributes. - public virtual bool HasAttributes - { - get - { - return AttributeCount > 0; - } - } - - // - // IDisposable interface - // - public void Dispose() - { - Dispose(true); - } - - protected virtual void Dispose(bool disposing) - { //the boolean flag may be used by subclasses to differentiate between disposing and finalizing - if (disposing && ReadState != ReadState.Closed) - { - Close(); - } - } - - // - // Internal methods - // - // Validation support - internal virtual XmlNamespaceManager NamespaceManager - { - get - { - return null; - } - } - - static internal bool IsTextualNode(XmlNodeType nodeType) - { -#if DEBUG - // This code verifies IsTextualNodeBitmap mapping of XmlNodeType to a bool specifying - // whether the node is 'textual' = Text, CDATA, Whitespace or SignificantWhitespace. - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.None))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Element))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Attribute))); - Debug.Assert(0 != (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Text))); - Debug.Assert(0 != (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.CDATA))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.EntityReference))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Entity))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.ProcessingInstruction))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Comment))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Document))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.DocumentType))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.DocumentFragment))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Notation))); - Debug.Assert(0 != (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.Whitespace))); - Debug.Assert(0 != (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.SignificantWhitespace))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.EndElement))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.EndEntity))); - Debug.Assert(0 == (s_isTextualNodeBitmap & (1 << (int)XmlNodeType.XmlDeclaration))); -#endif - return 0 != (s_isTextualNodeBitmap & (1 << (int)nodeType)); - } - - static internal bool CanReadContentAs(XmlNodeType nodeType) - { -#if DEBUG - // This code verifies IsTextualNodeBitmap mapping of XmlNodeType to a bool specifying - // whether ReadContentAsXxx calls are allowed on his node type - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.None))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Element))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Attribute))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Text))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.CDATA))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.EntityReference))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Entity))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.ProcessingInstruction))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Comment))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Document))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.DocumentType))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.DocumentFragment))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Notation))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.Whitespace))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.SignificantWhitespace))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.EndElement))); - Debug.Assert(0 != (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.EndEntity))); - Debug.Assert(0 == (s_canReadContentAsBitmap & (1 << (int)XmlNodeType.XmlDeclaration))); -#endif - return 0 != (s_canReadContentAsBitmap & (1 << (int)nodeType)); - } - - static internal bool HasValueInternal(XmlNodeType nodeType) - { -#if DEBUG - // This code verifies HasValueBitmap mapping of XmlNodeType to a bool specifying - // whether the node can have a non-empty Value - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.None))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.Element))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.Attribute))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.Text))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.CDATA))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.EntityReference))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.Entity))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.ProcessingInstruction))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.Comment))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.Document))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.DocumentType))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.DocumentFragment))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.Notation))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.Whitespace))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.SignificantWhitespace))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.EndElement))); - Debug.Assert(0 == (s_hasValueBitmap & (1 << (int)XmlNodeType.EndEntity))); - Debug.Assert(0 != (s_hasValueBitmap & (1 << (int)XmlNodeType.XmlDeclaration))); -#endif - return 0 != (s_hasValueBitmap & (1 << (int)nodeType)); - } - - // - // Private methods - // - //SkipSubTree is called whenever validation of the skipped subtree is required on a reader with XsdValidation - private bool SkipSubtree() - { - MoveToElement(); - if (NodeType == XmlNodeType.Element && !IsEmptyElement) - { - int depth = Depth; - - while (Read() && depth < Depth) - { - // Nothing, just read on - } - - // consume end tag - if (NodeType == XmlNodeType.EndElement) - return Read(); - } - else - { - return Read(); - } - - return false; - } - - internal void CheckElement(string localName, string namespaceURI) - { - if (localName == null || localName.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(localName, "localName"); - } - if (namespaceURI == null) - { - throw new ArgumentNullException("namespaceURI"); - } - if (NodeType != XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo); - } - if (LocalName != localName || NamespaceURI != namespaceURI) - { - throw new XmlException(ResXml.Xml_ElementNotFoundNs, new string[2] { localName, namespaceURI }, this as IXmlLineInfo); - } - } - - internal Exception CreateReadContentAsException(string methodName) - { - return CreateReadContentAsException(methodName, NodeType, this as IXmlLineInfo); - } - - internal Exception CreateReadElementContentAsException(string methodName) - { - return CreateReadElementContentAsException(methodName, NodeType, this as IXmlLineInfo); - } - - internal bool CanReadContentAs() - { - return CanReadContentAs(this.NodeType); - } - - static internal Exception CreateReadContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo) - { - return new InvalidOperationException(AddLineInfo(string.Format(ResXml.Xml_InvalidReadContentAs, new string[] { methodName, nodeType.ToString() }), lineInfo)); - } - - static internal Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo) - { - return new InvalidOperationException(AddLineInfo(string.Format(ResXml.Xml_InvalidReadElementContentAs, new string[] { methodName, nodeType.ToString() }), lineInfo)); - } - - private static string AddLineInfo(string message, IXmlLineInfo lineInfo) - { - if (lineInfo != null) - { - string[] lineArgs = new string[2]; - lineArgs[0] = lineInfo.LineNumber.ToString(); - lineArgs[1] = lineInfo.LinePosition.ToString(); - message += " " + string.Format(ResXml.Xml_ErrorPosition, lineArgs); - } - return message; - } - - internal string InternalReadContentAsString() - { - string value = string.Empty; - BufferBuilder sb = null; - do - { - switch (this.NodeType) - { - case XmlNodeType.Attribute: - return this.Value; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.CDATA: - // merge text content - if (value.Length == 0) - { - value = this.Value; - } - else - { - if (sb == null) - { - sb = new BufferBuilder(); - sb.Append(value); - } - sb.Append(this.Value); - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.EndEntity: - // skip comments, pis and end entity nodes - break; - case XmlNodeType.EntityReference: - if (this.CanResolveEntity) - { - this.ResolveEntity(); - break; - } - goto default; - case XmlNodeType.EndElement: - default: - goto ReturnContent; - } - } while ((this.AttributeCount != 0) ? this.ReadAttributeValue() : this.Read()); - - ReturnContent: - return (sb == null) ? value : sb.ToString(); - } - - private bool SetupReadElementContentAsXxx(string methodName) - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException(methodName); - } - - bool isEmptyElement = this.IsEmptyElement; - - // move to content or beyond the empty element - this.Read(); - - if (isEmptyElement) - { - return false; - } - - XmlNodeType nodeType = this.NodeType; - if (nodeType == XmlNodeType.EndElement) - { - this.Read(); - return false; - } - else if (nodeType == XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - return true; - } - - private void FinishReadElementContentAsXxx() - { - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString()); - } - this.Read(); - } - - internal bool IsDefaultInternal - { - get - { - if (this.IsDefault) - { - return true; - } - IXmlSchemaInfo schemaInfo = this.SchemaInfo; - if (schemaInfo != null && schemaInfo.IsDefault) - { - return true; - } - return false; - } - } - - internal virtual IDtdInfo DtdInfo - { - get - { - return null; - } - } - - internal static Encoding GetEncoding(XmlReader reader) - { - XmlTextReaderImpl tri = GetXmlTextReaderImpl(reader); - return tri != null ? tri.Encoding : null; - } - - internal static ConformanceLevel GetV1ConformanceLevel(XmlReader reader) - { - XmlTextReaderImpl tri = GetXmlTextReaderImpl(reader); - return tri != null ? tri.V1ComformanceLevel : ConformanceLevel.Document; - } - - private static XmlTextReaderImpl GetXmlTextReaderImpl(XmlReader reader) - { - XmlTextReaderImpl tri = reader as XmlTextReaderImpl; - if (tri != null) - { - return tri; - } - - XmlTextReader tr = reader as XmlTextReader; - if (tr != null) - { - return tr.Impl; - } - - XmlValidatingReaderImpl vri = reader as XmlValidatingReaderImpl; - if (vri != null) - { - return vri.ReaderImpl; - } -#pragma warning disable 618 - XmlValidatingReader vr = reader as XmlValidatingReader; -#pragma warning restore 618 - if (vr != null) - { - return vr.Impl.ReaderImpl; - } - return null; - } - - // - // Static methods for creating readers - // - - // Creates an XmlReader for parsing XML from the given Uri. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public static XmlReader Create(string inputUri) - { - return XmlReader.Create(inputUri, (XmlReaderSettings)null, (XmlParserContext)null); - } - - // Creates an XmlReader according to the settings for parsing XML from the given Uri. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public static XmlReader Create(string inputUri, XmlReaderSettings settings) - { - return XmlReader.Create(inputUri, settings, (XmlParserContext)null); - } - - // Creates an XmlReader according to the settings and parser context for parsing XML from the given Uri. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public static XmlReader Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(inputUri, inputContext); - } - - // Creates an XmlReader according for parsing XML from the given stream. - public static XmlReader Create(Stream input) - { - return Create(input, (XmlReaderSettings)null, (string)string.Empty); - } - - // Creates an XmlReader according to the settings for parsing XML from the given stream. - public static XmlReader Create(Stream input, XmlReaderSettings settings) - { - return Create(input, settings, string.Empty); - } - - // Creates an XmlReader according to the settings and base Uri for parsing XML from the given stream. - public static XmlReader Create(Stream input, XmlReaderSettings settings, String baseUri) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(input, null, (string)baseUri, null); - } - - // Creates an XmlReader according to the settings and parser context for parsing XML from the given stream. - public static XmlReader Create(Stream input, XmlReaderSettings settings, XmlParserContext inputContext) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(input, null, (string)string.Empty, inputContext); - } - - // Creates an XmlReader according for parsing XML from the given TextReader. - public static XmlReader Create(TextReader input) - { - return Create(input, (XmlReaderSettings)null, (string)string.Empty); - } - - // Creates an XmlReader according to the settings for parsing XML from the given TextReader. - public static XmlReader Create(TextReader input, XmlReaderSettings settings) - { - return Create(input, settings, string.Empty); - } - - // Creates an XmlReader according to the settings and baseUri for parsing XML from the given TextReader. - public static XmlReader Create(TextReader input, XmlReaderSettings settings, String baseUri) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(input, baseUri, null); - } - - // Creates an XmlReader according to the settings and parser context for parsing XML from the given TextReader. - public static XmlReader Create(TextReader input, XmlReaderSettings settings, XmlParserContext inputContext) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(input, string.Empty, inputContext); - } - - // Creates an XmlReader according to the settings wrapped over the given reader. - public static XmlReader Create(XmlReader reader, XmlReaderSettings settings) - { - if (settings == null) - { - settings = new XmlReaderSettings(); - } - return settings.CreateReader(reader); - } - - // !!!!!! - // NOTE: This method is called via reflection from System.Data.dll and from Analysis Services in Yukon. - // Do not change its signature without notifying the appropriate teams! - // !!!!!! - internal static XmlReader CreateSqlReader(Stream input, XmlReaderSettings settings, XmlParserContext inputContext) - { - if (input == null) - { - throw new ArgumentNullException("input"); - } - if (settings == null) - { - settings = new XmlReaderSettings(); - } - - XmlReader reader; - - // allocate byte buffer - byte[] bytes = new byte[CalcBufferSize(input)]; - - { - // catch the binary XML input and dump it into a local file (for debugging and testing purposes) - - // create dump file name - string dumpFileNameBase = "~CreateSqlReaderInputDump"; - string dumpFileName; - int i = 0; - do { - i++; - dumpFileName = Path.GetFullPath(string.Concat(dumpFileNameBase, i.ToString(), ".bmx")); - } while (File.Exists(dumpFileName)); - - // dump the input into the file - FileStream fs = new FileStream(dumpFileName, FileMode.Create, FileAccess.ReadWrite); - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) { - fs.Write(buffer, 0, bytesRead); - } - fs.Seek(0, SeekOrigin.Begin); - - // make sure it will get closed - if (settings.CloseInput) { - input.Close(); - } - input = fs; - settings = settings.Clone(); - settings.CloseInput = true; - } - int byteCount = 0; - int read; - do - { - read = input.Read(bytes, byteCount, bytes.Length - byteCount); - byteCount += read; - } while (read > 0 && byteCount < 2); - - // create text or binary XML reader depenting on the stream first 2 bytes - if (byteCount >= 2 && (bytes[0] == 0xdf && bytes[1] == 0xff)) - { - if (inputContext != null) - throw new ArgumentException(ResXml.XmlBinary_NoParserContext, "inputContext"); - reader = new XmlSqlBinaryReader(input, bytes, byteCount, string.Empty, settings.CloseInput, settings); - } - else - { - reader = new XmlTextReaderImpl(input, bytes, byteCount, settings, null, string.Empty, inputContext, settings.CloseInput); - } - - // wrap with validating reader - if (settings.ValidationType != ValidationType.None) - { - reader = settings.AddValidation(reader); - } - - return reader; - } - - internal static int CalcBufferSize(Stream input) - { - // determine the size of byte buffer - int bufferSize = DefaultBufferSize; - if (input.CanSeek) - { - long len = input.Length; - if (len < bufferSize) - { - bufferSize = checked((int)len); - } - else if (len > MaxStreamLengthForDefaultBufferSize) - { - bufferSize = BiggerBufferSize; - } - } - - // return the byte buffer size - return bufferSize; - } - - private object debuggerDisplayProxy { get { return new XmlReaderDebuggerDisplayProxy(this); } } - - [DebuggerDisplay("{ToString()}")] - private struct XmlReaderDebuggerDisplayProxy - { - private XmlReader _reader; - - internal XmlReaderDebuggerDisplayProxy(XmlReader reader) - { - _reader = reader; - } - - public override string ToString() - { - XmlNodeType nt = _reader.NodeType; - string result = nt.ToString(); - switch (nt) - { - case XmlNodeType.Element: - case XmlNodeType.EndElement: - case XmlNodeType.EntityReference: - case XmlNodeType.EndEntity: - result += ", Name=\"" + _reader.Name + '"'; - break; - case XmlNodeType.Attribute: - case XmlNodeType.ProcessingInstruction: - result += ", Name=\"" + _reader.Name + "\", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_reader.Value) + '"'; - break; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Comment: - case XmlNodeType.XmlDeclaration: - case XmlNodeType.CDATA: - result += ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_reader.Value) + '"'; - break; - case XmlNodeType.DocumentType: - result += ", Name=\"" + _reader.Name + "'"; - result += ", SYSTEM=\"" + _reader.GetAttribute("SYSTEM") + '"'; - result += ", PUBLIC=\"" + _reader.GetAttribute("PUBLIC") + '"'; - result += ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_reader.Value) + '"'; - break; - } - return result; - } - } - - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderAsync.cs deleted file mode 100644 index e8442cff64a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderAsync.cs +++ /dev/null @@ -1,437 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Text; -using System.Security; -using System.Diagnostics; -using System.Collections; -using System.Globalization; -// using System.Security.Permissions; -using Microsoft.Xml.Schema; -using System.Runtime.Versioning; - -using System.Threading.Tasks; - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - // Represents a reader that provides fast, non-cached forward only stream access to XML data. - [DebuggerDisplay("{debuggerDisplayProxy}")] - public abstract partial class XmlReader : IDisposable - { - public virtual Task GetValueAsync() - { - throw new NotImplementedException(); - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and returns the content as the most appropriate type (by default as string). Stops at start tags and end tags. - public virtual async Task ReadContentAsObjectAsync() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsObject"); - } - return await InternalReadContentAsStringAsync().ConfigureAwait(false); - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and returns the content as a string. Stops at start tags and end tags. - public virtual Task ReadContentAsStringAsync() - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAsString"); - } - return InternalReadContentAsStringAsync(); - } - - // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, - // and converts the content to the requested type. Stops at start tags and end tags. - public virtual async Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (!CanReadContentAs()) - { - throw CreateReadContentAsException("ReadContentAs"); - } - - string strContentValue = await InternalReadContentAsStringAsync().ConfigureAwait(false); - if (returnType == typeof(string)) - { - return strContentValue; - } - else - { - try - { - return XmlUntypedConverter.Untyped.ChangeType(strContentValue, returnType, (namespaceResolver == null ? this as IXmlNamespaceResolver : namespaceResolver)); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - } - - // Returns the content of the current element as the most appropriate type. Moves to the node following the element's end tag. - public virtual async Task ReadElementContentAsObjectAsync() - { - if (await SetupReadElementContentAsXxxAsync("ReadElementContentAsObject").ConfigureAwait(false)) - { - object value = await ReadContentAsObjectAsync().ConfigureAwait(false); - await FinishReadElementContentAsXxxAsync().ConfigureAwait(false); - return value; - } - return string.Empty; - } - - // Returns the content of the current element as a string. Moves to the node following the element's end tag. - public virtual async Task ReadElementContentAsStringAsync() - { - if (await SetupReadElementContentAsXxxAsync("ReadElementContentAsString").ConfigureAwait(false)) - { - string value = await ReadContentAsStringAsync().ConfigureAwait(false); - await FinishReadElementContentAsXxxAsync().ConfigureAwait(false); - return value; - } - return string.Empty; - } - - // Returns the content of the current element as the requested type. Moves to the node following the element's end tag. - public virtual async Task ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (await SetupReadElementContentAsXxxAsync("ReadElementContentAs").ConfigureAwait(false)) - { - object value = await ReadContentAsAsync(returnType, namespaceResolver).ConfigureAwait(false); - await FinishReadElementContentAsXxxAsync().ConfigureAwait(false); - return value; - } - return (returnType == typeof(string)) ? string.Empty : XmlUntypedConverter.Untyped.ChangeType(string.Empty, returnType, namespaceResolver); - } - - // Moving through the Stream - // Reads the next node from the stream. - - public virtual Task ReadAsync() - { - throw new NotImplementedException(); - } - - // Skips to the end tag of the current element. - public virtual Task SkipAsync() - { - if (ReadState != ReadState.Interactive) - { - return AsyncHelper.DoneTask; - } - return SkipSubtreeAsync(); - } - - // Returns decoded bytes of the current base64 text content. Call this methods until it returns 0 to get all the data. - public virtual Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadContentAsBase64")); - } - - // Returns decoded bytes of the current base64 element content. Call this methods until it returns 0 to get all the data. - public virtual Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadElementContentAsBase64")); - } - - // Returns decoded bytes of the current binhex text content. Call this methods until it returns 0 to get all the data. - public virtual Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadContentAsBinHex")); - } - - // Returns decoded bytes of the current binhex element content. Call this methods until it returns 0 to get all the data. - public virtual Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - throw new NotSupportedException(string.Format(ResXml.Xml_ReadBinaryContentNotSupported, "ReadElementContentAsBinHex")); - } - - // Returns a chunk of the value of the current node. Call this method in a loop to get all the data. - // Use this method to get a streaming access to the value of the current node. - public virtual Task ReadValueChunkAsync(char[] buffer, int index, int count) - { - throw new NotSupportedException(ResXml.Xml_ReadValueChunkNotSupported); - } - - // Checks whether the current node is a content (non-whitespace text, CDATA, Element, EndElement, EntityReference - // or EndEntity) node. If the node is not a content node, then the method skips ahead to the next content node or - // end of file. Skips over nodes of type ProcessingInstruction, DocumentType, Comment, Whitespace and SignificantWhitespace. - public virtual async Task MoveToContentAsync() - { - do - { - switch (this.NodeType) - { - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - case XmlNodeType.Element: - case XmlNodeType.EndElement: - case XmlNodeType.CDATA: - case XmlNodeType.Text: - case XmlNodeType.EntityReference: - case XmlNodeType.EndEntity: - return this.NodeType; - } - } while (await ReadAsync().ConfigureAwait(false)); - return this.NodeType; - } - - // Returns the inner content (including markup) of an element or attribute as a string. - public virtual async Task ReadInnerXmlAsync() - { - if (ReadState != ReadState.Interactive) - { - return string.Empty; - } - if ((this.NodeType != XmlNodeType.Attribute) && (this.NodeType != XmlNodeType.Element)) - { - await ReadAsync().ConfigureAwait(false); - return string.Empty; - } - - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlWriter xtw = CreateWriterForInnerOuterXml(sw); - - try - { - if (this.NodeType == XmlNodeType.Attribute) - { - ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar; - WriteAttributeValue(xtw); - } - if (this.NodeType == XmlNodeType.Element) - { - await this.WriteNodeAsync(xtw, false).ConfigureAwait(false); - } - } - finally - { - xtw.Close(); - } - return sw.ToString(); - } - - // Writes the content (inner XML) of the current node into the provided XmlWriter. - private async Task WriteNodeAsync(XmlWriter xtw, bool defattr) - { - Debug.Assert(xtw is XmlTextWriter); - int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth; - while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth)) - { - switch (this.NodeType) - { - case XmlNodeType.Element: - xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI); - ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar; - xtw.WriteAttributes(this, defattr); - if (this.IsEmptyElement) - { - xtw.WriteEndElement(); - } - break; - case XmlNodeType.Text: - xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false)); - break; - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false)); - break; - case XmlNodeType.CDATA: - xtw.WriteCData(this.Value); - break; - case XmlNodeType.EntityReference: - xtw.WriteEntityRef(this.Name); - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.ProcessingInstruction: - xtw.WriteProcessingInstruction(this.Name, this.Value); - break; - case XmlNodeType.DocumentType: - xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value); - break; - case XmlNodeType.Comment: - xtw.WriteComment(this.Value); - break; - case XmlNodeType.EndElement: - xtw.WriteFullEndElement(); - break; - } - } - if (d == this.Depth && this.NodeType == XmlNodeType.EndElement) - { - await ReadAsync().ConfigureAwait(false); - } - } - - // Returns the current element and its descendants or an attribute as a string. - public virtual async Task ReadOuterXmlAsync() - { - if (ReadState != ReadState.Interactive) - { - return string.Empty; - } - if ((this.NodeType != XmlNodeType.Attribute) && (this.NodeType != XmlNodeType.Element)) - { - await ReadAsync().ConfigureAwait(false); - return string.Empty; - } - - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlWriter xtw = CreateWriterForInnerOuterXml(sw); - - try - { - if (this.NodeType == XmlNodeType.Attribute) - { - xtw.WriteStartAttribute(this.Prefix, this.LocalName, this.NamespaceURI); - WriteAttributeValue(xtw); - xtw.WriteEndAttribute(); - } - else - { - xtw.WriteNode(this, false); - } - } - finally - { - xtw.Close(); - } - return sw.ToString(); - } - - // - // Private methods - // - //SkipSubTree is called whenever validation of the skipped subtree is required on a reader with XsdValidation - private async Task SkipSubtreeAsync() - { - MoveToElement(); - if (NodeType == XmlNodeType.Element && !IsEmptyElement) - { - int depth = Depth; - - while (await ReadAsync().ConfigureAwait(false) && depth < Depth) - { - // Nothing, just read on - } - - // consume end tag - if (NodeType == XmlNodeType.EndElement) - return await ReadAsync().ConfigureAwait(false); - } - else - { - return await ReadAsync().ConfigureAwait(false); - } - - return false; - } - - internal async Task InternalReadContentAsStringAsync() - { - string value = string.Empty; - BufferBuilder sb = null; - do - { - switch (this.NodeType) - { - case XmlNodeType.Attribute: - return this.Value; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.CDATA: - // merge text content - if (value.Length == 0) - { - value = await this.GetValueAsync().ConfigureAwait(false); - } - else - { - if (sb == null) - { - sb = new BufferBuilder(); - sb.Append(value); - } - sb.Append(await this.GetValueAsync().ConfigureAwait(false)); - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.EndEntity: - // skip comments, pis and end entity nodes - break; - case XmlNodeType.EntityReference: - if (this.CanResolveEntity) - { - this.ResolveEntity(); - break; - } - goto default; - case XmlNodeType.EndElement: - default: - goto ReturnContent; - } - } while ((this.AttributeCount != 0) ? this.ReadAttributeValue() : await this.ReadAsync().ConfigureAwait(false)); - - ReturnContent: - return (sb == null) ? value : sb.ToString(); - } - - private async Task SetupReadElementContentAsXxxAsync(string methodName) - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException(methodName); - } - - bool isEmptyElement = this.IsEmptyElement; - - // move to content or beyond the empty element - await this.ReadAsync().ConfigureAwait(false); - - if (isEmptyElement) - { - return false; - } - - XmlNodeType nodeType = this.NodeType; - if (nodeType == XmlNodeType.EndElement) - { - await this.ReadAsync().ConfigureAwait(false); - return false; - } - else if (nodeType == XmlNodeType.Element) - { - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - return true; - } - - private Task FinishReadElementContentAsXxxAsync() - { - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, this.NodeType.ToString()); - } - return this.ReadAsync(); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderSettings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderSettings.cs deleted file mode 100644 index 3f968e67bf8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlReaderSettings.cs +++ /dev/null @@ -1,784 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Diagnostics; -// using System.Security.Permissions; -using Microsoft.Win32; -using System.Globalization; -using System.Security; -using Microsoft.Xml.Schema; -// using Microsoft.Xml.XmlConfiguration; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - // XmlReaderSettings class specifies basic features of an XmlReader. - // [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")] - public sealed class XmlReaderSettings - { - // - // Fields - // - -#if ASYNC || FEATURE_NETCORE - bool useAsync; -#endif - - - // Nametable - private XmlNameTable _nameTable; - - // XmlResolver - private XmlResolver _xmlResolver; - - // Text settings - private int _lineNumberOffset; - private int _linePositionOffset; - - // Conformance settings - private ConformanceLevel _conformanceLevel; - private bool _checkCharacters; - - private long _maxCharactersInDocument; - private long _maxCharactersFromEntities; - - // Filtering settings - private bool _ignoreWhitespace; - private bool _ignorePIs; - private bool _ignoreComments; - - // security settings - private DtdProcessing _dtdProcessing; - - //Validation settings - private ValidationType _validationType; - private XmlSchemaValidationFlags _validationFlags; - private XmlSchemaSet _schemas; - private ValidationEventHandler _valEventHandler; - - // other settings - private bool _closeInput; - - // read-only flag - private bool _isReadOnly; - - // - // Constructor - // - public XmlReaderSettings() - { - Initialize(); - } - -#if !FEATURE_LEGACYNETCF - // introduced for supporting design-time loading of phone assemblies - [Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] -#endif - public XmlReaderSettings(XmlResolver resolver) - { - Initialize(resolver); - } - - // - // Properties - // - -#if ASYNC || FEATURE_NETCORE - public bool Async { - get { - return useAsync; - } - set { - CheckReadOnly("Async"); - useAsync = value; - } - } -#endif - - // Nametable - public XmlNameTable NameTable - { - get - { - return _nameTable; - } - set - { - CheckReadOnly("NameTable"); - _nameTable = value; - } - } - - // XmlResolver - internal bool IsXmlResolverSet - { - get; - set; // keep set internal as we need to call it from the schema validation code - } - - public XmlResolver XmlResolver - { - set - { - CheckReadOnly("XmlResolver"); - _xmlResolver = value; - IsXmlResolverSet = true; - } - } - - internal XmlResolver GetXmlResolver() - { - return _xmlResolver; - } - - //This is used by get XmlResolver in Xsd. - //Check if the config set to prohibit default resovler - //notice we must keep GetXmlResolver() to avoid dead lock when init System.Config.ConfigurationManager - internal XmlResolver GetXmlResolver_CheckConfig() - { - return _xmlResolver; - } - - // Text settings - public int LineNumberOffset - { - get - { - return _lineNumberOffset; - } - set - { - CheckReadOnly("LineNumberOffset"); - _lineNumberOffset = value; - } - } - - public int LinePositionOffset - { - get - { - return _linePositionOffset; - } - set - { - CheckReadOnly("LinePositionOffset"); - _linePositionOffset = value; - } - } - - // Conformance settings - public ConformanceLevel ConformanceLevel - { - get - { - return _conformanceLevel; - } - set - { - CheckReadOnly("ConformanceLevel"); - - if ((uint)value > (uint)ConformanceLevel.Document) - { - throw new ArgumentOutOfRangeException("value"); - } - _conformanceLevel = value; - } - } - - public bool CheckCharacters - { - get - { - return _checkCharacters; - } - set - { - CheckReadOnly("CheckCharacters"); - _checkCharacters = value; - } - } - - public long MaxCharactersInDocument - { - get - { - return _maxCharactersInDocument; - } - set - { - CheckReadOnly("MaxCharactersInDocument"); - if (value < 0) - { - throw new ArgumentOutOfRangeException("value"); - } - _maxCharactersInDocument = value; - } - } - - public long MaxCharactersFromEntities - { - get - { - return _maxCharactersFromEntities; - } - set - { - CheckReadOnly("MaxCharactersFromEntities"); - if (value < 0) - { - throw new ArgumentOutOfRangeException("value"); - } - _maxCharactersFromEntities = value; - } - } - - // Filtering settings - public bool IgnoreWhitespace - { - get - { - return _ignoreWhitespace; - } - set - { - CheckReadOnly("IgnoreWhitespace"); - _ignoreWhitespace = value; - } - } - - public bool IgnoreProcessingInstructions - { - get - { - return _ignorePIs; - } - set - { - CheckReadOnly("IgnoreProcessingInstructions"); - _ignorePIs = value; - } - } - - public bool IgnoreComments - { - get - { - return _ignoreComments; - } - set - { - CheckReadOnly("IgnoreComments"); - _ignoreComments = value; - } - } - - [Obsolete("Use XmlReaderSettings.DtdProcessing property instead.")] - public bool ProhibitDtd - { - get - { - return _dtdProcessing == DtdProcessing.Prohibit; - } - set - { - CheckReadOnly("ProhibitDtd"); - _dtdProcessing = value ? DtdProcessing.Prohibit : DtdProcessing.Parse; - } - } - - public DtdProcessing DtdProcessing - { - get - { - return _dtdProcessing; - } - set - { - CheckReadOnly("DtdProcessing"); - - if ((uint)value > (uint)DtdProcessing.Parse) - { - throw new ArgumentOutOfRangeException("value"); - } - _dtdProcessing = value; - } - } - - public bool CloseInput - { - get - { - return _closeInput; - } - set - { - CheckReadOnly("CloseInput"); - _closeInput = value; - } - } - - public ValidationType ValidationType - { - get - { - return _validationType; - } - set - { - CheckReadOnly("ValidationType"); - - if ((uint)value > (uint)ValidationType.Schema) - { - throw new ArgumentOutOfRangeException("value"); - } - _validationType = value; - } - } - - public XmlSchemaValidationFlags ValidationFlags - { - get - { - return _validationFlags; - } - set - { - CheckReadOnly("ValidationFlags"); - - if ((uint)value > (uint)(XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | - XmlSchemaValidationFlags.AllowXmlAttributes)) - { - throw new ArgumentOutOfRangeException("value"); - } - _validationFlags = value; - } - } - - public XmlSchemaSet Schemas - { - get - { - if (_schemas == null) - { - _schemas = new XmlSchemaSet(); - } - return _schemas; - } - set - { - CheckReadOnly("Schemas"); - _schemas = value; - } - } - - public event ValidationEventHandler ValidationEventHandler - { - add - { - CheckReadOnly("ValidationEventHandler"); - _valEventHandler += value; - } - remove - { - CheckReadOnly("ValidationEventHandler"); - _valEventHandler -= value; - } - } - - // - // Public methods - // - public void Reset() - { - CheckReadOnly("Reset"); - Initialize(); - } - - public XmlReaderSettings Clone() - { - XmlReaderSettings clonedSettings = this.MemberwiseClone() as XmlReaderSettings; - clonedSettings.ReadOnly = false; - return clonedSettings; - } - - // - // Internal methods - // - internal ValidationEventHandler GetEventHandler() - { - return _valEventHandler; - } - - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - internal XmlReader CreateReader(String inputUri, XmlParserContext inputContext) - { - if (inputUri == null) - { - throw new ArgumentNullException("inputUri"); - } - if (inputUri.Length == 0) - { - throw new ArgumentException(ResXml.XmlConvert_BadUri, "inputUri"); - } - - // resolve and open the url - XmlResolver tmpResolver = this.GetXmlResolver(); - if (tmpResolver == null) - { - tmpResolver = CreateDefaultResolver(); - } - - // create text XML reader - XmlReader reader = new XmlTextReaderImpl(inputUri, this, inputContext, tmpResolver); - - // wrap with validating reader - if (this.ValidationType != ValidationType.None) - { - reader = AddValidation(reader); - } - -#if ASYNC - if (useAsync) { - reader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(reader); - } -#endif - return reader; - } - - internal XmlReader CreateReader(Stream input, Uri baseUri, string baseUriString, XmlParserContext inputContext) - { - if (input == null) - { - throw new ArgumentNullException("input"); - } - if (baseUriString == null) - { - if (baseUri == null) - { - baseUriString = string.Empty; - } - else - { - baseUriString = baseUri.ToString(); - } - } - - // create text XML reader - XmlReader reader = new XmlTextReaderImpl(input, null, 0, this, baseUri, baseUriString, inputContext, _closeInput); - - // wrap with validating reader - if (this.ValidationType != ValidationType.None) - { - reader = AddValidation(reader); - } - -#if ASYNC - if (useAsync) { - reader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(reader); - } -#endif - - return reader; - } - - internal XmlReader CreateReader(TextReader input, string baseUriString, XmlParserContext inputContext) - { - if (input == null) - { - throw new ArgumentNullException("input"); - } - if (baseUriString == null) - { - baseUriString = string.Empty; - } - - // create xml text reader - XmlReader reader = new XmlTextReaderImpl(input, this, baseUriString, inputContext); - - // wrap with validating reader - if (this.ValidationType != ValidationType.None) - { - reader = AddValidation(reader); - } - -#if ASYNC - if (useAsync) { - reader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(reader); - } -#endif - - return reader; - } - - internal XmlReader CreateReader(XmlReader reader) - { - if (reader == null) - { - throw new ArgumentNullException("reader"); - } -#if !ASYNC || SILVERLIGHT || FEATURE_NETCORE - // wrap with conformance layer (if needed) - return AddConformanceWrapper(reader); -#else - return AddValidationAndConformanceWrapper(reader); -#endif // !ASYNC || SILVERLIGHT || FEATURE_NETCORE - } - - internal bool ReadOnly - { - get - { - return _isReadOnly; - } - set - { - _isReadOnly = value; - } - } - - private void CheckReadOnly(string propertyName) - { - if (_isReadOnly) - { - throw new XmlException(ResXml.Xml_ReadOnlyProperty, this.GetType().Name + '.' + propertyName); - } - } - - // - // Private methods - // - private void Initialize() - { - Initialize(null); - } - - private void Initialize(XmlResolver resolver) - { - _nameTable = null; - if (!EnableLegacyXmlSettings()) - { - _xmlResolver = resolver; - // limit the entity resolving to 10 million character. the caller can still - // override it to any other value or set it to zero for unlimiting it - _maxCharactersFromEntities = (long)1e7; - } - else - { - _xmlResolver = (resolver == null ? CreateDefaultResolver() : resolver); - _maxCharactersFromEntities = 0; - } - _lineNumberOffset = 0; - _linePositionOffset = 0; - _checkCharacters = true; - _conformanceLevel = ConformanceLevel.Document; - - _ignoreWhitespace = false; - _ignorePIs = false; - _ignoreComments = false; - _dtdProcessing = DtdProcessing.Prohibit; - _closeInput = false; - - _maxCharactersInDocument = 0; - - _schemas = null; - _validationType = ValidationType.None; - _validationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints; - _validationFlags |= XmlSchemaValidationFlags.AllowXmlAttributes; - -#if ASYNC || FEATURE_NETCORE - useAsync = false; -#endif - - _isReadOnly = false; - IsXmlResolverSet = false; - } - - private static XmlResolver CreateDefaultResolver() - { - return new XmlUrlResolver(); - } - - internal XmlReader AddValidation(XmlReader reader) - { - if (_validationType == ValidationType.Schema) - { - XmlResolver resolver = GetXmlResolver_CheckConfig(); - - if (resolver == null && - !this.IsXmlResolverSet && - !EnableLegacyXmlSettings()) - { - resolver = new XmlUrlResolver(); - } - reader = new XsdValidatingReader(reader, resolver, this); - } - else if (_validationType == ValidationType.DTD) - { - reader = CreateDtdValidatingReader(reader); - } - return reader; - } - - private XmlReader AddValidationAndConformanceWrapper(XmlReader reader) - { - // wrap with DTD validating reader - if (_validationType == ValidationType.DTD) - { - reader = CreateDtdValidatingReader(reader); - } - // add conformance checking (must go after DTD validation because XmlValidatingReader works only on XmlTextReader), - // but before XSD validation because of typed value access - reader = AddConformanceWrapper(reader); - - if (_validationType == ValidationType.Schema) - { - reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this); - } - return reader; - } - - private XmlValidatingReaderImpl CreateDtdValidatingReader(XmlReader baseReader) - { - return new XmlValidatingReaderImpl(baseReader, this.GetEventHandler(), (this.ValidationFlags & XmlSchemaValidationFlags.ProcessIdentityConstraints) != 0); - } - - internal XmlReader AddConformanceWrapper(XmlReader baseReader) - { - XmlReaderSettings baseReaderSettings = baseReader.Settings; - bool checkChars = false; - bool noWhitespace = false; - bool noComments = false; - bool noPIs = false; - DtdProcessing dtdProc = (DtdProcessing)(-1); - bool needWrap = false; - - if (baseReaderSettings == null) - { -#pragma warning disable 618 - - if (_conformanceLevel != ConformanceLevel.Auto && _conformanceLevel != XmlReader.GetV1ConformanceLevel(baseReader)) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_IncompatibleConformanceLevel, _conformanceLevel.ToString())); - } - - // get the V1 XmlTextReader ref - XmlTextReader v1XmlTextReader = baseReader as XmlTextReader; - if (v1XmlTextReader == null) - { - XmlValidatingReader vr = baseReader as XmlValidatingReader; - if (vr != null) - { - v1XmlTextReader = (XmlTextReader)vr.Reader; - } - } - - // assume the V1 readers already do all conformance checking; - // wrap only if IgnoreWhitespace, IgnoreComments, IgnoreProcessingInstructions or ProhibitDtd is true; - if (_ignoreWhitespace) - { - WhitespaceHandling wh = WhitespaceHandling.All; - // special-case our V1 readers to see if whey already filter whitespaces - if (v1XmlTextReader != null) - { - wh = v1XmlTextReader.WhitespaceHandling; - } - if (wh == WhitespaceHandling.All) - { - noWhitespace = true; - needWrap = true; - } - } - if (_ignoreComments) - { - noComments = true; - needWrap = true; - } - if (_ignorePIs) - { - noPIs = true; - needWrap = true; - } - // DTD processing - DtdProcessing baseDtdProcessing = DtdProcessing.Parse; - if (v1XmlTextReader != null) - { - baseDtdProcessing = v1XmlTextReader.DtdProcessing; - } - if ((_dtdProcessing == DtdProcessing.Prohibit && baseDtdProcessing != DtdProcessing.Prohibit) || - (_dtdProcessing == DtdProcessing.Ignore && baseDtdProcessing == DtdProcessing.Parse)) - { - dtdProc = _dtdProcessing; - needWrap = true; - } -#pragma warning restore 618 - } - else - { - if (_conformanceLevel != baseReaderSettings.ConformanceLevel && _conformanceLevel != ConformanceLevel.Auto) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_IncompatibleConformanceLevel, _conformanceLevel.ToString())); - } - if (_checkCharacters && !baseReaderSettings.CheckCharacters) - { - checkChars = true; - needWrap = true; - } - if (_ignoreWhitespace && !baseReaderSettings.IgnoreWhitespace) - { - noWhitespace = true; - needWrap = true; - } - if (_ignoreComments && !baseReaderSettings.IgnoreComments) - { - noComments = true; - needWrap = true; - } - if (_ignorePIs && !baseReaderSettings.IgnoreProcessingInstructions) - { - noPIs = true; - needWrap = true; - } - - if ((_dtdProcessing == DtdProcessing.Prohibit && baseReaderSettings.DtdProcessing != DtdProcessing.Prohibit) || - (_dtdProcessing == DtdProcessing.Ignore && baseReaderSettings.DtdProcessing == DtdProcessing.Parse)) - { - dtdProc = _dtdProcessing; - needWrap = true; - } - } - - if (needWrap) - { - IXmlNamespaceResolver readerAsNSResolver = baseReader as IXmlNamespaceResolver; - if (readerAsNSResolver != null) - { - return new XmlCharCheckingReaderWithNS(baseReader, readerAsNSResolver, checkChars, noWhitespace, noComments, noPIs, dtdProc); - } - else - { - return new XmlCharCheckingReader(baseReader, checkChars, noWhitespace, noComments, noPIs, dtdProc); - } - } - else - { - return baseReader; - } - } - - private static bool? s_enableLegacyXmlSettings = null; - - static internal bool EnableLegacyXmlSettings() - { - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSpace.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSpace.cs deleted file mode 100644 index 145ba43e787..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSpace.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // An enumeration for the xml:space scope used in XmlReader and XmlWriter. - public enum XmlSpace - { - // xml:space scope has not been specified. - None = 0, - - // The xml:space scope is "default". - Default = 1, - - // The xml:space scope is "preserve". - Preserve = 2 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReader.cs deleted file mode 100644 index 3ed7870941a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReader.cs +++ /dev/null @@ -1,1582 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Globalization; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - internal sealed partial class XmlSubtreeReader : XmlWrappingReader, IXmlLineInfo, IXmlNamespaceResolver - { - // - // Private types - // - private class NodeData - { - internal XmlNodeType type; - internal string localName; - internal string prefix; - internal string name; - internal string namespaceUri; - internal string value; - - internal NodeData() - { - } - - internal void Set(XmlNodeType nodeType, string localName, string prefix, string name, string namespaceUri, string value) - { - this.type = nodeType; - this.localName = localName; - this.prefix = prefix; - this.name = name; - this.namespaceUri = namespaceUri; - this.value = value; - } - } - - private enum State - { - Initial = ReadState.Initial, - Interactive = ReadState.Interactive, - Error = ReadState.Error, - EndOfFile = ReadState.EndOfFile, - Closed = ReadState.Closed, - PopNamespaceScope, - ClearNsAttributes, - ReadElementContentAsBase64, - ReadElementContentAsBinHex, - ReadContentAsBase64, - ReadContentAsBinHex, - } - - private const int AttributeActiveStates = 0x62; // 00001100010 bin - private const int NamespaceActiveStates = 0x7E2; // 11111100010 bin - - // - // Fields - // - private int _initialDepth; - private State _state; - - // namespace management - private XmlNamespaceManager _nsManager; - private NodeData[] _nsAttributes; - private int _nsAttrCount; - private int _curNsAttr = -1; - - private string _xmlns; - private string _xmlnsUri; - - // incremental reading of added xmlns nodes (ReadValueChunk, ReadContentAsBase64, ReadContentAsBinHex) - private int _nsIncReadOffset; - private IncrementalReadDecoder _binDecoder; - - // cached nodes - private bool _useCurNode; - private NodeData _curNode; - // node used for a text node of ReadAttributeValue or as Initial or EOF node - private NodeData _tmpNode; - - // - // Constants - // - internal int InitialNamespaceAttributeCount = 4; - - // - // Constructor - // - internal XmlSubtreeReader(XmlReader reader) : base(reader) - { - _initialDepth = reader.Depth; - _state = State.Initial; - _nsManager = new XmlNamespaceManager(reader.NameTable); - _xmlns = reader.NameTable.Add("xmlns"); - _xmlnsUri = reader.NameTable.Add(XmlReservedNs.NsXmlNs); - - _tmpNode = new NodeData(); - _tmpNode.Set(XmlNodeType.None, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); - - SetCurrentNode(_tmpNode); - } - - // - // XmlReader implementation - // - public override XmlNodeType NodeType - { - get - { - return (_useCurNode) ? _curNode.type : reader.NodeType; - } - } - - public override string Name - { - get - { - return (_useCurNode) ? _curNode.name : reader.Name; - } - } - - public override string LocalName - { - get - { - return (_useCurNode) ? _curNode.localName : reader.LocalName; - } - } - - public override string NamespaceURI - { - get - { - return (_useCurNode) ? _curNode.namespaceUri : reader.NamespaceURI; - } - } - - public override string Prefix - { - get - { - return (_useCurNode) ? _curNode.prefix : reader.Prefix; - } - } - - public override string Value - { - get - { - return (_useCurNode) ? _curNode.value : reader.Value; - } - } - - public override int Depth - { - get - { - int depth = reader.Depth - _initialDepth; - if (_curNsAttr != -1) - { - if (_curNode.type == XmlNodeType.Text) - { // we are on namespace attribute value - depth += 2; - } - else - { - depth++; - } - } - return depth; - } - } - - public override string BaseURI - { - get - { - return reader.BaseURI; - } - } - - public override bool IsEmptyElement - { - get - { - return reader.IsEmptyElement; - } - } - - public override bool EOF - { - get - { - return _state == State.EndOfFile || _state == State.Closed; - } - } - - public override ReadState ReadState - { - get - { - if (reader.ReadState == ReadState.Error) - { - return ReadState.Error; - } - else - { - if ((int)_state <= (int)State.Closed) - { - return (ReadState)(int)_state; - } - else - { - return ReadState.Interactive; - } - } - } - } - - public override XmlNameTable NameTable - { - get - { - return reader.NameTable; - } - } - - public override int AttributeCount - { - get - { - return InAttributeActiveState ? reader.AttributeCount + _nsAttrCount : 0; - } - } - - public override string GetAttribute(string name) - { - if (!InAttributeActiveState) - { - return null; - } - string attr = reader.GetAttribute(name); - if (attr != null) - { - return attr; - } - for (int i = 0; i < _nsAttrCount; i++) - { - if (name == _nsAttributes[i].name) - { - return _nsAttributes[i].value; - } - } - return null; - } - - public override string GetAttribute(string name, string namespaceURI) - { - if (!InAttributeActiveState) - { - return null; - } - string attr = reader.GetAttribute(name, namespaceURI); - if (attr != null) - { - return attr; - } - for (int i = 0; i < _nsAttrCount; i++) - { - if (name == _nsAttributes[i].localName && namespaceURI == _xmlnsUri) - { - return _nsAttributes[i].value; - } - } - return null; - } - - public override string GetAttribute(int i) - { - if (!InAttributeActiveState) - { - throw new ArgumentOutOfRangeException("i"); - } - int n = reader.AttributeCount; - if (i < n) - { - return reader.GetAttribute(i); - } - else if (i - n < _nsAttrCount) - { - return _nsAttributes[i - n].value; - } - else - { - throw new ArgumentOutOfRangeException("i"); - } - } - - public override bool MoveToAttribute(string name) - { - if (!InAttributeActiveState) - { - return false; - } - if (reader.MoveToAttribute(name)) - { - _curNsAttr = -1; - _useCurNode = false; - return true; - } - for (int i = 0; i < _nsAttrCount; i++) - { - if (name == _nsAttributes[i].name) - { - MoveToNsAttribute(i); - return true; - } - } - return false; - } - - public override bool MoveToAttribute(string name, string ns) - { - if (!InAttributeActiveState) - { - return false; - } - if (reader.MoveToAttribute(name, ns)) - { - _curNsAttr = -1; - _useCurNode = false; - return true; - } - for (int i = 0; i < _nsAttrCount; i++) - { - if (name == _nsAttributes[i].localName && ns == _xmlnsUri) - { - MoveToNsAttribute(i); - return true; - } - } - return false; - } - - public override void MoveToAttribute(int i) - { - if (!InAttributeActiveState) - { - throw new ArgumentOutOfRangeException("i"); - } - int n = reader.AttributeCount; - if (i < n) - { - reader.MoveToAttribute(i); - _curNsAttr = -1; - _useCurNode = false; - } - else if (i - n < _nsAttrCount) - { - MoveToNsAttribute(i - n); - } - else - { - throw new ArgumentOutOfRangeException("i"); - } - } - - public override bool MoveToFirstAttribute() - { - if (!InAttributeActiveState) - { - return false; - } - if (reader.MoveToFirstAttribute()) - { - _useCurNode = false; - return true; - } - if (_nsAttrCount > 0) - { - MoveToNsAttribute(0); - return true; - } - return false; - } - - public override bool MoveToNextAttribute() - { - if (!InAttributeActiveState) - { - return false; - } - if (_curNsAttr == -1 && reader.MoveToNextAttribute()) - { - return true; - } - if (_curNsAttr + 1 < _nsAttrCount) - { - MoveToNsAttribute(_curNsAttr + 1); - return true; - } - return false; - } - - public override bool MoveToElement() - { - if (!InAttributeActiveState) - { - return false; - } - - _useCurNode = false; - //If on Namespace attribute, the base reader is already on Element node. - if (_curNsAttr >= 0) - { - _curNsAttr = -1; - Debug.Assert(reader.NodeType == XmlNodeType.Element); - return true; - } - else - { - return reader.MoveToElement(); - } - } - - public override bool ReadAttributeValue() - { - if (!InAttributeActiveState) - { - return false; - } - if (_curNsAttr == -1) - { - return reader.ReadAttributeValue(); - } - else if (_curNode.type == XmlNodeType.Text) - { // we are on namespace attribute value - return false; - } - else - { - Debug.Assert(_curNode.type == XmlNodeType.Attribute); - _tmpNode.type = XmlNodeType.Text; - _tmpNode.value = _curNode.value; - SetCurrentNode(_tmpNode); - return true; - } - } - - public override bool Read() - { - switch (_state) - { - case State.Initial: - _useCurNode = false; - _state = State.Interactive; - ProcessNamespaces(); - return true; - - case State.Interactive: - _curNsAttr = -1; - _useCurNode = false; - reader.MoveToElement(); - Debug.Assert(reader.Depth >= _initialDepth); - if (reader.Depth == _initialDepth) - { - if (reader.NodeType == XmlNodeType.EndElement || - (reader.NodeType == XmlNodeType.Element && reader.IsEmptyElement)) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - Debug.Assert(reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement); - } - if (reader.Read()) - { - ProcessNamespaces(); - return true; - } - else - { - SetEmptyNode(); - return false; - } - - case State.EndOfFile: - case State.Closed: - case State.Error: - return false; - - case State.PopNamespaceScope: - _nsManager.PopScope(); - goto case State.ClearNsAttributes; - - case State.ClearNsAttributes: - _nsAttrCount = 0; - _state = State.Interactive; - goto case State.Interactive; - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - if (!FinishReadElementContentAsBinary()) - { - return false; - } - return Read(); - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - if (!FinishReadContentAsBinary()) - { - return false; - } - return Read(); - - default: - Debug.Assert(false); - return false; - } - } - - public override void Close() - { - if (_state == State.Closed) - { - return; - } - try - { - // move the underlying reader to the next sibling - if (_state != State.EndOfFile) - { - reader.MoveToElement(); - Debug.Assert(reader.Depth >= _initialDepth); - // move off the root of the subtree - if (reader.Depth == _initialDepth && reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) - { - reader.Read(); - } - // move to the end of the subtree, do nothing if on empty root element - while (reader.Depth > _initialDepth && reader.Read()) - { - /* intentionally empty */ - } - } - } - catch - { // never fail... - } - finally - { - _curNsAttr = -1; - _useCurNode = false; - _state = State.Closed; - SetEmptyNode(); - } - } - - public override void Skip() - { - switch (_state) - { - case State.Initial: - Read(); - return; - - case State.Interactive: - _curNsAttr = -1; - _useCurNode = false; - reader.MoveToElement(); - Debug.Assert(reader.Depth >= _initialDepth); - if (reader.Depth == _initialDepth) - { - if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) - { - // we are on root of the subtree -> skip to the end element and set to Eof state - if (reader.Read()) - { - while (reader.NodeType != XmlNodeType.EndElement && reader.Depth > _initialDepth) - { - reader.Skip(); - } - } - } - Debug.Assert(reader.NodeType == XmlNodeType.EndElement || - reader.NodeType == XmlNodeType.Element && reader.IsEmptyElement || - reader.ReadState != ReadState.Interactive); - _state = State.EndOfFile; - SetEmptyNode(); - return; - } - - if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) - { - _nsManager.PopScope(); - } - reader.Skip(); - ProcessNamespaces(); - - Debug.Assert(reader.Depth >= _initialDepth); - return; - - case State.Closed: - case State.EndOfFile: - return; - - case State.PopNamespaceScope: - _nsManager.PopScope(); - goto case State.ClearNsAttributes; - - case State.ClearNsAttributes: - _nsAttrCount = 0; - _state = State.Interactive; - goto case State.Interactive; - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - if (FinishReadElementContentAsBinary()) - { - Skip(); - } - break; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - if (FinishReadContentAsBinary()) - { - Skip(); - } - break; - - case State.Error: - return; - - default: - Debug.Assert(false); - return; - } - } - - public override object ReadContentAsObject() - { - try - { - InitReadContentAsType("ReadContentAsObject"); - object value = reader.ReadContentAsObject(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override bool ReadContentAsBoolean() - { - try - { - InitReadContentAsType("ReadContentAsBoolean"); - bool value = reader.ReadContentAsBoolean(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override DateTime ReadContentAsDateTime() - { - try - { - InitReadContentAsType("ReadContentAsDateTime"); - DateTime value = reader.ReadContentAsDateTime(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override double ReadContentAsDouble() - { - try - { - InitReadContentAsType("ReadContentAsDouble"); - double value = reader.ReadContentAsDouble(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override float ReadContentAsFloat() - { - try - { - InitReadContentAsType("ReadContentAsFloat"); - float value = reader.ReadContentAsFloat(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override decimal ReadContentAsDecimal() - { - try - { - InitReadContentAsType("ReadContentAsDecimal"); - decimal value = reader.ReadContentAsDecimal(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override int ReadContentAsInt() - { - try - { - InitReadContentAsType("ReadContentAsInt"); - int value = reader.ReadContentAsInt(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override long ReadContentAsLong() - { - try - { - InitReadContentAsType("ReadContentAsLong"); - long value = reader.ReadContentAsLong(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override string ReadContentAsString() - { - try - { - InitReadContentAsType("ReadContentAsString"); - string value = reader.ReadContentAsString(); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - try - { - InitReadContentAsType("ReadContentAs"); - object value = reader.ReadContentAs(returnType, namespaceResolver); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override bool CanReadBinaryContent - { - get - { - return reader.CanReadBinaryContent; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - switch (NodeType) - { - case XmlNodeType.Element: - throw CreateReadContentAsException("ReadContentAsBase64"); - case XmlNodeType.EndElement: - return 0; - case XmlNodeType.Attribute: - if (_curNsAttr != -1 && reader.CanReadBinaryContent) - { - CheckBuffer(buffer, index, count); - if (count == 0) - { - return 0; - } - if (_nsIncReadOffset == 0) - { - // called first time on this ns attribute - if (_binDecoder != null && _binDecoder is Base64Decoder) - { - _binDecoder.Reset(); - } - else - { - _binDecoder = new Base64Decoder(); - } - } - if (_nsIncReadOffset == _curNode.value.Length) - { - return 0; - } - _binDecoder.SetNextOutputBuffer(buffer, index, count); - _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); - return _binDecoder.DecodedCount; - } - goto case XmlNodeType.Text; - case XmlNodeType.Text: - Debug.Assert(AttributeCount > 0); - return reader.ReadContentAsBase64(buffer, index, count); - default: - Debug.Assert(false); - return 0; - } - - case State.Interactive: - _state = State.ReadContentAsBase64; - goto case State.ReadContentAsBase64; - - case State.ReadContentAsBase64: - int read = reader.ReadContentAsBase64(buffer, index, count); - if (read == 0) - { - _state = State.Interactive; - ProcessNamespaces(); - } - return read; - - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.Interactive: - case State.PopNamespaceScope: - case State.ClearNsAttributes: - if (!InitReadElementContentAsBinary(State.ReadElementContentAsBase64)) - { - return 0; - } - goto case State.ReadElementContentAsBase64; - - case State.ReadElementContentAsBase64: - int read = reader.ReadContentAsBase64(buffer, index, count); - if (read > 0 || count == 0) - { - return read; - } - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // set eof state or move off the end element - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - } - else - { - Read(); - } - return 0; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - switch (NodeType) - { - case XmlNodeType.Element: - throw CreateReadContentAsException("ReadContentAsBinHex"); - case XmlNodeType.EndElement: - return 0; - case XmlNodeType.Attribute: - if (_curNsAttr != -1 && reader.CanReadBinaryContent) - { - CheckBuffer(buffer, index, count); - if (count == 0) - { - return 0; - } - if (_nsIncReadOffset == 0) - { - // called first time on this ns attribute - if (_binDecoder != null && _binDecoder is BinHexDecoder) - { - _binDecoder.Reset(); - } - else - { - _binDecoder = new BinHexDecoder(); - } - } - if (_nsIncReadOffset == _curNode.value.Length) - { - return 0; - } - _binDecoder.SetNextOutputBuffer(buffer, index, count); - _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); - return _binDecoder.DecodedCount; - } - goto case XmlNodeType.Text; - case XmlNodeType.Text: - Debug.Assert(AttributeCount > 0); - return reader.ReadContentAsBinHex(buffer, index, count); - default: - Debug.Assert(false); - return 0; - } - - case State.Interactive: - _state = State.ReadContentAsBinHex; - goto case State.ReadContentAsBinHex; - - case State.ReadContentAsBinHex: - int read = reader.ReadContentAsBinHex(buffer, index, count); - if (read == 0) - { - _state = State.Interactive; - ProcessNamespaces(); - } - return read; - - case State.ReadContentAsBase64: - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.Interactive: - case State.PopNamespaceScope: - case State.ClearNsAttributes: - if (!InitReadElementContentAsBinary(State.ReadElementContentAsBinHex)) - { - return 0; - } - goto case State.ReadElementContentAsBinHex; - case State.ReadElementContentAsBinHex: - int read = reader.ReadContentAsBinHex(buffer, index, count); - if (read > 0 || count == 0) - { - return read; - } - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // set eof state or move off the end element - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - } - else - { - Read(); - } - return 0; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBase64: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override bool CanReadValueChunk - { - get - { - return reader.CanReadValueChunk; - } - } - - public override int ReadValueChunk(char[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - // ReadValueChunk implementation on added xmlns attributes - if (_curNsAttr != -1 && reader.CanReadValueChunk) - { - CheckBuffer(buffer, index, count); - int copyCount = _curNode.value.Length - _nsIncReadOffset; - if (copyCount > count) - { - copyCount = count; - } - if (copyCount > 0) - { - _curNode.value.CopyTo(_nsIncReadOffset, buffer, index, copyCount); - } - _nsIncReadOffset += copyCount; - return copyCount; - } - // Otherwise fall back to the case State.Interactive. - // No need to clean ns attributes or pop scope because the reader when ReadValueChunk is called - // - on Element errors - // - on EndElement errors - // - on Attribute does not move - // and that's all where State.ClearNsAttributes or State.PopnamespaceScope can be set - goto case State.Interactive; - - case State.Interactive: - return reader.ReadValueChunk(buffer, index, count); - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingReadValueChunkWithBinary); - - default: - Debug.Assert(false); - return 0; - } - } - - public override string LookupNamespace(string prefix) - { - return ((IXmlNamespaceResolver)this).LookupNamespace(prefix); - } - - // - // IDisposable interface - // - protected override void Dispose(bool disposing) - { - // note: we do not want to dispose the underlying reader - this.Close(); - } - - // - // IXmlLineInfo implementation - // - int IXmlLineInfo.LineNumber - { - get - { - if (!_useCurNode) - { - IXmlLineInfo lineInfo = reader as IXmlLineInfo; - if (lineInfo != null) - { - return lineInfo.LineNumber; - } - } - return 0; - } - } - - int IXmlLineInfo.LinePosition - { - get - { - if (!_useCurNode) - { - IXmlLineInfo lineInfo = reader as IXmlLineInfo; - if (lineInfo != null) - { - return lineInfo.LinePosition; - } - } - return 0; - } - } - - bool IXmlLineInfo.HasLineInfo() - { - return reader is IXmlLineInfo; - } - - // - // IXmlNamespaceResolver implementation - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - if (!InNamespaceActiveState) - { - return new Dictionary(); - } - return _nsManager.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - if (!InNamespaceActiveState) - { - return null; - } - return _nsManager.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - if (!InNamespaceActiveState) - { - return null; - } - return _nsManager.LookupPrefix(namespaceName); - } - - // - // Private methods - // - private void ProcessNamespaces() - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - _nsManager.PushScope(); - - string prefix = reader.Prefix; - string ns = reader.NamespaceURI; - if (_nsManager.LookupNamespace(prefix) != ns) - { - AddNamespace(prefix, ns); - } - - if (reader.MoveToFirstAttribute()) - { - do - { - prefix = reader.Prefix; - ns = reader.NamespaceURI; - - if (Ref.Equal(ns, _xmlnsUri)) - { - if (prefix.Length == 0) - { - _nsManager.AddNamespace(string.Empty, reader.Value); - RemoveNamespace(string.Empty, _xmlns); - } - else - { - prefix = reader.LocalName; - _nsManager.AddNamespace(prefix, reader.Value); - RemoveNamespace(_xmlns, prefix); - } - } - else if (prefix.Length != 0 && _nsManager.LookupNamespace(prefix) != ns) - { - AddNamespace(prefix, ns); - } - } while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - - if (reader.IsEmptyElement) - { - _state = State.PopNamespaceScope; - } - break; - case XmlNodeType.EndElement: - _state = State.PopNamespaceScope; - break; - } - } - - private void AddNamespace(string prefix, string ns) - { - _nsManager.AddNamespace(prefix, ns); - - int index = _nsAttrCount++; - if (_nsAttributes == null) - { - _nsAttributes = new NodeData[InitialNamespaceAttributeCount]; - } - if (index == _nsAttributes.Length) - { - NodeData[] newNsAttrs = new NodeData[_nsAttributes.Length * 2]; - Array.Copy(_nsAttributes, 0, newNsAttrs, 0, index); - _nsAttributes = newNsAttrs; - } - - if (_nsAttributes[index] == null) - { - _nsAttributes[index] = new NodeData(); - } - if (prefix.Length == 0) - { - _nsAttributes[index].Set(XmlNodeType.Attribute, _xmlns, string.Empty, _xmlns, _xmlnsUri, ns); - } - else - { - _nsAttributes[index].Set(XmlNodeType.Attribute, prefix, _xmlns, reader.NameTable.Add(string.Concat(_xmlns, ":", prefix)), _xmlnsUri, ns); - } - - Debug.Assert(_state == State.ClearNsAttributes || _state == State.Interactive || _state == State.PopNamespaceScope); - _state = State.ClearNsAttributes; - - _curNsAttr = -1; - } - - private void RemoveNamespace(string prefix, string localName) - { - for (int i = 0; i < _nsAttrCount; i++) - { - if (Ref.Equal(prefix, _nsAttributes[i].prefix) && - Ref.Equal(localName, _nsAttributes[i].localName)) - { - if (i < _nsAttrCount - 1) - { - // swap - NodeData tmpNodeData = _nsAttributes[i]; - _nsAttributes[i] = _nsAttributes[_nsAttrCount - 1]; - _nsAttributes[_nsAttrCount - 1] = tmpNodeData; - } - _nsAttrCount--; - break; - } - } - } - - private void MoveToNsAttribute(int index) - { - Debug.Assert(index >= 0 && index <= _nsAttrCount); - reader.MoveToElement(); - _curNsAttr = index; - _nsIncReadOffset = 0; - SetCurrentNode(_nsAttributes[index]); - } - - private bool InitReadElementContentAsBinary(State binaryState) - { - if (NodeType != XmlNodeType.Element) - { - throw reader.CreateReadElementContentAsException("ReadElementContentAsBase64"); - } - - bool isEmpty = IsEmptyElement; - - // move to content or off the empty element - if (!Read() || isEmpty) - { - return false; - } - // special-case child element and end element - switch (NodeType) - { - case XmlNodeType.Element: - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - case XmlNodeType.EndElement: - // pop scope & move off end element - ProcessNamespaces(); - Read(); - return false; - } - - Debug.Assert(_state == State.Interactive); - _state = binaryState; - return true; - } - - private bool FinishReadElementContentAsBinary() - { - Debug.Assert(_state == State.ReadElementContentAsBase64 || _state == State.ReadElementContentAsBinHex); - - byte[] bytes = new byte[256]; - if (_state == State.ReadElementContentAsBase64) - { - while (reader.ReadContentAsBase64(bytes, 0, 256) > 0) ; - } - else - { - while (reader.ReadContentAsBinHex(bytes, 0, 256) > 0) ; - } - - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // check eof - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - // move off end element - return Read(); - } - - private bool FinishReadContentAsBinary() - { - Debug.Assert(_state == State.ReadContentAsBase64 || _state == State.ReadContentAsBinHex); - - byte[] bytes = new byte[256]; - if (_state == State.ReadContentAsBase64) - { - while (reader.ReadContentAsBase64(bytes, 0, 256) > 0) ; - } - else - { - while (reader.ReadContentAsBinHex(bytes, 0, 256) > 0) ; - } - - _state = State.Interactive; - ProcessNamespaces(); - - // check eof - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - return true; - } - - private bool InAttributeActiveState - { - get - { -#if DEBUG - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.Initial))); - Debug.Assert(0 != (AttributeActiveStates & (1 << (int)State.Interactive))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.Error))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.EndOfFile))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.Closed))); - Debug.Assert(0 != (AttributeActiveStates & (1 << (int)State.PopNamespaceScope))); - Debug.Assert(0 != (AttributeActiveStates & (1 << (int)State.ClearNsAttributes))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.ReadElementContentAsBase64))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.ReadElementContentAsBinHex))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.ReadContentAsBase64))); - Debug.Assert(0 == (AttributeActiveStates & (1 << (int)State.ReadContentAsBinHex))); -#endif - return 0 != (AttributeActiveStates & (1 << (int)_state)); - } - } - - private bool InNamespaceActiveState - { - get - { -#if DEBUG - Debug.Assert(0 == (NamespaceActiveStates & (1 << (int)State.Initial))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.Interactive))); - Debug.Assert(0 == (NamespaceActiveStates & (1 << (int)State.Error))); - Debug.Assert(0 == (NamespaceActiveStates & (1 << (int)State.EndOfFile))); - Debug.Assert(0 == (NamespaceActiveStates & (1 << (int)State.Closed))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.PopNamespaceScope))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.ClearNsAttributes))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.ReadElementContentAsBase64))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.ReadElementContentAsBinHex))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.ReadContentAsBase64))); - Debug.Assert(0 != (NamespaceActiveStates & (1 << (int)State.ReadContentAsBinHex))); -#endif - return 0 != (NamespaceActiveStates & (1 << (int)_state)); - } - } - - private void SetEmptyNode() - { - Debug.Assert(_tmpNode.localName == string.Empty && _tmpNode.prefix == string.Empty && _tmpNode.name == string.Empty && _tmpNode.namespaceUri == string.Empty); - _tmpNode.type = XmlNodeType.None; - _tmpNode.value = string.Empty; - - _curNode = _tmpNode; - _useCurNode = true; - } - - private void SetCurrentNode(NodeData node) - { - _curNode = node; - _useCurNode = true; - } - - private void InitReadContentAsType(string methodName) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - throw new InvalidOperationException(ResXml.Xml_ClosedOrErrorReader); - - case State.Interactive: - return; - - case State.PopNamespaceScope: - case State.ClearNsAttributes: - // no need to clean ns attributes or pop scope because the reader when ReadContentAs is called - // - on Element errors - // - on Attribute does not move - // - on EndElement does not move - // and that's all where State.ClearNsAttributes or State.PopNamespacScope can be set - return; - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingReadValueChunkWithBinary); - - default: - Debug.Assert(false); - break; - } - throw CreateReadContentAsException(methodName); - } - - private void FinishReadContentAsType() - { - Debug.Assert(_state == State.Interactive || - _state == State.PopNamespaceScope || - _state == State.ClearNsAttributes); - - switch (NodeType) - { - case XmlNodeType.Element: - // new element we moved to - process namespaces - ProcessNamespaces(); - break; - case XmlNodeType.EndElement: - // end element we've stayed on or have been moved to - _state = State.PopNamespaceScope; - break; - case XmlNodeType.Attribute: - // stayed on attribute, do nothing - break; - } - } - - private void CheckBuffer(Array buffer, int index, int count) - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReaderAsync.cs deleted file mode 100644 index 390c9a58fe7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlSubtreeReaderAsync.cs +++ /dev/null @@ -1,651 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Globalization; -using System.Collections.Generic; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - internal sealed partial class XmlSubtreeReader : XmlWrappingReader, IXmlLineInfo, IXmlNamespaceResolver - { - public override Task GetValueAsync() - { - if (_useCurNode) - { - return Task.FromResult(_curNode.value); - } - else - { - return reader.GetValueAsync(); - } - } - - public override async Task ReadAsync() - { - switch (_state) - { - case State.Initial: - _useCurNode = false; - _state = State.Interactive; - ProcessNamespaces(); - return true; - - case State.Interactive: - _curNsAttr = -1; - _useCurNode = false; - reader.MoveToElement(); - Debug.Assert(reader.Depth >= _initialDepth); - if (reader.Depth == _initialDepth) - { - if (reader.NodeType == XmlNodeType.EndElement || - (reader.NodeType == XmlNodeType.Element && reader.IsEmptyElement)) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - Debug.Assert(reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement); - } - if (await reader.ReadAsync().ConfigureAwait(false)) - { - ProcessNamespaces(); - return true; - } - else - { - SetEmptyNode(); - return false; - } - - case State.EndOfFile: - case State.Closed: - case State.Error: - return false; - - case State.PopNamespaceScope: - _nsManager.PopScope(); - goto case State.ClearNsAttributes; - - case State.ClearNsAttributes: - _nsAttrCount = 0; - _state = State.Interactive; - goto case State.Interactive; - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - if (!await FinishReadElementContentAsBinaryAsync().ConfigureAwait(false)) - { - return false; - } - return await ReadAsync().ConfigureAwait(false); - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - if (!await FinishReadContentAsBinaryAsync().ConfigureAwait(false)) - { - return false; - } - return await ReadAsync().ConfigureAwait(false); - - default: - Debug.Assert(false); - return false; - } - } - - public override async Task SkipAsync() - { - switch (_state) - { - case State.Initial: - await ReadAsync().ConfigureAwait(false); - return; - - case State.Interactive: - _curNsAttr = -1; - _useCurNode = false; - reader.MoveToElement(); - Debug.Assert(reader.Depth >= _initialDepth); - if (reader.Depth == _initialDepth) - { - if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) - { - // we are on root of the subtree -> skip to the end element and set to Eof state - if (await reader.ReadAsync().ConfigureAwait(false)) - { - while (reader.NodeType != XmlNodeType.EndElement && reader.Depth > _initialDepth) - { - await reader.SkipAsync().ConfigureAwait(false); - } - } - } - Debug.Assert(reader.NodeType == XmlNodeType.EndElement || - reader.NodeType == XmlNodeType.Element && reader.IsEmptyElement || - reader.ReadState != ReadState.Interactive); - _state = State.EndOfFile; - SetEmptyNode(); - return; - } - - if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement) - { - _nsManager.PopScope(); - } - await reader.SkipAsync().ConfigureAwait(false); - ProcessNamespaces(); - - Debug.Assert(reader.Depth >= _initialDepth); - return; - - case State.Closed: - case State.EndOfFile: - return; - - case State.PopNamespaceScope: - _nsManager.PopScope(); - goto case State.ClearNsAttributes; - - case State.ClearNsAttributes: - _nsAttrCount = 0; - _state = State.Interactive; - goto case State.Interactive; - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - if (await FinishReadElementContentAsBinaryAsync().ConfigureAwait(false)) - { - await SkipAsync().ConfigureAwait(false); - } - break; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - if (await FinishReadContentAsBinaryAsync().ConfigureAwait(false)) - { - await SkipAsync().ConfigureAwait(false); - } - break; - - case State.Error: - return; - - default: - Debug.Assert(false); - return; - } - } - - public override async Task ReadContentAsObjectAsync() - { - try - { - InitReadContentAsType("ReadContentAsObject"); - object value = await reader.ReadContentAsObjectAsync().ConfigureAwait(false); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override async Task ReadContentAsStringAsync() - { - try - { - InitReadContentAsType("ReadContentAsString"); - string value = await reader.ReadContentAsStringAsync().ConfigureAwait(false); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override async Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - try - { - InitReadContentAsType("ReadContentAs"); - object value = await reader.ReadContentAsAsync(returnType, namespaceResolver).ConfigureAwait(false); - FinishReadContentAsType(); - return value; - } - catch - { - _state = State.Error; - throw; - } - } - - public override async Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - switch (NodeType) - { - case XmlNodeType.Element: - throw CreateReadContentAsException("ReadContentAsBase64"); - case XmlNodeType.EndElement: - return 0; - case XmlNodeType.Attribute: - if (_curNsAttr != -1 && reader.CanReadBinaryContent) - { - CheckBuffer(buffer, index, count); - if (count == 0) - { - return 0; - } - if (_nsIncReadOffset == 0) - { - // called first time on this ns attribute - if (_binDecoder != null && _binDecoder is Base64Decoder) - { - _binDecoder.Reset(); - } - else - { - _binDecoder = new Base64Decoder(); - } - } - if (_nsIncReadOffset == _curNode.value.Length) - { - return 0; - } - _binDecoder.SetNextOutputBuffer(buffer, index, count); - _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); - return _binDecoder.DecodedCount; - } - goto case XmlNodeType.Text; - case XmlNodeType.Text: - Debug.Assert(AttributeCount > 0); - return await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - default: - Debug.Assert(false); - return 0; - } - - case State.Interactive: - _state = State.ReadContentAsBase64; - goto case State.ReadContentAsBase64; - - case State.ReadContentAsBase64: - int read = await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - if (read == 0) - { - _state = State.Interactive; - ProcessNamespaces(); - } - return read; - - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override async Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.Interactive: - case State.PopNamespaceScope: - case State.ClearNsAttributes: - if (!await InitReadElementContentAsBinaryAsync(State.ReadElementContentAsBase64).ConfigureAwait(false)) - { - return 0; - } - goto case State.ReadElementContentAsBase64; - - case State.ReadElementContentAsBase64: - int read = await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - if (read > 0 || count == 0) - { - return read; - } - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // set eof state or move off the end element - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - } - else - { - await ReadAsync().ConfigureAwait(false); - } - return 0; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override async Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - switch (NodeType) - { - case XmlNodeType.Element: - throw CreateReadContentAsException("ReadContentAsBinHex"); - case XmlNodeType.EndElement: - return 0; - case XmlNodeType.Attribute: - if (_curNsAttr != -1 && reader.CanReadBinaryContent) - { - CheckBuffer(buffer, index, count); - if (count == 0) - { - return 0; - } - if (_nsIncReadOffset == 0) - { - // called first time on this ns attribute - if (_binDecoder != null && _binDecoder is BinHexDecoder) - { - _binDecoder.Reset(); - } - else - { - _binDecoder = new BinHexDecoder(); - } - } - if (_nsIncReadOffset == _curNode.value.Length) - { - return 0; - } - _binDecoder.SetNextOutputBuffer(buffer, index, count); - _nsIncReadOffset += _binDecoder.Decode(_curNode.value, _nsIncReadOffset, _curNode.value.Length - _nsIncReadOffset); - return _binDecoder.DecodedCount; - } - goto case XmlNodeType.Text; - case XmlNodeType.Text: - Debug.Assert(AttributeCount > 0); - return await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - default: - Debug.Assert(false); - return 0; - } - - case State.Interactive: - _state = State.ReadContentAsBinHex; - goto case State.ReadContentAsBinHex; - - case State.ReadContentAsBinHex: - int read = await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - if (read == 0) - { - _state = State.Interactive; - ProcessNamespaces(); - } - return read; - - case State.ReadContentAsBase64: - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override async Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return 0; - - case State.Interactive: - case State.PopNamespaceScope: - case State.ClearNsAttributes: - if (!await InitReadElementContentAsBinaryAsync(State.ReadElementContentAsBinHex).ConfigureAwait(false)) - { - return 0; - } - goto case State.ReadElementContentAsBinHex; - case State.ReadElementContentAsBinHex: - int read = await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - if (read > 0 || count == 0) - { - return read; - } - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // set eof state or move off the end element - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - } - else - { - await ReadAsync().ConfigureAwait(false); - } - return 0; - - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - case State.ReadElementContentAsBase64: - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - - default: - Debug.Assert(false); - return 0; - } - } - - public override Task ReadValueChunkAsync(char[] buffer, int index, int count) - { - switch (_state) - { - case State.Initial: - case State.EndOfFile: - case State.Closed: - case State.Error: - return Task.FromResult(0); - - case State.ClearNsAttributes: - case State.PopNamespaceScope: - // ReadValueChunk implementation on added xmlns attributes - if (_curNsAttr != -1 && reader.CanReadValueChunk) - { - CheckBuffer(buffer, index, count); - int copyCount = _curNode.value.Length - _nsIncReadOffset; - if (copyCount > count) - { - copyCount = count; - } - if (copyCount > 0) - { - _curNode.value.CopyTo(_nsIncReadOffset, buffer, index, copyCount); - } - _nsIncReadOffset += copyCount; - return Task.FromResult(copyCount); - } - // Otherwise fall back to the case State.Interactive. - // No need to clean ns attributes or pop scope because the reader when ReadValueChunk is called - // - on Element errors - // - on EndElement errors - // - on Attribute does not move - // and that's all where State.ClearNsAttributes or State.PopnamespaceScope can be set - goto case State.Interactive; - - case State.Interactive: - return reader.ReadValueChunkAsync(buffer, index, count); - - case State.ReadElementContentAsBase64: - case State.ReadElementContentAsBinHex: - case State.ReadContentAsBase64: - case State.ReadContentAsBinHex: - throw new InvalidOperationException(ResXml.Xml_MixingReadValueChunkWithBinary); - - default: - Debug.Assert(false); - return Task.FromResult(0); - } - } - - private async Task InitReadElementContentAsBinaryAsync(State binaryState) - { - if (NodeType != XmlNodeType.Element) - { - throw reader.CreateReadElementContentAsException("ReadElementContentAsBase64"); - } - - bool isEmpty = IsEmptyElement; - - // move to content or off the empty element - if (!await ReadAsync().ConfigureAwait(false) || isEmpty) - { - return false; - } - // special-case child element and end element - switch (NodeType) - { - case XmlNodeType.Element: - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - case XmlNodeType.EndElement: - // pop scope & move off end element - ProcessNamespaces(); - await ReadAsync().ConfigureAwait(false); - return false; - } - - Debug.Assert(_state == State.Interactive); - _state = binaryState; - return true; - } - - private async Task FinishReadElementContentAsBinaryAsync() - { - Debug.Assert(_state == State.ReadElementContentAsBase64 || _state == State.ReadElementContentAsBinHex); - - byte[] bytes = new byte[256]; - if (_state == State.ReadElementContentAsBase64) - { - while (await reader.ReadContentAsBase64Async(bytes, 0, 256).ConfigureAwait(false) > 0) ; - } - else - { - while (await reader.ReadContentAsBinHexAsync(bytes, 0, 256).ConfigureAwait(false) > 0) ; - } - - if (NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, reader.NodeType.ToString(), reader as IXmlLineInfo); - } - - // pop namespace scope - _state = State.Interactive; - ProcessNamespaces(); - - // check eof - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - // move off end element - return await ReadAsync().ConfigureAwait(false); - } - - private async Task FinishReadContentAsBinaryAsync() - { - Debug.Assert(_state == State.ReadContentAsBase64 || _state == State.ReadContentAsBinHex); - - byte[] bytes = new byte[256]; - if (_state == State.ReadContentAsBase64) - { - while (await reader.ReadContentAsBase64Async(bytes, 0, 256).ConfigureAwait(false) > 0) ; - } - else - { - while (await reader.ReadContentAsBinHexAsync(bytes, 0, 256).ConfigureAwait(false) > 0) ; - } - - _state = State.Interactive; - ProcessNamespaces(); - - // check eof - if (reader.Depth == _initialDepth) - { - _state = State.EndOfFile; - SetEmptyNode(); - return false; - } - return true; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextEncoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextEncoder.cs deleted file mode 100644 index c1c3412d73a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextEncoder.cs +++ /dev/null @@ -1,590 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - // XmlTextEncoder - // - // This class does special handling of text content for XML. For example - // it will replace special characters with entities whenever necessary. - internal class XmlTextEncoder - { - // - // Fields - // - // output text writer - private TextWriter _textWriter; - - // true when writing out the content of attribute value - private bool _inAttribute; - - // quote char of the attribute (when inAttribute) - private char _quoteChar; - - // caching of attribute value - private StringBuilder _attrValue; - private bool _cacheAttrValue; - - // XmlCharType - private XmlCharType _xmlCharType; - - // - // Constructor - // - internal XmlTextEncoder(TextWriter textWriter) - { - _textWriter = textWriter; - _quoteChar = '"'; - _xmlCharType = XmlCharType.Instance; - } - - // - // Internal methods and properties - // - internal char QuoteChar - { - set - { - _quoteChar = value; - } - } - - internal void StartAttribute(bool cacheAttrValue) - { - _inAttribute = true; - _cacheAttrValue = cacheAttrValue; - if (cacheAttrValue) - { - if (_attrValue == null) - { - _attrValue = new StringBuilder(); - } - else - { - _attrValue.Length = 0; - } - } - } - - internal void EndAttribute() - { - if (_cacheAttrValue) - { - _attrValue.Length = 0; - } - _inAttribute = false; - _cacheAttrValue = false; - } - - internal string AttributeValue - { - get - { - if (_cacheAttrValue) - { - return _attrValue.ToString(); - } - else - { - return String.Empty; - } - } - } - - internal void WriteSurrogateChar(char lowChar, char highChar) - { - if (!XmlCharType.IsLowSurrogate(lowChar) || - !XmlCharType.IsHighSurrogate(highChar)) - { - throw XmlConvert.CreateInvalidSurrogatePairException(lowChar, highChar); - } - - _textWriter.Write(highChar); - _textWriter.Write(lowChar); - } - -#if FEATURE_NETCORE - [System.Security.SecurityCritical] -#endif - internal void Write(char[] array, int offset, int count) - { - if (null == array) - { - throw new ArgumentNullException("array"); - } - - if (0 > offset) - { - throw new ArgumentOutOfRangeException("offset"); - } - - if (0 > count) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (count > array.Length - offset) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (_cacheAttrValue) - { - _attrValue.Append(array, offset, count); - } - - int endPos = offset + count; - int i = offset; - char ch = (char)0; - for (; ; ) - { - int startPos = i; - unsafe - { - while (i < endPos && (_xmlCharType.charProperties[ch = array[i]] & XmlCharType.fAttrValue) != 0) - { // ( xmlCharType.IsAttributeValueChar( ( ch = array[i] ) ) ) ) { - i++; - } - } - - if (startPos < i) - { - _textWriter.Write(array, startPos, i - startPos); - } - if (i == endPos) - { - break; - } - - switch (ch) - { - case (char)0x9: - _textWriter.Write(ch); - break; - case (char)0xA: - case (char)0xD: - if (_inAttribute) - { - WriteCharEntityImpl(ch); - } - else - { - _textWriter.Write(ch); - } - break; - - case '<': - WriteEntityRefImpl("lt"); - break; - case '>': - WriteEntityRefImpl("gt"); - break; - case '&': - WriteEntityRefImpl("amp"); - break; - case '\'': - if (_inAttribute && _quoteChar == ch) - { - WriteEntityRefImpl("apos"); - } - else - { - _textWriter.Write('\''); - } - break; - case '"': - if (_inAttribute && _quoteChar == ch) - { - WriteEntityRefImpl("quot"); - } - else - { - _textWriter.Write('"'); - } - break; - default: - if (XmlCharType.IsHighSurrogate(ch)) - { - if (i + 1 < endPos) - { - WriteSurrogateChar(array[++i], ch); - } - else - { - throw new ArgumentException(ResXml.Xml_SurrogatePairSplit); - } - } - else if (XmlCharType.IsLowSurrogate(ch)) - { - throw XmlConvert.CreateInvalidHighSurrogateCharException(ch); - } - else - { - Debug.Assert((ch < 0x20 && !_xmlCharType.IsWhiteSpace(ch)) || (ch > 0xFFFD)); - WriteCharEntityImpl(ch); - } - break; - } - i++; - } - } - - internal void WriteSurrogateCharEntity(char lowChar, char highChar) - { - if (!XmlCharType.IsLowSurrogate(lowChar) || - !XmlCharType.IsHighSurrogate(highChar)) - { - throw XmlConvert.CreateInvalidSurrogatePairException(lowChar, highChar); - } - int surrogateChar = XmlCharType.CombineSurrogateChar(lowChar, highChar); - - if (_cacheAttrValue) - { - _attrValue.Append(highChar); - _attrValue.Append(lowChar); - } - - _textWriter.Write("&#x"); - _textWriter.Write(surrogateChar.ToString("X", NumberFormatInfo.InvariantInfo)); - _textWriter.Write(';'); - } - -#if FEATURE_NETCORE - [System.Security.SecurityCritical] -#endif - internal void Write(string text) - { - if (text == null) - { - return; - } - - if (_cacheAttrValue) - { - _attrValue.Append(text); - } - - // scan through the string to see if there are any characters to be escaped - int len = text.Length; - int i = 0; - int startPos = 0; - char ch = (char)0; - for (; ; ) - { - unsafe - { - while (i < len && (_xmlCharType.charProperties[ch = text[i]] & XmlCharType.fAttrValue) != 0) - { // ( xmlCharType.IsAttributeValueChar( ( ch = text[i] ) ) ) ) { - i++; - } - } - if (i == len) - { - // reached the end of the string -> write it whole out - _textWriter.Write(text); - return; - } - if (_inAttribute) - { - if (ch == 0x9) - { - i++; - continue; - } - } - else - { - if (ch == 0x9 || ch == 0xA || ch == 0xD || ch == '"' || ch == '\'') - { - i++; - continue; - } - } - // some character that needs to be escaped is found: - break; - } - - char[] helperBuffer = new char[256]; - for (; ; ) - { - if (startPos < i) - { - WriteStringFragment(text, startPos, i - startPos, helperBuffer); - } - if (i == len) - { - break; - } - - switch (ch) - { - case (char)0x9: - _textWriter.Write(ch); - break; - case (char)0xA: - case (char)0xD: - if (_inAttribute) - { - WriteCharEntityImpl(ch); - } - else - { - _textWriter.Write(ch); - } - break; - case '<': - WriteEntityRefImpl("lt"); - break; - case '>': - WriteEntityRefImpl("gt"); - break; - case '&': - WriteEntityRefImpl("amp"); - break; - case '\'': - if (_inAttribute && _quoteChar == ch) - { - WriteEntityRefImpl("apos"); - } - else - { - _textWriter.Write('\''); - } - break; - case '"': - if (_inAttribute && _quoteChar == ch) - { - WriteEntityRefImpl("quot"); - } - else - { - _textWriter.Write('"'); - } - break; - default: - if (XmlCharType.IsHighSurrogate(ch)) - { - if (i + 1 < len) - { - WriteSurrogateChar(text[++i], ch); - } - else - { - throw XmlConvert.CreateInvalidSurrogatePairException(text[i], ch); - } - } - else if (XmlCharType.IsLowSurrogate(ch)) - { - throw XmlConvert.CreateInvalidHighSurrogateCharException(ch); - } - else - { - Debug.Assert((ch < 0x20 && !_xmlCharType.IsWhiteSpace(ch)) || (ch > 0xFFFD)); - WriteCharEntityImpl(ch); - } - break; - } - i++; - startPos = i; - unsafe - { - while (i < len && (_xmlCharType.charProperties[ch = text[i]] & XmlCharType.fAttrValue) != 0) - { // ( xmlCharType.IsAttributeValueChar( ( text[i] ) ) ) ) { - i++; - } - } - } - } - -#if FEATURE_NETCORE - [System.Security.SecurityCritical] -#endif - internal void WriteRawWithSurrogateChecking(string text) - { - if (text == null) - { - return; - } - if (_cacheAttrValue) - { - _attrValue.Append(text); - } - - int len = text.Length; - int i = 0; - char ch = (char)0; - - for (; ; ) - { - unsafe - { - while (i < len && - ((_xmlCharType.charProperties[ch = text[i]] & XmlCharType.fCharData) != 0 // ( xmlCharType.IsCharData( ( ch = text[i] ) ) - || ch < 0x20)) - { - i++; - } - } - if (i == len) - { - break; - } - if (XmlCharType.IsHighSurrogate(ch)) - { - if (i + 1 < len) - { - char lowChar = text[i + 1]; - if (XmlCharType.IsLowSurrogate(lowChar)) - { - i += 2; - continue; - } - else - { - throw XmlConvert.CreateInvalidSurrogatePairException(lowChar, ch); - } - } - throw new ArgumentException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - else if (XmlCharType.IsLowSurrogate(ch)) - { - throw XmlConvert.CreateInvalidHighSurrogateCharException(ch); - } - else - { - i++; - } - } - - _textWriter.Write(text); - return; - } - - internal void WriteRaw(string value) - { - if (_cacheAttrValue) - { - _attrValue.Append(value); - } - _textWriter.Write(value); - } - - internal void WriteRaw(char[] array, int offset, int count) - { - if (null == array) - { - throw new ArgumentNullException("array"); - } - - if (0 > count) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (0 > offset) - { - throw new ArgumentOutOfRangeException("offset"); - } - - if (count > array.Length - offset) - { - throw new ArgumentOutOfRangeException("count"); - } - - if (_cacheAttrValue) - { - _attrValue.Append(array, offset, count); - } - _textWriter.Write(array, offset, count); - } - - - - internal void WriteCharEntity(char ch) - { - if (XmlCharType.IsSurrogate(ch)) - { - throw new ArgumentException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - - string strVal = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); - if (_cacheAttrValue) - { - _attrValue.Append("&#x"); - _attrValue.Append(strVal); - _attrValue.Append(';'); - } - WriteCharEntityImpl(strVal); - } - - internal void WriteEntityRef(string name) - { - if (_cacheAttrValue) - { - _attrValue.Append('&'); - _attrValue.Append(name); - _attrValue.Append(';'); - } - WriteEntityRefImpl(name); - } - - internal void Flush() - { - // TODO? - } - - // - // Private implementation methods - // - // This is a helper method to woraround the fact that TextWriter does not have a Write method - // for fragment of a string such as Write( string, offset, count). - // The string fragment will be written out by copying into a small helper buffer and then - // calling textWriter to write out the buffer. - private void WriteStringFragment(string str, int offset, int count, char[] helperBuffer) - { - int bufferSize = helperBuffer.Length; - while (count > 0) - { - int copyCount = count; - if (copyCount > bufferSize) - { - copyCount = bufferSize; - } - - str.CopyTo(offset, helperBuffer, 0, copyCount); - _textWriter.Write(helperBuffer, 0, copyCount); - offset += copyCount; - count -= copyCount; - } - } - - private void WriteCharEntityImpl(char ch) - { - WriteCharEntityImpl(((int)ch).ToString("X", NumberFormatInfo.InvariantInfo)); - } - - private void WriteCharEntityImpl(string strVal) - { - _textWriter.Write("&#x"); - _textWriter.Write(strVal); - _textWriter.Write(';'); - } - - private void WriteEntityRefImpl(string name) - { - _textWriter.Write('&'); - _textWriter.Write(name); - _textWriter.Write(';'); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReader.cs deleted file mode 100644 index b6033af7e25..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReader.cs +++ /dev/null @@ -1,475 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using System.Collections; -// using System.Security.Policy; -using System.Collections.Generic; -// using System.Security.Permissions; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - // [PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )] - public class XmlTextReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver - { - // - // Member fields - // - private XmlTextReaderImpl _impl; - // - // - // Constructors - // - protected XmlTextReader() - { - _impl = new XmlTextReaderImpl(); - _impl.OuterReader = this; - } - - protected XmlTextReader(XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(nt); - _impl.OuterReader = this; - } - - public XmlTextReader(Stream input) - { - _impl = new XmlTextReaderImpl(input); - _impl.OuterReader = this; - } - - public XmlTextReader(string url, Stream input) - { - _impl = new XmlTextReaderImpl(url, input); - _impl.OuterReader = this; - } - - public XmlTextReader(Stream input, XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(input, nt); - _impl.OuterReader = this; - } - - public XmlTextReader(string url, Stream input, XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(url, input, nt); - _impl.OuterReader = this; - } - - public XmlTextReader(TextReader input) - { - _impl = new XmlTextReaderImpl(input); - _impl.OuterReader = this; - } - - public XmlTextReader(string url, TextReader input) - { - _impl = new XmlTextReaderImpl(url, input); - _impl.OuterReader = this; - } - - public XmlTextReader(TextReader input, XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(input, nt); - _impl.OuterReader = this; - } - - public XmlTextReader(string url, TextReader input, XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(url, input, nt); - _impl.OuterReader = this; - } - - public XmlTextReader(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context) - { - _impl = new XmlTextReaderImpl(xmlFragment, fragType, context); - _impl.OuterReader = this; - } - - public XmlTextReader(string xmlFragment, XmlNodeType fragType, XmlParserContext context) - { - _impl = new XmlTextReaderImpl(xmlFragment, fragType, context); - _impl.OuterReader = this; - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlTextReader(string url) - { - _impl = new XmlTextReaderImpl(url, new NameTable()); - _impl.OuterReader = this; - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlTextReader(String url, XmlNameTable nt) - { - _impl = new XmlTextReaderImpl(url, nt); - _impl.OuterReader = this; - } - // - // XmlReader members - // - public override XmlNodeType NodeType - { - get { return _impl.NodeType; } - } - - public override string Name - { - get { return _impl.Name; } - } - - public override string LocalName - { - get { return _impl.LocalName; } - } - - public override string NamespaceURI - { - get { return _impl.NamespaceURI; } - } - - public override string Prefix - { - get { return _impl.Prefix; } - } - - public override bool HasValue - { - get { return _impl.HasValue; } - } - - public override string Value - { - get { return _impl.Value; } - } - - public override int Depth - { - get { return _impl.Depth; } - } - - public override string BaseURI - { - get { return _impl.BaseURI; } - } - - public override bool IsEmptyElement - { - get { return _impl.IsEmptyElement; } - } - - public override bool IsDefault - { - get { return _impl.IsDefault; } - } - - public override char QuoteChar - { - get { return _impl.QuoteChar; } - } - - public override XmlSpace XmlSpace - { - get { return _impl.XmlSpace; } - } - - public override string XmlLang - { - get { return _impl.XmlLang; } - } - - // XmlTextReader does not override SchemaInfo, ValueType and ReadTypeValue - - public override int AttributeCount { get { return _impl.AttributeCount; } } - - public override string GetAttribute(string name) - { - return _impl.GetAttribute(name); - } - - public override string GetAttribute(string localName, string namespaceURI) - { - return _impl.GetAttribute(localName, namespaceURI); - } - - public override string GetAttribute(int i) - { - return _impl.GetAttribute(i); - } - - public override bool MoveToAttribute(string name) - { - return _impl.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string localName, string namespaceURI) - { - return _impl.MoveToAttribute(localName, namespaceURI); - } - - public override void MoveToAttribute(int i) - { - _impl.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - return _impl.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - return _impl.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - return _impl.MoveToElement(); - } - - public override bool ReadAttributeValue() - { - return _impl.ReadAttributeValue(); - } - - public override bool Read() - { - return _impl.Read(); - } - - public override bool EOF - { - get { return _impl.EOF; } - } - - public override void Close() - { - _impl.Close(); - } - - public override ReadState ReadState - { - get { return _impl.ReadState; } - } - - public override void Skip() - { - _impl.Skip(); - } - - public override XmlNameTable NameTable - { - get { return _impl.NameTable; } - } - - public override String LookupNamespace(String prefix) - { - string ns = _impl.LookupNamespace(prefix); - if (ns != null && ns.Length == 0) - { - ns = null; - } - return ns; - } - - public override bool CanResolveEntity - { - get { return true; } - } - - public override void ResolveEntity() - { - _impl.ResolveEntity(); - } - - // Binary content access methods - public override bool CanReadBinaryContent - { - get { return true; } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - return _impl.ReadContentAsBase64(buffer, index, count); - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - return _impl.ReadElementContentAsBase64(buffer, index, count); - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - return _impl.ReadContentAsBinHex(buffer, index, count); - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - return _impl.ReadElementContentAsBinHex(buffer, index, count); - } - - // Text streaming methods - - // XmlTextReader does do support streaming of Value (there are backwards compatibility issues when enabled) - public override bool CanReadValueChunk - { - get { return false; } - } - - // Overriden helper methods - - public override string ReadString() - { - _impl.MoveOffEntityReference(); - return base.ReadString(); - } - - // - // IXmlLineInfo members - // - public bool HasLineInfo() { return true; } - - public int LineNumber { get { return _impl.LineNumber; } } - - public int LinePosition { get { return _impl.LinePosition; } } - - // - // IXmlNamespaceResolver members - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _impl.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _impl.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _impl.LookupPrefix(namespaceName); - } - - // This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey. -#pragma warning disable 3002 - // FXCOP: ExplicitMethodImplementationsInUnsealedClassesHaveVisibleAlternates - // public versions of IXmlNamespaceResolver methods, so that XmlTextReader subclasses can access them - public IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - return _impl.GetNamespacesInScope(scope); - } -#pragma warning restore 3002 - - // - // XmlTextReader - // - public bool Namespaces - { - get { return _impl.Namespaces; } - set { _impl.Namespaces = value; } - } - - public bool Normalization - { - get { return _impl.Normalization; } - set { _impl.Normalization = value; } - } - - public Encoding Encoding - { - get { return _impl.Encoding; } - } - - public WhitespaceHandling WhitespaceHandling - { - get { return _impl.WhitespaceHandling; } - set { _impl.WhitespaceHandling = value; } - } - - [Obsolete("Use DtdProcessing property instead.")] - public bool ProhibitDtd - { - get { return _impl.DtdProcessing == DtdProcessing.Prohibit; } - set { _impl.DtdProcessing = value ? DtdProcessing.Prohibit : DtdProcessing.Parse; } - } - - public DtdProcessing DtdProcessing - { - get { return _impl.DtdProcessing; } - set { _impl.DtdProcessing = value; } - } - - public EntityHandling EntityHandling - { - get { return _impl.EntityHandling; } - set { _impl.EntityHandling = value; } - } - - public XmlResolver XmlResolver - { - set { _impl.XmlResolver = value; } - } - - public void ResetState() - { - _impl.ResetState(); - } - - public TextReader GetRemainder() - { - return _impl.GetRemainder(); - } - - public int ReadChars(char[] buffer, int index, int count) - { - return _impl.ReadChars(buffer, index, count); - } - - public int ReadBase64(byte[] array, int offset, int len) - { - return _impl.ReadBase64(array, offset, len); - } - - public int ReadBinHex(byte[] array, int offset, int len) - { - return _impl.ReadBinHex(array, offset, len); - } - // - // Internal helper methods - // - internal XmlTextReaderImpl Impl - { - get { return _impl; } - } - - internal override XmlNamespaceManager NamespaceManager - { - get { return _impl.NamespaceManager; } - } - - // NOTE: System.Data.SqlXml.XmlDataSourceResolver accesses this property via reflection - internal bool XmlValidatingReaderCompatibilityMode - { - set { _impl.XmlValidatingReaderCompatibilityMode = value; } - } - - internal override IDtdInfo DtdInfo - { - get { return _impl.DtdInfo; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImpl.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImpl.cs deleted file mode 100644 index fc37d42dfc9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImpl.cs +++ /dev/null @@ -1,9871 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using System.Security; -using System.Threading; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Runtime.Versioning; - - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlTextReaderImpl : XmlReader, IXmlLineInfo, IXmlNamespaceResolver - { - // - // Private helper types - // - // ParsingFunction = what should the reader do when the next Read() is called - private enum ParsingFunction - { - ElementContent = 0, - NoData, - OpenUrl, - SwitchToInteractive, - SwitchToInteractiveXmlDecl, - DocumentContent, - MoveToElementContent, - PopElementContext, - PopEmptyElementContext, - ResetAttributesRootLevel, - Error, - Eof, - ReaderClosed, - EntityReference, - InIncrementalRead, - FragmentAttribute, - ReportEndEntity, - AfterResolveEntityInContent, - AfterResolveEmptyEntityInContent, - XmlDeclarationFragment, - GoToEof, - PartialTextValue, - - // these two states must be last; see InAttributeValueIterator property - InReadAttributeValue, - InReadValueChunk, - InReadContentAsBinary, - InReadElementContentAsBinary, - } - - private enum ParsingMode - { - Full, - SkipNode, - SkipContent, - } - - private enum EntityType - { - CharacterDec, - CharacterHex, - CharacterNamed, - Expanded, - Skipped, - FakeExpanded, - Unexpanded, - ExpandedInAttribute, - } - - private enum EntityExpandType - { - All, - OnlyGeneral, - OnlyCharacter, - } - - private enum IncrementalReadState - { - // Following values are used in ReadText, ReadBase64 and ReadBinHex (V1 streaming methods) - Text, - StartTag, - PI, - CDATA, - Comment, - Attributes, - AttributeValue, - ReadData, - EndElement, - End, - - // Following values are used in ReadTextChunk, ReadContentAsBase64 and ReadBinHexChunk (V2 streaming methods) - ReadValueChunk_OnCachedValue, - ReadValueChunk_OnPartialValue, - - ReadContentAsBinary_OnCachedValue, - ReadContentAsBinary_OnPartialValue, - ReadContentAsBinary_End, - } - - // - // Fields - // -#if ASYNC - private readonly bool useAsync; -#endif - - #region Later Init Fileds - - //later init means in the construction stage, do not opend filestream and do not read any data from Stream/TextReader - //the purpose is to make the Create of XmlReader do not block on IO. - private class LaterInitParam - { - public bool useAsync = false; - - public Stream inputStream; - public byte[] inputBytes; - public int inputByteCount; - public Uri inputbaseUri; - public string inputUriStr; - public XmlResolver inputUriResolver; - public XmlParserContext inputContext; - public TextReader inputTextReader; - - public InitInputType initType = InitInputType.Invalid; - } - - private LaterInitParam _laterInitParam = null; - - private enum InitInputType - { - UriString, - Stream, - TextReader, - Invalid - } - - #endregion - - // XmlCharType instance - private XmlCharType _xmlCharType = XmlCharType.Instance; - - // current parsing state (aka. scanner data) - private ParsingState _ps; - - // parsing function = what to do in the next Read() (3-items-long stack, usually used just 2 level) - private ParsingFunction _parsingFunction; - private ParsingFunction _nextParsingFunction; - private ParsingFunction _nextNextParsingFunction; - - // stack of nodes - private NodeData[] _nodes; - - // current node - private NodeData _curNode; - - // current index - private int _index = 0; - - // attributes info - private int _curAttrIndex = -1; - private int _attrCount; - private int _attrHashtable; - private int _attrDuplWalkCount; - private bool _attrNeedNamespaceLookup; - private bool _fullAttrCleanup; - private NodeData[] _attrDuplSortingArray; - - // name table - private XmlNameTable _nameTable; - private bool _nameTableFromSettings; - - // resolver - private XmlResolver _xmlResolver; - - // this is only for constructors that takes url - private string _url = string.Empty; - //CompressedStack compressedStack; - - // settings - private bool _normalize; - private bool _supportNamespaces = true; - private WhitespaceHandling _whitespaceHandling; - private DtdProcessing _dtdProcessing = DtdProcessing.Parse; - private EntityHandling _entityHandling; - private bool _ignorePIs; - private bool _ignoreComments; - private bool _checkCharacters; - private int _lineNumberOffset; - private int _linePositionOffset; - private bool _closeInput; - private long _maxCharactersInDocument; - private long _maxCharactersFromEntities; - - // this flag enables XmlTextReader backwards compatibility; - // when false, the reader has been created via XmlReader.Create - private bool _v1Compat; - - // namespace handling - private XmlNamespaceManager _namespaceManager; - private string _lastPrefix = string.Empty; - - // xml context (xml:space, xml:lang, default namespace) - private XmlContext _xmlContext; - - // stack of parsing states (=stack of entities) - private ParsingState[] _parsingStatesStack; - private int _parsingStatesStackTop = -1; - - // current node base uri and encoding - private string _reportedBaseUri; - private Encoding _reportedEncoding; - - // DTD - private IDtdInfo _dtdInfo; - - // fragment parsing - private XmlNodeType _fragmentType = XmlNodeType.Document; - private XmlParserContext _fragmentParserContext; - private bool _fragment; - - // incremental read - private IncrementalReadDecoder _incReadDecoder; - private IncrementalReadState _incReadState; - private LineInfo _incReadLineInfo; - private BinHexDecoder _binHexDecoder; - private Base64Decoder _base64Decoder; - private int _incReadDepth; - private int _incReadLeftStartPos; - private int _incReadLeftEndPos; - private IncrementalReadCharsDecoder _readCharsDecoder; - - // ReadAttributeValue helpers - private int _attributeValueBaseEntityId; - private bool _emptyEntityInAttributeResolved; - - // Validation helpers - private IValidationEventHandling _validationEventHandling; - private OnDefaultAttributeUseDelegate _onDefaultAttributeUse; - - private bool _validatingReaderCompatFlag; - - // misc - private bool _addDefaultAttributesAndNormalize; - private BufferBuilder _stringBuilder; - private bool _rootElementParsed; - private bool _standalone; - private int _nextEntityId = 1; - private ParsingMode _parsingMode; - private ReadState _readState = ReadState.Initial; - private IDtdEntityInfo _lastEntity; - private bool _afterResetState; - private int _documentStartBytePos; - private int _readValueOffset; - - // Counters for security settings - private long _charactersInDocument; - private long _charactersFromEntities; - - // All entities that are currently being processed - private Dictionary _currentEntities; - - // DOM helpers - private bool _disableUndeclaredEntityCheck; - - // Outer XmlReader exposed to the user - either XmlTextReader or XmlTextReaderImpl (when created via XmlReader.Create). - // Virtual methods called from within XmlTextReaderImpl must be called on the outer reader so in case the user overrides - // some of the XmlTextReader methods we will call the overriden version. - private XmlReader _outerReader; - - //indicate if the XmlResolver is explicit set - private bool _xmlResolverIsSet; - - // - // Atomized string constants - // - private string _xml; - private string _xmlNs; - - // - // Constants - // - private const int MaxBytesToMove = 128; - private const int ApproxXmlDeclLength = 80; - private const int NodesInitialSize = 8; - private const int InitialAttributesCount = 4; - private const int InitialParsingStateStackSize = 2; - private const int InitialParsingStatesDepth = 2; - private const int DtdChidrenInitialSize = 2; - private const int MaxByteSequenceLen = 6; // max bytes per character - private const int MaxAttrDuplWalkCount = 250; - private const int MinWhitespaceLookahedCount = 4096; - - private const string XmlDeclarationBegining = "")); - InitFragmentReader(XmlNodeType.XmlDeclaration, context, true); - } - - // Initializes a new instance of the XmlTextReaderImpl class with the specified url and XmlNameTable. - // This constructor is used when creating XmlTextReaderImpl for V1 XmlTextReader - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlTextReaderImpl(string url) : this(url, new NameTable()) - { - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlTextReaderImpl(string url, XmlNameTable nt) : this(nt) - { - if (url == null) - { - throw new ArgumentNullException("url"); - } - if (url.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyUrl, "url"); - } - _namespaceManager = new XmlNamespaceManager(nt); - - //compressedStack = CompressedStack.Capture(); - - _url = url; - - // It is important to have valid resolver here to resolve the Xml url file path. - // it is safe as this resolver will not be used to resolve DTD url's - _ps.baseUri = GetTempResolver().ResolveUri(null, url); - _ps.baseUriStr = _ps.baseUri.ToString(); - _reportedBaseUri = _ps.baseUriStr; - - _parsingFunction = ParsingFunction.OpenUrl; - } - - - // Initializes a new instance of the XmlTextReaderImpl class with the specified arguments. - // This constructor is used when creating XmlTextReaderImpl via XmlReader.Create - internal XmlTextReaderImpl(string uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver) - : this(settings.GetXmlResolver(), settings, context) - { - Uri baseUri = uriResolver.ResolveUri(null, uriStr); - string baseUriStr = baseUri.ToString(); - - // get BaseUri from XmlParserContext - if (context != null) - { - if (context.BaseURI != null && context.BaseURI.Length > 0 && - !UriEqual(baseUri, baseUriStr, context.BaseURI, settings.GetXmlResolver())) - { - if (baseUriStr.Length > 0) - { - Throw(ResXml.Xml_DoubleBaseUri); - } - Debug.Assert(baseUri == null); - baseUriStr = context.BaseURI; - } - } - - _reportedBaseUri = baseUriStr; - _closeInput = true; - _laterInitParam = new LaterInitParam(); - _laterInitParam.inputUriStr = uriStr; - _laterInitParam.inputbaseUri = baseUri; - _laterInitParam.inputContext = context; - _laterInitParam.inputUriResolver = uriResolver; - _laterInitParam.initType = InitInputType.UriString; -#if !ASYNC - FinishInitUriString(); -#else - if (!settings.Async) { - //if not set Async flag, finish the init in create stage. - FinishInitUriString(); - } - else { - laterInitParam.useAsync = true; - } -#endif - } - - private void FinishInitUriString() - { - Stream stream = null; - -#if ASYNC - if (laterInitParam.useAsync) { - //this will be hit when user create a XmlReader by setting Async, but the first call is Read() instead of ReadAsync(), - //then we still should create an async stream here. And wait for the method finish. - System.Threading.Tasks.Task t = laterInitParam.inputUriResolver.GetEntityAsync(laterInitParam.inputbaseUri, string.Empty, typeof(Stream)); - t.Wait(); - stream = (Stream)t.Result; - } - else -#endif - { - stream = (Stream)_laterInitParam.inputUriResolver.GetEntity(_laterInitParam.inputbaseUri, string.Empty, typeof(Stream)); - } - - if (stream == null) - { - throw new XmlException(ResXml.Xml_CannotResolveUrl, _laterInitParam.inputUriStr); - } - - Encoding enc = null; - // get Encoding from XmlParserContext - if (_laterInitParam.inputContext != null) - { - enc = _laterInitParam.inputContext.Encoding; - } - - try - { - // init ParsingState - InitStreamInput(_laterInitParam.inputbaseUri, _reportedBaseUri, stream, null, 0, enc); - - _reportedEncoding = _ps.encoding; - - // parse DTD - if (_laterInitParam.inputContext != null && _laterInitParam.inputContext.HasDtdInfo) - { - ProcessDtdFromParserContext(_laterInitParam.inputContext); - } - } - catch - { - stream.Close(); - throw; - } - _laterInitParam = null; - } - - // Initializes a new instance of the XmlTextReaderImpl class with the specified arguments. - // This constructor is used when creating XmlTextReaderImpl via XmlReader.Create - internal XmlTextReaderImpl(Stream stream, byte[] bytes, int byteCount, XmlReaderSettings settings, Uri baseUri, string baseUriStr, - XmlParserContext context, bool closeInput) - : this(settings.GetXmlResolver(), settings, context) - { - // get BaseUri from XmlParserContext - if (context != null) - { - if (context.BaseURI != null && context.BaseURI.Length > 0 && - !UriEqual(baseUri, baseUriStr, context.BaseURI, settings.GetXmlResolver())) - { - if (baseUriStr.Length > 0) - { - Throw(ResXml.Xml_DoubleBaseUri); - } - Debug.Assert(baseUri == null); - baseUriStr = context.BaseURI; - } - } - - _reportedBaseUri = baseUriStr; - _closeInput = closeInput; - - _laterInitParam = new LaterInitParam(); - _laterInitParam.inputStream = stream; - _laterInitParam.inputBytes = bytes; - _laterInitParam.inputByteCount = byteCount; - _laterInitParam.inputbaseUri = baseUri; - _laterInitParam.inputContext = context; - - _laterInitParam.initType = InitInputType.Stream; -#if !ASYNC - FinishInitStream(); -#else - if (!settings.Async) { - //if not set Async flag, finish the init in create stage. - FinishInitStream(); - } - else { - laterInitParam.useAsync = true; - } -#endif - } - - private void FinishInitStream() - { - Encoding enc = null; - - // get Encoding from XmlParserContext - if (_laterInitParam.inputContext != null) - { - enc = _laterInitParam.inputContext.Encoding; - } - - // init ParsingState - InitStreamInput(_laterInitParam.inputbaseUri, _reportedBaseUri, _laterInitParam.inputStream, _laterInitParam.inputBytes, _laterInitParam.inputByteCount, enc); - - _reportedEncoding = _ps.encoding; - - // parse DTD - if (_laterInitParam.inputContext != null && _laterInitParam.inputContext.HasDtdInfo) - { - ProcessDtdFromParserContext(_laterInitParam.inputContext); - } - _laterInitParam = null; - } - - // Initializes a new instance of the XmlTextReaderImpl class with the specified arguments. - // This constructor is used when creating XmlTextReaderImpl via XmlReader.Create - internal XmlTextReaderImpl(TextReader input, XmlReaderSettings settings, string baseUriStr, XmlParserContext context) - : this(settings.GetXmlResolver(), settings, context) - { - // get BaseUri from XmlParserContext - if (context != null) - { - Debug.Assert(baseUriStr == string.Empty, "BaseURI can come either from XmlParserContext or from the constructor argument, not from both"); - if (context.BaseURI != null) - { - baseUriStr = context.BaseURI; - } - } - - _reportedBaseUri = baseUriStr; - _closeInput = settings.CloseInput; - _laterInitParam = new LaterInitParam(); - _laterInitParam.inputTextReader = input; - _laterInitParam.inputContext = context; - _laterInitParam.initType = InitInputType.TextReader; -#if !ASYNC - FinishInitTextReader(); -#else - if (!settings.Async) { - //if not set Async flag, finish the init in create stage. - FinishInitTextReader(); - } - else { - laterInitParam.useAsync = true; - } -#endif - } - - private void FinishInitTextReader() - { - // init ParsingState - InitTextReaderInput(_reportedBaseUri, _laterInitParam.inputTextReader); - - _reportedEncoding = _ps.encoding; - - // parse DTD - if (_laterInitParam.inputContext != null && _laterInitParam.inputContext.HasDtdInfo) - { - ProcessDtdFromParserContext(_laterInitParam.inputContext); - } - - _laterInitParam = null; - } - - - // Initializes a new instance of the XmlTextReaderImpl class for fragment parsing. - // This constructor is used by XmlBinaryReader for nested text XML - internal XmlTextReaderImpl(string xmlFragment, XmlParserContext context, XmlReaderSettings settings) - : this(null, settings, context) - { - Debug.Assert(xmlFragment != null); - InitStringInput(string.Empty, Encoding.Unicode, xmlFragment); - _reportedBaseUri = _ps.baseUriStr; - _reportedEncoding = _ps.encoding; - } - - // - // XmlReader members - // - // Returns the current settings of the reader - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings = new XmlReaderSettings(); - - if (_nameTableFromSettings) - { - settings.NameTable = _nameTable; - } - - switch (_fragmentType) - { - case XmlNodeType.None: settings.ConformanceLevel = ConformanceLevel.Auto; break; - case XmlNodeType.Element: settings.ConformanceLevel = ConformanceLevel.Fragment; break; - case XmlNodeType.Document: settings.ConformanceLevel = ConformanceLevel.Document; break; - default: Debug.Assert(false); goto case XmlNodeType.None; - } - settings.CheckCharacters = _checkCharacters; - settings.LineNumberOffset = _lineNumberOffset; - settings.LinePositionOffset = _linePositionOffset; - settings.IgnoreWhitespace = (_whitespaceHandling == WhitespaceHandling.Significant); - settings.IgnoreProcessingInstructions = _ignorePIs; - settings.IgnoreComments = _ignoreComments; - settings.DtdProcessing = _dtdProcessing; - settings.MaxCharactersInDocument = _maxCharactersInDocument; - settings.MaxCharactersFromEntities = _maxCharactersFromEntities; - - if (!Microsoft.Xml.XmlReaderSettings.EnableLegacyXmlSettings()) - { - settings.XmlResolver = _xmlResolver; - } - settings.ReadOnly = true; - return settings; - } - } - - // Returns the type of the current node. - public override XmlNodeType NodeType - { - get - { - return _curNode.type; - } - } - - // Returns the name of the current node, including prefix. - public override string Name - { - get - { - return _curNode.GetNameWPrefix(_nameTable); - } - } - - // Returns local name of the current node (without prefix) - public override string LocalName - { - get - { - return _curNode.localName; - } - } - - // Returns namespace name of the current node. - public override string NamespaceURI - { - get - { - return _curNode.ns; - } - } - - // Returns prefix associated with the current node. - public override string Prefix - { - get - { - return _curNode.prefix; - } - } - - // Returns the text value of the current node. - public override string Value - { - get - { - if (_parsingFunction >= ParsingFunction.PartialTextValue) - { - if (_parsingFunction == ParsingFunction.PartialTextValue) - { - FinishPartialValue(); - _parsingFunction = _nextParsingFunction; - } - else - { - FinishOtherValueIterator(); - } - } - return _curNode.StringValue; - } - } - - // Returns the depth of the current node in the XML element stack - public override int Depth - { - get - { - return _curNode.depth; - } - } - - // Returns the base URI of the current node. - public override string BaseURI - { - get - { - return _reportedBaseUri; - } - } - - // Returns true if the current node is an empty element (for example, ). - public override bool IsEmptyElement - { - get - { - return _curNode.IsEmptyElement; - } - } - - // Returns true of the current node is a default attribute declared in DTD. - public override bool IsDefault - { - get - { - return _curNode.IsDefaultAttribute; - } - } - - // Returns the quote character used in the current attribute declaration - public override char QuoteChar - { - get - { - return _curNode.type == XmlNodeType.Attribute ? _curNode.quoteChar : '"'; - } - } - - // Returns the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - return _xmlContext.xmlSpace; - } - } - - // Returns the current xml:lang scope. - public override string XmlLang - { - get - { - return _xmlContext.xmlLang; - } - } - - // Returns the current read state of the reader - public override ReadState ReadState - { - get - { - return _readState; - } - } - - // Returns true if the reader reached end of the input data - public override bool EOF - { - get - { - return _parsingFunction == ParsingFunction.Eof; - } - } - - // Returns the XmlNameTable associated with this XmlReader - public override XmlNameTable NameTable - { - get - { - return _nameTable; - } - } - - // Returns true if the XmlReader knows how to resolve general entities - public override bool CanResolveEntity - { - get - { - return true; - } - } - - // Returns the number of attributes on the current node. - public override int AttributeCount - { - get - { - return _attrCount; - } - } - - // Returns value of an attribute with the specified Name - public override string GetAttribute(string name) - { - int i; - if (name.IndexOf(':') == -1) - { - i = GetIndexOfAttributeWithoutPrefix(name); - } - else - { - i = GetIndexOfAttributeWithPrefix(name); - } - return (i >= 0) ? _nodes[i].StringValue : null; - } - - // Returns value of an attribute with the specified LocalName and NamespaceURI - public override string GetAttribute(string localName, string namespaceURI) - { - namespaceURI = (namespaceURI == null) ? string.Empty : _nameTable.Get(namespaceURI); - localName = _nameTable.Get(localName); - for (int i = _index + 1; i < _index + _attrCount + 1; i++) - { - if (Ref.Equal(_nodes[i].localName, localName) && Ref.Equal(_nodes[i].ns, namespaceURI)) - { - return _nodes[i].StringValue; - } - } - return null; - } - - // Returns value of an attribute at the specified index (position) - public override string GetAttribute(int i) - { - if (i < 0 || i >= _attrCount) - { - throw new ArgumentOutOfRangeException("i"); - } - return _nodes[_index + i + 1].StringValue; - } - - // Moves to an attribute with the specified Name - public override bool MoveToAttribute(string name) - { - int i; - if (name.IndexOf(':') == -1) - { - i = GetIndexOfAttributeWithoutPrefix(name); - } - else - { - i = GetIndexOfAttributeWithPrefix(name); - } - - if (i >= 0) - { - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - _curAttrIndex = i - _index - 1; - _curNode = _nodes[i]; - return true; - } - else - { - return false; - } - } - - // Moves to an attribute with the specified LocalName and NamespceURI - public override bool MoveToAttribute(string localName, string namespaceURI) - { - namespaceURI = (namespaceURI == null) ? string.Empty : _nameTable.Get(namespaceURI); - localName = _nameTable.Get(localName); - for (int i = _index + 1; i < _index + _attrCount + 1; i++) - { - if (Ref.Equal(_nodes[i].localName, localName) && - Ref.Equal(_nodes[i].ns, namespaceURI)) - { - _curAttrIndex = i - _index - 1; - _curNode = _nodes[i]; - - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - return true; - } - } - return false; - } - - // Moves to an attribute at the specified index (position) - public override void MoveToAttribute(int i) - { - if (i < 0 || i >= _attrCount) - { - throw new ArgumentOutOfRangeException("i"); - } - - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - _curAttrIndex = i; - _curNode = _nodes[_index + 1 + _curAttrIndex]; - } - - // Moves to the first attribute of the current node - public override bool MoveToFirstAttribute() - { - if (_attrCount == 0) - { - return false; - } - - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - - _curAttrIndex = 0; - _curNode = _nodes[_index + 1]; - - return true; - } - - // Moves to the next attribute of the current node - public override bool MoveToNextAttribute() - { - if (_curAttrIndex + 1 < _attrCount) - { - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - _curNode = _nodes[_index + 1 + ++_curAttrIndex]; - return true; - } - return false; - } - - // If on attribute, moves to the element that contains the attribute node - public override bool MoveToElement() - { - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - } - else if (_curNode.type != XmlNodeType.Attribute) - { - return false; - } - _curAttrIndex = -1; - _curNode = _nodes[_index]; - - return true; - } - - - private void FinishInit() - { - switch (_laterInitParam.initType) - { - case InitInputType.UriString: - FinishInitUriString(); - break; - case InitInputType.Stream: - FinishInitStream(); - break; - case InitInputType.TextReader: - FinishInitTextReader(); - break; - default: - //should never hit here - Debug.Assert(false, "Invalid InitInputType"); - break; - } - } - - - // Reads next node from the input data - public override bool Read() - { - if (_laterInitParam != null) - { - FinishInit(); - } - - for (; ; ) - { - switch (_parsingFunction) - { - case ParsingFunction.ElementContent: - return ParseElementContent(); - case ParsingFunction.DocumentContent: - return ParseDocumentContent(); - case ParsingFunction.OpenUrl: - OpenUrl(); - Debug.Assert(_nextParsingFunction == ParsingFunction.DocumentContent); - goto case ParsingFunction.SwitchToInteractiveXmlDecl; - case ParsingFunction.SwitchToInteractive: - Debug.Assert(!_ps.appendMode); - _readState = ReadState.Interactive; - _parsingFunction = _nextParsingFunction; - continue; - case ParsingFunction.SwitchToInteractiveXmlDecl: - _readState = ReadState.Interactive; - _parsingFunction = _nextParsingFunction; - if (ParseXmlDeclaration(false)) - { - _reportedEncoding = _ps.encoding; - return true; - } - _reportedEncoding = _ps.encoding; - continue; - case ParsingFunction.ResetAttributesRootLevel: - ResetAttributes(); - _curNode = _nodes[_index]; - _parsingFunction = (_index == 0) ? ParsingFunction.DocumentContent : ParsingFunction.ElementContent; - continue; - case ParsingFunction.MoveToElementContent: - ResetAttributes(); - _index++; - _curNode = AddNode(_index, _index); - _parsingFunction = ParsingFunction.ElementContent; - continue; - case ParsingFunction.PopElementContext: - PopElementContext(); - _parsingFunction = _nextParsingFunction; - Debug.Assert(_parsingFunction == ParsingFunction.ElementContent || - _parsingFunction == ParsingFunction.DocumentContent); - continue; - case ParsingFunction.PopEmptyElementContext: - _curNode = _nodes[_index]; - Debug.Assert(_curNode.type == XmlNodeType.Element); - _curNode.IsEmptyElement = false; - ResetAttributes(); - PopElementContext(); - _parsingFunction = _nextParsingFunction; - continue; - case ParsingFunction.EntityReference: - _parsingFunction = _nextParsingFunction; - ParseEntityReference(); - return true; - case ParsingFunction.ReportEndEntity: - SetupEndEntityNodeInContent(); - _parsingFunction = _nextParsingFunction; - return true; - case ParsingFunction.AfterResolveEntityInContent: - _curNode = AddNode(_index, _index); - _reportedEncoding = _ps.encoding; - _reportedBaseUri = _ps.baseUriStr; - _parsingFunction = _nextParsingFunction; - continue; - case ParsingFunction.AfterResolveEmptyEntityInContent: - _curNode = AddNode(_index, _index); - _curNode.SetValueNode(XmlNodeType.Text, string.Empty); - _curNode.SetLineInfo(_ps.lineNo, _ps.LinePos); - _reportedEncoding = _ps.encoding; - _reportedBaseUri = _ps.baseUriStr; - _parsingFunction = _nextParsingFunction; - return true; - case ParsingFunction.InReadAttributeValue: - FinishAttributeValueIterator(); - _curNode = _nodes[_index]; - continue; - case ParsingFunction.InIncrementalRead: - FinishIncrementalRead(); - return true; - case ParsingFunction.FragmentAttribute: - return ParseFragmentAttribute(); - case ParsingFunction.XmlDeclarationFragment: - ParseXmlDeclarationFragment(); - _parsingFunction = ParsingFunction.GoToEof; - return true; - case ParsingFunction.GoToEof: - OnEof(); - return false; - case ParsingFunction.Error: - case ParsingFunction.Eof: - case ParsingFunction.ReaderClosed: - return false; - case ParsingFunction.NoData: - ThrowWithoutLineInfo(ResXml.Xml_MissingRoot); - return false; - case ParsingFunction.PartialTextValue: - SkipPartialTextValue(); - continue; - case ParsingFunction.InReadValueChunk: - FinishReadValueChunk(); - continue; - case ParsingFunction.InReadContentAsBinary: - FinishReadContentAsBinary(); - continue; - case ParsingFunction.InReadElementContentAsBinary: - FinishReadElementContentAsBinary(); - continue; - default: - Debug.Assert(false); - break; - } - } - } - - // Closes the input stream ot TextReader, changes the ReadState to Closed and sets all properties to zero/string.Empty - public override void Close() - { - Close(_closeInput); - } - - // Skips the current node. If on element, skips to the end tag of the element. - public override void Skip() - { - if (_readState != ReadState.Interactive) - return; - - if (InAttributeValueIterator) - { - FinishAttributeValueIterator(); - _curNode = _nodes[_index]; - } - else - { - switch (_parsingFunction) - { - case ParsingFunction.InReadAttributeValue: - Debug.Assert(false); - break; - case ParsingFunction.InIncrementalRead: - FinishIncrementalRead(); - break; - case ParsingFunction.PartialTextValue: - SkipPartialTextValue(); - break; - case ParsingFunction.InReadValueChunk: - FinishReadValueChunk(); - break; - case ParsingFunction.InReadContentAsBinary: - FinishReadContentAsBinary(); - break; - case ParsingFunction.InReadElementContentAsBinary: - FinishReadElementContentAsBinary(); - break; - } - } - - switch (_curNode.type) - { - // skip subtree - case XmlNodeType.Element: - if (_curNode.IsEmptyElement) - { - break; - } - int initialDepth = _index; - _parsingMode = ParsingMode.SkipContent; - // skip content - while (_outerReader.Read() && _index > initialDepth) ; - Debug.Assert(_curNode.type == XmlNodeType.EndElement); - Debug.Assert(_parsingFunction != ParsingFunction.Eof); - _parsingMode = ParsingMode.Full; - break; - case XmlNodeType.Attribute: - _outerReader.MoveToElement(); - goto case XmlNodeType.Element; - } - // move to following sibling node - _outerReader.Read(); - return; - } - - // Returns NamespaceURI associated with the specified prefix in the current namespace scope. - public override String LookupNamespace(String prefix) - { - if (!_supportNamespaces) - { - return null; - } - - return _namespaceManager.LookupNamespace(prefix); - } - - // Iterates through the current attribute value's text and entity references chunks. - public override bool ReadAttributeValue() - { - if (_parsingFunction != ParsingFunction.InReadAttributeValue) - { - if (_curNode.type != XmlNodeType.Attribute) - { - return false; - } - if (_readState != ReadState.Interactive || _curAttrIndex < 0) - { - return false; - } - if (_parsingFunction == ParsingFunction.InReadValueChunk) - { - FinishReadValueChunk(); - } - if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - FinishReadContentAsBinary(); - } - - if (_curNode.nextAttrValueChunk == null || _entityHandling == EntityHandling.ExpandEntities) - { - NodeData simpleValueNode = AddNode(_index + _attrCount + 1, _curNode.depth + 1); - simpleValueNode.SetValueNode(XmlNodeType.Text, _curNode.StringValue); - simpleValueNode.lineInfo = _curNode.lineInfo2; - simpleValueNode.depth = _curNode.depth + 1; - _curNode = simpleValueNode; - - simpleValueNode.nextAttrValueChunk = null; - } - else - { - _curNode = _curNode.nextAttrValueChunk; - - // Place the current node at nodes[index + attrCount + 1]. If the node type - // is be EntityReference and user calls ResolveEntity, the associated EndEntity - // node will be constructed from the information stored there. - - // This will initialize the (index + attrCount + 1) place in nodes array - AddNode(_index + _attrCount + 1, _index + 2); - _nodes[_index + _attrCount + 1] = _curNode; - - _fullAttrCleanup = true; - } - _nextParsingFunction = _parsingFunction; - _parsingFunction = ParsingFunction.InReadAttributeValue; - _attributeValueBaseEntityId = _ps.entityId; - return true; - } - else - { - if (_ps.entityId == _attributeValueBaseEntityId) - { - if (_curNode.nextAttrValueChunk != null) - { - _curNode = _curNode.nextAttrValueChunk; - _nodes[_index + _attrCount + 1] = _curNode; // if curNode == EntityReference node, it will be picked from here by SetupEndEntityNodeInAttribute - return true; - } - return false; - } - else - { - // expanded entity in attribute value - return ParseAttributeValueChunk(); - } - } - } - - // Resolves the current entity reference node - public override void ResolveEntity() - { - if (_curNode.type != XmlNodeType.EntityReference) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - Debug.Assert(_parsingMode == ParsingMode.Full); - - // entity in attribute value - if (_parsingFunction == ParsingFunction.InReadAttributeValue || - _parsingFunction == ParsingFunction.FragmentAttribute) - { - switch (HandleGeneralEntityReference(_curNode.localName, true, true, _curNode.LinePos)) - { - case EntityType.ExpandedInAttribute: - case EntityType.Expanded: - if (_ps.charsUsed - _ps.charPos == 0) - { // entity value == "" - _emptyEntityInAttributeResolved = true; - } - break; - case EntityType.FakeExpanded: - _emptyEntityInAttributeResolved = true; - break; - default: - Debug.Assert(false); - throw new XmlException(ResXml.Xml_InternalError, string.Empty); - } - } - // entity in element content - else - { - switch (HandleGeneralEntityReference(_curNode.localName, false, true, _curNode.LinePos)) - { - case EntityType.ExpandedInAttribute: - case EntityType.Expanded: - _nextParsingFunction = _parsingFunction; - if (_ps.charsUsed - _ps.charPos == 0 && !_ps.entity.IsExternal) - { // empty internal entity value - _parsingFunction = ParsingFunction.AfterResolveEmptyEntityInContent; - } - else - { - _parsingFunction = ParsingFunction.AfterResolveEntityInContent; - } - break; - case EntityType.FakeExpanded: - _nextParsingFunction = _parsingFunction; - _parsingFunction = ParsingFunction.AfterResolveEmptyEntityInContent; - break; - default: - Debug.Assert(false); - throw new XmlException(ResXml.Xml_InternalError, string.Empty); - } - } - _ps.entityResolvedManually = true; - _index++; - } - - internal XmlReader OuterReader - { - get - { - return _outerReader; - } - set - { - Debug.Assert(value is XmlTextReader); - _outerReader = value; - } - } - - internal void MoveOffEntityReference() - { - if (_outerReader.NodeType == XmlNodeType.EntityReference && - _parsingFunction == ParsingFunction.AfterResolveEntityInContent) - { - if (!_outerReader.Read()) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - } - } - - public override string ReadString() - { - Debug.Assert(_outerReader is XmlTextReaderImpl); - MoveOffEntityReference(); - return base.ReadString(); - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - // Reads and concatenates content nodes, base64-decodes the results and copies the decoded bytes into the provided buffer - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - // if not the first call to ReadContentAsBase64 - if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - // and if we have a correct decoder - if (_incReadDecoder == _base64Decoder) - { - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - } - // first call of ReadContentAsBase64 -> initialize (move to first text child (for elements) and initialize incremental read state) - else - { - if (_readState != ReadState.Interactive) - { - return 0; - } - if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary) - { - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - } - if (!XmlReader.CanReadContentAs(_curNode.type)) - { - throw CreateReadContentAsException("ReadContentAsBase64"); - } - if (!InitReadContentAsBinary()) - { - return 0; - } - } - - // setup base64 decoder - InitBase64Decoder(); - - // read binary data - return ReadContentAsBinary(buffer, index, count); - } - - - // Reads and concatenates content nodes, binhex-decodes the results and copies the decoded bytes into the provided buffer - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - // if not the first call to ReadContentAsBinHex - if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - // and if we have a correct decoder - if (_incReadDecoder == _binHexDecoder) - { - // read more binary data - return ReadContentAsBinary(buffer, index, count); - } - } - // first call of ReadContentAsBinHex -> initialize (move to first text child (for elements) and initialize incremental read state) - else - { - if (_readState != ReadState.Interactive) - { - return 0; - } - if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary) - { - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - } - if (!XmlReader.CanReadContentAs(_curNode.type)) - { - throw CreateReadContentAsException("ReadContentAsBinHex"); - } - if (!InitReadContentAsBinary()) - { - return 0; - } - } - - // setup binhex decoder (when in first ReadContentAsBinHex call or when mixed with ReadContentAsBase64) - InitBinHexDecoder(); - - // read binary data - return ReadContentAsBinary(buffer, index, count); - } - - // Reads and concatenates content of an element, base64-decodes the results and copies the decoded bytes into the provided buffer - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - // if not the first call to ReadContentAsBase64 - if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary) - { - // and if we have a correct decoder - if (_incReadDecoder == _base64Decoder) - { - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - } - // first call of ReadElementContentAsBase64 -> initialize - else - { - if (_readState != ReadState.Interactive) - { - return 0; - } - if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - } - if (_curNode.type != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsBinHex"); - } - if (!InitReadElementContentAsBinary()) - { - return 0; - } - } - - // setup base64 decoder - InitBase64Decoder(); - - // read binary data - return ReadElementContentAsBinary(buffer, index, count); - } - - - // Reads and concatenates content of an element, binhex-decodes the results and copies the decoded bytes into the provided buffer - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - // if not the first call to ReadContentAsBinHex - if (_parsingFunction == ParsingFunction.InReadElementContentAsBinary) - { - // and if we have a correct decoder - if (_incReadDecoder == _binHexDecoder) - { - // read more binary data - return ReadElementContentAsBinary(buffer, index, count); - } - } - // first call of ReadContentAsBinHex -> initialize - else - { - if (_readState != ReadState.Interactive) - { - return 0; - } - if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - throw new InvalidOperationException(ResXml.Xml_MixingBinaryContentMethods); - } - if (_curNode.type != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsBinHex"); - } - if (!InitReadElementContentAsBinary()) - { - return 0; - } - } - - // setup binhex decoder (when in first ReadContentAsBinHex call or when mixed with ReadContentAsBase64) - InitBinHexDecoder(); - - // read binary data - return ReadElementContentAsBinary(buffer, index, count); - } - - // Returns true if ReadValue is supported - public override bool CanReadValueChunk - { - get - { - return true; - } - } - - // Iterates over Value property and copies it into the provided buffer - public override int ReadValueChunk(char[] buffer, int index, int count) - { - // throw on elements - if (!XmlReader.HasValueInternal(_curNode.type)) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_InvalidReadValueChunk, _curNode.type)); - } - // check arguments - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (buffer.Length - index < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - // first call of ReadValueChunk -> initialize incremental read state - if (_parsingFunction != ParsingFunction.InReadValueChunk) - { - if (_readState != ReadState.Interactive) - { - return 0; - } - if (_parsingFunction == ParsingFunction.PartialTextValue) - { - _incReadState = IncrementalReadState.ReadValueChunk_OnPartialValue; - } - else - { - _incReadState = IncrementalReadState.ReadValueChunk_OnCachedValue; - _nextNextParsingFunction = _nextParsingFunction; - _nextParsingFunction = _parsingFunction; - } - _parsingFunction = ParsingFunction.InReadValueChunk; - _readValueOffset = 0; - } - - if (count == 0) - { - return 0; - } - - // read what is already cached in curNode - int readCount = 0; - int read = _curNode.CopyTo(_readValueOffset, buffer, index + readCount, count - readCount); - readCount += read; - _readValueOffset += read; - - if (readCount == count) - { - // take care of surrogate pairs spanning between buffers - char ch = buffer[index + count - 1]; - if (XmlCharType.IsHighSurrogate(ch)) - { - readCount--; - _readValueOffset--; - if (readCount == 0) - { - Throw(ResXml.Xml_NotEnoughSpaceForSurrogatePair); - } - } - return readCount; - } - - // if on partial value, read the rest of it - if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue) - { - _curNode.SetValue(string.Empty); - - // read next chunk of text - bool endOfValue = false; - int startPos = 0; - int endPos = 0; - while (readCount < count && !endOfValue) - { - int orChars = 0; - endOfValue = ParseText(out startPos, out endPos, ref orChars); - - int copyCount = count - readCount; - if (copyCount > endPos - startPos) - { - copyCount = endPos - startPos; - } - BlockCopyChars(_ps.chars, startPos, buffer, (index + readCount), copyCount); - - readCount += copyCount; - startPos += copyCount; - } - - _incReadState = endOfValue ? IncrementalReadState.ReadValueChunk_OnCachedValue : IncrementalReadState.ReadValueChunk_OnPartialValue; - - if (readCount == count) - { - char ch = buffer[index + count - 1]; - if (XmlCharType.IsHighSurrogate(ch)) - { - readCount--; - startPos--; - if (readCount == 0) - { - Throw(ResXml.Xml_NotEnoughSpaceForSurrogatePair); - } - } - } - - _readValueOffset = 0; - _curNode.SetValue(_ps.chars, startPos, endPos - startPos); - } - return readCount; - } - - // - // IXmlLineInfo members - // - public bool HasLineInfo() - { - return true; - } - - // Returns the line number of the current node - public int LineNumber - { - get - { - return _curNode.LineNo; - } - } - - // Returns the line position of the current node - public int LinePosition - { - get - { - return _curNode.LinePos; - } - } - - // - // IXmlNamespaceResolver members - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return this.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return this.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return this.LookupPrefix(namespaceName); - } - - // Internal IXmlNamespaceResolver methods - internal IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - return _namespaceManager.GetNamespacesInScope(scope); - } - - // NOTE: there already is virtual method for "string LookupNamespace(string prefix)" - - internal string LookupPrefix(string namespaceName) - { - return _namespaceManager.LookupPrefix(namespaceName); - } - - // - // XmlTextReader members - // - // Disables or enables support of W3C XML 1.0 Namespaces - internal bool Namespaces - { - get - { - return _supportNamespaces; - } - set - { - if (_readState != ReadState.Initial) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - _supportNamespaces = value; - if (value) - { - if (_namespaceManager is NoNamespaceManager) - { - if (_fragment && _fragmentParserContext != null && _fragmentParserContext.NamespaceManager != null) - { - _namespaceManager = _fragmentParserContext.NamespaceManager; - } - else - { - _namespaceManager = new XmlNamespaceManager(_nameTable); - } - } - _xmlContext.defaultNamespace = _namespaceManager.LookupNamespace(string.Empty); - } - else - { - if (!(_namespaceManager is NoNamespaceManager)) - { - _namespaceManager = new NoNamespaceManager(); - } - _xmlContext.defaultNamespace = string.Empty; - } - } - } - - // Enables or disables XML 1.0 normalization (incl. end-of-line normalization and normalization of attributes) - internal bool Normalization - { - get - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.Normalization property cannot be accessed on reader created via XmlReader.Create."); - return _normalize; - } - set - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.Normalization property cannot be changed on reader created via XmlReader.Create."); - if (_readState == ReadState.Closed) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - _normalize = value; - - if (_ps.entity == null || _ps.entity.IsExternal) - { - _ps.eolNormalized = !value; - } - } - } - - // Returns the Encoding of the XML document - internal Encoding Encoding - { - get - { - return (_readState == ReadState.Interactive) ? _reportedEncoding : null; - } - } - - // Spefifies whitespace handling of the XML document, i.e. whether return all namespaces, only significant ones or none - internal WhitespaceHandling WhitespaceHandling - { - get - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.WhitespaceHandling property cannot be accessed on reader created via XmlReader.Create."); - return _whitespaceHandling; - } - set - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.WhitespaceHandling property cannot be changed on reader created via XmlReader.Create."); - if (_readState == ReadState.Closed) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - if ((uint)value > (uint)WhitespaceHandling.None) - { - throw new XmlException(ResXml.Xml_WhitespaceHandling, string.Empty); - } - _whitespaceHandling = value; - } - } - - // Specifies how the DTD is processed in the XML document. - internal DtdProcessing DtdProcessing - { - get - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.DtdProcessing property cannot be accessed on reader created via XmlReader.Create."); - return _dtdProcessing; - } - set - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.DtdProcessing property cannot be changed on reader created via XmlReader.Create."); - - if ((uint)value > (uint)DtdProcessing.Parse) - { - throw new ArgumentOutOfRangeException("value"); - } - _dtdProcessing = value; - } - } - - // Spefifies whether general entities should be automatically expanded or not - internal EntityHandling EntityHandling - { - get - { - return _entityHandling; - } - set - { - if (value != EntityHandling.ExpandEntities && value != EntityHandling.ExpandCharEntities) - { - throw new XmlException(ResXml.Xml_EntityHandling, string.Empty); - } - _entityHandling = value; - } - } - - // Needed to check from the schema validation if the caller set the resolver so we'll not override it - internal bool IsResolverSet - { - get { return _xmlResolverIsSet; } - } - - // Specifies XmlResolver used for opening the XML document and other external references - internal XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - _xmlResolverIsSet = true; - // invalidate all baseUris on the stack - _ps.baseUri = null; - for (int i = 0; i <= _parsingStatesStackTop; i++) - { - _parsingStatesStack[i].baseUri = null; - } - } - } - - // Reset the state of the reader so the reader is ready to parse another XML document from the same stream. - internal void ResetState() - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.ResetState cannot be called on reader created via XmlReader.Create."); - - if (_fragment) - { - Throw(new InvalidOperationException(ResXml.Xml_InvalidResetStateCall)); - } - - if (_readState == ReadState.Initial) - { - return; - } - - // Clear - ResetAttributes(); - while (_namespaceManager.PopScope()) ; - - while (InEntity) - { - HandleEntityEnd(true); - } - - // Init - _readState = ReadState.Initial; - _parsingFunction = ParsingFunction.SwitchToInteractiveXmlDecl; - _nextParsingFunction = ParsingFunction.DocumentContent; - - _curNode = _nodes[0]; - _curNode.Clear(XmlNodeType.None); - _curNode.SetLineInfo(0, 0); - _index = 0; - _rootElementParsed = false; - - _charactersInDocument = 0; - _charactersFromEntities = 0; - - _afterResetState = true; - } - - // returns the remaining unparsed data as TextReader - internal TextReader GetRemainder() - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.GetRemainder cannot be called on reader created via XmlReader.Create."); - - Debug.Assert(_stringBuilder.Length == 0); - switch (_parsingFunction) - { - case ParsingFunction.Eof: - case ParsingFunction.ReaderClosed: - return new StringReader(string.Empty); - case ParsingFunction.OpenUrl: - OpenUrl(); - break; - case ParsingFunction.InIncrementalRead: - if (!InEntity) - { - _stringBuilder.Append(_ps.chars, _incReadLeftStartPos, _incReadLeftEndPos - _incReadLeftStartPos); - } - break; - } - - while (InEntity) - { - HandleEntityEnd(true); - } - - _ps.appendMode = false; - do - { - _stringBuilder.Append(_ps.chars, _ps.charPos, _ps.charsUsed - _ps.charPos); - _ps.charPos = _ps.charsUsed; - } while (ReadData() != 0); - - OnEof(); - - string remainer = _stringBuilder.ToString(); - _stringBuilder.Length = 0; - return new StringReader(remainer); - } - - // Reads the contents of an element including markup into a character buffer. Wellformedness checks are limited. - // This method is designed to read large streams of embedded text by calling it successively. - internal int ReadChars(char[] buffer, int index, int count) - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.ReadChars cannot be called on reader created via XmlReader.Create."); - Debug.Assert(_outerReader is XmlTextReader); - - if (_parsingFunction == ParsingFunction.InIncrementalRead) - { - if (_incReadDecoder != _readCharsDecoder) - { // mixing ReadChars with ReadBase64 or ReadBinHex - if (_readCharsDecoder == null) - { - _readCharsDecoder = new IncrementalReadCharsDecoder(); - } - _readCharsDecoder.Reset(); - _incReadDecoder = _readCharsDecoder; - } - return IncrementalRead(buffer, index, count); - } - else - { - if (_curNode.type != XmlNodeType.Element) - { - return 0; - } - if (_curNode.IsEmptyElement) - { - _outerReader.Read(); - return 0; - } - - if (_readCharsDecoder == null) - { - _readCharsDecoder = new IncrementalReadCharsDecoder(); - } - - InitIncrementalRead(_readCharsDecoder); - return IncrementalRead(buffer, index, count); - } - } - - // Reads the contents of an element including markup and base64-decodes it into a byte buffer. Wellformedness checks are limited. - // This method is designed to read base64-encoded large streams of bytes by calling it successively. - internal int ReadBase64(byte[] array, int offset, int len) - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.ReadBase64 cannot be called on reader created via XmlReader.Create."); - Debug.Assert(_outerReader is XmlTextReader); - - if (_parsingFunction == ParsingFunction.InIncrementalRead) - { - if (_incReadDecoder != _base64Decoder) - { // mixing ReadBase64 with ReadChars or ReadBinHex - InitBase64Decoder(); - } - return IncrementalRead(array, offset, len); - } - else - { - if (_curNode.type != XmlNodeType.Element) - { - return 0; - } - if (_curNode.IsEmptyElement) - { - _outerReader.Read(); - return 0; - } - - if (_base64Decoder == null) - { - _base64Decoder = new Base64Decoder(); - } - - InitIncrementalRead(_base64Decoder); - return IncrementalRead(array, offset, len); - } - } - - // Reads the contents of an element including markup and binhex-decodes it into a byte buffer. Wellformedness checks are limited. - // This method is designed to read binhex-encoded large streams of bytes by calling it successively. - internal int ReadBinHex(byte[] array, int offset, int len) - { - Debug.Assert(_v1Compat, "XmlTextReaderImpl.ReadBinHex cannot be called on reader created via XmlReader.Create."); - Debug.Assert(_outerReader is XmlTextReader); - - if (_parsingFunction == ParsingFunction.InIncrementalRead) - { - if (_incReadDecoder != _binHexDecoder) - { // mixing ReadBinHex with ReadChars or ReadBase64 - InitBinHexDecoder(); - } - return IncrementalRead(array, offset, len); - } - else - { - if (_curNode.type != XmlNodeType.Element) - { - return 0; - } - if (_curNode.IsEmptyElement) - { - _outerReader.Read(); - return 0; - } - - if (_binHexDecoder == null) - { - _binHexDecoder = new BinHexDecoder(); - } - - InitIncrementalRead(_binHexDecoder); - return IncrementalRead(array, offset, len); - } - } - - // - // Helpers for DtdParserProxy - // - internal XmlNameTable DtdParserProxy_NameTable - { - get - { - return _nameTable; - } - } - - internal IXmlNamespaceResolver DtdParserProxy_NamespaceResolver - { - get - { - return _namespaceManager; - } - } - - internal bool DtdParserProxy_DtdValidation - { - get - { - return DtdValidation; - } - } - - internal bool DtdParserProxy_Normalization - { - get - { - return _normalize; - } - } - - internal bool DtdParserProxy_Namespaces - { - get - { - return _supportNamespaces; - } - } - - internal bool DtdParserProxy_V1CompatibilityMode - { - get - { - return _v1Compat; - } - } - - internal Uri DtdParserProxy_BaseUri - { - // SxS: ps.baseUri may be initialized in the constructor (public XmlTextReaderImpl( string url, XmlNameTable nt )) based on - // url provided by the user. Here the property returns ps.BaseUri - so it may expose a path. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - get - { - if (_ps.baseUriStr.Length > 0 && _ps.baseUri == null && _xmlResolver != null) - { - _ps.baseUri = _xmlResolver.ResolveUri(null, _ps.baseUriStr); - } - return _ps.baseUri; - } - } - - internal bool DtdParserProxy_IsEof - { - get - { - return _ps.isEof; - } - } - - internal char[] DtdParserProxy_ParsingBuffer - { - get - { - return _ps.chars; - } - } - - internal int DtdParserProxy_ParsingBufferLength - { - get - { - return _ps.charsUsed; - } - } - - internal int DtdParserProxy_CurrentPosition - { - get - { - return _ps.charPos; - } - set - { - Debug.Assert(value >= 0 && value <= _ps.charsUsed); - _ps.charPos = value; - } - } - - internal int DtdParserProxy_EntityStackLength - { - get - { - return _parsingStatesStackTop + 1; - } - } - - internal bool DtdParserProxy_IsEntityEolNormalized - { - get - { - return _ps.eolNormalized; - } - } - - internal IValidationEventHandling DtdParserProxy_ValidationEventHandling - { - get - { - return _validationEventHandling; - } - set - { - _validationEventHandling = value; - } - } - - internal void DtdParserProxy_OnNewLine(int pos) - { - this.OnNewLine(pos); - } - - internal int DtdParserProxy_LineNo - { - get - { - return _ps.LineNo; - } - } - - internal int DtdParserProxy_LineStartPosition - { - get - { - return _ps.lineStartPos; - } - } - - internal int DtdParserProxy_ReadData() - { - return this.ReadData(); - } - - internal int DtdParserProxy_ParseNumericCharRef(BufferBuilder internalSubsetBuilder) - { - EntityType entType; - return this.ParseNumericCharRef(true, internalSubsetBuilder, out entType); - } - - internal int DtdParserProxy_ParseNamedCharRef(bool expand, BufferBuilder internalSubsetBuilder) - { - return this.ParseNamedCharRef(expand, internalSubsetBuilder); - } - - internal void DtdParserProxy_ParsePI(BufferBuilder sb) - { - if (sb == null) - { - ParsingMode pm = _parsingMode; - _parsingMode = ParsingMode.SkipNode; - ParsePI(null); - _parsingMode = pm; - } - else - { - ParsePI(sb); - } - } - - internal void DtdParserProxy_ParseComment(BufferBuilder sb) - { - Debug.Assert(_parsingMode == ParsingMode.Full); - - try - { - if (sb == null) - { - ParsingMode savedParsingMode = _parsingMode; - _parsingMode = ParsingMode.SkipNode; - ParseCDataOrComment(XmlNodeType.Comment); - _parsingMode = savedParsingMode; - } - else - { - NodeData originalCurNode = _curNode; - - _curNode = AddNode(_index + _attrCount + 1, _index); - ParseCDataOrComment(XmlNodeType.Comment); - _curNode.CopyTo(0, sb); - - _curNode = originalCurNode; - } - } - catch (XmlException e) - { - if (e.ResString == ResXml.Xml_UnexpectedEOF && _ps.entity != null) - { - SendValidationEvent(XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, null, _ps.LineNo, _ps.LinePos); - } - else - { - throw; - } - } - } - - private bool IsResolverNull - { - get - { - return _xmlResolver == null; // || (Microsoft.Xml.XmlConfiguration.XmlReaderSection.ProhibitDefaultUrlResolver && !xmlResolverIsSet); - } - } - - private XmlResolver GetTempResolver() - { - return _xmlResolver == null ? new XmlUrlResolver() : _xmlResolver; - } - - internal bool DtdParserProxy_PushEntity(IDtdEntityInfo entity, out int entityId) - { - bool retValue; - if (entity.IsExternal) - { - if (IsResolverNull) - { - entityId = -1; - return false; - } - retValue = PushExternalEntity(entity); - } - else - { - PushInternalEntity(entity); - retValue = true; - } - entityId = _ps.entityId; - return retValue; - } - - internal bool DtdParserProxy_PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId) - { - if (_parsingStatesStackTop == -1) - { - oldEntity = null; - newEntityId = -1; - return false; - } - oldEntity = _ps.entity; - PopEntity(); - newEntityId = _ps.entityId; - return true; - } - - // SxS: The caller did not provide any SxS sensitive name or resource. No resource is being exposed either. - // It is OK to disable SxS warning. - - - internal bool DtdParserProxy_PushExternalSubset(string systemId, string publicId) - { - Debug.Assert(_parsingStatesStackTop == -1); - Debug.Assert((systemId != null && systemId.Length > 0) || (publicId != null && publicId.Length > 0)); - - if (IsResolverNull) - { - return false; - } - if (_ps.baseUri == null && !string.IsNullOrEmpty(_ps.baseUriStr)) - { - _ps.baseUri = _xmlResolver.ResolveUri(null, _ps.baseUriStr); - } - PushExternalEntityOrSubset(publicId, systemId, _ps.baseUri, null); - - _ps.entity = null; - _ps.entityId = 0; - - Debug.Assert(_ps.appendMode); - int initialPos = _ps.charPos; - if (_v1Compat) - { - EatWhitespaces(null); - } - if (!ParseXmlDeclaration(true)) - { - _ps.charPos = initialPos; - } - - return true; - } - - internal void DtdParserProxy_PushInternalDtd(string baseUri, string internalDtd) - { - Debug.Assert(_parsingStatesStackTop == -1); - Debug.Assert(internalDtd != null); - - PushParsingState(); - - RegisterConsumedCharacters(internalDtd.Length, false); - InitStringInput(baseUri, Encoding.Unicode, internalDtd); - - _ps.entity = null; - _ps.entityId = 0; - _ps.eolNormalized = false; - } - - internal void DtdParserProxy_Throw(Exception e) - { - this.Throw(e); - } - - internal void DtdParserProxy_OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo) - { - NodeData attr = AddAttributeNoChecks("SYSTEM", _index + 1); - attr.SetValue(systemId); - attr.lineInfo = keywordLineInfo; - attr.lineInfo2 = systemLiteralLineInfo; - } - - internal void DtdParserProxy_OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo) - { - NodeData attr = AddAttributeNoChecks("PUBLIC", _index + 1); - attr.SetValue(publicId); - attr.lineInfo = keywordLineInfo; - attr.lineInfo2 = publicLiteralLineInfo; - } - - // - // Throw methods: Sets the reader current position to pos, sets the error state and throws exception - // - private void Throw(int pos, string res, string arg) - { - _ps.charPos = pos; - Throw(res, arg); - } - - private void Throw(int pos, string res, string[] args) - { - _ps.charPos = pos; - Throw(res, args); - } - - private void Throw(int pos, string res) - { - _ps.charPos = pos; - Throw(res, string.Empty); - } - - private void Throw(string res) - { - Throw(res, string.Empty); - } - - private void Throw(string res, int lineNo, int linePos) - { - Throw(new XmlException(res, string.Empty, lineNo, linePos, _ps.baseUriStr)); - } - - private void Throw(string res, string arg) - { - Throw(new XmlException(res, arg, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); - } - - private void Throw(string res, string arg, int lineNo, int linePos) - { - Throw(new XmlException(res, arg, lineNo, linePos, _ps.baseUriStr)); - } - - private void Throw(string res, string[] args) - { - Throw(new XmlException(res, args, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); - } - - private void Throw(string res, string arg, Exception innerException) - { - Throw(res, new string[] { arg }, innerException); - } - - private void Throw(string res, string[] args, Exception innerException) - { - Throw(new XmlException(res, args, innerException, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); - } - - private void Throw(Exception e) - { - SetErrorState(); - XmlException xmlEx = e as XmlException; - if (xmlEx != null) - { - _curNode.SetLineInfo(xmlEx.LineNumber, xmlEx.LinePosition); - } - throw e; - } - - private void ReThrow(Exception e, int lineNo, int linePos) - { - Throw(new XmlException(e.Message, (Exception)null, lineNo, linePos, _ps.baseUriStr)); - } - - private void ThrowWithoutLineInfo(string res) - { - Throw(new XmlException(res, string.Empty, _ps.baseUriStr)); - } - - private void ThrowWithoutLineInfo(string res, string arg) - { - Throw(new XmlException(res, arg, _ps.baseUriStr)); - } - - private void ThrowWithoutLineInfo(string res, string[] args, Exception innerException) - { - Throw(new XmlException(res, args, innerException, 0, 0, _ps.baseUriStr)); - } - - private void ThrowInvalidChar(char[] data, int length, int invCharPos) - { - Throw(invCharPos, ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(data, length, invCharPos)); - } - - private void SetErrorState() - { - _parsingFunction = ParsingFunction.Error; - _readState = ReadState.Error; - } - - private void SendValidationEvent(XmlSeverityType severity, string code, string arg, int lineNo, int linePos) - { - SendValidationEvent(severity, new XmlSchemaException(code, arg, _ps.baseUriStr, lineNo, linePos)); - } - - private void SendValidationEvent(XmlSeverityType severity, XmlSchemaException exception) - { - if (_validationEventHandling != null) - { - _validationEventHandling.SendEvent(exception, severity); - } - } - - // - // Private implementation methods & properties - // - private bool InAttributeValueIterator - { - get - { - return _attrCount > 0 && _parsingFunction >= ParsingFunction.InReadAttributeValue; - } - } - - private void FinishAttributeValueIterator() - { - Debug.Assert(InAttributeValueIterator); - if (_parsingFunction == ParsingFunction.InReadValueChunk) - { - FinishReadValueChunk(); - } - else if (_parsingFunction == ParsingFunction.InReadContentAsBinary) - { - FinishReadContentAsBinary(); - } - if (_parsingFunction == ParsingFunction.InReadAttributeValue) - { - while (_ps.entityId != _attributeValueBaseEntityId) - { - HandleEntityEnd(false); - } - _emptyEntityInAttributeResolved = false; - _parsingFunction = _nextParsingFunction; - _nextParsingFunction = (_index > 0) ? ParsingFunction.ElementContent : ParsingFunction.DocumentContent; - } - } - - private bool DtdValidation - { - get - { - return _validationEventHandling != null; - } - } - - private void InitStreamInput(Stream stream, Encoding encoding) - { - InitStreamInput(null, string.Empty, stream, null, 0, encoding); - } - - private void InitStreamInput(string baseUriStr, Stream stream, Encoding encoding) - { - Debug.Assert(baseUriStr != null); - InitStreamInput(null, baseUriStr, stream, null, 0, encoding); - } - - private void InitStreamInput(Uri baseUri, Stream stream, Encoding encoding) - { - Debug.Assert(baseUri != null); - InitStreamInput(baseUri, baseUri.ToString(), stream, null, 0, encoding); - } - - private void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, Encoding encoding) - { - InitStreamInput(baseUri, baseUriStr, stream, null, 0, encoding); - } - - private void InitStreamInput(Uri baseUri, string baseUriStr, Stream stream, byte[] bytes, int byteCount, Encoding encoding) - { - Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0 && _ps.textReader == null); - Debug.Assert(baseUriStr != null); - Debug.Assert(baseUri == null || (baseUri.ToString().Equals(baseUriStr))); - - _ps.stream = stream; - _ps.baseUri = baseUri; - _ps.baseUriStr = baseUriStr; - - // take over the byte buffer allocated in XmlReader.Create, if available - int bufferSize; - if (bytes != null) - { - _ps.bytes = bytes; - _ps.bytesUsed = byteCount; - bufferSize = _ps.bytes.Length; - } - else - { - // allocate the byte buffer -#if !ASYNC - bufferSize = XmlReader.CalcBufferSize(stream); -#else - if (laterInitParam != null && laterInitParam.useAsync) { - bufferSize = AsyncBufferSize; - } - else { - bufferSize = XmlReader.CalcBufferSize(stream); - } -#endif - if (_ps.bytes == null || _ps.bytes.Length < bufferSize) - { - _ps.bytes = new byte[bufferSize]; - } - } - - // allocate char buffer - if (_ps.chars == null || _ps.chars.Length < bufferSize + 1) - { - _ps.chars = new char[bufferSize + 1]; - } - - // make sure we have at least 4 bytes to detect the encoding (no preamble of System.Text supported encoding is longer than 4 bytes) - _ps.bytePos = 0; - while (_ps.bytesUsed < 4 && _ps.bytes.Length - _ps.bytesUsed > 0) - { - int read = stream.Read(_ps.bytes, _ps.bytesUsed, _ps.bytes.Length - _ps.bytesUsed); - if (read == 0) - { - _ps.isStreamEof = true; - break; - } - _ps.bytesUsed += read; - } - - // detect & setup encoding - if (encoding == null) - { - encoding = DetectEncoding(); - } - SetupEncoding(encoding); - - // eat preamble - byte[] preamble = _ps.encoding.GetPreamble(); - int preambleLen = preamble.Length; - int i; - for (i = 0; i < preambleLen && i < _ps.bytesUsed; i++) - { - if (_ps.bytes[i] != preamble[i]) - { - break; - } - } - if (i == preambleLen) - { - _ps.bytePos = preambleLen; - } - - _documentStartBytePos = _ps.bytePos; - - _ps.eolNormalized = !_normalize; - - // decode first characters - _ps.appendMode = true; - ReadData(); - } - - private void InitTextReaderInput(string baseUriStr, TextReader input) - { - InitTextReaderInput(baseUriStr, null, input); - } - - private void InitTextReaderInput(string baseUriStr, Uri baseUri, TextReader input) - { - Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0 && _ps.stream == null); - Debug.Assert(baseUriStr != null); - - _ps.textReader = input; - _ps.baseUriStr = baseUriStr; - _ps.baseUri = baseUri; - - if (_ps.chars == null) - { -#if !ASYNC - _ps.chars = new char[XmlReader.DefaultBufferSize + 1]; -#else - if (laterInitParam != null && laterInitParam.useAsync) { - ps.chars = new char[XmlReader.AsyncBufferSize + 1]; - } - else { - ps.chars = new char[XmlReader.DefaultBufferSize + 1]; - } -#endif - } - - _ps.encoding = Encoding.Unicode; - _ps.eolNormalized = !_normalize; - - // read first characters - _ps.appendMode = true; - ReadData(); - } - - private void InitStringInput(string baseUriStr, Encoding originalEncoding, string str) - { - Debug.Assert(_ps.stream == null && _ps.textReader == null); - Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0); - Debug.Assert(baseUriStr != null); - Debug.Assert(str != null); - - _ps.baseUriStr = baseUriStr; - _ps.baseUri = null; - - int len = str.Length; - _ps.chars = new char[len + 1]; - str.CopyTo(0, _ps.chars, 0, str.Length); - _ps.charsUsed = len; - _ps.chars[len] = (char)0; - - _ps.encoding = originalEncoding; - - _ps.eolNormalized = !_normalize; - _ps.isEof = true; - } - - private void InitFragmentReader(XmlNodeType fragmentType, XmlParserContext parserContext, bool allowXmlDeclFragment) - { - _fragmentParserContext = parserContext; - - if (parserContext != null) - { - if (parserContext.NamespaceManager != null) - { - _namespaceManager = parserContext.NamespaceManager; - _xmlContext.defaultNamespace = _namespaceManager.LookupNamespace(string.Empty); - } - else - { - _namespaceManager = new XmlNamespaceManager(_nameTable); - } - - _ps.baseUriStr = parserContext.BaseURI; - _ps.baseUri = null; - _xmlContext.xmlLang = parserContext.XmlLang; - _xmlContext.xmlSpace = parserContext.XmlSpace; - } - else - { - _namespaceManager = new XmlNamespaceManager(_nameTable); - _ps.baseUriStr = string.Empty; - _ps.baseUri = null; - } - - _reportedBaseUri = _ps.baseUriStr; - - switch (fragmentType) - { - case XmlNodeType.Attribute: - _ps.appendMode = false; - _parsingFunction = ParsingFunction.SwitchToInteractive; - _nextParsingFunction = ParsingFunction.FragmentAttribute; - break; - case XmlNodeType.Element: - Debug.Assert(_parsingFunction == ParsingFunction.SwitchToInteractiveXmlDecl); - _nextParsingFunction = ParsingFunction.DocumentContent; - break; - case XmlNodeType.Document: - Debug.Assert(_parsingFunction == ParsingFunction.SwitchToInteractiveXmlDecl); - Debug.Assert(_nextParsingFunction == ParsingFunction.DocumentContent); - break; - case XmlNodeType.XmlDeclaration: - if (allowXmlDeclFragment) - { - _ps.appendMode = false; - _parsingFunction = ParsingFunction.SwitchToInteractive; - _nextParsingFunction = ParsingFunction.XmlDeclarationFragment; - break; - } - else - { - goto default; - } - default: - Throw(ResXml.Xml_PartialContentNodeTypeNotSupportedEx, fragmentType.ToString()); - return; - } - _fragmentType = fragmentType; - _fragment = true; - } - - private void ProcessDtdFromParserContext(XmlParserContext context) - { - Debug.Assert(context != null && context.HasDtdInfo); - - switch (_dtdProcessing) - { - case DtdProcessing.Prohibit: - ThrowWithoutLineInfo(ResXml.Xml_DtdIsProhibitedEx); - break; - case DtdProcessing.Ignore: - // do nothing - break; - case DtdProcessing.Parse: - ParseDtdFromParserContext(); - break; - default: - Debug.Assert(false, "Unhandled DtdProcessing enumeration value."); - break; - } - } - - // SxS: This method resolve Uri but does not expose it to the caller. It's OK to disable the warning. - - - private void OpenUrl() - { - Debug.Assert(_url != null && _url.Length > 0); - //Debug.Assert( compressedStack != null ); - - // It is safe to use the resolver here as we don't resolve or expose any DTD to the caller - XmlResolver tmpResolver = GetTempResolver(); - if (_ps.baseUri != null) - { - Debug.Assert(_xmlResolver != null || !Microsoft.Xml.XmlReaderSettings.EnableLegacyXmlSettings()); - } - else - { - _ps.baseUri = tmpResolver.ResolveUri(null, _url); - _ps.baseUriStr = _ps.baseUri.ToString(); - } - - if (_ps.stream == null) - { - ThrowWithoutLineInfo(ResXml.Xml_CannotResolveUrl, _ps.baseUriStr); - } - - InitStreamInput(_ps.baseUri, _ps.baseUriStr, _ps.stream, null); - _reportedEncoding = _ps.encoding; - } - - private void OpenUrlDelegate(object xmlResolver) - { - // Safe to have valid resolver here as it is not used to parse DTD - _ps.stream = (Stream)GetTempResolver().GetEntity(_ps.baseUri, null, typeof(Stream)); - } - - // Stream input only: detect encoding from the first 4 bytes of the byte buffer starting at ps.bytes[ps.bytePos] - private Encoding DetectEncoding() - { - Debug.Assert(_ps.bytes != null); - Debug.Assert(_ps.bytePos == 0); - - if (_ps.bytesUsed < 2) - { - return null; - } - int first2Bytes = _ps.bytes[0] << 8 | _ps.bytes[1]; - int next2Bytes = (_ps.bytesUsed >= 4) ? (_ps.bytes[2] << 8 | _ps.bytes[3]) : 0; - - switch (first2Bytes) - { - case 0x0000: - switch (next2Bytes) - { - case 0xFEFF: - return Ucs4Encoding.UCS4_Bigendian; - case 0x003C: - return Ucs4Encoding.UCS4_Bigendian; - case 0xFFFE: - return Ucs4Encoding.UCS4_2143; - case 0x3C00: - return Ucs4Encoding.UCS4_2143; - } - break; - case 0xFEFF: - if (next2Bytes == 0x0000) - { - return Ucs4Encoding.UCS4_3412; - } - else - { - return Encoding.BigEndianUnicode; - } - case 0xFFFE: - if (next2Bytes == 0x0000) - { - return Ucs4Encoding.UCS4_Littleendian; - } - else - { - return Encoding.Unicode; - } - case 0x3C00: - if (next2Bytes == 0x0000) - { - return Ucs4Encoding.UCS4_Littleendian; - } - else - { - return Encoding.Unicode; - } - case 0x003C: - if (next2Bytes == 0x0000) - { - return Ucs4Encoding.UCS4_3412; - } - else - { - return Encoding.BigEndianUnicode; - } - case 0x4C6F: - if (next2Bytes == 0xA794) - { - Throw(ResXml.Xml_UnknownEncoding, "ebcdic"); - } - break; - case 0xEFBB: - if ((next2Bytes & 0xFF00) == 0xBF00) - { - return new UTF8Encoding(true, true); - } - break; - } - // Default encoding is ASCII (using SafeAsciiDecoder) until we read xml declaration. - // If we set UTF8 encoding now, it will throw exceptions (=slow) when decoding non-UTF8-friendly - // characters after the xml declaration, which may be perfectly valid in the encoding - // specified in xml declaration. - return null; - } - - private void SetupEncoding(Encoding encoding) - { - if (encoding == null) - { - Debug.Assert(_ps.charPos == 0); - _ps.encoding = Encoding.UTF8; - _ps.decoder = new SafeAsciiDecoder(); - } - else - { - _ps.encoding = encoding; - - switch (_ps.encoding.WebName) - { // Encoding.Codepage is not supported in Silverlight - case "utf-16": - _ps.decoder = new UTF16Decoder(false); - break; - case "utf-16BE": - _ps.decoder = new UTF16Decoder(true); - break; - default: - _ps.decoder = encoding.GetDecoder(); - break; - } - } - } - - // Switches the reader's encoding - private void SwitchEncoding(Encoding newEncoding) - { - if ((newEncoding.WebName != _ps.encoding.WebName || _ps.decoder is SafeAsciiDecoder) && !_afterResetState) - { - Debug.Assert(_ps.stream != null); - UnDecodeChars(); - _ps.appendMode = false; - SetupEncoding(newEncoding); - ReadData(); - } - } - - // Returns the Encoding object for the given encoding name, if the reader's encoding can be switched to that encoding. - // Performs checks whether switching from current encoding to specified encoding is allowed. - private Encoding CheckEncoding(string newEncodingName) - { - // encoding can be switched on stream input only - if (_ps.stream == null) - { - return _ps.encoding; - } - - if (0 == String.Compare(newEncodingName, "ucs-2", StringComparison.OrdinalIgnoreCase) || - 0 == String.Compare(newEncodingName, "utf-16", StringComparison.OrdinalIgnoreCase) || - 0 == String.Compare(newEncodingName, "iso-10646-ucs-2", StringComparison.OrdinalIgnoreCase) || - 0 == String.Compare(newEncodingName, "ucs-4", StringComparison.OrdinalIgnoreCase)) - { - if (_ps.encoding.WebName != "utf-16BE" && - _ps.encoding.WebName != "utf-16" && - 0 != String.Compare(newEncodingName, "ucs-4", StringComparison.OrdinalIgnoreCase)) - { - if (_afterResetState) - { - Throw(ResXml.Xml_EncodingSwitchAfterResetState, newEncodingName); - } - else - { - ThrowWithoutLineInfo(ResXml.Xml_MissingByteOrderMark); - } - } - return _ps.encoding; - } - - Encoding newEncoding = null; - if (0 == String.Compare(newEncodingName, "utf-8", StringComparison.OrdinalIgnoreCase)) - { - newEncoding = new UTF8Encoding(true, true); - } - else - { - try - { - newEncoding = Encoding.GetEncoding(newEncodingName); - } - catch (NotSupportedException innerEx) - { - Throw(ResXml.Xml_UnknownEncoding, newEncodingName, innerEx); - } - catch (ArgumentException innerEx) - { - Throw(ResXml.Xml_UnknownEncoding, newEncodingName, innerEx); - } - Debug.Assert(newEncoding.EncodingName != "UTF-8"); - } - - // check for invalid encoding switches after ResetState - if (_afterResetState && _ps.encoding.WebName != newEncoding.WebName) - { - Throw(ResXml.Xml_EncodingSwitchAfterResetState, newEncodingName); - } - - return newEncoding; - } - - private void UnDecodeChars() - { - Debug.Assert(_ps.stream != null && _ps.decoder != null && _ps.bytes != null); - Debug.Assert(_ps.appendMode, "UnDecodeChars cannot be called after ps.appendMode has been changed to false"); - - Debug.Assert(_ps.charsUsed >= _ps.charPos, "The current position must be in the valid character range."); - if (_maxCharactersInDocument > 0) - { - // We're returning back in the input (potentially) so we need to fixup - // the character counters to avoid counting some of them twice. - // The following code effectively rolls-back all decoded characters - // after the ps.charPos (which typically points to the first character - // after the XML decl). - Debug.Assert(_charactersInDocument >= _ps.charsUsed - _ps.charPos, - "We didn't correctly count some of the decoded characters against the MaxCharactersInDocument."); - _charactersInDocument -= _ps.charsUsed - _ps.charPos; - } - if (_maxCharactersFromEntities > 0) - { - if (InEntity) - { - Debug.Assert(_charactersFromEntities >= _ps.charsUsed - _ps.charPos, - "We didn't correctly count some of the decoded characters against the MaxCharactersFromEntities."); - _charactersFromEntities -= _ps.charsUsed - _ps.charPos; - } - } - - _ps.bytePos = _documentStartBytePos; // byte position after preamble - if (_ps.charPos > 0) - { - _ps.bytePos += _ps.encoding.GetByteCount(_ps.chars, 0, _ps.charPos); - } - _ps.charsUsed = _ps.charPos; - _ps.isEof = false; - } - - private void SwitchEncodingToUTF8() - { - SwitchEncoding(new UTF8Encoding(true, true)); - } - - // Reads more data to the character buffer, discarding already parsed chars / decoded bytes. - private int ReadData() - { - // Append Mode: Append new bytes and characters to the buffers, do not rewrite them. Allocate new buffers - // if the current ones are full - // Rewrite Mode: Reuse the buffers. If there is less than half of the char buffer left for new data, move - // the characters that has not been parsed yet to the front of the buffer. Same for bytes. - - if (_ps.isEof) - { - return 0; - } - - int charsRead; - if (_ps.appendMode) - { - // the character buffer is full -> allocate a new one - if (_ps.charsUsed == _ps.chars.Length - 1) - { - // invalidate node values kept in buffer - applies to attribute values only - for (int i = 0; i < _attrCount; i++) - { - _nodes[_index + i + 1].OnBufferInvalidated(); - } - - char[] newChars = new char[_ps.chars.Length * 2]; - BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); - _ps.chars = newChars; - } - - if (_ps.stream != null) - { - // the byte buffer is full -> allocate a new one - if (_ps.bytesUsed - _ps.bytePos < MaxByteSequenceLen) - { - if (_ps.bytes.Length - _ps.bytesUsed < MaxByteSequenceLen) - { - byte[] newBytes = new byte[_ps.bytes.Length * 2]; - BlockCopy(_ps.bytes, 0, newBytes, 0, _ps.bytesUsed); - _ps.bytes = newBytes; - } - } - } - - charsRead = _ps.chars.Length - _ps.charsUsed - 1; - if (charsRead > ApproxXmlDeclLength) - { - charsRead = ApproxXmlDeclLength; - } - } - else - { - int charsLen = _ps.chars.Length; - if (charsLen - _ps.charsUsed <= charsLen / 2) - { - // invalidate node values kept in buffer - applies to attribute values only - for (int i = 0; i < _attrCount; i++) - { - _nodes[_index + i + 1].OnBufferInvalidated(); - } - - // move unparsed characters to front, unless the whole buffer contains unparsed characters - int copyCharsCount = _ps.charsUsed - _ps.charPos; - if (copyCharsCount < charsLen - 1) - { - _ps.lineStartPos = _ps.lineStartPos - _ps.charPos; - if (copyCharsCount > 0) - { - BlockCopyChars(_ps.chars, _ps.charPos, _ps.chars, 0, copyCharsCount); - } - _ps.charPos = 0; - _ps.charsUsed = copyCharsCount; - } - else - { - char[] newChars = new char[_ps.chars.Length * 2]; - BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); - _ps.chars = newChars; - } - } - - if (_ps.stream != null) - { - // move undecoded bytes to the front to make some space in the byte buffer - int bytesLeft = _ps.bytesUsed - _ps.bytePos; - if (bytesLeft <= MaxBytesToMove) - { - if (bytesLeft == 0) - { - _ps.bytesUsed = 0; - } - else - { - BlockCopy(_ps.bytes, _ps.bytePos, _ps.bytes, 0, bytesLeft); - _ps.bytesUsed = bytesLeft; - } - _ps.bytePos = 0; - } - } - charsRead = _ps.chars.Length - _ps.charsUsed - 1; - } - - if (_ps.stream != null) - { - if (!_ps.isStreamEof) - { - // read new bytes - if (_ps.bytePos == _ps.bytesUsed && _ps.bytes.Length - _ps.bytesUsed > 0) - { - int read = _ps.stream.Read(_ps.bytes, _ps.bytesUsed, _ps.bytes.Length - _ps.bytesUsed); - if (read == 0) - { - _ps.isStreamEof = true; - } - _ps.bytesUsed += read; - } - } - - int originalBytePos = _ps.bytePos; - - // decode chars - charsRead = GetChars(charsRead); - if (charsRead == 0 && _ps.bytePos != originalBytePos) - { - // GetChars consumed some bytes but it was not enough bytes to form a character -> try again - return ReadData(); - } - } - else if (_ps.textReader != null) - { - // read chars - charsRead = _ps.textReader.Read(_ps.chars, _ps.charsUsed, _ps.chars.Length - _ps.charsUsed - 1); - _ps.charsUsed += charsRead; - } - else - { - charsRead = 0; - } - - RegisterConsumedCharacters(charsRead, InEntity); - - if (charsRead == 0) - { - Debug.Assert(_ps.charsUsed < _ps.chars.Length); - _ps.isEof = true; - } - _ps.chars[_ps.charsUsed] = (char)0; - return charsRead; - } - - // Stream input only: read bytes from stream and decodes them according to the current encoding - private int GetChars(int maxCharsCount) - { - Debug.Assert(_ps.stream != null && _ps.decoder != null && _ps.bytes != null); - Debug.Assert(maxCharsCount <= _ps.chars.Length - _ps.charsUsed - 1); - - // determine the maximum number of bytes we can pass to the decoder - int bytesCount = _ps.bytesUsed - _ps.bytePos; - if (bytesCount == 0) - { - return 0; - } - - int charsCount; - bool completed; - try - { - // decode chars - _ps.decoder.Convert(_ps.bytes, _ps.bytePos, bytesCount, _ps.chars, _ps.charsUsed, maxCharsCount, false, out bytesCount, out charsCount, out completed); - } - catch (ArgumentException) - { - InvalidCharRecovery(ref bytesCount, out charsCount); - } - - // move pointers and return - _ps.bytePos += bytesCount; - _ps.charsUsed += charsCount; - Debug.Assert(maxCharsCount >= charsCount); - return charsCount; - } - - private void InvalidCharRecovery(ref int bytesCount, out int charsCount) - { - int charsDecoded = 0; - int bytesDecoded = 0; - try - { - while (bytesDecoded < bytesCount) - { - int chDec; - int bDec; - bool completed; - _ps.decoder.Convert(_ps.bytes, _ps.bytePos + bytesDecoded, 1, _ps.chars, _ps.charsUsed + charsDecoded, 1, false, out bDec, out chDec, out completed); - charsDecoded += chDec; - bytesDecoded += bDec; - } - Debug.Assert(false, "We should get an exception again."); - } - catch (ArgumentException) - { - } - - if (charsDecoded == 0) - { - Throw(_ps.charsUsed, ResXml.Xml_InvalidCharInThisEncoding); - } - charsCount = charsDecoded; - bytesCount = bytesDecoded; - } - - internal void Close(bool closeInput) - { - if (_parsingFunction == ParsingFunction.ReaderClosed) - { - return; - } - - while (InEntity) - { - PopParsingState(); - } - - _ps.Close(closeInput); - - _curNode = NodeData.None; - _parsingFunction = ParsingFunction.ReaderClosed; - _reportedEncoding = null; - _reportedBaseUri = string.Empty; - _readState = ReadState.Closed; - _fullAttrCleanup = false; - ResetAttributes(); - - _laterInitParam = null; - } - - private void ShiftBuffer(int sourcePos, int destPos, int count) - { - BlockCopyChars(_ps.chars, sourcePos, _ps.chars, destPos, count); - } - - // Parses the xml or text declaration and switched encoding if needed - private bool ParseXmlDeclaration(bool isTextDecl) - { - while (_ps.charsUsed - _ps.charPos < 6) - { // minimum " - Encoding encoding = null; - - for (; ; ) - { - int originalSbLen = sb.Length; - int wsCount = EatWhitespaces(xmlDeclState == 0 ? null : sb); - - // end of xml declaration - if (_ps.chars[_ps.charPos] == '?') - { - sb.Length = originalSbLen; - - if (_ps.chars[_ps.charPos + 1] == '>') - { - if (xmlDeclState == 0) - { - Throw(isTextDecl ? ResXml.Xml_InvalidTextDecl : ResXml.Xml_InvalidXmlDecl); - } - - _ps.charPos += 2; - if (!isTextDecl) - { - _curNode.SetValue(sb.ToString()); - sb.Length = 0; - - _nextParsingFunction = _parsingFunction; - _parsingFunction = ParsingFunction.ResetAttributesRootLevel; - } - - // switch to encoding specified in xml declaration - if (encoding == null) - { - if (isTextDecl) - { - Throw(ResXml.Xml_InvalidTextDecl); - } - if (_afterResetState) - { - // check for invalid encoding switches to default encoding - string encodingName = _ps.encoding.WebName; - if (encodingName != "utf-8" && encodingName != "utf-16" && - encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) - { - Throw(ResXml.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); - } - } - if (_ps.decoder is SafeAsciiDecoder) - { - SwitchEncodingToUTF8(); - } - } - else - { - SwitchEncoding(encoding); - } - _ps.appendMode = false; - return true; - } - else if (_ps.charPos + 1 == _ps.charsUsed) - { - goto ReadData; - } - else - { - ThrowUnexpectedToken("'>'"); - } - } - - if (wsCount == 0 && xmlDeclState != 0) - { - ThrowUnexpectedToken("?>"); - } - - // read attribute name - int nameEndPos = ParseName(); - - NodeData attr = null; - switch (_ps.chars[_ps.charPos]) - { - case 'v': - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos, "version") && xmlDeclState == 0) - { - if (!isTextDecl) - { - attr = AddAttributeNoChecks("version", 1); - } - break; - } - goto default; - case 'e': - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos, "encoding") && - (xmlDeclState == 1 || (isTextDecl && xmlDeclState == 0))) - { - if (!isTextDecl) - { - attr = AddAttributeNoChecks("encoding", 1); - } - xmlDeclState = 1; - break; - } - goto default; - case 's': - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos, "standalone") && - (xmlDeclState == 1 || xmlDeclState == 2) && !isTextDecl) - { - if (!isTextDecl) - { - attr = AddAttributeNoChecks("standalone", 1); - } - xmlDeclState = 2; - break; - } - goto default; - default: - Throw(isTextDecl ? ResXml.Xml_InvalidTextDecl : ResXml.Xml_InvalidXmlDecl); - break; - } - if (!isTextDecl) - { - attr.SetLineInfo(_ps.LineNo, _ps.LinePos); - } - sb.Append(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); - _ps.charPos = nameEndPos; - - // parse equals and quote char; - if (_ps.chars[_ps.charPos] != '=') - { - EatWhitespaces(sb); - if (_ps.chars[_ps.charPos] != '=') - { - ThrowUnexpectedToken("="); - } - } - sb.Append('='); - _ps.charPos++; - - char quoteChar = _ps.chars[_ps.charPos]; - if (quoteChar != '"' && quoteChar != '\'') - { - EatWhitespaces(sb); - quoteChar = _ps.chars[_ps.charPos]; - if (quoteChar != '"' && quoteChar != '\'') - { - ThrowUnexpectedToken("\"", "'"); - } - } - sb.Append(quoteChar); - _ps.charPos++; - if (!isTextDecl) - { - attr.quoteChar = quoteChar; - attr.SetLineInfo2(_ps.LineNo, _ps.LinePos); - } - - // parse attribute value - int pos = _ps.charPos; - char[] chars; - Continue: - chars = _ps.chars; - unsafe - { - while (((_xmlCharType.charProperties[chars[pos]] & XmlCharType.fAttrValue) != 0)) - { - pos++; - } - } - - if (_ps.chars[pos] == quoteChar) - { - switch (xmlDeclState) - { - // version - case 0: -#if XML10_FIFTH_EDITION - // VersionNum ::= '1.' [0-9]+ (starting with XML Fifth Edition) - if ( pos - ps.charPos >= 3 && - ps.chars[ps.charPos] == '1' && - ps.chars[ps.charPos + 1] == '.' && - XmlCharType.IsOnlyDigits( ps.chars, ps.charPos + 2, pos - ps.charPos - 2 ) ) { -#else - // VersionNum ::= '1.0' (XML Fourth Edition and earlier) - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "1.0")) - { -#endif - if (!isTextDecl) - { - attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); - } - xmlDeclState = 1; - } - else - { - string badVersion = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); - Throw(ResXml.Xml_InvalidVersionNumber, badVersion); - } - break; - case 1: - string encName = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); - encoding = CheckEncoding(encName); - if (!isTextDecl) - { - attr.SetValue(encName); - } - xmlDeclState = 2; - break; - case 2: - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "yes")) - { - _standalone = true; - } - else if (XmlConvert.StrEqual(_ps.chars, _ps.charPos, pos - _ps.charPos, "no")) - { - _standalone = false; - } - else - { - Debug.Assert(!isTextDecl); - Throw(ResXml.Xml_InvalidXmlDecl, _ps.LineNo, _ps.LinePos - 1); - } - if (!isTextDecl) - { - attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); - } - xmlDeclState = 3; - break; - default: - Debug.Assert(false); - break; - } - sb.Append(chars, _ps.charPos, pos - _ps.charPos); - sb.Append(quoteChar); - _ps.charPos = pos + 1; - continue; - } - else if (pos == _ps.charsUsed) - { - if (ReadData() != 0) - { - goto Continue; - } - else - { - Throw(ResXml.Xml_UnclosedQuote); - } - } - else - { - Throw(isTextDecl ? ResXml.Xml_InvalidTextDecl : ResXml.Xml_InvalidXmlDecl); - } - - ReadData: - if (_ps.isEof || ReadData() == 0) - { - Throw(ResXml.Xml_UnexpectedEOF1); - } - } - - NoXmlDecl: - // no xml declaration - if (!isTextDecl) - { - _parsingFunction = _nextParsingFunction; - } - if (_afterResetState) - { - // check for invalid encoding switches to default encoding - string encodingName = _ps.encoding.WebName; - if (encodingName != "utf-8" && encodingName != "utf-16" && - encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) - { - Throw(ResXml.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); - } - } - if (_ps.decoder is SafeAsciiDecoder) - { - SwitchEncodingToUTF8(); - } - _ps.appendMode = false; - return false; - } - - // Parses the document content - private bool ParseDocumentContent() - { - bool mangoQuirks = false; -#if FEATURE_LEGACYNETCF - // Dev11 447539 quirk: - // In Mango the default XmlTextReader is instantiated - // with v1Compat flag set to true. One of the effects - // of this settings is to eat any trailing nulls in the - // buffer and some apps depend on this behavior. - if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) - mangoQuirks = true; -#endif - for (; ; ) - { - bool needMoreChars = false; - int pos = _ps.charPos; - char[] chars = _ps.chars; - - // some tag - if (chars[pos] == '<') - { - needMoreChars = true; - if (_ps.charsUsed - pos < 4) // minimum "" - goto ReadData; - pos++; - switch (chars[pos]) - { - // processing instruction - case '?': - _ps.charPos = pos + 1; - if (ParsePI()) - { - return true; - } - continue; - case '!': - pos++; - if (_ps.charsUsed - pos < 2) // minimum characters expected "--" - goto ReadData; - // comment - if (chars[pos] == '-') - { - if (chars[pos + 1] == '-') - { - _ps.charPos = pos + 2; - if (ParseComment()) - { - return true; - } - continue; - } - else - { - ThrowUnexpectedToken(pos + 1, "-"); - } - } - // CDATA section - else if (chars[pos] == '[') - { - if (_fragmentType != XmlNodeType.Document) - { - pos++; - if (_ps.charsUsed - pos < 6) - { - goto ReadData; - } - if (XmlConvert.StrEqual(chars, pos, 6, "CDATA[")) - { - _ps.charPos = pos + 6; - ParseCData(); - if (_fragmentType == XmlNodeType.None) - { - _fragmentType = XmlNodeType.Element; - } - return true; - } - else - { - ThrowUnexpectedToken(pos, "CDATA["); - } - } - else - { - Throw(_ps.charPos, ResXml.Xml_InvalidRootData); - } - } - // DOCTYPE declaration - else - { - if (_fragmentType == XmlNodeType.Document || _fragmentType == XmlNodeType.None) - { - _fragmentType = XmlNodeType.Document; - _ps.charPos = pos; - if (ParseDoctypeDecl()) - { - return true; - } - continue; - } - else - { - if (ParseUnexpectedToken(pos) == "DOCTYPE") - { - Throw(ResXml.Xml_BadDTDLocation); - } - else - { - ThrowUnexpectedToken(pos, "")); - _ps.charPos -= 3; - _incReadState = IncrementalReadState.Text; - } - goto Append; - case IncrementalReadState.CDATA: - if (ParseCDataOrComment(XmlNodeType.CDATA, out startPos, out pos)) - { - Debug.Assert(XmlConvert.StrEqual(_ps.chars, _ps.charPos - 3, 3, "]]>")); - _ps.charPos -= 3; - _incReadState = IncrementalReadState.Text; - } - goto Append; - case IncrementalReadState.EndElement: - _parsingFunction = ParsingFunction.PopElementContext; - _nextParsingFunction = (_index > 0 || _fragmentType != XmlNodeType.Document) ? ParsingFunction.ElementContent - : ParsingFunction.DocumentContent; - _outerReader.Read(); - _incReadState = IncrementalReadState.End; - goto case IncrementalReadState.End; - case IncrementalReadState.End: - return charsDecoded; - case IncrementalReadState.ReadData: - if (ReadData() == 0) - { - ThrowUnclosedElements(); - } - _incReadState = IncrementalReadState.Text; - startPos = _ps.charPos; - pos = startPos; - break; - default: - Debug.Assert(false); - break; - } - Debug.Assert(_incReadState == IncrementalReadState.Text || - _incReadState == IncrementalReadState.Attributes || - _incReadState == IncrementalReadState.AttributeValue); - - char[] chars = _ps.chars; - startPos = _ps.charPos; - pos = startPos; - - for (; ; ) - { - _incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); - - char c; - unsafe - { - if (_incReadState == IncrementalReadState.Attributes) - { - while (((_xmlCharType.charProperties[c = chars[pos]] & XmlCharType.fAttrValue) != 0) && c != '/') - { - pos++; - } - } - else - { - while (((_xmlCharType.charProperties[c = chars[pos]] & XmlCharType.fAttrValue) != 0)) - { - pos++; - } - } - } - - if (chars[pos] == '&' || chars[pos] == (char)0x9) - { - pos++; - continue; - } - - if (pos - startPos > 0) - { - goto AppendAndUpdateCharPos; - } - - switch (chars[pos]) - { - // eol - case (char)0xA: - pos++; - OnNewLine(pos); - continue; - case (char)0xD: - if (chars[pos + 1] == (char)0xA) - { - pos += 2; - } - else if (pos + 1 < _ps.charsUsed) - { - pos++; - } - else - { - goto ReadData; - } - OnNewLine(pos); - continue; - // some tag - case '<': - if (_incReadState != IncrementalReadState.Text) - { - pos++; - continue; - } - if (_ps.charsUsed - pos < 2) - { - goto ReadData; - } - switch (chars[pos + 1]) - { - // pi - case '?': - pos += 2; - _incReadState = IncrementalReadState.PI; - goto AppendAndUpdateCharPos; - // comment - case '!': - if (_ps.charsUsed - pos < 4) - { - goto ReadData; - } - if (chars[pos + 2] == '-' && chars[pos + 3] == '-') - { - pos += 4; - _incReadState = IncrementalReadState.Comment; - goto AppendAndUpdateCharPos; - } - if (_ps.charsUsed - pos < 9) - { - goto ReadData; - } - if (XmlConvert.StrEqual(chars, pos + 2, 7, "[CDATA[")) - { - pos += 9; - _incReadState = IncrementalReadState.CDATA; - goto AppendAndUpdateCharPos; - } - else - { - ;//Throw( ); - } - break; - // end tag - case '/': - { - Debug.Assert(_ps.charPos - pos == 0); - Debug.Assert(_ps.charPos - startPos == 0); - - int colonPos; - // ParseQName can flush the buffer, so we need to update the startPos, pos and chars after calling it - int endPos = ParseQName(true, 2, out colonPos); - if (XmlConvert.StrEqual(chars, _ps.charPos + 2, endPos - _ps.charPos - 2, _curNode.GetNameWPrefix(_nameTable)) && - (_ps.chars[endPos] == '>' || _xmlCharType.IsWhiteSpace(_ps.chars[endPos]))) - { - if (--_incReadDepth > 0) - { - pos = endPos + 1; - continue; - } - - _ps.charPos = endPos; - if (_xmlCharType.IsWhiteSpace(_ps.chars[endPos])) - { - EatWhitespaces(null); - } - if (_ps.chars[_ps.charPos] != '>') - { - ThrowUnexpectedToken(">"); - } - _ps.charPos++; - - _incReadState = IncrementalReadState.EndElement; - goto OuterContinue; - } - else - { - pos = endPos; - startPos = _ps.charPos; - chars = _ps.chars; - continue; - } - } - // start tag - default: - { - Debug.Assert(_ps.charPos - pos == 0); - Debug.Assert(_ps.charPos - startPos == 0); - - int colonPos; - // ParseQName can flush the buffer, so we need to update the startPos, pos and chars after calling it - int endPos = ParseQName(true, 1, out colonPos); - if (XmlConvert.StrEqual(_ps.chars, _ps.charPos + 1, endPos - _ps.charPos - 1, _curNode.localName) && - (_ps.chars[endPos] == '>' || _ps.chars[endPos] == '/' || _xmlCharType.IsWhiteSpace(_ps.chars[endPos]))) - { - _incReadDepth++; - _incReadState = IncrementalReadState.Attributes; - pos = endPos; - goto AppendAndUpdateCharPos; - } - pos = endPos; - startPos = _ps.charPos; - chars = _ps.chars; - continue; - } - } - break; - // end of start tag - case '/': - if (_incReadState == IncrementalReadState.Attributes) - { - if (_ps.charsUsed - pos < 2) - { - goto ReadData; - } - if (chars[pos + 1] == '>') - { - _incReadState = IncrementalReadState.Text; - _incReadDepth--; - } - } - pos++; - continue; - // end of start tag - case '>': - if (_incReadState == IncrementalReadState.Attributes) - { - _incReadState = IncrementalReadState.Text; - } - pos++; - continue; - case '"': - case '\'': - switch (_incReadState) - { - case IncrementalReadState.AttributeValue: - if (chars[pos] == _curNode.quoteChar) - { - _incReadState = IncrementalReadState.Attributes; - } - break; - case IncrementalReadState.Attributes: - _curNode.quoteChar = chars[pos]; - _incReadState = IncrementalReadState.AttributeValue; - break; - } - pos++; - continue; - default: - // end of buffer - if (pos == _ps.charsUsed) - { - goto ReadData; - } - // surrogate chars or invalid chars are ignored - else - { - pos++; - continue; - } - } - } - - ReadData: - _incReadState = IncrementalReadState.ReadData; - - AppendAndUpdateCharPos: - _ps.charPos = pos; - - Append: - // decode characters - int charsParsed = pos - startPos; - if (charsParsed > 0) - { - int count; - try - { - count = _incReadDecoder.Decode(_ps.chars, startPos, charsParsed); - } - catch (XmlException e) - { - ReThrow(e, (int)_incReadLineInfo.lineNo, (int)_incReadLineInfo.linePos); - return 0; - } - Debug.Assert(count == charsParsed || _incReadDecoder.IsFull, "Check if decoded consumed all characters unless it's full."); - charsDecoded += count; - if (_incReadDecoder.IsFull) - { - _incReadLeftStartPos = startPos + count; - _incReadLeftEndPos = pos; - _incReadLineInfo.linePos += count; // we have never more than 1 line cached - return charsDecoded; - } - } - } - } - - private void FinishIncrementalRead() - { - _incReadDecoder = new IncrementalReadDummyDecoder(); - IncrementalRead(); - Debug.Assert(IncrementalRead() == 0, "Previous call of IncrementalRead should eat up all characters!"); - _incReadDecoder = null; - } - - private bool ParseFragmentAttribute() - { - Debug.Assert(_fragmentType == XmlNodeType.Attribute); - - // if first call then parse the whole attribute value - if (_curNode.type == XmlNodeType.None) - { - _curNode.type = XmlNodeType.Attribute; - _curAttrIndex = 0; - ParseAttributeValueSlow(_ps.charPos, ' ', _curNode); // The quote char is intentionally empty (space) because we need to parse ' and " into the attribute value - } - else - { - _parsingFunction = ParsingFunction.InReadAttributeValue; - } - - // return attribute value chunk - if (ReadAttributeValue()) - { - Debug.Assert(_parsingFunction == ParsingFunction.InReadAttributeValue); - _parsingFunction = ParsingFunction.FragmentAttribute; - return true; - } - else - { - OnEof(); - return false; - } - } - - - private bool ParseAttributeValueChunk() - { - char[] chars = _ps.chars; - int pos = _ps.charPos; - - _curNode = AddNode(_index + _attrCount + 1, _index + 2); - _curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); - - if (_emptyEntityInAttributeResolved) - { - _curNode.SetValueNode(XmlNodeType.Text, string.Empty); - _emptyEntityInAttributeResolved = false; - return true; - } - - Debug.Assert(_stringBuilder.Length == 0); - - for (; ; ) - { - unsafe - { - while (((_xmlCharType.charProperties[chars[pos]] & XmlCharType.fAttrValue) != 0)) - pos++; - } - - switch (chars[pos]) - { - // eol D - case (char)0xD: - Debug.Assert(_ps.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!"); - pos++; - continue; - // eol A, tab - case (char)0xA: - case (char)0x9: - if (_normalize) - { - chars[pos] = (char)0x20; // CDATA normalization of 0xA and 0x9 - } - pos++; - continue; - case '"': - case '\'': - case '>': - pos++; - continue; - // attribute values cannot contain '<' - case '<': - Throw(pos, ResXml.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0')); - break; - // entity reference - case '&': - if (pos - _ps.charPos > 0) - { - _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); - } - _ps.charPos = pos; - - // expand char entities but not general entities - switch (HandleEntityReference(true, EntityExpandType.OnlyCharacter, out pos)) - { - case EntityType.CharacterDec: - case EntityType.CharacterHex: - case EntityType.CharacterNamed: - chars = _ps.chars; - if (_normalize && _xmlCharType.IsWhiteSpace(chars[_ps.charPos]) && pos - _ps.charPos == 1) - { - chars[_ps.charPos] = (char)0x20; // CDATA normalization of character references in entities - } - break; - case EntityType.Unexpanded: - if (_stringBuilder.Length == 0) - { - _curNode.lineInfo.linePos++; - _ps.charPos++; - _curNode.SetNamedNode(XmlNodeType.EntityReference, ParseEntityName()); - return true; - } - else - { - goto ReturnText; - } - default: - Debug.Assert(false, "We should never get to this point."); - break; - } - chars = _ps.chars; - continue; - default: - // end of buffer - if (pos == _ps.charsUsed) - { - goto ReadData; - } - // surrogate chars - else - { - char ch = chars[pos]; - if (XmlCharType.IsHighSurrogate(ch)) - { - if (pos + 1 == _ps.charsUsed) - { - goto ReadData; - } - pos++; - if (XmlCharType.IsLowSurrogate(chars[pos])) - { - pos++; - continue; - } - } - ThrowInvalidChar(chars, _ps.charsUsed, pos); - break; - } - } - - ReadData: - if (pos - _ps.charPos > 0) - { - _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); - _ps.charPos = pos; - } - // read new characters into the buffer - if (ReadData() == 0) - { - if (_stringBuilder.Length > 0) - { - goto ReturnText; - } - else - { - if (HandleEntityEnd(false)) - { - SetupEndEntityNodeInAttribute(); - return true; - } - else - { - Debug.Assert(false, "We should never get to this point."); - } - } - } - - pos = _ps.charPos; - chars = _ps.chars; - } - - ReturnText: - if (pos - _ps.charPos > 0) - { - _stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); - _ps.charPos = pos; - } - _curNode.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString()); - _stringBuilder.Length = 0; - return true; - } - - private void ParseXmlDeclarationFragment() - { - try - { - ParseXmlDeclaration(false); - } - catch (XmlException e) - { - ReThrow(e, e.LineNumber, e.LinePosition - 6); // 6 == strlen( " create a new one - else if (nt == null) - { - nt = new NameTable(); - Debug.Assert(_nameTableFromSettings == false); - } - _nameTable = nt; - - // make sure we have namespace manager - if (_namespaceManager == null) - { - _namespaceManager = new XmlNamespaceManager(nt); - } - - // copy xml:space and xml:lang - _xmlContext.xmlSpace = context.XmlSpace; - _xmlContext.xmlLang = context.XmlLang; - } - - // - // DtdInfo - // - internal override IDtdInfo DtdInfo - { - get - { - return _dtdInfo; - } - } - - internal void SetDtdInfo(IDtdInfo newDtdInfo) - { - Debug.Assert(_dtdInfo == null); - - _dtdInfo = newDtdInfo; - if (_dtdInfo != null) - { - if ((_validatingReaderCompatFlag || !_v1Compat) && (_dtdInfo.HasDefaultAttributes || _dtdInfo.HasNonCDataAttributes)) - { - _addDefaultAttributesAndNormalize = true; - } - } - } - - // - // Validation support - // - - internal IValidationEventHandling ValidationEventHandling - { - set - { - _validationEventHandling = value; - } - } - - internal OnDefaultAttributeUseDelegate OnDefaultAttributeUse - { - set { _onDefaultAttributeUse = value; } - } - - // - // Internal properties for XmlValidatingReader - // - - internal bool XmlValidatingReaderCompatibilityMode - { - set - { - _validatingReaderCompatFlag = value; - - // Fix for VSWhidbey 516556; These namespaces must be added to the nametable for back compat reasons. - if (value) - { - _nameTable.Add(XmlReservedNs.NsXs); // Note: this is equal to XmlReservedNs.NsXsd in Everett - _nameTable.Add(XmlReservedNs.NsXsi); - _nameTable.Add(XmlReservedNs.NsDataType); - } - } - } - - internal XmlNodeType FragmentType - { - get - { - return _fragmentType; - } - } - - internal void ChangeCurrentNodeType(XmlNodeType newNodeType) - { - Debug.Assert(_curNode.type == XmlNodeType.Whitespace && newNodeType == XmlNodeType.SignificantWhitespace, "Incorrect node type change!"); - _curNode.type = newNodeType; - } - - internal XmlResolver GetResolver() - { - if (IsResolverNull) - return null; - else - return _xmlResolver; - } - - internal object InternalSchemaType - { - get - { - return _curNode.schemaType; - } - set - { - _curNode.schemaType = value; - } - } - - internal object InternalTypedValue - { - get - { - return _curNode.typedValue; - } - set - { - _curNode.typedValue = value; - } - } - - internal bool StandAlone - { - get - { - return _standalone; - } - } - - internal override XmlNamespaceManager NamespaceManager - { - get - { - return _namespaceManager; - } - } - - internal bool V1Compat - { - get - { - return _v1Compat; - } - } - - internal ConformanceLevel V1ComformanceLevel - { - get - { - return _fragmentType == XmlNodeType.Element ? ConformanceLevel.Fragment : ConformanceLevel.Document; - } - } - - private bool AddDefaultAttributeDtd(IDtdDefaultAttributeInfo defAttrInfo, bool definedInDtd, NodeData[] nameSortedNodeData) - { - if (defAttrInfo.Prefix.Length > 0) - { - _attrNeedNamespaceLookup = true; - } - - string localName = defAttrInfo.LocalName; - string prefix = defAttrInfo.Prefix; - - // check for duplicates - if (nameSortedNodeData != null) - { - if (Array.BinarySearch(nameSortedNodeData, defAttrInfo, DtdDefaultAttributeInfoToNodeDataComparer.Instance) >= 0) - { - return false; - } - } - else - { - for (int i = _index + 1; i < _index + 1 + _attrCount; i++) - { - if ((object)_nodes[i].localName == (object)localName && - (object)_nodes[i].prefix == (object)prefix) - { - return false; - } - } - } - - NodeData attr = AddDefaultAttributeInternal(defAttrInfo.LocalName, null, defAttrInfo.Prefix, defAttrInfo.DefaultValueExpanded, - defAttrInfo.LineNumber, defAttrInfo.LinePosition, - defAttrInfo.ValueLineNumber, defAttrInfo.ValueLinePosition, defAttrInfo.IsXmlAttribute); - - Debug.Assert(attr != null); - - if (DtdValidation) - { - if (_onDefaultAttributeUse != null) - { - _onDefaultAttributeUse(defAttrInfo, this); - } - attr.typedValue = defAttrInfo.DefaultValueTyped; - } - return attr != null; - } - - internal bool AddDefaultAttributeNonDtd(SchemaAttDef attrDef) - { - // atomize names - Xsd Validator does not need to have the same nametable - string localName = _nameTable.Add(attrDef.Name.Name); - string prefix = _nameTable.Add(attrDef.Prefix); - string ns = _nameTable.Add(attrDef.Name.Namespace); - - // atomize namespace - Xsd Validator does not need to have the same nametable - if (prefix.Length == 0 && ns.Length > 0) - { - prefix = _namespaceManager.LookupPrefix(ns); - - Debug.Assert(prefix != null); - if (prefix == null) - { - prefix = string.Empty; - } - } - - // find out if the attribute is already there - for (int i = _index + 1; i < _index + 1 + _attrCount; i++) - { - if ((object)_nodes[i].localName == (object)localName && - (((object)_nodes[i].prefix == (object)prefix) || ((object)_nodes[i].ns == (object)ns && ns != null))) - { - return false; - } - } - - // attribute does not exist -> we need to add it - NodeData attr = AddDefaultAttributeInternal(localName, ns, prefix, attrDef.DefaultValueExpanded, - attrDef.LineNumber, attrDef.LinePosition, - attrDef.ValueLineNumber, attrDef.ValueLinePosition, attrDef.Reserved != SchemaAttDef.Reserve.None); - Debug.Assert(attr != null); - - attr.schemaType = (attrDef.SchemaType == null) ? (object)attrDef.Datatype : (object)attrDef.SchemaType; - attr.typedValue = attrDef.DefaultValueTyped; - return true; - } - - private NodeData AddDefaultAttributeInternal(string localName, string ns, string prefix, string value, - int lineNo, int linePos, int valueLineNo, int valueLinePos, bool isXmlAttribute) - { - // setup the attribute - NodeData attr = AddAttribute(localName, prefix, prefix.Length > 0 ? null : localName); - if (ns != null) - { - attr.ns = ns; - } - - attr.SetValue(value); - attr.IsDefaultAttribute = true; - attr.lineInfo.Set(lineNo, linePos); - attr.lineInfo2.Set(valueLineNo, valueLinePos); - - // handle special attributes: - if (attr.prefix.Length == 0) - { - // default namespace declaration - if (Ref.Equal(attr.localName, _xmlNs)) - { - OnDefaultNamespaceDecl(attr); - if (!_attrNeedNamespaceLookup) - { - // change element default namespace - Debug.Assert(_nodes[_index].type == XmlNodeType.Element); - if (_nodes[_index].prefix.Length == 0) - { - _nodes[_index].ns = _xmlContext.defaultNamespace; - } - } - } - } - else - { - // prefixed namespace declaration - if (Ref.Equal(attr.prefix, _xmlNs)) - { - OnNamespaceDecl(attr); - if (!_attrNeedNamespaceLookup) - { - // change namespace of current element and attributes - string pref = attr.localName; - Debug.Assert(_nodes[_index].type == XmlNodeType.Element); - for (int i = _index; i < _index + _attrCount + 1; i++) - { - if (_nodes[i].prefix.Equals(pref)) - { - _nodes[i].ns = _namespaceManager.LookupNamespace(pref); - } - } - } - } - // xml: attribute - else - { - if (isXmlAttribute) - { - OnXmlReservedAttribute(attr); - } - } - } - - _fullAttrCleanup = true; - return attr; - } - - internal bool DisableUndeclaredEntityCheck - { - set - { - _disableUndeclaredEntityCheck = value; - } - } - - private int ReadContentAsBinary(byte[] buffer, int index, int count) - { - Debug.Assert(_incReadDecoder != null); - - if (_incReadState == IncrementalReadState.ReadContentAsBinary_End) - { - return 0; - } - - _incReadDecoder.SetNextOutputBuffer(buffer, index, count); - - for (; ; ) - { - // read what is already cached in curNode - int charsRead = 0; - try - { - charsRead = _curNode.CopyToBinary(_incReadDecoder, _readValueOffset); - } - // add line info to the exception - catch (XmlException e) - { - _curNode.AdjustLineInfo(_readValueOffset, _ps.eolNormalized, ref _incReadLineInfo); - ReThrow(e, _incReadLineInfo.lineNo, _incReadLineInfo.linePos); - } - _readValueOffset += charsRead; - - if (_incReadDecoder.IsFull) - { - return _incReadDecoder.DecodedCount; - } - - // if on partial value, read the rest of it - if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue) - { - _curNode.SetValue(string.Empty); - - // read next chunk of text - bool endOfValue = false; - int startPos = 0; - int endPos = 0; - while (!_incReadDecoder.IsFull && !endOfValue) - { - int orChars = 0; - - // store current line info and parse more text - _incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); - endOfValue = ParseText(out startPos, out endPos, ref orChars); - - try - { - charsRead = _incReadDecoder.Decode(_ps.chars, startPos, endPos - startPos); - } - // add line info to the exception - catch (XmlException e) - { - ReThrow(e, _incReadLineInfo.lineNo, _incReadLineInfo.linePos); - } - startPos += charsRead; - } - _incReadState = endOfValue ? IncrementalReadState.ReadContentAsBinary_OnCachedValue : IncrementalReadState.ReadContentAsBinary_OnPartialValue; - _readValueOffset = 0; - - if (_incReadDecoder.IsFull) - { - _curNode.SetValue(_ps.chars, startPos, endPos - startPos); - // adjust line info for the chunk that has been already decoded - AdjustLineInfo(_ps.chars, startPos - charsRead, startPos, _ps.eolNormalized, ref _incReadLineInfo); - _curNode.SetLineInfo(_incReadLineInfo.lineNo, _incReadLineInfo.linePos); - return _incReadDecoder.DecodedCount; - } - } - - // reset to normal state so we can call Read() to move forward - ParsingFunction tmp = _parsingFunction; - _parsingFunction = _nextParsingFunction; - _nextParsingFunction = _nextNextParsingFunction; - - // move to next textual node in the element content; throw on sub elements - if (!MoveToNextContentNode(true)) - { - SetupReadContentAsBinaryState(tmp); - _incReadState = IncrementalReadState.ReadContentAsBinary_End; - return _incReadDecoder.DecodedCount; - } - SetupReadContentAsBinaryState(tmp); - _incReadLineInfo.Set(_curNode.LineNo, _curNode.LinePos); - } - } - - private int ReadElementContentAsBinary(byte[] buffer, int index, int count) - { - if (count == 0) - { - return 0; - } - int decoded = ReadContentAsBinary(buffer, index, count); - if (decoded > 0) - { - return decoded; - } - - // if 0 bytes returned check if we are on a closing EndElement, throw exception if not - if (_curNode.type != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _curNode.type.ToString(), this as IXmlLineInfo); - } - - // reset state - _parsingFunction = _nextParsingFunction; - _nextParsingFunction = _nextNextParsingFunction; - Debug.Assert(_parsingFunction != ParsingFunction.InReadElementContentAsBinary); - - // move off the EndElement - _outerReader.Read(); - return 0; - } - - private void InitBase64Decoder() - { - if (_base64Decoder == null) - { - _base64Decoder = new Base64Decoder(); - } - else - { - _base64Decoder.Reset(); - } - _incReadDecoder = _base64Decoder; - } - - private void InitBinHexDecoder() - { - if (_binHexDecoder == null) - { - _binHexDecoder = new BinHexDecoder(); - } - else - { - _binHexDecoder.Reset(); - } - _incReadDecoder = _binHexDecoder; - } - - // SxS: URIs are resolved only to be compared. No resource exposure. It's OK to disable the SxS warning. - - - private bool UriEqual(Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver) - { - if (resolver == null) - { - return uri1Str == uri2Str; - } - if (uri1 == null) - { - uri1 = resolver.ResolveUri(null, uri1Str); - } - Uri uri2 = resolver.ResolveUri(null, uri2Str); - return uri1.Equals(uri2); - } - - /// - /// This method should be called every time the reader is about to consume some number of - /// characters from the input. It will count it agains the security counters and - /// may throw if some of the security limits are exceeded. - /// - /// Number of characters to be consumed. - /// true if the characters are result of entity expansion. - private void RegisterConsumedCharacters(long characters, bool inEntityReference) - { - Debug.Assert(characters >= 0); - if (_maxCharactersInDocument > 0) - { - long newCharactersInDocument = _charactersInDocument + characters; - if (newCharactersInDocument < _charactersInDocument) - { - // Integer overflow while counting - ThrowWithoutLineInfo(ResXml.Xml_LimitExceeded, "MaxCharactersInDocument"); - } - else - { - _charactersInDocument = newCharactersInDocument; - } - if (_charactersInDocument > _maxCharactersInDocument) - { - // The limit was exceeded for the total number of characters in the document - ThrowWithoutLineInfo(ResXml.Xml_LimitExceeded, "MaxCharactersInDocument"); - } - } - - if (_maxCharactersFromEntities > 0 && inEntityReference) - { - long newCharactersFromEntities = _charactersFromEntities + characters; - if (newCharactersFromEntities < _charactersFromEntities) - { - // Integer overflow while counting - ThrowWithoutLineInfo(ResXml.Xml_LimitExceeded, "MaxCharactersFromEntities"); - } - else - { - _charactersFromEntities = newCharactersFromEntities; - } - if (_charactersFromEntities > _maxCharactersFromEntities) - { - // The limit was exceeded for the number of characters from entities - ThrowWithoutLineInfo(ResXml.Xml_LimitExceeded, "MaxCharactersFromEntities"); - } - } - } - - static internal unsafe void AdjustLineInfo(char[] chars, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo) - { - Debug.Assert(startPos >= 0); - Debug.Assert(endPos < chars.Length); - Debug.Assert(startPos <= endPos); - - fixed (char* pChars = &chars[startPos]) - { - AdjustLineInfo(pChars, endPos - startPos, isNormalized, ref lineInfo); - } - } - - static internal unsafe void AdjustLineInfo(string str, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo) - { - Debug.Assert(startPos >= 0); - Debug.Assert(endPos < str.Length); - Debug.Assert(startPos <= endPos); - - fixed (char* pChars = str) - { - AdjustLineInfo(pChars + startPos, endPos - startPos, isNormalized, ref lineInfo); - } - } - - static internal unsafe void AdjustLineInfo(char* pChars, int length, bool isNormalized, ref LineInfo lineInfo) - { - int lastNewLinePos = -1; - for (int i = 0; i < length; i++) - { - switch (pChars[i]) - { - case '\n': - lineInfo.lineNo++; - lastNewLinePos = i; - break; - case '\r': - if (isNormalized) - { - break; - } - lineInfo.lineNo++; - lastNewLinePos = i; - if (i + 1 < length && pChars[i + 1] == '\n') - { - i++; - lastNewLinePos++; - } - break; - } - } - if (lastNewLinePos >= 0) - { - lineInfo.linePos = length - lastNewLinePos; - } - } - - // StripSpaces removes spaces at the beginning and at the end of the value and replaces sequences of spaces with a single space - internal static string StripSpaces(string value) - { - int len = value.Length; - if (len <= 0) - { - return string.Empty; - } - - int startPos = 0; - StringBuilder norValue = null; - - while (value[startPos] == 0x20) - { - startPos++; - if (startPos == len) - { - return " "; - } - } - - int i; - for (i = startPos; i < len; i++) - { - if (value[i] == 0x20) - { - int j = i + 1; - while (j < len && value[j] == 0x20) - { - j++; - } - if (j == len) - { - if (norValue == null) - { - return value.Substring(startPos, i - startPos); - } - else - { - norValue.Append(value, startPos, i - startPos); - return norValue.ToString(); - } - } - if (j > i + 1) - { - if (norValue == null) - { - norValue = new StringBuilder(len); - } - norValue.Append(value, startPos, i - startPos + 1); - startPos = j; - i = j - 1; - } - } - } - if (norValue == null) - { - return (startPos == 0) ? value : value.Substring(startPos, len - startPos); - } - else - { - if (i > startPos) - { - norValue.Append(value, startPos, i - startPos); - } - return norValue.ToString(); - } - } - - // StripSpaces removes spaces at the beginning and at the end of the value and replaces sequences of spaces with a single space - internal static void StripSpaces(char[] value, int index, ref int len) - { - if (len <= 0) - { - return; - } - - int startPos = index; - int endPos = index + len; - - while (value[startPos] == 0x20) - { - startPos++; - if (startPos == endPos) - { - len = 1; - return; - } - } - - int offset = startPos - index; - int i; - for (i = startPos; i < endPos; i++) - { - char ch; - if ((ch = value[i]) == 0x20) - { - int j = i + 1; - while (j < endPos && value[j] == 0x20) - { - j++; - } - if (j == endPos) - { - offset += (j - i); - break; - } - if (j > i + 1) - { - offset += (j - i - 1); - i = j - 1; - } - } - value[i - offset] = ch; - } - len -= offset; - } - - internal static void BlockCopyChars(char[] src, int srcOffset, char[] dst, int dstOffset, int count) - { - // PERF: Buffer.BlockCopy is faster than Array.Copy - Buffer.BlockCopy(src, srcOffset * sizeof(char), dst, dstOffset * sizeof(char), count * sizeof(char)); - } - - internal static void BlockCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) - { - Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImplHelpers.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImplHelpers.cs deleted file mode 100644 index 4ca57ffdee4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextReaderImplHelpers.cs +++ /dev/null @@ -1,802 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using System.Security; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -using System.Collections.Generic; -using System.Runtime.Versioning; - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlTextReaderImpl - { - // - // ParsingState - // - // Parsing state (aka. scanner data) - holds parsing buffer and entity input data information - private struct ParsingState - { - // character buffer - internal char[] chars; - internal int charPos; - internal int charsUsed; - internal Encoding encoding; - internal bool appendMode; - - // input stream & byte buffer - internal Stream stream; - internal Decoder decoder; - internal byte[] bytes; - internal int bytePos; - internal int bytesUsed; - - // input text reader - internal TextReader textReader; - - // current line number & position - internal int lineNo; - internal int lineStartPos; - - // base uri of the current entity - internal string baseUriStr; - internal Uri baseUri; - - // eof flag of the entity - internal bool isEof; - internal bool isStreamEof; - - // entity type & id - internal IDtdEntityInfo entity; - internal int entityId; - - // normalization - internal bool eolNormalized; - - // EndEntity reporting - internal bool entityResolvedManually; - - internal void Clear() - { - chars = null; - charPos = 0; - charsUsed = 0; - encoding = null; - stream = null; - decoder = null; - bytes = null; - bytePos = 0; - bytesUsed = 0; - textReader = null; - lineNo = 1; - lineStartPos = -1; - baseUriStr = string.Empty; - baseUri = null; - isEof = false; - isStreamEof = false; - eolNormalized = true; - entityResolvedManually = false; - } - - internal void Close(bool closeInput) - { - if (closeInput) - { - if (stream != null) - { - stream.Close(); - } - else if (textReader != null) - { - textReader.Dispose(); - } - } - } - - internal int LineNo - { - get - { - return lineNo; - } - } - - internal int LinePos - { - get - { - return charPos - lineStartPos; - } - } - } - - // - // XmlContext - // - private class XmlContext - { - internal XmlSpace xmlSpace; - internal string xmlLang; - internal string defaultNamespace; - internal XmlContext previousContext; - - internal XmlContext() - { - xmlSpace = XmlSpace.None; - xmlLang = string.Empty; - defaultNamespace = string.Empty; - previousContext = null; - } - - internal XmlContext(XmlContext previousContext) - { - this.xmlSpace = previousContext.xmlSpace; - this.xmlLang = previousContext.xmlLang; - this.defaultNamespace = previousContext.defaultNamespace; - this.previousContext = previousContext; - } - } - - // - // NoNamespaceManager - // - private class NoNamespaceManager : XmlNamespaceManager - { - public NoNamespaceManager() : base() { } - public override string DefaultNamespace { get { return string.Empty; } } - public override void PushScope() { } - public override bool PopScope() { return false; } - public override void AddNamespace(string prefix, string uri) { } - public override void RemoveNamespace(string prefix, string uri) { } - public override IEnumerator GetEnumerator() { return null; } - public override IDictionary GetNamespacesInScope(XmlNamespaceScope scope) { return null; } - public override string LookupNamespace(string prefix) { return string.Empty; } - public override string LookupPrefix(string uri) { return null; } - public override bool HasNamespace(string prefix) { return false; } - } - - // - // DtdParserProxy: IDtdParserAdapter proxy for XmlTextReaderImpl - // - internal partial class DtdParserProxy : IDtdParserAdapterV1 - { - - // Fields - private XmlTextReaderImpl _reader; - - // Constructors - internal DtdParserProxy(XmlTextReaderImpl reader) - { - _reader = reader; - } - - // IDtdParserAdapter proxies - XmlNameTable IDtdParserAdapter.NameTable - { - get { return _reader.DtdParserProxy_NameTable; } - } - - IXmlNamespaceResolver IDtdParserAdapter.NamespaceResolver - { - get { return _reader.DtdParserProxy_NamespaceResolver; } - } - - Uri IDtdParserAdapter.BaseUri - { - // SxS: DtdParserProxy_BaseUri property on the reader may expose machine scope resources. This property - // is just returning the value of the other property, so it may expose machine scope resource as well. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - get { return _reader.DtdParserProxy_BaseUri; } - } - - bool IDtdParserAdapter.IsEof - { - get { return _reader.DtdParserProxy_IsEof; } - } - - char[] IDtdParserAdapter.ParsingBuffer - { - get { return _reader.DtdParserProxy_ParsingBuffer; } - } - - int IDtdParserAdapter.ParsingBufferLength - { - get { return _reader.DtdParserProxy_ParsingBufferLength; } - } - - int IDtdParserAdapter.CurrentPosition - { - get { return _reader.DtdParserProxy_CurrentPosition; } - set { _reader.DtdParserProxy_CurrentPosition = value; } - } - - int IDtdParserAdapter.EntityStackLength - { - get { return _reader.DtdParserProxy_EntityStackLength; } - } - - bool IDtdParserAdapter.IsEntityEolNormalized - { - get { return _reader.DtdParserProxy_IsEntityEolNormalized; } - } - - void IDtdParserAdapter.OnNewLine(int pos) - { - _reader.DtdParserProxy_OnNewLine(pos); - } - - int IDtdParserAdapter.LineNo - { - get { return _reader.DtdParserProxy_LineNo; } - } - - int IDtdParserAdapter.LineStartPosition - { - get { return _reader.DtdParserProxy_LineStartPosition; } - } - - int IDtdParserAdapter.ReadData() - { - return _reader.DtdParserProxy_ReadData(); - } - - int IDtdParserAdapter.ParseNumericCharRef(BufferBuilder internalSubsetBuilder) - { - return _reader.DtdParserProxy_ParseNumericCharRef(internalSubsetBuilder); - } - - int IDtdParserAdapter.ParseNamedCharRef(bool expand, BufferBuilder internalSubsetBuilder) - { - return _reader.DtdParserProxy_ParseNamedCharRef(expand, internalSubsetBuilder); - } - - void IDtdParserAdapter.ParsePI(BufferBuilder sb) - { - _reader.DtdParserProxy_ParsePI(sb); - } - - void IDtdParserAdapter.ParseComment(BufferBuilder sb) - { - _reader.DtdParserProxy_ParseComment(sb); - } - - bool IDtdParserAdapter.PushEntity(IDtdEntityInfo entity, out int entityId) - { - return _reader.DtdParserProxy_PushEntity(entity, out entityId); - } - - bool IDtdParserAdapter.PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId) - { - return _reader.DtdParserProxy_PopEntity(out oldEntity, out newEntityId); - } - - bool IDtdParserAdapter.PushExternalSubset(string systemId, string publicId) - { - return _reader.DtdParserProxy_PushExternalSubset(systemId, publicId); - } - - void IDtdParserAdapter.PushInternalDtd(string baseUri, string internalDtd) - { - Debug.Assert(internalDtd != null); - _reader.DtdParserProxy_PushInternalDtd(baseUri, internalDtd); - } - - void IDtdParserAdapter.Throw(Exception e) - { - _reader.DtdParserProxy_Throw(e); - } - - void IDtdParserAdapter.OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo) - { - _reader.DtdParserProxy_OnSystemId(systemId, keywordLineInfo, systemLiteralLineInfo); - } - - void IDtdParserAdapter.OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo) - { - _reader.DtdParserProxy_OnPublicId(publicId, keywordLineInfo, publicLiteralLineInfo); - } - - bool IDtdParserAdapterWithValidation.DtdValidation - { - get { return _reader.DtdParserProxy_DtdValidation; } - } - - IValidationEventHandling IDtdParserAdapterWithValidation.ValidationEventHandling - { - get { return _reader.DtdParserProxy_ValidationEventHandling; } - } - - bool IDtdParserAdapterV1.Normalization - { - get { return _reader.DtdParserProxy_Normalization; } - } - - bool IDtdParserAdapterV1.Namespaces - { - get { return _reader.DtdParserProxy_Namespaces; } - } - - bool IDtdParserAdapterV1.V1CompatibilityMode - { - get { return _reader.DtdParserProxy_V1CompatibilityMode; } - } - - } - - // - // NodeData - // - private class NodeData : IComparable - { - // static instance with no data - is used when XmlTextReader is closed - private static volatile NodeData s_None; - - // NOTE: Do not use this property for reference comparison. It may not be unique. - internal static NodeData None - { - get - { - if (s_None == null) - { - // no locking; s_None is immutable so it's not a problem that it may get initialized more than once - s_None = new NodeData(); - } - return s_None; - } - } - - // type - internal XmlNodeType type; - - // name - internal string localName; - internal string prefix; - internal string ns; - internal string nameWPrefix; - - // value: - // value == null -> the value is kept in the 'chars' buffer starting at valueStartPos and valueLength long - private string _value; - private char[] _chars; - private int _valueStartPos; - private int _valueLength; - - // main line info - internal LineInfo lineInfo; - - // second line info - internal LineInfo lineInfo2; - - // quote char for attributes - internal char quoteChar; - - // depth - internal int depth; - - // empty element / default attribute - private bool _isEmptyOrDefault; - - // entity id - internal int entityId; - - // helper members - internal bool xmlContextPushed; - - // attribute value chunks - internal NodeData nextAttrValueChunk; - - // type info - internal object schemaType; - internal object typedValue; - - internal NodeData() - { - Clear(XmlNodeType.None); - xmlContextPushed = false; - } - - internal int LineNo - { - get - { - return lineInfo.lineNo; - } - } - - internal int LinePos - { - get - { - return lineInfo.linePos; - } - } - - internal bool IsEmptyElement - { - get - { - return type == XmlNodeType.Element && _isEmptyOrDefault; - } - set - { - Debug.Assert(type == XmlNodeType.Element); - _isEmptyOrDefault = value; - } - } - - internal bool IsDefaultAttribute - { - get - { - return type == XmlNodeType.Attribute && _isEmptyOrDefault; - } - set - { - Debug.Assert(type == XmlNodeType.Attribute); - _isEmptyOrDefault = value; - } - } - - internal bool ValueBuffered - { - get - { - return _value == null; - } - } - - internal string StringValue - { - get - { - Debug.Assert(_valueStartPos >= 0 || _value != null, "Value not ready."); - - if (_value == null) - { - _value = new string(_chars, _valueStartPos, _valueLength); - } - return _value; - } - } - - internal void TrimSpacesInValue() - { - if (ValueBuffered) - { - XmlTextReaderImpl.StripSpaces(_chars, _valueStartPos, ref _valueLength); - } - else - { - _value = XmlTextReaderImpl.StripSpaces(_value); - } - } - - internal void Clear(XmlNodeType type) - { - this.type = type; - ClearName(); - _value = string.Empty; - _valueStartPos = -1; - nameWPrefix = string.Empty; - schemaType = null; - typedValue = null; - } - - internal void ClearName() - { - localName = string.Empty; - prefix = string.Empty; - ns = string.Empty; - nameWPrefix = string.Empty; - } - - internal void SetLineInfo(int lineNo, int linePos) - { - lineInfo.Set(lineNo, linePos); - } - - internal void SetLineInfo2(int lineNo, int linePos) - { - lineInfo2.Set(lineNo, linePos); - } - - internal void SetValueNode(XmlNodeType type, string value) - { - Debug.Assert(value != null); - - this.type = type; - ClearName(); - _value = value; - _valueStartPos = -1; - } - - internal void SetValueNode(XmlNodeType type, char[] chars, int startPos, int len) - { - this.type = type; - ClearName(); - - _value = null; - _chars = chars; - _valueStartPos = startPos; - _valueLength = len; - } - - internal void SetNamedNode(XmlNodeType type, string localName) - { - SetNamedNode(type, localName, string.Empty, localName); - } - - internal void SetNamedNode(XmlNodeType type, string localName, string prefix, string nameWPrefix) - { - Debug.Assert(localName != null); - Debug.Assert(localName.Length > 0); - - this.type = type; - this.localName = localName; - this.prefix = prefix; - this.nameWPrefix = nameWPrefix; - this.ns = string.Empty; - _value = string.Empty; - _valueStartPos = -1; - } - - internal void SetValue(string value) - { - _valueStartPos = -1; - _value = value; - } - - internal void SetValue(char[] chars, int startPos, int len) - { - _value = null; - _chars = chars; - _valueStartPos = startPos; - _valueLength = len; - } - - internal void OnBufferInvalidated() - { - if (_value == null) - { - Debug.Assert(_valueStartPos != -1); - Debug.Assert(_chars != null); - _value = new string(_chars, _valueStartPos, _valueLength); - } - _valueStartPos = -1; - } - - internal void CopyTo(int valueOffset, BufferBuilder sb) - { - if (_value == null) - { - Debug.Assert(_valueStartPos != -1); - Debug.Assert(_chars != null); - sb.Append(_chars, _valueStartPos + valueOffset, _valueLength - valueOffset); - } - else - { - if (valueOffset <= 0) - { - sb.Append(_value); - } - else - { - sb.Append(_value, valueOffset, _value.Length - valueOffset); - } - } - } - - internal int CopyTo(int valueOffset, char[] buffer, int offset, int length) - { - if (_value == null) - { - Debug.Assert(_valueStartPos != -1); - Debug.Assert(_chars != null); - int copyCount = _valueLength - valueOffset; - if (copyCount > length) - { - copyCount = length; - } - XmlTextReaderImpl.BlockCopyChars(_chars, _valueStartPos + valueOffset, buffer, offset, copyCount); - return copyCount; - } - else - { - int copyCount = _value.Length - valueOffset; - if (copyCount > length) - { - copyCount = length; - } - _value.CopyTo(valueOffset, buffer, offset, copyCount); - return copyCount; - } - } - - internal int CopyToBinary(IncrementalReadDecoder decoder, int valueOffset) - { - if (_value == null) - { - Debug.Assert(_valueStartPos != -1); - Debug.Assert(_chars != null); - return decoder.Decode(_chars, _valueStartPos + valueOffset, _valueLength - valueOffset); - } - else - { - return decoder.Decode(_value, valueOffset, _value.Length - valueOffset); - } - } - - internal void AdjustLineInfo(int valueOffset, bool isNormalized, ref LineInfo lineInfo) - { - if (valueOffset == 0) - { - return; - } - if (_valueStartPos != -1) - { - XmlTextReaderImpl.AdjustLineInfo(_chars, _valueStartPos, _valueStartPos + valueOffset, isNormalized, ref lineInfo); - } - else - { - XmlTextReaderImpl.AdjustLineInfo(_value, 0, valueOffset, isNormalized, ref lineInfo); - } - } - - // This should be inlined by JIT compiler - internal string GetNameWPrefix(XmlNameTable nt) - { - if (nameWPrefix != null) - { - return nameWPrefix; - } - else - { - return CreateNameWPrefix(nt); - } - } - - internal string CreateNameWPrefix(XmlNameTable nt) - { - Debug.Assert(nameWPrefix == null); - if (prefix.Length == 0) - { - nameWPrefix = localName; - } - else - { - nameWPrefix = nt.Add(string.Concat(prefix, ":", localName)); - } - return nameWPrefix; - } - - int IComparable.CompareTo(object obj) - { - NodeData other = obj as NodeData; - if (other != null) - { - if (Ref.Equal(localName, other.localName)) - { - if (Ref.Equal(ns, other.ns)) - { - return 0; - } - else - { - return string.CompareOrdinal(ns, other.ns); - } - } - else - { - return string.CompareOrdinal(localName, other.localName); - } - } - else - { - Debug.Assert(false, "We should never get to this point."); - // 'other' is null, 'this' is not null. Always return 1, like "".CompareTo(null). - return 1; - } - } - } - - // - // DtdDefaultAttributeInfoToNodeDataComparer - // - // Compares IDtdDefaultAttributeInfo to NodeData - private class DtdDefaultAttributeInfoToNodeDataComparer : IComparer - { - private static IComparer s_instance = new DtdDefaultAttributeInfoToNodeDataComparer(); - - internal static IComparer Instance - { - get { return s_instance; } - } - - public int Compare(object x, object y) - { - Debug.Assert(x == null || x is NodeData || x is IDtdDefaultAttributeInfo); - Debug.Assert(y == null || y is NodeData || y is IDtdDefaultAttributeInfo); - - string localName, localName2; - string prefix, prefix2; - - if (x == null) - { - return y == null ? 0 : -1; - } - else if (y == null) - { - return 1; - } - - NodeData nodeData = x as NodeData; - if (nodeData != null) - { - localName = nodeData.localName; - prefix = nodeData.prefix; - } - else - { - IDtdDefaultAttributeInfo attrDef = x as IDtdDefaultAttributeInfo; - if (attrDef != null) - { - localName = attrDef.LocalName; - prefix = attrDef.Prefix; - } - else - { - throw new XmlException(ResXml.Xml_DefaultException, string.Empty); - } - } - - nodeData = y as NodeData; - if (nodeData != null) - { - localName2 = nodeData.localName; - prefix2 = nodeData.prefix; - } - else - { - IDtdDefaultAttributeInfo attrDef = y as IDtdDefaultAttributeInfo; - if (attrDef != null) - { - localName2 = attrDef.LocalName; - prefix2 = attrDef.Prefix; - } - else - { - throw new XmlException(ResXml.Xml_DefaultException, string.Empty); - } - } - - // string.Compare does reference euqality first for us, so we don't have to do it here - int result = string.Compare(localName, localName2, StringComparison.Ordinal); - if (result != 0) - { - return result; - } - - return string.Compare(prefix, prefix2, StringComparison.Ordinal); - } - } - - // - // OnDefaultAttributeUse delegate - // - internal delegate void OnDefaultAttributeUseDelegate(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader); - - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextWriter.cs deleted file mode 100644 index f61a04a047f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlTextWriter.cs +++ /dev/null @@ -1,1753 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - // Specifies formatting options for XmlTextWriter. - public enum Formatting - { - // No special formatting is done (this is the default). - None, - - //This option causes child elements to be indented using the Indentation and IndentChar properties. - // It only indents Element Content (http://www.w3.org/TR/1998/REC-xml-19980210#sec-element-content) - // and not Mixed Content (http://www.w3.org/TR/1998/REC-xml-19980210#sec-mixed-content) - // according to the XML 1.0 definitions of these terms. - Indented, - }; - - // Represents a writer that provides fast non-cached forward-only way of generating XML streams - // containing XML documents that conform to the W3CExtensible Markup Language (XML) 1.0 specification - // and the Namespaces in XML specification. - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public class XmlTextWriter : XmlWriter - { - // - // Private types - // - private enum NamespaceState - { - Uninitialized, - NotDeclaredButInScope, - DeclaredButNotWrittenOut, - DeclaredAndWrittenOut - } - - private struct TagInfo - { - internal string name; - internal string prefix; - internal string defaultNs; - internal NamespaceState defaultNsState; - internal XmlSpace xmlSpace; - internal string xmlLang; - internal int prevNsTop; - internal int prefixCount; - internal bool mixed; // whether to pretty print the contents of this element. - - internal void Init(int nsTop) - { - name = null; - defaultNs = String.Empty; - defaultNsState = NamespaceState.Uninitialized; - xmlSpace = XmlSpace.None; - xmlLang = null; - prevNsTop = nsTop; - prefixCount = 0; - mixed = false; - } - } - - private struct Namespace - { - internal string prefix; - internal string ns; - internal bool declared; - internal int prevNsIndex; - - internal void Set(string prefix, string ns, bool declared) - { - this.prefix = prefix; - this.ns = ns; - this.declared = declared; - this.prevNsIndex = -1; - } - } - - private enum SpecialAttr - { - None, - XmlSpace, - XmlLang, - XmlNs - }; - - // State machine is working through autocomplete - private enum State - { - Start, - Prolog, - PostDTD, - Element, - Attribute, - Content, - AttrOnly, - Epilog, - Error, - Closed, - } - - private enum Token - { - PI, - Doctype, - Comment, - CData, - StartElement, - EndElement, - LongEndElement, - StartAttribute, - EndAttribute, - Content, - Base64, - RawData, - Whitespace, - Empty - } - - // - // Fields - // - // output - private TextWriter _textWriter; - private XmlTextEncoder _xmlEncoder; - private Encoding _encoding; - - // formatting - private Formatting _formatting; - private bool _indented; // perf - faster to check a boolean. - private int _indentation; - private char _indentChar; - - // element stack - private TagInfo[] _stack; - private int _top; - - // state machine for AutoComplete - private State[] _stateTable; - private State _currentState; - private Token _lastToken; - - // Base64 content - private XmlTextWriterBase64Encoder _base64Encoder; - - // misc - private char _quoteChar; - private char _curQuoteChar; - private bool _namespaces; - private SpecialAttr _specialAttr; - private string _prefixForXmlNs; - private bool _flush; - - // namespaces - private Namespace[] _nsStack; - private int _nsTop; - private Dictionary _nsHashtable; - private bool _useNsHashtable; - - // char types - private XmlCharType _xmlCharType = XmlCharType.Instance; - - // - // Constants and constant tables - // - private const int NamespaceStackInitialSize = 8; -#if DEBUG - private const int MaxNamespacesWalkCount = 3; -#else - private const int MaxNamespacesWalkCount = 16; -#endif - - private static string[] s_stateName = { - "Start", - "Prolog", - "PostDTD", - "Element", - "Attribute", - "Content", - "AttrOnly", - "Epilog", - "Error", - "Closed", - }; - - private static string[] s_tokenName = { - "PI", - "Doctype", - "Comment", - "CData", - "StartElement", - "EndElement", - "LongEndElement", - "StartAttribute", - "EndAttribute", - "Content", - "Base64", - "RawData", - "Whitespace", - "Empty" - }; - - private static readonly State[] s_stateTableDefault = { - // State.Start State.Prolog State.PostDTD State.Element State.Attribute State.Content State.AttrOnly State.Epilog - // - /* Token.PI */ State.Prolog, State.Prolog, State.PostDTD, State.Content, State.Content, State.Content, State.Error, State.Epilog, - /* Token.Doctype */ State.PostDTD, State.PostDTD, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Comment */ State.Prolog, State.Prolog, State.PostDTD, State.Content, State.Content, State.Content, State.Error, State.Epilog, - /* Token.CData */ State.Content, State.Content, State.Error, State.Content, State.Content, State.Content, State.Error, State.Epilog, - /* Token.StartElement */ State.Element, State.Element, State.Element, State.Element, State.Element, State.Element, State.Error, State.Element, - /* Token.EndElement */ State.Error, State.Error, State.Error, State.Content, State.Content, State.Content, State.Error, State.Error, - /* Token.LongEndElement */ State.Error, State.Error, State.Error, State.Content, State.Content, State.Content, State.Error, State.Error, - /* Token.StartAttribute */ State.AttrOnly, State.Error, State.Error, State.Attribute, State.Attribute, State.Error, State.Error, State.Error, - /* Token.EndAttribute */ State.Error, State.Error, State.Error, State.Error, State.Element, State.Error, State.Epilog, State.Error, - /* Token.Content */ State.Content, State.Content, State.Error, State.Content, State.Attribute, State.Content, State.Attribute, State.Epilog, - /* Token.Base64 */ State.Content, State.Content, State.Error, State.Content, State.Attribute, State.Content, State.Attribute, State.Epilog, - /* Token.RawData */ State.Prolog, State.Prolog, State.PostDTD, State.Content, State.Attribute, State.Content, State.Attribute, State.Epilog, - /* Token.Whitespace */ State.Prolog, State.Prolog, State.PostDTD, State.Content, State.Attribute, State.Content, State.Attribute, State.Epilog, - }; - - private static readonly State[] s_stateTableDocument = { - // State.Start State.Prolog State.PostDTD State.Element State.Attribute State.Content State.AttrOnly State.Epilog - // - /* Token.PI */ State.Error, State.Prolog, State.PostDTD, State.Content, State.Content, State.Content, State.Error, State.Epilog, - /* Token.Doctype */ State.Error, State.PostDTD, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Comment */ State.Error, State.Prolog, State.PostDTD, State.Content, State.Content, State.Content, State.Error, State.Epilog, - /* Token.CData */ State.Error, State.Error, State.Error, State.Content, State.Content, State.Content, State.Error, State.Error, - /* Token.StartElement */ State.Error, State.Element, State.Element, State.Element, State.Element, State.Element, State.Error, State.Error, - /* Token.EndElement */ State.Error, State.Error, State.Error, State.Content, State.Content, State.Content, State.Error, State.Error, - /* Token.LongEndElement */ State.Error, State.Error, State.Error, State.Content, State.Content, State.Content, State.Error, State.Error, - /* Token.StartAttribute */ State.Error, State.Error, State.Error, State.Attribute, State.Attribute, State.Error, State.Error, State.Error, - /* Token.EndAttribute */ State.Error, State.Error, State.Error, State.Error, State.Element, State.Error, State.Error, State.Error, - /* Token.Content */ State.Error, State.Error, State.Error, State.Content, State.Attribute, State.Content, State.Error, State.Error, - /* Token.Base64 */ State.Error, State.Error, State.Error, State.Content, State.Attribute, State.Content, State.Error, State.Error, - /* Token.RawData */ State.Error, State.Prolog, State.PostDTD, State.Content, State.Attribute, State.Content, State.Error, State.Epilog, - /* Token.Whitespace */ State.Error, State.Prolog, State.PostDTD, State.Content, State.Attribute, State.Content, State.Error, State.Epilog, - }; - - // - // Constructors - // - internal XmlTextWriter() - { - _namespaces = true; - _formatting = Formatting.None; - _indentation = 2; - _indentChar = ' '; - // namespaces - _nsStack = new Namespace[NamespaceStackInitialSize]; - _nsTop = -1; - // element stack - _stack = new TagInfo[10]; - _top = 0;// 0 is an empty sentanial element - _stack[_top].Init(-1); - _quoteChar = '"'; - - _stateTable = s_stateTableDefault; - _currentState = State.Start; - _lastToken = Token.Empty; - } - - // Creates an instance of the XmlTextWriter class using the specified stream. - public XmlTextWriter(Stream w, Encoding encoding) : this() - { - _encoding = encoding; - if (encoding != null) - _textWriter = new StreamWriter(w, encoding); - else - _textWriter = new StreamWriter(w); - _xmlEncoder = new XmlTextEncoder(_textWriter); - _xmlEncoder.QuoteChar = _quoteChar; - } - - // Creates an instance of the XmlTextWriter class using the specified file. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlTextWriter(String filename, Encoding encoding) - : this(new FileStream(filename, FileMode.Create, - FileAccess.Write, FileShare.Read), encoding) - { - } - - // Creates an instance of the XmlTextWriter class using the specified TextWriter. - public XmlTextWriter(TextWriter w) : this() - { - _textWriter = w; - - _encoding = w.Encoding; - _xmlEncoder = new XmlTextEncoder(w); - _xmlEncoder.QuoteChar = _quoteChar; - } - - // - // XmlTextWriter properties - // - // Gets the XmlTextWriter base stream. - public Stream BaseStream - { - get - { - StreamWriter streamWriter = _textWriter as StreamWriter; - return (streamWriter == null ? null : streamWriter.BaseStream); - } - } - - // Gets or sets a value indicating whether to do namespace support. - public bool Namespaces - { - get { return _namespaces; } - set - { - if (_currentState != State.Start) - throw new InvalidOperationException(ResXml.Xml_NotInWriteState); - - _namespaces = value; - } - } - - // Indicates how the output is formatted. - public Formatting Formatting - { - get { return _formatting; } - set { _formatting = value; _indented = value == Formatting.Indented; } - } - - // Gets or sets how many IndentChars to write for each level in the hierarchy when Formatting is set to "Indented". - public int Indentation - { - get { return _indentation; } - set - { - if (value < 0) - throw new ArgumentException(ResXml.Xml_InvalidIndentation); - _indentation = value; - } - } - - // Gets or sets which character to use for indenting when Formatting is set to "Indented". - public char IndentChar - { - get { return _indentChar; } - set { _indentChar = value; } - } - - // Gets or sets which character to use to quote attribute values. - public char QuoteChar - { - get { return _quoteChar; } - set - { - if (value != '"' && value != '\'') - { - throw new ArgumentException(ResXml.Xml_InvalidQuote); - } - _quoteChar = value; - _xmlEncoder.QuoteChar = value; - } - } - - // - // XmlWriter implementation - // - // Writes out the XML declaration with the version "1.0". - public override void WriteStartDocument() - { - StartDocument(-1); - } - - // Writes out the XML declaration with the version "1.0" and the standalone attribute. - public override void WriteStartDocument(bool standalone) - { - StartDocument(standalone ? 1 : 0); - } - - // Closes any open elements or attributes and puts the writer back in the Start state. - public override void WriteEndDocument() - { - try - { - AutoCompleteAll(); - if (_currentState != State.Epilog) - { - if (_currentState == State.Closed) - { - throw new ArgumentException(ResXml.Xml_ClosedOrError); - } - else - { - throw new ArgumentException(ResXml.Xml_NoRoot); - } - } - _stateTable = s_stateTableDefault; - _currentState = State.Start; - _lastToken = Token.Empty; - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the DOCTYPE declaration with the specified name and optional attributes. - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - try - { - ValidateName(name, false); - - AutoComplete(Token.Doctype); - _textWriter.Write("'); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the specified start tag and associates it with the given namespace and prefix. - public override void WriteStartElement(string prefix, string localName, string ns) - { - try - { - AutoComplete(Token.StartElement); - PushStack(); - _textWriter.Write('<'); - - if (_namespaces) - { - // Propagate default namespace and mix model down the stack. - _stack[_top].defaultNs = _stack[_top - 1].defaultNs; - if (_stack[_top - 1].defaultNsState != NamespaceState.Uninitialized) - _stack[_top].defaultNsState = NamespaceState.NotDeclaredButInScope; - _stack[_top].mixed = _stack[_top - 1].mixed; - if (ns == null) - { - // use defined prefix - if (prefix != null && prefix.Length != 0 && (LookupNamespace(prefix) == -1)) - { - throw new ArgumentException(ResXml.Xml_UndefPrefix); - } - } - else - { - if (prefix == null) - { - string definedPrefix = FindPrefix(ns); - if (definedPrefix != null) - { - prefix = definedPrefix; - } - else - { - PushNamespace(null, ns, false); // new default - } - } - else if (prefix.Length == 0) - { - PushNamespace(null, ns, false); // new default - } - else - { - if (ns.Length == 0) - { - prefix = null; - } - VerifyPrefixXml(prefix, ns); - PushNamespace(prefix, ns, false); // define - } - } - _stack[_top].prefix = null; - if (prefix != null && prefix.Length != 0) - { - _stack[_top].prefix = prefix; - _textWriter.Write(prefix); - _textWriter.Write(':'); - } - } - else - { - if ((ns != null && ns.Length != 0) || (prefix != null && prefix.Length != 0)) - { - throw new ArgumentException(ResXml.Xml_NoNamespaces); - } - } - _stack[_top].name = localName; - _textWriter.Write(localName); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Closes one element and pops the corresponding namespace scope. - public override void WriteEndElement() - { - InternalWriteEndElement(false); - } - - // Closes one element and pops the corresponding namespace scope. - public override void WriteFullEndElement() - { - InternalWriteEndElement(true); - } - - // Writes the start of an attribute. - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - try - { - AutoComplete(Token.StartAttribute); - - _specialAttr = SpecialAttr.None; - if (_namespaces) - { - if (prefix != null && prefix.Length == 0) - { - prefix = null; - } - - if (ns == XmlReservedNs.NsXmlNs && prefix == null && localName != "xmlns") - { - prefix = "xmlns"; - } - - if (prefix == "xml") - { - if (localName == "lang") - { - _specialAttr = SpecialAttr.XmlLang; - } - else if (localName == "space") - { - _specialAttr = SpecialAttr.XmlSpace; - } - /* bug54408. to be fwd compatible we need to treat xml prefix as reserved - and not really insist on a specific value. Who knows in the future it - might be OK to say xml:blabla - else { - throw new ArgumentException(Res.GetString(Res.Xml_InvalidPrefix)); - }*/ - } - else if (prefix == "xmlns") - { - if (XmlReservedNs.NsXmlNs != ns && ns != null) - { - throw new ArgumentException(ResXml.Xml_XmlnsBelongsToReservedNs); - } - if (localName == null || localName.Length == 0) - { - localName = prefix; - prefix = null; - _prefixForXmlNs = null; - } - else - { - _prefixForXmlNs = localName; - } - _specialAttr = SpecialAttr.XmlNs; - } - else if (prefix == null && localName == "xmlns") - { - if (XmlReservedNs.NsXmlNs != ns && ns != null) - { - // add the below line back in when DOM is fixed - throw new ArgumentException(ResXml.Xml_XmlnsBelongsToReservedNs); - } - _specialAttr = SpecialAttr.XmlNs; - _prefixForXmlNs = null; - } - else - { - if (ns == null) - { - // use defined prefix - if (prefix != null && (LookupNamespace(prefix) == -1)) - { - throw new ArgumentException(ResXml.Xml_UndefPrefix); - } - } - else if (ns.Length == 0) - { - // empty namespace require null prefix - prefix = string.Empty; - } - else - { // ns.Length != 0 - VerifyPrefixXml(prefix, ns); - if (prefix != null && LookupNamespaceInCurrentScope(prefix) != -1) - { - prefix = null; - } - // Now verify prefix validity - string definedPrefix = FindPrefix(ns); - if (definedPrefix != null && (prefix == null || prefix == definedPrefix)) - { - prefix = definedPrefix; - } - else - { - if (prefix == null) - { - prefix = GeneratePrefix(); // need a prefix if - } - PushNamespace(prefix, ns, false); - } - } - } - if (prefix != null && prefix.Length != 0) - { - _textWriter.Write(prefix); - _textWriter.Write(':'); - } - } - else - { - if ((ns != null && ns.Length != 0) || (prefix != null && prefix.Length != 0)) - { - throw new ArgumentException(ResXml.Xml_NoNamespaces); - } - if (localName == "xml:lang") - { - _specialAttr = SpecialAttr.XmlLang; - } - else if (localName == "xml:space") - { - _specialAttr = SpecialAttr.XmlSpace; - } - } - _xmlEncoder.StartAttribute(_specialAttr != SpecialAttr.None); - - _textWriter.Write(localName); - _textWriter.Write('='); - if (_curQuoteChar != _quoteChar) - { - _curQuoteChar = _quoteChar; - _xmlEncoder.QuoteChar = _quoteChar; - } - _textWriter.Write(_curQuoteChar); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Closes the attribute opened by WriteStartAttribute. - public override void WriteEndAttribute() - { - try - { - AutoComplete(Token.EndAttribute); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out a <![CDATA[...]]> block containing the specified text. - public override void WriteCData(string text) - { - try - { - AutoComplete(Token.CData); - if (null != text && text.IndexOf("]]>", StringComparison.Ordinal) >= 0) - { - throw new ArgumentException(ResXml.Xml_InvalidCDataChars); - } - _textWriter.Write(""); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out a comment containing the specified text. - public override void WriteComment(string text) - { - try - { - if (null != text && (text.IndexOf("--", StringComparison.Ordinal) >= 0 || (text.Length != 0 && text[text.Length - 1] == '-'))) - { - throw new ArgumentException(ResXml.Xml_InvalidCommentChars); - } - AutoComplete(Token.Comment); - _textWriter.Write(""); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out a processing instruction with a space between the name and text as follows: - public override void WriteProcessingInstruction(string name, string text) - { - try - { - if (null != text && text.IndexOf("?>", StringComparison.Ordinal) >= 0) - { - throw new ArgumentException(ResXml.Xml_InvalidPiChars); - } - if (0 == String.Compare(name, "xml", StringComparison.OrdinalIgnoreCase) && _stateTable == s_stateTableDocument) - { - throw new ArgumentException(ResXml.Xml_DupXmlDecl); - } - AutoComplete(Token.PI); - InternalWriteProcessingInstruction(name, text); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out an entity reference as follows: "&"+name+";". - public override void WriteEntityRef(string name) - { - try - { - ValidateName(name, false); - AutoComplete(Token.Content); - _xmlEncoder.WriteEntityRef(name); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Forces the generation of a character entity for the specified Unicode character value. - public override void WriteCharEntity(char ch) - { - try - { - AutoComplete(Token.Content); - _xmlEncoder.WriteCharEntity(ch); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the given whitespace. - public override void WriteWhitespace(string ws) - { - try - { - if (null == ws) - { - ws = String.Empty; - } - - if (!_xmlCharType.IsOnlyWhitespace(ws)) - { - throw new ArgumentException(ResXml.Xml_NonWhitespace); - } - AutoComplete(Token.Whitespace); - _xmlEncoder.Write(ws); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the specified text content. - public override void WriteString(string text) - { - try - { - if (null != text && text.Length != 0) - { - AutoComplete(Token.Content); - _xmlEncoder.Write(text); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the specified surrogate pair as a character entity. - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - try - { - AutoComplete(Token.Content); - _xmlEncoder.WriteSurrogateCharEntity(lowChar, highChar); - } - catch - { - _currentState = State.Error; - throw; - } - } - - - // Writes out the specified text content. - public override void WriteChars(Char[] buffer, int index, int count) - { - try - { - AutoComplete(Token.Content); - _xmlEncoder.Write(buffer, index, count); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes raw markup from the specified character buffer. - public override void WriteRaw(Char[] buffer, int index, int count) - { - try - { - AutoComplete(Token.RawData); - _xmlEncoder.WriteRaw(buffer, index, count); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes raw markup from the specified character string. - public override void WriteRaw(String data) - { - try - { - AutoComplete(Token.RawData); - _xmlEncoder.WriteRawWithSurrogateChecking(data); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Encodes the specified binary bytes as base64 and writes out the resulting text. - public override void WriteBase64(byte[] buffer, int index, int count) - { - try - { - if (!_flush) - { - AutoComplete(Token.Base64); - } - - _flush = true; - // No need for us to explicitly validate the args. The StreamWriter will do - // it for us. - if (null == _base64Encoder) - { - _base64Encoder = new XmlTextWriterBase64Encoder(_xmlEncoder); - } - // Encode will call WriteRaw to write out the encoded characters - _base64Encoder.Encode(buffer, index, count); - } - catch - { - _currentState = State.Error; - throw; - } - } - - - // Encodes the specified binary bytes as binhex and writes out the resulting text. - public override void WriteBinHex(byte[] buffer, int index, int count) - { - try - { - AutoComplete(Token.Content); - BinHexEncoder.Encode(buffer, index, count, this); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Returns the state of the XmlWriter. - public override WriteState WriteState - { - get - { - switch (_currentState) - { - case State.Start: - return WriteState.Start; - case State.Prolog: - case State.PostDTD: - return WriteState.Prolog; - case State.Element: - return WriteState.Element; - case State.Attribute: - case State.AttrOnly: - return WriteState.Attribute; - case State.Content: - case State.Epilog: - return WriteState.Content; - case State.Error: - return WriteState.Error; - case State.Closed: - return WriteState.Closed; - default: - Debug.Assert(false); - return WriteState.Error; - } - } - } - - // Closes the XmlWriter and the underlying stream/TextWriter. - public override void Close() - { - try - { - AutoCompleteAll(); - } - catch - { // never fail - } - finally - { - _currentState = State.Closed; - _textWriter.Dispose(); - } - } - - // Flushes whatever is in the buffer to the underlying stream/TextWriter and flushes the underlying stream/TextWriter. - public override void Flush() - { - _textWriter.Flush(); - } - - // Writes out the specified name, ensuring it is a valid Name according to the XML specification - // (http://www.w3.org/TR/1998/REC-xml-19980210#NT-Name - public override void WriteName(string name) - { - try - { - AutoComplete(Token.Content); - InternalWriteName(name, false); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Writes out the specified namespace-qualified name by looking up the prefix that is in scope for the given namespace. - public override void WriteQualifiedName(string localName, string ns) - { - try - { - AutoComplete(Token.Content); - if (_namespaces) - { - if (ns != null && ns.Length != 0 && ns != _stack[_top].defaultNs) - { - string prefix = FindPrefix(ns); - if (prefix == null) - { - if (_currentState != State.Attribute) - { - throw new ArgumentException(string.Format(ResXml.Xml_UndefNamespace, ns)); - } - prefix = GeneratePrefix(); // need a prefix if - PushNamespace(prefix, ns, false); - } - if (prefix.Length != 0) - { - InternalWriteName(prefix, true); - _textWriter.Write(':'); - } - } - } - else if (ns != null && ns.Length != 0) - { - throw new ArgumentException(ResXml.Xml_NoNamespaces); - } - InternalWriteName(localName, true); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // Returns the closest prefix defined in the current namespace scope for the specified namespace URI. - public override string LookupPrefix(string ns) - { - if (ns == null || ns.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - string s = FindPrefix(ns); - if (s == null && ns == _stack[_top].defaultNs) - { - s = string.Empty; - } - return s; - } - - // Gets an XmlSpace representing the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - for (int i = _top; i > 0; i--) - { - XmlSpace xs = _stack[i].xmlSpace; - if (xs != XmlSpace.None) - return xs; - } - return XmlSpace.None; - } - } - - // Gets the current xml:lang scope. - public override string XmlLang - { - get - { - for (int i = _top; i > 0; i--) - { - String xlang = _stack[i].xmlLang; - if (xlang != null) - return xlang; - } - return null; - } - } - - // Writes out the specified name, ensuring it is a valid NmToken - // according to the XML specification (http://www.w3.org/TR/1998/REC-xml-19980210#NT-Name). - public override void WriteNmToken(string name) - { - try - { - AutoComplete(Token.Content); - - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - if (!ValidateNames.IsNmtokenNoNamespaces(name)) - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidNameChars, name)); - } - _textWriter.Write(name); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // - // Private implementation methods - // - private void StartDocument(int standalone) - { - try - { - if (_currentState != State.Start) - { - throw new InvalidOperationException(ResXml.Xml_NotTheFirst); - } - _stateTable = s_stateTableDocument; - _currentState = State.Prolog; - - StringBuilder bufBld = new StringBuilder(128); - bufBld.Append("version=" + _quoteChar + "1.0" + _quoteChar); - if (_encoding != null) - { - bufBld.Append(" encoding="); - bufBld.Append(_quoteChar); - bufBld.Append(_encoding.WebName); - bufBld.Append(_quoteChar); - } - if (standalone >= 0) - { - bufBld.Append(" standalone="); - bufBld.Append(_quoteChar); - bufBld.Append(standalone == 0 ? "no" : "yes"); - bufBld.Append(_quoteChar); - } - InternalWriteProcessingInstruction("xml", bufBld.ToString()); - } - catch - { - _currentState = State.Error; - throw; - } - } - - private void AutoComplete(Token token) - { - if (_currentState == State.Closed) - { - throw new InvalidOperationException(ResXml.Xml_Closed); - } - else if (_currentState == State.Error) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_WrongToken, s_tokenName[(int)token], s_stateName[(int)State.Error])); - } - - State newState = _stateTable[(int)token * 8 + (int)_currentState]; - if (newState == State.Error) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_WrongToken, s_tokenName[(int)token], s_stateName[(int)_currentState])); - } - - switch (token) - { - case Token.Doctype: - if (_indented && _currentState != State.Start) - { - Indent(false); - } - break; - - case Token.StartElement: - case Token.Comment: - case Token.PI: - case Token.CData: - if (_currentState == State.Attribute) - { - WriteEndAttributeQuote(); - WriteEndStartTag(false); - } - else if (_currentState == State.Element) - { - WriteEndStartTag(false); - } - if (token == Token.CData) - { - _stack[_top].mixed = true; - } - else if (_indented && _currentState != State.Start) - { - Indent(false); - } - break; - - case Token.EndElement: - case Token.LongEndElement: - if (_flush) - { - FlushEncoders(); - } - if (_currentState == State.Attribute) - { - WriteEndAttributeQuote(); - } - if (_currentState == State.Content) - { - token = Token.LongEndElement; - } - else - { - WriteEndStartTag(token == Token.EndElement); - } - if (s_stateTableDocument == _stateTable && _top == 1) - { - newState = State.Epilog; - } - break; - - case Token.StartAttribute: - if (_flush) - { - FlushEncoders(); - } - if (_currentState == State.Attribute) - { - WriteEndAttributeQuote(); - _textWriter.Write(' '); - } - else if (_currentState == State.Element) - { - _textWriter.Write(' '); - } - break; - - case Token.EndAttribute: - if (_flush) - { - FlushEncoders(); - } - WriteEndAttributeQuote(); - break; - - case Token.Whitespace: - case Token.Content: - case Token.RawData: - case Token.Base64: - - if (token != Token.Base64 && _flush) - { - FlushEncoders(); - } - if (_currentState == State.Element && _lastToken != Token.Content) - { - WriteEndStartTag(false); - } - if (newState == State.Content) - { - _stack[_top].mixed = true; - } - break; - - default: - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - _currentState = newState; - _lastToken = token; - } - - private void AutoCompleteAll() - { - if (_flush) - { - FlushEncoders(); - } - while (_top > 0) - { - WriteEndElement(); - } - } - - private void InternalWriteEndElement(bool longFormat) - { - try - { - if (_top <= 0) - { - throw new InvalidOperationException(ResXml.Xml_NoStartTag); - } - // if we are in the element, we need to close it. - AutoComplete(longFormat ? Token.LongEndElement : Token.EndElement); - if (_lastToken == Token.LongEndElement) - { - if (_indented) - { - Indent(true); - } - _textWriter.Write('<'); - _textWriter.Write('/'); - if (_namespaces && _stack[_top].prefix != null) - { - _textWriter.Write(_stack[_top].prefix); - _textWriter.Write(':'); - } - _textWriter.Write(_stack[_top].name); - _textWriter.Write('>'); - } - - // pop namespaces - int prevNsTop = _stack[_top].prevNsTop; - if (_useNsHashtable && prevNsTop < _nsTop) - { - PopNamespaces(prevNsTop + 1, _nsTop); - } - _nsTop = prevNsTop; - _top--; - } - catch - { - _currentState = State.Error; - throw; - } - } - - private void WriteEndStartTag(bool empty) - { - _xmlEncoder.StartAttribute(false); - for (int i = _nsTop; i > _stack[_top].prevNsTop; i--) - { - if (!_nsStack[i].declared) - { - _textWriter.Write(" xmlns"); - _textWriter.Write(':'); - _textWriter.Write(_nsStack[i].prefix); - _textWriter.Write('='); - _textWriter.Write(_quoteChar); - _xmlEncoder.Write(_nsStack[i].ns); - _textWriter.Write(_quoteChar); - } - } - // Default - if ((_stack[_top].defaultNs != _stack[_top - 1].defaultNs) && - (_stack[_top].defaultNsState == NamespaceState.DeclaredButNotWrittenOut)) - { - _textWriter.Write(" xmlns"); - _textWriter.Write('='); - _textWriter.Write(_quoteChar); - _xmlEncoder.Write(_stack[_top].defaultNs); - _textWriter.Write(_quoteChar); - _stack[_top].defaultNsState = NamespaceState.DeclaredAndWrittenOut; - } - _xmlEncoder.EndAttribute(); - if (empty) - { - _textWriter.Write(" /"); - } - _textWriter.Write('>'); - } - - private void WriteEndAttributeQuote() - { - if (_specialAttr != SpecialAttr.None) - { - // Ok, now to handle xmlspace, etc. - HandleSpecialAttribute(); - } - _xmlEncoder.EndAttribute(); - _textWriter.Write(_curQuoteChar); - } - - private void Indent(bool beforeEndElement) - { - // pretty printing. - if (_top == 0) - { - _textWriter.WriteLine(); - } - else if (!_stack[_top].mixed) - { - _textWriter.WriteLine(); - int i = beforeEndElement ? _top - 1 : _top; - for (i *= _indentation; i > 0; i--) - { - _textWriter.Write(_indentChar); - } - } - } - - // pushes new namespace scope, and returns generated prefix, if one - // was needed to resolve conflicts. - private void PushNamespace(string prefix, string ns, bool declared) - { - if (XmlReservedNs.NsXmlNs == ns) - { - throw new ArgumentException(ResXml.Xml_CanNotBindToReservedNamespace); - } - - if (prefix == null) - { - switch (_stack[_top].defaultNsState) - { - case NamespaceState.DeclaredButNotWrittenOut: - Debug.Assert(declared == true, "Unexpected situation!!"); - // the first namespace that the user gave us is what we - // like to keep. - break; - case NamespaceState.Uninitialized: - case NamespaceState.NotDeclaredButInScope: - // we now got a brand new namespace that we need to remember - _stack[_top].defaultNs = ns; - break; - default: - Debug.Assert(false, "Should have never come here"); - return; - } - _stack[_top].defaultNsState = (declared ? NamespaceState.DeclaredAndWrittenOut : NamespaceState.DeclaredButNotWrittenOut); - } - else - { - if (prefix.Length != 0 && ns.Length == 0) - { - throw new ArgumentException(ResXml.Xml_PrefixForEmptyNs); - } - - int existingNsIndex = LookupNamespace(prefix); - if (existingNsIndex != -1 && _nsStack[existingNsIndex].ns == ns) - { - // it is already in scope. - if (declared) - { - _nsStack[existingNsIndex].declared = true; - } - } - else - { - // see if prefix conflicts for the current element - if (declared) - { - if (existingNsIndex != -1 && existingNsIndex > _stack[_top].prevNsTop) - { - _nsStack[existingNsIndex].declared = true; // old one is silenced now - } - } - AddNamespace(prefix, ns, declared); - } - } - } - - private void AddNamespace(string prefix, string ns, bool declared) - { - int nsIndex = ++_nsTop; - if (nsIndex == _nsStack.Length) - { - Namespace[] newStack = new Namespace[nsIndex * 2]; - Array.Copy(_nsStack, newStack, nsIndex); - _nsStack = newStack; - } - _nsStack[nsIndex].Set(prefix, ns, declared); - - if (_useNsHashtable) - { - AddToNamespaceHashtable(nsIndex); - } - else if (nsIndex == MaxNamespacesWalkCount) - { - // add all - _nsHashtable = new Dictionary(new SecureStringHasher()); - for (int i = 0; i <= nsIndex; i++) - { - AddToNamespaceHashtable(i); - } - _useNsHashtable = true; - } - } - - private void AddToNamespaceHashtable(int namespaceIndex) - { - string prefix = _nsStack[namespaceIndex].prefix; - int existingNsIndex; - if (_nsHashtable.TryGetValue(prefix, out existingNsIndex)) - { - _nsStack[namespaceIndex].prevNsIndex = existingNsIndex; - } - _nsHashtable[prefix] = namespaceIndex; - } - - private void PopNamespaces(int indexFrom, int indexTo) - { - Debug.Assert(_useNsHashtable); - for (int i = indexTo; i >= indexFrom; i--) - { - Debug.Assert(_nsHashtable.ContainsKey(_nsStack[i].prefix)); - if (_nsStack[i].prevNsIndex == -1) - { - _nsHashtable.Remove(_nsStack[i].prefix); - } - else - { - _nsHashtable[_nsStack[i].prefix] = _nsStack[i].prevNsIndex; - } - } - } - - private string GeneratePrefix() - { - int temp = _stack[_top].prefixCount++ + 1; - return "d" + _top.ToString("d", CultureInfo.InvariantCulture) - + "p" + temp.ToString("d", CultureInfo.InvariantCulture); - } - - private void InternalWriteProcessingInstruction(string name, string text) - { - _textWriter.Write(""); - } - - private int LookupNamespace(string prefix) - { - if (_useNsHashtable) - { - int nsIndex; - if (_nsHashtable.TryGetValue(prefix, out nsIndex)) - { - return nsIndex; - } - } - else - { - for (int i = _nsTop; i >= 0; i--) - { - if (_nsStack[i].prefix == prefix) - { - return i; - } - } - } - return -1; - } - - private int LookupNamespaceInCurrentScope(string prefix) - { - if (_useNsHashtable) - { - int nsIndex; - if (_nsHashtable.TryGetValue(prefix, out nsIndex)) - { - if (nsIndex > _stack[_top].prevNsTop) - { - return nsIndex; - } - } - } - else - { - for (int i = _nsTop; i > _stack[_top].prevNsTop; i--) - { - if (_nsStack[i].prefix == prefix) - { - return i; - } - } - } - return -1; - } - - private string FindPrefix(string ns) - { - for (int i = _nsTop; i >= 0; i--) - { - if (_nsStack[i].ns == ns) - { - if (LookupNamespace(_nsStack[i].prefix) == i) - { - return _nsStack[i].prefix; - } - } - } - return null; - } - - // There are three kind of strings we write out - Name, LocalName and Prefix. - // Both LocalName and Prefix can be represented with NCName == false and Name - // can be represented as NCName == true - - private void InternalWriteName(string name, bool isNCName) - { - ValidateName(name, isNCName); - _textWriter.Write(name); - } - - // This method is used for validation of the DOCTYPE, processing instruction and entity names plus names - // written out by the user via WriteName and WriteQualifiedName. - // Unfortunatelly the names of elements and attributes are not validated by the XmlTextWriter. - // Also this method does not check wheather the character after ':' is a valid start name character. It accepts - // all valid name characters at that position. This can't be changed because of backwards compatibility. - private unsafe void ValidateName(string name, bool isNCName) - { - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - - int nameLength = name.Length; - - // Namespaces supported - if (_namespaces) - { - // We can't use ValidateNames.ParseQName here because of backwards compatibility bug we need to preserve. - // The bug is that the character after ':' is validated only as a NCName characters instead of NCStartName. - int colonPosition = -1; - - // Parse NCName (may be prefix, may be local name) - int position = ValidateNames.ParseNCName(name); - - Continue: - if (position == nameLength) - { - return; - } - - // we have prefix:localName - if (name[position] == ':') - { - if (!isNCName) - { - // first colon in qname - if (colonPosition == -1) - { - // make sure it is not the first or last characters - if (position > 0 && position + 1 < nameLength) - { - colonPosition = position; - // Because of the back-compat bug (described above) parse the rest as Nmtoken - position++; - position += ValidateNames.ParseNmtoken(name, position); - goto Continue; - } - } - } - } - } - // Namespaces not supported - else - { - if (ValidateNames.IsNameNoNamespaces(name)) - { - return; - } - } - throw new ArgumentException(string.Format(ResXml.Xml_InvalidNameChars, name)); - } - - private void HandleSpecialAttribute() - { - string value = _xmlEncoder.AttributeValue; - switch (_specialAttr) - { - case SpecialAttr.XmlLang: - _stack[_top].xmlLang = value; - break; - case SpecialAttr.XmlSpace: - // validate XmlSpace attribute - value = XmlConvert.TrimString(value); - if (value == "default") - { - _stack[_top].xmlSpace = XmlSpace.Default; - } - else if (value == "preserve") - { - _stack[_top].xmlSpace = XmlSpace.Preserve; - } - else - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidXmlSpace, value)); - } - break; - case SpecialAttr.XmlNs: - VerifyPrefixXml(_prefixForXmlNs, value); - PushNamespace(_prefixForXmlNs, value, true); - break; - } - } - - - private void VerifyPrefixXml(string prefix, string ns) - { - if (prefix != null && prefix.Length == 3) - { - if ( - (prefix[0] == 'x' || prefix[0] == 'X') && - (prefix[1] == 'm' || prefix[1] == 'M') && - (prefix[2] == 'l' || prefix[2] == 'L') - ) - { - if (XmlReservedNs.NsXml != ns) - { - throw new ArgumentException(ResXml.Xml_InvalidPrefix); - } - } - } - } - - private void PushStack() - { - if (_top == _stack.Length - 1) - { - TagInfo[] na = new TagInfo[_stack.Length + 10]; - if (_top > 0) Array.Copy(_stack, na, _top + 1); - _stack = na; - } - - _top++; // Move up stack - _stack[_top].Init(_nsTop); - } - - private void FlushEncoders() - { - if (null != _base64Encoder) - { - // The Flush will call WriteRaw to write out the rest of the encoded characters - _base64Encoder.Flush(); - } - _flush = false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlUtf8RawTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlUtf8RawTextWriter.cs deleted file mode 100644 index e1e0528ad1c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlUtf8RawTextWriter.cs +++ /dev/null @@ -1,1921 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -// WARNING: This file is generated and should not be modified directly. Instead, -// modify XmlTextWriterGenerator.cxxbak and run gen.bat in the same directory. -// This batch file will execute the following commands: -// -// Before running below command, rename XmlRawTextWriterGenerator.cxxbak to XmlRawTextWriterGenerator.cxx -// cl.exe /C /EP /D _XML_ENCODED_TEXT_WRITER XmlRawTextWriterGenerator.cxx > XmlEncodedRawTextWriter.cs -// -// Because these two implementations of XmlTextWriter are so similar, the C++ preprocessor -// is used to generate each implementation from one template file, using macros and ifdefs. - -// Note: This file was generated without #define SILVERLIGHT - -using System; -using System.IO; -using Microsoft.Xml; -using System.Text; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - // Concrete implementation of XmlWriter abstract class that serializes events as encoded XML - // text. The general-purpose XmlEncodedTextWriter uses the Encoder class to output to any - // encoding. The XmlUtf8TextWriter class combined the encoding operation with serialization - // in order to achieve better performance. - internal partial class XmlUtf8RawTextWriter : XmlRawWriter - { - // - // Fields - // -#if ASYNC - private readonly bool useAsync; -#endif - - // main buffer - protected byte[] bufBytes; - - // output stream - protected Stream stream; - - // encoding of the stream or text writer - protected Encoding encoding; - - // char type tables - protected XmlCharType xmlCharType = XmlCharType.Instance; - - // buffer positions - protected int bufPos = 1; // buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - protected int textPos = 1; // text end position; don't indent first element, pi, or comment - protected int contentPos; // element content end position - protected int cdataPos; // cdata end position - protected int attrEndPos; // end of the last attribute - protected int bufLen = BUFSIZE; - - // flags - protected bool writeToNull; - protected bool hadDoubleBracket; - protected bool inAttributeValue; - - // writer settings - protected NewLineHandling newLineHandling; - protected bool closeOutput; - protected bool omitXmlDeclaration; - protected string newLineChars; - protected bool checkCharacters; - - protected XmlStandalone standalone; - protected XmlOutputMethod outputMethod; - - protected bool autoXmlDeclaration; - protected bool mergeCDataSections; - - // - // Constants - // - private const int BUFSIZE = 2048 * 3; // Should be greater than default FileStream size (4096), otherwise the FileStream will try to cache the data - private const int ASYNCBUFSIZE = 64 * 1024; // Set async buffer size to 64KB - private const int OVERFLOW = 32; // Allow overflow in order to reduce checks when writing out constant size markup - private const int INIT_MARKS_COUNT = 64; - - // - // Constructors - // - // Construct and initialize an instance of this class. - protected XmlUtf8RawTextWriter(XmlWriterSettings settings) - { -#if ASYNC - useAsync = settings.Async; -#endif - - // copy settings - newLineHandling = settings.NewLineHandling; - omitXmlDeclaration = settings.OmitXmlDeclaration; - newLineChars = settings.NewLineChars; - checkCharacters = settings.CheckCharacters; - closeOutput = settings.CloseOutput; - - standalone = settings.Standalone; - outputMethod = settings.OutputMethod; - mergeCDataSections = settings.MergeCDataSections; - - if (checkCharacters && newLineHandling == NewLineHandling.Replace) - { - ValidateContentChars(newLineChars, "NewLineChars", false); - } - } - - // Construct an instance of this class that serializes to a Stream interface. - public XmlUtf8RawTextWriter(Stream stream, XmlWriterSettings settings) : this(settings) - { - Debug.Assert(stream != null && settings != null); - - this.stream = stream; - this.encoding = settings.Encoding; - - bufBytes = new byte[bufLen + OVERFLOW]; - - // Output UTF-8 byte order mark if Encoding object wants it - if (!stream.CanSeek || stream.Position == 0) - { - byte[] bom = encoding.GetPreamble(); - if (bom.Length != 0) - { - Buffer.BlockCopy(bom, 0, bufBytes, 1, bom.Length); - bufPos += bom.Length; - textPos += bom.Length; - } - } - - // Write the xml declaration - if (settings.AutoXmlDeclaration) - { - WriteXmlDeclaration(standalone); - autoXmlDeclaration = true; - } - } - - // - // XmlWriter implementation - // - // Returns settings the writer currently applies. - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = new XmlWriterSettings(); - - settings.Encoding = this.encoding; - settings.OmitXmlDeclaration = this.omitXmlDeclaration; - settings.NewLineHandling = this.newLineHandling; - settings.NewLineChars = this.newLineChars; - settings.CloseOutput = this.closeOutput; - settings.ConformanceLevel = ConformanceLevel.Auto; - settings.CheckCharacters = checkCharacters; - - settings.AutoXmlDeclaration = autoXmlDeclaration; - settings.Standalone = standalone; - settings.OutputMethod = outputMethod; - - settings.ReadOnly = true; - return settings; - } - } - - // Write the xml declaration. This must be the first call. - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - // Output xml declaration only if user allows it and it was not already output - if (!omitXmlDeclaration && !autoXmlDeclaration) - { - RawText(""); - } - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - // Output xml declaration only if user allows it and it was not already output - if (!omitXmlDeclaration && !autoXmlDeclaration) - { - WriteProcessingInstruction("xml", xmldecl); - } - } - - // Serialize the document type declaration. - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - Debug.Assert(name != null && name.Length > 0); - - RawText("'; - } - - // Serialize the beginning of an element start tag: " 0); - Debug.Assert(prefix != null); - - bufBytes[bufPos++] = (byte)'<'; - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufBytes[this.bufPos++] = (byte)':'; - } - - RawText(localName); - - attrEndPos = bufPos; - } - - // Serialize the end of an element start tag in preparation for content serialization: ">" - internal override void StartElementContent() - { - bufBytes[bufPos++] = (byte)'>'; - - // StartElementContent is always called; therefore, in order to allow shortcut syntax, we save the - // position of the '>' character. If WriteEndElement is called and no other characters have been - // output, then the '>' character can be be overwritten with the shortcut syntax " />". - contentPos = bufPos; - } - - // Serialize an element end tag: "", if content was output. Otherwise, serialize - // the shortcut syntax: " />". - internal override void WriteEndElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - if (contentPos != bufPos) - { - // Content has been output, so can't use shortcut syntax - bufBytes[bufPos++] = (byte)'<'; - bufBytes[bufPos++] = (byte)'/'; - - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufBytes[bufPos++] = (byte)':'; - } - RawText(localName); - bufBytes[bufPos++] = (byte)'>'; - } - else - { - // Use shortcut syntax; overwrite the already output '>' character - bufPos--; - bufBytes[bufPos++] = (byte)' '; - bufBytes[bufPos++] = (byte)'/'; - bufBytes[bufPos++] = (byte)'>'; - } - } - - // Serialize a full element end tag: "" - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - bufBytes[bufPos++] = (byte)'<'; - bufBytes[bufPos++] = (byte)'/'; - - if (prefix != null && prefix.Length != 0) - { - RawText(prefix); - bufBytes[bufPos++] = (byte)':'; - } - RawText(localName); - bufBytes[bufPos++] = (byte)'>'; - } - - // Serialize an attribute tag using double quotes around the attribute value: 'prefix:localName="' - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length > 0); - Debug.Assert(prefix != null); - - if (attrEndPos == bufPos) - { - bufBytes[bufPos++] = (byte)' '; - } - - if (prefix != null && prefix.Length > 0) - { - RawText(prefix); - bufBytes[bufPos++] = (byte)':'; - } - RawText(localName); - bufBytes[bufPos++] = (byte)'='; - bufBytes[bufPos++] = (byte)'"'; - - inAttributeValue = true; - } - - // Serialize the end of an attribute value using double quotes: '"' - public override void WriteEndAttribute() - { - bufBytes[bufPos++] = (byte)'"'; - inAttributeValue = false; - attrEndPos = bufPos; - } - - internal override void WriteNamespaceDeclaration(string prefix, string namespaceName) - { - Debug.Assert(prefix != null && namespaceName != null); - - this.WriteStartNamespaceDeclaration(prefix); - this.WriteString(namespaceName); - this.WriteEndNamespaceDeclaration(); - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return true; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) - { - Debug.Assert(prefix != null); - - // VSTFDEVDIV bug #583965: Inconsistency between Silverlight 2 and Dev10 in the way a single xmlns attribute is serialized - // Resolved as: Won't fix (breaking change) - - if (prefix.Length == 0) - { - RawText(" xmlns=\""); - } - else - { - RawText(" xmlns:"); - RawText(prefix); - bufBytes[bufPos++] = (byte)'='; - bufBytes[bufPos++] = (byte)'"'; - } - - inAttributeValue = true; - } - - internal override void WriteEndNamespaceDeclaration() - { - inAttributeValue = false; - - bufBytes[bufPos++] = (byte)'"'; - attrEndPos = bufPos; - } - - // Serialize a CData section. If the "]]>" pattern is found within - // the text, replace it with "]]>". - public override void WriteCData(string text) - { - Debug.Assert(text != null); - - if (mergeCDataSections && bufPos == cdataPos) - { - // Merge adjacent cdata sections - overwrite the "]]>" characters - Debug.Assert(bufPos >= 4); - bufPos -= 3; - } - else - { - // Start a new cdata section - bufBytes[bufPos++] = (byte)'<'; - bufBytes[bufPos++] = (byte)'!'; - bufBytes[bufPos++] = (byte)'['; - bufBytes[bufPos++] = (byte)'C'; - bufBytes[bufPos++] = (byte)'D'; - bufBytes[bufPos++] = (byte)'A'; - bufBytes[bufPos++] = (byte)'T'; - bufBytes[bufPos++] = (byte)'A'; - bufBytes[bufPos++] = (byte)'['; - } - - WriteCDataSection(text); - - bufBytes[bufPos++] = (byte)']'; - bufBytes[bufPos++] = (byte)']'; - bufBytes[bufPos++] = (byte)'>'; - - textPos = bufPos; - cdataPos = bufPos; - } - - // Serialize a comment. - public override void WriteComment(string text) - { - Debug.Assert(text != null); - - bufBytes[bufPos++] = (byte)'<'; - bufBytes[bufPos++] = (byte)'!'; - bufBytes[bufPos++] = (byte)'-'; - bufBytes[bufPos++] = (byte)'-'; - - WriteCommentOrPi(text, '-'); - - bufBytes[bufPos++] = (byte)'-'; - bufBytes[bufPos++] = (byte)'-'; - bufBytes[bufPos++] = (byte)'>'; - } - - // Serialize a processing instruction. - public override void WriteProcessingInstruction(string name, string text) - { - Debug.Assert(name != null && name.Length > 0); - Debug.Assert(text != null); - - bufBytes[bufPos++] = (byte)'<'; - bufBytes[bufPos++] = (byte)'?'; - RawText(name); - - if (text.Length > 0) - { - bufBytes[bufPos++] = (byte)' '; - WriteCommentOrPi(text, '?'); - } - - bufBytes[bufPos++] = (byte)'?'; - bufBytes[bufPos++] = (byte)'>'; - } - - // Serialize an entity reference. - public override void WriteEntityRef(string name) - { - Debug.Assert(name != null && name.Length > 0); - - bufBytes[bufPos++] = (byte)'&'; - RawText(name); - bufBytes[bufPos++] = (byte)';'; - - if (bufPos > bufLen) - { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a character entity reference. - public override void WriteCharEntity(char ch) - { - string strVal = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); - - if (checkCharacters && !xmlCharType.IsCharData(ch)) - { - // we just have a single char, not a surrogate, therefore we have to pass in '\0' for the second char - throw XmlConvert.CreateInvalidCharException(ch, '\0'); - } - - bufBytes[bufPos++] = (byte)'&'; - bufBytes[bufPos++] = (byte)'#'; - bufBytes[bufPos++] = (byte)'x'; - RawText(strVal); - bufBytes[bufPos++] = (byte)';'; - - if (bufPos > bufLen) - { - FlushBuffer(); - } - - textPos = bufPos; - } - - // Serialize a whitespace node. - - public override unsafe void WriteWhitespace(string ws) - { - Debug.Assert(ws != null); - - fixed (char* pSrc = ws) - { - char* pSrcEnd = pSrc + ws.Length; - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteElementTextBlock(pSrc, pSrcEnd); - } - } - } - - // Serialize either attribute or element text using XML rules. - - public override unsafe void WriteString(string text) - { - Debug.Assert(text != null); - - fixed (char* pSrc = text) - { - char* pSrcEnd = pSrc + text.Length; - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrc, pSrcEnd); - } - else - { - WriteElementTextBlock(pSrc, pSrcEnd); - } - } - } - - // Serialize surrogate character entity. - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - int surrogateChar = XmlCharType.CombineSurrogateChar(lowChar, highChar); - - bufBytes[bufPos++] = (byte)'&'; - bufBytes[bufPos++] = (byte)'#'; - bufBytes[bufPos++] = (byte)'x'; - RawText(surrogateChar.ToString("X", NumberFormatInfo.InvariantInfo)); - bufBytes[bufPos++] = (byte)';'; - textPos = bufPos; - } - - // Serialize either attribute or element text using XML rules. - // Arguments are validated in the XmlWellformedWriter layer. - - public override unsafe void WriteChars(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - fixed (char* pSrcBegin = &buffer[index]) - { - if (inAttributeValue) - { - WriteAttributeTextBlock(pSrcBegin, pSrcBegin + count); - } - else - { - WriteElementTextBlock(pSrcBegin, pSrcBegin + count); - } - } - } - - // Serialize raw data. - // Arguments are validated in the XmlWellformedWriter layer - - public override unsafe void WriteRaw(char[] buffer, int index, int count) - { - Debug.Assert(buffer != null); - Debug.Assert(index >= 0); - Debug.Assert(count >= 0 && index + count <= buffer.Length); - - fixed (char* pSrcBegin = &buffer[index]) - { - WriteRawWithCharChecking(pSrcBegin, pSrcBegin + count); - } - - textPos = bufPos; - } - - // Serialize raw data. - - public override unsafe void WriteRaw(string data) - { - Debug.Assert(data != null); - - fixed (char* pSrcBegin = data) - { - WriteRawWithCharChecking(pSrcBegin, pSrcBegin + data.Length); - } - - textPos = bufPos; - } - - // Flush all bytes in the buffer to output and close the output stream or writer. - public override void Close() - { - try - { - FlushBuffer(); - FlushEncoder(); - } - finally - { - // Future calls to Close or Flush shouldn't write to Stream or Writer - writeToNull = true; - - if (stream != null) - { - try - { - stream.Flush(); - } - finally - { - try - { - if (closeOutput) - { - stream.Close(); - } - } - finally - { - stream = null; - } - } - } - } - } - - // Flush all characters in the buffer to output and call Flush() on the output object. - public override void Flush() - { - FlushBuffer(); - FlushEncoder(); - - if (stream != null) - { - stream.Flush(); - } - } - - // - // Implementation methods - // - // Flush all characters in the buffer to output. Do not flush the output object. - protected virtual void FlushBuffer() - { - try - { - // Output all characters (except for previous characters stored at beginning of buffer) - if (!writeToNull) - { - Debug.Assert(stream != null); - stream.Write(bufBytes, 1, bufPos - 1); - } - } - catch - { - // Future calls to flush (i.e. when Close() is called) don't attempt to write to stream - writeToNull = true; - throw; - } - finally - { - // Move last buffer character to the beginning of the buffer (so that previous character can always be determined) - bufBytes[0] = bufBytes[bufPos - 1]; - - if (IsSurrogateByte(bufBytes[0])) - { - // Last character was the first byte in a surrogate encoding, so move last three - // bytes of encoding to the beginning of the buffer. - bufBytes[1] = bufBytes[bufPos]; - bufBytes[2] = bufBytes[bufPos + 1]; - bufBytes[3] = bufBytes[bufPos + 2]; - } - - // Reset buffer position - textPos = (textPos == bufPos) ? 1 : 0; - attrEndPos = (attrEndPos == bufPos) ? 1 : 0; - contentPos = 0; // Needs to be zero, since overwriting '>' character is no longer possible - cdataPos = 0; // Needs to be zero, since overwriting ']]>' characters is no longer possible - bufPos = 1; // Buffer position starts at 1, because we need to be able to safely step back -1 in case we need to - // close an empty element or in CDATA section detection of double ]; _BUFFER[0] will always be 0 - } - } - - private void FlushEncoder() - { - // intentionally empty - - } - - // Serialize text that is part of an attribute value. The '&', '<', '>', and '"' characters - // are entitized. - - protected unsafe void WriteAttributeTextBlock(char* pSrc, char* pSrcEnd) - { - fixed (byte* pDstBegin = bufBytes) - { - byte* pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch <= 0x7F)) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - pDst = AmpEntity(pDst); - break; - case '<': - pDst = LtEntity(pDst); - break; - case '>': - pDst = GtEntity(pDst); - break; - case '"': - pDst = QuoteEntity(pDst); - break; - case '\'': - *pDst = (byte)ch; - pDst++; - break; - case (char)0x9: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (byte)ch; - pDst++; - } - else - { - // escape tab in attributes - pDst = TabEntity(pDst); - } - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (byte)ch; - pDst++; - } - else - { - // escape new lines in attributes - pDst = CarriageReturnEntity(pDst); - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.None) - { - *pDst = (byte)ch; - pDst++; - } - else - { - // escape new lines in attributes - pDst = LineFeedEntity(pDst); - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // Serialize text that is part of element content. The '&', '<', and '>' characters - // are entitized. - - protected unsafe void WriteElementTextBlock(char* pSrc, char* pSrcEnd) - { - fixed (byte* pDstBegin = bufBytes) - { - byte* pDst = pDstBegin + this.bufPos; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch <= 0x7F)) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // some character needs to be escaped - switch (ch) - { - case '&': - pDst = AmpEntity(pDst); - break; - case '<': - pDst = LtEntity(pDst); - break; - case '>': - pDst = GtEntity(pDst); - break; - case '"': - case '\'': - case (char)0x9: - *pDst = (byte)ch; - pDst++; - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case (char)0xD: - switch (newLineHandling) - { - case NewLineHandling.Replace: - // Replace "\r\n", or "\r" with NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - break; - - case NewLineHandling.Entitize: - // Entitize 0xD - pDst = CarriageReturnEntity(pDst); - break; - case NewLineHandling.None: - *pDst = (byte)ch; - pDst++; - break; - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - textPos = bufPos; - contentPos = 0; - } - } - - protected unsafe void RawText(string s) - { - Debug.Assert(s != null); - - fixed (char* pSrcBegin = s) - { - RawText(pSrcBegin, pSrcBegin + s.Length); - } - } - - protected unsafe void RawText(char* pSrcBegin, char* pSrcEnd) - { - fixed (byte* pDstBegin = bufBytes) - { - byte* pDst = pDstBegin + this.bufPos; - char* pSrc = pSrcBegin; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + this.bufLen) - { - pDstEnd = pDstBegin + this.bufLen; - } - - while (pDst < pDstEnd && ((ch = *pSrc) <= 0x7F)) - { - pSrc++; - *pDst = (byte)ch; - pDst++; - } - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - } - - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteRawWithCharChecking(char* pSrcBegin, char* pSrcEnd) - { - fixed (byte* pDstBegin = bufBytes) - { - char* pSrc = pSrcBegin; - byte* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fText) != 0) && ch <= 0x7F)) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case ']': - case '<': - case '&': - case (char)0x9: - *pDst = (byte)ch; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCommentOrPi(string text, int stopChar) - { - if (text.Length == 0) - { - if (bufPos >= bufLen) - { - FlushBuffer(); - } - return; - } - // write text - fixed (char* pSrcBegin = text) - - fixed (byte* pDstBegin = bufBytes) - { - char* pSrc = pSrcBegin; - - char* pSrcEnd = pSrcBegin + text.Length; - - byte* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fText) != 0) && ch != stopChar && ch <= 0x7F)) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case '-': - *pDst = (byte)'-'; - pDst++; - if (ch == stopChar) - { - // Insert space between adjacent dashes or before comment's end dashes - if (pSrc + 1 == pSrcEnd || *(pSrc + 1) == '-') - { - *pDst = (byte)' '; - pDst++; - } - } - break; - case '?': - *pDst = (byte)'?'; - pDst++; - if (ch == stopChar) - { - // Processing instruction: insert space between adjacent '?' and '>' - if (pSrc + 1 < pSrcEnd && *(pSrc + 1) == '>') - { - *pDst = (byte)' '; - pDst++; - } - } - break; - case ']': - *pDst = (byte)']'; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case '<': - case '&': - case (char)0x9: - *pDst = (byte)ch; - pDst++; - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - protected unsafe void WriteCDataSection(string text) - { - if (text.Length == 0) - { - if (bufPos >= bufLen) - { - FlushBuffer(); - } - return; - } - - // write text - - fixed (char* pSrcBegin = text) - - fixed (byte* pDstBegin = bufBytes) - { - char* pSrc = pSrcBegin; - - char* pSrcEnd = pSrcBegin + text.Length; - - byte* pDst = pDstBegin + bufPos; - - int ch = 0; - for (; ; ) - { - byte* pDstEnd = pDst + (pSrcEnd - pSrc); - if (pDstEnd > pDstBegin + bufLen) - { - pDstEnd = pDstBegin + bufLen; - } - - while (pDst < pDstEnd && (((xmlCharType.charProperties[(ch = *pSrc)] & XmlCharType.fAttrValue) != 0) && ch != ']' && ch <= 0x7F)) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - - Debug.Assert(pSrc <= pSrcEnd); - - // end of value - if (pSrc >= pSrcEnd) - { - break; - } - - // end of buffer - if (pDst >= pDstEnd) - { - bufPos = (int)(pDst - pDstBegin); - FlushBuffer(); - pDst = pDstBegin + 1; - continue; - } - - // handle special characters - switch (ch) - { - case '>': - if (hadDoubleBracket && pDst[-1] == (byte)']') - { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - // The characters "]]>" were found within the CData text - pDst = RawEndCData(pDst); - pDst = RawStartCData(pDst); - } - *pDst = (byte)'>'; - pDst++; - break; - case ']': - if (pDst[-1] == (byte)']') - { // pDst[-1] will always correct - there is a padding character at _BUFFER[0] - hadDoubleBracket = true; - } - else - { - hadDoubleBracket = false; - } - *pDst = (byte)']'; - pDst++; - break; - case (char)0xD: - if (newLineHandling == NewLineHandling.Replace) - { - // Normalize "\r\n", or "\r" to NewLineChars - if (pSrc[1] == '\n') - { - pSrc++; - } - - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case (char)0xA: - if (newLineHandling == NewLineHandling.Replace) - { - pDst = WriteNewLine(pDst); - } - else - { - *pDst = (byte)ch; - pDst++; - } - break; - case '&': - case '<': - case '"': - case '\'': - case (char)0x9: - *pDst = (byte)ch; - pDst++; - break; - default: - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - continue; - } - pSrc++; - } - bufPos = (int)(pDst - pDstBegin); - } - } - - // Returns true if UTF8 encoded byte is first of four bytes that encode a surrogate pair. - // To do this, detect the bit pattern 11110xxx. - private static bool IsSurrogateByte(byte b) - { - return (b & 0xF8) == 0xF0; - } - - private static unsafe byte* EncodeSurrogate(char* pSrc, char* pSrcEnd, byte* pDst) - { - Debug.Assert(XmlCharType.IsSurrogate(*pSrc)); - int ch = *pSrc; - if (ch <= XmlCharType.SurHighEnd) - { - if (pSrc + 1 < pSrcEnd) - { - int lowChar = pSrc[1]; - if (lowChar >= XmlCharType.SurLowStart && - (/*LocalAppContextSwitches.DontThrowOnInvalidSurrogatePairs ||*/ lowChar <= XmlCharType.SurLowEnd)) - { - // Calculate Unicode scalar value for easier manipulations (see section 3.7 in Unicode spec) - // The scalar value repositions surrogate values to start at 0x10000. - - ch = XmlCharType.CombineSurrogateChar(lowChar, ch); - - pDst[0] = (byte)(0xF0 | (ch >> 18)); - pDst[1] = (byte)(0x80 | (ch >> 12) & 0x3F); - pDst[2] = (byte)(0x80 | (ch >> 6) & 0x3F); - pDst[3] = (byte)(0x80 | ch & 0x3F); - pDst += 4; - - return pDst; - } - throw XmlConvert.CreateInvalidSurrogatePairException((char)lowChar, (char)ch); - } - throw new ArgumentException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - throw XmlConvert.CreateInvalidHighSurrogateCharException((char)ch); - } - - private unsafe byte* InvalidXmlChar(int ch, byte* pDst, bool entitize) - { - Debug.Assert(!xmlCharType.IsWhiteSpace((char)ch)); - Debug.Assert(!xmlCharType.IsAttributeValueChar((char)ch)); - - if (checkCharacters) - { - // This method will never be called on surrogates, so it is ok to pass in '\0' to the CreateInvalidCharException - throw XmlConvert.CreateInvalidCharException((char)ch, '\0'); - } - else - { - if (entitize) - { - return CharEntity(pDst, (char)ch); - } - else - { - if (ch < 0x80) - { - *pDst = (byte)ch; - pDst++; - } - else - { - pDst = EncodeMultibyteUTF8(ch, pDst); - } - - return pDst; - } - } - } - - internal unsafe void EncodeChar(ref char* pSrc, char* pSrcEnd, ref byte* pDst) - { - int ch = *pSrc; - if (XmlCharType.IsSurrogate(ch)) { pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); pSrc += 2; } else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; } else { pDst = EncodeMultibyteUTF8(ch, pDst); pSrc++; }; - } - - internal static unsafe byte* EncodeMultibyteUTF8(int ch, byte* pDst) - { - Debug.Assert(ch >= 0x80 && !XmlCharType.IsSurrogate(ch)); - - /* UTF8-2: If ch is in 0x80-0x7ff range, then use 2 bytes to encode it */ - if (ch < 0x800) - { - *pDst = (byte)(unchecked((sbyte)0xC0) | (ch >> 6)); - } - /* UTF8-3: If ch is anything else, then default to using 3 bytes to encode it. */ - else - { - *pDst = (byte)(unchecked((sbyte)0xE0) | (ch >> 12)); - pDst++; - - *pDst = (byte)(unchecked((sbyte)0x80) | (ch >> 6) & 0x3F); - } - pDst++; - *pDst = (byte)(0x80 | ch & 0x3F); - return pDst + 1; - } - - // Encode *pSrc as a sequence of UTF8 bytes. Write the bytes to pDst and return an updated pointer. - - internal static unsafe void CharToUTF8(ref char* pSrc, char* pSrcEnd, ref byte* pDst) - { - int ch = *pSrc; - if (ch <= 0x7F) - { - *pDst = (byte)ch; - pDst++; - pSrc++; - } - else if (XmlCharType.IsSurrogate(ch)) - { - pDst = EncodeSurrogate(pSrc, pSrcEnd, pDst); - pSrc += 2; - } - else - { - pDst = EncodeMultibyteUTF8(ch, pDst); - pSrc++; - } - } - - // Write NewLineChars to the specified buffer position and return an updated position. - - protected unsafe byte* WriteNewLine(byte* pDst) - { - fixed (byte* pDstBegin = bufBytes) - { - bufPos = (int)(pDst - pDstBegin); - // Let RawText do the real work - RawText(newLineChars); - return pDstBegin + bufPos; - } - } - - // Following methods do not check whether pDst is beyond the bufSize because the buffer was allocated with a OVERFLOW to accomodate - // for the writes of small constant-length string as below. - - // Entitize '<' as "<". Return an updated pointer. - - protected static unsafe byte* LtEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'l'; - pDst[2] = (byte)'t'; - pDst[3] = (byte)';'; - return pDst + 4; - } - - // Entitize '>' as ">". Return an updated pointer. - - protected static unsafe byte* GtEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'g'; - pDst[2] = (byte)'t'; - pDst[3] = (byte)';'; - return pDst + 4; - } - - // Entitize '&' as "&". Return an updated pointer. - - protected static unsafe byte* AmpEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'a'; - pDst[2] = (byte)'m'; - pDst[3] = (byte)'p'; - pDst[4] = (byte)';'; - return pDst + 5; - } - - // Entitize '"' as """. Return an updated pointer. - - protected static unsafe byte* QuoteEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'q'; - pDst[2] = (byte)'u'; - pDst[3] = (byte)'o'; - pDst[4] = (byte)'t'; - pDst[5] = (byte)';'; - return pDst + 6; - } - - // Entitize '\t' as " ". Return an updated pointer. - - protected static unsafe byte* TabEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'#'; - pDst[2] = (byte)'x'; - pDst[3] = (byte)'9'; - pDst[4] = (byte)';'; - return pDst + 5; - } - - // Entitize 0xa as " ". Return an updated pointer. - - protected static unsafe byte* LineFeedEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'#'; - pDst[2] = (byte)'x'; - pDst[3] = (byte)'A'; - pDst[4] = (byte)';'; - return pDst + 5; - } - - // Entitize 0xd as " ". Return an updated pointer. - - protected static unsafe byte* CarriageReturnEntity(byte* pDst) - { - pDst[0] = (byte)'&'; - pDst[1] = (byte)'#'; - pDst[2] = (byte)'x'; - pDst[3] = (byte)'D'; - pDst[4] = (byte)';'; - return pDst + 5; - } - - private static unsafe byte* CharEntity(byte* pDst, char ch) - { - string s = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); - pDst[0] = (byte)'&'; - pDst[1] = (byte)'#'; - pDst[2] = (byte)'x'; - pDst += 3; - - fixed (char* pSrc = s) - { - char* pS = pSrc; - while ((*pDst++ = (byte)*pS++) != 0) ; - } - - pDst[-1] = (byte)';'; - return pDst; - } - - // Write "" to the specified buffer. Return an updated pointer. - - protected static unsafe byte* RawEndCData(byte* pDst) - { - pDst[0] = (byte)']'; - pDst[1] = (byte)']'; - pDst[2] = (byte)'>'; - return pDst + 3; - } - - protected unsafe void ValidateContentChars(string chars, string propertyName, bool allowOnlyWhitespace) - { - if (allowOnlyWhitespace) - { - if (!xmlCharType.IsOnlyWhitespace(chars)) - { - throw new ArgumentException(string.Format(ResXml.Xml_IndentCharsNotWhitespace, propertyName)); - } - } - else - { - string error = null; - for (int i = 0; i < chars.Length; i++) - { - if (!xmlCharType.IsTextChar(chars[i])) - { - switch (chars[i]) - { - case '\n': - case '\r': - case '\t': - continue; - case '<': - case '&': - case ']': - error = string.Format(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(chars, i)); - goto Error; - default: - if (XmlCharType.IsHighSurrogate(chars[i])) - { - if (i + 1 < chars.Length) - { - if (XmlCharType.IsLowSurrogate(chars[i + 1])) - { - i++; - continue; - } - } - error = ResXml.Xml_InvalidSurrogateMissingLowChar; - goto Error; - } - else if (XmlCharType.IsLowSurrogate(chars[i])) - { - error = string.Format(ResXml.Xml_InvalidSurrogateHighChar, ((uint)chars[i]).ToString("X", CultureInfo.InvariantCulture)); - goto Error; - } - continue; - } - } - } - return; - - Error: - throw new ArgumentException(string.Format(ResXml.Xml_InvalidCharsInIndent, new string[] { propertyName, error })); - } - } - } - - // Same as base text writer class except that elements, attributes, comments, and pi's are indented. - internal partial class XmlUtf8RawTextWriterIndent : XmlUtf8RawTextWriter - { - // - // Fields - // - protected int indentLevel; - protected bool newLineOnAttributes; - protected string indentChars; - - protected bool mixedContent; - private BitStack _mixedContentStack; - - protected ConformanceLevel conformanceLevel = ConformanceLevel.Auto; - - // - // Constructors - // - - public XmlUtf8RawTextWriterIndent(Stream stream, XmlWriterSettings settings) : base(stream, settings) - { - Init(settings); - } - - // - // XmlWriter methods - // - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = base.Settings; - - settings.ReadOnly = false; - settings.Indent = true; - settings.IndentChars = indentChars; - settings.NewLineOnAttributes = newLineOnAttributes; - settings.ReadOnly = true; - - return settings; - } - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - // Add indentation - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - base.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - Debug.Assert(localName != null && localName.Length != 0 && prefix != null && ns != null); - - // Add indentation - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - indentLevel++; - _mixedContentStack.PushBit(mixedContent); - - base.WriteStartElement(prefix, localName, ns); - } - - internal override void StartElementContent() - { - // If this is the root element and we're writing a document - // do not inherit the mixedContent flag into the root element. - // This is to allow for whitespace nodes on root level - // without disabling indentation for the whole document. - if (indentLevel == 1 && conformanceLevel == ConformanceLevel.Document) - { - mixedContent = false; - } - else - { - mixedContent = _mixedContentStack.PeekBit(); - } - base.StartElementContent(); - } - - internal override void OnRootElement(ConformanceLevel currentConformanceLevel) - { - // Just remember the current conformance level - conformanceLevel = currentConformanceLevel; - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - // Add indentation - indentLevel--; - if (!mixedContent && base.contentPos != base.bufPos) - { - // There was content, so try to indent - if (base.textPos != base.bufPos) - { - WriteIndent(); - } - } - mixedContent = _mixedContentStack.PopBit(); - - base.WriteEndElement(prefix, localName, ns); - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - // Add indentation - indentLevel--; - if (!mixedContent && base.contentPos != base.bufPos) - { - // There was content, so try to indent - if (base.textPos != base.bufPos) - { - WriteIndent(); - } - } - mixedContent = _mixedContentStack.PopBit(); - - base.WriteFullEndElement(prefix, localName, ns); - } - - // Same as base class, plus possible indentation. - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - // Add indentation - if (newLineOnAttributes) - { - WriteIndent(); - } - - base.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteCData(string text) - { - mixedContent = true; - base.WriteCData(text); - } - - public override void WriteComment(string text) - { - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - - base.WriteComment(text); - } - - public override void WriteProcessingInstruction(string target, string text) - { - if (!mixedContent && base.textPos != base.bufPos) - { - WriteIndent(); - } - - base.WriteProcessingInstruction(target, text); - } - - public override void WriteEntityRef(string name) - { - mixedContent = true; - base.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - mixedContent = true; - base.WriteCharEntity(ch); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - mixedContent = true; - base.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteWhitespace(string ws) - { - mixedContent = true; - base.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - mixedContent = true; - base.WriteString(text); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - mixedContent = true; - base.WriteChars(buffer, index, count); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - mixedContent = true; - base.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - mixedContent = true; - base.WriteRaw(data); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - mixedContent = true; - base.WriteBase64(buffer, index, count); - } - - // - // Private methods - // - private void Init(XmlWriterSettings settings) - { - indentLevel = 0; - indentChars = settings.IndentChars; - newLineOnAttributes = settings.NewLineOnAttributes; - _mixedContentStack = new BitStack(); - - // check indent characters that they are valid XML characters - if (base.checkCharacters) - { - if (newLineOnAttributes) - { - base.ValidateContentChars(indentChars, "IndentChars", true); - base.ValidateContentChars(newLineChars, "NewLineChars", true); - } - else - { - base.ValidateContentChars(indentChars, "IndentChars", false); - if (base.newLineHandling != NewLineHandling.Replace) - { - base.ValidateContentChars(newLineChars, "NewLineChars", false); - } - } - } - } - - // Add indentation to output. Write newline and then repeat IndentChars for each indent level. - private void WriteIndent() - { - RawText(base.newLineChars); - for (int i = indentLevel; i > 0; i--) - { - RawText(indentChars); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReader.cs deleted file mode 100644 index 92d06ee48fc..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReader.cs +++ /dev/null @@ -1,356 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Collections.Generic; -// using System.Security.Permissions; - -namespace Microsoft.Xml -{ - using System; - - // [PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )] - [Obsolete("Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202")] - public class XmlValidatingReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver - { - // - // Member fields - // - private XmlValidatingReaderImpl _impl; - // - // Constructors - // - public XmlValidatingReader(XmlReader reader) - { - _impl = new XmlValidatingReaderImpl(reader); - _impl.OuterReader = this; - } - - public XmlValidatingReader(string xmlFragment, XmlNodeType fragType, XmlParserContext context) - { - if (xmlFragment == null) - { - throw new ArgumentNullException("xmlFragment"); - } - _impl = new XmlValidatingReaderImpl(xmlFragment, fragType, context); - _impl.OuterReader = this; - } - - public XmlValidatingReader(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context) - { - if (xmlFragment == null) - { - throw new ArgumentNullException("xmlFragment"); - } - _impl = new XmlValidatingReaderImpl(xmlFragment, fragType, context); - _impl.OuterReader = this; - } - - // - // XmlReader members - // - public override XmlNodeType NodeType - { - get { return _impl.NodeType; } - } - - public override string Name - { - get { return _impl.Name; } - } - - public override string LocalName - { - get { return _impl.LocalName; } - } - - public override string NamespaceURI - { - get { return _impl.NamespaceURI; } - } - - public override string Prefix - { - get { return _impl.Prefix; } - } - - public override bool HasValue - { - get { return _impl.HasValue; } - } - - public override string Value - { - get { return _impl.Value; } - } - - public override int Depth - { - get { return _impl.Depth; } - } - - public override string BaseURI - { - get { return _impl.BaseURI; } - } - - public override bool IsEmptyElement - { - get { return _impl.IsEmptyElement; } - } - - public override bool IsDefault - { - get { return _impl.IsDefault; } - } - - public override char QuoteChar - { - get { return _impl.QuoteChar; } - } - - public override XmlSpace XmlSpace - { - get { return _impl.XmlSpace; } - } - - public override string XmlLang - { - get { return _impl.XmlLang; } - } - - // XmlTextReader does not override SchemaInfo, ValueType and ReadTypeValue - - public override int AttributeCount { get { return _impl.AttributeCount; } } - - public override string GetAttribute(string name) - { - return _impl.GetAttribute(name); - } - - public override string GetAttribute(string localName, string namespaceURI) - { - return _impl.GetAttribute(localName, namespaceURI); - } - - public override string GetAttribute(int i) - { - return _impl.GetAttribute(i); - } - - public override bool MoveToAttribute(string name) - { - return _impl.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string localName, string namespaceURI) - { - return _impl.MoveToAttribute(localName, namespaceURI); - } - - public override void MoveToAttribute(int i) - { - _impl.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - return _impl.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - return _impl.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - return _impl.MoveToElement(); - } - - public override bool ReadAttributeValue() - { - return _impl.ReadAttributeValue(); - } - - public override bool Read() - { - return _impl.Read(); - } - - public override bool EOF - { - get { return _impl.EOF; } - } - - public override void Close() - { - _impl.Close(); - } - - public override ReadState ReadState - { - get { return _impl.ReadState; } - } - - public override XmlNameTable NameTable - { - get { return _impl.NameTable; } - } - - public override String LookupNamespace(String prefix) - { - string ns = _impl.LookupNamespace(prefix); - if (ns != null && ns.Length == 0) - { - ns = null; - } - return ns; - } - - public override bool CanResolveEntity - { - get { return true; } - } - - public override void ResolveEntity() - { - _impl.ResolveEntity(); - } - - // Binary content access methods - public override bool CanReadBinaryContent - { - get { return true; } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - return _impl.ReadContentAsBase64(buffer, index, count); - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - return _impl.ReadElementContentAsBase64(buffer, index, count); - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - return _impl.ReadContentAsBinHex(buffer, index, count); - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - return _impl.ReadElementContentAsBinHex(buffer, index, count); - } - - // Overriden helper methods - - public override string ReadString() - { - _impl.MoveOffEntityReference(); - return base.ReadString(); - } - - // - // IXmlLineInfo members - // - public bool HasLineInfo() { return true; } - - public int LineNumber { get { return _impl.LineNumber; } } - - public int LinePosition { get { return _impl.LinePosition; } } - - // - // IXmlNamespaceResolver members - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _impl.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _impl.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _impl.LookupPrefix(namespaceName); - } - - // - // XmlValidatingReader - // - public event ValidationEventHandler ValidationEventHandler - { - add { _impl.ValidationEventHandler += value; } - remove { _impl.ValidationEventHandler -= value; } - } - - public object SchemaType - { - get { return _impl.SchemaType; } - } - - public XmlReader Reader - { - get { return _impl.Reader; } - } - - public ValidationType ValidationType - { - get { return _impl.ValidationType; } - set { _impl.ValidationType = value; } - } - - public XmlSchemaCollection Schemas - { - get { return _impl.Schemas; } - } - - public EntityHandling EntityHandling - { - get { return _impl.EntityHandling; } - set { _impl.EntityHandling = value; } - } - - public XmlResolver XmlResolver - { - set { _impl.XmlResolver = value; } - } - - public bool Namespaces - { - get { return _impl.Namespaces; } - set { _impl.Namespaces = value; } - } - - public object ReadTypedValue() - { - return _impl.ReadTypedValue(); - } - - public Encoding Encoding - { - get { return _impl.Encoding; } - } - // - // Internal helper methods - // - internal XmlValidatingReaderImpl Impl - { - get { return _impl; } - } - - internal override IDtdInfo DtdInfo - { - get { return _impl.DtdInfo; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReaderImpl.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReaderImpl.cs deleted file mode 100644 index 238e0b66a28..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlValidatingReaderImpl.cs +++ /dev/null @@ -1,1213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -// using System.Security.Policy; -using System.Collections.Generic; -// using System.Security.Permissions; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - internal sealed partial class XmlValidatingReaderImpl : XmlReader, IXmlLineInfo, IXmlNamespaceResolver - { - // - // Private helper types - // - // ParsingFunction = what should the reader do when the next Read() is called - private enum ParsingFunction - { - Read = 0, - Init, - ParseDtdFromContext, - ResolveEntityInternally, - InReadBinaryContent, - ReaderClosed, - Error, - None, - } - - internal class ValidationEventHandling : IValidationEventHandling - { - // Fields - private XmlValidatingReaderImpl _reader; - private ValidationEventHandler _eventHandler; - - // Constructor - internal ValidationEventHandling(XmlValidatingReaderImpl reader) - { - _reader = reader; - } - - // IValidationEventHandling interface - #region IValidationEventHandling interface - object IValidationEventHandling.EventHandler - { - get { return _eventHandler; } - } - - void IValidationEventHandling.SendEvent(Exception /*XmlSchemaException*/ exception, XmlSeverityType severity) - { - if (_eventHandler != null) - { - _eventHandler(_reader, new ValidationEventArgs((XmlSchemaException)exception, severity)); - } - else if (_reader.ValidationType != ValidationType.None && severity == XmlSeverityType.Error) - { - throw exception; - } - } - #endregion - - // XmlValidatingReaderImpl helper methods - internal void AddHandler(ValidationEventHandler handler) - { - _eventHandler += handler; - } - - internal void RemoveHandler(ValidationEventHandler handler) - { - _eventHandler -= handler; - } - } - - // - // Fields - // - // core text reader - private XmlReader _coreReader; - private XmlTextReaderImpl _coreReaderImpl; - private IXmlNamespaceResolver _coreReaderNSResolver; - - // validation - private ValidationType _validationType; - private BaseValidator _validator; - -#pragma warning disable 618 - private XmlSchemaCollection _schemaCollection; -#pragma warning restore 618 - private bool _processIdentityConstraints; - - // parsing function (state) - private ParsingFunction _parsingFunction = ParsingFunction.Init; - - // event handling - private ValidationEventHandling _eventHandling; - - // misc - private XmlParserContext _parserContext; - - // helper for Read[Element]ContentAs{Base64,BinHex} methods - private ReadContentAsBinaryHelper _readBinaryHelper; - - // Outer XmlReader exposed to the user - either XmlValidatingReader or XmlValidatingReaderImpl (when created via XmlReader.Create). - // Virtual methods called from within XmlValidatingReaderImpl must be called on the outer reader so in case the user overrides - // some of the XmlValidatingReader methods we will call the overriden version. - private XmlReader _outerReader; - - // - // Constructors - // - // Initializes a new instance of XmlValidatingReaderImpl class with the specified XmlReader. - // This constructor is used when creating XmlValidatingReaderImpl for V1 XmlValidatingReader - internal XmlValidatingReaderImpl(XmlReader reader) - { - XmlAsyncCheckReader asyncCheckReader = reader as XmlAsyncCheckReader; - if (asyncCheckReader != null) - { - reader = asyncCheckReader.CoreReader; - } - _outerReader = this; - _coreReader = reader; - _coreReaderNSResolver = reader as IXmlNamespaceResolver; - _coreReaderImpl = reader as XmlTextReaderImpl; - if (_coreReaderImpl == null) - { - XmlTextReader tr = reader as XmlTextReader; - if (tr != null) - { - _coreReaderImpl = tr.Impl; - } - } - if (_coreReaderImpl == null) - { - throw new ArgumentException(ResXml.Arg_ExpectingXmlTextReader, "reader"); - } - _coreReaderImpl.EntityHandling = EntityHandling.ExpandEntities; - _coreReaderImpl.XmlValidatingReaderCompatibilityMode = true; - _processIdentityConstraints = true; - -#pragma warning disable 618 - _schemaCollection = new XmlSchemaCollection(_coreReader.NameTable); - _schemaCollection.XmlResolver = GetResolver(); - - _eventHandling = new ValidationEventHandling(this); - _coreReaderImpl.ValidationEventHandling = _eventHandling; - _coreReaderImpl.OnDefaultAttributeUse = new XmlTextReaderImpl.OnDefaultAttributeUseDelegate(ValidateDefaultAttributeOnUse); - - _validationType = ValidationType.Auto; - SetupValidation(ValidationType.Auto); -#pragma warning restore 618 - - } - - // Initializes a new instance of XmlValidatingReaderImpl class for parsing fragments with the specified string, fragment type and parser context - // This constructor is used when creating XmlValidatingReaderImpl for V1 XmlValidatingReader - // SxS: This method resolves an Uri but does not expose it to the caller. It's OK to disable the SxS warning. - - - internal XmlValidatingReaderImpl(string xmlFragment, XmlNodeType fragType, XmlParserContext context) - : this(new XmlTextReader(xmlFragment, fragType, context)) - { - if (_coreReader.BaseURI.Length > 0) - { - _validator.BaseUri = GetResolver().ResolveUri(null, _coreReader.BaseURI); - } - - if (context != null) - { - _parsingFunction = ParsingFunction.ParseDtdFromContext; - _parserContext = context; - } - } - - // Initializes a new instance of XmlValidatingReaderImpl class for parsing fragments with the specified stream, fragment type and parser context - // This constructor is used when creating XmlValidatingReaderImpl for V1 XmlValidatingReader - // SxS: This method resolves an Uri but does not expose it to the caller. It's OK to disable the SxS warning. - - - internal XmlValidatingReaderImpl(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context) - : this(new XmlTextReader(xmlFragment, fragType, context)) - { - if (_coreReader.BaseURI.Length > 0) - { - _validator.BaseUri = GetResolver().ResolveUri(null, _coreReader.BaseURI); - } - - if (context != null) - { - _parsingFunction = ParsingFunction.ParseDtdFromContext; - _parserContext = context; - } - } - - // Initializes a new instance of XmlValidatingReaderImpl class with the specified arguments. - // This constructor is used when creating XmlValidatingReaderImpl reader via "XmlReader.Create(..)" - internal XmlValidatingReaderImpl(XmlReader reader, ValidationEventHandler settingsEventHandler, bool processIdentityConstraints) - { - XmlAsyncCheckReader asyncCheckReader = reader as XmlAsyncCheckReader; - if (asyncCheckReader != null) - { - reader = asyncCheckReader.CoreReader; - } - _outerReader = this; - _coreReader = reader; - _coreReaderImpl = reader as XmlTextReaderImpl; - if (_coreReaderImpl == null) - { - XmlTextReader tr = reader as XmlTextReader; - if (tr != null) - { - _coreReaderImpl = tr.Impl; - } - } - if (_coreReaderImpl == null) - { - throw new ArgumentException(ResXml.Arg_ExpectingXmlTextReader, "reader"); - } - _coreReaderImpl.XmlValidatingReaderCompatibilityMode = true; - _coreReaderNSResolver = reader as IXmlNamespaceResolver; - _processIdentityConstraints = processIdentityConstraints; - -#pragma warning disable 618 - - _schemaCollection = new XmlSchemaCollection(_coreReader.NameTable); - -#pragma warning restore 618 - - _schemaCollection.XmlResolver = GetResolver(); - - _eventHandling = new ValidationEventHandling(this); - if (settingsEventHandler != null) - { - _eventHandling.AddHandler(settingsEventHandler); - } - _coreReaderImpl.ValidationEventHandling = _eventHandling; - _coreReaderImpl.OnDefaultAttributeUse = new XmlTextReaderImpl.OnDefaultAttributeUseDelegate(ValidateDefaultAttributeOnUse); - - _validationType = ValidationType.DTD; - SetupValidation(ValidationType.DTD); - } - - // - // XmlReader members - // - // Returns the current settings of the reader - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings; - if (_coreReaderImpl.V1Compat) - { - settings = null; - } - else - { - settings = _coreReader.Settings; - } - if (settings != null) - { - settings = settings.Clone(); - } - else - { - settings = new XmlReaderSettings(); - } - settings.ValidationType = ValidationType.DTD; - if (!_processIdentityConstraints) - { - settings.ValidationFlags &= ~XmlSchemaValidationFlags.ProcessIdentityConstraints; - } - settings.ReadOnly = true; - return settings; - } - } - - // Returns the type of the current node. - public override XmlNodeType NodeType - { - get - { - return _coreReader.NodeType; - } - } - - // Returns the name of the current node, including prefix. - public override string Name - { - get - { - return _coreReader.Name; - } - } - - // Returns local name of the current node (without prefix) - public override string LocalName - { - get - { - return _coreReader.LocalName; - } - } - - // Returns namespace name of the current node. - public override string NamespaceURI - { - get - { - return _coreReader.NamespaceURI; - } - } - - // Returns prefix associated with the current node. - public override string Prefix - { - get - { - return _coreReader.Prefix; - } - } - - // Returns true if the current node can have Value property != string.Empty. - public override bool HasValue - { - get - { - return _coreReader.HasValue; - } - } - - // Returns the text value of the current node. - public override string Value - { - get - { - return _coreReader.Value; - } - } - - // Returns the depth of the current node in the XML element stack - public override int Depth - { - get - { - return _coreReader.Depth; - } - } - - // Returns the base URI of the current node. - public override string BaseURI - { - get - { - return _coreReader.BaseURI; - } - } - - // Returns true if the current node is an empty element (for example, ). - public override bool IsEmptyElement - { - get - { - return _coreReader.IsEmptyElement; - } - } - - // Returns true of the current node is a default attribute declared in DTD. - public override bool IsDefault - { - get - { - return _coreReader.IsDefault; - } - } - - // Returns the quote character used in the current attribute declaration - public override char QuoteChar - { - get - { - return _coreReader.QuoteChar; - } - } - - // Returns the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - return _coreReader.XmlSpace; - } - } - - // Returns the current xml:lang scope. - public override string XmlLang - { - get - { - return _coreReader.XmlLang; - } - } - - // Returns the current read state of the reader - public override ReadState ReadState - { - get - { - return (_parsingFunction == ParsingFunction.Init) ? ReadState.Initial : _coreReader.ReadState; - } - } - - // Returns true if the reader reached end of the input data - public override bool EOF - { - get - { - return _coreReader.EOF; - } - } - - // Returns the XmlNameTable associated with this XmlReader - public override XmlNameTable NameTable - { - get - { - return _coreReader.NameTable; - } - } - - // Returns encoding of the XML document - internal Encoding Encoding - { - get - { - return _coreReaderImpl.Encoding; - } - } - - // Returns the number of attributes on the current node. - public override int AttributeCount - { - get - { - return _coreReader.AttributeCount; - } - } - - // Returns value of an attribute with the specified Name - public override string GetAttribute(string name) - { - return _coreReader.GetAttribute(name); - } - - // Returns value of an attribute with the specified LocalName and NamespaceURI - public override string GetAttribute(string localName, string namespaceURI) - { - return _coreReader.GetAttribute(localName, namespaceURI); - } - - // Returns value of an attribute at the specified index (position) - public override string GetAttribute(int i) - { - return _coreReader.GetAttribute(i); - } - - // Moves to an attribute with the specified Name - public override bool MoveToAttribute(string name) - { - if (!_coreReader.MoveToAttribute(name)) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - // Moves to an attribute with the specified LocalName and NamespceURI - public override bool MoveToAttribute(string localName, string namespaceURI) - { - if (!_coreReader.MoveToAttribute(localName, namespaceURI)) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - // Moves to an attribute at the specified index (position) - public override void MoveToAttribute(int i) - { - _coreReader.MoveToAttribute(i); - _parsingFunction = ParsingFunction.Read; - } - - // Moves to the first attribute of the current node - public override bool MoveToFirstAttribute() - { - if (!_coreReader.MoveToFirstAttribute()) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - // Moves to the next attribute of the current node - public override bool MoveToNextAttribute() - { - if (!_coreReader.MoveToNextAttribute()) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - // If on attribute, moves to the element that contains the attribute node - public override bool MoveToElement() - { - if (!_coreReader.MoveToElement()) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - // Reads and validated next node from the input data - public override bool Read() - { - switch (_parsingFunction) - { - case ParsingFunction.Read: - if (_coreReader.Read()) - { - ProcessCoreReaderEvent(); - return true; - } - else - { - _validator.CompleteValidation(); - return false; - } - case ParsingFunction.ParseDtdFromContext: - _parsingFunction = ParsingFunction.Read; - ParseDtdFromParserContext(); - goto case ParsingFunction.Read; - case ParsingFunction.Error: - case ParsingFunction.ReaderClosed: - return false; - case ParsingFunction.Init: - _parsingFunction = ParsingFunction.Read; // this changes the value returned by ReadState - if (_coreReader.ReadState == ReadState.Interactive) - { - ProcessCoreReaderEvent(); - return true; - } - else - { - goto case ParsingFunction.Read; - } - case ParsingFunction.ResolveEntityInternally: - _parsingFunction = ParsingFunction.Read; - ResolveEntityInternally(); - goto case ParsingFunction.Read; - case ParsingFunction.InReadBinaryContent: - _parsingFunction = ParsingFunction.Read; - _readBinaryHelper.Finish(); - goto case ParsingFunction.Read; - default: - Debug.Assert(false); - return false; - } - } - - // Closes the input stream ot TextReader, changes the ReadState to Closed and sets all properties to zero/string.Empty - public override void Close() - { - _coreReader.Close(); - _parsingFunction = ParsingFunction.ReaderClosed; - } - - // Returns NamespaceURI associated with the specified prefix in the current namespace scope. - public override String LookupNamespace(String prefix) - { - return _coreReaderImpl.LookupNamespace(prefix); - } - - // Iterates through the current attribute value's text and entity references chunks. - public override bool ReadAttributeValue() - { - if (_parsingFunction == ParsingFunction.InReadBinaryContent) - { - _parsingFunction = ParsingFunction.Read; - _readBinaryHelper.Finish(); - } - if (!_coreReader.ReadAttributeValue()) - { - return false; - } - _parsingFunction = ParsingFunction.Read; - return true; - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadChunkHelper if called the first time - if (_parsingFunction != ParsingFunction.InReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, _outerReader); - } - - // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper - _parsingFunction = ParsingFunction.Read; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count); - - // setup parsingFunction - _parsingFunction = ParsingFunction.InReadBinaryContent; - return readCount; - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadChunkHelper when called first time - if (_parsingFunction != ParsingFunction.InReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, _outerReader); - } - - // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper - _parsingFunction = ParsingFunction.Read; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count); - - // setup parsingFunction - _parsingFunction = ParsingFunction.InReadBinaryContent; - return readCount; - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadChunkHelper if called the first time - if (_parsingFunction != ParsingFunction.InReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, _outerReader); - } - - // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper - _parsingFunction = ParsingFunction.Read; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count); - - // setup parsingFunction - _parsingFunction = ParsingFunction.InReadBinaryContent; - return readCount; - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadChunkHelper when called first time - if (_parsingFunction != ParsingFunction.InReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, _outerReader); - } - - // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper - _parsingFunction = ParsingFunction.Read; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count); - - // setup parsingFunction - _parsingFunction = ParsingFunction.InReadBinaryContent; - return readCount; - } - - // Returns true if the XmlReader knows how to resolve general entities - public override bool CanResolveEntity - { - get - { - return true; - } - } - - // Resolves the current entity reference node - public override void ResolveEntity() - { - if (_parsingFunction == ParsingFunction.ResolveEntityInternally) - { - _parsingFunction = ParsingFunction.Read; - } - _coreReader.ResolveEntity(); - } - - internal XmlReader OuterReader - { - get - { - return _outerReader; - } - set - { -#pragma warning disable 618 - Debug.Assert(value is XmlValidatingReader); -#pragma warning restore 618 - _outerReader = value; - } - } - - internal void MoveOffEntityReference() - { - if (_outerReader.NodeType == XmlNodeType.EntityReference && _parsingFunction != ParsingFunction.ResolveEntityInternally) - { - if (!_outerReader.Read()) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - } - } - - public override string ReadString() - { - MoveOffEntityReference(); - return base.ReadString(); - } - - // - // IXmlLineInfo members - // - public bool HasLineInfo() - { - return true; - } - - // Returns the line number of the current node - public int LineNumber - { - get - { - return ((IXmlLineInfo)_coreReader).LineNumber; - } - } - - // Returns the line number of the current node - public int LinePosition - { - get - { - return ((IXmlLineInfo)_coreReader).LinePosition; - } - } - - // - // IXmlNamespaceResolver members - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return this.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return this.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return this.LookupPrefix(namespaceName); - } - - // Internal IXmlNamespaceResolver methods - internal IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - return _coreReaderNSResolver.GetNamespacesInScope(scope); - } - - internal string LookupPrefix(string namespaceName) - { - return _coreReaderNSResolver.LookupPrefix(namespaceName); - } - - // - // XmlValidatingReader members - // - // Specufies the validation event handler that wil get warnings and errors related to validation - internal event ValidationEventHandler ValidationEventHandler - { - add - { - _eventHandling.AddHandler(value); - } - remove - { - _eventHandling.RemoveHandler(value); ; - } - } - - // returns the schema type of the current node - internal object SchemaType - { - get - { - if (_validationType != ValidationType.None) - { - XmlSchemaType schemaTypeObj = _coreReaderImpl.InternalSchemaType as XmlSchemaType; - if (schemaTypeObj != null && schemaTypeObj.QualifiedName.Namespace == XmlReservedNs.NsXs) - { - return schemaTypeObj.Datatype; - } - return _coreReaderImpl.InternalSchemaType; - } - else - return null; - } - } - - // returns the underlying XmlTextReader or XmlTextReaderImpl - internal XmlReader Reader - { - get - { - return (XmlReader)_coreReader; - } - } - - // returns the underlying XmlTextReaderImpl - internal XmlTextReaderImpl ReaderImpl - { - get - { - return _coreReaderImpl; - } - } - - // specifies the validation type (None, DDT, XSD, XDR, Auto) - internal ValidationType ValidationType - { - get - { - return _validationType; - } - set - { - if (ReadState != ReadState.Initial) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - _validationType = value; - SetupValidation(value); - } - } - - // current schema collection used for validationg -#pragma warning disable 618 - internal XmlSchemaCollection Schemas - { - get - { - return _schemaCollection; - } - } -#pragma warning restore 618 - - // Spefifies whether general entities should be automatically expanded or not - internal EntityHandling EntityHandling - { - get - { - return _coreReaderImpl.EntityHandling; - } - set - { - _coreReaderImpl.EntityHandling = value; - } - } - - // Specifies XmlResolver used for opening the XML document and other external references - internal XmlResolver XmlResolver - { - set - { - _coreReaderImpl.XmlResolver = value; - _validator.XmlResolver = value; - _schemaCollection.XmlResolver = value; - } - } - - // Disables or enables support of W3C XML 1.0 Namespaces - internal bool Namespaces - { - get - { - return _coreReaderImpl.Namespaces; - } - set - { - _coreReaderImpl.Namespaces = value; - } - } - - // Returns typed value of the current node (based on the type specified by schema) - public object ReadTypedValue() - { - if (_validationType == ValidationType.None) - { - return null; - } - - switch (_outerReader.NodeType) - { - case XmlNodeType.Attribute: - return _coreReaderImpl.InternalTypedValue; - case XmlNodeType.Element: - if (SchemaType == null) - { - return null; - } - XmlSchemaDatatype dtype = (SchemaType is XmlSchemaDatatype) ? (XmlSchemaDatatype)SchemaType : ((XmlSchemaType)SchemaType).Datatype; - if (dtype != null) - { - if (!_outerReader.IsEmptyElement) - { - for (; ; ) - { - if (!_outerReader.Read()) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - XmlNodeType type = _outerReader.NodeType; - if (type != XmlNodeType.CDATA && type != XmlNodeType.Text && - type != XmlNodeType.Whitespace && type != XmlNodeType.SignificantWhitespace && - type != XmlNodeType.Comment && type != XmlNodeType.ProcessingInstruction) - { - break; - } - } - if (_outerReader.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_InvalidNodeType, _outerReader.NodeType.ToString()); - } - } - return _coreReaderImpl.InternalTypedValue; - } - return null; - - case XmlNodeType.EndElement: - return null; - - default: - if (_coreReaderImpl.V1Compat) - { //If v1 XmlValidatingReader return null - return null; - } - else - { - return Value; - } - } - } - - // - // Private implementation methods - // - - private void ParseDtdFromParserContext() - { - Debug.Assert(_parserContext != null); - Debug.Assert(_coreReaderImpl.DtdInfo == null); - - if (_parserContext.DocTypeName == null || _parserContext.DocTypeName.Length == 0) - { - return; - } - - IDtdParser dtdParser = DtdParser.Create(); - XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(_coreReaderImpl); - IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(_parserContext.BaseURI, _parserContext.DocTypeName, _parserContext.PublicId, - _parserContext.SystemId, _parserContext.InternalSubset, proxy); - _coreReaderImpl.SetDtdInfo(dtdInfo); - - ValidateDtd(); - } - - private void ValidateDtd() - { - IDtdInfo dtdInfo = _coreReaderImpl.DtdInfo; - if (dtdInfo != null) - { - switch (_validationType) - { -#pragma warning disable 618 - case ValidationType.Auto: - SetupValidation(ValidationType.DTD); - goto case ValidationType.DTD; -#pragma warning restore 618 - case ValidationType.DTD: - case ValidationType.None: - _validator.DtdInfo = dtdInfo; - break; - } - } - } - - private void ResolveEntityInternally() - { - Debug.Assert(_coreReader.NodeType == XmlNodeType.EntityReference); - int initialDepth = _coreReader.Depth; - _outerReader.ResolveEntity(); - while (_outerReader.Read() && _coreReader.Depth > initialDepth) ; - } - - // SxS: This method resolves an Uri but does not expose it to caller. It's OK to disable the SxS warning. - - - private void SetupValidation(ValidationType valType) - { - _validator = BaseValidator.CreateInstance(valType, this, _schemaCollection, _eventHandling, _processIdentityConstraints); - - XmlResolver resolver = GetResolver(); - _validator.XmlResolver = resolver; - - if (_outerReader.BaseURI.Length > 0) - { - _validator.BaseUri = (resolver == null) ? new Uri(_outerReader.BaseURI, UriKind.RelativeOrAbsolute) : resolver.ResolveUri(null, _outerReader.BaseURI); - } - _coreReaderImpl.ValidationEventHandling = (_validationType == ValidationType.None) ? null : _eventHandling; - } - - private static XmlResolver s_tempResolver; - - // This is needed because we can't have the setter for XmlResolver public and with internal getter. - private XmlResolver GetResolver() - { - XmlResolver tempResolver = _coreReaderImpl.GetResolver(); - - if (tempResolver == null && !_coreReaderImpl.IsResolverSet && - !Microsoft.Xml.XmlReaderSettings.EnableLegacyXmlSettings()) - { - // it is safe to return valid resolver as it'll be used in the schema validation - if (s_tempResolver == null) - s_tempResolver = new XmlUrlResolver(); - return s_tempResolver; - } - - return tempResolver; - } - - // - // Internal methods for validators, DOM, XPathDocument etc. - // - private void ProcessCoreReaderEvent() - { - switch (_coreReader.NodeType) - { - case XmlNodeType.Whitespace: - if (_coreReader.Depth > 0 || _coreReaderImpl.FragmentType != XmlNodeType.Document) - { - if (_validator.PreserveWhitespace) - { - _coreReaderImpl.ChangeCurrentNodeType(XmlNodeType.SignificantWhitespace); - } - } - goto default; - case XmlNodeType.DocumentType: - ValidateDtd(); - break; - case XmlNodeType.EntityReference: - _parsingFunction = ParsingFunction.ResolveEntityInternally; - goto default; - default: - _coreReaderImpl.InternalSchemaType = null; - _coreReaderImpl.InternalTypedValue = null; - _validator.Validate(); - break; - } - } - - internal void Close(bool closeStream) - { - _coreReaderImpl.Close(closeStream); - _parsingFunction = ParsingFunction.ReaderClosed; - } - - internal BaseValidator Validator - { - get - { - return _validator; - } - set - { - _validator = value; - } - } - - internal override XmlNamespaceManager NamespaceManager - { - get - { - return _coreReaderImpl.NamespaceManager; - } - } - - internal bool StandAlone - { - get - { - return _coreReaderImpl.StandAlone; - } - } - - internal object SchemaTypeObject - { - set - { - _coreReaderImpl.InternalSchemaType = value; - } - } - - internal object TypedValueObject - { - get - { - return _coreReaderImpl.InternalTypedValue; - } - set - { - _coreReaderImpl.InternalTypedValue = value; - } - } - - internal bool Normalization - { - get - { - return _coreReaderImpl.Normalization; - } - } - - internal bool AddDefaultAttribute(SchemaAttDef attdef) - { - return _coreReaderImpl.AddDefaultAttributeNonDtd(attdef); - } - - internal override IDtdInfo DtdInfo - { - get { return _coreReaderImpl.DtdInfo; } - } - - internal void ValidateDefaultAttributeOnUse(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader) - { - SchemaAttDef attdef = defaultAttribute as SchemaAttDef; - if (attdef == null) - { - return; - } - - if (!attdef.DefaultValueChecked) - { - SchemaInfo schemaInfo = coreReader.DtdInfo as SchemaInfo; - if (schemaInfo == null) - { - return; - } - DtdValidator.CheckDefaultValue(attdef, schemaInfo, _eventHandling, coreReader.BaseURI); - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriter.cs deleted file mode 100644 index 2ef6fd9c205..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriter.cs +++ /dev/null @@ -1,2295 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Globalization; -using System.Collections.Generic; - -// OpenIssue : is it better to cache the current namespace decls for each elem -// as the current code does, or should it just always walk the namespace stack? - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlWellFormedWriter : XmlWriter - { - // - // Private types used by the XmlWellFormedWriter are defined in XmlWellFormedWriterHelpers.cs - // - - // - // Fields - // - // underlying writer - private XmlWriter _writer; - private XmlRawWriter _rawWriter; // writer as XmlRawWriter - private IXmlNamespaceResolver _predefinedNamespaces; // writer as IXmlNamespaceResolver - - // namespace management - private Namespace[] _nsStack; - private int _nsTop; - private Dictionary _nsHashtable; - private bool _useNsHashtable; - - // element scoping - private ElementScope[] _elemScopeStack; - private int _elemTop; - - // attribute tracking - private AttrName[] _attrStack; - private int _attrCount; - private Dictionary _attrHashTable; - - // special attribute caching (xmlns, xml:space, xml:lang) - private SpecialAttribute _specAttr = SpecialAttribute.No; - private AttributeValueCache _attrValueCache; - private string _curDeclPrefix; - - // state machine - private State[] _stateTable; - private State _currentState; - - // settings - private bool _checkCharacters; - private bool _omitDuplNamespaces; - private bool _writeEndDocumentOnClose; - - // actual conformance level - private ConformanceLevel _conformanceLevel; - - // flags - private bool _dtdWritten; - private bool _xmlDeclFollows; - - // char type tables - private XmlCharType _xmlCharType = XmlCharType.Instance; - - // hash randomizer - private SecureStringHasher _hasher; - - - // - // Constants - // - private const int ElementStackInitialSize = 8; - private const int NamespaceStackInitialSize = 8; - private const int AttributeArrayInitialSize = 8; -#if DEBUG - private const int MaxAttrDuplWalkCount = 2; - private const int MaxNamespacesWalkCount = 3; -#else - private const int MaxAttrDuplWalkCount = 14; - private const int MaxNamespacesWalkCount = 16; -#endif - - // - // State tables - // - private enum State - { - Start = 0, - TopLevel = 1, - Document = 2, - Element = 3, - Content = 4, - B64Content = 5, - B64Attribute = 6, - AfterRootEle = 7, - Attribute = 8, - SpecialAttr = 9, - EndDocument = 10, - RootLevelAttr = 11, - RootLevelSpecAttr = 12, - RootLevelB64Attr = 13, - AfterRootLevelAttr = 14, - Closed = 15, - Error = 16, - - StartContent = 101, - StartContentEle = 102, - StartContentB64 = 103, - StartDoc = 104, - StartDocEle = 106, - EndAttrSEle = 107, - EndAttrEEle = 108, - EndAttrSCont = 109, - EndAttrSAttr = 111, - PostB64Cont = 112, - PostB64Attr = 113, - PostB64RootAttr = 114, - StartFragEle = 115, - StartFragCont = 116, - StartFragB64 = 117, - StartRootLevelAttr = 118, - } - - private enum Token - { - StartDocument, - EndDocument, - PI, - Comment, - Dtd, - StartElement, - EndElement, - StartAttribute, - EndAttribute, - Text, - CData, - AtomicValue, - Base64, - RawData, - Whitespace, - } - - internal static readonly string[] stateName = { - "Start", // State.Start - "TopLevel", // State.TopLevel - "Document", // State.Document - "Element Start Tag", // State.Element - "Element Content", // State.Content - "Element Content", // State.B64Content - "Attribute", // State.B64Attribute - "EndRootElement", // State.AfterRootEle - "Attribute", // State.Attribute - "Special Attribute", // State.SpecialAttr - "End Document", // State.EndDocument - "Root Level Attribute Value", // State.RootLevelAttr - "Root Level Special Attribute Value", // State.RootLevelSpecAttr - "Root Level Base64 Attribute Value", // State.RootLevelB64Attr - "After Root Level Attribute", // State.AfterRootLevelAttr - "Closed", // State.Closed - "Error", // State.Error - }; - - internal static readonly string[] tokenName = { - "StartDocument", // Token.StartDocument - "EndDocument", // Token.EndDocument - "PI", // Token.PI - "Comment", // Token.Comment - "DTD", // Token.Dtd - "StartElement", // Token.StartElement - "EndElement", // Token.EndElement - "StartAttribute", // Token.StartAttribut - "EndAttribute", // Token.EndAttribute - "Text", // Token.Text - "CDATA", // Token.CData - "Atomic value", // Token.AtomicValue - "Base64", // Token.Base64 - "RawData", // Token.RawData - "Whitespace", // Token.Whitespace - }; - - private static WriteState[] s_state2WriteState = { - WriteState.Start, // State.Start - WriteState.Prolog, // State.TopLevel - WriteState.Prolog, // State.Document - WriteState.Element, // State.Element - WriteState.Content, // State.Content - WriteState.Content, // State.B64Content - WriteState.Attribute, // State.B64Attribute - WriteState.Content, // State.AfterRootEle - WriteState.Attribute, // State.Attribute - WriteState.Attribute, // State.SpecialAttr - WriteState.Content, // State.EndDocument - WriteState.Attribute, // State.RootLevelAttr - WriteState.Attribute, // State.RootLevelSpecAttr - WriteState.Attribute, // State.RootLevelB64Attr - WriteState.Attribute, // State.AfterRootLevelAttr - WriteState.Closed, // State.Closed - WriteState.Error, // State.Error - }; - - private static readonly State[] s_stateTableDocument = { - // State.Start State.TopLevel State.Document State.Element State.Content State.B64Content State.B64Attribute State.AfterRootEle State.Attribute, State.SpecialAttr, State.EndDocument, State.RootLevelAttr, State.RootLevelSpecAttr, State.RootLevelB64Attr State.AfterRootLevelAttr, // 16 - /* Token.StartDocument */ State.Document, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.EndDocument */ State.Error, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.Error, State.EndDocument, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.PI */ State.StartDoc, State.TopLevel, State.Document, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Comment */ State.StartDoc, State.TopLevel, State.Document, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Dtd */ State.StartDoc, State.TopLevel, State.Document, State.Error, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.StartElement */ State.StartDocEle, State.Element, State.Element, State.StartContentEle, State.Element, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrSEle, State.EndAttrSEle, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.EndElement */ State.Error, State.Error, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrEEle, State.EndAttrEEle, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.StartAttribute */ State.Error, State.Error, State.Error, State.Attribute, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrSAttr, State.EndAttrSAttr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.EndAttribute */ State.Error, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.Element, State.Element, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Text */ State.Error, State.Error, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Error, State.Attribute, State.SpecialAttr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.CData */ State.Error, State.Error, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.AtomicValue */ State.Error, State.Error, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Error, State.Attribute, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Base64 */ State.Error, State.Error, State.Error, State.StartContentB64, State.B64Content, State.B64Content, State.B64Attribute, State.Error, State.B64Attribute, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.RawData */ State.StartDoc, State.Error, State.Document, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.Attribute, State.SpecialAttr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, - /* Token.Whitespace */ State.StartDoc, State.TopLevel, State.Document, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.Attribute, State.SpecialAttr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error - }; - - private static readonly State[] s_stateTableAuto = { - // State.Start State.TopLevel State.Document State.Element State.Content State.B64Content State.B64Attribute State.AfterRootEle State.Attribute, State.SpecialAttr, State.EndDocument, State.RootLevelAttr, State.RootLevelSpecAttr, State.RootLevelB64Attr, State.AfterRootLevelAttr // 16 - /* Token.StartDocument */ State.Document, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.StartDocument */ - /* Token.EndDocument */ State.Error, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.Error, State.EndDocument, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.EndDocument */ - /* Token.PI */ State.TopLevel, State.TopLevel, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.PI */ - /* Token.Comment */ State.TopLevel, State.TopLevel, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.Comment */ - /* Token.Dtd */ State.StartDoc, State.TopLevel, State.Error, State.Error, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.Dtd */ - /* Token.StartElement */ State.StartFragEle, State.Element, State.Error, State.StartContentEle, State.Element, State.PostB64Cont, State.PostB64Attr, State.Element, State.EndAttrSEle, State.EndAttrSEle, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.StartElement */ - /* Token.EndElement */ State.Error, State.Error, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrEEle, State.EndAttrEEle, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.EndElement */ - /* Token.StartAttribute */ State.RootLevelAttr, State.Error, State.Error, State.Attribute, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.EndAttrSAttr, State.EndAttrSAttr, State.Error, State.StartRootLevelAttr, State.StartRootLevelAttr, State.PostB64RootAttr, State.RootLevelAttr, State.Error, /* Token.StartAttribute */ - /* Token.EndAttribute */ State.Error, State.Error, State.Error, State.Error, State.Error, State.PostB64Cont, State.PostB64Attr, State.Error, State.Element, State.Element, State.Error, State.AfterRootLevelAttr, State.AfterRootLevelAttr, State.PostB64RootAttr, State.Error, State.Error, /* Token.EndAttribute */ - /* Token.Text */ State.StartFragCont, State.StartFragCont, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Content, State.Attribute, State.SpecialAttr, State.Error, State.RootLevelAttr, State.RootLevelSpecAttr, State.PostB64RootAttr, State.Error, State.Error, /* Token.Text */ - /* Token.CData */ State.StartFragCont, State.StartFragCont, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Content, State.EndAttrSCont, State.EndAttrSCont, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error, /* Token.CData */ - /* Token.AtomicValue */ State.StartFragCont, State.StartFragCont, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Content, State.Attribute, State.Error, State.Error, State.RootLevelAttr, State.Error, State.PostB64RootAttr, State.Error, State.Error, /* Token.AtomicValue */ - /* Token.Base64 */ State.StartFragB64, State.StartFragB64, State.Error, State.StartContentB64, State.B64Content, State.B64Content, State.B64Attribute, State.B64Content, State.B64Attribute, State.Error, State.Error, State.RootLevelB64Attr, State.Error, State.RootLevelB64Attr, State.Error, State.Error, /* Token.Base64 */ - /* Token.RawData */ State.StartFragCont, State.TopLevel, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.Content, State.Attribute, State.SpecialAttr, State.Error, State.RootLevelAttr, State.RootLevelSpecAttr, State.PostB64RootAttr, State.AfterRootLevelAttr, State.Error, /* Token.RawData */ - /* Token.Whitespace */ State.TopLevel, State.TopLevel, State.Error, State.StartContent, State.Content, State.PostB64Cont, State.PostB64Attr, State.AfterRootEle, State.Attribute, State.SpecialAttr, State.Error, State.RootLevelAttr, State.RootLevelSpecAttr, State.PostB64RootAttr, State.AfterRootLevelAttr, State.Error, /* Token.Whitespace */ - }; - - // - // Constructor & finalizer - // - internal XmlWellFormedWriter(XmlWriter writer, XmlWriterSettings settings) - { - Debug.Assert(writer != null); - Debug.Assert(settings != null); - Debug.Assert(MaxNamespacesWalkCount <= 3); - - _writer = writer; - - _rawWriter = writer as XmlRawWriter; - _predefinedNamespaces = writer as IXmlNamespaceResolver; - if (_rawWriter != null) - { - _rawWriter.NamespaceResolver = new NamespaceResolverProxy(this); - } - - _checkCharacters = settings.CheckCharacters; - _omitDuplNamespaces = (settings.NamespaceHandling & NamespaceHandling.OmitDuplicates) != 0; - _writeEndDocumentOnClose = settings.WriteEndDocumentOnClose; - - _conformanceLevel = settings.ConformanceLevel; - _stateTable = (_conformanceLevel == ConformanceLevel.Document) ? s_stateTableDocument : s_stateTableAuto; - - _currentState = State.Start; - - _nsStack = new Namespace[NamespaceStackInitialSize]; - _nsStack[0].Set("xmlns", XmlReservedNs.NsXmlNs, NamespaceKind.Special); - _nsStack[1].Set("xml", XmlReservedNs.NsXml, NamespaceKind.Special); - if (_predefinedNamespaces == null) - { - _nsStack[2].Set(string.Empty, string.Empty, NamespaceKind.Implied); - } - else - { - string defaultNs = _predefinedNamespaces.LookupNamespace(string.Empty); - _nsStack[2].Set(string.Empty, (defaultNs == null ? string.Empty : defaultNs), NamespaceKind.Implied); - } - _nsTop = 2; - - _elemScopeStack = new ElementScope[ElementStackInitialSize]; - _elemScopeStack[0].Set(string.Empty, string.Empty, string.Empty, _nsTop); - _elemScopeStack[0].xmlSpace = XmlSpace.None; - _elemScopeStack[0].xmlLang = null; - _elemTop = 0; - - _attrStack = new AttrName[AttributeArrayInitialSize]; - - _hasher = new SecureStringHasher(); - } - - // - // XmlWriter implementation - // - public override WriteState WriteState - { - get - { - if ((int)_currentState <= (int)State.Error) - { - return s_state2WriteState[(int)_currentState]; - } - else - { - Debug.Assert(false, "Expected currentState <= State.Error "); - return WriteState.Error; - } - } - } - - public override XmlWriterSettings Settings - { - get - { - XmlWriterSettings settings = _writer.Settings; - settings.ReadOnly = false; - settings.ConformanceLevel = _conformanceLevel; - if (_omitDuplNamespaces) - { - settings.NamespaceHandling |= NamespaceHandling.OmitDuplicates; - } - settings.WriteEndDocumentOnClose = _writeEndDocumentOnClose; - settings.ReadOnly = true; - return settings; - } - } - - public override void WriteStartDocument() - { - WriteStartDocumentImpl(XmlStandalone.Omit); - } - - public override void WriteStartDocument(bool standalone) - { - WriteStartDocumentImpl(standalone ? XmlStandalone.Yes : XmlStandalone.No); - } - - public override void WriteEndDocument() - { - try - { - // auto-close all elements - while (_elemTop > 0) - { - WriteEndElement(); - } - State prevState = _currentState; - AdvanceState(Token.EndDocument); - - if (prevState != State.AfterRootEle) - { - throw new ArgumentException(ResXml.Xml_NoRoot); - } - if (_rawWriter == null) - { - _writer.WriteEndDocument(); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - try - { - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - XmlConvert.VerifyQName(name, ExceptionType.XmlException); - - if (_conformanceLevel == ConformanceLevel.Fragment) - { - throw new InvalidOperationException(ResXml.Xml_DtdNotAllowedInFragment); - } - - AdvanceState(Token.Dtd); - if (_dtdWritten) - { - _currentState = State.Error; - throw new InvalidOperationException(ResXml.Xml_DtdAlreadyWritten); - } - - if (_conformanceLevel == ConformanceLevel.Auto) - { - _conformanceLevel = ConformanceLevel.Document; - _stateTable = s_stateTableDocument; - } - - int i; - - // check characters - if (_checkCharacters) - { - if (pubid != null) - { - if ((i = _xmlCharType.IsPublicId(pubid)) >= 0) - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(pubid, i)), "pubid"); - } - } - if (sysid != null) - { - if ((i = _xmlCharType.IsOnlyCharData(sysid)) >= 0) - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(sysid, i)), "sysid"); - } - } - if (subset != null) - { - if ((i = _xmlCharType.IsOnlyCharData(subset)) >= 0) - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(subset, i)), "subset"); - } - } - } - - // write doctype - _writer.WriteDocType(name, pubid, sysid, subset); - _dtdWritten = true; - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - try - { - // check local name - if (localName == null || localName.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyLocalName); - } - CheckNCName(localName); - - AdvanceState(Token.StartElement); - - // lookup prefix / namespace - if (prefix == null) - { - if (ns != null) - { - prefix = LookupPrefix(ns); - } - if (prefix == null) - { - prefix = string.Empty; - } - } - else if (prefix.Length > 0) - { - CheckNCName(prefix); - if (ns == null) - { - ns = LookupNamespace(prefix); - } - if (ns == null || (ns != null && ns.Length == 0)) - { - throw new ArgumentException(ResXml.Xml_PrefixForEmptyNs); - } - } - if (ns == null) - { - ns = LookupNamespace(prefix); - if (ns == null) - { - Debug.Assert(prefix.Length == 0); - ns = string.Empty; - } - } - - if (_elemTop == 0 && _rawWriter != null) - { - // notify the underlying raw writer about the root level element - _rawWriter.OnRootElement(_conformanceLevel); - } - - // write start tag - _writer.WriteStartElement(prefix, localName, ns); - - // push element on stack and add/check namespace - int top = ++_elemTop; - if (top == _elemScopeStack.Length) - { - ElementScope[] newStack = new ElementScope[top * 2]; - Array.Copy(_elemScopeStack, newStack, top); - _elemScopeStack = newStack; - } - _elemScopeStack[top].Set(prefix, localName, ns, _nsTop); - - PushNamespaceImplicit(prefix, ns); - - if (_attrCount >= MaxAttrDuplWalkCount) - { - _attrHashTable.Clear(); - } - _attrCount = 0; - } - catch - { - _currentState = State.Error; - throw; - } - } - - - public override void WriteEndElement() - { - try - { - AdvanceState(Token.EndElement); - - int top = _elemTop; - if (top == 0) - { - throw new XmlException(ResXml.Xml_NoStartTag, string.Empty); - } - - // write end tag - if (_rawWriter != null) - { - _elemScopeStack[top].WriteEndElement(_rawWriter); - } - else - { - _writer.WriteEndElement(); - } - - // pop namespaces - int prevNsTop = _elemScopeStack[top].prevNSTop; - if (_useNsHashtable && prevNsTop < _nsTop) - { - PopNamespaces(prevNsTop + 1, _nsTop); - } - _nsTop = prevNsTop; - _elemTop = --top; - - // check "one root element" condition for ConformanceLevel.Document - if (top == 0) - { - if (_conformanceLevel == ConformanceLevel.Document) - { - _currentState = State.AfterRootEle; - } - else - { - _currentState = State.TopLevel; - } - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteFullEndElement() - { - try - { - AdvanceState(Token.EndElement); - - int top = _elemTop; - if (top == 0) - { - throw new XmlException(ResXml.Xml_NoStartTag, string.Empty); - } - - // write end tag - if (_rawWriter != null) - { - _elemScopeStack[top].WriteFullEndElement(_rawWriter); - } - else - { - _writer.WriteFullEndElement(); - } - - // pop namespaces - int prevNsTop = _elemScopeStack[top].prevNSTop; - if (_useNsHashtable && prevNsTop < _nsTop) - { - PopNamespaces(prevNsTop + 1, _nsTop); - } - _nsTop = prevNsTop; - _elemTop = --top; - - // check "one root element" condition for ConformanceLevel.Document - if (top == 0) - { - if (_conformanceLevel == ConformanceLevel.Document) - { - _currentState = State.AfterRootEle; - } - else - { - _currentState = State.TopLevel; - } - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteStartAttribute(string prefix, string localName, string namespaceName) - { - try - { - // check local name - if (localName == null || localName.Length == 0) - { - if (prefix == "xmlns") - { - localName = "xmlns"; - prefix = string.Empty; - } - else - { - throw new ArgumentException(ResXml.Xml_EmptyLocalName); - } - } - CheckNCName(localName); - - AdvanceState(Token.StartAttribute); - - // lookup prefix / namespace - if (prefix == null) - { - if (namespaceName != null) - { - // special case prefix=null/localname=xmlns - if (!(localName == "xmlns" && namespaceName == XmlReservedNs.NsXmlNs)) - prefix = LookupPrefix(namespaceName); - } - if (prefix == null) - { - prefix = string.Empty; - } - } - if (namespaceName == null) - { - if (prefix != null && prefix.Length > 0) - { - namespaceName = LookupNamespace(prefix); - } - if (namespaceName == null) - { - namespaceName = string.Empty; - } - } - - if (prefix.Length == 0) - { - if (localName[0] == 'x' && localName == "xmlns") - { - if (namespaceName.Length > 0 && namespaceName != XmlReservedNs.NsXmlNs) - { - throw new ArgumentException(ResXml.Xml_XmlnsPrefix); - } - _curDeclPrefix = String.Empty; - SetSpecialAttribute(SpecialAttribute.DefaultXmlns); - goto SkipPushAndWrite; - } - else if (namespaceName.Length > 0) - { - prefix = LookupPrefix(namespaceName); - if (prefix == null || prefix.Length == 0) - { - prefix = GeneratePrefix(); - } - } - } - else - { - if (prefix[0] == 'x') - { - if (prefix == "xmlns") - { - if (namespaceName.Length > 0 && namespaceName != XmlReservedNs.NsXmlNs) - { - throw new ArgumentException(ResXml.Xml_XmlnsPrefix); - } - _curDeclPrefix = localName; - SetSpecialAttribute(SpecialAttribute.PrefixedXmlns); - goto SkipPushAndWrite; - } - else if (prefix == "xml") - { - if (namespaceName.Length > 0 && namespaceName != XmlReservedNs.NsXml) - { - throw new ArgumentException(ResXml.Xml_XmlPrefix); - } - switch (localName) - { - case "space": - SetSpecialAttribute(SpecialAttribute.XmlSpace); - goto SkipPushAndWrite; - case "lang": - SetSpecialAttribute(SpecialAttribute.XmlLang); - goto SkipPushAndWrite; - } - } - } - - CheckNCName(prefix); - - if (namespaceName.Length == 0) - { - // attributes cannot have default namespace - prefix = string.Empty; - } - else - { - string definedNs = LookupLocalNamespace(prefix); - if (definedNs != null && definedNs != namespaceName) - { - prefix = GeneratePrefix(); - } - } - } - - if (prefix.Length != 0) - { - PushNamespaceImplicit(prefix, namespaceName); - } - - SkipPushAndWrite: - - // add attribute to the list and check for duplicates - AddAttribute(prefix, localName, namespaceName); - - if (_specAttr == SpecialAttribute.No) - { - // write attribute name - _writer.WriteStartAttribute(prefix, localName, namespaceName); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteEndAttribute() - { - try - { - AdvanceState(Token.EndAttribute); - - if (_specAttr != SpecialAttribute.No) - { - string value; - - switch (_specAttr) - { - case SpecialAttribute.DefaultXmlns: - value = _attrValueCache.StringValue; - if (PushNamespaceExplicit(string.Empty, value)) - { // returns true if the namespace declaration should be written out - if (_rawWriter != null) - { - if (_rawWriter.SupportsNamespaceDeclarationInChunks) - { - _rawWriter.WriteStartNamespaceDeclaration(string.Empty); - _attrValueCache.Replay(_rawWriter); - _rawWriter.WriteEndNamespaceDeclaration(); - } - else - { - _rawWriter.WriteNamespaceDeclaration(string.Empty, value); - } - } - else - { - _writer.WriteStartAttribute(string.Empty, "xmlns", XmlReservedNs.NsXmlNs); - _attrValueCache.Replay(_writer); - _writer.WriteEndAttribute(); - } - } - _curDeclPrefix = null; - break; - case SpecialAttribute.PrefixedXmlns: - value = _attrValueCache.StringValue; - if (value.Length == 0) - { - throw new ArgumentException(ResXml.Xml_PrefixForEmptyNs); - } - if (value == XmlReservedNs.NsXmlNs || (value == XmlReservedNs.NsXml && _curDeclPrefix != "xml")) - { - throw new ArgumentException(ResXml.Xml_CanNotBindToReservedNamespace); - } - if (PushNamespaceExplicit(_curDeclPrefix, value)) - { // returns true if the namespace declaration should be written out - if (_rawWriter != null) - { - if (_rawWriter.SupportsNamespaceDeclarationInChunks) - { - _rawWriter.WriteStartNamespaceDeclaration(_curDeclPrefix); - _attrValueCache.Replay(_rawWriter); - _rawWriter.WriteEndNamespaceDeclaration(); - } - else - { - _rawWriter.WriteNamespaceDeclaration(_curDeclPrefix, value); - } - } - else - { - _writer.WriteStartAttribute("xmlns", _curDeclPrefix, XmlReservedNs.NsXmlNs); - _attrValueCache.Replay(_writer); - _writer.WriteEndAttribute(); - } - } - _curDeclPrefix = null; - break; - case SpecialAttribute.XmlSpace: - _attrValueCache.Trim(); - value = _attrValueCache.StringValue; - - if (value == "default") - { - _elemScopeStack[_elemTop].xmlSpace = XmlSpace.Default; - } - else if (value == "preserve") - { - _elemScopeStack[_elemTop].xmlSpace = XmlSpace.Preserve; - } - else - { - throw new ArgumentException(string.Format(ResXml.Xml_InvalidXmlSpace, value)); - } - _writer.WriteStartAttribute("xml", "space", XmlReservedNs.NsXml); - _attrValueCache.Replay(_writer); - _writer.WriteEndAttribute(); - break; - case SpecialAttribute.XmlLang: - value = _attrValueCache.StringValue; - _elemScopeStack[_elemTop].xmlLang = value; - _writer.WriteStartAttribute("xml", "lang", XmlReservedNs.NsXml); - _attrValueCache.Replay(_writer); - _writer.WriteEndAttribute(); - break; - } - _specAttr = SpecialAttribute.No; - _attrValueCache.Clear(); - } - else - { - _writer.WriteEndAttribute(); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteCData(string text) - { - try - { - if (text == null) - { - text = string.Empty; - } - AdvanceState(Token.CData); - _writer.WriteCData(text); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteComment(string text) - { - try - { - if (text == null) - { - text = string.Empty; - } - AdvanceState(Token.Comment); - _writer.WriteComment(text); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteProcessingInstruction(string name, string text) - { - try - { - // check name - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - CheckNCName(name); - - // check text - if (text == null) - { - text = string.Empty; - } - - // xml declaration is a special case (not a processing instruction, but we allow WriteProcessingInstruction as a convenience) - if (name.Length == 3 && string.Compare(name, "xml", StringComparison.OrdinalIgnoreCase) == 0) - { - if (_currentState != State.Start) - { - throw new ArgumentException(_conformanceLevel == ConformanceLevel.Document ? ResXml.Xml_DupXmlDecl : ResXml.Xml_CannotWriteXmlDecl); - } - - _xmlDeclFollows = true; - AdvanceState(Token.PI); - - if (_rawWriter != null) - { - // Translate PI into an xml declaration - _rawWriter.WriteXmlDeclaration(text); - } - else - { - _writer.WriteProcessingInstruction(name, text); - } - } - else - { - AdvanceState(Token.PI); - _writer.WriteProcessingInstruction(name, text); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteEntityRef(string name) - { - try - { - // check name - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - CheckNCName(name); - - AdvanceState(Token.Text); - if (SaveAttrValue) - { - _attrValueCache.WriteEntityRef(name); - } - else - { - _writer.WriteEntityRef(name); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteCharEntity(char ch) - { - try - { - if (Char.IsSurrogate(ch)) - { - throw new ArgumentException(ResXml.Xml_InvalidSurrogateMissingLowChar); - } - - AdvanceState(Token.Text); - if (SaveAttrValue) - { - _attrValueCache.WriteCharEntity(ch); - } - else - { - _writer.WriteCharEntity(ch); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - try - { - if (!Char.IsSurrogatePair(highChar, lowChar)) - { - throw XmlConvert.CreateInvalidSurrogatePairException(lowChar, highChar); - } - - AdvanceState(Token.Text); - if (SaveAttrValue) - { - _attrValueCache.WriteSurrogateCharEntity(lowChar, highChar); - } - else - { - _writer.WriteSurrogateCharEntity(lowChar, highChar); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteWhitespace(string ws) - { - try - { - if (ws == null) - { - ws = string.Empty; - } - if (!XmlCharType.Instance.IsOnlyWhitespace(ws)) - { - throw new ArgumentException(ResXml.Xml_NonWhitespace); - } - - AdvanceState(Token.Whitespace); - if (SaveAttrValue) - { - _attrValueCache.WriteWhitespace(ws); - } - else - { - _writer.WriteWhitespace(ws); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteString(string text) - { - try - { - if (text == null) - { - return; - } - - AdvanceState(Token.Text); - if (SaveAttrValue) - { - _attrValueCache.WriteString(text); - } - else - { - _writer.WriteString(text); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteChars(char[] buffer, int index, int count) - { - try - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - AdvanceState(Token.Text); - if (SaveAttrValue) - { - _attrValueCache.WriteChars(buffer, index, count); - } - else - { - _writer.WriteChars(buffer, index, count); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - try - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - AdvanceState(Token.RawData); - if (SaveAttrValue) - { - _attrValueCache.WriteRaw(buffer, index, count); - } - else - { - _writer.WriteRaw(buffer, index, count); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteRaw(string data) - { - try - { - if (data == null) - { - return; - } - - AdvanceState(Token.RawData); - if (SaveAttrValue) - { - _attrValueCache.WriteRaw(data); - } - else - { - _writer.WriteRaw(data); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - try - { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (count > buffer.Length - index) - { - throw new ArgumentOutOfRangeException("count"); - } - - AdvanceState(Token.Base64); - _writer.WriteBase64(buffer, index, count); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void Close() - { - if (_currentState != State.Closed) - { - try - { - if (_writeEndDocumentOnClose) - { - while (_currentState != State.Error && _elemTop > 0) - { - WriteEndElement(); - } - } - else - { - if (_currentState != State.Error && _elemTop > 0) - { - //finish the start element tag '>' - try - { - AdvanceState(Token.EndElement); - } - catch - { - _currentState = State.Error; - throw; - } - } - } - - if (InBase64 && _rawWriter != null) - { - _rawWriter.WriteEndBase64(); - } - - _writer.Flush(); - } - finally - { - try - { - if (_rawWriter != null) - { - _rawWriter.Close(WriteState); - } - else - { - _writer.Close(); - } - } - finally - { - _currentState = State.Closed; - } - } - } - } - - public override void Flush() - { - try - { - _writer.Flush(); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override string LookupPrefix(string ns) - { - try - { - if (ns == null) - { - throw new ArgumentNullException("ns"); - } - for (int i = _nsTop; i >= 0; i--) - { - if (_nsStack[i].namespaceUri == ns) - { - string prefix = _nsStack[i].prefix; - for (i++; i <= _nsTop; i++) - { - if (_nsStack[i].prefix == prefix) - { - return null; - } - } - return prefix; - } - } - return (_predefinedNamespaces != null) ? _predefinedNamespaces.LookupPrefix(ns) : null; - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override XmlSpace XmlSpace - { - get - { - int i; - for (i = _elemTop; i >= 0 && _elemScopeStack[i].xmlSpace == (Microsoft.Xml.XmlSpace)(int)-1; i--) ; - Debug.Assert(i >= 0); - return _elemScopeStack[i].xmlSpace; - } - } - - public override string XmlLang - { - get - { - int i; - for (i = _elemTop; i > 0 && _elemScopeStack[i].xmlLang == null; i--) ; - Debug.Assert(i >= 0); - return _elemScopeStack[i].xmlLang; - } - } - - public override void WriteQualifiedName(string localName, string ns) - { - try - { - if (localName == null || localName.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyLocalName); - } - CheckNCName(localName); - - AdvanceState(Token.Text); - string prefix = String.Empty; - if (ns != null && ns.Length != 0) - { - prefix = LookupPrefix(ns); - if (prefix == null) - { - if (_currentState != State.Attribute) - { - throw new ArgumentException(string.Format(ResXml.Xml_UndefNamespace, ns)); - } - prefix = GeneratePrefix(); - PushNamespaceImplicit(prefix, ns); - } - } - // if this is a special attribute, then just convert this to text - // otherwise delegate to raw-writer - if (SaveAttrValue || _rawWriter == null) - { - if (prefix.Length != 0) - { - WriteString(prefix); - WriteString(":"); - } - WriteString(localName); - } - else - { - _rawWriter.WriteQualifiedName(prefix, localName, ns); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(bool value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(DateTime value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(DateTimeOffset value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(double value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(float value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(decimal value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(int value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(long value) - { - try - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(string value) - { - try - { - if (value == null) - { - return; - } - if (SaveAttrValue) - { - AdvanceState(Token.Text); - _attrValueCache.WriteValue(value); - } - else - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteValue(object value) - { - try - { - if (SaveAttrValue && value is string) - { - AdvanceState(Token.Text); - _attrValueCache.WriteValue((string)value); - } - else - { - AdvanceState(Token.AtomicValue); - _writer.WriteValue(value); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - public override void WriteBinHex(byte[] buffer, int index, int count) - { - if (IsClosedOrErrorState) - { - throw new InvalidOperationException(ResXml.Xml_ClosedOrError); - } - try - { - AdvanceState(Token.Text); - base.WriteBinHex(buffer, index, count); - } - catch - { - _currentState = State.Error; - throw; - } - } - - // - // Internal methods - // - internal XmlWriter InnerWriter - { - get - { - return _writer; - } - } - - internal XmlRawWriter RawWriter - { - get - { - return _rawWriter; - } - } - - // - // Private methods - // - private bool SaveAttrValue - { - get - { - return _specAttr != SpecialAttribute.No; - } - } - - private bool InBase64 - { - get - { - return (_currentState == State.B64Content || _currentState == State.B64Attribute || _currentState == State.RootLevelB64Attr); - } - } - - private void SetSpecialAttribute(SpecialAttribute special) - { - _specAttr = special; - if (State.Attribute == _currentState) - _currentState = State.SpecialAttr; - else if (State.RootLevelAttr == _currentState) - _currentState = State.RootLevelSpecAttr; - else - Debug.Assert(false, "State.Attribute == currentState || State.RootLevelAttr == currentState"); - - if (_attrValueCache == null) - { - _attrValueCache = new AttributeValueCache(); - } - } - - private void WriteStartDocumentImpl(XmlStandalone standalone) - { - try - { - AdvanceState(Token.StartDocument); - - if (_conformanceLevel == ConformanceLevel.Auto) - { - _conformanceLevel = ConformanceLevel.Document; - _stateTable = s_stateTableDocument; - } - else if (_conformanceLevel == ConformanceLevel.Fragment) - { - throw new InvalidOperationException(ResXml.Xml_CannotStartDocumentOnFragment); - } - - if (_rawWriter != null) - { - if (!_xmlDeclFollows) - { - _rawWriter.WriteXmlDeclaration(standalone); - } - } - else - { - // We do not pass the standalone value here - Dev10 Bug #479769 - _writer.WriteStartDocument(); - } - } - catch - { - _currentState = State.Error; - throw; - } - } - - private void StartFragment() - { - _conformanceLevel = ConformanceLevel.Fragment; - Debug.Assert(_stateTable == s_stateTableAuto); - } - - // PushNamespaceImplicit is called when a prefix/namespace pair is used in an element name, attribute name or some other qualified name. - private void PushNamespaceImplicit(string prefix, string ns) - { - NamespaceKind kind; - - // See if the prefix is already defined - int existingNsIndex = LookupNamespaceIndex(prefix); - - // Prefix is already defined - if (existingNsIndex != -1) - { - // It is defined in the current scope - if (existingNsIndex > _elemScopeStack[_elemTop].prevNSTop) - { - // The new namespace Uri needs to be the same as the one that is already declared - if (_nsStack[existingNsIndex].namespaceUri != ns) - { - throw new XmlException(ResXml.Xml_RedefinePrefix, new string[] { prefix, _nsStack[existingNsIndex].namespaceUri, ns }); - } - // No additional work needed - return; - } - // The prefix is defined but in a different scope - else - { - // existing declaration is special one (xml, xmlns) -> validate that the new one is the same and can be declared - if (_nsStack[existingNsIndex].kind == NamespaceKind.Special) - { - if (prefix == "xml") - { - if (ns != _nsStack[existingNsIndex].namespaceUri) - { - throw new ArgumentException(ResXml.Xml_XmlPrefix); - } - else - { - kind = NamespaceKind.Implied; - } - } - else - { - Debug.Assert(prefix == "xmlns"); - throw new ArgumentException(ResXml.Xml_XmlnsPrefix); - } - } - // regular namespace declaration -> compare the namespace Uris to decide if the prefix is redefined - else - { - kind = (_nsStack[existingNsIndex].namespaceUri == ns) ? NamespaceKind.Implied : NamespaceKind.NeedToWrite; - } - } - } - // No existing declaration found in the namespace stack - else - { - // validate special declaration (xml, xmlns) - if ((ns == XmlReservedNs.NsXml && prefix != "xml") || - (ns == XmlReservedNs.NsXmlNs && prefix != "xmlns")) - { - throw new ArgumentException(string.Format(ResXml.Xml_NamespaceDeclXmlXmlns, prefix)); - } - - // check if it can be found in the predefinedNamespaces (which are provided by the user) - if (_predefinedNamespaces != null) - { - string definedNs = _predefinedNamespaces.LookupNamespace(prefix); - // compare the namespace Uri to decide if the prefix is redefined - kind = (definedNs == ns) ? NamespaceKind.Implied : NamespaceKind.NeedToWrite; - } - else - { - // Namespace not declared anywhere yet, we need to write it out - kind = NamespaceKind.NeedToWrite; - } - } - - AddNamespace(prefix, ns, kind); - } - - // PushNamespaceExplicit is called when a namespace declaration is written out; - // It returs true if the namespace declaration should we written out, false if it should be omited (if OmitDuplicateNamespaceDeclarations is true) - private bool PushNamespaceExplicit(string prefix, string ns) - { - bool writeItOut = true; - - // See if the prefix is already defined - int existingNsIndex = LookupNamespaceIndex(prefix); - - // Existing declaration in the current scope - if (existingNsIndex != -1) - { - // It is defined in the current scope - if (existingNsIndex > _elemScopeStack[_elemTop].prevNSTop) - { - // The new namespace Uri needs to be the same as the one that is already declared - if (_nsStack[existingNsIndex].namespaceUri != ns) - { - throw new XmlException(ResXml.Xml_RedefinePrefix, new string[] { prefix, _nsStack[existingNsIndex].namespaceUri, ns }); - } - // Check for duplicate declarations - NamespaceKind existingNsKind = _nsStack[existingNsIndex].kind; - if (existingNsKind == NamespaceKind.Written) - { - throw DupAttrException((prefix.Length == 0) ? string.Empty : "xmlns", (prefix.Length == 0) ? "xmlns" : prefix); - } - // Check if it can be omitted - if (_omitDuplNamespaces && existingNsKind != NamespaceKind.NeedToWrite) - { - writeItOut = false; - } - _nsStack[existingNsIndex].kind = NamespaceKind.Written; - // No additional work needed - return writeItOut; - } - // The prefix is defined but in a different scope - else - { - // check if is the same and can be omitted - if (_nsStack[existingNsIndex].namespaceUri == ns && _omitDuplNamespaces) - { - writeItOut = false; - } - } - } - // No existing declaration found in the namespace stack - else - { - // check if it can be found in the predefinedNamespaces (which are provided by the user) - if (_predefinedNamespaces != null) - { - string definedNs = _predefinedNamespaces.LookupNamespace(prefix); - // compare the namespace Uri to decide if the prefix is redefined - if (definedNs == ns && _omitDuplNamespaces) - { - writeItOut = false; - } - } - } - - // validate special declaration (xml, xmlns) - if ((ns == XmlReservedNs.NsXml && prefix != "xml") || - (ns == XmlReservedNs.NsXmlNs && prefix != "xmlns")) - { - throw new ArgumentException(string.Format(ResXml.Xml_NamespaceDeclXmlXmlns, prefix)); - } - if (prefix.Length > 0 && prefix[0] == 'x') - { - if (prefix == "xml") - { - if (ns != XmlReservedNs.NsXml) - { - throw new ArgumentException(ResXml.Xml_XmlPrefix); - } - } - else if (prefix == "xmlns") - { - throw new ArgumentException(ResXml.Xml_XmlnsPrefix); - } - } - - AddNamespace(prefix, ns, NamespaceKind.Written); - - return writeItOut; - } - - private void AddNamespace(string prefix, string ns, NamespaceKind kind) - { - int top = ++_nsTop; - if (top == _nsStack.Length) - { - Namespace[] newStack = new Namespace[top * 2]; - Array.Copy(_nsStack, newStack, top); - _nsStack = newStack; - } - _nsStack[top].Set(prefix, ns, kind); - - if (_useNsHashtable) - { - // add last - AddToNamespaceHashtable(_nsTop); - } - else if (_nsTop == MaxNamespacesWalkCount) - { - // add all - _nsHashtable = new Dictionary(_hasher); - for (int i = 0; i <= _nsTop; i++) - { - AddToNamespaceHashtable(i); - } - _useNsHashtable = true; - } - } - - private void AddToNamespaceHashtable(int namespaceIndex) - { - string prefix = _nsStack[namespaceIndex].prefix; - int existingNsIndex; - if (_nsHashtable.TryGetValue(prefix, out existingNsIndex)) - { - _nsStack[namespaceIndex].prevNsIndex = existingNsIndex; - } - _nsHashtable[prefix] = namespaceIndex; - } - - private int LookupNamespaceIndex(string prefix) - { - int index; - if (_useNsHashtable) - { - if (_nsHashtable.TryGetValue(prefix, out index)) - { - return index; - } - } - else - { - for (int i = _nsTop; i >= 0; i--) - { - if (_nsStack[i].prefix == prefix) - { - return i; - } - } - } - return -1; - } - - private void PopNamespaces(int indexFrom, int indexTo) - { - Debug.Assert(_useNsHashtable); - Debug.Assert(indexFrom <= indexTo); - for (int i = indexTo; i >= indexFrom; i--) - { - Debug.Assert(_nsHashtable.ContainsKey(_nsStack[i].prefix)); - if (_nsStack[i].prevNsIndex == -1) - { - _nsHashtable.Remove(_nsStack[i].prefix); - } - else - { - _nsHashtable[_nsStack[i].prefix] = _nsStack[i].prevNsIndex; - } - } - } - - static private XmlException DupAttrException(string prefix, string localName) - { - StringBuilder sb = new StringBuilder(); - if (prefix.Length > 0) - { - sb.Append(prefix); - sb.Append(':'); - } - sb.Append(localName); - return new XmlException(ResXml.Xml_DupAttributeName, sb.ToString()); - } - - // Advance the state machine - private void AdvanceState(Token token) - { - if ((int)_currentState >= (int)State.Closed) - { - if (_currentState == State.Closed || _currentState == State.Error) - { - throw new InvalidOperationException(ResXml.Xml_ClosedOrError); - } - else - { - throw new InvalidOperationException(string.Format(ResXml.Xml_WrongToken, tokenName[(int)token], GetStateName(_currentState))); - } - } - - Advance: - State newState = _stateTable[((int)token << 4) + (int)_currentState]; - // [ (int)token * 16 + (int)currentState ]; - - if ((int)newState >= (int)State.Error) - { - switch (newState) - { - case State.Error: - ThrowInvalidStateTransition(token, _currentState); - break; - - case State.StartContent: - StartElementContent(); - newState = State.Content; - break; - - case State.StartContentEle: - StartElementContent(); - newState = State.Element; - break; - - case State.StartContentB64: - StartElementContent(); - newState = State.B64Content; - break; - - case State.StartDoc: - WriteStartDocument(); - newState = State.Document; - break; - - case State.StartDocEle: - WriteStartDocument(); - newState = State.Element; - break; - - case State.EndAttrSEle: - WriteEndAttribute(); - StartElementContent(); - newState = State.Element; - break; - - case State.EndAttrEEle: - WriteEndAttribute(); - StartElementContent(); - newState = State.Content; - break; - - case State.EndAttrSCont: - WriteEndAttribute(); - StartElementContent(); - newState = State.Content; - break; - - case State.EndAttrSAttr: - WriteEndAttribute(); - newState = State.Attribute; - break; - - case State.PostB64Cont: - if (_rawWriter != null) - { - _rawWriter.WriteEndBase64(); - } - _currentState = State.Content; - goto Advance; - - case State.PostB64Attr: - if (_rawWriter != null) - { - _rawWriter.WriteEndBase64(); - } - _currentState = State.Attribute; - goto Advance; - - case State.PostB64RootAttr: - if (_rawWriter != null) - { - _rawWriter.WriteEndBase64(); - } - _currentState = State.RootLevelAttr; - goto Advance; - - case State.StartFragEle: - StartFragment(); - newState = State.Element; - break; - - case State.StartFragCont: - StartFragment(); - newState = State.Content; - break; - - case State.StartFragB64: - StartFragment(); - newState = State.B64Content; - break; - - case State.StartRootLevelAttr: - WriteEndAttribute(); - newState = State.RootLevelAttr; - break; - - default: - Debug.Assert(false, "We should not get to this point."); - break; - } - } - - _currentState = newState; - } - - private void StartElementContent() - { - // write namespace declarations - int start = _elemScopeStack[_elemTop].prevNSTop; - for (int i = _nsTop; i > start; i--) - { - if (_nsStack[i].kind == NamespaceKind.NeedToWrite) - { - _nsStack[i].WriteDecl(_writer, _rawWriter); - } - } - - if (_rawWriter != null) - { - _rawWriter.StartElementContent(); - } - } - - private static string GetStateName(State state) - { - if (state >= State.Error) - { - Debug.Assert(false, "We should never get to this point. State = " + state); - return "Error"; - } - else - { - return stateName[(int)state]; - } - } - - internal string LookupNamespace(string prefix) - { - for (int i = _nsTop; i >= 0; i--) - { - if (_nsStack[i].prefix == prefix) - { - return _nsStack[i].namespaceUri; - } - } - return (_predefinedNamespaces != null) ? _predefinedNamespaces.LookupNamespace(prefix) : null; - } - - private string LookupLocalNamespace(string prefix) - { - for (int i = _nsTop; i > _elemScopeStack[_elemTop].prevNSTop; i--) - { - if (_nsStack[i].prefix == prefix) - { - return _nsStack[i].namespaceUri; - } - } - return null; - } - - private string GeneratePrefix() - { - string genPrefix = "p" + (_nsTop - 2).ToString("d", CultureInfo.InvariantCulture); - if (LookupNamespace(genPrefix) == null) - { - return genPrefix; - } - int i = 0; - - string s; - do - { - s = string.Concat(genPrefix, i.ToString()); - i++; - } while (LookupNamespace(s) != null); - return s; - } - - private unsafe void CheckNCName(string ncname) - { - Debug.Assert(ncname != null && ncname.Length > 0); - - int i; - int endPos = ncname.Length; - - // Check if first character is StartNCName (inc. surrogates) - if ((_xmlCharType.charProperties[ncname[0]] & XmlCharType.fNCStartNameSC) != 0) - { // if ( xmlCharType.IsStartNCNameChar( ncname[0] ) ) { - i = 1; - } -#if XML10_FIFTH_EDITION - else if (xmlCharType.IsNCNameSurrogateChar(ncname, 0)) { // surrogate ranges are same for NCName and StartNCName - i = 2; - } -#endif - else - { - throw InvalidCharsException(ncname, 0); - } - - // Check if following characters are NCName (inc. surrogates) - while (i < endPos) - { - if ((_xmlCharType.charProperties[ncname[i]] & XmlCharType.fNCNameSC) != 0) - { // if ( xmlCharType.IsNCNameChar( ncname[i] ) ) { - i++; - } -#if XML10_FIFTH_EDITION - else if (xmlCharType.IsNCNameSurrogateChar(ncname, i)) { - i += 2; - } -#endif - else - { - throw InvalidCharsException(ncname, i); - } - } - } - - private static Exception InvalidCharsException(string name, int badCharIndex) - { - string[] badCharArgs = XmlException.BuildCharExceptionArgs(name, badCharIndex); - string[] args = new string[3]; - args[0] = name; - args[1] = badCharArgs[0]; - args[2] = badCharArgs[1]; - return new ArgumentException(string.Format(ResXml.Xml_InvalidNameCharsDetail, args)); - } - - // This method translates speficic state transition errors in more friendly error messages - private void ThrowInvalidStateTransition(Token token, State currentState) - { - string wrongTokenMessage = string.Format(ResXml.Xml_WrongToken, tokenName[(int)token], GetStateName(currentState)); - switch (currentState) - { - case State.AfterRootEle: - case State.Start: - if (_conformanceLevel == ConformanceLevel.Document) - { - throw new InvalidOperationException(wrongTokenMessage + ' ' + ResXml.Xml_ConformanceLevelFragment); - } - break; - } - throw new InvalidOperationException(wrongTokenMessage); - } - - private bool IsClosedOrErrorState - { - get - { - return (int)_currentState >= (int)State.Closed; - } - } - - private void AddAttribute(string prefix, string localName, string namespaceName) - { - int top = _attrCount++; - if (top == _attrStack.Length) - { - AttrName[] newStack = new AttrName[top * 2]; - Array.Copy(_attrStack, newStack, top); - _attrStack = newStack; - } - _attrStack[top].Set(prefix, localName, namespaceName); - - if (_attrCount < MaxAttrDuplWalkCount) - { - // check for duplicates - for (int i = 0; i < top; i++) - { - if (_attrStack[i].IsDuplicate(prefix, localName, namespaceName)) - { - throw DupAttrException(prefix, localName); - } - } - } - else - { - // reached the threshold -> add all attributes to hash table - if (_attrCount == MaxAttrDuplWalkCount) - { - if (_attrHashTable == null) - { - _attrHashTable = new Dictionary(_hasher); - } - Debug.Assert(_attrHashTable.Count == 0); - for (int i = 0; i < top; i++) - { - AddToAttrHashTable(i); - } - } - - // add last attribute to hash table and check for duplicates - AddToAttrHashTable(top); - int prev = _attrStack[top].prev; - while (prev > 0) - { - // indexes are stored incremented by 1, 0 means no entry - prev--; - if (_attrStack[prev].IsDuplicate(prefix, localName, namespaceName)) - { - throw DupAttrException(prefix, localName); - } - prev = _attrStack[prev].prev; - } - } - } - - private void AddToAttrHashTable(int attributeIndex) - { - string localName = _attrStack[attributeIndex].localName; - int count = _attrHashTable.Count; - _attrHashTable[localName] = 0; // overwrite on collision - if (count != _attrHashTable.Count) - { - return; - } - // chain to previous attribute in stack with the same localName - int prev = attributeIndex - 1; - while (prev >= 0) - { - if (_attrStack[prev].localName == localName) - { - break; - } - prev--; - } - Debug.Assert(prev >= 0 && _attrStack[prev].localName == localName); - _attrStack[attributeIndex].prev = prev + 1; // indexes are stored incremented by 1 - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriterHelpers.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriterHelpers.cs deleted file mode 100644 index 49f5aaf13b1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWellformedWriterHelpers.cs +++ /dev/null @@ -1,530 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.Text; -using System.Diagnostics; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlWellFormedWriter : XmlWriter - { - // - // Private types - // - private class NamespaceResolverProxy : IXmlNamespaceResolver - { - private XmlWellFormedWriter _wfWriter; - - internal NamespaceResolverProxy(XmlWellFormedWriter wfWriter) - { - _wfWriter = wfWriter; - } - - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - throw new NotImplementedException(); - } - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _wfWriter.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _wfWriter.LookupPrefix(namespaceName); - } - } - - private partial struct ElementScope - { - internal int prevNSTop; - internal string prefix; - internal string localName; - internal string namespaceUri; - internal XmlSpace xmlSpace; - internal string xmlLang; - - internal void Set(string prefix, string localName, string namespaceUri, int prevNSTop) - { - this.prevNSTop = prevNSTop; - this.prefix = prefix; - this.namespaceUri = namespaceUri; - this.localName = localName; - this.xmlSpace = (Microsoft.Xml.XmlSpace)(int)-1; - this.xmlLang = null; - } - - internal void WriteEndElement(XmlRawWriter rawWriter) - { - rawWriter.WriteEndElement(prefix, localName, namespaceUri); - } - - internal void WriteFullEndElement(XmlRawWriter rawWriter) - { - rawWriter.WriteFullEndElement(prefix, localName, namespaceUri); - } - } - - private enum NamespaceKind - { - Written, - NeedToWrite, - Implied, - Special, - } - - private partial struct Namespace - { - internal string prefix; - internal string namespaceUri; - internal NamespaceKind kind; - internal int prevNsIndex; - - internal void Set(string prefix, string namespaceUri, NamespaceKind kind) - { - this.prefix = prefix; - this.namespaceUri = namespaceUri; - this.kind = kind; - this.prevNsIndex = -1; - } - - internal void WriteDecl(XmlWriter writer, XmlRawWriter rawWriter) - { - Debug.Assert(kind == NamespaceKind.NeedToWrite); - if (null != rawWriter) - { - rawWriter.WriteNamespaceDeclaration(prefix, namespaceUri); - } - else - { - if (prefix.Length == 0) - { - writer.WriteStartAttribute(string.Empty, "xmlns", XmlReservedNs.NsXmlNs); - } - else - { - writer.WriteStartAttribute("xmlns", prefix, XmlReservedNs.NsXmlNs); - } - writer.WriteString(namespaceUri); - writer.WriteEndAttribute(); - } - } - } - - private struct AttrName - { - internal string prefix; - internal string namespaceUri; - internal string localName; - internal int prev; - - internal void Set(string prefix, string localName, string namespaceUri) - { - this.prefix = prefix; - this.namespaceUri = namespaceUri; - this.localName = localName; - this.prev = 0; - } - - internal bool IsDuplicate(string prefix, string localName, string namespaceUri) - { - return ((this.localName == localName) - && ((this.prefix == prefix) || (this.namespaceUri == namespaceUri))); - } - } - - private enum SpecialAttribute - { - No = 0, - DefaultXmlns, - PrefixedXmlns, - XmlSpace, - XmlLang - } - - private partial class AttributeValueCache - { - private enum ItemType - { - EntityRef, - CharEntity, - SurrogateCharEntity, - Whitespace, - String, - StringChars, - Raw, - RawChars, - ValueString, - } - - private class Item - { - internal ItemType type; - internal object data; - - internal Item() { } - - internal void Set(ItemType type, object data) - { - this.type = type; - this.data = data; - } - } - - private class BufferChunk - { - internal char[] buffer; - internal int index; - internal int count; - - internal BufferChunk(char[] buffer, int index, int count) - { - this.buffer = buffer; - this.index = index; - this.count = count; - } - } - - private StringBuilder _stringValue = new StringBuilder(); - private string _singleStringValue; // special-case for a single WriteString call - private Item[] _items; - private int _firstItem; - private int _lastItem = -1; - - internal string StringValue - { - get - { - if (_singleStringValue != null) - { - return _singleStringValue; - } - else - { - return _stringValue.ToString(); - } - } - } - - internal void WriteEntityRef(string name) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - - switch (name) - { - case "lt": - _stringValue.Append('<'); - break; - case "gt": - _stringValue.Append('>'); - break; - case "quot": - _stringValue.Append('"'); - break; - case "apos": - _stringValue.Append('\''); - break; - case "amp": - _stringValue.Append('&'); - break; - default: - _stringValue.Append('&'); - _stringValue.Append(name); - _stringValue.Append(';'); - break; - } - - AddItem(ItemType.EntityRef, name); - } - - internal void WriteCharEntity(char ch) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(ch); - AddItem(ItemType.CharEntity, ch); - } - - internal void WriteSurrogateCharEntity(char lowChar, char highChar) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(highChar); - _stringValue.Append(lowChar); - AddItem(ItemType.SurrogateCharEntity, new char[] { lowChar, highChar }); - } - - internal void WriteWhitespace(string ws) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(ws); - AddItem(ItemType.Whitespace, ws); - } - - internal void WriteString(string text) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - else - { - // special-case for a single WriteString - if (_lastItem == -1) - { - _singleStringValue = text; - return; - } - } - - _stringValue.Append(text); - AddItem(ItemType.String, text); - } - - internal void WriteChars(char[] buffer, int index, int count) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(buffer, index, count); - AddItem(ItemType.StringChars, new BufferChunk(buffer, index, count)); - } - - internal void WriteRaw(char[] buffer, int index, int count) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(buffer, index, count); - AddItem(ItemType.RawChars, new BufferChunk(buffer, index, count)); - } - - internal void WriteRaw(string data) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(data); - AddItem(ItemType.Raw, data); - } - - internal void WriteValue(string value) - { - if (_singleStringValue != null) - { - StartComplexValue(); - } - _stringValue.Append(value); - AddItem(ItemType.ValueString, value); - } - - internal void Replay(XmlWriter writer) - { - if (_singleStringValue != null) - { - writer.WriteString(_singleStringValue); - return; - } - - BufferChunk bufChunk; - for (int i = _firstItem; i <= _lastItem; i++) - { - Item item = _items[i]; - switch (item.type) - { - case ItemType.EntityRef: - writer.WriteEntityRef((string)item.data); - break; - case ItemType.CharEntity: - writer.WriteCharEntity((char)item.data); - break; - case ItemType.SurrogateCharEntity: - char[] chars = (char[])item.data; - writer.WriteSurrogateCharEntity(chars[0], chars[1]); - break; - case ItemType.Whitespace: - writer.WriteWhitespace((string)item.data); - break; - case ItemType.String: - writer.WriteString((string)item.data); - break; - case ItemType.StringChars: - bufChunk = (BufferChunk)item.data; - writer.WriteChars(bufChunk.buffer, bufChunk.index, bufChunk.count); - break; - case ItemType.Raw: - writer.WriteRaw((string)item.data); - break; - case ItemType.RawChars: - bufChunk = (BufferChunk)item.data; - writer.WriteChars(bufChunk.buffer, bufChunk.index, bufChunk.count); - break; - case ItemType.ValueString: - writer.WriteValue((string)item.data); - break; - default: - Debug.Assert(false, "Unexpected ItemType value."); - break; - } - } - } - - // This method trims whitespaces from the beginnig and the end of the string and cached writer events - internal void Trim() - { - // if only one string value -> trim the write spaces directly - if (_singleStringValue != null) - { - _singleStringValue = XmlConvert.TrimString(_singleStringValue); - return; - } - - // trim the string in StringBuilder - string valBefore = _stringValue.ToString(); - string valAfter = XmlConvert.TrimString(valBefore); - if (valBefore != valAfter) - { - _stringValue = new StringBuilder(valAfter); - } - - // trim the beginning of the recorded writer events - XmlCharType xmlCharType = XmlCharType.Instance; - - int i = _firstItem; - while (i == _firstItem && i <= _lastItem) - { - Item item = _items[i]; - switch (item.type) - { - case ItemType.Whitespace: - _firstItem++; - break; - case ItemType.String: - case ItemType.Raw: - case ItemType.ValueString: - item.data = XmlConvert.TrimStringStart((string)item.data); - if (((string)item.data).Length == 0) - { - // no characters left -> move the firstItem index to exclude it from the Replay - _firstItem++; - } - break; - case ItemType.StringChars: - case ItemType.RawChars: - BufferChunk bufChunk = (BufferChunk)item.data; - int endIndex = bufChunk.index + bufChunk.count; - while (bufChunk.index < endIndex && xmlCharType.IsWhiteSpace(bufChunk.buffer[bufChunk.index])) - { - bufChunk.index++; - bufChunk.count--; - } - if (bufChunk.index == endIndex) - { - // no characters left -> move the firstItem index to exclude it from the Replay - _firstItem++; - } - break; - } - i++; - } - - // trim the end of the recorded writer events - i = _lastItem; - while (i == _lastItem && i >= _firstItem) - { - Item item = _items[i]; - switch (item.type) - { - case ItemType.Whitespace: - _lastItem--; - break; - case ItemType.String: - case ItemType.Raw: - case ItemType.ValueString: - item.data = XmlConvert.TrimStringEnd((string)item.data); - if (((string)item.data).Length == 0) - { - // no characters left -> move the lastItem index to exclude it from the Replay - _lastItem--; - } - break; - case ItemType.StringChars: - case ItemType.RawChars: - BufferChunk bufChunk = (BufferChunk)item.data; - while (bufChunk.count > 0 && xmlCharType.IsWhiteSpace(bufChunk.buffer[bufChunk.index + bufChunk.count - 1])) - { - bufChunk.count--; - } - if (bufChunk.count == 0) - { - // no characters left -> move the lastItem index to exclude it from the Replay - _lastItem--; - } - break; - } - i--; - } - } - - internal void Clear() - { - _singleStringValue = null; - _lastItem = -1; - _firstItem = 0; - _stringValue.Length = 0; - } - - private void StartComplexValue() - { - Debug.Assert(_singleStringValue != null); - Debug.Assert(_lastItem == -1); - - _stringValue.Append(_singleStringValue); - AddItem(ItemType.String, _singleStringValue); - - _singleStringValue = null; - } - - private void AddItem(ItemType type, object data) - { - int newItemIndex = _lastItem + 1; - if (_items == null) - { - _items = new Item[4]; - } - else if (_items.Length == newItemIndex) - { - Item[] newItems = new Item[newItemIndex * 2]; - Array.Copy(_items, newItems, newItemIndex); - _items = newItems; - } - if (_items[newItemIndex] == null) - { - _items[newItemIndex] = new Item(); - } - _items[newItemIndex].Set(type, data); - _lastItem = newItemIndex; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReader.cs deleted file mode 100644 index 51914282105..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReader.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Collections; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlWrappingReader : XmlReader, IXmlLineInfo - { - // - // Fields - // - protected XmlReader reader; - protected IXmlLineInfo readerAsIXmlLineInfo; - - // - // Constructor - // - internal XmlWrappingReader(XmlReader baseReader) - { - Debug.Assert(baseReader != null); - this.reader = baseReader; - this.readerAsIXmlLineInfo = baseReader as IXmlLineInfo; - } - - // - // XmlReader implementation - // - public override XmlReaderSettings Settings { get { return reader.Settings; } } - public override XmlNodeType NodeType { get { return reader.NodeType; } } - public override string Name { get { return reader.Name; } } - public override string LocalName { get { return reader.LocalName; } } - public override string NamespaceURI { get { return reader.NamespaceURI; } } - public override string Prefix { get { return reader.Prefix; } } - public override bool HasValue { get { return reader.HasValue; } } - public override string Value { get { return reader.Value; } } - public override int Depth { get { return reader.Depth; } } - public override string BaseURI { get { return reader.BaseURI; } } - public override bool IsEmptyElement { get { return reader.IsEmptyElement; } } - public override bool IsDefault { get { return reader.IsDefault; } } - public override XmlSpace XmlSpace { get { return reader.XmlSpace; } } - public override string XmlLang { get { return reader.XmlLang; } } - public override System.Type ValueType { get { return reader.ValueType; } } - public override int AttributeCount { get { return reader.AttributeCount; } } - public override bool EOF { get { return reader.EOF; } } - public override ReadState ReadState { get { return reader.ReadState; } } - public override bool HasAttributes { get { return reader.HasAttributes; } } - public override XmlNameTable NameTable { get { return reader.NameTable; } } - public override bool CanResolveEntity { get { return reader.CanResolveEntity; } } - - public override IXmlSchemaInfo SchemaInfo { get { return reader.SchemaInfo; } } - public override char QuoteChar { get { return reader.QuoteChar; } } - - public override string GetAttribute(string name) - { - return reader.GetAttribute(name); - } - - public override string GetAttribute(string name, string namespaceURI) - { - return reader.GetAttribute(name, namespaceURI); - } - - public override string GetAttribute(int i) - { - return reader.GetAttribute(i); - } - - public override bool MoveToAttribute(string name) - { - return reader.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string name, string ns) - { - return reader.MoveToAttribute(name, ns); - } - - public override void MoveToAttribute(int i) - { - reader.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - return reader.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - return reader.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - return reader.MoveToElement(); - } - - public override bool Read() - { - return reader.Read(); - } - - public override void Close() - { - reader.Close(); - } - - public override void Skip() - { - reader.Skip(); - } - - public override string LookupNamespace(string prefix) - { - return reader.LookupNamespace(prefix); - } - - public override void ResolveEntity() - { - reader.ResolveEntity(); - } - - public override bool ReadAttributeValue() - { - return reader.ReadAttributeValue(); - } - - // - // IXmlLineInfo members - // - public virtual bool HasLineInfo() - { - return (readerAsIXmlLineInfo == null) ? false : readerAsIXmlLineInfo.HasLineInfo(); - } - - public virtual int LineNumber - { - get - { - return (readerAsIXmlLineInfo == null) ? 0 : readerAsIXmlLineInfo.LineNumber; - } - } - - public virtual int LinePosition - { - get - { - return (readerAsIXmlLineInfo == null) ? 0 : readerAsIXmlLineInfo.LinePosition; - } - } - - // - // Internal methods - // - internal override IDtdInfo DtdInfo - { - get - { - return reader.DtdInfo; - } - } - - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReaderAsync.cs deleted file mode 100644 index 74620e9ff15..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingReaderAsync.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Collections; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlWrappingReader : XmlReader, IXmlLineInfo - { - public override Task GetValueAsync() - { - return reader.GetValueAsync(); - } - - public override Task ReadAsync() - { - return reader.ReadAsync(); - } - - public override Task SkipAsync() - { - return reader.SkipAsync(); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingWriter.cs deleted file mode 100644 index d39410e0a40..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWrappingWriter.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -using System; -using System.IO; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; - - - - - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XmlWrappingWriter : XmlWriter - { - // - // Fields - // - protected XmlWriter writer; - - // - // Constructor - // - internal XmlWrappingWriter(XmlWriter baseWriter) - { - Debug.Assert(baseWriter != null); - this.writer = baseWriter; - } - - // - // XmlWriter implementation - // - public override XmlWriterSettings Settings { get { return writer.Settings; } } - public override WriteState WriteState { get { return writer.WriteState; } } - public override XmlSpace XmlSpace { get { return writer.XmlSpace; } } - public override string XmlLang { get { return writer.XmlLang; } } - - - public override void WriteStartDocument() - { - writer.WriteStartDocument(); - } - - public override void WriteStartDocument(bool standalone) - { - writer.WriteStartDocument(standalone); - } - - public override void WriteEndDocument() - { - writer.WriteEndDocument(); - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - writer.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - writer.WriteStartElement(prefix, localName, ns); - } - - public override void WriteEndElement() - { - writer.WriteEndElement(); - } - - public override void WriteFullEndElement() - { - writer.WriteFullEndElement(); - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - writer.WriteStartAttribute(prefix, localName, ns); - } - - public override void WriteEndAttribute() - { - writer.WriteEndAttribute(); - } - - public override void WriteCData(string text) - { - writer.WriteCData(text); - } - - public override void WriteComment(string text) - { - writer.WriteComment(text); - } - - public override void WriteProcessingInstruction(string name, string text) - { - writer.WriteProcessingInstruction(name, text); - } - - public override void WriteEntityRef(string name) - { - writer.WriteEntityRef(name); - } - - public override void WriteCharEntity(char ch) - { - writer.WriteCharEntity(ch); - } - - public override void WriteWhitespace(string ws) - { - writer.WriteWhitespace(ws); - } - - public override void WriteString(string text) - { - writer.WriteString(text); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - writer.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - writer.WriteChars(buffer, index, count); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - writer.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - writer.WriteRaw(data); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - writer.WriteBase64(buffer, index, count); - } - - public override void Close() - { - writer.Close(); - } - - public override void Flush() - { - writer.Flush(); - } - - public override string LookupPrefix(string ns) - { - return writer.LookupPrefix(ns); - } - - public override void WriteValue(object value) - { - writer.WriteValue(value); - } - - public override void WriteValue(string value) - { - writer.WriteValue(value); - } - - public override void WriteValue(bool value) - { - writer.WriteValue(value); - } - - public override void WriteValue(DateTime value) - { - writer.WriteValue(value); - } - - public override void WriteValue(DateTimeOffset value) - { - writer.WriteValue(value); - } - - public override void WriteValue(double value) - { - writer.WriteValue(value); - } - - public override void WriteValue(float value) - { - writer.WriteValue(value); - } - - public override void WriteValue(decimal value) - { - writer.WriteValue(value); - } - - public override void WriteValue(int value) - { - writer.WriteValue(value); - } - - public override void WriteValue(long value) - { - writer.WriteValue(value); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - ((IDisposable)writer).Dispose(); - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriter.cs deleted file mode 100644 index 25a86283695..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriter.cs +++ /dev/null @@ -1,752 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.XPath; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Collections.Generic; -using System.Globalization; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - // Specifies the state of the XmlWriter. - public enum WriteState - { - // Nothing has been written yet. - Start, - - // Writing the prolog. - Prolog, - - // Writing a the start tag for an element. - Element, - - // Writing an attribute value. - Attribute, - - // Writing element content. - Content, - - // XmlWriter is closed; Close has been called. - Closed, - - // Writer is in error state. - Error, - }; - - // Represents a writer that provides fast non-cached forward-only way of generating XML streams containing XML documents - // that conform to the W3C Extensible Markup Language (XML) 1.0 specification and the Namespaces in XML specification. - public abstract partial class XmlWriter : IDisposable - { - // Helper buffer for WriteNode(XmlReader, bool) - private char[] _writeNodeBuffer; - - // Constants - private const int WriteNodeBufferSize = 1024; - - // Returns the settings describing the features of the the writer. Returns null for V1 XmlWriters (XmlTextWriter). - public virtual XmlWriterSettings Settings - { - get - { - return null; - } - } - - // Write methods - // Writes out the XML declaration with the version "1.0". - - public abstract void WriteStartDocument(); - - //Writes out the XML declaration with the version "1.0" and the speficied standalone attribute. - - public abstract void WriteStartDocument(bool standalone); - - //Closes any open elements or attributes and puts the writer back in the Start state. - - public abstract void WriteEndDocument(); - - // Writes out the DOCTYPE declaration with the specified name and optional attributes. - - public abstract void WriteDocType(string name, string pubid, string sysid, string subset); - - // Writes out the specified start tag and associates it with the given namespace. - public void WriteStartElement(string localName, string ns) - { - WriteStartElement(null, localName, ns); - } - - // Writes out the specified start tag and associates it with the given namespace and prefix. - - public abstract void WriteStartElement(string prefix, string localName, string ns); - - // Writes out a start tag with the specified local name with no namespace. - public void WriteStartElement(string localName) - { - WriteStartElement(null, localName, (string)null); - } - - // Closes one element and pops the corresponding namespace scope. - - public abstract void WriteEndElement(); - - // Closes one element and pops the corresponding namespace scope. Writes out a full end element tag, e.g. . - - public abstract void WriteFullEndElement(); - - // Writes out the attribute with the specified LocalName, value, and NamespaceURI. - public void WriteAttributeString(string localName, string ns, string value) - { - WriteStartAttribute(null, localName, ns); - WriteString(value); - WriteEndAttribute(); - } - - // Writes out the attribute with the specified LocalName and value. - public void WriteAttributeString(string localName, string value) - { - WriteStartAttribute(null, localName, (string)null); - WriteString(value); - WriteEndAttribute(); - } - - // Writes out the attribute with the specified prefix, LocalName, NamespaceURI and value. - public void WriteAttributeString(string prefix, string localName, string ns, string value) - { - WriteStartAttribute(prefix, localName, ns); - WriteString(value); - WriteEndAttribute(); - } - - // Writes the start of an attribute. - public void WriteStartAttribute(string localName, string ns) - { - WriteStartAttribute(null, localName, ns); - } - - // Writes the start of an attribute. - - public abstract void WriteStartAttribute(string prefix, string localName, string ns); - - // Writes the start of an attribute. - public void WriteStartAttribute(string localName) - { - WriteStartAttribute(null, localName, (string)null); - } - - // Closes the attribute opened by WriteStartAttribute call. - - public abstract void WriteEndAttribute(); - - // Writes out a ; block containing the specified text. - - public abstract void WriteCData(string text); - - // Writes out a comment ; containing the specified text. - - public abstract void WriteComment(string text); - - // Writes out a processing instruction with a space between the name and text as follows: - - public abstract void WriteProcessingInstruction(string name, string text); - - // Writes out an entity reference as follows: "&"+name+";". - - public abstract void WriteEntityRef(string name); - - // Forces the generation of a character entity for the specified Unicode character value. - - public abstract void WriteCharEntity(char ch); - - // Writes out the given whitespace. - - public abstract void WriteWhitespace(string ws); - - // Writes out the specified text content. - - public abstract void WriteString(string text); - - // Write out the given surrogate pair as an entity reference. - - public abstract void WriteSurrogateCharEntity(char lowChar, char highChar); - - // Writes out the specified text content. - - public abstract void WriteChars(char[] buffer, int index, int count); - - // Writes raw markup from the given character buffer. - - public abstract void WriteRaw(char[] buffer, int index, int count); - - // Writes raw markup from the given string. - - public abstract void WriteRaw(string data); - - // Encodes the specified binary bytes as base64 and writes out the resulting text. - - public abstract void WriteBase64(byte[] buffer, int index, int count); - - // Encodes the specified binary bytes as binhex and writes out the resulting text. - public virtual void WriteBinHex(byte[] buffer, int index, int count) - { - BinHexEncoder.Encode(buffer, index, count, this); - } - - // Returns the state of the XmlWriter. - public abstract WriteState WriteState { get; } - - // Closes the XmlWriter and the underlying stream/TextReader (if Settings.CloseOutput is true). - public virtual void Close() { } - - // Flushes data that is in the internal buffers into the underlying streams/TextReader and flushes the stream/TextReader. - - public abstract void Flush(); - - // Returns the closest prefix defined in the current namespace scope for the specified namespace URI. - public abstract string LookupPrefix(string ns); - - // Gets an XmlSpace representing the current xml:space scope. - public virtual XmlSpace XmlSpace - { - get - { - return XmlSpace.Default; - } - } - - // Gets the current xml:lang scope. - public virtual string XmlLang - { - get - { - return string.Empty; - } - } - - // Scalar Value Methods - - // Writes out the specified name, ensuring it is a valid NmToken according to the XML specification - // (http://www.w3.org/TR/1998/REC-xml-19980210#NT-Name). - public virtual void WriteNmToken(string name) - { - if (name == null || name.Length == 0) - { - throw new ArgumentException(ResXml.Xml_EmptyName); - } - WriteString(XmlConvert.VerifyNMTOKEN(name, ExceptionType.ArgumentException)); - } - - // Writes out the specified name, ensuring it is a valid Name according to the XML specification - // (http://www.w3.org/TR/1998/REC-xml-19980210#NT-Name). - public virtual void WriteName(string name) - { - WriteString(XmlConvert.VerifyQName(name, ExceptionType.ArgumentException)); - } - - // Writes out the specified namespace-qualified name by looking up the prefix that is in scope for the given namespace. - public virtual void WriteQualifiedName(string localName, string ns) - { - if (ns != null && ns.Length > 0) - { - string prefix = LookupPrefix(ns); - if (prefix == null) - { - throw new ArgumentException(string.Format(ResXml.Xml_UndefNamespace, ns)); - } - WriteString(prefix); - WriteString(":"); - } - WriteString(localName); - } - - // Writes out the specified value. - public virtual void WriteValue(object value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - WriteString(XmlUntypedConverter.Untyped.ToString(value, null)); - } - - // Writes out the specified value. - public virtual void WriteValue(string value) - { - if (value == null) - { - return; - } - WriteString(value); - } - - // Writes out the specified value. - public virtual void WriteValue(bool value) - { - WriteString(XmlConvert.ToString(value)); - } - - // Writes out the specified value. - public virtual void WriteValue(DateTime value) - { - WriteString(XmlConvert.ToString(value, XmlDateTimeSerializationMode.RoundtripKind)); - } - - // Writes out the specified value. - public virtual void WriteValue(DateTimeOffset value) - { - // Under Win8P, WriteValue(DateTime) will invoke this overload, but custom writers - // might not have implemented it. This base implementation should call WriteValue(DateTime). - // The following conversion results in the same string as calling ToString with DateTimeOffset. - if (value.Offset != TimeSpan.Zero) - { - WriteValue(value.LocalDateTime); - } - else - { - WriteValue(value.UtcDateTime); - } - } - - // Writes out the specified value. - public virtual void WriteValue(double value) - { - WriteString(XmlConvert.ToString(value)); - } - - // Writes out the specified value. - public virtual void WriteValue(float value) - { - WriteString(XmlConvert.ToString(value)); - } - - // Writes out the specified value. - public virtual void WriteValue(decimal value) - { - WriteString(XmlConvert.ToString(value)); - } - - // Writes out the specified value. - public virtual void WriteValue(int value) - { - WriteString(XmlConvert.ToString(value)); - } - - // Writes out the specified value. - public virtual void WriteValue(long value) - { - WriteString(XmlConvert.ToString(value)); - } - - // XmlReader Helper Methods - - // Writes out all the attributes found at the current position in the specified XmlReader. - public virtual void WriteAttributes(XmlReader reader, bool defattr) - { - if (null == reader) - { - throw new ArgumentNullException("reader"); - } - - if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.XmlDeclaration) - { - if (reader.MoveToFirstAttribute()) - { - WriteAttributes(reader, defattr); - reader.MoveToElement(); - } - } - else if (reader.NodeType != XmlNodeType.Attribute) - { - throw new XmlException(ResXml.Xml_InvalidPosition, string.Empty); - } - else - { - do - { - // we need to check both XmlReader.IsDefault and XmlReader.SchemaInfo.IsDefault. - // If either of these is true and defattr=false, we should not write the attribute out - if (defattr || !reader.IsDefaultInternal) - { - WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI); - while (reader.ReadAttributeValue()) - { - if (reader.NodeType == XmlNodeType.EntityReference) - { - WriteEntityRef(reader.Name); - } - else - { - WriteString(reader.Value); - } - } - WriteEndAttribute(); - } - } - while (reader.MoveToNextAttribute()); - } - } - - // Copies the current node from the given reader to the writer (including child nodes), and if called on an element moves the XmlReader - // to the corresponding end element. - public virtual void WriteNode(XmlReader reader, bool defattr) - { - if (null == reader) - { - throw new ArgumentNullException("reader"); - } - - bool canReadChunk = reader.CanReadValueChunk; - int d = reader.NodeType == XmlNodeType.None ? -1 : reader.Depth; - do - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); - WriteAttributes(reader, defattr); - if (reader.IsEmptyElement) - { - WriteEndElement(); - break; - } - break; - case XmlNodeType.Text: - if (canReadChunk) - { - if (_writeNodeBuffer == null) - { - _writeNodeBuffer = new char[WriteNodeBufferSize]; - } - int read; - while ((read = reader.ReadValueChunk(_writeNodeBuffer, 0, WriteNodeBufferSize)) > 0) - { - this.WriteChars(_writeNodeBuffer, 0, read); - } - } - else - { - WriteString(reader.Value); - } - break; - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - - WriteWhitespace(reader.Value); - - break; - case XmlNodeType.CDATA: - WriteCData(reader.Value); - break; - case XmlNodeType.EntityReference: - WriteEntityRef(reader.Name); - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.ProcessingInstruction: - WriteProcessingInstruction(reader.Name, reader.Value); - break; - case XmlNodeType.DocumentType: - WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value); - break; - - case XmlNodeType.Comment: - WriteComment(reader.Value); - break; - case XmlNodeType.EndElement: - WriteFullEndElement(); - break; - } - } while (reader.Read() && (d < reader.Depth || (d == reader.Depth && reader.NodeType == XmlNodeType.EndElement))); - } - - // Copies the current node from the given XPathNavigator to the writer (including child nodes). - public virtual void WriteNode(XPathNavigator navigator, bool defattr) - { - if (navigator == null) - { - throw new ArgumentNullException("navigator"); - } - int iLevel = 0; - - navigator = navigator.Clone(); - - while (true) - { - bool mayHaveChildren = false; - XPathNodeType nodeType = navigator.NodeType; - - switch (nodeType) - { - case XPathNodeType.Element: - WriteStartElement(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI); - - // Copy attributes - if (navigator.MoveToFirstAttribute()) - { - do - { - IXmlSchemaInfo schemaInfo = navigator.SchemaInfo; - if (defattr || (schemaInfo == null || !schemaInfo.IsDefault)) - { - WriteStartAttribute(navigator.Prefix, navigator.LocalName, navigator.NamespaceURI); - // copy string value to writer - WriteString(navigator.Value); - WriteEndAttribute(); - } - } while (navigator.MoveToNextAttribute()); - navigator.MoveToParent(); - } - - // Copy namespaces - if (navigator.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - WriteLocalNamespaces(navigator); - navigator.MoveToParent(); - } - mayHaveChildren = true; - break; - case XPathNodeType.Attribute: - // do nothing on root level attribute - break; - case XPathNodeType.Text: - WriteString(navigator.Value); - break; - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - WriteWhitespace(navigator.Value); - break; - case XPathNodeType.Root: - mayHaveChildren = true; - break; - case XPathNodeType.Comment: - WriteComment(navigator.Value); - break; - case XPathNodeType.ProcessingInstruction: - WriteProcessingInstruction(navigator.LocalName, navigator.Value); - break; - case XPathNodeType.Namespace: - // do nothing on root level namespace - break; - default: - Debug.Assert(false); - break; - } - - if (mayHaveChildren) - { - // If children exist, move down to next level - if (navigator.MoveToFirstChild()) - { - iLevel++; - continue; - } - else - { - // EndElement - if (navigator.NodeType == XPathNodeType.Element) - { - if (navigator.IsEmptyElement) - { - WriteEndElement(); - } - else - { - WriteFullEndElement(); - } - } - } - } - - // No children - while (true) - { - if (iLevel == 0) - { - // The entire subtree has been copied - return; - } - - if (navigator.MoveToNext()) - { - // Found a sibling, so break to outer loop - break; - } - - // No siblings, so move up to previous level - iLevel--; - navigator.MoveToParent(); - - // EndElement - if (navigator.NodeType == XPathNodeType.Element) - WriteFullEndElement(); - } - } - } - - // Element Helper Methods - - // Writes out an element with the specified name containing the specified string value. - public void WriteElementString(string localName, String value) - { - WriteElementString(localName, null, value); - } - - // Writes out an attribute with the specified name, namespace URI and string value. - public void WriteElementString(string localName, String ns, String value) - { - WriteStartElement(localName, ns); - if (null != value && 0 != value.Length) - { - WriteString(value); - } - WriteEndElement(); - } - - // Writes out an attribute with the specified name, namespace URI, and string value. - public void WriteElementString(string prefix, String localName, String ns, String value) - { - WriteStartElement(prefix, localName, ns); - if (null != value && 0 != value.Length) - { - WriteString(value); - } - WriteEndElement(); - } - - public void Dispose() - { - Dispose(true); - } - - // Dispose the underline stream objects (calls Close on the XmlWriter) - protected virtual void Dispose(bool disposing) - { - if (disposing && WriteState != WriteState.Closed) - { - Close(); - } - } - - // Copy local namespaces on the navigator's current node to the raw writer. The namespaces are returned by the navigator in reversed order. - // The recursive call reverses them back. - private void WriteLocalNamespaces(XPathNavigator nsNav) - { - string prefix = nsNav.LocalName; - string ns = nsNav.Value; - - if (nsNav.MoveToNextNamespace(XPathNamespaceScope.Local)) - { - WriteLocalNamespaces(nsNav); - } - - if (prefix.Length == 0) - { - WriteAttributeString(string.Empty, "xmlns", XmlReservedNs.NsXmlNs, ns); - } - else - { - WriteAttributeString("xmlns", prefix, XmlReservedNs.NsXmlNs, ns); - } - } - - // - // Static methods for creating writers - // - // Creates an XmlWriter for writing into the provided file. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public static XmlWriter Create(string outputFileName) - { - return Create(outputFileName, null); - } - - // Creates an XmlWriter for writing into the provided file with the specified settings. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public static XmlWriter Create(string outputFileName, XmlWriterSettings settings) - { - if (settings == null) - { - settings = new XmlWriterSettings(); - } - return settings.CreateWriter(outputFileName); - } - - // Creates an XmlWriter for writing into the provided stream. - public static XmlWriter Create(Stream output) - { - return Create(output, null); - } - - // Creates an XmlWriter for writing into the provided stream with the specified settings. - public static XmlWriter Create(Stream output, XmlWriterSettings settings) - { - if (settings == null) - { - settings = new XmlWriterSettings(); - } - return settings.CreateWriter(output); - } - - // Creates an XmlWriter for writing into the provided TextWriter. - public static XmlWriter Create(TextWriter output) - { - return Create(output, null); - } - - // Creates an XmlWriter for writing into the provided TextWriter with the specified settings. - public static XmlWriter Create(TextWriter output, XmlWriterSettings settings) - { - if (settings == null) - { - settings = new XmlWriterSettings(); - } - return settings.CreateWriter(output); - } - - // Creates an XmlWriter for writing into the provided StringBuilder. - public static XmlWriter Create(StringBuilder output) - { - return Create(output, null); - } - - // Creates an XmlWriter for writing into the provided StringBuilder with the specified settings. - public static XmlWriter Create(StringBuilder output, XmlWriterSettings settings) - { - if (settings == null) - { - settings = new XmlWriterSettings(); - } - if (output == null) - { - throw new ArgumentNullException("output"); - } - return settings.CreateWriter(new StringWriter(output, CultureInfo.InvariantCulture)); - } - - // Creates an XmlWriter wrapped around the provided XmlWriter with the default settings. - public static XmlWriter Create(XmlWriter output) - { - return Create(output, null); - } - - // Creates an XmlWriter wrapped around the provided XmlWriter with the specified settings. - public static XmlWriter Create(XmlWriter output, XmlWriterSettings settings) - { - if (settings == null) - { - settings = new XmlWriterSettings(); - } - return settings.CreateWriter(output); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriterSettings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriterSettings.cs deleted file mode 100644 index 807131cf00c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XmlWriterSettings.cs +++ /dev/null @@ -1,787 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; -// using System.Security.Permissions; -using System.Runtime.Versioning; - - -namespace Microsoft.Xml -{ - using System; - - public enum XmlOutputMethod - { - Xml = 0, // Use Xml 1.0 rules to serialize - Html = 1, // Use Html rules specified by Xslt specification to serialize - Text = 2, // Only serialize text blocks - AutoDetect = 3, // Choose between Xml and Html output methods at runtime (using Xslt rules to do so) - } - - /// - /// Three-state logic enumeration. - /// - internal enum TriState - { - Unknown = -1, - False = 0, - True = 1, - }; - - internal enum XmlStandalone - { - // Do not change the constants - XmlBinaryWriter depends in it - Omit = 0, - Yes = 1, - No = 2, - } - - // XmlWriterSettings class specifies basic features of an XmlWriter. - public sealed class XmlWriterSettings - { - // - // Fields - // - - // Text settings - private Encoding _encoding; - - private bool _omitXmlDecl; - private NewLineHandling _newLineHandling; - private string _newLineChars; - private TriState _indent; - private string _indentChars; - private bool _newLineOnAttributes; - private bool _closeOutput; - private NamespaceHandling _namespaceHandling; - - // Conformance settings - private ConformanceLevel _conformanceLevel; - private bool _checkCharacters; - private bool _writeEndDocumentOnClose; - - // Xslt settings - private XmlOutputMethod _outputMethod; - private List _cdataSections = new List(); - private bool _doNotEscapeUriAttributes; - private bool _mergeCDataSections; - private string _mediaType; - private string _docTypeSystem; - private string _docTypePublic; - private XmlStandalone _standalone; - private bool _autoXmlDecl; - - // read-only flag - private bool _isReadOnly; - - // - // Constructor - // - public XmlWriterSettings() - { - Initialize(); - } - - // - // Properties - // - - // Text - public Encoding Encoding - { - get - { - return _encoding; - } - set - { - CheckReadOnly("Encoding"); - _encoding = value; - } - } - - // True if an xml declaration should *not* be written. - public bool OmitXmlDeclaration - { - get - { - return _omitXmlDecl; - } - set - { - CheckReadOnly("OmitXmlDeclaration"); - _omitXmlDecl = value; - } - } - - // See NewLineHandling enum for details. - public NewLineHandling NewLineHandling - { - get - { - return _newLineHandling; - } - set - { - CheckReadOnly("NewLineHandling"); - - if ((uint)value > (uint)NewLineHandling.None) - { - throw new ArgumentOutOfRangeException("value"); - } - _newLineHandling = value; - } - } - - // Line terminator string. By default, this is a carriage return followed by a line feed ("\r\n"). - public string NewLineChars - { - get - { - return _newLineChars; - } - set - { - CheckReadOnly("NewLineChars"); - - if (value == null) - { - throw new ArgumentNullException("value"); - } - _newLineChars = value; - } - } - - // True if output should be indented using rules that are appropriate to the output rules (i.e. Xml, Html, etc). - public bool Indent - { - get - { - return _indent == TriState.True; - } - set - { - CheckReadOnly("Indent"); - _indent = value ? TriState.True : TriState.False; - } - } - - // Characters to use when indenting. This is usually tab or some spaces, but can be anything. - public string IndentChars - { - get - { - return _indentChars; - } - set - { - CheckReadOnly("IndentChars"); - - if (value == null) - { - throw new ArgumentNullException("value"); - } - _indentChars = value; - } - } - - // Whether or not indent attributes on new lines. - public bool NewLineOnAttributes - { - get - { - return _newLineOnAttributes; - } - set - { - CheckReadOnly("NewLineOnAttributes"); - _newLineOnAttributes = value; - } - } - - // Whether or not the XmlWriter should close the underlying stream or TextWriter when Close is called on the XmlWriter. - public bool CloseOutput - { - get - { - return _closeOutput; - } - set - { - CheckReadOnly("CloseOutput"); - _closeOutput = value; - } - } - - - // Conformance - // See ConformanceLevel enum for details. - public ConformanceLevel ConformanceLevel - { - get - { - return _conformanceLevel; - } - set - { - CheckReadOnly("ConformanceLevel"); - - if ((uint)value > (uint)ConformanceLevel.Document) - { - throw new ArgumentOutOfRangeException("value"); - } - _conformanceLevel = value; - } - } - - // Whether or not to check content characters that they are valid XML characters. - public bool CheckCharacters - { - get - { - return _checkCharacters; - } - set - { - CheckReadOnly("CheckCharacters"); - _checkCharacters = value; - } - } - - // Whether or not to remove duplicate namespace declarations - public NamespaceHandling NamespaceHandling - { - get - { - return _namespaceHandling; - } - set - { - CheckReadOnly("NamespaceHandling"); - if ((uint)value > (uint)(NamespaceHandling.OmitDuplicates)) - { - throw new ArgumentOutOfRangeException("value"); - } - _namespaceHandling = value; - } - } - - //Whether or not to auto complete end-element when close/dispose - public bool WriteEndDocumentOnClose - { - get - { - return _writeEndDocumentOnClose; - } - set - { - CheckReadOnly("WriteEndDocumentOnClose"); - _writeEndDocumentOnClose = value; - } - } - - // Specifies the method (Html, Xml, etc.) that will be used to serialize the result tree. - public XmlOutputMethod OutputMethod - { - get - { - return _outputMethod; - } - internal set - { - _outputMethod = value; - } - } - - // - // Public methods - // - public void Reset() - { - CheckReadOnly("Reset"); - Initialize(); - } - - // Deep clone all settings (except read-only, which is always set to false). The original and new objects - // can now be set independently of each other. - public XmlWriterSettings Clone() - { - XmlWriterSettings clonedSettings = MemberwiseClone() as XmlWriterSettings; - - // Deep clone shared settings that are not immutable - clonedSettings._cdataSections = new List(_cdataSections); - - clonedSettings._isReadOnly = false; - return clonedSettings; - } - - // - // Internal properties - // - // Set of XmlQualifiedNames that identify any elements that need to have text children wrapped in CData sections. - internal List CDataSectionElements - { - get - { - Debug.Assert(_cdataSections != null); - return _cdataSections; - } - } - - // Used in Html writer to disable encoding of uri attributes - public bool DoNotEscapeUriAttributes - { - get - { - return _doNotEscapeUriAttributes; - } - set - { - CheckReadOnly("DoNotEscapeUriAttributes"); - _doNotEscapeUriAttributes = value; - } - } - - internal bool MergeCDataSections - { - get - { - return _mergeCDataSections; - } - set - { - CheckReadOnly("MergeCDataSections"); - _mergeCDataSections = value; - } - } - - // Used in Html writer when writing Meta element. Null denotes the default media type. - internal string MediaType - { - get - { - return _mediaType; - } - set - { - CheckReadOnly("MediaType"); - _mediaType = value; - } - } - - // System Id in doc-type declaration. Null denotes the absence of the system Id. - internal string DocTypeSystem - { - get - { - return _docTypeSystem; - } - set - { - CheckReadOnly("DocTypeSystem"); - _docTypeSystem = value; - } - } - - // Public Id in doc-type declaration. Null denotes the absence of the public Id. - internal string DocTypePublic - { - get - { - return _docTypePublic; - } - set - { - CheckReadOnly("DocTypePublic"); - _docTypePublic = value; - } - } - - // Yes for standalone="yes", No for standalone="no", and Omit for no standalone. - internal XmlStandalone Standalone - { - get - { - return _standalone; - } - set - { - CheckReadOnly("Standalone"); - _standalone = value; - } - } - - // True if an xml declaration should automatically be output (no need to call WriteStartDocument) - internal bool AutoXmlDeclaration - { - get - { - return _autoXmlDecl; - } - set - { - CheckReadOnly("AutoXmlDeclaration"); - _autoXmlDecl = value; - } - } - - // If TriState.Unknown, then Indent property was not explicitly set. In this case, the AutoDetect output - // method will default to Indent=true for Html and Indent=false for Xml. - internal TriState IndentInternal - { - get - { - return _indent; - } - set - { - _indent = value; - } - } - - internal bool IsQuerySpecific - { - get - { - return _cdataSections.Count != 0 || _docTypePublic != null || - _docTypeSystem != null || _standalone == XmlStandalone.Yes; - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - internal XmlWriter CreateWriter(string outputFileName) - { - if (outputFileName == null) - { - throw new ArgumentNullException("outputFileName"); - } - - // need to clone the settigns so that we can set CloseOutput to true to make sure the stream gets closed in the end - XmlWriterSettings newSettings = this; - if (!newSettings.CloseOutput) - { - newSettings = newSettings.Clone(); - newSettings.CloseOutput = true; - } - - FileStream fs = null; - try - { - // open file stream - fs = new FileStream(outputFileName, FileMode.Create, FileAccess.Write, FileShare.Read); - - // create writer - return newSettings.CreateWriter(fs); - } - catch - { - if (fs != null) - { - fs.Close(); - } - throw; - } - } - - internal XmlWriter CreateWriter(Stream output) - { - if (output == null) - { - throw new ArgumentNullException("output"); - } - - XmlWriter writer; - - // create raw writer - - Debug.Assert(Encoding.UTF8.WebName == "utf-8"); - if (this.Encoding.WebName == "utf-8") - { // Encoding.CodePage is not supported in Silverlight - // create raw UTF-8 writer - switch (this.OutputMethod) - { - case XmlOutputMethod.Xml: - if (this.Indent) - { - writer = new XmlUtf8RawTextWriterIndent(output, this); - } - else - { - writer = new XmlUtf8RawTextWriter(output, this); - } - break; - case XmlOutputMethod.Html: - if (this.Indent) - { - writer = new HtmlUtf8RawTextWriterIndent(output, this); - } - else - { - writer = new HtmlUtf8RawTextWriter(output, this); - } - break; - case XmlOutputMethod.Text: - writer = new TextUtf8RawTextWriter(output, this); - break; - case XmlOutputMethod.AutoDetect: - writer = new XmlAutoDetectWriter(output, this); - break; - default: - Debug.Assert(false, "Invalid XmlOutputMethod setting."); - return null; - } - } - else - { - // Otherwise, create a general-purpose writer than can do any encoding - switch (this.OutputMethod) - { - case XmlOutputMethod.Xml: - if (this.Indent) - { - writer = new XmlEncodedRawTextWriterIndent(output, this); - } - else - { - writer = new XmlEncodedRawTextWriter(output, this); - } - break; - case XmlOutputMethod.Html: - if (this.Indent) - { - writer = new HtmlEncodedRawTextWriterIndent(output, this); - } - else - { - writer = new HtmlEncodedRawTextWriter(output, this); - } - break; - case XmlOutputMethod.Text: - writer = new TextEncodedRawTextWriter(output, this); - break; - case XmlOutputMethod.AutoDetect: - writer = new XmlAutoDetectWriter(output, this); - break; - default: - Debug.Assert(false, "Invalid XmlOutputMethod setting."); - return null; - } - } - - // Wrap with Xslt/XQuery specific writer if needed; - // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer. - if (this.OutputMethod != XmlOutputMethod.AutoDetect) - { - if (this.IsQuerySpecific) - { - // Create QueryOutputWriter if CData sections or DocType need to be tracked - writer = new QueryOutputWriter((XmlRawWriter)writer, this); - } - } - - // wrap with well-formed writer - writer = new XmlWellFormedWriter(writer, this); - - return writer; - } - - internal XmlWriter CreateWriter(TextWriter output) - { - if (output == null) - { - throw new ArgumentNullException("output"); - } - - XmlWriter writer; - - // create raw writer - switch (this.OutputMethod) - { - case XmlOutputMethod.Xml: - if (this.Indent) - { - writer = new XmlEncodedRawTextWriterIndent(output, this); - } - else - { - writer = new XmlEncodedRawTextWriter(output, this); - } - break; - case XmlOutputMethod.Html: - if (this.Indent) - { - writer = new HtmlEncodedRawTextWriterIndent(output, this); - } - else - { - writer = new HtmlEncodedRawTextWriter(output, this); - } - break; - case XmlOutputMethod.Text: - writer = new TextEncodedRawTextWriter(output, this); - break; - case XmlOutputMethod.AutoDetect: - writer = new XmlAutoDetectWriter(output, this); - break; - default: - Debug.Assert(false, "Invalid XmlOutputMethod setting."); - return null; - } - - // XmlOutputMethod.AutoDetect writer does this lazily when it creates the underlying Xml or Html writer. - if (this.OutputMethod != XmlOutputMethod.AutoDetect) - { - if (this.IsQuerySpecific) - { - // Create QueryOutputWriter if CData sections or DocType need to be tracked - writer = new QueryOutputWriter((XmlRawWriter)writer, this); - } - } - - // wrap with well-formed writer - writer = new XmlWellFormedWriter(writer, this); - - return writer; - } - - internal XmlWriter CreateWriter(XmlWriter output) - { - if (output == null) - { - throw new ArgumentNullException("output"); - } - - return AddConformanceWrapper(output); - } - - - internal bool ReadOnly - { - get - { - return _isReadOnly; - } - set - { - _isReadOnly = value; - } - } - - private void CheckReadOnly(string propertyName) - { - if (_isReadOnly) - { - throw new XmlException(ResXml.Xml_ReadOnlyProperty, this.GetType().Name + '.' + propertyName); - } - } - - // - // Private methods - // - private void Initialize() - { - _encoding = Encoding.UTF8; - _omitXmlDecl = false; - _newLineHandling = NewLineHandling.Replace; - _newLineChars = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix - _indent = TriState.Unknown; - _indentChars = " "; - _newLineOnAttributes = false; - _closeOutput = false; - _namespaceHandling = NamespaceHandling.Default; - _conformanceLevel = ConformanceLevel.Document; - _checkCharacters = true; - _writeEndDocumentOnClose = true; - - _outputMethod = XmlOutputMethod.Xml; - _cdataSections.Clear(); - _mergeCDataSections = false; - _mediaType = null; - _docTypeSystem = null; - _docTypePublic = null; - _standalone = XmlStandalone.Omit; - _doNotEscapeUriAttributes = false; - - _isReadOnly = false; - } - - 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; - } - - // - // Internal methods - // - internal void GetObjectData(object writer) { } - internal XmlWriterSettings(object reader) { } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReader.cs deleted file mode 100644 index f0a2ebdbce0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReader.cs +++ /dev/null @@ -1,781 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; -using System.Globalization; -using System.Collections; -// using System.Security.Policy; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XsdCachingReader : XmlReader, IXmlLineInfo - { - private enum CachingReaderState - { - None = 0, - Init = 1, - Record = 2, - Replay = 3, - ReaderClosed = 4, - Error = 5, - } - - private XmlReader _coreReader; - private XmlNameTable _coreReaderNameTable; - - private ValidatingReaderNodeData[] _contentEvents; - private ValidatingReaderNodeData[] _attributeEvents; - - private ValidatingReaderNodeData _cachedNode; - - private CachingReaderState _cacheState; - private int _contentIndex; - private int _attributeCount; - - private bool _returnOriginalStringValues; - - private CachingEventHandler _cacheHandler; - - //current state - private int _currentAttrIndex; - private int _currentContentIndex; - private bool _readAhead; - - //Lineinfo - private IXmlLineInfo _lineInfo; - - //ReadAttributeValue TextNode - private ValidatingReaderNodeData _textNode; - - //Constants - private const int InitialAttributeCount = 8; - private const int InitialContentCount = 4; - - //Constructor - internal XsdCachingReader(XmlReader reader, IXmlLineInfo lineInfo, CachingEventHandler handlerMethod) - { - _coreReader = reader; - _lineInfo = lineInfo; - _cacheHandler = handlerMethod; - _attributeEvents = new ValidatingReaderNodeData[InitialAttributeCount]; - _contentEvents = new ValidatingReaderNodeData[InitialContentCount]; - Init(); - } - - private void Init() - { - _coreReaderNameTable = _coreReader.NameTable; - _cacheState = CachingReaderState.Init; - _contentIndex = 0; - _currentAttrIndex = -1; - _currentContentIndex = -1; - _attributeCount = 0; - _cachedNode = null; - _readAhead = false; - //Initialize the cachingReader with start state - if (_coreReader.NodeType == XmlNodeType.Element) - { - ValidatingReaderNodeData element = AddContent(_coreReader.NodeType); - element.SetItemData(_coreReader.LocalName, _coreReader.Prefix, _coreReader.NamespaceURI, _coreReader.Depth); //Only created for element node type - element.SetLineInfo(_lineInfo); - RecordAttributes(); - } - } - - internal void Reset(XmlReader reader) - { - _coreReader = reader; - Init(); - } - - // Settings - public override XmlReaderSettings Settings - { - get - { - return _coreReader.Settings; - } - } - - // Node Properties - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - return _cachedNode.NodeType; - } - } - - // Gets the name of the current node, including the namespace prefix. - public override string Name - { - get - { - return _cachedNode.GetAtomizedNameWPrefix(_coreReaderNameTable); - } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get - { - return _cachedNode.LocalName; - } - } - - // Gets the namespace URN (as defined in the W3C Namespace Specification) of the current namespace scope. - public override string NamespaceURI - { - get - { - return _cachedNode.Namespace; - } - } - - // Gets the namespace prefix associated with the current node. - public override string Prefix - { - get - { - return _cachedNode.Prefix; - } - } - - // Gets a value indicating whether the current node can have a non-empty Value. - public override bool HasValue - { - get - { - return XmlReader.HasValueInternal(_cachedNode.NodeType); - } - } - - // Gets the text value of the current node. - public override string Value - { - get - { - return _returnOriginalStringValues ? _cachedNode.OriginalStringValue : _cachedNode.RawValue; - } - } - - // Gets the depth of the current node in the XML element stack. - public override int Depth - { - get - { - return _cachedNode.Depth; - } - } - - // Gets the base URI of the current node. - public override string BaseURI - { - get - { - return _coreReader.BaseURI; - } - } - - // Gets a value indicating whether the current node is an empty element (for example, ). - public override bool IsEmptyElement - { - get - { - return false; - } - } - - // Gets a value indicating whether the current node is an attribute that was generated from the default value defined - // in the DTD or schema. - public override bool IsDefault - { - get - { - return false; - } - } - - // Gets the quotation mark character used to enclose the value of an attribute node. - public override char QuoteChar - { - get - { - return _coreReader.QuoteChar; - } - } - - // Gets the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - return _coreReader.XmlSpace; - } - } - - // Gets the current xml:lang scope. - public override string XmlLang - { - get - { - return _coreReader.XmlLang; - } - } - - // Attribute Accessors - - // The number of attributes on the current node. - public override int AttributeCount - { - get - { - return _attributeCount; - } - } - - // Gets the value of the attribute with the specified Name. - public override string GetAttribute(string name) - { - int i; - if (name.IndexOf(':') == -1) - { - i = GetAttributeIndexWithoutPrefix(name); - } - else - { - i = GetAttributeIndexWithPrefix(name); - } - return (i >= 0) ? _attributeEvents[i].RawValue : null; - } - - // Gets the value of the attribute with the specified LocalName and NamespaceURI. - public override string GetAttribute(string name, string namespaceURI) - { - namespaceURI = (namespaceURI == null) ? string.Empty : _coreReaderNameTable.Get(namespaceURI); - name = _coreReaderNameTable.Get(name); - ValidatingReaderNodeData attribute; - for (int i = 0; i < _attributeCount; i++) - { - attribute = _attributeEvents[i]; - if (Ref.Equal(attribute.LocalName, name) && Ref.Equal(attribute.Namespace, namespaceURI)) - { - return attribute.RawValue; - } - } - return null; - } - - // Gets the value of the attribute with the specified index. - public override string GetAttribute(int i) - { - if (i < 0 || i >= _attributeCount) - { - throw new ArgumentOutOfRangeException("i"); - } - return _attributeEvents[i].RawValue; - } - - // Gets the value of the attribute with the specified index. - public override string this[int i] - { - get - { - return GetAttribute(i); - } - } - - // Gets the value of the attribute with the specified Name. - public override string this[string name] - { - get - { - return GetAttribute(name); - } - } - - // Gets the value of the attribute with the specified LocalName and NamespaceURI. - public override string this[string name, string namespaceURI] - { - get - { - return GetAttribute(name, namespaceURI); - } - } - - // Moves to the attribute with the specified Name. - public override bool MoveToAttribute(string name) - { - int i; - if (name.IndexOf(':') == -1) - { - i = GetAttributeIndexWithoutPrefix(name); - } - else - { - i = GetAttributeIndexWithPrefix(name); - } - - if (i >= 0) - { - _currentAttrIndex = i; - _cachedNode = _attributeEvents[i]; - return true; - } - else - { - return false; - } - } - - // Moves to the attribute with the specified LocalName and NamespaceURI - public override bool MoveToAttribute(string name, string ns) - { - ns = (ns == null) ? string.Empty : _coreReaderNameTable.Get(ns); - name = _coreReaderNameTable.Get(name); - ValidatingReaderNodeData attribute; - for (int i = 0; i < _attributeCount; i++) - { - attribute = _attributeEvents[i]; - if (Ref.Equal(attribute.LocalName, name) && - Ref.Equal(attribute.Namespace, ns)) - { - _currentAttrIndex = i; - _cachedNode = _attributeEvents[i]; - return true; - } - } - return false; - } - - // Moves to the attribute with the specified index. - public override void MoveToAttribute(int i) - { - if (i < 0 || i >= _attributeCount) - { - throw new ArgumentOutOfRangeException("i"); - } - _currentAttrIndex = i; - _cachedNode = _attributeEvents[i]; - } - - // Moves to the first attribute. - public override bool MoveToFirstAttribute() - { - if (_attributeCount == 0) - { - return false; - } - _currentAttrIndex = 0; - _cachedNode = _attributeEvents[0]; - return true; - } - - // Moves to the next attribute. - public override bool MoveToNextAttribute() - { - if (_currentAttrIndex + 1 < _attributeCount) - { - _cachedNode = _attributeEvents[++_currentAttrIndex]; - return true; - } - return false; - } - - // Moves to the element that contains the current attribute node. - public override bool MoveToElement() - { - if (_cacheState != CachingReaderState.Replay || _cachedNode.NodeType != XmlNodeType.Attribute) - { - return false; - } - _currentContentIndex = 0; - _currentAttrIndex = -1; - Read(); - return true; - } - - // Reads the next node from the stream/TextReader. - public override bool Read() - { - switch (_cacheState) - { - case CachingReaderState.Init: - _cacheState = CachingReaderState.Record; - goto case CachingReaderState.Record; - - case CachingReaderState.Record: - ValidatingReaderNodeData recordedNode = null; - if (_coreReader.Read()) - { - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - //Dont record element within the content of a union type since the main reader will break on this and the underlying coreReader will be positioned on this node - _cacheState = CachingReaderState.ReaderClosed; - return false; - - case XmlNodeType.EndElement: - recordedNode = AddContent(_coreReader.NodeType); - recordedNode.SetItemData(_coreReader.LocalName, _coreReader.Prefix, _coreReader.NamespaceURI, _coreReader.Depth); //Only created for element node type - recordedNode.SetLineInfo(_lineInfo); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - recordedNode = AddContent(_coreReader.NodeType); - recordedNode.SetItemData(_coreReader.Value); - recordedNode.SetLineInfo(_lineInfo); - recordedNode.Depth = _coreReader.Depth; - break; - - default: - break; - } - _cachedNode = recordedNode; - return true; - } - else - { - _cacheState = CachingReaderState.ReaderClosed; - return false; - } - - case CachingReaderState.Replay: - if (_currentContentIndex >= _contentIndex) - { //When positioned on the last cached node, switch back as the underlying coreReader is still positioned on this node - _cacheState = CachingReaderState.ReaderClosed; - _cacheHandler(this); - if (_coreReader.NodeType != XmlNodeType.Element || _readAhead) - { //Only when coreReader not positioned on Element node, read ahead, otherwise it is on the next element node already, since this was not cached - return _coreReader.Read(); - } - return true; - } - _cachedNode = _contentEvents[_currentContentIndex]; - if (_currentContentIndex > 0) - { - ClearAttributesInfo(); - } - _currentContentIndex++; - return true; - - default: - return false; - } - } - - internal ValidatingReaderNodeData RecordTextNode(string textValue, string originalStringValue, int depth, int lineNo, int linePos) - { - ValidatingReaderNodeData textNode = AddContent(XmlNodeType.Text); - textNode.SetItemData(textValue, originalStringValue); - textNode.SetLineInfo(lineNo, linePos); - textNode.Depth = depth; - return textNode; - } - - internal void SwitchTextNodeAndEndElement(string textValue, string originalStringValue) - { - Debug.Assert(_coreReader.NodeType == XmlNodeType.EndElement || (_coreReader.NodeType == XmlNodeType.Element && _coreReader.IsEmptyElement)); - - ValidatingReaderNodeData textNode = RecordTextNode(textValue, originalStringValue, _coreReader.Depth + 1, 0, 0); - int endElementIndex = _contentIndex - 2; - ValidatingReaderNodeData endElementNode = _contentEvents[endElementIndex]; - Debug.Assert(endElementNode.NodeType == XmlNodeType.EndElement); - _contentEvents[endElementIndex] = textNode; - _contentEvents[_contentIndex - 1] = endElementNode; - } - - internal void RecordEndElementNode() - { - ValidatingReaderNodeData recordedNode = AddContent(XmlNodeType.EndElement); - Debug.Assert(_coreReader.NodeType == XmlNodeType.EndElement || (_coreReader.NodeType == XmlNodeType.Element && _coreReader.IsEmptyElement)); - recordedNode.SetItemData(_coreReader.LocalName, _coreReader.Prefix, _coreReader.NamespaceURI, _coreReader.Depth); - recordedNode.SetLineInfo(_coreReader as IXmlLineInfo); - if (_coreReader.IsEmptyElement) - { //Simulated endElement node for , the coreReader is on cached Element node itself. - _readAhead = true; - } - } - - internal string ReadOriginalContentAsString() - { - _returnOriginalStringValues = true; - string strValue = InternalReadContentAsString(); - _returnOriginalStringValues = false; - return strValue; - } - - // Gets a value indicating whether XmlReader is positioned at the end of the stream. - public override bool EOF - { - get - { - return _cacheState == CachingReaderState.ReaderClosed && _coreReader.EOF; - } - } - - // Closes the stream, changes the ReadState to Closed, and sets all the properties back to zero. - public override void Close() - { - _coreReader.Close(); - _cacheState = CachingReaderState.ReaderClosed; - } - - // Returns the read state of the stream. - public override ReadState ReadState - { - get - { - return _coreReader.ReadState; - } - } - - // Skips to the end tag of the current element. - public override void Skip() - { - //Skip on caching reader should move to the end of the subtree, past all cached events - switch (_cachedNode.NodeType) - { - case XmlNodeType.Element: - if (_coreReader.NodeType != XmlNodeType.EndElement && !_readAhead) - { //will be true for IsDefault cases where we peek only one node ahead - int startDepth = _coreReader.Depth - 1; - while (_coreReader.Read() && _coreReader.Depth > startDepth) - ; - } - _coreReader.Read(); - _cacheState = CachingReaderState.ReaderClosed; - _cacheHandler(this); - break; - - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - - default: - Debug.Assert(_cacheState == CachingReaderState.Replay); - Read(); - break; - } - } - - // Gets the XmlNameTable associated with this implementation. - public override XmlNameTable NameTable - { - get - { - return _coreReaderNameTable; - } - } - - // Resolves a namespace prefix in the current element's scope. - public override string LookupNamespace(string prefix) - { - return _coreReader.LookupNamespace(prefix); - } - - // Resolves the entity reference for nodes of NodeType EntityReference. - public override void ResolveEntity() - { - throw new InvalidOperationException(); - } - - // Parses the attribute value into one or more Text and/or EntityReference node types. - public override bool ReadAttributeValue() - { - Debug.Assert(_cacheState == CachingReaderState.Replay); - if (_cachedNode.NodeType != XmlNodeType.Attribute) - { - return false; - } - _cachedNode = CreateDummyTextNode(_cachedNode.RawValue, _cachedNode.Depth + 1); - return true; - } - - // - // IXmlLineInfo members - // - - bool IXmlLineInfo.HasLineInfo() - { - return true; - } - - int IXmlLineInfo.LineNumber - { - get - { - return _cachedNode.LineNumber; - } - } - - int IXmlLineInfo.LinePosition - { - get - { - return _cachedNode.LinePosition; - } - } - - //Private methods - internal void SetToReplayMode() - { - _cacheState = CachingReaderState.Replay; - _currentContentIndex = 0; - _currentAttrIndex = -1; - Read(); //Position on first node recorded to begin replaying - } - - internal XmlReader GetCoreReader() - { - return _coreReader; - } - - internal IXmlLineInfo GetLineInfo() - { - return _lineInfo; - } - - private void ClearAttributesInfo() - { - _attributeCount = 0; - _currentAttrIndex = -1; - } - - private ValidatingReaderNodeData AddAttribute(int attIndex) - { - Debug.Assert(attIndex <= _attributeEvents.Length); - ValidatingReaderNodeData attInfo = _attributeEvents[attIndex]; - if (attInfo != null) - { - attInfo.Clear(XmlNodeType.Attribute); - return attInfo; - } - if (attIndex >= _attributeEvents.Length - 1) - { //reached capacity of array, Need to increase capacity to twice the initial - ValidatingReaderNodeData[] newAttributeEvents = new ValidatingReaderNodeData[_attributeEvents.Length * 2]; - Array.Copy(_attributeEvents, 0, newAttributeEvents, 0, _attributeEvents.Length); - _attributeEvents = newAttributeEvents; - } - attInfo = _attributeEvents[attIndex]; - if (attInfo == null) - { - attInfo = new ValidatingReaderNodeData(XmlNodeType.Attribute); - _attributeEvents[attIndex] = attInfo; - } - return attInfo; - } - - private ValidatingReaderNodeData AddContent(XmlNodeType nodeType) - { - Debug.Assert(_contentIndex <= _contentEvents.Length); - ValidatingReaderNodeData contentInfo = _contentEvents[_contentIndex]; - if (contentInfo != null) - { - contentInfo.Clear(nodeType); - _contentIndex++; - return contentInfo; - } - if (_contentIndex >= _contentEvents.Length - 1) - { //reached capacity of array, Need to increase capacity to twice the initial - ValidatingReaderNodeData[] newContentEvents = new ValidatingReaderNodeData[_contentEvents.Length * 2]; - Array.Copy(_contentEvents, 0, newContentEvents, 0, _contentEvents.Length); - _contentEvents = newContentEvents; - } - contentInfo = _contentEvents[_contentIndex]; - if (contentInfo == null) - { - contentInfo = new ValidatingReaderNodeData(nodeType); - _contentEvents[_contentIndex] = contentInfo; - } - _contentIndex++; - return contentInfo; - } - - private void RecordAttributes() - { - Debug.Assert(_coreReader.NodeType == XmlNodeType.Element); - ValidatingReaderNodeData attInfo; - _attributeCount = _coreReader.AttributeCount; - if (_coreReader.MoveToFirstAttribute()) - { - int attIndex = 0; - do - { - attInfo = AddAttribute(attIndex); - attInfo.SetItemData(_coreReader.LocalName, _coreReader.Prefix, _coreReader.NamespaceURI, _coreReader.Depth); - attInfo.SetLineInfo(_lineInfo); - attInfo.RawValue = _coreReader.Value; - attIndex++; - } while (_coreReader.MoveToNextAttribute()); - _coreReader.MoveToElement(); - } - } - - private int GetAttributeIndexWithoutPrefix(string name) - { - name = _coreReaderNameTable.Get(name); - if (name == null) - { - return -1; - } - ValidatingReaderNodeData attribute; - for (int i = 0; i < _attributeCount; i++) - { - attribute = _attributeEvents[i]; - if (Ref.Equal(attribute.LocalName, name) && attribute.Prefix.Length == 0) - { - return i; - } - } - return -1; - } - - private int GetAttributeIndexWithPrefix(string name) - { - name = _coreReaderNameTable.Get(name); - if (name == null) - { - return -1; - } - ValidatingReaderNodeData attribute; - for (int i = 0; i < _attributeCount; i++) - { - attribute = _attributeEvents[i]; - if (Ref.Equal(attribute.GetAtomizedNameWPrefix(_coreReaderNameTable), name)) - { - return i; - } - } - return -1; - } - - private ValidatingReaderNodeData CreateDummyTextNode(string attributeValue, int depth) - { - if (_textNode == null) - { - _textNode = new ValidatingReaderNodeData(XmlNodeType.Text); - } - _textNode.Depth = depth; - _textNode.RawValue = attributeValue; - return _textNode; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReaderAsync.cs deleted file mode 100644 index f05ffbdccbd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdCachingReaderAsync.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; -using System.Globalization; -using System.Collections; -// using System.Security.Policy; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XsdCachingReader : XmlReader, IXmlLineInfo - { - // Gets the text value of the current node. - public override Task GetValueAsync() - { - if (_returnOriginalStringValues) - { - return Task.FromResult(_cachedNode.OriginalStringValue); - } - else - { - return Task.FromResult(_cachedNode.RawValue); - } - } - - // Reads the next node from the stream/TextReader. - public override async Task ReadAsync() - { - switch (_cacheState) - { - case CachingReaderState.Init: - _cacheState = CachingReaderState.Record; - goto case CachingReaderState.Record; - - case CachingReaderState.Record: - ValidatingReaderNodeData recordedNode = null; - if (await _coreReader.ReadAsync().ConfigureAwait(false)) - { - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - //Dont record element within the content of a union type since the main reader will break on this and the underlying coreReader will be positioned on this node - _cacheState = CachingReaderState.ReaderClosed; - return false; - - case XmlNodeType.EndElement: - recordedNode = AddContent(_coreReader.NodeType); - recordedNode.SetItemData(_coreReader.LocalName, _coreReader.Prefix, _coreReader.NamespaceURI, _coreReader.Depth); //Only created for element node type - recordedNode.SetLineInfo(_lineInfo); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - recordedNode = AddContent(_coreReader.NodeType); - recordedNode.SetItemData(await _coreReader.GetValueAsync().ConfigureAwait(false)); - recordedNode.SetLineInfo(_lineInfo); - recordedNode.Depth = _coreReader.Depth; - break; - - default: - break; - } - _cachedNode = recordedNode; - return true; - } - else - { - _cacheState = CachingReaderState.ReaderClosed; - return false; - } - - case CachingReaderState.Replay: - if (_currentContentIndex >= _contentIndex) - { //When positioned on the last cached node, switch back as the underlying coreReader is still positioned on this node - _cacheState = CachingReaderState.ReaderClosed; - _cacheHandler(this); - if (_coreReader.NodeType != XmlNodeType.Element || _readAhead) - { //Only when coreReader not positioned on Element node, read ahead, otherwise it is on the next element node already, since this was not cached - return await _coreReader.ReadAsync().ConfigureAwait(false); - } - return true; - } - _cachedNode = _contentEvents[_currentContentIndex]; - if (_currentContentIndex > 0) - { - ClearAttributesInfo(); - } - _currentContentIndex++; - return true; - - default: - return false; - } - } - - // Skips to the end tag of the current element. - public override async Task SkipAsync() - { - //Skip on caching reader should move to the end of the subtree, past all cached events - switch (_cachedNode.NodeType) - { - case XmlNodeType.Element: - if (_coreReader.NodeType != XmlNodeType.EndElement && !_readAhead) - { //will be true for IsDefault cases where we peek only one node ahead - int startDepth = _coreReader.Depth - 1; - while (await _coreReader.ReadAsync().ConfigureAwait(false) && _coreReader.Depth > startDepth) - ; - } - await _coreReader.ReadAsync().ConfigureAwait(false); - _cacheState = CachingReaderState.ReaderClosed; - _cacheHandler(this); - break; - - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - - default: - Debug.Assert(_cacheState == CachingReaderState.Replay); - await ReadAsync().ConfigureAwait(false); - break; - } - } - - //Private methods - internal Task SetToReplayModeAsync() - { - _cacheState = CachingReaderState.Replay; - _currentContentIndex = 0; - _currentAttrIndex = -1; - return ReadAsync(); //Position on first node recorded to begin replaying - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReader.cs deleted file mode 100644 index 6919652f17c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReader.cs +++ /dev/null @@ -1,2642 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; -using System.Globalization; -using System.Collections; -// using System.Security.Policy; -using System.Collections.Generic; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - internal delegate void CachingEventHandler(XsdCachingReader cachingReader); - - internal class AttributePSVIInfo - { - internal string localName; - internal string namespaceUri; - internal object typedAttributeValue; - internal XmlSchemaInfo attributeSchemaInfo; - - internal AttributePSVIInfo() - { - attributeSchemaInfo = new XmlSchemaInfo(); - } - - internal void Reset() - { - typedAttributeValue = null; - localName = string.Empty; - namespaceUri = string.Empty; - attributeSchemaInfo.Clear(); - } - } - - internal partial class XsdValidatingReader : XmlReader, IXmlSchemaInfo, IXmlLineInfo, IXmlNamespaceResolver - { - private enum ValidatingReaderState - { - None = 0, - Init = 1, - Read = 2, - OnDefaultAttribute = -1, - OnReadAttributeValue = -2, - OnAttribute = 3, - ClearAttributes = 4, - ParseInlineSchema = 5, - ReadAhead = 6, - OnReadBinaryContent = 7, - ReaderClosed = 8, - EOF = 9, - Error = 10, - } - //Validation - private XmlReader _coreReader; - private IXmlNamespaceResolver _coreReaderNSResolver; - private IXmlNamespaceResolver _thisNSResolver; - private XmlSchemaValidator _validator; - private XmlResolver _xmlResolver; - private ValidationEventHandler _validationEvent; - private ValidatingReaderState _validationState; - private XmlValueGetter _valueGetter; - - // namespace management - private XmlNamespaceManager _nsManager; - private bool _manageNamespaces; - private bool _processInlineSchema; - private bool _replayCache; - - //Current Node handling - private ValidatingReaderNodeData _cachedNode; //Used to cache current node when looking ahead or default attributes - private AttributePSVIInfo _attributePSVI; - - //Attributes - private int _attributeCount; //Total count of attributes including default - private int _coreReaderAttributeCount; - private int _currentAttrIndex; - private AttributePSVIInfo[] _attributePSVINodes; - private ArrayList _defaultAttributes; - - //Inline Schema - private Parser _inlineSchemaParser = null; - - //Typed Value & PSVI - private object _atomicValue; - private XmlSchemaInfo _xmlSchemaInfo; - - // original string of the atomic value - private string _originalAtomicValueString; - - //cached coreReader information - private XmlNameTable _coreReaderNameTable; - private XsdCachingReader _cachingReader; - - //ReadAttributeValue TextNode - private ValidatingReaderNodeData _textNode; - - //To avoid SchemaNames creation - private string _nsXmlNs; - private string _nsXs; - private string _nsXsi; - private string _xsiType; - private string _xsiNil; - private string _xsdSchema; - private string _xsiSchemaLocation; - private string _xsiNoNamespaceSchemaLocation; - - //XmlCharType instance - private XmlCharType _xmlCharType = XmlCharType.Instance; - - //Underlying reader's IXmlLineInfo - private IXmlLineInfo _lineInfo; - - // helpers for Read[Element]ContentAs{Base64,BinHex} methods - private ReadContentAsBinaryHelper _readBinaryHelper; - private ValidatingReaderState _savedState; - - //Constants - private const int InitialAttributeCount = 8; - - private static volatile Type s_typeOfString; - - //Constructor - internal XsdValidatingReader(XmlReader reader, XmlResolver xmlResolver, XmlReaderSettings readerSettings, XmlSchemaObject partialValidationType) - { - _coreReader = reader; - _coreReaderNSResolver = reader as IXmlNamespaceResolver; - _lineInfo = reader as IXmlLineInfo; - _coreReaderNameTable = _coreReader.NameTable; - if (_coreReaderNSResolver == null) - { - _nsManager = new XmlNamespaceManager(_coreReaderNameTable); - _manageNamespaces = true; - } - _thisNSResolver = this as IXmlNamespaceResolver; - _xmlResolver = xmlResolver; - _processInlineSchema = (readerSettings.ValidationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != 0; - Init(); - SetupValidator(readerSettings, reader, partialValidationType); - _validationEvent = readerSettings.GetEventHandler(); - } - - internal XsdValidatingReader(XmlReader reader, XmlResolver xmlResolver, XmlReaderSettings readerSettings) - : - this(reader, xmlResolver, readerSettings, null) - { } - - private void Init() - { - _validationState = ValidatingReaderState.Init; - _defaultAttributes = new ArrayList(); - _currentAttrIndex = -1; - _attributePSVINodes = new AttributePSVIInfo[InitialAttributeCount]; - _valueGetter = new XmlValueGetter(GetStringValue); - s_typeOfString = typeof(System.String); - _xmlSchemaInfo = new XmlSchemaInfo(); - - //Add common strings to be compared to NameTable - _nsXmlNs = _coreReaderNameTable.Add(XmlReservedNs.NsXmlNs); - _nsXs = _coreReaderNameTable.Add(XmlReservedNs.NsXs); - _nsXsi = _coreReaderNameTable.Add(XmlReservedNs.NsXsi); - _xsiType = _coreReaderNameTable.Add("type"); - _xsiNil = _coreReaderNameTable.Add("nil"); - _xsiSchemaLocation = _coreReaderNameTable.Add("schemaLocation"); - _xsiNoNamespaceSchemaLocation = _coreReaderNameTable.Add("noNamespaceSchemaLocation"); - _xsdSchema = _coreReaderNameTable.Add("schema"); - } - - private void SetupValidator(XmlReaderSettings readerSettings, XmlReader reader, XmlSchemaObject partialValidationType) - { - _validator = new XmlSchemaValidator(_coreReaderNameTable, readerSettings.Schemas, _thisNSResolver, readerSettings.ValidationFlags); - _validator.XmlResolver = _xmlResolver; - _validator.SourceUri = XmlConvert.ToUri(reader.BaseURI); //Not using XmlResolver.ResolveUri as it checks for relative Uris,reader.BaseURI will be absolute file paths or string.Empty - _validator.ValidationEventSender = this; - _validator.ValidationEventHandler += readerSettings.GetEventHandler(); - _validator.LineInfoProvider = _lineInfo; - if (_validator.ProcessSchemaHints) - { - _validator.SchemaSet.ReaderSettings.DtdProcessing = readerSettings.DtdProcessing; - } - _validator.SetDtdSchemaInfo(reader.DtdInfo); - if (partialValidationType != null) - { - _validator.Initialize(partialValidationType); - } - else - { - _validator.Initialize(); - } - } - - // Settings - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings settings = _coreReader.Settings; - if (null != settings) - settings = settings.Clone(); - if (settings == null) - { - settings = new XmlReaderSettings(); - } - settings.Schemas = _validator.SchemaSet; - settings.ValidationType = ValidationType.Schema; - settings.ValidationFlags = _validator.ValidationFlags; - settings.ReadOnly = true; - return settings; - } - } - - // Node Properties - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.NodeType; - } - else - { - XmlNodeType nodeType = _coreReader.NodeType; - //Check for significant whitespace - if (nodeType == XmlNodeType.Whitespace && (_validator.CurrentContentType == XmlSchemaContentType.TextOnly || _validator.CurrentContentType == XmlSchemaContentType.Mixed)) - { - return XmlNodeType.SignificantWhitespace; - } - return nodeType; - } - } - } - - // Gets the name of the current node, including the namespace prefix. - public override string Name - { - get - { - if (_validationState == ValidatingReaderState.OnDefaultAttribute) - { - string prefix = _validator.GetDefaultAttributePrefix(_cachedNode.Namespace); - if (prefix != null && prefix.Length != 0) - { - return string.Concat(prefix + ":" + _cachedNode.LocalName); - } - return _cachedNode.LocalName; - } - return _coreReader.Name; - } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.LocalName; - } - return _coreReader.LocalName; - } - } - - // Gets the namespace URN (as defined in the W3C Namespace Specification) of the current namespace scope. - public override string NamespaceURI - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.Namespace; - } - return _coreReader.NamespaceURI; - } - } - - // Gets the namespace prefix associated with the current node. - public override string Prefix - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.Prefix; - } - return _coreReader.Prefix; - } - } - - // Gets a value indicating whether the current node can have a non-empty Value - public override bool HasValue - { - get - { - if ((int)_validationState < 0) - { - return true; - } - return _coreReader.HasValue; - } - } - - // Gets the text value of the current node. - public override string Value - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.RawValue; - } - return _coreReader.Value; - } - } - - // Gets the depth of the current node in the XML element stack. - public override int Depth - { - get - { - if ((int)_validationState < 0) - { - return _cachedNode.Depth; - } - return _coreReader.Depth; - } - } - - // Gets the base URI of the current node. - public override string BaseURI - { - get - { - return _coreReader.BaseURI; - } - } - - // Gets a value indicating whether the current node is an empty element (for example, ). - public override bool IsEmptyElement - { - get - { - return _coreReader.IsEmptyElement; - } - } - - // Gets a value indicating whether the current node is an attribute that was generated from the default value defined - // in the DTD or schema. - public override bool IsDefault - { - get - { - if (_validationState == ValidatingReaderState.OnDefaultAttribute) - { //XSD default attributes - return true; - } - return _coreReader.IsDefault; //This is DTD Default attribute - } - } - - // Gets the quotation mark character used to enclose the value of an attribute node. - public override char QuoteChar - { - get - { - return _coreReader.QuoteChar; - } - } - - // Gets the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - return _coreReader.XmlSpace; - } - } - - // Gets the current xml:lang scope. - public override string XmlLang - { - get - { - return _coreReader.XmlLang; - } - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - return this as IXmlSchemaInfo; - } - } - - public override System.Type ValueType - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.EndElement: //TODO Check that context is not popped to parents in the validator - if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - return _xmlSchemaInfo.SchemaType.Datatype.ValueType; - } - goto default; - - case XmlNodeType.Attribute: - if (_attributePSVI != null && AttributeSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - return AttributeSchemaInfo.SchemaType.Datatype.ValueType; - } - goto default; - - default: - return s_typeOfString; - } - } - } - - public override object ReadContentAsObject() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsObject"); - } - - return InternalReadContentAsObject(true); - } - - public override bool ReadContentAsBoolean() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsBoolean"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToBoolean(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToBoolean(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - } - - public override DateTime ReadContentAsDateTime() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsDateTime"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDateTime(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDateTime(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - } - - public override double ReadContentAsDouble() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsDouble"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDouble(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDouble(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - } - - public override float ReadContentAsFloat() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsFloat"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToSingle(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToSingle(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - } - - public override decimal ReadContentAsDecimal() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsDecimal"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDecimal(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDecimal(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - } - - public override int ReadContentAsInt() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsInt"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToInt32(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToInt32(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - } - - public override long ReadContentAsLong() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsLong"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToInt64(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToInt64(typedValue); - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - } - - public override string ReadContentAsString() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsString"); - } - object typedValue = InternalReadContentAsObject(); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToString(typedValue); - } - else - { - return typedValue as string; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - } - - public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAs"); - } - string originalStringValue; - - object typedValue = InternalReadContentAsObject(false, out originalStringValue); - - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; //TODO special case for xsd:duration and xsd:dateTime - try - { - if (xmlType != null) - { - // special-case convertions to DateTimeOffset; typedValue is by default a DateTime - // which cannot preserve time zone, so we need to convert from the original string - if (returnType == typeof(DateTimeOffset) && xmlType.Datatype is Datatype_dateTimeBase) - { - typedValue = originalStringValue; - } - return xmlType.ValueConverter.ChangeType(typedValue, returnType); - } - else - { - return XmlUntypedConverter.Untyped.ChangeType(typedValue, returnType, namespaceResolver); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - - public override object ReadElementContentAsObject() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsObject"); - } - XmlSchemaType xmlType; - - return InternalReadElementContentAsObject(out xmlType, true); - } - - public override bool ReadElementContentAsBoolean() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsBoolean"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToBoolean(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToBoolean(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Boolean", e, this as IXmlLineInfo); - } - } - - public override DateTime ReadElementContentAsDateTime() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsDateTime"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDateTime(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDateTime(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "DateTime", e, this as IXmlLineInfo); - } - } - - public override double ReadElementContentAsDouble() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsDouble"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDouble(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDouble(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo); - } - } - - public override float ReadElementContentAsFloat() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsFloat"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToSingle(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToSingle(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo); - } - } - - public override Decimal ReadElementContentAsDecimal() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsDecimal"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToDecimal(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToDecimal(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Decimal", e, this as IXmlLineInfo); - } - } - - public override int ReadElementContentAsInt() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsInt"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToInt32(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToInt32(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Int", e, this as IXmlLineInfo); - } - } - - public override long ReadElementContentAsLong() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsLong"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToInt64(typedValue); - } - else - { - return XmlUntypedConverter.Untyped.ToInt64(typedValue); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "Long", e, this as IXmlLineInfo); - } - } - - public override string ReadElementContentAsString() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsString"); - } - XmlSchemaType xmlType; - - object typedValue = InternalReadElementContentAsObject(out xmlType); - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToString(typedValue); - } - else - { - return typedValue as string; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - } - - public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAs"); - } - XmlSchemaType xmlType; - string originalStringValue; - - object typedValue = InternalReadElementContentAsObject(out xmlType, false, out originalStringValue); - - try - { - if (xmlType != null) - { - // special-case convertions to DateTimeOffset; typedValue is by default a DateTime - // which cannot preserve time zone, so we need to convert from the original string - if (returnType == typeof(DateTimeOffset) && xmlType.Datatype is Datatype_dateTimeBase) - { - typedValue = originalStringValue; - } - return xmlType.ValueConverter.ChangeType(typedValue, returnType, namespaceResolver); - } - else - { - return XmlUntypedConverter.Untyped.ChangeType(typedValue, returnType, namespaceResolver); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - - // Attribute Accessors - - // The number of attributes on the current node. - public override int AttributeCount - { - get - { - return _attributeCount; - } - } - - // Gets the value of the attribute with the specified Name. - public override string GetAttribute(string name) - { - string attValue = _coreReader.GetAttribute(name); - - if (attValue == null && _attributeCount > 0) - { //Could be default attribute - ValidatingReaderNodeData defaultNode = GetDefaultAttribute(name, false); - if (defaultNode != null) - { //Default found - attValue = defaultNode.RawValue; - } - } - return attValue; - } - - // Gets the value of the attribute with the specified LocalName and NamespaceURI. - public override string GetAttribute(string name, string namespaceURI) - { - string attValue = _coreReader.GetAttribute(name, namespaceURI); - - if (attValue == null && _attributeCount > 0) - { //Could be default attribute - namespaceURI = (namespaceURI == null) ? string.Empty : _coreReaderNameTable.Get(namespaceURI); - name = _coreReaderNameTable.Get(name); - if (name == null || namespaceURI == null) - { //Attribute not present since we did not see it - return null; - } - ValidatingReaderNodeData attNode = GetDefaultAttribute(name, namespaceURI, false); - if (attNode != null) - { - return attNode.RawValue; - } - } - return attValue; - } - - // Gets the value of the attribute with the specified index. - public override string GetAttribute(int i) - { - if (_attributeCount == 0) - { - return null; - } - if (i < _coreReaderAttributeCount) - { - return _coreReader.GetAttribute(i); - } - else - { - int defaultIndex = i - _coreReaderAttributeCount; - ValidatingReaderNodeData attNode = (ValidatingReaderNodeData)_defaultAttributes[defaultIndex]; - Debug.Assert(attNode != null); - return attNode.RawValue; - } - } - - // Moves to the attribute with the specified Name - public override bool MoveToAttribute(string name) - { - if (_coreReader.MoveToAttribute(name)) - { - _validationState = ValidatingReaderState.OnAttribute; - _attributePSVI = GetAttributePSVI(name); - goto Found; - } - else if (_attributeCount > 0) - { //Default attribute - ValidatingReaderNodeData defaultNode = GetDefaultAttribute(name, true); - if (defaultNode != null) - { - _validationState = ValidatingReaderState.OnDefaultAttribute; - _attributePSVI = defaultNode.AttInfo; - _cachedNode = defaultNode; - goto Found; - } - } - return false; - Found: - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - return true; - } - - // Moves to the attribute with the specified LocalName and NamespaceURI - public override bool MoveToAttribute(string name, string ns) - { - //Check atomized local name and ns - name = _coreReaderNameTable.Get(name); - ns = ns != null ? _coreReaderNameTable.Get(ns) : string.Empty; - if (name == null || ns == null) - { //Name or ns not found in the nameTable, then attribute is not found - return false; - } - if (_coreReader.MoveToAttribute(name, ns)) - { - _validationState = ValidatingReaderState.OnAttribute; - if (_inlineSchemaParser == null) - { - _attributePSVI = GetAttributePSVI(name, ns); - Debug.Assert(_attributePSVI != null); - } - else - { //Parsing inline schema, no PSVI for schema attributes - _attributePSVI = null; - } - goto Found; - } - else - { //Default attribute - ValidatingReaderNodeData defaultNode = GetDefaultAttribute(name, ns, true); - if (defaultNode != null) - { - _attributePSVI = defaultNode.AttInfo; - _cachedNode = defaultNode; - _validationState = ValidatingReaderState.OnDefaultAttribute; - goto Found; - } - } - return false; - Found: - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - return true; - } - - // Moves to the attribute with the specified index - public override void MoveToAttribute(int i) - { - if (i < 0 || i >= _attributeCount) - { - throw new ArgumentOutOfRangeException("i"); - } - _currentAttrIndex = i; - if (i < _coreReaderAttributeCount) - { //reader attribute - _coreReader.MoveToAttribute(i); - if (_inlineSchemaParser == null) - { - _attributePSVI = _attributePSVINodes[i]; - } - else - { - _attributePSVI = null; - } - _validationState = ValidatingReaderState.OnAttribute; - } - else - { //default attribute - int defaultIndex = i - _coreReaderAttributeCount; - _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[defaultIndex]; - _attributePSVI = _cachedNode.AttInfo; - _validationState = ValidatingReaderState.OnDefaultAttribute; - } - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - } - - // Moves to the first attribute. - public override bool MoveToFirstAttribute() - { - if (_coreReader.MoveToFirstAttribute()) - { - _currentAttrIndex = 0; - if (_inlineSchemaParser == null) - { - _attributePSVI = _attributePSVINodes[0]; - } - else - { - _attributePSVI = null; - } - _validationState = ValidatingReaderState.OnAttribute; - goto Found; - } - else if (_defaultAttributes.Count > 0) - { //check for default - _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[0]; - _attributePSVI = _cachedNode.AttInfo; - _currentAttrIndex = 0; - _validationState = ValidatingReaderState.OnDefaultAttribute; - goto Found; - } - return false; - Found: - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - return true; - } - - // Moves to the next attribute. - public override bool MoveToNextAttribute() - { - if (_currentAttrIndex + 1 < _coreReaderAttributeCount) - { - bool moveTo = _coreReader.MoveToNextAttribute(); - Debug.Assert(moveTo); - _currentAttrIndex++; - if (_inlineSchemaParser == null) - { - _attributePSVI = _attributePSVINodes[_currentAttrIndex]; - } - else - { - _attributePSVI = null; - } - _validationState = ValidatingReaderState.OnAttribute; - goto Found; - } - else if (_currentAttrIndex + 1 < _attributeCount) - { //default attribute - int defaultIndex = ++_currentAttrIndex - _coreReaderAttributeCount; - _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[defaultIndex]; - _attributePSVI = _cachedNode.AttInfo; - _validationState = ValidatingReaderState.OnDefaultAttribute; - goto Found; - } - return false; - Found: - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - return true; - } - - // Moves to the element that contains the current attribute node. - public override bool MoveToElement() - { - if (_coreReader.MoveToElement() || (int)_validationState < 0) - { //states OnDefaultAttribute or OnReadAttributeValue - _currentAttrIndex = -1; - _validationState = ValidatingReaderState.ClearAttributes; - return true; - } - return false; - } - - // Reads the next node from the stream/TextReader. - public override bool Read() - { - switch (_validationState) - { - case ValidatingReaderState.Read: - if (_coreReader.Read()) - { - ProcessReaderEvent(); - return true; - } - else - { - _validator.EndValidation(); - if (_coreReader.EOF) - { - _validationState = ValidatingReaderState.EOF; - } - return false; - } - - case ValidatingReaderState.ParseInlineSchema: - ProcessInlineSchema(); - return true; - - case ValidatingReaderState.OnAttribute: - case ValidatingReaderState.OnDefaultAttribute: - case ValidatingReaderState.ClearAttributes: - case ValidatingReaderState.OnReadAttributeValue: - ClearAttributesInfo(); - if (_inlineSchemaParser != null) - { - _validationState = ValidatingReaderState.ParseInlineSchema; - goto case ValidatingReaderState.ParseInlineSchema; - } - else - { - _validationState = ValidatingReaderState.Read; - goto case ValidatingReaderState.Read; - } - - case ValidatingReaderState.ReadAhead: //Will enter here on calling Skip() - ClearAttributesInfo(); - ProcessReaderEvent(); - _validationState = ValidatingReaderState.Read; - return true; - - case ValidatingReaderState.OnReadBinaryContent: - _validationState = _savedState; - _readBinaryHelper.Finish(); - return Read(); - - case ValidatingReaderState.Init: - _validationState = ValidatingReaderState.Read; - if (_coreReader.ReadState == ReadState.Interactive) - { //If the underlying reader is already positioned on a ndoe, process it - ProcessReaderEvent(); - return true; - } - else - { - goto case ValidatingReaderState.Read; - } - - case ValidatingReaderState.ReaderClosed: - case ValidatingReaderState.EOF: - return false; - - default: - return false; - } - } - - // Gets a value indicating whether XmlReader is positioned at the end of the stream/TextReader. - public override bool EOF - { - get - { - return _coreReader.EOF; - } - } - - // Closes the stream, changes the ReadState to Closed, and sets all the properties back to zero. - public override void Close() - { - _coreReader.Close(); - _validationState = ValidatingReaderState.ReaderClosed; - } - - // Returns the read state of the XmlReader. - public override ReadState ReadState - { - get - { - return (_validationState == ValidatingReaderState.Init) ? ReadState.Initial : _coreReader.ReadState; - } - } - - // Skips to the end tag of the current element. - public override void Skip() - { - int startDepth = Depth; - switch (NodeType) - { - case XmlNodeType.Element: - if (_coreReader.IsEmptyElement) - { - break; - } - bool callSkipToEndElem = true; - //If union and unionValue has been parsed till EndElement, then validator.ValidateEndElement has been called - //Hence should not call SkipToEndElement as the current context has already been popped in the validator - if ((_xmlSchemaInfo.IsUnionType || _xmlSchemaInfo.IsDefault) && _coreReader is XsdCachingReader) - { - callSkipToEndElem = false; - } - _coreReader.Skip(); - _validationState = ValidatingReaderState.ReadAhead; - if (callSkipToEndElem) - { - _validator.SkipToEndElement(_xmlSchemaInfo); - } - break; - - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - } - //For all other NodeTypes Skip() same as Read() - Read(); - return; - } - - // Gets the XmlNameTable associated with this implementation. - public override XmlNameTable NameTable - { - get - { - return _coreReaderNameTable; - } - } - - // Resolves a namespace prefix in the current element's scope. - public override string LookupNamespace(string prefix) - { - return _thisNSResolver.LookupNamespace(prefix); - } - - // Resolves the entity reference for nodes of NodeType EntityReference. - public override void ResolveEntity() - { - throw new InvalidOperationException(); - } - - // Parses the attribute value into one or more Text and/or EntityReference node types. - public override bool ReadAttributeValue() - { - if (_validationState == ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper.Finish(); - _validationState = _savedState; - } - if (NodeType == XmlNodeType.Attribute) - { - if (_validationState == ValidatingReaderState.OnDefaultAttribute) - { - _cachedNode = CreateDummyTextNode(_cachedNode.RawValue, _cachedNode.Depth + 1); - _validationState = ValidatingReaderState.OnReadAttributeValue; - return true; - } - return _coreReader.ReadAttributeValue(); - } - return false; - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - // - // IXmlSchemaInfo interface - // - bool IXmlSchemaInfo.IsDefault - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - if (!_coreReader.IsEmptyElement) - { - GetIsDefault(); - } - return _xmlSchemaInfo.IsDefault; - - case XmlNodeType.EndElement: - return _xmlSchemaInfo.IsDefault; - - case XmlNodeType.Attribute: - if (_attributePSVI != null) - { - return AttributeSchemaInfo.IsDefault; - } - break; - - default: - break; - } - return false; - } - } - - bool IXmlSchemaInfo.IsNil - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.EndElement: - return _xmlSchemaInfo.IsNil; - - default: - break; - } - return false; - } - } - - XmlSchemaValidity IXmlSchemaInfo.Validity - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - if (_coreReader.IsEmptyElement) - { - return _xmlSchemaInfo.Validity; - } - if (_xmlSchemaInfo.Validity == XmlSchemaValidity.Valid) - { //It might be valid for unions since we read ahead, but report notknown for consistency - return XmlSchemaValidity.NotKnown; - } - return _xmlSchemaInfo.Validity; - - case XmlNodeType.EndElement: - return _xmlSchemaInfo.Validity; - - case XmlNodeType.Attribute: - if (_attributePSVI != null) - { - return AttributeSchemaInfo.Validity; - } - break; - } - return XmlSchemaValidity.NotKnown; - } - } - - XmlSchemaSimpleType IXmlSchemaInfo.MemberType - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - if (!_coreReader.IsEmptyElement) - { - GetMemberType(); - } - return _xmlSchemaInfo.MemberType; - - case XmlNodeType.EndElement: - return _xmlSchemaInfo.MemberType; - - case XmlNodeType.Attribute: - if (_attributePSVI != null) - { - return AttributeSchemaInfo.MemberType; - } - return null; - - default: - return null; //Text, PI, Comment etc - } - } - } - - XmlSchemaType IXmlSchemaInfo.SchemaType - { - get - { - switch (NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.EndElement: - return _xmlSchemaInfo.SchemaType; - - case XmlNodeType.Attribute: - if (_attributePSVI != null) - { - return AttributeSchemaInfo.SchemaType; - } - return null; - - default: - return null; //Text, PI, Comment etc - } - } - } - XmlSchemaElement IXmlSchemaInfo.SchemaElement - { - get - { - if (NodeType == XmlNodeType.Element || NodeType == XmlNodeType.EndElement) - { - return _xmlSchemaInfo.SchemaElement; - } - return null; - } - } - - XmlSchemaAttribute IXmlSchemaInfo.SchemaAttribute - { - get - { - if (NodeType == XmlNodeType.Attribute) - { - if (_attributePSVI != null) - { - return AttributeSchemaInfo.SchemaAttribute; - } - } - return null; - } - } - - // - // IXmlLineInfo members - // - - public bool HasLineInfo() - { - return true; - } - - public int LineNumber - { - get - { - if (_lineInfo != null) - { - return _lineInfo.LineNumber; - } - return 0; - } - } - - public int LinePosition - { - get - { - if (_lineInfo != null) - { - return _lineInfo.LinePosition; - } - return 0; - } - } - - // - // IXmlNamespaceResolver members - // - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - if (_coreReaderNSResolver != null) - { - return _coreReaderNSResolver.GetNamespacesInScope(scope); - } - else - { - return _nsManager.GetNamespacesInScope(scope); - } - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - if (_coreReaderNSResolver != null) - { - return _coreReaderNSResolver.LookupNamespace(prefix); - } - else - { - return _nsManager.LookupNamespace(prefix); - } - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - if (_coreReaderNSResolver != null) - { - return _coreReaderNSResolver.LookupPrefix(namespaceName); - } - else - { - return _nsManager.LookupPrefix(namespaceName); - } - } - - //Internal / Private methods - - private object GetStringValue() - { - return _coreReader.Value; - } - - private XmlSchemaType ElementXmlType - { - get - { - return _xmlSchemaInfo.XmlType; - } - } - - private XmlSchemaType AttributeXmlType - { - get - { - if (_attributePSVI != null) - { - return AttributeSchemaInfo.XmlType; - } - return null; - } - } - - private XmlSchemaInfo AttributeSchemaInfo - { - get - { - Debug.Assert(_attributePSVI != null); - return _attributePSVI.attributeSchemaInfo; - } - } - - private void ProcessReaderEvent() - { - if (_replayCache) - { //if in replay mode, do nothing since nodes have been validated already - //If NodeType == XmlNodeType.EndElement && if manageNamespaces, may need to pop namespace scope, since scope is not popped in ReadAheadForMemberType - - return; - } - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - - ProcessElementEvent(); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Text: // text inside a node - case XmlNodeType.CDATA: // - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.EndElement: - - ProcessEndElementEvent(); - break; - - case XmlNodeType.EntityReference: - throw new InvalidOperationException(); - - case XmlNodeType.DocumentType: -#if TEMP_HACK_FOR_SCHEMA_INFO - validator.SetDtdSchemaInfo((SchemaInfo)coreReader.DtdInfo); -#else - _validator.SetDtdSchemaInfo(_coreReader.DtdInfo); -#endif - break; - - default: - break; - } - } - - // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. - // Since the resource names (namespace location) are not provided directly by the user (they are read from the source - // document) and the function does not expose any resources it is fine to disable the SxS warning. - - - private void ProcessElementEvent() - { - if (_processInlineSchema && IsXSDRoot(_coreReader.LocalName, _coreReader.NamespaceURI) && _coreReader.Depth > 0) - { - _xmlSchemaInfo.Clear(); - _attributeCount = _coreReaderAttributeCount = _coreReader.AttributeCount; - if (!_coreReader.IsEmptyElement) - { //If its not empty schema, then parse else ignore - _inlineSchemaParser = new Parser(SchemaType.XSD, _coreReaderNameTable, _validator.SchemaSet.GetSchemaNames(_coreReaderNameTable), _validationEvent); - _inlineSchemaParser.StartParsing(_coreReader, null); - _inlineSchemaParser.ParseReaderNode(); - _validationState = ValidatingReaderState.ParseInlineSchema; - } - else - { - _validationState = ValidatingReaderState.ClearAttributes; - } - } - else - { //Validate element - //Clear previous data - _atomicValue = null; - _originalAtomicValueString = null; - _xmlSchemaInfo.Clear(); - - if (_manageNamespaces) - { - _nsManager.PushScope(); - } - //Find Xsi attributes that need to be processed before validating the element - string xsiSchemaLocation = null; - string xsiNoNamespaceSL = null; - string xsiNil = null; - string xsiType = null; - if (_coreReader.MoveToFirstAttribute()) - { - do - { - string objectNs = _coreReader.NamespaceURI; - string objectName = _coreReader.LocalName; - if (Ref.Equal(objectNs, _nsXsi)) - { - if (Ref.Equal(objectName, _xsiSchemaLocation)) - { - xsiSchemaLocation = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiNoNamespaceSchemaLocation)) - { - xsiNoNamespaceSL = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiType)) - { - xsiType = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiNil)) - { - xsiNil = _coreReader.Value; - } - } - if (_manageNamespaces && Ref.Equal(_coreReader.NamespaceURI, _nsXmlNs)) - { - _nsManager.AddNamespace(_coreReader.Prefix.Length == 0 ? string.Empty : _coreReader.LocalName, _coreReader.Value); - } - } while (_coreReader.MoveToNextAttribute()); - _coreReader.MoveToElement(); - } - _validator.ValidateElement(_coreReader.LocalName, _coreReader.NamespaceURI, _xmlSchemaInfo, xsiType, xsiNil, xsiSchemaLocation, xsiNoNamespaceSL); - ValidateAttributes(); - _validator.ValidateEndOfAttributes(_xmlSchemaInfo); - if (_coreReader.IsEmptyElement) - { - ProcessEndElementEvent(); - } - _validationState = ValidatingReaderState.ClearAttributes; - } - } - - private void ProcessEndElementEvent() - { - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_xmlSchemaInfo.IsDefault) - { //The atomicValue returned is a default value - Debug.Assert(_atomicValue != null); - int depth = _coreReader.Depth; - _coreReader = GetCachingReader(); - _cachingReader.RecordTextNode(_xmlSchemaInfo.XmlType.ValueConverter.ToString(_atomicValue), _originalAtomicValueString, depth + 1, 0, 0); - _cachingReader.RecordEndElementNode(); - _cachingReader.SetToReplayMode(); - _replayCache = true; - } - else if (_manageNamespaces) - { - _nsManager.PopScope(); - } - } - - private void ValidateAttributes() - { - _attributeCount = _coreReaderAttributeCount = _coreReader.AttributeCount; - AttributePSVIInfo attributePSVI; - int attIndex = 0; - bool attributeInvalid = false; - if (_coreReader.MoveToFirstAttribute()) - { - do - { - string localName = _coreReader.LocalName; - string ns = _coreReader.NamespaceURI; - - attributePSVI = AddAttributePSVI(attIndex); - attributePSVI.localName = localName; - attributePSVI.namespaceUri = ns; - - if ((object)ns == (object)_nsXmlNs) - { - attIndex++; - continue; - } - attributePSVI.typedAttributeValue = _validator.ValidateAttribute(localName, ns, _valueGetter, attributePSVI.attributeSchemaInfo); - if (!attributeInvalid) - { - attributeInvalid = attributePSVI.attributeSchemaInfo.Validity == XmlSchemaValidity.Invalid; - } - attIndex++; - } while (_coreReader.MoveToNextAttribute()); - } - _coreReader.MoveToElement(); - if (attributeInvalid) - { //If any of the attributes are invalid, Need to report element's validity as invalid - _xmlSchemaInfo.Validity = XmlSchemaValidity.Invalid; - } - _validator.GetUnspecifiedDefaultAttributes(_defaultAttributes, true); - _attributeCount += _defaultAttributes.Count; - } - - private void ClearAttributesInfo() - { - _attributeCount = 0; - _coreReaderAttributeCount = 0; - _currentAttrIndex = -1; - _defaultAttributes.Clear(); - _attributePSVI = null; - } - - private AttributePSVIInfo GetAttributePSVI(string name) - { - if (_inlineSchemaParser != null) - { //Parsing inline schema, no PSVI for schema attributes - return null; - } - string attrLocalName; - string attrPrefix; - string ns; - ValidateNames.SplitQName(name, out attrPrefix, out attrLocalName); - attrPrefix = _coreReaderNameTable.Add(attrPrefix); - attrLocalName = _coreReaderNameTable.Add(attrLocalName); - - if (attrPrefix.Length == 0) - { //empty prefix, not qualified - ns = string.Empty; - } - else - { - ns = _thisNSResolver.LookupNamespace(attrPrefix); - } - return GetAttributePSVI(attrLocalName, ns); - } - - private AttributePSVIInfo GetAttributePSVI(string localName, string ns) - { - Debug.Assert(_coreReaderNameTable.Get(localName) != null); - Debug.Assert(_coreReaderNameTable.Get(ns) != null); - AttributePSVIInfo attInfo = null; - - for (int i = 0; i < _coreReaderAttributeCount; i++) - { - attInfo = _attributePSVINodes[i]; - if (attInfo != null) - { //Will be null for invalid attributes - if (Ref.Equal(localName, attInfo.localName) && Ref.Equal(ns, attInfo.namespaceUri)) - { - _currentAttrIndex = i; - return attInfo; - } - } - } - return null; - } - - private ValidatingReaderNodeData GetDefaultAttribute(string name, bool updatePosition) - { - string attrLocalName; - string attrPrefix; - ValidateNames.SplitQName(name, out attrPrefix, out attrLocalName); - - //Atomize - attrPrefix = _coreReaderNameTable.Add(attrPrefix); - attrLocalName = _coreReaderNameTable.Add(attrLocalName); - string ns; - if (attrPrefix.Length == 0) - { - ns = string.Empty; - } - else - { - ns = _thisNSResolver.LookupNamespace(attrPrefix); - } - return GetDefaultAttribute(attrLocalName, ns, updatePosition); - } - - private ValidatingReaderNodeData GetDefaultAttribute(string attrLocalName, string ns, bool updatePosition) - { - Debug.Assert(_coreReaderNameTable.Get(attrLocalName) != null); - Debug.Assert(_coreReaderNameTable.Get(ns) != null); - ValidatingReaderNodeData defaultNode = null; - - for (int i = 0; i < _defaultAttributes.Count; i++) - { - defaultNode = (ValidatingReaderNodeData)_defaultAttributes[i]; - if (Ref.Equal(defaultNode.LocalName, attrLocalName) && Ref.Equal(defaultNode.Namespace, ns)) - { - if (updatePosition) - { - _currentAttrIndex = _coreReader.AttributeCount + i; - } - return defaultNode; - } - } - return null; - } - - private AttributePSVIInfo AddAttributePSVI(int attIndex) - { - Debug.Assert(attIndex <= _attributePSVINodes.Length); - AttributePSVIInfo attInfo = _attributePSVINodes[attIndex]; - if (attInfo != null) - { - attInfo.Reset(); - return attInfo; - } - if (attIndex >= _attributePSVINodes.Length - 1) - { //reached capacity of PSVIInfo array, Need to increase capacity to twice the initial - AttributePSVIInfo[] newPSVINodes = new AttributePSVIInfo[_attributePSVINodes.Length * 2]; - Array.Copy(_attributePSVINodes, 0, newPSVINodes, 0, _attributePSVINodes.Length); - _attributePSVINodes = newPSVINodes; - } - attInfo = _attributePSVINodes[attIndex]; - if (attInfo == null) - { - attInfo = new AttributePSVIInfo(); - _attributePSVINodes[attIndex] = attInfo; - } - return attInfo; - } - - private bool IsXSDRoot(string localName, string ns) - { - return Ref.Equal(ns, _nsXs) && Ref.Equal(localName, _xsdSchema); - } - - private void ProcessInlineSchema() - { - Debug.Assert(_inlineSchemaParser != null); - if (_coreReader.Read()) - { - if (_coreReader.NodeType == XmlNodeType.Element) - { - _attributeCount = _coreReaderAttributeCount = _coreReader.AttributeCount; - } - else - { //Clear attributes info if nodeType is not element - ClearAttributesInfo(); - } - if (!_inlineSchemaParser.ParseReaderNode()) - { - _inlineSchemaParser.FinishParsing(); - XmlSchema schema = _inlineSchemaParser.XmlSchema; - _validator.AddSchema(schema); - _inlineSchemaParser = null; - _validationState = ValidatingReaderState.Read; - } - } - } - - private object InternalReadContentAsObject() - { - return InternalReadContentAsObject(false); - } - - private object InternalReadContentAsObject(bool unwrapTypedValue) - { - string str; - return InternalReadContentAsObject(unwrapTypedValue, out str); - } - - private object InternalReadContentAsObject(bool unwrapTypedValue, out string originalStringValue) - { - XmlNodeType nodeType = this.NodeType; - if (nodeType == XmlNodeType.Attribute) - { - originalStringValue = this.Value; - if (_attributePSVI != null && _attributePSVI.typedAttributeValue != null) - { - if (_validationState == ValidatingReaderState.OnDefaultAttribute) - { - XmlSchemaAttribute schemaAttr = _attributePSVI.attributeSchemaInfo.SchemaAttribute; - originalStringValue = (schemaAttr.DefaultValue != null) ? schemaAttr.DefaultValue : schemaAttr.FixedValue; - } - - return ReturnBoxedValue(_attributePSVI.typedAttributeValue, AttributeSchemaInfo.XmlType, unwrapTypedValue); - } - else - { //return string value - return this.Value; - } - } - else if (nodeType == XmlNodeType.EndElement) - { - if (_atomicValue != null) - { - originalStringValue = _originalAtomicValueString; - - return _atomicValue; - } - else - { - originalStringValue = string.Empty; - - return string.Empty; - } - } - else - { //Positioned on text, CDATA, PI, Comment etc - if (_validator.CurrentContentType == XmlSchemaContentType.TextOnly) - { //if current element is of simple type - object value = ReturnBoxedValue(ReadTillEndElement(), _xmlSchemaInfo.XmlType, unwrapTypedValue); - originalStringValue = _originalAtomicValueString; - - return value; - } - else - { - XsdCachingReader cachingReader = _coreReader as XsdCachingReader; - if (cachingReader != null) - { - originalStringValue = cachingReader.ReadOriginalContentAsString(); - } - else - { - originalStringValue = InternalReadContentAsString(); - } - - return originalStringValue; - } - } - } - - private object InternalReadElementContentAsObject(out XmlSchemaType xmlType) - { - return InternalReadElementContentAsObject(out xmlType, false); - } - - private object InternalReadElementContentAsObject(out XmlSchemaType xmlType, bool unwrapTypedValue) - { - string tmpString; - return InternalReadElementContentAsObject(out xmlType, unwrapTypedValue, out tmpString); - } - - private object InternalReadElementContentAsObject(out XmlSchemaType xmlType, bool unwrapTypedValue, out string originalString) - { - Debug.Assert(this.NodeType == XmlNodeType.Element); - object typedValue = null; - xmlType = null; - //If its an empty element, can have default/fixed value - if (this.IsEmptyElement) - { - if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue); - } - else - { - typedValue = _atomicValue; - } - originalString = _originalAtomicValueString; - xmlType = ElementXmlType; //Set this for default values - this.Read(); - - return typedValue; - } - // move to content and read typed value - this.Read(); - - if (this.NodeType == XmlNodeType.EndElement) - { //If IsDefault is true, the next node will be EndElement - if (_xmlSchemaInfo.IsDefault) - { - if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue); - } - else - { //anyType has default value - typedValue = _atomicValue; - } - originalString = _originalAtomicValueString; - } - else - { //Empty content - typedValue = string.Empty; - originalString = string.Empty; - } - } - else if (this.NodeType == XmlNodeType.Element) - { //the first child is again element node - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - else - { - typedValue = InternalReadContentAsObject(unwrapTypedValue, out originalString); - - // ReadElementContentAsXXX cannot be called on mixed content, if positioned on node other than EndElement, Error - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - } - xmlType = ElementXmlType; //Set this as we are moving ahead to the next node - - // move to next node - this.Read(); - - return typedValue; - } - - private object ReadTillEndElement() - { - if (_atomicValue == null) - { - while (_coreReader.Read()) - { - if (_replayCache) - { //If replaying nodes in the cache, they have already been validated - continue; - } - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - ProcessReaderEvent(); - goto breakWhile; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - case XmlNodeType.EndElement: - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_manageNamespaces) - { - _nsManager.PopScope(); - } - goto breakWhile; - } - continue; - breakWhile: - break; - } - } - else - { //atomicValue != null, meaning already read ahead - Switch reader - if (_atomicValue == this) - { //switch back invalid marker; dont need it since coreReader moved to endElement - _atomicValue = null; - } - SwitchReader(); - } - return _atomicValue; - } - - private void SwitchReader() - { - XsdCachingReader cachingReader = _coreReader as XsdCachingReader; - if (cachingReader != null) - { //Switch back without going over the cached contents again. - _coreReader = cachingReader.GetCoreReader(); - } - Debug.Assert(_coreReader.NodeType == XmlNodeType.EndElement); - _replayCache = false; - } - - private void ReadAheadForMemberType() - { - while (_coreReader.Read()) - { - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - Debug.Assert(false); //Should not happen as the caching reader does not cache elements in simple content - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - case XmlNodeType.EndElement: - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); //?? pop namespaceManager scope - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_atomicValue == null) - { //Invalid marker - _atomicValue = this; - } - else if (_xmlSchemaInfo.IsDefault) - { //The atomicValue returned is a default value - _cachingReader.SwitchTextNodeAndEndElement(_xmlSchemaInfo.XmlType.ValueConverter.ToString(_atomicValue), _originalAtomicValueString); - } - goto breakWhile; - } - continue; - breakWhile: - break; - } - } - - private void GetIsDefault() - { - XsdCachingReader cachedReader = _coreReader as XsdCachingReader; - if (cachedReader == null && _xmlSchemaInfo.HasDefaultValue) - { //Get Isdefault - _coreReader = GetCachingReader(); - if (_xmlSchemaInfo.IsUnionType && !_xmlSchemaInfo.IsNil) - { //If it also union, get the memberType as well - ReadAheadForMemberType(); - } - else - { - if (_coreReader.Read()) - { - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - Debug.Assert(false); //Should not happen as the caching reader does not cache elements in simple content - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - case XmlNodeType.EndElement: - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); //?? pop namespaceManager scope - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_xmlSchemaInfo.IsDefault) - { //The atomicValue returned is a default value - _cachingReader.SwitchTextNodeAndEndElement(_xmlSchemaInfo.XmlType.ValueConverter.ToString(_atomicValue), _originalAtomicValueString); - } - break; - - default: - break; - } - } - } - _cachingReader.SetToReplayMode(); - _replayCache = true; - } - } - - private void GetMemberType() - { - if (_xmlSchemaInfo.MemberType != null || _atomicValue == this) - { - return; - } - XsdCachingReader cachedReader = _coreReader as XsdCachingReader; - if (cachedReader == null && _xmlSchemaInfo.IsUnionType && !_xmlSchemaInfo.IsNil) - { - _coreReader = GetCachingReader(); - ReadAheadForMemberType(); - _cachingReader.SetToReplayMode(); - _replayCache = true; - } - } - - private object ReturnBoxedValue(object typedValue, XmlSchemaType xmlType, bool unWrap) - { - if (typedValue != null) - { - if (unWrap) - { //convert XmlAtomicValue[] to object[] for list of unions; The other cases return typed value of the valueType anyway - Debug.Assert(xmlType != null && xmlType.Datatype != null); - if (xmlType.Datatype.Variety == XmlSchemaDatatypeVariety.List) - { - Datatype_List listType = xmlType.Datatype as Datatype_List; - if (listType.ItemType.Variety == XmlSchemaDatatypeVariety.Union) - { - typedValue = xmlType.ValueConverter.ChangeType(typedValue, xmlType.Datatype.ValueType, _thisNSResolver); - } - } - } - return typedValue; - } - else - { //return the original string value of the element or attribute - Debug.Assert(NodeType != XmlNodeType.Attribute); - typedValue = _validator.GetConcatenatedValue(); - } - return typedValue; - } - - private XsdCachingReader GetCachingReader() - { - if (_cachingReader == null) - { - _cachingReader = new XsdCachingReader(_coreReader, _lineInfo, new CachingEventHandler(CachingCallBack)); - } - else - { - _cachingReader.Reset(_coreReader); - } - _lineInfo = _cachingReader as IXmlLineInfo; - return _cachingReader; - } - - internal ValidatingReaderNodeData CreateDummyTextNode(string attributeValue, int depth) - { - if (_textNode == null) - { - _textNode = new ValidatingReaderNodeData(XmlNodeType.Text); - } - _textNode.Depth = depth; - _textNode.RawValue = attributeValue; - return _textNode; - } - - internal void CachingCallBack(XsdCachingReader cachingReader) - { - _coreReader = cachingReader.GetCoreReader(); //re-switch the core-reader after caching reader is done - _lineInfo = cachingReader.GetLineInfo(); - _replayCache = false; - } - - private string GetOriginalAtomicValueStringOfElement() - { - if (_xmlSchemaInfo.IsDefault) - { - XmlSchemaElement schemaElem = _xmlSchemaInfo.SchemaElement; - if (schemaElem != null) - { - return (schemaElem.DefaultValue != null) ? schemaElem.DefaultValue : schemaElem.FixedValue; - } - } - else - { - return _validator.GetConcatenatedValue(); - } - return string.Empty; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReaderAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReaderAsync.cs deleted file mode 100644 index d44a0ec4757..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/XsdValidatingReaderAsync.cs +++ /dev/null @@ -1,876 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; -using System.Globalization; -using System.Collections; -// using System.Security.Policy; -using System.Collections.Generic; -using System.Runtime.Versioning; - -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class XsdValidatingReader : XmlReader, IXmlSchemaInfo, IXmlLineInfo, IXmlNamespaceResolver - { - // Gets the text value of the current node. - public override Task GetValueAsync() - { - if ((int)_validationState < 0) - { - return Task.FromResult(_cachedNode.RawValue); - } - return _coreReader.GetValueAsync(); - } - - public override Task ReadContentAsObjectAsync() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsObject"); - } - - return InternalReadContentAsObjectAsync(true); - } - - public override async Task ReadContentAsStringAsync() - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAsString"); - } - object typedValue = await InternalReadContentAsObjectAsync().ConfigureAwait(false); - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToString(typedValue); - } - else - { - return typedValue as string; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - } - - public override async Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (!CanReadContentAs(this.NodeType)) - { - throw CreateReadContentAsException("ReadContentAs"); - } - string originalStringValue; - - var tuple_0 = await InternalReadContentAsObjectTupleAsync(false).ConfigureAwait(false); - originalStringValue = tuple_0.Item1; - - object typedValue = tuple_0.Item2; - - XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; //TODO special case for xsd:duration and xsd:dateTime - try - { - if (xmlType != null) - { - // special-case convertions to DateTimeOffset; typedValue is by default a DateTime - // which cannot preserve time zone, so we need to convert from the original string - if (returnType == typeof(DateTimeOffset) && xmlType.Datatype is Datatype_dateTimeBase) - { - typedValue = originalStringValue; - } - return xmlType.ValueConverter.ChangeType(typedValue, returnType); - } - else - { - return XmlUntypedConverter.Untyped.ChangeType(typedValue, returnType, namespaceResolver); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - - public override async Task ReadElementContentAsObjectAsync() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsObject"); - } - - var tuple_1 = await InternalReadElementContentAsObjectAsync(true).ConfigureAwait(false); - - return tuple_1.Item2; - } - - public override async Task ReadElementContentAsStringAsync() - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAsString"); - } - XmlSchemaType xmlType; - - var tuple_9 = await InternalReadElementContentAsObjectAsync().ConfigureAwait(false); - xmlType = tuple_9.Item1; - - object typedValue = tuple_9.Item2; - - try - { - if (xmlType != null) - { - return xmlType.ValueConverter.ToString(typedValue); - } - else - { - return typedValue as string; - } - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, "String", e, this as IXmlLineInfo); - } - } - - public override async Task ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - if (this.NodeType != XmlNodeType.Element) - { - throw CreateReadElementContentAsException("ReadElementContentAs"); - } - XmlSchemaType xmlType; - string originalStringValue; - - var tuple_10 = await InternalReadElementContentAsObjectTupleAsync(false).ConfigureAwait(false); - xmlType = tuple_10.Item1; - originalStringValue = tuple_10.Item2; - - object typedValue = tuple_10.Item3; - - try - { - if (xmlType != null) - { - // special-case convertions to DateTimeOffset; typedValue is by default a DateTime - // which cannot preserve time zone, so we need to convert from the original string - if (returnType == typeof(DateTimeOffset) && xmlType.Datatype is Datatype_dateTimeBase) - { - typedValue = originalStringValue; - } - return xmlType.ValueConverter.ChangeType(typedValue, returnType, namespaceResolver); - } - else - { - return XmlUntypedConverter.Untyped.ChangeType(typedValue, returnType, namespaceResolver); - } - } - catch (FormatException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (InvalidCastException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - catch (OverflowException e) - { - throw new XmlException(ResXml.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo); - } - } - - private Task ReadAsync_Read(Task task) - { - if (task.IsSuccess()) - { - if (task.Result) - { - return ProcessReaderEventAsync().ReturnTaskBoolWhenFinish(true); - } - else - { - _validator.EndValidation(); - if (_coreReader.EOF) - { - _validationState = ValidatingReaderState.EOF; - } - return AsyncHelper.DoneTaskFalse; - } - } - else - { - return _ReadAsync_Read(task); - } - } - - private async Task _ReadAsync_Read(Task task) - { - if (await task.ConfigureAwait(false)) - { - await ProcessReaderEventAsync().ConfigureAwait(false); - return true; - } - else - { - _validator.EndValidation(); - if (_coreReader.EOF) - { - _validationState = ValidatingReaderState.EOF; - } - return false; - } - } - - private Task ReadAsync_ReadAhead(Task task) - { - if (task.IsSuccess()) - { - _validationState = ValidatingReaderState.Read; - return AsyncHelper.DoneTaskTrue; ; - } - else - { - return _ReadAsync_ReadAhead(task); - } - } - - private async Task _ReadAsync_ReadAhead(Task task) - { - await task.ConfigureAwait(false); - _validationState = ValidatingReaderState.Read; - return true; - } - - // Reads the next node from the stream/TextReader. - public override Task ReadAsync() - { - switch (_validationState) - { - case ValidatingReaderState.Read: - Task readTask = _coreReader.ReadAsync(); - return ReadAsync_Read(readTask); - - case ValidatingReaderState.ParseInlineSchema: - return ProcessInlineSchemaAsync().ReturnTaskBoolWhenFinish(true); - - case ValidatingReaderState.OnAttribute: - case ValidatingReaderState.OnDefaultAttribute: - case ValidatingReaderState.ClearAttributes: - case ValidatingReaderState.OnReadAttributeValue: - ClearAttributesInfo(); - if (_inlineSchemaParser != null) - { - _validationState = ValidatingReaderState.ParseInlineSchema; - goto case ValidatingReaderState.ParseInlineSchema; - } - else - { - _validationState = ValidatingReaderState.Read; - goto case ValidatingReaderState.Read; - } - - case ValidatingReaderState.ReadAhead: //Will enter here on calling Skip() - ClearAttributesInfo(); - Task task = ProcessReaderEventAsync(); - return ReadAsync_ReadAhead(task); - - case ValidatingReaderState.OnReadBinaryContent: - _validationState = _savedState; - return _readBinaryHelper.FinishAsync().CallBoolTaskFuncWhenFinish(ReadAsync); - - case ValidatingReaderState.Init: - _validationState = ValidatingReaderState.Read; - if (_coreReader.ReadState == ReadState.Interactive) - { //If the underlying reader is already positioned on a ndoe, process it - return ProcessReaderEventAsync().ReturnTaskBoolWhenFinish(true); - } - else - { - goto case ValidatingReaderState.Read; - } - - case ValidatingReaderState.ReaderClosed: - case ValidatingReaderState.EOF: - return AsyncHelper.DoneTaskFalse; - - default: - return AsyncHelper.DoneTaskFalse; - } - } - - // Skips to the end tag of the current element. - public override async Task SkipAsync() - { - int startDepth = Depth; - switch (NodeType) - { - case XmlNodeType.Element: - if (_coreReader.IsEmptyElement) - { - break; - } - bool callSkipToEndElem = true; - //If union and unionValue has been parsed till EndElement, then validator.ValidateEndElement has been called - //Hence should not call SkipToEndElement as the current context has already been popped in the validator - if ((_xmlSchemaInfo.IsUnionType || _xmlSchemaInfo.IsDefault) && _coreReader is XsdCachingReader) - { - callSkipToEndElem = false; - } - await _coreReader.SkipAsync().ConfigureAwait(false); - _validationState = ValidatingReaderState.ReadAhead; - if (callSkipToEndElem) - { - _validator.SkipToEndElement(_xmlSchemaInfo); - } - break; - - case XmlNodeType.Attribute: - MoveToElement(); - goto case XmlNodeType.Element; - } - //For all other NodeTypes Skip() same as Read() - await ReadAsync().ConfigureAwait(false); - return; - } - - public override async Task ReadContentAsBase64Async(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = await _readBinaryHelper.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override async Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = await _readBinaryHelper.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override async Task ReadElementContentAsBase64Async(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = await _readBinaryHelper.ReadElementContentAsBase64Async(buffer, index, count).ConfigureAwait(false); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - public override async Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_validationState != ValidatingReaderState.OnReadBinaryContent) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _validationState; - } - - // restore original state in order to have a normal Read() behavior when called from readBinaryHelper - _validationState = _savedState; - - // call to the helper - int readCount = await _readBinaryHelper.ReadElementContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false); - - // set OnReadBinaryContent state again and return - _savedState = _validationState; - _validationState = ValidatingReaderState.OnReadBinaryContent; - return readCount; - } - - private Task ProcessReaderEventAsync() - { - if (_replayCache) - { //if in replay mode, do nothing since nodes have been validated already - //If NodeType == XmlNodeType.EndElement && if manageNamespaces, may need to pop namespace scope, since scope is not popped in ReadAheadForMemberType - - return AsyncHelper.DoneTask; - } - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - - return ProcessElementEventAsync(); - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Text: // text inside a node - case XmlNodeType.CDATA: // - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.EndElement: - - return ProcessEndElementEventAsync(); - - case XmlNodeType.EntityReference: - throw new InvalidOperationException(); - - case XmlNodeType.DocumentType: -#if TEMP_HACK_FOR_SCHEMA_INFO - validator.SetDtdSchemaInfo((SchemaInfo)coreReader.DtdInfo); -#else - _validator.SetDtdSchemaInfo(_coreReader.DtdInfo); -#endif - break; - - default: - break; - } - - return AsyncHelper.DoneTask; - } - - // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. - // Since the resource names (namespace location) are not provided directly by the user (they are read from the source - // document) and the function does not expose any resources it is fine to disable the SxS warning. - - - private async Task ProcessElementEventAsync() - { - if (_processInlineSchema && IsXSDRoot(_coreReader.LocalName, _coreReader.NamespaceURI) && _coreReader.Depth > 0) - { - _xmlSchemaInfo.Clear(); - _attributeCount = _coreReaderAttributeCount = _coreReader.AttributeCount; - if (!_coreReader.IsEmptyElement) - { //If its not empty schema, then parse else ignore - _inlineSchemaParser = new Parser(SchemaType.XSD, _coreReaderNameTable, _validator.SchemaSet.GetSchemaNames(_coreReaderNameTable), _validationEvent); - await _inlineSchemaParser.StartParsingAsync(_coreReader, null).ConfigureAwait(false); - _inlineSchemaParser.ParseReaderNode(); - _validationState = ValidatingReaderState.ParseInlineSchema; - } - else - { - _validationState = ValidatingReaderState.ClearAttributes; - } - } - else - { //Validate element - //Clear previous data - _atomicValue = null; - _originalAtomicValueString = null; - _xmlSchemaInfo.Clear(); - - if (_manageNamespaces) - { - _nsManager.PushScope(); - } - //Find Xsi attributes that need to be processed before validating the element - string xsiSchemaLocation = null; - string xsiNoNamespaceSL = null; - string xsiNil = null; - string xsiType = null; - if (_coreReader.MoveToFirstAttribute()) - { - do - { - string objectNs = _coreReader.NamespaceURI; - string objectName = _coreReader.LocalName; - if (Ref.Equal(objectNs, _nsXsi)) - { - if (Ref.Equal(objectName, _xsiSchemaLocation)) - { - xsiSchemaLocation = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiNoNamespaceSchemaLocation)) - { - xsiNoNamespaceSL = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiType)) - { - xsiType = _coreReader.Value; - } - else if (Ref.Equal(objectName, _xsiNil)) - { - xsiNil = _coreReader.Value; - } - } - if (_manageNamespaces && Ref.Equal(_coreReader.NamespaceURI, _nsXmlNs)) - { - _nsManager.AddNamespace(_coreReader.Prefix.Length == 0 ? string.Empty : _coreReader.LocalName, _coreReader.Value); - } - } while (_coreReader.MoveToNextAttribute()); - _coreReader.MoveToElement(); - } - _validator.ValidateElement(_coreReader.LocalName, _coreReader.NamespaceURI, _xmlSchemaInfo, xsiType, xsiNil, xsiSchemaLocation, xsiNoNamespaceSL); - ValidateAttributes(); - _validator.ValidateEndOfAttributes(_xmlSchemaInfo); - if (_coreReader.IsEmptyElement) - { - await ProcessEndElementEventAsync().ConfigureAwait(false); - } - _validationState = ValidatingReaderState.ClearAttributes; - } - } - - private async Task ProcessEndElementEventAsync() - { - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_xmlSchemaInfo.IsDefault) - { //The atomicValue returned is a default value - Debug.Assert(_atomicValue != null); - int depth = _coreReader.Depth; - _coreReader = GetCachingReader(); - _cachingReader.RecordTextNode(_xmlSchemaInfo.XmlType.ValueConverter.ToString(_atomicValue), _originalAtomicValueString, depth + 1, 0, 0); - _cachingReader.RecordEndElementNode(); - await _cachingReader.SetToReplayModeAsync().ConfigureAwait(false); - _replayCache = true; - } - else if (_manageNamespaces) - { - _nsManager.PopScope(); - } - } - - private async Task ProcessInlineSchemaAsync() - { - Debug.Assert(_inlineSchemaParser != null); - if (await _coreReader.ReadAsync().ConfigureAwait(false)) - { - if (_coreReader.NodeType == XmlNodeType.Element) - { - _attributeCount = _coreReaderAttributeCount = _coreReader.AttributeCount; - } - else - { //Clear attributes info if nodeType is not element - ClearAttributesInfo(); - } - if (!_inlineSchemaParser.ParseReaderNode()) - { - _inlineSchemaParser.FinishParsing(); - XmlSchema schema = _inlineSchemaParser.XmlSchema; - _validator.AddSchema(schema); - _inlineSchemaParser = null; - _validationState = ValidatingReaderState.Read; - } - } - } - - private Task InternalReadContentAsObjectAsync() - { - return InternalReadContentAsObjectAsync(false); - } - - private async Task InternalReadContentAsObjectAsync(bool unwrapTypedValue) - { - var tuple_11 = await InternalReadContentAsObjectTupleAsync(unwrapTypedValue).ConfigureAwait(false); - - return tuple_11.Item2; - } - - private async Task> InternalReadContentAsObjectTupleAsync(bool unwrapTypedValue) - { - Tuple tuple; - string originalStringValue; - - XmlNodeType nodeType = this.NodeType; - if (nodeType == XmlNodeType.Attribute) - { - originalStringValue = this.Value; - if (_attributePSVI != null && _attributePSVI.typedAttributeValue != null) - { - if (_validationState == ValidatingReaderState.OnDefaultAttribute) - { - XmlSchemaAttribute schemaAttr = _attributePSVI.attributeSchemaInfo.SchemaAttribute; - originalStringValue = (schemaAttr.DefaultValue != null) ? schemaAttr.DefaultValue : schemaAttr.FixedValue; - } - - tuple = new Tuple(originalStringValue, ReturnBoxedValue(_attributePSVI.typedAttributeValue, AttributeSchemaInfo.XmlType, unwrapTypedValue)); - return tuple; - } - else - { //return string value - tuple = new Tuple(originalStringValue, this.Value); - return tuple; - } - } - else if (nodeType == XmlNodeType.EndElement) - { - if (_atomicValue != null) - { - originalStringValue = _originalAtomicValueString; - - tuple = new Tuple(originalStringValue, _atomicValue); - return tuple; - } - else - { - originalStringValue = string.Empty; - - tuple = new Tuple(originalStringValue, string.Empty); - return tuple; - } - } - else - { //Positioned on text, CDATA, PI, Comment etc - if (_validator.CurrentContentType == XmlSchemaContentType.TextOnly) - { //if current element is of simple type - object value = ReturnBoxedValue(await ReadTillEndElementAsync().ConfigureAwait(false), _xmlSchemaInfo.XmlType, unwrapTypedValue); - originalStringValue = _originalAtomicValueString; - - tuple = new Tuple(originalStringValue, value); - return tuple; - } - else - { - XsdCachingReader cachingReader = _coreReader as XsdCachingReader; - if (cachingReader != null) - { - originalStringValue = cachingReader.ReadOriginalContentAsString(); - } - else - { - originalStringValue = await InternalReadContentAsStringAsync().ConfigureAwait(false); - } - - tuple = new Tuple(originalStringValue, originalStringValue); - return tuple; - } - } - } - - private Task> InternalReadElementContentAsObjectAsync() - { - return InternalReadElementContentAsObjectAsync(false); - } - - private async Task> InternalReadElementContentAsObjectAsync(bool unwrapTypedValue) - { - var tuple_13 = await InternalReadElementContentAsObjectTupleAsync(unwrapTypedValue).ConfigureAwait(false); - - return new Tuple(tuple_13.Item1, tuple_13.Item3); - } - - private async Task> InternalReadElementContentAsObjectTupleAsync(bool unwrapTypedValue) - { - Tuple tuple; - XmlSchemaType xmlType; - string originalString; - - Debug.Assert(this.NodeType == XmlNodeType.Element); - object typedValue = null; - xmlType = null; - //If its an empty element, can have default/fixed value - if (this.IsEmptyElement) - { - if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue); - } - else - { - typedValue = _atomicValue; - } - originalString = _originalAtomicValueString; - xmlType = ElementXmlType; //Set this for default values - await this.ReadAsync().ConfigureAwait(false); - - tuple = new Tuple(xmlType, originalString, typedValue); - return tuple; - } - // move to content and read typed value - await this.ReadAsync().ConfigureAwait(false); - - if (this.NodeType == XmlNodeType.EndElement) - { //If IsDefault is true, the next node will be EndElement - if (_xmlSchemaInfo.IsDefault) - { - if (_xmlSchemaInfo.ContentType == XmlSchemaContentType.TextOnly) - { - typedValue = ReturnBoxedValue(_atomicValue, _xmlSchemaInfo.XmlType, unwrapTypedValue); - } - else - { //anyType has default value - typedValue = _atomicValue; - } - originalString = _originalAtomicValueString; - } - else - { //Empty content - typedValue = string.Empty; - originalString = string.Empty; - } - } - else if (this.NodeType == XmlNodeType.Element) - { //the first child is again element node - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - else - { - var tuple_14 = await InternalReadContentAsObjectTupleAsync(unwrapTypedValue).ConfigureAwait(false); - originalString = tuple_14.Item1; - - typedValue = tuple_14.Item2; - - // ReadElementContentAsXXX cannot be called on mixed content, if positioned on node other than EndElement, Error - if (this.NodeType != XmlNodeType.EndElement) - { - throw new XmlException(ResXml.Xml_MixedReadElementContentAs, string.Empty, this as IXmlLineInfo); - } - } - xmlType = ElementXmlType; //Set this as we are moving ahead to the next node - - // move to next node - await this.ReadAsync().ConfigureAwait(false); - - tuple = new Tuple(xmlType, originalString, typedValue); - return tuple; - } - - private async Task ReadTillEndElementAsync() - { - if (_atomicValue == null) - { - while (await _coreReader.ReadAsync().ConfigureAwait(false)) - { - if (_replayCache) - { //If replaying nodes in the cache, they have already been validated - continue; - } - switch (_coreReader.NodeType) - { - case XmlNodeType.Element: - await ProcessReaderEventAsync().ConfigureAwait(false); - goto breakWhile; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - _validator.ValidateText(GetStringValue); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(GetStringValue); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - case XmlNodeType.EndElement: - _atomicValue = _validator.ValidateEndElement(_xmlSchemaInfo); - _originalAtomicValueString = GetOriginalAtomicValueStringOfElement(); - if (_manageNamespaces) - { - _nsManager.PopScope(); - } - goto breakWhile; - } - continue; - breakWhile: - break; - } - } - else - { //atomicValue != null, meaning already read ahead - Switch reader - if (_atomicValue == this) - { //switch back invalid marker; dont need it since coreReader moved to endElement - _atomicValue = null; - } - SwitchReader(); - } - return _atomicValue; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/util/TernaryTreeGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/util/TernaryTreeGenerator.cs deleted file mode 100644 index 25146a7779a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Core/util/TernaryTreeGenerator.cs +++ /dev/null @@ -1,467 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace TernaryTreeGenerator -{ - using System; - using System.IO; - using System.Text; - using System.Diagnostics; - using Microsoft.Xml; - - // - // HTML Element/Attribute name <-> XSL output property mapping - // - /// - public class HtmlProps - { - /// - public String nameHTML; - /// - public byte properties; - /// - public bool visited; - /// - public HtmlProps(String nameHTML, byte properties) - { - this.nameHTML = nameHTML; - this.properties = properties; - } - } - - - // - // TernaryTreeRW // ------------- - // - // NOTE: This class is only meant to be used to generate static tables to be used - // later with TernaryTreeRO. It should not be used in production code. - // - /// - public class TernaryTreeRW - { - /// - public const int MAX_NODES = 2000; - // Since _lt and _gt are just offsets in the node buffer, the node buffer size is limited - private byte[,] _nodeBuffer; - //node indexer; - private int _endNodePos; - - private int _numHtmlElements; - private int _numHtmlAttributes; - - private static HtmlProps[] s_htmlElements = { - new HtmlProps("a", (byte)(ElementProperties.URI_PARENT)), - new HtmlProps("address", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("applet", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("area", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("base", (byte)(ElementProperties.URI_PARENT | ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("basefont", (byte)(ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("blockquote", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("body", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("br", (byte)(ElementProperties.EMPTY)), - new HtmlProps("button", (byte)(ElementProperties.BOOL_PARENT)), - new HtmlProps("caption", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("center", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("col", (byte)(ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("colgroup", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("dd", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("del", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("dir", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("div", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("dl", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("dt", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("fieldset", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("font", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("form", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("frame", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("frameset", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h1", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h2", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h3", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h4", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h5", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("h6", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("head", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS | ElementProperties.HEAD)), - new HtmlProps("hr", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("html", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("iframe", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("img", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.EMPTY)), - new HtmlProps("input", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT | ElementProperties.EMPTY)), - new HtmlProps("ins", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("isindex", (byte)(ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("legend", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("li", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("link", (byte)(ElementProperties.URI_PARENT | ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("map", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("menu", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("meta", (byte)(ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("noframes", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("noscript", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("object", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT)), - new HtmlProps("ol", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("optgroup", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("option", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("p", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("param", (byte)(ElementProperties.EMPTY | ElementProperties.BLOCK_WS)), - new HtmlProps("pre", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("q", (byte)(ElementProperties.URI_PARENT)), - new HtmlProps("s", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("script", (byte)(ElementProperties.NO_ENTITIES | ElementProperties.BOOL_PARENT | ElementProperties.URI_PARENT)), - new HtmlProps("select", (byte)(ElementProperties.BOOL_PARENT)), - new HtmlProps("strike", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("style", (byte)(ElementProperties.NO_ENTITIES | ElementProperties.BLOCK_WS)), - new HtmlProps("table", (byte)(ElementProperties.URI_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("tbody", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("td", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("textarea", (byte)(ElementProperties.BOOL_PARENT)), - new HtmlProps("tfoot", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("th", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("thead", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("title", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("tr", (byte)(ElementProperties.BLOCK_WS)), - new HtmlProps("ul", (byte)(ElementProperties.BOOL_PARENT | ElementProperties.BLOCK_WS)), - new HtmlProps("xmp", (byte)(ElementProperties.BLOCK_WS)), - }; - - private static HtmlProps[] s_htmlAttributes = { - new HtmlProps("action", (byte)AttributeProperties.URI), - new HtmlProps("checked", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("cite", (byte)AttributeProperties.URI), - new HtmlProps("classid", (byte)AttributeProperties.URI), - new HtmlProps("codebase", (byte)AttributeProperties.URI), - new HtmlProps("compact", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("data", (byte)AttributeProperties.URI), - new HtmlProps("datasrc", (byte)AttributeProperties.URI), - new HtmlProps("declare", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("defer", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("disabled", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("for", (byte)AttributeProperties.URI), - new HtmlProps("href", (byte)AttributeProperties.URI), - new HtmlProps("ismap", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("longdesc", (byte)AttributeProperties.URI), - new HtmlProps("multiple", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("name", (byte)AttributeProperties.URI), - new HtmlProps("nohref", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("noresize", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("noshade", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("nowrap", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("profile", (byte)AttributeProperties.URI), - new HtmlProps("readonly", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("selected", (byte)AttributeProperties.BOOLEAN), - new HtmlProps("src", (byte)AttributeProperties.URI), - new HtmlProps("usemap", (byte)AttributeProperties.URI), - }; - - /// - public TernaryTreeRW() - { - //create the two dimentional byte array - _nodeBuffer = new byte[MAX_NODES, 4]; - _numHtmlElements = s_htmlElements.Length; - _numHtmlAttributes = s_htmlAttributes.Length; - _endNodePos = 1; - } - - /// - public int lengthNodes() - { - return _endNodePos; - } - /// - public int lengthBytes() - { - return _endNodePos; - } - - - // ---------------------------------------------------------------------------- - // addCaseInsensitiveString() - // - // Insert a string into this ternary tree. Assert if it's already been inserted - // or if the path offset variables (_lt, _gt) are overflowed. - // - /// - public void AddCaseInsensitiveString(String stringToAdd, byte data) - { - int charToAdd; - int charInTheTree; - int stringPos = 0; - int nodePos = 0; - - if (stringToAdd.Length == 0) - { - charToAdd = 0; - } - else - { - charToAdd = stringToAdd[0]; - - // Normalize to upper case - if (charToAdd >= 'a' && charToAdd <= 'z') charToAdd -= ('a' - 'A'); - } - - do - { - charInTheTree = _nodeBuffer[nodePos, (int)TernaryTreeByte.characterByte]; - - //Console.Write("charToAdd: {0},charInTheTree: {1}, nodePos: {2}, endNodePos {3}, ", Convert.ToChar(charToAdd), Convert.ToChar(charInTheTree), nodePos, endNodePos); - //Console.WriteLine("Left :{0}, Right:{0}", nodeBuffer[nodePos, (int)TernaryTreeByte.leftTree], nodeBuffer[nodePos, (int)TernaryTreeByte.rightTree]); - - - if (charToAdd == charInTheTree) - { - // This character already appears in the tree; take the equals path - nodePos++; - stringPos++; - - if (stringPos == stringToAdd.Length) - { - charToAdd = 0; - } - else - { - charToAdd = stringToAdd[stringPos]; - - // Normalize to upper case - if (charToAdd >= 'a' && charToAdd <= 'z') charToAdd -= ('a' - 'A'); - } - } - else - { - if (charToAdd < charInTheTree) - { - if (_nodeBuffer[nodePos, (int)TernaryTreeByte.leftTree] == 0x0) - { - // Create a new path less than the current character - if (_endNodePos - nodePos > 255) - { - throw new Exception("Too many characters have been added"); - } - else - { - _nodeBuffer[nodePos, (int)TernaryTreeByte.leftTree] = (byte)(_endNodePos - nodePos); - } - } - else - { - // Take the existing less than path - nodePos = nodePos + _nodeBuffer[nodePos, (int)TernaryTreeByte.leftTree]; - continue; - } - } - else - { - if (_nodeBuffer[nodePos, (int)TernaryTreeByte.rightTree] == 0x0) - { - // Create a new path greater than the current character - if (_endNodePos - nodePos > 255) - { - throw new Exception("Too many characters have been added"); - } - else - { - _nodeBuffer[nodePos, (int)TernaryTreeByte.rightTree] = (byte)(_endNodePos - nodePos); - } - } - else - { - // Take the existing greater than path - nodePos = nodePos + _nodeBuffer[nodePos, (int)TernaryTreeByte.rightTree]; - continue; - } - } - - - // Add new nodes to hold rest of string - - for (int i = stringPos; i < stringToAdd.Length; ++i) - { - charToAdd = stringToAdd[i]; - // Normalize to upper case - if (charToAdd >= 'a' && charToAdd <= 'z') charToAdd -= ('a' - 'A'); - - nodePos = _endNodePos++; - _nodeBuffer[nodePos, (int)TernaryTreeByte.characterByte] = (byte)charToAdd; - } - - // Store terminating null to indicate that this is the end of the string - nodePos = _endNodePos++; - _nodeBuffer[nodePos, (int)TernaryTreeByte.characterByte] = 0; - _nodeBuffer[nodePos, (int)TernaryTreeByte.data] = data; - break; - } - } while (true); - } - - /// - public void GenerateHtmlElementTable() - { - // Verify that the element and attribute tables are sorted correctly - s_htmlElements[0].visited = false; - - for (int i = 1; i < _numHtmlElements; i++) - { - s_htmlElements[i].visited = false; - if (s_htmlElements[i - 1].nameHTML.CompareTo(s_htmlElements[i].nameHTML) > 0) - { - throw new Exception("String table not correctly sorted"); - } - } - - // Add strings from the tables to the ternary trees - AddMidHtmlElement(0, _numHtmlElements - 1); - } - - /// - public void GenerateHtmlAttributeTable() - { - // Verify that the element and attribute tables are sorted correctly - - s_htmlAttributes[0].visited = false; - - for (int i = 1; i < _numHtmlAttributes; i++) - { - s_htmlAttributes[i].visited = false; - - if (s_htmlAttributes[i - 1].nameHTML.CompareTo(s_htmlAttributes[i].nameHTML) > 0) - { - throw new Exception("String table not correctly sorted"); - } - } - - // Add strings from the tables to the ternary trees - AddMidHtmlAttribute(0, _numHtmlAttributes - 1); - } - - - - // ---------------------------------------------------------------------------- - // addMidHtml() - // - // Given a sorted list of HTML names/properties, adds the middle name to the - // ternary tree and partitions the remaining halves, which are then recursively - // sent to this procedure. - // - private void AddMidHtmlElement(int startPos, int endPos) - { - int midPos; - - if (startPos > endPos) - return; - - midPos = (startPos + endPos) / 2; - - AddCaseInsensitiveString(s_htmlElements[midPos].nameHTML, s_htmlElements[midPos].properties); - - AddMidHtmlElement(startPos, midPos - 1); - AddMidHtmlElement(midPos + 1, endPos); - } - - // ---------------------------------------------------------------------------- - // addMidHtml() - // - // Given a sorted list of HTML names/properties, adds the middle name to the - // ternary tree and partitions the remaining halves, which are then recursively - // sent to this procedure. - // - private void AddMidHtmlAttribute(int startPos, int endPos) - { - int midPos; - if (startPos > endPos) - return; - - midPos = (startPos + endPos) / 2; - AddCaseInsensitiveString(s_htmlAttributes[midPos].nameHTML, s_htmlAttributes[midPos].properties); - - - AddMidHtmlAttribute(startPos, midPos - 1); - AddMidHtmlAttribute(midPos + 1, endPos); - } - - //---------------------------------------------------------------------------- - // OutputFileHeader() - // - - /// - public void OutputFileHeader(StreamWriter streamWriter) - { - string indent1 = " "; - - streamWriter.WriteLine("//------------------------------------------------------------------------------"); - streamWriter.WriteLine("// "); - streamWriter.WriteLine("// Copyright (c) Microsoft Corporation. All rights reserved."); - streamWriter.WriteLine("// "); - streamWriter.WriteLine("// derekdb"); - streamWriter.WriteLine("//------------------------------------------------------------------------------"); - - streamWriter.WriteLine("//"); - streamWriter.WriteLine("// This file is generated by TernaryTreeGenerator.cs,"); - streamWriter.WriteLine("// and is used by the TernaryTreeRO class.\n"); - streamWriter.WriteLine("//"); - streamWriter.WriteLine("// It contains the state for a ternary tree used to map HTML\n"); - streamWriter.WriteLine("// keywords to XSL output properties.\n"); - streamWriter.WriteLine("//"); - streamWriter.WriteLine("// Do not modify this file directly! (as if you could)\n"); - streamWriter.WriteLine("//"); - - streamWriter.WriteLine("namespace Microsoft.Xml"); - streamWriter.WriteLine("{0}internal abstract class HtmlTernaryTree {{", indent1); - } - - // - // Dump a C-style BYTE table to the output file. This table will contain the - // persisted state of this ternary tree. - // - - /// - public void OutputFileFooter(StreamWriter streamWriter) - { - streamWriter.WriteLine(" }"); - streamWriter.WriteLine("}"); - streamWriter.Flush(); - } - - - //---------------------------------------------------------------------------- - // dumpTree() - // - // Dump a C-style BYTE table to the output file. This table will contain the - // persisted state of this ternary tree. - // - - /// - public void dumpTree(StreamWriter streamWriter, String wszName) - { - int n = 0; - string indent3 = " "; - string indent2 = " "; - //string indent1 = " "; - - streamWriter.WriteLine("{0}internal static byte [] {1} = {{", indent2, wszName); - streamWriter.Write(indent3); - - for (int pos = 1; pos < _endNodePos; pos++) - { - streamWriter.Write("{0},{1},{2},{3},", _nodeBuffer[pos, (int)TernaryTreeByte.characterByte], - _nodeBuffer[pos, (int)TernaryTreeByte.leftTree], - _nodeBuffer[pos, (int)TernaryTreeByte.rightTree], - _nodeBuffer[pos, (int)TernaryTreeByte.data]); - n++; - - if (n % 7 == 0) - { - streamWriter.WriteLine(); - streamWriter.Write(indent3); - } - else - { - streamWriter.Write(" "); - } - } - streamWriter.WriteLine(); - streamWriter.WriteLine("{0}}};", indent2); - streamWriter.Flush(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentSchemaValidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentSchemaValidator.cs deleted file mode 100644 index 98f3f477e92..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentSchemaValidator.cs +++ /dev/null @@ -1,828 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Text; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Globalization; -using System.Security; -// using System.Security.Policy; -// using System.Security.Permissions; -using System.Reflection; -using System.Runtime.Versioning; - -namespace Microsoft.Xml -{ - using System; - - - internal sealed class DocumentSchemaValidator : IXmlNamespaceResolver - { - private XmlSchemaValidator _validator; - private XmlSchemaSet _schemas; - - private XmlNamespaceManager _nsManager; - private XmlNameTable _nameTable; - - //Attributes - private ArrayList _defaultAttributes; - private XmlValueGetter _nodeValueGetter; - private XmlSchemaInfo _attributeSchemaInfo; - - //Element PSVI - private XmlSchemaInfo _schemaInfo; - - //Event Handler - private ValidationEventHandler _eventHandler; - private ValidationEventHandler _internalEventHandler; - - //Store nodes - private XmlNode _startNode; - private XmlNode _currentNode; - private XmlDocument _document; - - //List of nodes for partial validation tree walk - private XmlNode[] _nodeSequenceToValidate; - private bool _isPartialTreeValid; - - private bool _psviAugmentation; - private bool _isValid; - - //To avoid SchemaNames creation - private string _nsXmlNs; - private string _nsXsi; - private string _xsiType; - private string _xsiNil; - - public DocumentSchemaValidator(XmlDocument ownerDocument, XmlSchemaSet schemas, ValidationEventHandler eventHandler) - { - _schemas = schemas; - _eventHandler = eventHandler; - _document = ownerDocument; - _internalEventHandler = new ValidationEventHandler(InternalValidationCallBack); - - _nameTable = _document.NameTable; - _nsManager = new XmlNamespaceManager(_nameTable); - - Debug.Assert(schemas != null && schemas.Count > 0); - - _nodeValueGetter = new XmlValueGetter(GetNodeValue); - _psviAugmentation = true; - - //Add common strings to be compared to NameTable - _nsXmlNs = _nameTable.Add(XmlReservedNs.NsXmlNs); - _nsXsi = _nameTable.Add(XmlReservedNs.NsXsi); - _xsiType = _nameTable.Add("type"); - _xsiNil = _nameTable.Add("nil"); - } - - public bool PsviAugmentation - { - get { return _psviAugmentation; } - set { _psviAugmentation = value; } - } - - public bool Validate(XmlNode nodeToValidate) - { - XmlSchemaObject partialValidationType = null; - XmlSchemaValidationFlags validationFlags = XmlSchemaValidationFlags.AllowXmlAttributes; - Debug.Assert(nodeToValidate.SchemaInfo != null); - - _startNode = nodeToValidate; - switch (nodeToValidate.NodeType) - { - case XmlNodeType.Document: - validationFlags |= XmlSchemaValidationFlags.ProcessIdentityConstraints; - break; - - case XmlNodeType.DocumentFragment: - break; - - case XmlNodeType.Element: //Validate children of this element - IXmlSchemaInfo schemaInfo = nodeToValidate.SchemaInfo; - XmlSchemaElement schemaElement = schemaInfo.SchemaElement; - if (schemaElement != null) - { - if (!schemaElement.RefName.IsEmpty) - { //If it is element ref, - partialValidationType = _schemas.GlobalElements[schemaElement.QualifiedName]; //Get Global element with correct Nillable, Default etc - } - else - { //local element - partialValidationType = schemaElement; - } - //Verify that if there was xsi:type, the schemaElement returned has the correct type set - Debug.Assert(schemaElement.ElementSchemaType == schemaInfo.SchemaType); - } - else - { //Can be an element that matched xs:any and had xsi:type - partialValidationType = schemaInfo.SchemaType; - - if (partialValidationType == null) - { //Validated against xs:any with pc= lax or skip or undeclared / not validated element - if (nodeToValidate.ParentNode.NodeType == XmlNodeType.Document) - { - //If this is the documentElement and it has not been validated at all - nodeToValidate = nodeToValidate.ParentNode; - } - else - { - partialValidationType = FindSchemaInfo(nodeToValidate as XmlElement); - if (partialValidationType == null) - { - throw new XmlSchemaValidationException(ResXml.XmlDocument_NoNodeSchemaInfo, null, nodeToValidate); - } - } - } - } - break; - - case XmlNodeType.Attribute: - if (nodeToValidate.XPNodeType == XPathNodeType.Namespace) goto default; - partialValidationType = nodeToValidate.SchemaInfo.SchemaAttribute; - if (partialValidationType == null) - { //Validated against xs:anyAttribute with pc = lax or skip / undeclared attribute - partialValidationType = FindSchemaInfo(nodeToValidate as XmlAttribute); - if (partialValidationType == null) - { - throw new XmlSchemaValidationException(ResXml.XmlDocument_NoNodeSchemaInfo, null, nodeToValidate); - } - } - break; - - default: - throw new InvalidOperationException(string.Format(ResXml.XmlDocument_ValidateInvalidNodeType, null)); - } - _isValid = true; - CreateValidator(partialValidationType, validationFlags); - if (_psviAugmentation) - { - if (_schemaInfo == null) - { //Might have created it during FindSchemaInfo - _schemaInfo = new XmlSchemaInfo(); - } - _attributeSchemaInfo = new XmlSchemaInfo(); - } - ValidateNode(nodeToValidate); - _validator.EndValidation(); - return _isValid; - } - - public IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - IDictionary dictionary = _nsManager.GetNamespacesInScope(scope); - if (scope != XmlNamespaceScope.Local) - { - XmlNode node = _startNode; - while (node != null) - { - switch (node.NodeType) - { - case XmlNodeType.Element: - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttributeCollection attrs = elem.Attributes; - for (int i = 0; i < attrs.Count; i++) - { - XmlAttribute attr = attrs[i]; - if (Ref.Equal(attr.NamespaceURI, _document.strReservedXmlns)) - { - if (attr.Prefix.Length == 0) - { - // xmlns='' declaration - if (!dictionary.ContainsKey(string.Empty)) - { - dictionary.Add(string.Empty, attr.Value); - } - } - else - { - // xmlns:prefix='' declaration - if (!dictionary.ContainsKey(attr.LocalName)) - { - dictionary.Add(attr.LocalName, attr.Value); - } - } - } - } - } - node = node.ParentNode; - break; - case XmlNodeType.Attribute: - node = ((XmlAttribute)node).OwnerElement; - break; - default: - node = node.ParentNode; - break; - } - } - } - return dictionary; - } - - public string LookupNamespace(string prefix) - { - string namespaceName = _nsManager.LookupNamespace(prefix); - if (namespaceName == null) - { - namespaceName = _startNode.GetNamespaceOfPrefixStrict(prefix); - } - return namespaceName; - } - - public string LookupPrefix(string namespaceName) - { - string prefix = _nsManager.LookupPrefix(namespaceName); - if (prefix == null) - { - prefix = _startNode.GetPrefixOfNamespaceStrict(namespaceName); - } - return prefix; - } - - private IXmlNamespaceResolver NamespaceResolver - { - get - { - if ((object)_startNode == (object)_document) - { - return _nsManager; - } - return this; - } - } - - private void CreateValidator(XmlSchemaObject partialValidationType, XmlSchemaValidationFlags validationFlags) - { - _validator = new XmlSchemaValidator(_nameTable, _schemas, NamespaceResolver, validationFlags); - _validator.SourceUri = XmlConvert.ToUri(_document.BaseURI); - _validator.XmlResolver = null; - _validator.ValidationEventHandler += _internalEventHandler; - _validator.ValidationEventSender = this; - - if (partialValidationType != null) - { - _validator.Initialize(partialValidationType); - } - else - { - _validator.Initialize(); - } - } - - private void ValidateNode(XmlNode node) - { - _currentNode = node; - switch (_currentNode.NodeType) - { - case XmlNodeType.Document: - XmlElement docElem = ((XmlDocument)node).DocumentElement; - if (docElem == null) - { - throw new InvalidOperationException(string.Format(ResXml.Xml_InvalidXmlDocument, string.Format(ResXml.Xdom_NoRootEle))); - } - ValidateNode(docElem); - break; - - case XmlNodeType.DocumentFragment: - case XmlNodeType.EntityReference: - for (XmlNode child = node.FirstChild; child != null; child = child.NextSibling) - { - ValidateNode(child); - } - break; - - case XmlNodeType.Element: - ValidateElement(); - break; - - case XmlNodeType.Attribute: //Top-level attribute - XmlAttribute attr = _currentNode as XmlAttribute; - _validator.ValidateAttribute(attr.LocalName, attr.NamespaceURI, _nodeValueGetter, _attributeSchemaInfo); - if (_psviAugmentation) - { - attr.XmlName = _document.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, _attributeSchemaInfo); - } - break; - - case XmlNodeType.Text: - _validator.ValidateText(_nodeValueGetter); - break; - - case XmlNodeType.CDATA: - _validator.ValidateText(_nodeValueGetter); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(_nodeValueGetter); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - default: - throw new InvalidOperationException(string.Format(ResXml.Xml_UnexpectedNodeType, new string[] { _currentNode.NodeType.ToString() })); - } - } - - // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. - // Since the resource names passed to ValidateElement method are null and the function does not expose any resources - // it is fine to disable the SxS warning. - - - private void ValidateElement() - { - _nsManager.PushScope(); - XmlElement elementNode = _currentNode as XmlElement; - Debug.Assert(elementNode != null); - - XmlAttributeCollection attributes = elementNode.Attributes; - XmlAttribute attr = null; - - //Find Xsi attributes that need to be processed before validating the element - string xsiNil = null; - string xsiType = null; - - for (int i = 0; i < attributes.Count; i++) - { - attr = attributes[i]; - string objectNs = attr.NamespaceURI; - string objectName = attr.LocalName; - Debug.Assert(_nameTable.Get(attr.NamespaceURI) != null); - Debug.Assert(_nameTable.Get(attr.LocalName) != null); - - if (Ref.Equal(objectNs, _nsXsi)) - { - if (Ref.Equal(objectName, _xsiType)) - { - xsiType = attr.Value; - } - else if (Ref.Equal(objectName, _xsiNil)) - { - xsiNil = attr.Value; - } - } - else if (Ref.Equal(objectNs, _nsXmlNs)) - { - _nsManager.AddNamespace(attr.Prefix.Length == 0 ? string.Empty : attr.LocalName, attr.Value); - } - } - _validator.ValidateElement(elementNode.LocalName, elementNode.NamespaceURI, _schemaInfo, xsiType, xsiNil, null, null); - ValidateAttributes(elementNode); - _validator.ValidateEndOfAttributes(_schemaInfo); - - //If element has children, drill down - for (XmlNode child = elementNode.FirstChild; child != null; child = child.NextSibling) - { - ValidateNode(child); - } - //Validate end of element - _currentNode = elementNode; //Reset current Node for validation call back - _validator.ValidateEndElement(_schemaInfo); - //Get XmlName, as memberType / validity might be set now - if (_psviAugmentation) - { - elementNode.XmlName = _document.AddXmlName(elementNode.Prefix, elementNode.LocalName, elementNode.NamespaceURI, _schemaInfo); - if (_schemaInfo.IsDefault) - { //the element has a default value - XmlText textNode = _document.CreateTextNode(_schemaInfo.SchemaElement.ElementDecl.DefaultValueRaw); - elementNode.AppendChild(textNode); - } - } - - _nsManager.PopScope(); //Pop current namespace scope - } - - private void ValidateAttributes(XmlElement elementNode) - { - XmlAttributeCollection attributes = elementNode.Attributes; - XmlAttribute attr = null; - - for (int i = 0; i < attributes.Count; i++) - { - attr = attributes[i]; - _currentNode = attr; //For nodeValueGetter to pick up the right attribute value - if (Ref.Equal(attr.NamespaceURI, _nsXmlNs)) - { //Do not validate namespace decls - continue; - } - _validator.ValidateAttribute(attr.LocalName, attr.NamespaceURI, _nodeValueGetter, _attributeSchemaInfo); - if (_psviAugmentation) - { - attr.XmlName = _document.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, _attributeSchemaInfo); - } - } - - if (_psviAugmentation) - { - //Add default attributes to the attributes collection - if (_defaultAttributes == null) - { - _defaultAttributes = new ArrayList(); - } - else - { - _defaultAttributes.Clear(); - } - _validator.GetUnspecifiedDefaultAttributes(_defaultAttributes); - XmlSchemaAttribute schemaAttribute = null; - XmlQualifiedName attrQName; - attr = null; - for (int i = 0; i < _defaultAttributes.Count; i++) - { - schemaAttribute = _defaultAttributes[i] as XmlSchemaAttribute; - attrQName = schemaAttribute.QualifiedName; - Debug.Assert(schemaAttribute != null); - attr = _document.CreateDefaultAttribute(GetDefaultPrefix(attrQName.Namespace), attrQName.Name, attrQName.Namespace); - SetDefaultAttributeSchemaInfo(schemaAttribute); - attr.XmlName = _document.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, _attributeSchemaInfo); - attr.AppendChild(_document.CreateTextNode(schemaAttribute.AttDef.DefaultValueRaw)); - attributes.Append(attr); - XmlUnspecifiedAttribute defAttr = attr as XmlUnspecifiedAttribute; - if (defAttr != null) - { - defAttr.SetSpecified(false); - } - } - } - } - - private void SetDefaultAttributeSchemaInfo(XmlSchemaAttribute schemaAttribute) - { - Debug.Assert(_attributeSchemaInfo != null); - _attributeSchemaInfo.Clear(); - _attributeSchemaInfo.IsDefault = true; - _attributeSchemaInfo.IsNil = false; - _attributeSchemaInfo.SchemaType = schemaAttribute.AttributeSchemaType; - _attributeSchemaInfo.SchemaAttribute = schemaAttribute; - - //Get memberType for default attribute - SchemaAttDef attributeDef = schemaAttribute.AttDef; - if (attributeDef.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { - XsdSimpleValue simpleValue = attributeDef.DefaultValueTyped as XsdSimpleValue; - Debug.Assert(simpleValue != null); - _attributeSchemaInfo.MemberType = simpleValue.XmlType; - } - _attributeSchemaInfo.Validity = XmlSchemaValidity.Valid; - } - - private string GetDefaultPrefix(string attributeNS) - { - IDictionary namespaceDecls = NamespaceResolver.GetNamespacesInScope(XmlNamespaceScope.All); - string defaultPrefix = null; - string defaultNS; - attributeNS = _nameTable.Add(attributeNS); //atomize ns - - foreach (KeyValuePair pair in namespaceDecls) - { - defaultNS = _nameTable.Add(pair.Value); - if (object.ReferenceEquals(defaultNS, attributeNS)) - { - defaultPrefix = pair.Key; - if (defaultPrefix.Length != 0) - { //Locate first non-empty prefix - return defaultPrefix; - } - } - } - return defaultPrefix; - } - - private object GetNodeValue() - { - return _currentNode.Value; - } - - //Code for finding type during partial validation - private XmlSchemaObject FindSchemaInfo(XmlElement elementToValidate) - { - _isPartialTreeValid = true; - Debug.Assert(elementToValidate.ParentNode.NodeType != XmlNodeType.Document); //Handle if it is the documentElement seperately - - //Create nodelist to navigate down again - XmlNode currentNode = elementToValidate; - IXmlSchemaInfo parentSchemaInfo = null; - int nodeIndex = 0; - - //Check common case of parent node first - XmlNode parentNode = currentNode.ParentNode; - do - { - parentSchemaInfo = parentNode.SchemaInfo; - if (parentSchemaInfo.SchemaElement != null || parentSchemaInfo.SchemaType != null) - { - break; //Found ancestor with schemaInfo - } - CheckNodeSequenceCapacity(nodeIndex); - _nodeSequenceToValidate[nodeIndex++] = parentNode; - parentNode = parentNode.ParentNode; - } while (parentNode != null); - - if (parentNode == null) - { //Did not find any type info all the way to the root, currentNode is Document || DocumentFragment - nodeIndex = nodeIndex - 1; //Subtract the one for document and set the node to null - _nodeSequenceToValidate[nodeIndex] = null; - return GetTypeFromAncestors(elementToValidate, null, nodeIndex); - } - else - { - //Start validating down from the parent or ancestor that has schema info and shallow validate all previous siblings - //to correctly ascertain particle for current node - CheckNodeSequenceCapacity(nodeIndex); - _nodeSequenceToValidate[nodeIndex++] = parentNode; - XmlSchemaObject ancestorSchemaObject = parentSchemaInfo.SchemaElement; - if (ancestorSchemaObject == null) - { - ancestorSchemaObject = parentSchemaInfo.SchemaType; - } - return GetTypeFromAncestors(elementToValidate, ancestorSchemaObject, nodeIndex); - } - } - - /*private XmlSchemaElement GetTypeFromParent(XmlElement elementToValidate, XmlSchemaComplexType parentSchemaType) { - XmlQualifiedName elementName = new XmlQualifiedName(elementToValidate.LocalName, elementToValidate.NamespaceURI); - XmlSchemaElement elem = parentSchemaType.LocalElements[elementName] as XmlSchemaElement; - if (elem == null) { //Element not found as direct child of the content model. It might be invalid at this position or it might be a substitution member - SchemaInfo compiledSchemaInfo = schemas.CompiledInfo; - XmlSchemaElement memberElem = compiledSchemaInfo.GetElement(elementName); - if (memberElem != null) { - } - } - }*/ - - private void CheckNodeSequenceCapacity(int currentIndex) - { - if (_nodeSequenceToValidate == null) - { //Normally users would call Validate one level down, this allows for 4 - _nodeSequenceToValidate = new XmlNode[4]; - } - else if (currentIndex >= _nodeSequenceToValidate.Length - 1) - { //reached capacity of array, Need to increase capacity to twice the initial - XmlNode[] newNodeSequence = new XmlNode[_nodeSequenceToValidate.Length * 2]; - Array.Copy(_nodeSequenceToValidate, 0, newNodeSequence, 0, _nodeSequenceToValidate.Length); - _nodeSequenceToValidate = newNodeSequence; - } - } - - private XmlSchemaAttribute FindSchemaInfo(XmlAttribute attributeToValidate) - { - XmlElement parentElement = attributeToValidate.OwnerElement; - XmlSchemaObject schemaObject = FindSchemaInfo(parentElement); - XmlSchemaComplexType elementSchemaType = GetComplexType(schemaObject); - if (elementSchemaType == null) - { - return null; - } - XmlQualifiedName attName = new XmlQualifiedName(attributeToValidate.LocalName, attributeToValidate.NamespaceURI); - XmlSchemaAttribute schemaAttribute = elementSchemaType.AttributeUses[attName] as XmlSchemaAttribute; - if (schemaAttribute == null) - { - XmlSchemaAnyAttribute anyAttribute = elementSchemaType.AttributeWildcard; - if (anyAttribute != null) - { - if (anyAttribute.NamespaceList.Allows(attName)) - { //Match wildcard against global attribute - schemaAttribute = _schemas.GlobalAttributes[attName] as XmlSchemaAttribute; - } - } - } - return schemaAttribute; - } - - private XmlSchemaObject GetTypeFromAncestors(XmlElement elementToValidate, XmlSchemaObject ancestorType, int ancestorsCount) - { - //schemaInfo is currentNode's schemaInfo - _validator = CreateTypeFinderValidator(ancestorType); - _schemaInfo = new XmlSchemaInfo(); - - //start at the ancestor to start validating - int startIndex = ancestorsCount - 1; - - bool ancestorHasWildCard = AncestorTypeHasWildcard(ancestorType); - for (int i = startIndex; i >= 0; i--) - { - XmlNode node = _nodeSequenceToValidate[i]; - XmlElement currentElement = node as XmlElement; - ValidateSingleElement(currentElement, false, _schemaInfo); - if (!ancestorHasWildCard) - { //store type if ancestor does not have wildcard in its content model - currentElement.XmlName = _document.AddXmlName(currentElement.Prefix, currentElement.LocalName, currentElement.NamespaceURI, _schemaInfo); - //update wildcard flag - ancestorHasWildCard = AncestorTypeHasWildcard(_schemaInfo.SchemaElement); - } - - _validator.ValidateEndOfAttributes(null); - if (i > 0) - { - ValidateChildrenTillNextAncestor(node, _nodeSequenceToValidate[i - 1]); - } - else - { //i == 0 - ValidateChildrenTillNextAncestor(node, elementToValidate); - } - } - - Debug.Assert(_nodeSequenceToValidate[0] == elementToValidate.ParentNode); - //validate element whose type is needed, - ValidateSingleElement(elementToValidate, false, _schemaInfo); - - XmlSchemaObject schemaInfoFound = null; - if (_schemaInfo.SchemaElement != null) - { - schemaInfoFound = _schemaInfo.SchemaElement; - } - else - { - schemaInfoFound = _schemaInfo.SchemaType; - } - if (schemaInfoFound == null) - { //Detect if the node was validated lax or skip - if (_validator.CurrentProcessContents == XmlSchemaContentProcessing.Skip) - { - if (_isPartialTreeValid) - { //Then node assessed as skip; if there was error we turn processContents to skip as well. But this is not the same as validating as skip. - return XmlSchemaComplexType.AnyTypeSkip; - } - } - else if (_validator.CurrentProcessContents == XmlSchemaContentProcessing.Lax) - { - return XmlSchemaComplexType.AnyType; - } - } - return schemaInfoFound; - } - - private bool AncestorTypeHasWildcard(XmlSchemaObject ancestorType) - { - XmlSchemaComplexType ancestorSchemaType = GetComplexType(ancestorType); - if (ancestorType != null) - { - return ancestorSchemaType.HasWildCard; - } - return false; - } - - private XmlSchemaComplexType GetComplexType(XmlSchemaObject schemaObject) - { - if (schemaObject == null) - { - return null; - } - XmlSchemaElement schemaElement = schemaObject as XmlSchemaElement; - XmlSchemaComplexType complexType = null; - if (schemaElement != null) - { - complexType = schemaElement.ElementSchemaType as XmlSchemaComplexType; - } - else - { - complexType = schemaObject as XmlSchemaComplexType; - } - return complexType; - } - - // SxS: This function calls ValidateElement on XmlSchemaValidator which is annotated with ResourceExposure attribute. - // Since the resource names passed to ValidateElement method are null and the function does not expose any resources - // it is fine to supress the warning. - - - private void ValidateSingleElement(XmlElement elementNode, bool skipToEnd, XmlSchemaInfo newSchemaInfo) - { - _nsManager.PushScope(); - Debug.Assert(elementNode != null); - - XmlAttributeCollection attributes = elementNode.Attributes; - XmlAttribute attr = null; - - //Find Xsi attributes that need to be processed before validating the element - string xsiNil = null; - string xsiType = null; - - for (int i = 0; i < attributes.Count; i++) - { - attr = attributes[i]; - string objectNs = attr.NamespaceURI; - string objectName = attr.LocalName; - Debug.Assert(_nameTable.Get(attr.NamespaceURI) != null); - Debug.Assert(_nameTable.Get(attr.LocalName) != null); - - if (Ref.Equal(objectNs, _nsXsi)) - { - if (Ref.Equal(objectName, _xsiType)) - { - xsiType = attr.Value; - } - else if (Ref.Equal(objectName, _xsiNil)) - { - xsiNil = attr.Value; - } - } - else if (Ref.Equal(objectNs, _nsXmlNs)) - { - _nsManager.AddNamespace(attr.Prefix.Length == 0 ? string.Empty : attr.LocalName, attr.Value); - } - } - _validator.ValidateElement(elementNode.LocalName, elementNode.NamespaceURI, newSchemaInfo, xsiType, xsiNil, null, null); - //Validate end of element - if (skipToEnd) - { - _validator.ValidateEndOfAttributes(newSchemaInfo); - _validator.SkipToEndElement(newSchemaInfo); - _nsManager.PopScope(); //Pop current namespace scope - } - } - - private void ValidateChildrenTillNextAncestor(XmlNode parentNode, XmlNode childToStopAt) - { - XmlNode child; - - for (child = parentNode.FirstChild; child != null; child = child.NextSibling) - { - if (child == childToStopAt) - { - break; - } - switch (child.NodeType) - { - case XmlNodeType.EntityReference: - ValidateChildrenTillNextAncestor(child, childToStopAt); - break; - - case XmlNodeType.Element: //Flat validation, do not drill down into children - ValidateSingleElement(child as XmlElement, true, null); - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - _validator.ValidateText(child.Value); - break; - - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - _validator.ValidateWhitespace(child.Value); - break; - - case XmlNodeType.Comment: - case XmlNodeType.ProcessingInstruction: - break; - - default: - throw new InvalidOperationException(string.Format(ResXml.Xml_UnexpectedNodeType, new string[] { _currentNode.NodeType.ToString() })); - } - } - Debug.Assert(child == childToStopAt); - } - - private XmlSchemaValidator CreateTypeFinderValidator(XmlSchemaObject partialValidationType) - { - XmlSchemaValidator findTypeValidator = new XmlSchemaValidator(_document.NameTable, _document.Schemas, _nsManager, XmlSchemaValidationFlags.None); - findTypeValidator.ValidationEventHandler += new ValidationEventHandler(TypeFinderCallBack); - if (partialValidationType != null) - { - findTypeValidator.Initialize(partialValidationType); - } - else - { //If we walked up to the root and no schemaInfo was there, start validating from root - findTypeValidator.Initialize(); - } - return findTypeValidator; - } - - private void TypeFinderCallBack(object sender, ValidationEventArgs arg) - { - if (arg.Severity == XmlSeverityType.Error) - { - _isPartialTreeValid = false; - } - } - - private void InternalValidationCallBack(object sender, ValidationEventArgs arg) - { - if (arg.Severity == XmlSeverityType.Error) - { - _isValid = false; - } - XmlSchemaValidationException ex = arg.Exception as XmlSchemaValidationException; - Debug.Assert(ex != null); - ex.SetSourceObject(_currentNode); - if (_eventHandler != null) - { //Invoke user's event handler - _eventHandler(sender, arg); - } - else if (arg.Severity == XmlSeverityType.Error) - { - throw ex; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXPathNavigator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXPathNavigator.cs deleted file mode 100644 index f8376b384d1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXPathNavigator.cs +++ /dev/null @@ -1,2452 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Diagnostics; - -namespace Microsoft.Xml -{ - using System; - - internal sealed class DocumentXPathNavigator : XPathNavigator, IHasXmlNode - { - private XmlDocument _document; // owner document - private XmlNode _source; // navigator position - private int _attributeIndex; // index in attribute collection for attribute - private XmlElement _namespaceParent; // parent for namespace - - public DocumentXPathNavigator(XmlDocument document, XmlNode node) - { - _document = document; - ResetPosition(node); - } - - public DocumentXPathNavigator(DocumentXPathNavigator other) - { - _document = other._document; - _source = other._source; - _attributeIndex = other._attributeIndex; - _namespaceParent = other._namespaceParent; - } - - public override XPathNavigator Clone() - { - return new DocumentXPathNavigator(this); - } - - public override void SetValue(string value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - XmlNode node = _source; - XmlNode end; - - switch (node.NodeType) - { - case XmlNodeType.Attribute: - if (((XmlAttribute)node).IsNamespace) - { - goto default; - } - node.InnerText = value; - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - CalibrateText(); - - node = _source; - end = TextEnd(node); - if (node != end) - { - if (node.IsReadOnly) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Modify_ReadOnly); - } - DeleteToFollowingSibling(node.NextSibling, end); - } - goto case XmlNodeType.Element; - case XmlNodeType.Element: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - node.InnerText = value; - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - } - - public override XmlNameTable NameTable - { - get - { - return _document.NameTable; - } - } - - public override XPathNodeType NodeType - { - get - { - CalibrateText(); - - return (XPathNodeType)_source.XPNodeType; - } - } - - public override string LocalName - { - get - { - return _source.XPLocalName; - } - } - - public override string NamespaceURI - { - get - { - XmlAttribute attribute = _source as XmlAttribute; - if (attribute != null - && attribute.IsNamespace) - { - return string.Empty; - } - return _source.NamespaceURI; - } - } - - public override string Name - { - get - { - switch (_source.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.ProcessingInstruction: - return _source.Name; - case XmlNodeType.Attribute: - if (((XmlAttribute)_source).IsNamespace) - { - string localName = _source.LocalName; - if (Ref.Equal(localName, _document.strXmlns)) - { - return string.Empty; // xmlns declaration - } - return localName; // xmlns:name declaration - } - return _source.Name; // attribute - default: - return string.Empty; - } - } - } - - public override string Prefix - { - get - { - XmlAttribute attribute = _source as XmlAttribute; - if (attribute != null - && attribute.IsNamespace) - { - return string.Empty; - } - return _source.Prefix; - } - } - - public override string Value - { - get - { - switch (_source.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.DocumentFragment: - return _source.InnerText; - case XmlNodeType.Document: - return ValueDocument; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return ValueText; - default: - return _source.Value; - } - } - } - - private string ValueDocument - { - get - { - XmlElement element = _document.DocumentElement; - if (element != null) - { - return element.InnerText; - } - return string.Empty; - } - } - - private string ValueText - { - get - { - CalibrateText(); - - string value = _source.Value; - XmlNode nextSibling = NextSibling(_source); - if (nextSibling != null - && nextSibling.IsText) - { - StringBuilder builder = new StringBuilder(value); - do - { - builder.Append(nextSibling.Value); - nextSibling = NextSibling(nextSibling); - } - while (nextSibling != null - && nextSibling.IsText); - value = builder.ToString(); - } - return value; - } - } - - public override string BaseURI - { - get - { - return _source.BaseURI; - } - } - - public override bool IsEmptyElement - { - get - { - XmlElement element = _source as XmlElement; - if (element != null) - { - return element.IsEmpty; - } - return false; - } - } - - public override string XmlLang - { - get - { - return _source.XmlLang; - } - } - - public override object UnderlyingObject - { - get - { - CalibrateText(); - - return _source; - } - } - - public override bool HasAttributes - { - get - { - XmlElement element = _source as XmlElement; - if (element != null - && element.HasAttributes) - { - XmlAttributeCollection attributes = element.Attributes; - for (int i = 0; i < attributes.Count; i++) - { - XmlAttribute attribute = attributes[i]; - if (!attribute.IsNamespace) - { - return true; - } - } - } - return false; - } - } - - public override string GetAttribute(string localName, string namespaceURI) - { - return _source.GetXPAttribute(localName, namespaceURI); - } - - public override bool MoveToAttribute(string localName, string namespaceURI) - { - XmlElement element = _source as XmlElement; - if (element != null - && element.HasAttributes) - { - XmlAttributeCollection attributes = element.Attributes; - for (int i = 0; i < attributes.Count; i++) - { - XmlAttribute attribute = attributes[i]; - if (attribute.LocalName == localName - && attribute.NamespaceURI == namespaceURI) - { - if (!attribute.IsNamespace) - { - _source = attribute; - _attributeIndex = i; - return true; - } - else - { - return false; - } - } - } - } - return false; - } - - public override bool MoveToFirstAttribute() - { - XmlElement element = _source as XmlElement; - if (element != null - && element.HasAttributes) - { - XmlAttributeCollection attributes = element.Attributes; - for (int i = 0; i < attributes.Count; i++) - { - XmlAttribute attribute = attributes[i]; - if (!attribute.IsNamespace) - { - _source = attribute; - _attributeIndex = i; - return true; - } - } - } - return false; - } - - public override bool MoveToNextAttribute() - { - XmlAttribute attribute = _source as XmlAttribute; - if (attribute == null - || attribute.IsNamespace) - { - return false; - } - XmlAttributeCollection attributes; - if (!CheckAttributePosition(attribute, out attributes, _attributeIndex) - && !ResetAttributePosition(attribute, attributes, out _attributeIndex)) - { - return false; - } - for (int i = _attributeIndex + 1; i < attributes.Count; i++) - { - attribute = attributes[i]; - if (!attribute.IsNamespace) - { - _source = attribute; - _attributeIndex = i; - return true; - } - } - return false; - } - - public override string GetNamespace(string name) - { - XmlNode node = _source; - while (node != null - && node.NodeType != XmlNodeType.Element) - { - XmlAttribute attribute = node as XmlAttribute; - if (attribute != null) - { - node = attribute.OwnerElement; - } - else - { - node = node.ParentNode; - } - } - - XmlElement element = node as XmlElement; - if (element != null) - { - string localName; - if (name != null - && name.Length != 0) - { - localName = name; - } - else - { - localName = _document.strXmlns; - } - string namespaceUri = _document.strReservedXmlns; - - do - { - XmlAttribute attribute = element.GetAttributeNode(localName, namespaceUri); - if (attribute != null) - { - return attribute.Value; - } - element = element.ParentNode as XmlElement; - } - while (element != null); - } - - if (name == _document.strXml) - { - return _document.strReservedXml; - } - else if (name == _document.strXmlns) - { - return _document.strReservedXmlns; - } - return string.Empty; - } - - public override bool MoveToNamespace(string name) - { - if (name == _document.strXmlns) - { - return false; - } - XmlElement element = _source as XmlElement; - if (element != null) - { - string localName; - if (name != null - && name.Length != 0) - { - localName = name; - } - else - { - localName = _document.strXmlns; - } - string namespaceUri = _document.strReservedXmlns; - - do - { - XmlAttribute attribute = element.GetAttributeNode(localName, namespaceUri); - if (attribute != null) - { - _namespaceParent = (XmlElement)_source; - _source = attribute; - return true; - } - element = element.ParentNode as XmlElement; - } - while (element != null); - - if (name == _document.strXml) - { - _namespaceParent = (XmlElement)_source; - _source = _document.NamespaceXml; - return true; - } - } - return false; - } - - public override bool MoveToFirstNamespace(XPathNamespaceScope scope) - { - XmlElement element = _source as XmlElement; - if (element == null) - { - return false; - } - XmlAttributeCollection attributes; - int index = Int32.MaxValue; - switch (scope) - { - case XPathNamespaceScope.Local: - if (!element.HasAttributes) - { - return false; - } - attributes = element.Attributes; - if (!MoveToFirstNamespaceLocal(attributes, ref index)) - { - return false; - } - _source = attributes[index]; - _attributeIndex = index; - _namespaceParent = element; - break; - case XPathNamespaceScope.ExcludeXml: - attributes = element.Attributes; - if (!MoveToFirstNamespaceGlobal(ref attributes, ref index)) - { - return false; - } - XmlAttribute attribute = attributes[index]; - while (Ref.Equal(attribute.LocalName, _document.strXml)) - { - if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) - { - return false; - } - attribute = attributes[index]; - } - _source = attribute; - _attributeIndex = index; - _namespaceParent = element; - break; - case XPathNamespaceScope.All: - attributes = element.Attributes; - if (!MoveToFirstNamespaceGlobal(ref attributes, ref index)) - { - _source = _document.NamespaceXml; - // attributeIndex = 0; - } - else - { - _source = attributes[index]; - _attributeIndex = index; - } - _namespaceParent = element; - break; - default: - Debug.Assert(false); - return false; - } - return true; - } - - private static bool MoveToFirstNamespaceLocal(XmlAttributeCollection attributes, ref int index) - { - Debug.Assert(attributes != null); - for (int i = attributes.Count - 1; i >= 0; i--) - { - XmlAttribute attribute = attributes[i]; - if (attribute.IsNamespace) - { - index = i; - return true; - } - } - return false; - } - - private static bool MoveToFirstNamespaceGlobal(ref XmlAttributeCollection attributes, ref int index) - { - if (MoveToFirstNamespaceLocal(attributes, ref index)) - { - return true; - } - - Debug.Assert(attributes != null && attributes.parent != null); - XmlElement element = attributes.parent.ParentNode as XmlElement; - while (element != null) - { - if (element.HasAttributes) - { - attributes = element.Attributes; - if (MoveToFirstNamespaceLocal(attributes, ref index)) - { - return true; - } - } - element = element.ParentNode as XmlElement; - } - return false; - } - - public override bool MoveToNextNamespace(XPathNamespaceScope scope) - { - XmlAttribute attribute = _source as XmlAttribute; - if (attribute == null - || !attribute.IsNamespace) - { - return false; - } - XmlAttributeCollection attributes; - int index = _attributeIndex; - if (!CheckAttributePosition(attribute, out attributes, index) - && !ResetAttributePosition(attribute, attributes, out index)) - { - return false; - } - Debug.Assert(_namespaceParent != null); - switch (scope) - { - case XPathNamespaceScope.Local: - if (attribute.OwnerElement != _namespaceParent) - { - return false; - } - if (!MoveToNextNamespaceLocal(attributes, ref index)) - { - return false; - } - _source = attributes[index]; - _attributeIndex = index; - break; - case XPathNamespaceScope.ExcludeXml: - string localName; - do - { - if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) - { - return false; - } - attribute = attributes[index]; - localName = attribute.LocalName; - } - while (PathHasDuplicateNamespace(attribute.OwnerElement, _namespaceParent, localName) - || Ref.Equal(localName, _document.strXml)); - _source = attribute; - _attributeIndex = index; - break; - case XPathNamespaceScope.All: - do - { - if (!MoveToNextNamespaceGlobal(ref attributes, ref index)) - { - if (PathHasDuplicateNamespace(null, _namespaceParent, _document.strXml)) - { - return false; - } - else - { - _source = _document.NamespaceXml; - // attributeIndex = 0; - return true; - } - } - attribute = attributes[index]; - } - while (PathHasDuplicateNamespace(attribute.OwnerElement, _namespaceParent, attribute.LocalName)); - _source = attribute; - _attributeIndex = index; - break; - default: - Debug.Assert(false); - return false; - } - return true; - } - - private static bool MoveToNextNamespaceLocal(XmlAttributeCollection attributes, ref int index) - { - Debug.Assert(attributes != null); - Debug.Assert(0 <= index && index < attributes.Count); - for (int i = index - 1; i >= 0; i--) - { - XmlAttribute attribute = attributes[i]; - if (attribute.IsNamespace) - { - index = i; - return true; - } - } - return false; - } - - private static bool MoveToNextNamespaceGlobal(ref XmlAttributeCollection attributes, ref int index) - { - if (MoveToNextNamespaceLocal(attributes, ref index)) - { - return true; - } - - Debug.Assert(attributes != null && attributes.parent != null); - XmlElement element = attributes.parent.ParentNode as XmlElement; - while (element != null) - { - if (element.HasAttributes) - { - attributes = element.Attributes; - if (MoveToFirstNamespaceLocal(attributes, ref index)) - { - return true; - } - } - element = element.ParentNode as XmlElement; - } - return false; - } - - private bool PathHasDuplicateNamespace(XmlElement top, XmlElement bottom, string localName) - { - string namespaceUri = _document.strReservedXmlns; - while (bottom != null - && bottom != top) - { - XmlAttribute attribute = bottom.GetAttributeNode(localName, namespaceUri); - if (attribute != null) - { - return true; - } - bottom = bottom.ParentNode as XmlElement; - } - return false; - } - - public override string LookupNamespace(string prefix) - { - string ns = base.LookupNamespace(prefix); - if (ns != null) - { - ns = this.NameTable.Add(ns); - } - return ns; - } - - public override bool MoveToNext() - { - XmlNode sibling = NextSibling(_source); - if (sibling == null) - { - return false; - } - if (sibling.IsText) - { - if (_source.IsText) - { - sibling = NextSibling(TextEnd(sibling)); - if (sibling == null) - { - return false; - } - } - } - XmlNode parent = ParentNode(sibling); - Debug.Assert(parent != null); - while (!IsValidChild(parent, sibling)) - { - sibling = NextSibling(sibling); - if (sibling == null) - { - return false; - } - } - _source = sibling; - return true; - } - - public override bool MoveToPrevious() - { - XmlNode sibling = PreviousSibling(_source); - if (sibling == null) - { - return false; - } - if (sibling.IsText) - { - if (_source.IsText) - { - sibling = PreviousSibling(TextStart(sibling)); - if (sibling == null) - { - return false; - } - } - else - { - sibling = TextStart(sibling); - } - } - XmlNode parent = ParentNode(sibling); - Debug.Assert(parent != null); - while (!IsValidChild(parent, sibling)) - { - sibling = PreviousSibling(sibling); - if (sibling == null) - { - return false; - } - // if (sibling.IsText) { - // sibling = TextStart(sibling); - // } - } - _source = sibling; - return true; - } - - public override bool MoveToFirst() - { - if (_source.NodeType == XmlNodeType.Attribute) - { - return false; - } - XmlNode parent = ParentNode(_source); - if (parent == null) - { - return false; - } - XmlNode sibling = FirstChild(parent); - Debug.Assert(sibling != null); - while (!IsValidChild(parent, sibling)) - { - sibling = NextSibling(sibling); - if (sibling == null) - { - return false; - } - } - _source = sibling; - return true; - } - - public override bool MoveToFirstChild() - { - XmlNode child; - switch (_source.NodeType) - { - case XmlNodeType.Element: - child = FirstChild(_source); - if (child == null) - { - return false; - } - break; - case XmlNodeType.DocumentFragment: - case XmlNodeType.Document: - child = FirstChild(_source); - if (child == null) - { - return false; - } - while (!IsValidChild(_source, child)) - { - child = NextSibling(child); - if (child == null) - { - return false; - } - } - break; - default: - return false; - } - _source = child; - return true; - } - - public override bool MoveToParent() - { - XmlNode parent = ParentNode(_source); - if (parent != null) - { - _source = parent; - return true; - } - XmlAttribute attribute = _source as XmlAttribute; - if (attribute != null) - { - parent = attribute.IsNamespace ? _namespaceParent : attribute.OwnerElement; - if (parent != null) - { - _source = parent; - _namespaceParent = null; - return true; - } - } - return false; - } - - public override void MoveToRoot() - { - for (; ; ) - { - XmlNode parent = _source.ParentNode; - if (parent == null) - { - XmlAttribute attribute = _source as XmlAttribute; - if (attribute == null) - { - break; - } - parent = attribute.IsNamespace ? _namespaceParent : attribute.OwnerElement; - if (parent == null) - { - break; - } - } - _source = parent; - } - _namespaceParent = null; - } - - public override bool MoveTo(XPathNavigator other) - { - DocumentXPathNavigator that = other as DocumentXPathNavigator; - if (that != null - && _document == that._document) - { - _source = that._source; - _attributeIndex = that._attributeIndex; - _namespaceParent = that._namespaceParent; - return true; - } - return false; - } - - public override bool MoveToId(string id) - { - XmlElement element = _document.GetElementById(id); - if (element != null) - { - _source = element; - _namespaceParent = null; - return true; - } - return false; - } - - public override bool MoveToChild(string localName, string namespaceUri) - { - if (_source.NodeType == XmlNodeType.Attribute) - { - return false; - } - - XmlNode child = FirstChild(_source); - if (child != null) - { - do - { - if (child.NodeType == XmlNodeType.Element - && child.LocalName == localName - && child.NamespaceURI == namespaceUri) - { - _source = child; - return true; - } - child = NextSibling(child); - } - while (child != null); - } - return false; - } - - public override bool MoveToChild(XPathNodeType type) - { - if (_source.NodeType == XmlNodeType.Attribute) - { - return false; - } - - XmlNode child = FirstChild(_source); - if (child != null) - { - int mask = GetContentKindMask(type); - if (mask == 0) - { - return false; - } - do - { - if (((1 << (int)child.XPNodeType) & mask) != 0) - { - _source = child; - return true; - } - child = NextSibling(child); - } - while (child != null); - } - return false; - } - - public override bool MoveToFollowing(string localName, string namespaceUri, XPathNavigator end) - { - XmlNode pastFollowing = null; - DocumentXPathNavigator that = end as DocumentXPathNavigator; - if (that != null) - { - if (_document != that._document) - { - return false; - } - switch (that._source.NodeType) - { - case XmlNodeType.Attribute: - that = (DocumentXPathNavigator)that.Clone(); - if (!that.MoveToNonDescendant()) - { - return false; - } - break; - } - pastFollowing = that._source; - } - - XmlNode following = _source; - if (following.NodeType == XmlNodeType.Attribute) - { - following = ((XmlAttribute)following).OwnerElement; - if (following == null) - { - return false; - } - } - do - { - XmlNode firstChild = following.FirstChild; - if (firstChild != null) - { - following = firstChild; - } - else - { - for (; ; ) - { - XmlNode nextSibling = following.NextSibling; - if (nextSibling != null) - { - following = nextSibling; - break; - } - else - { - XmlNode parent = following.ParentNode; - if (parent != null) - { - following = parent; - } - else - { - return false; - } - } - } - } - if (following == pastFollowing) - { - return false; - } - } - while (following.NodeType != XmlNodeType.Element - || following.LocalName != localName - || following.NamespaceURI != namespaceUri); - - _source = following; - return true; - } - - public override bool MoveToFollowing(XPathNodeType type, XPathNavigator end) - { - XmlNode pastFollowing = null; - DocumentXPathNavigator that = end as DocumentXPathNavigator; - if (that != null) - { - if (_document != that._document) - { - return false; - } - switch (that._source.NodeType) - { - case XmlNodeType.Attribute: - that = (DocumentXPathNavigator)that.Clone(); - if (!that.MoveToNonDescendant()) - { - return false; - } - break; - } - pastFollowing = that._source; - } - - int mask = GetContentKindMask(type); - if (mask == 0) - { - return false; - } - XmlNode following = _source; - switch (following.NodeType) - { - case XmlNodeType.Attribute: - following = ((XmlAttribute)following).OwnerElement; - if (following == null) - { - return false; - } - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - following = TextEnd(following); - break; - } - do - { - XmlNode firstChild = following.FirstChild; - if (firstChild != null) - { - following = firstChild; - } - else - { - for (; ; ) - { - XmlNode nextSibling = following.NextSibling; - if (nextSibling != null) - { - following = nextSibling; - break; - } - else - { - XmlNode parent = following.ParentNode; - if (parent != null) - { - following = parent; - } - else - { - return false; - } - } - } - } - if (following == pastFollowing) - { - return false; - } - } - while (((1 << (int)following.XPNodeType) & mask) == 0); - - _source = following; - return true; - } - - public override bool MoveToNext(string localName, string namespaceUri) - { - XmlNode sibling = NextSibling(_source); - if (sibling == null) - { - return false; - } - do - { - if (sibling.NodeType == XmlNodeType.Element - && sibling.LocalName == localName - && sibling.NamespaceURI == namespaceUri) - { - _source = sibling; - return true; - } - sibling = NextSibling(sibling); - } - while (sibling != null); - return false; - } - - public override bool MoveToNext(XPathNodeType type) - { - XmlNode sibling = NextSibling(_source); - if (sibling == null) - { - return false; - } - if (sibling.IsText - && _source.IsText) - { - sibling = NextSibling(TextEnd(sibling)); - if (sibling == null) - { - return false; - } - } - - int mask = GetContentKindMask(type); - if (mask == 0) - { - return false; - } - do - { - if (((1 << (int)sibling.XPNodeType) & mask) != 0) - { - _source = sibling; - return true; - } - sibling = NextSibling(sibling); - } - while (sibling != null); - return false; - } - - public override bool HasChildren - { - get - { - XmlNode child; - switch (_source.NodeType) - { - case XmlNodeType.Element: - child = FirstChild(_source); - if (child == null) - { - return false; - } - return true; - case XmlNodeType.DocumentFragment: - case XmlNodeType.Document: - child = FirstChild(_source); - if (child == null) - { - return false; - } - while (!IsValidChild(_source, child)) - { - child = NextSibling(child); - if (child == null) - { - return false; - } - } - return true; - default: - return false; - } - } - } - - public override bool IsSamePosition(XPathNavigator other) - { - DocumentXPathNavigator that = other as DocumentXPathNavigator; - if (that != null) - { - this.CalibrateText(); - that.CalibrateText(); - - return _source == that._source - && _namespaceParent == that._namespaceParent; - } - return false; - } - - public override bool IsDescendant(XPathNavigator other) - { - DocumentXPathNavigator that = other as DocumentXPathNavigator; - if (that != null) - { - return IsDescendant(_source, that._source); - } - return false; - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - return _source.SchemaInfo; - } - } - - public override bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler) - { - XmlDocument ownerDocument; - - if (_source.NodeType == XmlNodeType.Document) - { - ownerDocument = (XmlDocument)_source; - } - else - { - ownerDocument = _source.OwnerDocument; - - if (schemas != null) - { - throw new ArgumentException(string.Format(ResXml.XPathDocument_SchemaSetNotAllowed, null)); - } - } - if (schemas == null && ownerDocument != null) - { - schemas = ownerDocument.Schemas; - } - - if (schemas == null || schemas.Count == 0) - { - throw new InvalidOperationException(ResXml.XmlDocument_NoSchemaInfo); - } - - DocumentSchemaValidator validator = new DocumentSchemaValidator(ownerDocument, schemas, validationEventHandler); - validator.PsviAugmentation = false; - return validator.Validate(_source); - } - - private static XmlNode OwnerNode(XmlNode node) - { - XmlNode parent = node.ParentNode; - if (parent != null) - { - return parent; - } - XmlAttribute attribute = node as XmlAttribute; - if (attribute != null) - { - return attribute.OwnerElement; - } - return null; - } - - private static int GetDepth(XmlNode node) - { - int depth = 0; - XmlNode owner = OwnerNode(node); - while (owner != null) - { - depth++; - owner = OwnerNode(owner); - } - return depth; - } - - //Assuming that node1 and node2 are in the same level; Except when they are namespace nodes, they should have the same parent node - //the returned value is node2's position corresponding to node1 - private XmlNodeOrder Compare(XmlNode node1, XmlNode node2) - { - Debug.Assert(node1 != null); - Debug.Assert(node2 != null); - Debug.Assert(node1 != node2, "Should be handled by ComparePosition()"); - //Attribute nodes come before other children nodes except namespace nodes - Debug.Assert(OwnerNode(node1) == OwnerNode(node2)); - if (node1.XPNodeType == XPathNodeType.Attribute) - { - if (node2.XPNodeType == XPathNodeType.Attribute) - { - XmlElement element = ((XmlAttribute)node1).OwnerElement; - if (element.HasAttributes) - { - XmlAttributeCollection attributes = element.Attributes; - for (int i = 0; i < attributes.Count; i++) - { - XmlAttribute attribute = attributes[i]; - if (attribute == node1) - { - return XmlNodeOrder.Before; - } - else if (attribute == node2) - { - return XmlNodeOrder.After; - } - } - } - return XmlNodeOrder.Unknown; - } - else - { - return XmlNodeOrder.Before; - } - } - if (node2.XPNodeType == XPathNodeType.Attribute) - { - return XmlNodeOrder.After; - } - - //neither of the node is Namespace node or Attribute node - XmlNode nextNode = node1.NextSibling; - while (nextNode != null && nextNode != node2) - nextNode = nextNode.NextSibling; - if (nextNode == null) - //didn't meet node2 in the path to the end, thus it has to be in the front of node1 - return XmlNodeOrder.After; - else - //met node2 in the path to the end, so node1 is at front - return XmlNodeOrder.Before; - } - - public override XmlNodeOrder ComparePosition(XPathNavigator other) - { - DocumentXPathNavigator that = other as DocumentXPathNavigator; - if (that == null) - { - return XmlNodeOrder.Unknown; - } - - this.CalibrateText(); - that.CalibrateText(); - - if (_source == that._source - && _namespaceParent == that._namespaceParent) - { - return XmlNodeOrder.Same; - } - - if (_namespaceParent != null - || that._namespaceParent != null) - { - return base.ComparePosition(other); - } - - XmlNode node1 = _source; - XmlNode node2 = that._source; - - XmlNode parent1 = OwnerNode(node1); - XmlNode parent2 = OwnerNode(node2); - if (parent1 == parent2) - { - if (parent1 == null) - { - return XmlNodeOrder.Unknown; - } - else - { - Debug.Assert(node1 != node2); - return Compare(node1, node2); - } - } - - int depth1 = GetDepth(node1); - int depth2 = GetDepth(node2); - if (depth2 > depth1) - { - while (node2 != null - && depth2 > depth1) - { - node2 = OwnerNode(node2); - depth2--; - } - if (node1 == node2) - { - return XmlNodeOrder.Before; - } - parent2 = OwnerNode(node2); - } - else if (depth1 > depth2) - { - while (node1 != null - && depth1 > depth2) - { - node1 = OwnerNode(node1); - depth1--; - } - if (node1 == node2) - { - return XmlNodeOrder.After; - } - parent1 = OwnerNode(node1); - } - - while (parent1 != null - && parent2 != null) - { - if (parent1 == parent2) - { - Debug.Assert(node1 != node2); - return Compare(node1, node2); - } - node1 = parent1; - node2 = parent2; - parent1 = OwnerNode(node1); - parent2 = OwnerNode(node2); - } - return XmlNodeOrder.Unknown; - } - - //the function just for XPathNodeList to enumerate current Node. - XmlNode IHasXmlNode.GetNode() { return _source; } - - public override XPathNodeIterator SelectDescendants(string localName, string namespaceURI, bool matchSelf) - { - string nsAtom = _document.NameTable.Get(namespaceURI); - if (nsAtom == null || _source.NodeType == XmlNodeType.Attribute) - return new DocumentXPathNodeIterator_Empty(this); - - Debug.Assert(this.NodeType != XPathNodeType.Attribute && this.NodeType != XPathNodeType.Namespace && this.NodeType != XPathNodeType.All); - - string localNameAtom = _document.NameTable.Get(localName); - if (localNameAtom == null) - return new DocumentXPathNodeIterator_Empty(this); - - if (localNameAtom.Length == 0) - { - if (matchSelf) - return new DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName(this, nsAtom); - return new DocumentXPathNodeIterator_ElemChildren_NoLocalName(this, nsAtom); - } - - if (matchSelf) - return new DocumentXPathNodeIterator_ElemChildren_AndSelf(this, localNameAtom, nsAtom); - return new DocumentXPathNodeIterator_ElemChildren(this, localNameAtom, nsAtom); - } - - public override XPathNodeIterator SelectDescendants(XPathNodeType nt, bool includeSelf) - { - if (nt == XPathNodeType.Element) - { - XmlNodeType curNT = _source.NodeType; - if (curNT != XmlNodeType.Document && curNT != XmlNodeType.Element) - { - //only Document, Entity, Element node can have Element node as children ( descendant ) - //entity nodes should be invisible to XPath data model - return new DocumentXPathNodeIterator_Empty(this); - } - if (includeSelf) - return new DocumentXPathNodeIterator_AllElemChildren_AndSelf(this); - return new DocumentXPathNodeIterator_AllElemChildren(this); - } - return base.SelectDescendants(nt, includeSelf); - } - - public override bool CanEdit - { - get - { - return true; - } - } - - public override XmlWriter PrependChild() - { - switch (_source.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.PrependChild, _source, _document); - writer.NamespaceManager = GetNamespaceManager(_source, _document); - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override XmlWriter AppendChild() - { - switch (_source.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendChild, _source, _document); - writer.NamespaceManager = GetNamespaceManager(_source, _document); - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override XmlWriter InsertAfter() - { - XmlNode node = _source; - - switch (node.NodeType) - { - case XmlNodeType.Attribute: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - node = TextEnd(node); - break; - default: - break; - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.InsertSiblingAfter, node, _document); - writer.NamespaceManager = GetNamespaceManager(node.ParentNode, _document); - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override XmlWriter InsertBefore() - { - switch (_source.NodeType) - { - case XmlNodeType.Attribute: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - CalibrateText(); - - break; - default: - break; - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.InsertSiblingBefore, _source, _document); - writer.NamespaceManager = GetNamespaceManager(_source.ParentNode, _document); - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override XmlWriter CreateAttributes() - { - if (_source.NodeType != XmlNodeType.Element) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.AppendAttribute, _source, _document); - writer.NamespaceManager = GetNamespaceManager(_source, _document); - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace) - { - DocumentXPathNavigator that = lastSiblingToReplace as DocumentXPathNavigator; - if (that == null) - { - if (lastSiblingToReplace == null) - { - throw new ArgumentNullException("lastSiblingToReplace"); - } - else - { - throw new NotSupportedException(); - } - } - - this.CalibrateText(); - that.CalibrateText(); - - XmlNode node = _source; - XmlNode end = that._source; - - if (node == end) - { - switch (node.NodeType) - { - case XmlNodeType.Attribute: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - end = that.TextEnd(end); - break; - default: - break; - } - } - else - { - if (end.IsText) - { - end = that.TextEnd(end); - } - if (!IsFollowingSibling(node, end)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - } - - DocumentXmlWriter writer = new DocumentXmlWriter(DocumentXmlWriterType.ReplaceToFollowingSibling, node, _document); - writer.NamespaceManager = GetNamespaceManager(node.ParentNode, _document); - writer.Navigator = this; - writer.EndNode = end; - return new XmlWellFormedWriter(writer, writer.Settings); - } - - public override void DeleteRange(XPathNavigator lastSiblingToDelete) - { - DocumentXPathNavigator that = lastSiblingToDelete as DocumentXPathNavigator; - if (that == null) - { - if (lastSiblingToDelete == null) - { - throw new ArgumentNullException("lastSiblingToDelete"); - } - else - { - throw new NotSupportedException(); - } - } - - this.CalibrateText(); - that.CalibrateText(); - - XmlNode node = _source; - XmlNode end = that._source; - - if (node == end) - { - switch (node.NodeType) - { - case XmlNodeType.Attribute: - XmlAttribute attribute = (XmlAttribute)node; - if (attribute.IsNamespace) - { - goto default; - } - XmlNode parent = OwnerNode(attribute); - DeleteAttribute(attribute, _attributeIndex); - if (parent != null) - { - ResetPosition(parent); - } - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - end = that.TextEnd(end); - goto case XmlNodeType.Element; - case XmlNodeType.Element: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - parent = OwnerNode(node); - DeleteToFollowingSibling(node, end); - if (parent != null) - { - ResetPosition(parent); - } - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - } - else - { - if (end.IsText) - { - end = that.TextEnd(end); - } - if (!IsFollowingSibling(node, end)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlNode parent = OwnerNode(node); - DeleteToFollowingSibling(node, end); - if (parent != null) - { - ResetPosition(parent); - } - } - } - - public override void DeleteSelf() - { - XmlNode node = _source; - XmlNode end = node; - - switch (node.NodeType) - { - case XmlNodeType.Attribute: - XmlAttribute attribute = (XmlAttribute)node; - if (attribute.IsNamespace) - { - goto default; - } - XmlNode parent = OwnerNode(attribute); - DeleteAttribute(attribute, _attributeIndex); - if (parent != null) - { - ResetPosition(parent); - } - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - CalibrateText(); - - node = _source; - end = TextEnd(node); - goto case XmlNodeType.Element; - case XmlNodeType.Element: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - parent = OwnerNode(node); - DeleteToFollowingSibling(node, end); - if (parent != null) - { - ResetPosition(parent); - } - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - } - - private static void DeleteAttribute(XmlAttribute attribute, int index) - { - XmlAttributeCollection attributes; - - if (!CheckAttributePosition(attribute, out attributes, index) - && !ResetAttributePosition(attribute, attributes, out index)) - { - throw new InvalidOperationException(ResXml.Xpn_MissingParent); - } - if (attribute.IsReadOnly) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Modify_ReadOnly); - } - attributes.RemoveAt(index); - } - - internal static void DeleteToFollowingSibling(XmlNode node, XmlNode end) - { - XmlNode parent = node.ParentNode; - - if (parent == null) - { - throw new InvalidOperationException(ResXml.Xpn_MissingParent); - } - if (node.IsReadOnly - || end.IsReadOnly) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Modify_ReadOnly); - } - while (node != end) - { - XmlNode temp = node; - node = node.NextSibling; - parent.RemoveChild(temp); - } - parent.RemoveChild(node); - } - - private static XmlNamespaceManager GetNamespaceManager(XmlNode node, XmlDocument document) - { - XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable); - List elements = new List(); - - while (node != null) - { - XmlElement element = node as XmlElement; - if (element != null - && element.HasAttributes) - { - elements.Add(element); - } - node = node.ParentNode; - } - for (int i = elements.Count - 1; i >= 0; i--) - { - namespaceManager.PushScope(); - XmlAttributeCollection attributes = elements[i].Attributes; - for (int j = 0; j < attributes.Count; j++) - { - XmlAttribute attribute = attributes[j]; - if (attribute.IsNamespace) - { - string prefix = attribute.Prefix.Length == 0 ? string.Empty : attribute.LocalName; - namespaceManager.AddNamespace(prefix, attribute.Value); - } - } - } - return namespaceManager; - } - - internal void ResetPosition(XmlNode node) - { - Debug.Assert(node != null, "Undefined navigator position"); - Debug.Assert(node == _document || node.OwnerDocument == _document, "Navigator switched documents"); - _source = node; - XmlAttribute attribute = node as XmlAttribute; - if (attribute != null) - { - XmlElement element = attribute.OwnerElement; - if (element != null) - { - ResetAttributePosition(attribute, element.Attributes, out _attributeIndex); - if (attribute.IsNamespace) - { - _namespaceParent = element; - } - } - } - } - - private static bool ResetAttributePosition(XmlAttribute attribute, XmlAttributeCollection attributes, out int index) - { - if (attributes != null) - { - for (int i = 0; i < attributes.Count; i++) - { - if (attribute == attributes[i]) - { - index = i; - return true; - } - } - } - index = 0; - return false; - } - - private static bool CheckAttributePosition(XmlAttribute attribute, out XmlAttributeCollection attributes, int index) - { - XmlElement element = attribute.OwnerElement; - if (element != null) - { - attributes = element.Attributes; - if (index >= 0 - && index < attributes.Count - && attribute == attributes[index]) - { - return true; - } - } - else - { - attributes = null; - } - return false; - } - - private void CalibrateText() - { - XmlNode text = PreviousText(_source); - while (text != null) - { - ResetPosition(text); - text = PreviousText(text); - } - } - - private XmlNode ParentNode(XmlNode node) - { - XmlNode parent = node.ParentNode; - - if (!_document.HasEntityReferences) - { - return parent; - } - return ParentNodeTail(parent); - } - - private XmlNode ParentNodeTail(XmlNode parent) - { - while (parent != null - && parent.NodeType == XmlNodeType.EntityReference) - { - parent = parent.ParentNode; - } - return parent; - } - - private XmlNode FirstChild(XmlNode node) - { - XmlNode child = node.FirstChild; - - if (!_document.HasEntityReferences) - { - return child; - } - return FirstChildTail(child); - } - - private XmlNode FirstChildTail(XmlNode child) - { - while (child != null - && child.NodeType == XmlNodeType.EntityReference) - { - child = child.FirstChild; - } - return child; - } - - private XmlNode NextSibling(XmlNode node) - { - XmlNode sibling = node.NextSibling; - - if (!_document.HasEntityReferences) - { - return sibling; - } - return NextSiblingTail(node, sibling); - } - - private XmlNode NextSiblingTail(XmlNode node, XmlNode sibling) - { - while (sibling == null) - { - node = node.ParentNode; - if (node == null - || node.NodeType != XmlNodeType.EntityReference) - { - return null; - } - sibling = node.NextSibling; - } - while (sibling != null - && sibling.NodeType == XmlNodeType.EntityReference) - { - sibling = sibling.FirstChild; - } - return sibling; - } - - private XmlNode PreviousSibling(XmlNode node) - { - XmlNode sibling = node.PreviousSibling; - - if (!_document.HasEntityReferences) - { - return sibling; - } - return PreviousSiblingTail(node, sibling); - } - - private XmlNode PreviousSiblingTail(XmlNode node, XmlNode sibling) - { - while (sibling == null) - { - node = node.ParentNode; - if (node == null - || node.NodeType != XmlNodeType.EntityReference) - { - return null; - } - sibling = node.PreviousSibling; - } - while (sibling != null - && sibling.NodeType == XmlNodeType.EntityReference) - { - sibling = sibling.LastChild; - } - return sibling; - } - - private XmlNode PreviousText(XmlNode node) - { - XmlNode text = node.PreviousText; - - if (!_document.HasEntityReferences) - { - return text; - } - return PreviousTextTail(node, text); - } - - private XmlNode PreviousTextTail(XmlNode node, XmlNode text) - { - if (text != null) - { - return text; - } - if (!node.IsText) - { - return null; - } - XmlNode sibling = node.PreviousSibling; - while (sibling == null) - { - node = node.ParentNode; - if (node == null - || node.NodeType != XmlNodeType.EntityReference) - { - return null; - } - sibling = node.PreviousSibling; - } - while (sibling != null) - { - switch (sibling.NodeType) - { - case XmlNodeType.EntityReference: - sibling = sibling.LastChild; - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return sibling; - default: - return null; - } - } - return null; - } - - internal static bool IsFollowingSibling(XmlNode left, XmlNode right) - { - for (; ; ) - { - left = left.NextSibling; - if (left == null) - { - break; - } - if (left == right) - { - return true; - } - } - return false; - } - - private static bool IsDescendant(XmlNode top, XmlNode bottom) - { - for (; ; ) - { - XmlNode parent = bottom.ParentNode; - if (parent == null) - { - XmlAttribute attribute = bottom as XmlAttribute; - if (attribute == null) - { - break; - } - parent = attribute.OwnerElement; - if (parent == null) - { - break; - } - } - bottom = parent; - if (top == bottom) - { - return true; - } - } - return false; - } - - private static bool IsValidChild(XmlNode parent, XmlNode child) - { - switch (parent.NodeType) - { - case XmlNodeType.Element: - return true; - case XmlNodeType.DocumentFragment: - switch (child.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return true; - } - break; - case XmlNodeType.Document: - switch (child.NodeType) - { - case XmlNodeType.Element: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - return true; - } - break; - default: - break; - } - return false; - } - - private XmlNode TextStart(XmlNode node) - { - XmlNode start; - - do - { - start = node; - node = PreviousSibling(node); - } - while (node != null - && node.IsText); - return start; - } - - private XmlNode TextEnd(XmlNode node) - { - XmlNode end; - - do - { - end = node; - node = NextSibling(node); - } - while (node != null - && node.IsText); - return end; - } - } - - // An iterator that matches no nodes - internal sealed class DocumentXPathNodeIterator_Empty : XPathNodeIterator - { - private XPathNavigator _nav; - - internal DocumentXPathNodeIterator_Empty(DocumentXPathNavigator nav) { _nav = nav.Clone(); } - internal DocumentXPathNodeIterator_Empty(DocumentXPathNodeIterator_Empty other) { _nav = other._nav.Clone(); } - public override XPathNodeIterator Clone() { return new DocumentXPathNodeIterator_Empty(this); } - public override bool MoveNext() { return false; } - public override XPathNavigator Current { get { return _nav; } } - public override int CurrentPosition { get { return 0; } } - public override int Count { get { return 0; } } - } - - // An iterator that can match any child elements that match the Match condition (overrided in the derived class) - internal abstract class DocumentXPathNodeIterator_ElemDescendants : XPathNodeIterator - { - private DocumentXPathNavigator _nav; - private int _level; - private int _position; - - internal DocumentXPathNodeIterator_ElemDescendants(DocumentXPathNavigator nav) - { - _nav = (DocumentXPathNavigator)(nav.Clone()); - _level = 0; - _position = 0; - } - internal DocumentXPathNodeIterator_ElemDescendants(DocumentXPathNodeIterator_ElemDescendants other) - { - _nav = (DocumentXPathNavigator)(other._nav.Clone()); - _level = other._level; - _position = other._position; - } - - protected abstract bool Match(XmlNode node); - - public override XPathNavigator Current - { - get { return _nav; } - } - - public override int CurrentPosition - { - get { return _position; } - } - - protected void SetPosition(int pos) - { - _position = pos; - } - - public override bool MoveNext() - { - for (; ; ) - { - if (_nav.MoveToFirstChild()) - { - _level++; - } - else - { - if (_level == 0) - { - return false; - } - while (!_nav.MoveToNext()) - { - _level--; - if (_level == 0) - { - return false; - } - if (!_nav.MoveToParent()) - { - return false; - } - } - } - XmlNode node = (XmlNode)_nav.UnderlyingObject; - if (node.NodeType == XmlNodeType.Element && Match(node)) - { - _position++; - return true; - } - } - } - } - - // Iterate over all element children irrespective of the localName and namespace - internal class DocumentXPathNodeIterator_AllElemChildren : DocumentXPathNodeIterator_ElemDescendants - { - internal DocumentXPathNodeIterator_AllElemChildren(DocumentXPathNavigator nav) : base(nav) - { - Debug.Assert(((XmlNode)nav.UnderlyingObject).NodeType != XmlNodeType.Attribute); - } - internal DocumentXPathNodeIterator_AllElemChildren(DocumentXPathNodeIterator_AllElemChildren other) : base(other) - { - } - - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_AllElemChildren(this); - } - - protected override bool Match(XmlNode node) - { - Debug.Assert(node != null); - return (node.NodeType == XmlNodeType.Element); - } - } - // Iterate over all element children irrespective of the localName and namespace, include the self node when testing for localName/ns - internal sealed class DocumentXPathNodeIterator_AllElemChildren_AndSelf : DocumentXPathNodeIterator_AllElemChildren - { - internal DocumentXPathNodeIterator_AllElemChildren_AndSelf(DocumentXPathNavigator nav) : base(nav) - { - } - internal DocumentXPathNodeIterator_AllElemChildren_AndSelf(DocumentXPathNodeIterator_AllElemChildren_AndSelf other) : base(other) - { - } - - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_AllElemChildren_AndSelf(this); - } - - public override bool MoveNext() - { - if (CurrentPosition == 0) - { - DocumentXPathNavigator nav = (DocumentXPathNavigator)this.Current; - XmlNode node = (XmlNode)nav.UnderlyingObject; - if (node.NodeType == XmlNodeType.Element && Match(node)) - { - SetPosition(1); - return true; - } - } - return base.MoveNext(); - } - } - // Iterate over all element children that have a given namespace but irrespective of the localName - internal class DocumentXPathNodeIterator_ElemChildren_NoLocalName : DocumentXPathNodeIterator_ElemDescendants - { - private string _nsAtom; - - internal DocumentXPathNodeIterator_ElemChildren_NoLocalName(DocumentXPathNavigator nav, string nsAtom) : base(nav) - { - Debug.Assert(((XmlNode)nav.UnderlyingObject).NodeType != XmlNodeType.Attribute); - Debug.Assert(Ref.Equal(nav.NameTable.Get(nsAtom), nsAtom)); - _nsAtom = nsAtom; - } - internal DocumentXPathNodeIterator_ElemChildren_NoLocalName(DocumentXPathNodeIterator_ElemChildren_NoLocalName other) : base(other) - { - _nsAtom = other._nsAtom; - } - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_ElemChildren_NoLocalName(this); - } - - protected override bool Match(XmlNode node) - { - Debug.Assert(node != null); - Debug.Assert(node.NodeType == XmlNodeType.Element); - return Ref.Equal(node.NamespaceURI, _nsAtom); - } - } - // Iterate over all element children that have a given namespace but irrespective of the localName, include self node when checking for ns - internal sealed class DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName : DocumentXPathNodeIterator_ElemChildren_NoLocalName - { - internal DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName(DocumentXPathNavigator nav, string nsAtom) : base(nav, nsAtom) - { - } - internal DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName(DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName other) : base(other) - { - } - - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName(this); - } - - public override bool MoveNext() - { - if (CurrentPosition == 0) - { - DocumentXPathNavigator nav = (DocumentXPathNavigator)this.Current; - XmlNode node = (XmlNode)nav.UnderlyingObject; - if (node.NodeType == XmlNodeType.Element && Match(node)) - { - SetPosition(1); - return true; - } - } - return base.MoveNext(); - } - } - // Iterate over all element children that have a given name and namespace - internal class DocumentXPathNodeIterator_ElemChildren : DocumentXPathNodeIterator_ElemDescendants - { - protected string localNameAtom; - protected string nsAtom; - - internal DocumentXPathNodeIterator_ElemChildren(DocumentXPathNavigator nav, string localNameAtom, string nsAtom) : base(nav) - { - Debug.Assert(((XmlNode)nav.UnderlyingObject).NodeType != XmlNodeType.Attribute); - Debug.Assert(Ref.Equal(nav.NameTable.Get(localNameAtom), localNameAtom)); - Debug.Assert(Ref.Equal(nav.NameTable.Get(nsAtom), nsAtom)); - Debug.Assert(localNameAtom.Length > 0); // Use DocumentXPathNodeIterator_ElemChildren_NoLocalName class for special magic value of localNameAtom - - this.localNameAtom = localNameAtom; - this.nsAtom = nsAtom; - } - - internal DocumentXPathNodeIterator_ElemChildren(DocumentXPathNodeIterator_ElemChildren other) : base(other) - { - this.localNameAtom = other.localNameAtom; - this.nsAtom = other.nsAtom; - } - - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_ElemChildren(this); - } - - protected override bool Match(XmlNode node) - { - Debug.Assert(node != null); - Debug.Assert(node.NodeType == XmlNodeType.Element); - return Ref.Equal(node.LocalName, localNameAtom) && Ref.Equal(node.NamespaceURI, nsAtom); - } - } - // Iterate over all elem children and itself and check for the given localName (including the magic value "") and namespace - internal sealed class DocumentXPathNodeIterator_ElemChildren_AndSelf : DocumentXPathNodeIterator_ElemChildren - { - internal DocumentXPathNodeIterator_ElemChildren_AndSelf(DocumentXPathNavigator nav, string localNameAtom, string nsAtom) - : base(nav, localNameAtom, nsAtom) - { - Debug.Assert(localNameAtom.Length > 0); // Use DocumentXPathNodeIterator_ElemChildren_AndSelf_NoLocalName if localName == String.Empty - } - internal DocumentXPathNodeIterator_ElemChildren_AndSelf(DocumentXPathNodeIterator_ElemChildren_AndSelf other) : base(other) - { - } - - public override XPathNodeIterator Clone() - { - return new DocumentXPathNodeIterator_ElemChildren_AndSelf(this); - } - - public override bool MoveNext() - { - if (CurrentPosition == 0) - { - DocumentXPathNavigator nav = (DocumentXPathNavigator)this.Current; - XmlNode node = (XmlNode)nav.UnderlyingObject; - if (node.NodeType == XmlNodeType.Element && Match(node)) - { - SetPosition(1); - return true; - } - } - return base.MoveNext(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXmlWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXmlWriter.cs deleted file mode 100644 index e01a4239eb6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DocumentXmlWriter.cs +++ /dev/null @@ -1,615 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - internal enum DocumentXmlWriterType - { - InsertSiblingAfter, - InsertSiblingBefore, - PrependChild, - AppendChild, - AppendAttribute, - ReplaceToFollowingSibling, - } - - // Implements a XmlWriter that augments a XmlDocument. - internal sealed class DocumentXmlWriter : XmlRawWriter, IXmlNamespaceResolver - { - private enum State - { - Error, - Attribute, - Prolog, - Fragment, - Content, - - Last, // always last - } - - private enum Method - { - WriteXmlDeclaration, - WriteStartDocument, - WriteEndDocument, - WriteDocType, - WriteStartElement, - WriteEndElement, - WriteFullEndElement, - WriteStartAttribute, - WriteEndAttribute, - WriteStartNamespaceDeclaration, - WriteEndNamespaceDeclaration, - WriteCData, - WriteComment, - WriteProcessingInstruction, - WriteEntityRef, - WriteWhitespace, - WriteString, - } - - private DocumentXmlWriterType _type; // writer type - private XmlNode _start; // context node - private XmlDocument _document; // context document - private XmlNamespaceManager _namespaceManager; // context namespace manager - private State _state; // current state - private XmlNode _write; // current node - private List _fragment; // top level node cache - private XmlWriterSettings _settings; // wrapping writer settings - private DocumentXPathNavigator _navigator; // context for replace - private XmlNode _end; // context for replace - - public DocumentXmlWriter(DocumentXmlWriterType type, XmlNode start, XmlDocument document) - { - _type = type; - _start = start; - _document = document; - - _state = StartState(); - _fragment = new List(); - _settings = new XmlWriterSettings(); - _settings.ReadOnly = false; - _settings.CheckCharacters = false; - _settings.CloseOutput = false; - _settings.ConformanceLevel = (_state == State.Prolog ? ConformanceLevel.Document : ConformanceLevel.Fragment); - _settings.ReadOnly = true; - } - - public XmlNamespaceManager NamespaceManager - { - set - { - _namespaceManager = value; - } - } - - public override XmlWriterSettings Settings - { - get - { - return _settings; - } - } - - internal void SetSettings(XmlWriterSettings value) - { - _settings = value; - } - - public DocumentXPathNavigator Navigator - { - set - { - _navigator = value; - } - } - - public XmlNode EndNode - { - set - { - _end = value; - } - } - - internal override void WriteXmlDeclaration(XmlStandalone standalone) - { - VerifyState(Method.WriteXmlDeclaration); - if (standalone != XmlStandalone.Omit) - { - XmlNode node = _document.CreateXmlDeclaration("1.0", string.Empty, standalone == XmlStandalone.Yes ? "yes" : "no"); - AddChild(node, _write); - } - } - - internal override void WriteXmlDeclaration(string xmldecl) - { - VerifyState(Method.WriteXmlDeclaration); - string version, encoding, standalone; - XmlLoader.ParseXmlDeclarationValue(xmldecl, out version, out encoding, out standalone); - XmlNode node = _document.CreateXmlDeclaration(version, encoding, standalone); - AddChild(node, _write); - } - - public override void WriteStartDocument() - { - VerifyState(Method.WriteStartDocument); - } - - public override void WriteStartDocument(bool standalone) - { - VerifyState(Method.WriteStartDocument); - } - - public override void WriteEndDocument() - { - VerifyState(Method.WriteEndDocument); - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - VerifyState(Method.WriteDocType); - XmlNode node = _document.CreateDocumentType(name, pubid, sysid, subset); - AddChild(node, _write); - } - - public override void WriteStartElement(string prefix, string localName, string ns) - { - VerifyState(Method.WriteStartElement); - XmlNode node = _document.CreateElement(prefix, localName, ns); - AddChild(node, _write); - _write = node; - } - - public override void WriteEndElement() - { - VerifyState(Method.WriteEndElement); - if (_write == null) - { - throw new InvalidOperationException(); - } - _write = _write.ParentNode; - } - - internal override void WriteEndElement(string prefix, string localName, string ns) - { - WriteEndElement(); - } - - public override void WriteFullEndElement() - { - VerifyState(Method.WriteFullEndElement); - XmlElement elem = _write as XmlElement; - if (elem == null) - { - throw new InvalidOperationException(); - } - elem.IsEmpty = false; - _write = elem.ParentNode; - } - - internal override void WriteFullEndElement(string prefix, string localName, string ns) - { - WriteFullEndElement(); - } - - internal override void StartElementContent() - { - // nop - } - - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - VerifyState(Method.WriteStartAttribute); - XmlAttribute attr = _document.CreateAttribute(prefix, localName, ns); - AddAttribute(attr, _write); - _write = attr; - } - - public override void WriteEndAttribute() - { - VerifyState(Method.WriteEndAttribute); - XmlAttribute attr = _write as XmlAttribute; - if (attr == null) - { - throw new InvalidOperationException(); - } - if (!attr.HasChildNodes) - { - XmlNode node = _document.CreateTextNode(string.Empty); - AddChild(node, attr); - } - _write = attr.OwnerElement; - } - - internal override void WriteNamespaceDeclaration(string prefix, string ns) - { - this.WriteStartNamespaceDeclaration(prefix); - this.WriteString(ns); - this.WriteEndNamespaceDeclaration(); - } - - internal override bool SupportsNamespaceDeclarationInChunks - { - get - { - return true; - } - } - - internal override void WriteStartNamespaceDeclaration(string prefix) - { - VerifyState(Method.WriteStartNamespaceDeclaration); - XmlAttribute attr; - if (prefix.Length == 0) - { - attr = _document.CreateAttribute(prefix, _document.strXmlns, _document.strReservedXmlns); - } - else - { - attr = _document.CreateAttribute(_document.strXmlns, prefix, _document.strReservedXmlns); - } - AddAttribute(attr, _write); - _write = attr; - } - - internal override void WriteEndNamespaceDeclaration() - { - VerifyState(Method.WriteEndNamespaceDeclaration); - XmlAttribute attr = _write as XmlAttribute; - if (attr == null) - { - throw new InvalidOperationException(); - } - if (!attr.HasChildNodes) - { - XmlNode node = _document.CreateTextNode(string.Empty); - AddChild(node, attr); - } - _write = attr.OwnerElement; - } - - public override void WriteCData(string text) - { - VerifyState(Method.WriteCData); - XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException); - XmlNode node = _document.CreateCDataSection(text); - AddChild(node, _write); - } - - public override void WriteComment(string text) - { - VerifyState(Method.WriteComment); - XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException); - XmlNode node = _document.CreateComment(text); - AddChild(node, _write); - } - - public override void WriteProcessingInstruction(string name, string text) - { - VerifyState(Method.WriteProcessingInstruction); - XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException); - XmlNode node = _document.CreateProcessingInstruction(name, text); - AddChild(node, _write); - } - - public override void WriteEntityRef(string name) - { - VerifyState(Method.WriteEntityRef); - XmlNode node = _document.CreateEntityReference(name); - AddChild(node, _write); - // REVIEW: the namespace scope is incorrect(?) unless write == null - } - - public override void WriteCharEntity(char ch) - { - WriteString(new string(ch, 1)); - } - - public override void WriteWhitespace(string text) - { - VerifyState(Method.WriteWhitespace); - XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException); - if (_document.PreserveWhitespace) - { - XmlNode node = _document.CreateWhitespace(text); - AddChild(node, _write); - } - } - - public override void WriteString(string text) - { - VerifyState(Method.WriteString); - XmlConvert.VerifyCharData(text, ExceptionType.ArgumentException); - XmlNode node = _document.CreateTextNode(text); - AddChild(node, _write); - } - - public override void WriteSurrogateCharEntity(char lowCh, char highCh) - { - WriteString(new string(new char[] { highCh, lowCh })); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - WriteString(new string(buffer, index, count)); - } - - public override void WriteRaw(string data) - { - WriteString(data); - } - - public override void Close() - { - // nop - } - - internal override void Close(WriteState currentState) - { - if (currentState == WriteState.Error) - { - return; - } - try - { - switch (_type) - { - case DocumentXmlWriterType.InsertSiblingAfter: - XmlNode parent = _start.ParentNode; - if (parent == null) - { - throw new InvalidOperationException(ResXml.Xpn_MissingParent); - } - for (int i = _fragment.Count - 1; i >= 0; i--) - { - parent.InsertAfter(_fragment[i], _start); - } - break; - case DocumentXmlWriterType.InsertSiblingBefore: - parent = _start.ParentNode; - if (parent == null) - { - throw new InvalidOperationException(ResXml.Xpn_MissingParent); - } - for (int i = 0; i < _fragment.Count; i++) - { - parent.InsertBefore(_fragment[i], _start); - } - break; - case DocumentXmlWriterType.PrependChild: - for (int i = _fragment.Count - 1; i >= 0; i--) - { - _start.PrependChild(_fragment[i]); - } - break; - case DocumentXmlWriterType.AppendChild: - for (int i = 0; i < _fragment.Count; i++) - { - _start.AppendChild(_fragment[i]); - } - break; - case DocumentXmlWriterType.AppendAttribute: - CloseWithAppendAttribute(); - break; - case DocumentXmlWriterType.ReplaceToFollowingSibling: - if (_fragment.Count == 0) - { - throw new InvalidOperationException(ResXml.Xpn_NoContent); - } - CloseWithReplaceToFollowingSibling(); - break; - } - } - finally - { - _fragment.Clear(); - } - } - - private void CloseWithAppendAttribute() - { - XmlElement elem = _start as XmlElement; - Debug.Assert(elem != null); - XmlAttributeCollection attrs = elem.Attributes; - for (int i = 0; i < _fragment.Count; i++) - { - XmlAttribute attr = _fragment[i] as XmlAttribute; - Debug.Assert(attr != null); - int offset = attrs.FindNodeOffsetNS(attr); - if (offset != -1 - && ((XmlAttribute)attrs.nodes[offset]).Specified) - { - throw new XmlException(ResXml.Xml_DupAttributeName, attr.Prefix.Length == 0 ? attr.LocalName : string.Concat(attr.Prefix, ":", attr.LocalName)); - } - } - for (int i = 0; i < _fragment.Count; i++) - { - XmlAttribute attr = _fragment[i] as XmlAttribute; - Debug.Assert(attr != null); - attrs.Append(attr); - } - } - - private void CloseWithReplaceToFollowingSibling() - { - XmlNode parent = _start.ParentNode; - if (parent == null) - { - throw new InvalidOperationException(ResXml.Xpn_MissingParent); - } - if (_start != _end) - { - if (!DocumentXPathNavigator.IsFollowingSibling(_start, _end)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - if (_start.IsReadOnly) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Modify_ReadOnly); - } - DocumentXPathNavigator.DeleteToFollowingSibling(_start.NextSibling, _end); - } - XmlNode fragment0 = _fragment[0]; - parent.ReplaceChild(fragment0, _start); - for (int i = _fragment.Count - 1; i >= 1; i--) - { - parent.InsertAfter(_fragment[i], fragment0); - } - _navigator.ResetPosition(fragment0); - } - - public override void Flush() - { - // nop - } - - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _namespaceManager.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _namespaceManager.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _namespaceManager.LookupPrefix(namespaceName); - } - - private void AddAttribute(XmlAttribute attr, XmlNode parent) - { - if (parent == null) - { - _fragment.Add(attr); - } - else - { - XmlElement elem = parent as XmlElement; - if (elem == null) - { - throw new InvalidOperationException(); - } - elem.Attributes.Append(attr); - } - } - - private void AddChild(XmlNode node, XmlNode parent) - { - if (parent == null) - { - _fragment.Add(node); - } - else - { - parent.AppendChild(node); - } - } - - private State StartState() - { - XmlNodeType nodeType = XmlNodeType.None; - - switch (_type) - { - case DocumentXmlWriterType.InsertSiblingAfter: - case DocumentXmlWriterType.InsertSiblingBefore: - XmlNode parent = _start.ParentNode; - if (parent != null) - { - nodeType = parent.NodeType; - } - if (nodeType == XmlNodeType.Document) - { - return State.Prolog; - } - else if (nodeType == XmlNodeType.DocumentFragment) - { - return State.Fragment; - } - break; - case DocumentXmlWriterType.PrependChild: - case DocumentXmlWriterType.AppendChild: - nodeType = _start.NodeType; - if (nodeType == XmlNodeType.Document) - { - return State.Prolog; - } - else if (nodeType == XmlNodeType.DocumentFragment) - { - return State.Fragment; - } - break; - case DocumentXmlWriterType.AppendAttribute: - return State.Attribute; - case DocumentXmlWriterType.ReplaceToFollowingSibling: - break; - } - return State.Content; - } - - private static State[] s_changeState = { -// State.Error, State.Attribute,State.Prolog, State.Fragment, State.Content, - -// Method.XmlDeclaration: - State.Error, State.Error, State.Prolog, State.Content, State.Error, -// Method.StartDocument: - State.Error, State.Error, State.Error, State.Error, State.Error, -// Method.EndDocument: - State.Error, State.Error, State.Error, State.Error, State.Error, -// Method.DocType: - State.Error, State.Error, State.Prolog, State.Error, State.Error, -// Method.StartElement: - State.Error, State.Error, State.Content, State.Content, State.Content, -// Method.EndElement: - State.Error, State.Error, State.Error, State.Error, State.Content, -// Method.FullEndElement: - State.Error, State.Error, State.Error, State.Error, State.Content, -// Method.StartAttribute: - State.Error, State.Content, State.Error, State.Error, State.Content, -// Method.EndAttribute: - State.Error, State.Error, State.Error, State.Error, State.Content, -// Method.StartNamespaceDeclaration: - State.Error, State.Content, State.Error, State.Error, State.Content, -// Method.EndNamespaceDeclaration: - State.Error, State.Error, State.Error, State.Error, State.Content, -// Method.CData: - State.Error, State.Error, State.Error, State.Content, State.Content, -// Method.Comment: - State.Error, State.Error, State.Prolog, State.Content, State.Content, -// Method.ProcessingInstruction: - State.Error, State.Error, State.Prolog, State.Content, State.Content, -// Method.EntityRef: - State.Error, State.Error, State.Error, State.Content, State.Content, -// Method.Whitespace: - State.Error, State.Error, State.Prolog, State.Content, State.Content, -// Method.String: - State.Error, State.Error, State.Error, State.Content, State.Content, - }; - - private void VerifyState(Method method) - { - _state = s_changeState[(int)method * (int)State.Last + (int)_state]; - if (_state == State.Error) - { - throw new InvalidOperationException(ResXml.Xml_ClosedOrError); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DomNameTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DomNameTable.cs deleted file mode 100644 index 95ee239add6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/DomNameTable.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml -{ - using System; - - - internal class DomNameTable - { - private XmlName[] _entries; - private int _count; - private int _mask; - private XmlDocument _ownerDocument; - private XmlNameTable _nameTable; - - private const int InitialSize = 64; // must be a power of two - - public DomNameTable(XmlDocument document) - { - _ownerDocument = document; - _nameTable = document.NameTable; - _entries = new XmlName[InitialSize]; - _mask = InitialSize - 1; - Debug.Assert((_entries.Length & _mask) == 0); // entries.Length must be a power of two - } - - public XmlName GetName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo) - { - if (prefix == null) - { - prefix = string.Empty; - } - if (ns == null) - { - ns = string.Empty; - } - - int hashCode = XmlName.GetHashCode(localName); - - for (XmlName e = _entries[hashCode & _mask]; e != null; e = e.next) - { - if (e.HashCode == hashCode - && ((object)e.LocalName == (object)localName - || e.LocalName.Equals(localName)) - && ((object)e.Prefix == (object)prefix - || e.Prefix.Equals(prefix)) - && ((object)e.NamespaceURI == (object)ns - || e.NamespaceURI.Equals(ns)) - && e.Equals(schemaInfo)) - { - return e; - } - } - return null; - } - - public XmlName AddName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo) - { - if (prefix == null) - { - prefix = string.Empty; - } - if (ns == null) - { - ns = string.Empty; - } - - int hashCode = XmlName.GetHashCode(localName); - - for (XmlName e = _entries[hashCode & _mask]; e != null; e = e.next) - { - if (e.HashCode == hashCode - && ((object)e.LocalName == (object)localName - || e.LocalName.Equals(localName)) - && ((object)e.Prefix == (object)prefix - || e.Prefix.Equals(prefix)) - && ((object)e.NamespaceURI == (object)ns - || e.NamespaceURI.Equals(ns)) - && e.Equals(schemaInfo)) - { - return e; - } - } - - prefix = _nameTable.Add(prefix); - localName = _nameTable.Add(localName); - ns = _nameTable.Add(ns); - int index = hashCode & _mask; - XmlName name = XmlName.Create(prefix, localName, ns, hashCode, _ownerDocument, _entries[index], schemaInfo); - _entries[index] = name; - - if (_count++ == _mask) - { - Grow(); - } - - return name; - } - - private void Grow() - { - int newMask = _mask * 2 + 1; - XmlName[] oldEntries = _entries; - XmlName[] newEntries = new XmlName[newMask + 1]; - - // use oldEntries.Length to eliminate the rangecheck - for (int i = 0; i < oldEntries.Length; i++) - { - XmlName name = oldEntries[i]; - while (name != null) - { - int newIndex = name.HashCode & newMask; - XmlName tmp = name.next; - name.next = newEntries[newIndex]; - newEntries[newIndex] = name; - name = tmp; - } - } - _entries = newEntries; - _mask = newMask; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XPathNodeList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XPathNodeList.cs deleted file mode 100644 index e49de1180db..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XPathNodeList.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections; - using System.Collections.Generic; - - internal class XPathNodeList : XmlNodeList - { - private List _list; - private XPathNodeIterator _nodeIterator; - private bool _done; - - public XPathNodeList(XPathNodeIterator nodeIterator) - { - _nodeIterator = nodeIterator; - _list = new List(); - _done = false; - } - - public override int Count - { - get - { - if (!_done) - { - ReadUntil(Int32.MaxValue); - } - return _list.Count; - } - } - - private static readonly object[] s_nullparams = { }; - - private XmlNode GetNode(XPathNavigator n) - { - IHasXmlNode iHasNode = (IHasXmlNode)n; - return iHasNode.GetNode(); - } - - internal int ReadUntil(int index) - { - int count = _list.Count; - while (!_done && count <= index) - { - if (_nodeIterator.MoveNext()) - { - XmlNode n = GetNode(_nodeIterator.Current); - if (n != null) - { - _list.Add(n); - count++; - } - } - else - { - _done = true; - break; - } - } - return count; - } - - public override XmlNode Item(int index) - { - if (_list.Count <= index) - { - ReadUntil(index); - } - if (index < 0 || _list.Count <= index) - { - return null; - } - return _list[index]; - } - - public override IEnumerator GetEnumerator() - { - return new XmlNodeListEnumerator(this); - } - } - - internal class XmlNodeListEnumerator : IEnumerator - { - private XPathNodeList _list; - private int _index; - private bool _valid; - - public XmlNodeListEnumerator(XPathNodeList list) - { - _list = list; - _index = -1; - _valid = false; - } - - public void Reset() - { - _index = -1; - } - - public bool MoveNext() - { - _index++; - int count = _list.ReadUntil(_index + 1); // read past for delete-node case - if (count - 1 < _index) - { - return false; - } - _valid = (_list[_index] != null); - return _valid; - } - - public object Current - { - get - { - if (_valid) - { - return _list[_index]; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttribute.cs deleted file mode 100644 index d8c2ebfc09b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttribute.cs +++ /dev/null @@ -1,421 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using Microsoft.Xml.Schema; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - // Represents an attribute of the XMLElement object. Valid and default - // values for the attribute are defined in a DTD or schema. - public class XmlAttribute : XmlNode - { - private XmlName _name; - private XmlLinkedNode _lastChild; - - internal XmlAttribute(XmlName name, XmlDocument doc) : base(doc) - { - Debug.Assert(name != null); - Debug.Assert(doc != null); - this.parentNode = null; - if (!doc.IsLoading) - { - XmlDocument.CheckName(name.Prefix); - XmlDocument.CheckName(name.LocalName); - } - if (name.LocalName.Length == 0) - throw new ArgumentException(ResXml.Xdom_Attr_Name); - _name = name; - } - - internal int LocalNameHash - { - get { return _name.HashCode; } - } - - protected internal XmlAttribute(string prefix, string localName, string namespaceURI, XmlDocument doc) - : this(doc.AddAttrXmlName(prefix, localName, namespaceURI, null), doc) - { - } - - internal XmlName XmlName - { - get { return _name; } - set { _name = value; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - // CloneNode for attributes is deep irrespective of parameter 'deep' value - Debug.Assert(OwnerDocument != null); - XmlDocument doc = OwnerDocument; - XmlAttribute attr = doc.CreateAttribute(Prefix, LocalName, NamespaceURI); - attr.CopyChildren(doc, this, true); - return attr; - } - - // Gets the parent of this node (for nodes that can have parents). - public override XmlNode ParentNode - { - get { return null; } - } - - // Gets the name of the node. - public override String Name - { - get { return _name.Name; } - } - - // Gets the name of the node without the namespace prefix. - public override String LocalName - { - get { return _name.LocalName; } - } - - // Gets the namespace URI of this node. - public override String NamespaceURI - { - get { return _name.NamespaceURI; } - } - - // Gets or sets the namespace prefix of this node. - public override String Prefix - { - get { return _name.Prefix; } - set { _name = _name.OwnerDocument.AddAttrXmlName(value, LocalName, NamespaceURI, SchemaInfo); } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Attribute; } - } - - // Gets the XmlDocument that contains this node. - public override XmlDocument OwnerDocument - { - get - { - return _name.OwnerDocument; - } - } - - // Gets or sets the value of the node. - public override String Value - { - get { return InnerText; } - set { InnerText = value; } //use InnerText which has perf optimization - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - return _name; - } - } - - public override String InnerText - { - set - { - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = base.InnerText; - base.InnerText = value; - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - base.InnerText = value; - } - } - } - - internal bool PrepareOwnerElementInElementIdAttrMap() - { - XmlDocument ownerDocument = OwnerDocument; - if (ownerDocument.DtdSchemaInfo != null) - { // DTD exists - XmlElement ownerElement = OwnerElement; - if (ownerElement != null) - { - return ownerElement.Attributes.PrepareParentInElementIdAttrMap(Prefix, LocalName); - } - } - return false; - } - - internal void ResetOwnerElementInElementIdAttrMap(string oldInnerText) - { - XmlElement ownerElement = OwnerElement; - if (ownerElement != null) - { - ownerElement.Attributes.ResetParentInElementIdAttrMap(oldInnerText, InnerText); - } - } - - internal override bool IsContainer - { - get { return true; } - } - - //the function is provided only at Load time to speed up Load process - internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc) - { - XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(newChild, this); - - if (args != null) - doc.BeforeEvent(args); - - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - - if (_lastChild == null) - { // if LastNode == null - newNode.next = newNode; - _lastChild = newNode; - newNode.SetParentForLoad(this); - } - else - { - XmlLinkedNode refNode = _lastChild; // refNode = LastNode; - newNode.next = refNode.next; - refNode.next = newNode; - _lastChild = newNode; // LastNode = newNode; - if (refNode.IsText - && newNode.IsText) - { - NestTextNodes(refNode, newNode); - } - else - { - newNode.SetParentForLoad(this); - } - } - - if (args != null) - doc.AfterEvent(args); - - return newNode; - } - - internal override XmlLinkedNode LastNode - { - get { return _lastChild; } - set { _lastChild = value; } - } - - internal override bool IsValidChildType(XmlNodeType type) - { - return (type == XmlNodeType.Text) || (type == XmlNodeType.EntityReference); - } - - // Gets a value indicating whether the value was explicitly set. - public virtual bool Specified - { - get { return true; } - } - - public override XmlNode InsertBefore(XmlNode newChild, XmlNode refChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.InsertBefore(newChild, refChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.InsertBefore(newChild, refChild); - } - return node; - } - - public override XmlNode InsertAfter(XmlNode newChild, XmlNode refChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.InsertAfter(newChild, refChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.InsertAfter(newChild, refChild); - } - return node; - } - - public override XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.ReplaceChild(newChild, oldChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.ReplaceChild(newChild, oldChild); - } - return node; - } - - public override XmlNode RemoveChild(XmlNode oldChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.RemoveChild(oldChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.RemoveChild(oldChild); - } - return node; - } - - public override XmlNode PrependChild(XmlNode newChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.PrependChild(newChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.PrependChild(newChild); - } - return node; - } - - public override XmlNode AppendChild(XmlNode newChild) - { - XmlNode node; - if (PrepareOwnerElementInElementIdAttrMap()) - { - string innerText = InnerText; - node = base.AppendChild(newChild); - ResetOwnerElementInElementIdAttrMap(innerText); - } - else - { - node = base.AppendChild(newChild); - } - return node; - } - - // DOM Level 2 - - // Gets the XmlElement node that contains this attribute. - public virtual XmlElement OwnerElement - { - get - { - return parentNode as XmlElement; - } - } - - // Gets or sets the markup representing just the children of this node. - public override string InnerXml - { - set - { - RemoveAll(); - XmlLoader loader = new XmlLoader(); - loader.LoadInnerXmlAttribute(this, value); - } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteStartAttribute(Prefix, LocalName, NamespaceURI); - WriteContentTo(w); - w.WriteEndAttribute(); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - for (XmlNode node = FirstChild; node != null; node = node.NextSibling) - { - node.WriteTo(w); - } - } - - public override String BaseURI - { - get - { - if (OwnerElement != null) - return OwnerElement.BaseURI; - return String.Empty; - } - } - - internal override void SetParent(XmlNode node) - { - this.parentNode = node; - } - - internal override XmlSpace XmlSpace - { - get - { - if (OwnerElement != null) - return OwnerElement.XmlSpace; - return XmlSpace.None; - } - } - - internal override String XmlLang - { - get - { - if (OwnerElement != null) - return OwnerElement.XmlLang; - return String.Empty; - } - } - internal override XPathNodeType XPNodeType - { - get - { - if (IsNamespace) - { - return XPathNodeType.Namespace; - } - return XPathNodeType.Attribute; - } - } - - internal override string XPLocalName - { - get - { - if (_name.Prefix.Length == 0 && _name.LocalName == "xmlns") return string.Empty; - return _name.LocalName; - } - } - - internal bool IsNamespace - { - get - { - return Ref.Equal(_name.NamespaceURI, _name.OwnerDocument.strReservedXmlns); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttributeCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttributeCollection.cs deleted file mode 100644 index 999f0ec8e4f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlAttributeCollection.cs +++ /dev/null @@ -1,416 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml -{ - using System; - using System.Collections; - using System.Diagnostics; - - // Represents a collection of attributes that can be accessed by name or index. - public sealed class XmlAttributeCollection : XmlNamedNodeMap, ICollection - { - internal XmlAttributeCollection(XmlNode parent) : base(parent) - { - } - - // Gets the attribute with the specified index. - [System.Runtime.CompilerServices.IndexerName("ItemOf")] - public XmlAttribute this[int i] - { - get - { - try - { - return (XmlAttribute)nodes[i]; - } - catch (ArgumentOutOfRangeException) - { - throw new IndexOutOfRangeException(ResXml.Xdom_IndexOutOfRange); - } - } - } - - // Gets the attribute with the specified name. - [System.Runtime.CompilerServices.IndexerName("ItemOf")] - public XmlAttribute this[string name] - { - get - { - int hash = XmlName.GetHashCode(name); - - for (int i = 0; i < nodes.Count; i++) - { - XmlAttribute node = (XmlAttribute)nodes[i]; - - if (hash == node.LocalNameHash - && name == node.Name) - { - return node; - } - } - - return null; - } - } - - // Gets the attribute with the specified LocalName and NamespaceUri. - [System.Runtime.CompilerServices.IndexerName("ItemOf")] - public XmlAttribute this[string localName, string namespaceURI] - { - get - { - int hash = XmlName.GetHashCode(localName); - - for (int i = 0; i < nodes.Count; i++) - { - XmlAttribute node = (XmlAttribute)nodes[i]; - - if (hash == node.LocalNameHash - && localName == node.LocalName - && namespaceURI == node.NamespaceURI) - { - return node; - } - } - - return null; - } - } - - internal int FindNodeOffset(XmlAttribute node) - { - for (int i = 0; i < nodes.Count; i++) - { - XmlAttribute tmp = (XmlAttribute)nodes[i]; - - if (tmp.LocalNameHash == node.LocalNameHash - && tmp.Name == node.Name - && tmp.NamespaceURI == node.NamespaceURI) - { - return i; - } - } - return -1; - } - - internal int FindNodeOffsetNS(XmlAttribute node) - { - for (int i = 0; i < nodes.Count; i++) - { - XmlAttribute tmp = (XmlAttribute)nodes[i]; - if (tmp.LocalNameHash == node.LocalNameHash - && tmp.LocalName == node.LocalName - && tmp.NamespaceURI == node.NamespaceURI) - { - return i; - } - } - return -1; - } - - // Adds a XmlNode using its Name property - public override XmlNode SetNamedItem(XmlNode node) - { - if (node != null && !(node is XmlAttribute)) - throw new ArgumentException(ResXml.Xdom_AttrCol_Object); - - int offset = FindNodeOffset(node.LocalName, node.NamespaceURI); - if (offset == -1) - { - return InternalAppendAttribute((XmlAttribute)node); - } - else - { - XmlNode oldNode = base.RemoveNodeAt(offset); - InsertNodeAt(offset, node); - return oldNode; - } - } - - // Inserts the specified node as the first node in the collection. - public XmlAttribute Prepend(XmlAttribute node) - { - if (node.OwnerDocument != null && node.OwnerDocument != parent.OwnerDocument) - throw new ArgumentException(ResXml.Xdom_NamedNode_Context); - - if (node.OwnerElement != null) - Detach(node); - - RemoveDuplicateAttribute(node); - - InsertNodeAt(0, node); - return node; - } - - // Inserts the specified node as the last node in the collection. - public XmlAttribute Append(XmlAttribute node) - { - XmlDocument doc = node.OwnerDocument; - if (doc == null || doc.IsLoading == false) - { - if (doc != null && doc != parent.OwnerDocument) - { - throw new ArgumentException(ResXml.Xdom_NamedNode_Context); - } - if (node.OwnerElement != null) - { - Detach(node); - } - AddNode(node); - } - else - { - base.AddNodeForLoad(node, doc); - InsertParentIntoElementIdAttrMap(node); - } - return node; - } - - // Inserts the specified attribute immediately before the specified reference attribute. - public XmlAttribute InsertBefore(XmlAttribute newNode, XmlAttribute refNode) - { - if (newNode == refNode) - return newNode; - - if (refNode == null) - return Append(newNode); - - if (refNode.OwnerElement != parent) - throw new ArgumentException(ResXml.Xdom_AttrCol_Insert); - - if (newNode.OwnerDocument != null && newNode.OwnerDocument != parent.OwnerDocument) - throw new ArgumentException(ResXml.Xdom_NamedNode_Context); - - if (newNode.OwnerElement != null) - Detach(newNode); - - int offset = FindNodeOffset(refNode.LocalName, refNode.NamespaceURI); - Debug.Assert(offset != -1); // the if statement above guarantees that the ref node is in the collection - - int dupoff = RemoveDuplicateAttribute(newNode); - if (dupoff >= 0 && dupoff < offset) - offset--; - InsertNodeAt(offset, newNode); - - return newNode; - } - - // Inserts the specified attribute immediately after the specified reference attribute. - public XmlAttribute InsertAfter(XmlAttribute newNode, XmlAttribute refNode) - { - if (newNode == refNode) - return newNode; - - if (refNode == null) - return Prepend(newNode); - - if (refNode.OwnerElement != parent) - throw new ArgumentException(ResXml.Xdom_AttrCol_Insert); - - if (newNode.OwnerDocument != null && newNode.OwnerDocument != parent.OwnerDocument) - throw new ArgumentException(ResXml.Xdom_NamedNode_Context); - - if (newNode.OwnerElement != null) - Detach(newNode); - - int offset = FindNodeOffset(refNode.LocalName, refNode.NamespaceURI); - Debug.Assert(offset != -1); // the if statement above guarantees that the ref node is in the collection - - int dupoff = RemoveDuplicateAttribute(newNode); - if (dupoff >= 0 && dupoff < offset) - offset--; - InsertNodeAt(offset + 1, newNode); - - return newNode; - } - - // Removes the specified attribute node from the map. - public XmlAttribute Remove(XmlAttribute node) - { - int cNodes = nodes.Count; - for (int offset = 0; offset < cNodes; offset++) - { - if (nodes[offset] == node) - { - RemoveNodeAt(offset); - return node; - } - } - return null; - } - - // Removes the attribute node with the specified index from the map. - public XmlAttribute RemoveAt(int i) - { - if (i < 0 || i >= Count) - return null; - - return (XmlAttribute)RemoveNodeAt(i); - } - - // Removes all attributes from the map. - public void RemoveAll() - { - int n = Count; - while (n > 0) - { - n--; - RemoveAt(n); - } - } - - void ICollection.CopyTo(Array array, int index) - { - for (int i = 0, max = Count; i < max; i++, index++) - array.SetValue(nodes[i], index); - } - - bool ICollection.IsSynchronized - { - get { return false; } - } - - object ICollection.SyncRoot - { - get { return this; } - } - - int ICollection.Count - { - get { return base.Count; } - } - - public void CopyTo(XmlAttribute[] array, int index) - { - for (int i = 0, max = Count; i < max; i++, index++) - array[index] = (XmlAttribute)(((XmlNode)nodes[i]).CloneNode(true)); - } - - internal override XmlNode AddNode(XmlNode node) - { - //should be sure by now that the node doesn't have the same name with an existing node in the collection - RemoveDuplicateAttribute((XmlAttribute)node); - XmlNode retNode = base.AddNode(node); - Debug.Assert(retNode is XmlAttribute); - InsertParentIntoElementIdAttrMap((XmlAttribute)node); - return retNode; - } - - internal override XmlNode InsertNodeAt(int i, XmlNode node) - { - XmlNode retNode = base.InsertNodeAt(i, node); - InsertParentIntoElementIdAttrMap((XmlAttribute)node); - return retNode; - } - - internal override XmlNode RemoveNodeAt(int i) - { - //remove the node without checking replacement - XmlNode retNode = base.RemoveNodeAt(i); - Debug.Assert(retNode is XmlAttribute); - RemoveParentFromElementIdAttrMap((XmlAttribute)retNode); - // after remove the attribute, we need to check if a default attribute node should be created and inserted into the tree - XmlAttribute defattr = parent.OwnerDocument.GetDefaultAttribute((XmlElement)parent, retNode.Prefix, retNode.LocalName, retNode.NamespaceURI); - if (defattr != null) - InsertNodeAt(i, defattr); - return retNode; - } - - internal void Detach(XmlAttribute attr) - { - attr.OwnerElement.Attributes.Remove(attr); - } - - //insert the parent element node into the map - internal void InsertParentIntoElementIdAttrMap(XmlAttribute attr) - { - XmlElement parentElem = parent as XmlElement; - if (parentElem != null) - { - if (parent.OwnerDocument == null) - return; - XmlName attrname = parent.OwnerDocument.GetIDInfoByElement(parentElem.XmlName); - if (attrname != null && attrname.Prefix == attr.XmlName.Prefix && attrname.LocalName == attr.XmlName.LocalName) - { - parent.OwnerDocument.AddElementWithId(attr.Value, parentElem); //add the element into the hashtable - } - } - } - - //remove the parent element node from the map when the ID attribute is removed - internal void RemoveParentFromElementIdAttrMap(XmlAttribute attr) - { - XmlElement parentElem = parent as XmlElement; - if (parentElem != null) - { - if (parent.OwnerDocument == null) - return; - XmlName attrname = parent.OwnerDocument.GetIDInfoByElement(parentElem.XmlName); - if (attrname != null && attrname.Prefix == attr.XmlName.Prefix && attrname.LocalName == attr.XmlName.LocalName) - { - parent.OwnerDocument.RemoveElementWithId(attr.Value, parentElem); //remove the element from the hashtable - } - } - } - - //the function checks if there is already node with the same name existing in the collection - // if so, remove it because the new one will be inserted to replace this one (could be in different position though ) - // by the calling function later - internal int RemoveDuplicateAttribute(XmlAttribute attr) - { - int ind = FindNodeOffset(attr.LocalName, attr.NamespaceURI); - if (ind != -1) - { - XmlAttribute at = (XmlAttribute)nodes[ind]; - base.RemoveNodeAt(ind); - RemoveParentFromElementIdAttrMap(at); - } - return ind; - } - - internal bool PrepareParentInElementIdAttrMap(string attrPrefix, string attrLocalName) - { - XmlElement parentElem = parent as XmlElement; - Debug.Assert(parentElem != null); - XmlDocument doc = parent.OwnerDocument; - Debug.Assert(doc != null); - //The returned attrname if not null is the name with namespaceURI being set to string.Empty - //Because DTD doesn't support namespaceURI so all comparisons are based on no namespaceURI (string.Empty); - XmlName attrname = doc.GetIDInfoByElement(parentElem.XmlName); - if (attrname != null && attrname.Prefix == attrPrefix && attrname.LocalName == attrLocalName) - { - return true; - } - return false; - } - - internal void ResetParentInElementIdAttrMap(string oldVal, string newVal) - { - XmlElement parentElem = parent as XmlElement; - Debug.Assert(parentElem != null); - XmlDocument doc = parent.OwnerDocument; - Debug.Assert(doc != null); - doc.RemoveElementWithId(oldVal, parentElem); //add the element into the hashtable - doc.AddElementWithId(newVal, parentElem); - } - - // WARNING: - // For performance reasons, this function does not check - // for xml attributes within the collection with the same full name. - // This means that any caller of this function must be sure that - // a duplicate attribute does not exist. - internal XmlAttribute InternalAppendAttribute(XmlAttribute node) - { - // a duplicate node better not exist - Debug.Assert(-1 == FindNodeOffset(node)); - - XmlNode retNode = base.AddNode(node); - Debug.Assert(retNode is XmlAttribute); - InsertParentIntoElementIdAttrMap((XmlAttribute)node); - return (XmlAttribute)retNode; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCDATASection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCDATASection.cs deleted file mode 100644 index 07473c3f184..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCDATASection.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Text; - using System.Diagnostics; - using Microsoft.Xml.XPath; - - // Used to quote or escape blocks of text to keep that text from being - // interpreted as markup language. - public class XmlCDataSection : XmlCharacterData - { - protected internal XmlCDataSection(string data, XmlDocument doc) : base(data, doc) - { - } - - // Gets the name of the node. - public override String Name - { - get - { - return OwnerDocument.strCDataSectionName; - } - } - - // Gets the name of the node without the namespace prefix. - public override String LocalName - { - get - { - return OwnerDocument.strCDataSectionName; - } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - return XmlNodeType.CDATA; - } - } - - public override XmlNode ParentNode - { - get - { - switch (parentNode.NodeType) - { - case XmlNodeType.Document: - return null; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - XmlNode parent = parentNode.parentNode; - while (parent.IsText) - { - parent = parent.parentNode; - } - return parent; - default: - return parentNode; - } - } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateCDataSection(Data); - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteCData(Data); - } - - // Saves the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override XPathNodeType XPNodeType - { - get - { - return XPathNodeType.Text; - } - } - - internal override bool IsText - { - get - { - return true; - } - } - - public override XmlNode PreviousText - { - get - { - if (parentNode.IsText) - { - return parentNode; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCharacterData.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCharacterData.cs deleted file mode 100644 index 7b4ef05d2a7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlCharacterData.cs +++ /dev/null @@ -1,231 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Diagnostics; - using System.Text; - using Microsoft.Xml.XPath; - - // Provides text-manipulation methods that are used by several classes. - public abstract class XmlCharacterData : XmlLinkedNode - { - private string _data; - - //base(doc) will throw exception if doc is null. - protected internal XmlCharacterData(string data, XmlDocument doc) : base(doc) - { - _data = data; - } - - // Gets or sets the value of the node. - public override String Value - { - get { return Data; } - set { Data = value; } - } - - // Gets or sets the concatenated values of the node and - // all its children. - public override string InnerText - { - get { return Value; } - set { Value = value; } - } - - // Contains this node's data. - public virtual string Data - { - get - { - if (_data != null) - { - return _data; - } - else - { - return String.Empty; - } - } - - set - { - XmlNode parent = ParentNode; - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, value, XmlNodeChangedAction.Change); - - if (args != null) - BeforeEvent(args); - - _data = value; - - if (args != null) - AfterEvent(args); - } - } - - // Gets the length of the data, in characters. - public virtual int Length - { - get - { - if (_data != null) - { - return _data.Length; - } - return 0; - } - } - - // Retrieves a substring of the full string from the specified range. - public virtual String Substring(int offset, int count) - { - int len = _data != null ? _data.Length : 0; - if (len > 0) - { - if (len < (offset + count)) - { - count = len - offset; - } - return _data.Substring(offset, count); - } - return String.Empty; - } - - // Appends the specified string to the end of the character - // data of the node. - public virtual void AppendData(String strData) - { - XmlNode parent = ParentNode; - int capacity = _data != null ? _data.Length : 0; - if (strData != null) capacity += strData.Length; - string newValue = new StringBuilder(capacity).Append(_data).Append(strData).ToString(); - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, newValue, XmlNodeChangedAction.Change); - - if (args != null) - BeforeEvent(args); - - _data = newValue; - - if (args != null) - AfterEvent(args); - } - - // Insert the specified string at the specified character offset. - public virtual void InsertData(int offset, string strData) - { - XmlNode parent = ParentNode; - int capacity = _data != null ? _data.Length : 0; - if (strData != null) capacity += strData.Length; - string newValue = new StringBuilder(capacity).Append(_data).Insert(offset, strData).ToString(); - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, newValue, XmlNodeChangedAction.Change); - if (args != null) - BeforeEvent(args); - - _data = newValue; - - if (args != null) - AfterEvent(args); - } - - // Remove a range of characters from the node. - public virtual void DeleteData(int offset, int count) - { - //Debug.Assert(offset >= 0 && offset <= Length); - - int len = _data != null ? _data.Length : 0; - if (len > 0) - { - if (len < (offset + count)) - { - count = Math.Max(len - offset, 0); - } - } - - string newValue = new StringBuilder(_data).Remove(offset, count).ToString(); - XmlNode parent = ParentNode; - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, newValue, XmlNodeChangedAction.Change); - - if (args != null) - BeforeEvent(args); - - _data = newValue; - - if (args != null) - AfterEvent(args); - } - - // Replace the specified number of characters starting at the specified offset with the - // specified string. - public virtual void ReplaceData(int offset, int count, String strData) - { - //Debug.Assert(offset >= 0 && offset <= Length); - - int len = _data != null ? _data.Length : 0; - if (len > 0) - { - if (len < (offset + count)) - { - count = Math.Max(len - offset, 0); - } - } - - StringBuilder temp = new StringBuilder(_data).Remove(offset, count); - string newValue = temp.Insert(offset, strData).ToString(); - - XmlNode parent = ParentNode; - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, newValue, XmlNodeChangedAction.Change); - - if (args != null) - BeforeEvent(args); - - _data = newValue; - - if (args != null) - AfterEvent(args); - } - - internal bool CheckOnData(string data) - { - return XmlCharType.Instance.IsOnlyWhitespace(data); - } - - internal bool DecideXPNodeTypeForTextNodes(XmlNode node, ref XPathNodeType xnt) - { - //returns true - if all siblings of the node are processed else returns false. - //The reference XPathNodeType argument being passed in is the watermark that - //changes according to the siblings nodetype and will contain the correct - //nodetype when it returns. - - Debug.Assert(XmlDocument.IsTextNode(node.NodeType) || (node.ParentNode != null && node.ParentNode.NodeType == XmlNodeType.EntityReference)); - while (node != null) - { - switch (node.NodeType) - { - case XmlNodeType.Whitespace: - break; - case XmlNodeType.SignificantWhitespace: - xnt = XPathNodeType.SignificantWhitespace; - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - xnt = XPathNodeType.Text; - return false; - case XmlNodeType.EntityReference: - if (!DecideXPNodeTypeForTextNodes(node.FirstChild, ref xnt)) - { - return false; - } - break; - default: - return false; - } - node = node.NextSibling; - } - return true; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildEnumerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildEnumerator.cs deleted file mode 100644 index 693ee8ef76f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildEnumerator.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - - internal sealed class XmlChildEnumerator : IEnumerator - { - internal XmlNode container; - internal XmlNode child; - internal bool isFirst; - - internal XmlChildEnumerator(XmlNode container) - { - this.container = container; - this.child = container.FirstChild; - this.isFirst = true; - } - - bool IEnumerator.MoveNext() - { - return this.MoveNext(); - } - - internal bool MoveNext() - { - if (isFirst) - { - child = container.FirstChild; - isFirst = false; - } - else if (child != null) - { - child = child.NextSibling; - } - - return child != null; - } - - void IEnumerator.Reset() - { - isFirst = true; - child = container.FirstChild; - } - - object IEnumerator.Current - { - get - { - return this.Current; - } - } - - internal XmlNode Current - { - get - { - if (isFirst || child == null) - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - - return child; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildNodes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildNodes.cs deleted file mode 100644 index 3fb2ba6a4fc..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlChildNodes.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - - internal class XmlChildNodes : XmlNodeList - { - private XmlNode _container; - - public XmlChildNodes(XmlNode container) - { - _container = container; - } - - public override XmlNode Item(int i) - { - // Out of range indexes return a null XmlNode - if (i < 0) - return null; - for (XmlNode n = _container.FirstChild; n != null; n = n.NextSibling, i--) - { - if (i == 0) - return n; - } - return null; - } - - public override int Count - { - get - { - int c = 0; - for (XmlNode n = _container.FirstChild; n != null; n = n.NextSibling) - { - c++; - } - return c; - } - } - - public override IEnumerator GetEnumerator() - { - if (_container.FirstChild == null) - { - return XmlDocument.EmptyEnumerator; - } - else - { - return new XmlChildEnumerator(_container); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlComment.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlComment.cs deleted file mode 100644 index 7f3024410a3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlComment.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using Microsoft.Xml.XPath; - using System.Diagnostics; - - // Represents the content of an XML comment. - public class XmlComment : XmlCharacterData - { - protected internal XmlComment(string comment, XmlDocument doc) : base(comment, doc) - { - } - - // Gets the name of the node. - public override String Name - { - get { return OwnerDocument.strCommentName; } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get { return OwnerDocument.strCommentName; } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Comment; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateComment(Data); - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteComment(Data); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override XPathNodeType XPNodeType { get { return XPathNodeType.Comment; } } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDeclaration.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDeclaration.cs deleted file mode 100644 index ede7fbe769f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDeclaration.cs +++ /dev/null @@ -1,174 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Text; - using System.Diagnostics; - - // Represents the xml declaration nodes: - public class XmlDeclaration : XmlLinkedNode - { - private const string YES = "yes"; - private const string NO = "no"; - - private string _version; - private string _encoding; - private string _standalone; - - protected internal XmlDeclaration(string version, string encoding, string standalone, XmlDocument doc) : base(doc) - { - if (!IsValidXmlVersion(version)) - throw new ArgumentException(ResXml.Xdom_Version); - if ((standalone != null) && (standalone.Length > 0)) - if ((standalone != YES) && (standalone != NO)) - throw new ArgumentException(string.Format(ResXml.Xdom_standalone, standalone)); - this.Encoding = encoding; - this.Standalone = standalone; - this.Version = version; - } - - - // The version attribute for - public string Version - { - get { return _version; } - internal set { _version = value; } - } - - // Specifies the value of the encoding attribute, as for - // - public string Encoding - { - get { return _encoding; } - set { _encoding = ((value == null) ? String.Empty : value); } - } - - // Specifies the value of the standalone attribute. - public string Standalone - { - get { return _standalone; } - set - { - if (value == null) - _standalone = String.Empty; - else if (value.Length == 0 || value == YES || value == NO) - _standalone = value; - else - throw new ArgumentException(string.Format(ResXml.Xdom_standalone, value)); - } - } - - public override String Value - { - get { return InnerText; } - set { InnerText = value; } - } - - - // Gets or sets the concatenated values of the node and - // all its children. - public override string InnerText - { - get - { - StringBuilder strb = new StringBuilder("version=\"" + Version + "\""); - if (Encoding.Length > 0) - { - strb.Append(" encoding=\""); - strb.Append(Encoding); - strb.Append("\""); - } - if (Standalone.Length > 0) - { - strb.Append(" standalone=\""); - strb.Append(Standalone); - strb.Append("\""); - } - return strb.ToString(); - } - - set - { - string tempVersion = null; - string tempEncoding = null; - string tempStandalone = null; - string orgEncoding = this.Encoding; - string orgStandalone = this.Standalone; - string orgVersion = this.Version; - - XmlLoader.ParseXmlDeclarationValue(value, out tempVersion, out tempEncoding, out tempStandalone); - - try - { - if (tempVersion != null && !IsValidXmlVersion(tempVersion)) - throw new ArgumentException(ResXml.Xdom_Version); - Version = tempVersion; - - if (tempEncoding != null) - Encoding = tempEncoding; - if (tempStandalone != null) - Standalone = tempStandalone; - } - catch - { - Encoding = orgEncoding; - Standalone = orgStandalone; - Version = orgVersion; - throw; - } - } - } - - //override methods and properties from XmlNode - - // Gets the name of the node. - public override String Name - { - get - { - return "xml"; - } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get { return Name; } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.XmlDeclaration; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateXmlDeclaration(Version, Encoding, Standalone); - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteProcessingInstruction(Name, InnerText); - } - - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing since the node doesn't have children. - } - - private bool IsValidXmlVersion(string ver) - { - return ver.Length >= 3 && ver[0] == '1' && ver[1] == '.' && XmlCharType.IsOnlyDigits(ver, 2, ver.Length - 2); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocument.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocument.cs deleted file mode 100644 index dc6a12d3cc8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocument.cs +++ /dev/null @@ -1,1780 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Collections; - using System.Diagnostics; - using System.IO; - using System.Text; - using Microsoft.Xml.Schema; - using Microsoft.Xml.XPath; - using System.Security; - // using System.Security.Permissions; - using System.Globalization; - using System.Runtime.Versioning; - - // Represents an entire document. An XmlDocument contains XML data. - public class XmlDocument : XmlNode - { - private XmlImplementation _implementation; - private DomNameTable _domNameTable; // hash table of XmlName - private XmlLinkedNode _lastChild; - private XmlNamedNodeMap _entities; - private Hashtable _htElementIdMap; - private Hashtable _htElementIDAttrDecl; //key: id; object: the ArrayList of the elements that have the same id (connected or disconnected) - private SchemaInfo _schemaInfo; - private XmlSchemaSet _schemas; // schemas associated with the cache - private bool _reportValidity; - //This variable represents the actual loading status. Since, IsLoading will - //be manipulated soemtimes for adding content to EntityReference this variable - //has been added which would always represent the loading status of document. - private bool _actualLoadingStatus; - - private XmlNodeChangedEventHandler _onNodeInsertingDelegate; - private XmlNodeChangedEventHandler _onNodeInsertedDelegate; - private XmlNodeChangedEventHandler _onNodeRemovingDelegate; - private XmlNodeChangedEventHandler _onNodeRemovedDelegate; - private XmlNodeChangedEventHandler _onNodeChangingDelegate; - private XmlNodeChangedEventHandler _onNodeChangedDelegate; - - // false if there are no ent-ref present, true if ent-ref nodes are or were present (i.e. if all ent-ref were removed, the doc will not clear this flag) - internal bool fEntRefNodesPresent; - internal bool fCDataNodesPresent; - - private bool _preserveWhitespace; - private bool _isLoading; - - // special name strings for - internal string strDocumentName; - internal string strDocumentFragmentName; - internal string strCommentName; - internal string strTextName; - internal string strCDataSectionName; - internal string strEntityName; - internal string strID; - internal string strXmlns; - internal string strXml; - internal string strSpace; - internal string strLang; - internal string strEmpty; - - internal string strNonSignificantWhitespaceName; - internal string strSignificantWhitespaceName; - internal string strReservedXmlns; - internal string strReservedXml; - - internal String baseURI; - - private XmlResolver _resolver; - internal bool bSetResolver; - internal object objLock; - - private XmlAttribute _namespaceXml; - - static internal EmptyEnumerator EmptyEnumerator = new EmptyEnumerator(); - static internal IXmlSchemaInfo NotKnownSchemaInfo = new XmlSchemaInfo(XmlSchemaValidity.NotKnown); - static internal IXmlSchemaInfo ValidSchemaInfo = new XmlSchemaInfo(XmlSchemaValidity.Valid); - static internal IXmlSchemaInfo InvalidSchemaInfo = new XmlSchemaInfo(XmlSchemaValidity.Invalid); - - // Initializes a new instance of the XmlDocument class. - public XmlDocument() : this(new XmlImplementation()) - { - } - - // Initializes a new instance - // of the XmlDocument class with the specified XmlNameTable. - public XmlDocument(XmlNameTable nt) : this(new XmlImplementation(nt)) - { - } - - protected internal XmlDocument(XmlImplementation imp) : base() - { - _implementation = imp; - _domNameTable = new DomNameTable(this); - - // force the following string instances to be default in the nametable - XmlNameTable nt = this.NameTable; - nt.Add(string.Empty); - strDocumentName = nt.Add("#document"); - strDocumentFragmentName = nt.Add("#document-fragment"); - strCommentName = nt.Add("#comment"); - strTextName = nt.Add("#text"); - strCDataSectionName = nt.Add("#cdata-section"); - strEntityName = nt.Add("#entity"); - strID = nt.Add("id"); - strNonSignificantWhitespaceName = nt.Add("#whitespace"); - strSignificantWhitespaceName = nt.Add("#significant-whitespace"); - strXmlns = nt.Add("xmlns"); - strXml = nt.Add("xml"); - strSpace = nt.Add("space"); - strLang = nt.Add("lang"); - strReservedXmlns = nt.Add(XmlReservedNs.NsXmlNs); - strReservedXml = nt.Add(XmlReservedNs.NsXml); - strEmpty = nt.Add(String.Empty); - baseURI = String.Empty; - - objLock = new object(); - } - - internal SchemaInfo DtdSchemaInfo - { - get { return _schemaInfo; } - set { _schemaInfo = value; } - } - - // NOTE: This does not correctly check start name char, but we cannot change it since it would be a breaking change. - internal static void CheckName(String name) - { - int endPos = ValidateNames.ParseNmtoken(name, 0); - if (endPos < name.Length) - { - throw new XmlException(ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos)); - } - } - - internal XmlName AddXmlName(string prefix, string localName, string namespaceURI, IXmlSchemaInfo schemaInfo) - { - XmlName n = _domNameTable.AddName(prefix, localName, namespaceURI, schemaInfo); - Debug.Assert((prefix == null) ? (n.Prefix.Length == 0) : (prefix == n.Prefix)); - Debug.Assert(n.LocalName == localName); - Debug.Assert((namespaceURI == null) ? (n.NamespaceURI.Length == 0) : (n.NamespaceURI == namespaceURI)); - return n; - } - - internal XmlName GetXmlName(string prefix, string localName, string namespaceURI, IXmlSchemaInfo schemaInfo) - { - XmlName n = _domNameTable.GetName(prefix, localName, namespaceURI, schemaInfo); - Debug.Assert(n == null || ((prefix == null) ? (n.Prefix.Length == 0) : (prefix == n.Prefix))); - Debug.Assert(n == null || n.LocalName == localName); - Debug.Assert(n == null || ((namespaceURI == null) ? (n.NamespaceURI.Length == 0) : (n.NamespaceURI == namespaceURI))); - return n; - } - - internal XmlName AddAttrXmlName(string prefix, string localName, string namespaceURI, IXmlSchemaInfo schemaInfo) - { - XmlName xmlName = AddXmlName(prefix, localName, namespaceURI, schemaInfo); - Debug.Assert((prefix == null) ? (xmlName.Prefix.Length == 0) : (prefix == xmlName.Prefix)); - Debug.Assert(xmlName.LocalName == localName); - Debug.Assert((namespaceURI == null) ? (xmlName.NamespaceURI.Length == 0) : (xmlName.NamespaceURI == namespaceURI)); - - if (!this.IsLoading) - { - // Use atomized versions instead of prefix, localName and nsURI - object oPrefix = xmlName.Prefix; - object oNamespaceURI = xmlName.NamespaceURI; - object oLocalName = xmlName.LocalName; - if ((oPrefix == (object)strXmlns || (oPrefix == (object)strEmpty && oLocalName == (object)strXmlns)) ^ (oNamespaceURI == (object)strReservedXmlns)) - throw new ArgumentException(string.Format(ResXml.Xdom_Attr_Reserved_XmlNS, namespaceURI)); - } - return xmlName; - } - - internal bool AddIdInfo(XmlName eleName, XmlName attrName) - { - //when XmlLoader call XmlDocument.AddInfo, the element.XmlName and attr.XmlName - //have already been replaced with the ones that don't have namespace values (or just - //string.Empty) because in DTD, the namespace is not supported - if (_htElementIDAttrDecl == null || _htElementIDAttrDecl[eleName] == null) - { - if (_htElementIDAttrDecl == null) - _htElementIDAttrDecl = new Hashtable(); - _htElementIDAttrDecl.Add(eleName, attrName); - return true; - } - return false; - } - - private XmlName GetIDInfoByElement_(XmlName eleName) - { - //When XmlDocument is getting the IDAttribute for a given element, - //we need only compare the prefix and localname of element.XmlName with - //the registered htElementIDAttrDecl. - XmlName newName = GetXmlName(eleName.Prefix, eleName.LocalName, string.Empty, null); - if (newName != null) - { - return (XmlName)(_htElementIDAttrDecl[newName]); - } - return null; - } - - internal XmlName GetIDInfoByElement(XmlName eleName) - { - if (_htElementIDAttrDecl == null) - return null; - else - return GetIDInfoByElement_(eleName); - } - - private WeakReference GetElement(ArrayList elementList, XmlElement elem) - { - ArrayList gcElemRefs = new ArrayList(); - foreach (WeakReference elemRef in elementList) - { - if (!elemRef.IsAlive) - //take notes on the garbage collected nodes - gcElemRefs.Add(elemRef); - else - { - if ((XmlElement)(elemRef.Target) == elem) - return elemRef; - } - } - //Clear out the gced elements - foreach (WeakReference elemRef in gcElemRefs) - elementList.Remove(elemRef); - return null; - } - - internal void AddElementWithId(string id, XmlElement elem) - { - if (_htElementIdMap == null || !_htElementIdMap.Contains(id)) - { - if (_htElementIdMap == null) - _htElementIdMap = new Hashtable(); - ArrayList elementList = new ArrayList(); - elementList.Add(new WeakReference(elem)); - _htElementIdMap.Add(id, elementList); - } - else - { - // there are other element(s) that has the same id - ArrayList elementList = (ArrayList)(_htElementIdMap[id]); - if (GetElement(elementList, elem) == null) - elementList.Add(new WeakReference(elem)); - } - } - - internal void RemoveElementWithId(string id, XmlElement elem) - { - if (_htElementIdMap != null && _htElementIdMap.Contains(id)) - { - ArrayList elementList = (ArrayList)(_htElementIdMap[id]); - WeakReference elemRef = GetElement(elementList, elem); - if (elemRef != null) - { - elementList.Remove(elemRef); - if (elementList.Count == 0) - _htElementIdMap.Remove(id); - } - } - } - - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - XmlDocument clone = Implementation.CreateDocument(); - clone.SetBaseURI(this.baseURI); - if (deep) - clone.ImportChildren(this, clone, deep); - - return clone; - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Document; } - } - - public override XmlNode ParentNode - { - get { return null; } - } - - // Gets the node for the DOCTYPE declaration. - public virtual XmlDocumentType DocumentType - { - get { return (XmlDocumentType)FindChild(XmlNodeType.DocumentType); } - } - - internal virtual XmlDeclaration Declaration - { - get - { - if (HasChildNodes) - { - XmlDeclaration dec = FirstChild as XmlDeclaration; - return dec; - } - return null; - } - } - - // Gets the XmlImplementation object for this document. - public XmlImplementation Implementation - { - get { return _implementation; } - } - - // Gets the name of the node. - public override String Name - { - get { return strDocumentName; } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get { return strDocumentName; } - } - - // Gets the root XmlElement for the document. - public XmlElement DocumentElement - { - get { return (XmlElement)FindChild(XmlNodeType.Element); } - } - - internal override bool IsContainer - { - get { return true; } - } - - internal override XmlLinkedNode LastNode - { - get { return _lastChild; } - set { _lastChild = value; } - } - - // Gets the XmlDocument that contains this node. - public override XmlDocument OwnerDocument - { - get { return null; } - } - - public XmlSchemaSet Schemas - { - get - { - if (_schemas == null) - { - _schemas = new XmlSchemaSet(NameTable); - } - return _schemas; - } - - set - { - _schemas = value; - } - } - - internal bool CanReportValidity - { - get { return _reportValidity; } - } - - internal bool HasSetResolver - { - get { return bSetResolver; } - } - - internal XmlResolver GetResolver() - { - return _resolver; - } - - public virtual XmlResolver XmlResolver - { - set - { - _resolver = value; - if (!bSetResolver) - bSetResolver = true; - - XmlDocumentType dtd = this.DocumentType; - if (dtd != null) - { - dtd.DtdSchemaInfo = null; - } - } - } - internal override bool IsValidChildType(XmlNodeType type) - { - switch (type) - { - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return true; - - case XmlNodeType.DocumentType: - if (DocumentType != null) - throw new InvalidOperationException(ResXml.Xdom_DualDocumentTypeNode); - return true; - - case XmlNodeType.Element: - if (DocumentElement != null) - throw new InvalidOperationException(ResXml.Xdom_DualDocumentElementNode); - return true; - - case XmlNodeType.XmlDeclaration: - if (Declaration != null) - throw new InvalidOperationException(ResXml.Xdom_DualDeclarationNode); - return true; - - default: - return false; - } - } - // the function examines all the siblings before the refNode - // if any of the nodes has type equals to "nt", return true; otherwise, return false; - private bool HasNodeTypeInPrevSiblings(XmlNodeType nt, XmlNode refNode) - { - if (refNode == null) - return false; - - XmlNode node = null; - if (refNode.ParentNode != null) - node = refNode.ParentNode.FirstChild; - while (node != null) - { - if (node.NodeType == nt) - return true; - if (node == refNode) - break; - node = node.NextSibling; - } - return false; - } - - // the function examines all the siblings after the refNode - // if any of the nodes has the type equals to "nt", return true; otherwise, return false; - private bool HasNodeTypeInNextSiblings(XmlNodeType nt, XmlNode refNode) - { - XmlNode node = refNode; - while (node != null) - { - if (node.NodeType == nt) - return true; - node = node.NextSibling; - } - return false; - } - - internal override bool CanInsertBefore(XmlNode newChild, XmlNode refChild) - { - if (refChild == null) - refChild = FirstChild; - - if (refChild == null) - return true; - - switch (newChild.NodeType) - { - case XmlNodeType.XmlDeclaration: - return (refChild == FirstChild); - - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - return refChild.NodeType != XmlNodeType.XmlDeclaration; - - case XmlNodeType.DocumentType: - { - if (refChild.NodeType != XmlNodeType.XmlDeclaration) - { - //if refChild is not the XmlDeclaration node, only need to go through the sibling before and including refChild to - // make sure no Element ( rootElem node ) before the current position - return !HasNodeTypeInPrevSiblings(XmlNodeType.Element, refChild.PreviousSibling); - } - } - break; - - case XmlNodeType.Element: - { - if (refChild.NodeType != XmlNodeType.XmlDeclaration) - { - //if refChild is not the XmlDeclaration node, only need to go through the siblings after and including the refChild to - // make sure no DocType node and XmlDeclaration node after the current posistion. - return !HasNodeTypeInNextSiblings(XmlNodeType.DocumentType, refChild); - } - } - break; - } - - return false; - } - - internal override bool CanInsertAfter(XmlNode newChild, XmlNode refChild) - { - if (refChild == null) - refChild = LastChild; - - if (refChild == null) - return true; - - switch (newChild.NodeType) - { - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return true; - - case XmlNodeType.DocumentType: - { - //we will have to go through all the siblings before the refChild just to make sure no Element node ( rootElem ) - // before the current position - return !HasNodeTypeInPrevSiblings(XmlNodeType.Element, refChild); - } - - case XmlNodeType.Element: - { - return !HasNodeTypeInNextSiblings(XmlNodeType.DocumentType, refChild.NextSibling); - } - } - - return false; - } - - // Creates an XmlAttribute with the specified name. - public XmlAttribute CreateAttribute(String name) - { - String prefix = String.Empty; - String localName = String.Empty; - String namespaceURI = String.Empty; - - SplitName(name, out prefix, out localName); - - SetDefaultNamespace(prefix, localName, ref namespaceURI); - - return CreateAttribute(prefix, localName, namespaceURI); - } - - internal void SetDefaultNamespace(String prefix, String localName, ref String namespaceURI) - { - if (prefix == strXmlns || (prefix.Length == 0 && localName == strXmlns)) - { - namespaceURI = strReservedXmlns; - } - else if (prefix == strXml) - { - namespaceURI = strReservedXml; - } - } - - // Creates a XmlCDataSection containing the specified data. - public virtual XmlCDataSection CreateCDataSection(String data) - { - fCDataNodesPresent = true; - return new XmlCDataSection(data, this); - } - - // Creates an XmlComment containing the specified data. - public virtual XmlComment CreateComment(String data) - { - return new XmlComment(data, this); - } - - // Returns a new XmlDocumentType object. - // [PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )] - public virtual XmlDocumentType CreateDocumentType(string name, string publicId, string systemId, string internalSubset) - { - return new XmlDocumentType(name, publicId, systemId, internalSubset, this); - } - - // Creates an XmlDocumentFragment. - public virtual XmlDocumentFragment CreateDocumentFragment() - { - return new XmlDocumentFragment(this); - } - - // Creates an element with the specified name. - public XmlElement CreateElement(String name) - { - string prefix = String.Empty; - string localName = String.Empty; - SplitName(name, out prefix, out localName); - return CreateElement(prefix, localName, string.Empty); - } - - - internal void AddDefaultAttributes(XmlElement elem) - { - SchemaInfo schInfo = DtdSchemaInfo; - SchemaElementDecl ed = GetSchemaElementDecl(elem); - if (ed != null && ed.AttDefs != null) - { - IDictionaryEnumerator attrDefs = ed.AttDefs.GetEnumerator(); - while (attrDefs.MoveNext()) - { - SchemaAttDef attdef = (SchemaAttDef)attrDefs.Value; - if (attdef.Presence == SchemaDeclBase.Use.Default || - attdef.Presence == SchemaDeclBase.Use.Fixed) - { - //build a default attribute and return - string attrPrefix = string.Empty; - string attrLocalname = attdef.Name.Name; - string attrNamespaceURI = string.Empty; - if (schInfo.SchemaType == SchemaType.DTD) - attrPrefix = attdef.Name.Namespace; - else - { - attrPrefix = attdef.Prefix; - attrNamespaceURI = attdef.Name.Namespace; - } - XmlAttribute defattr = PrepareDefaultAttribute(attdef, attrPrefix, attrLocalname, attrNamespaceURI); - elem.SetAttributeNode(defattr); - } - } - } - } - - private SchemaElementDecl GetSchemaElementDecl(XmlElement elem) - { - SchemaInfo schInfo = DtdSchemaInfo; - if (schInfo != null) - { - //build XmlQualifiedName used to identify the element schema declaration - XmlQualifiedName qname = new XmlQualifiedName(elem.LocalName, schInfo.SchemaType == SchemaType.DTD ? elem.Prefix : elem.NamespaceURI); - //get the schema info for the element - SchemaElementDecl elemDecl; - if (schInfo.ElementDecls.TryGetValue(qname, out elemDecl)) - { - return elemDecl; - } - } - return null; - } - - //Will be used by AddDeafulatAttributes() and GetDefaultAttribute() methods - private XmlAttribute PrepareDefaultAttribute(SchemaAttDef attdef, string attrPrefix, string attrLocalname, string attrNamespaceURI) - { - SetDefaultNamespace(attrPrefix, attrLocalname, ref attrNamespaceURI); - XmlAttribute defattr = CreateDefaultAttribute(attrPrefix, attrLocalname, attrNamespaceURI); - //parsing the default value for the default attribute - defattr.InnerXml = attdef.DefaultValueRaw; - //during the expansion of the tree, the flag could be set to true, we need to set it back. - XmlUnspecifiedAttribute unspAttr = defattr as XmlUnspecifiedAttribute; - if (unspAttr != null) - { - unspAttr.SetSpecified(false); - } - return defattr; - } - - // Creates an XmlEntityReference with the specified name. - public virtual XmlEntityReference CreateEntityReference(String name) - { - return new XmlEntityReference(name, this); - } - - // Creates a XmlProcessingInstruction with the specified name - // and data strings. - public virtual XmlProcessingInstruction CreateProcessingInstruction(String target, String data) - { - return new XmlProcessingInstruction(target, data, this); - } - - // Creates a XmlDeclaration node with the specified values. - public virtual XmlDeclaration CreateXmlDeclaration(String version, string encoding, string standalone) - { - return new XmlDeclaration(version, encoding, standalone, this); - } - - // Creates an XmlText with the specified text. - public virtual XmlText CreateTextNode(String text) - { - return new XmlText(text, this); - } - - // Creates a XmlSignificantWhitespace node. - public virtual XmlSignificantWhitespace CreateSignificantWhitespace(string text) - { - return new XmlSignificantWhitespace(text, this); - } - - public override XPathNavigator CreateNavigator() - { - return CreateNavigator(this); - } - - internal protected virtual XPathNavigator CreateNavigator(XmlNode node) - { - XmlNodeType nodeType = node.NodeType; - XmlNode parent; - XmlNodeType parentType; - - switch (nodeType) - { - case XmlNodeType.EntityReference: - case XmlNodeType.Entity: - case XmlNodeType.DocumentType: - case XmlNodeType.Notation: - case XmlNodeType.XmlDeclaration: - return null; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.SignificantWhitespace: - parent = node.ParentNode; - if (parent != null) - { - do - { - parentType = parent.NodeType; - if (parentType == XmlNodeType.Attribute) - { - return null; - } - else if (parentType == XmlNodeType.EntityReference) - { - parent = parent.ParentNode; - } - else - { - break; - } - } - while (parent != null); - } - node = NormalizeText(node); - break; - case XmlNodeType.Whitespace: - parent = node.ParentNode; - if (parent != null) - { - do - { - parentType = parent.NodeType; - if (parentType == XmlNodeType.Document - || parentType == XmlNodeType.Attribute) - { - return null; - } - else if (parentType == XmlNodeType.EntityReference) - { - parent = parent.ParentNode; - } - else - { - break; - } - } - while (parent != null); - } - node = NormalizeText(node); - break; - default: - break; - } - return new DocumentXPathNavigator(this, node); - } - - internal static bool IsTextNode(XmlNodeType nt) - { - switch (nt) - { - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return true; - default: - return false; - } - } - - private XmlNode NormalizeText(XmlNode n) - { - XmlNode retnode = null; - while (IsTextNode(n.NodeType)) - { - retnode = n; - n = n.PreviousSibling; - - if (n == null) - { - XmlNode intnode = retnode; - while (true) - { - if (intnode.ParentNode != null && intnode.ParentNode.NodeType == XmlNodeType.EntityReference) - { - if (intnode.ParentNode.PreviousSibling != null) - { - n = intnode.ParentNode.PreviousSibling; - break; - } - else - { - intnode = intnode.ParentNode; - if (intnode == null) - break; - } - } - else - break; - } - } - - if (n == null) - break; - while (n.NodeType == XmlNodeType.EntityReference) - { - n = n.LastChild; - } - } - return retnode; - } - - // Creates a XmlWhitespace node. - public virtual XmlWhitespace CreateWhitespace(string text) - { - return new XmlWhitespace(text, this); - } - - // Returns an XmlNodeList containing - // a list of all descendant elements that match the specified name. - public virtual XmlNodeList GetElementsByTagName(String name) - { - return new XmlElementList(this, name); - } - - // DOM Level 2 - - // Creates an XmlAttribute with the specified LocalName - // and NamespaceURI. - public XmlAttribute CreateAttribute(String qualifiedName, String namespaceURI) - { - string prefix = String.Empty; - string localName = String.Empty; - - SplitName(qualifiedName, out prefix, out localName); - return CreateAttribute(prefix, localName, namespaceURI); - } - - // Creates an XmlElement with the specified LocalName and - // NamespaceURI. - public XmlElement CreateElement(String qualifiedName, String namespaceURI) - { - string prefix = String.Empty; - string localName = String.Empty; - SplitName(qualifiedName, out prefix, out localName); - return CreateElement(prefix, localName, namespaceURI); - } - - // Returns a XmlNodeList containing - // a list of all descendant elements that match the specified name. - public virtual XmlNodeList GetElementsByTagName(String localName, String namespaceURI) - { - return new XmlElementList(this, localName, namespaceURI); - } - - // Returns the XmlElement with the specified ID. - public virtual XmlElement GetElementById(string elementId) - { - if (_htElementIdMap != null) - { - ArrayList elementList = (ArrayList)(_htElementIdMap[elementId]); - if (elementList != null) - { - foreach (WeakReference elemRef in elementList) - { - XmlElement elem = (XmlElement)elemRef.Target; - if (elem != null - && elem.IsConnected()) - return elem; - } - } - } - return null; - } - - // Imports a node from another document to this document. - public virtual XmlNode ImportNode(XmlNode node, bool deep) - { - return ImportNodeInternal(node, deep); - } - - private XmlNode ImportNodeInternal(XmlNode node, bool deep) - { - XmlNode newNode = null; - - if (node == null) - { - throw new InvalidOperationException(ResXml.Xdom_Import_NullNode); - } - else - { - switch (node.NodeType) - { - case XmlNodeType.Element: - newNode = CreateElement(node.Prefix, node.LocalName, node.NamespaceURI); - ImportAttributes(node, newNode); - if (deep) - ImportChildren(node, newNode, deep); - break; - - case XmlNodeType.Attribute: - Debug.Assert(((XmlAttribute)node).Specified); - newNode = CreateAttribute(node.Prefix, node.LocalName, node.NamespaceURI); - ImportChildren(node, newNode, true); - break; - - case XmlNodeType.Text: - newNode = CreateTextNode(node.Value); - break; - case XmlNodeType.Comment: - newNode = CreateComment(node.Value); - break; - case XmlNodeType.ProcessingInstruction: - newNode = CreateProcessingInstruction(node.Name, node.Value); - break; - case XmlNodeType.XmlDeclaration: - XmlDeclaration decl = (XmlDeclaration)node; - newNode = CreateXmlDeclaration(decl.Version, decl.Encoding, decl.Standalone); - break; - case XmlNodeType.CDATA: - newNode = CreateCDataSection(node.Value); - break; - case XmlNodeType.DocumentType: - XmlDocumentType docType = (XmlDocumentType)node; - newNode = CreateDocumentType(docType.Name, docType.PublicId, docType.SystemId, docType.InternalSubset); - break; - case XmlNodeType.DocumentFragment: - newNode = CreateDocumentFragment(); - if (deep) - ImportChildren(node, newNode, deep); - break; - - case XmlNodeType.EntityReference: - newNode = CreateEntityReference(node.Name); - // we don't import the children of entity reference because they might result in different - // children nodes given different namesapce context in the new document. - break; - - case XmlNodeType.Whitespace: - newNode = CreateWhitespace(node.Value); - break; - - case XmlNodeType.SignificantWhitespace: - newNode = CreateSignificantWhitespace(node.Value); - break; - - default: - throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, ResXml.Xdom_Import, node.NodeType.ToString())); - } - } - - return newNode; - } - - private void ImportAttributes(XmlNode fromElem, XmlNode toElem) - { - int cAttr = fromElem.Attributes.Count; - for (int iAttr = 0; iAttr < cAttr; iAttr++) - { - if (fromElem.Attributes[iAttr].Specified) - toElem.Attributes.SetNamedItem(ImportNodeInternal(fromElem.Attributes[iAttr], true)); - } - } - - private void ImportChildren(XmlNode fromNode, XmlNode toNode, bool deep) - { - Debug.Assert(toNode.NodeType != XmlNodeType.EntityReference); - for (XmlNode n = fromNode.FirstChild; n != null; n = n.NextSibling) - { - toNode.AppendChild(ImportNodeInternal(n, deep)); - } - } - - // Microsoft extensions - - // Gets the XmlNameTable associated with this - // implementation. - public XmlNameTable NameTable - { - get { return _implementation.NameTable; } - } - - // Creates a XmlAttribute with the specified Prefix, LocalName, - // and NamespaceURI. - public virtual XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI) - { - return new XmlAttribute(AddAttrXmlName(prefix, localName, namespaceURI, null), this); - } - - protected internal virtual XmlAttribute CreateDefaultAttribute(string prefix, string localName, string namespaceURI) - { - return new XmlUnspecifiedAttribute(prefix, localName, namespaceURI, this); - } - - public virtual XmlElement CreateElement(string prefix, string localName, string namespaceURI) - { - XmlElement elem = new XmlElement(AddXmlName(prefix, localName, namespaceURI, null), true, this); - if (!IsLoading) - AddDefaultAttributes(elem); - return elem; - } - - // Gets or sets a value indicating whether to preserve whitespace. - public bool PreserveWhitespace - { - get { return _preserveWhitespace; } - set { _preserveWhitespace = value; } - } - - // Gets a value indicating whether the node is read-only. - public override bool IsReadOnly - { - get { return false; } - } - - internal XmlNamedNodeMap Entities - { - get - { - if (_entities == null) - _entities = new XmlNamedNodeMap(this); - return _entities; - } - set { _entities = value; } - } - - internal bool IsLoading - { - get { return _isLoading; } - set { _isLoading = value; } - } - - internal bool ActualLoadingStatus - { - get { return _actualLoadingStatus; } - set { _actualLoadingStatus = value; } - } - - - // Creates a XmlNode with the specified XmlNodeType, Prefix, Name, and NamespaceURI. - public virtual XmlNode CreateNode(XmlNodeType type, string prefix, string name, string namespaceURI) - { - switch (type) - { - case XmlNodeType.Element: - if (prefix != null) - return CreateElement(prefix, name, namespaceURI); - else - return CreateElement(name, namespaceURI); - - case XmlNodeType.Attribute: - if (prefix != null) - return CreateAttribute(prefix, name, namespaceURI); - else - return CreateAttribute(name, namespaceURI); - - case XmlNodeType.Text: - return CreateTextNode(string.Empty); - - case XmlNodeType.CDATA: - return CreateCDataSection(string.Empty); - - case XmlNodeType.EntityReference: - return CreateEntityReference(name); - - case XmlNodeType.ProcessingInstruction: - return CreateProcessingInstruction(name, string.Empty); - - case XmlNodeType.XmlDeclaration: - return CreateXmlDeclaration("1.0", null, null); - - case XmlNodeType.Comment: - return CreateComment(string.Empty); - - case XmlNodeType.DocumentFragment: - return CreateDocumentFragment(); - - case XmlNodeType.DocumentType: - return CreateDocumentType(name, string.Empty, string.Empty, string.Empty); - - case XmlNodeType.Document: - return new XmlDocument(); - - case XmlNodeType.SignificantWhitespace: - return CreateSignificantWhitespace(string.Empty); - - case XmlNodeType.Whitespace: - return CreateWhitespace(string.Empty); - - default: - throw new ArgumentException(string.Format(ResXml.Arg_CannotCreateNode, type)); - } - } - - // Creates an XmlNode with the specified node type, Name, and - // NamespaceURI. - public virtual XmlNode CreateNode(string nodeTypeString, string name, string namespaceURI) - { - return CreateNode(ConvertToNodeType(nodeTypeString), name, namespaceURI); - } - - // Creates an XmlNode with the specified XmlNodeType, Name, and - // NamespaceURI. - public virtual XmlNode CreateNode(XmlNodeType type, string name, string namespaceURI) - { - return CreateNode(type, null, name, namespaceURI); - } - - // Creates an XmlNode object based on the information in the XmlReader. - // The reader must be positioned on a node or attribute. - // [PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )] - public virtual XmlNode ReadNode(XmlReader reader) - { - XmlNode node = null; - try - { - IsLoading = true; - XmlLoader loader = new XmlLoader(); - node = loader.ReadCurrentNode(this, reader); - } - finally - { - IsLoading = false; - } - return node; - } - - internal XmlNodeType ConvertToNodeType(string nodeTypeString) - { - if (nodeTypeString == "element") - { - return XmlNodeType.Element; - } - else if (nodeTypeString == "attribute") - { - return XmlNodeType.Attribute; - } - else if (nodeTypeString == "text") - { - return XmlNodeType.Text; - } - else if (nodeTypeString == "cdatasection") - { - return XmlNodeType.CDATA; - } - else if (nodeTypeString == "entityreference") - { - return XmlNodeType.EntityReference; - } - else if (nodeTypeString == "entity") - { - return XmlNodeType.Entity; - } - else if (nodeTypeString == "processinginstruction") - { - return XmlNodeType.ProcessingInstruction; - } - else if (nodeTypeString == "comment") - { - return XmlNodeType.Comment; - } - else if (nodeTypeString == "document") - { - return XmlNodeType.Document; - } - else if (nodeTypeString == "documenttype") - { - return XmlNodeType.DocumentType; - } - else if (nodeTypeString == "documentfragment") - { - return XmlNodeType.DocumentFragment; - } - else if (nodeTypeString == "notation") - { - return XmlNodeType.Notation; - } - else if (nodeTypeString == "significantwhitespace") - { - return XmlNodeType.SignificantWhitespace; - } - else if (nodeTypeString == "whitespace") - { - return XmlNodeType.Whitespace; - } - throw new ArgumentException(string.Format(ResXml.Xdom_Invalid_NT_String, nodeTypeString)); - } - - - private XmlTextReader SetupReader(XmlTextReader tr) - { - tr.XmlValidatingReaderCompatibilityMode = true; - tr.EntityHandling = EntityHandling.ExpandCharEntities; - if (this.HasSetResolver) - tr.XmlResolver = GetResolver(); - return tr; - } - - // Loads the XML document from the specified URL. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public virtual void Load(string filename) - { - XmlTextReader reader = SetupReader(new XmlTextReader(filename, NameTable)); - try - { - Load(reader); - } - finally - { - reader.Close(); - } - } - - public virtual void Load(Stream inStream) - { - XmlTextReader reader = SetupReader(new XmlTextReader(inStream, NameTable)); - try - { - Load(reader); - } - finally - { - reader.Impl.Close(false); - } - } - - // Loads the XML document from the specified TextReader. - public virtual void Load(TextReader txtReader) - { - XmlTextReader reader = SetupReader(new XmlTextReader(txtReader, NameTable)); - try - { - Load(reader); - } - finally - { - reader.Impl.Close(false); - } - } - - // Loads the XML document from the specified XmlReader. - public virtual void Load(XmlReader reader) - { - try - { - IsLoading = true; - _actualLoadingStatus = true; - RemoveAll(); - fEntRefNodesPresent = false; - fCDataNodesPresent = false; - _reportValidity = true; - - XmlLoader loader = new XmlLoader(); - loader.Load(this, reader, _preserveWhitespace); - } - finally - { - IsLoading = false; - _actualLoadingStatus = false; - - // Ensure the bit is still on after loading a dtd - _reportValidity = true; - } - } - - // Loads the XML document from the specified string. - public virtual void LoadXml(string xml) - { - XmlTextReader reader = SetupReader(new XmlTextReader(new StringReader(xml), NameTable)); - try - { - Load(reader); - } - finally - { - reader.Close(); - } - } - - //TextEncoding is the one from XmlDeclaration if there is any - internal Encoding TextEncoding - { - get - { - if (Declaration != null) - { - string value = Declaration.Encoding; - if (value.Length > 0) - { - return System.Text.Encoding.GetEncoding(value); - } - } - return null; - } - } - - public override string InnerText - { - set - { - throw new InvalidOperationException(ResXml.Xdom_Document_Innertext); - } - } - - public override string InnerXml - { - get - { - return base.InnerXml; - } - set - { - LoadXml(value); - } - } - - // Saves the XML document to the specified file. - //Saves out the to the file with exact content in the XmlDocument. - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public virtual void Save(string filename) - { - if (DocumentElement == null) - throw new XmlException(ResXml.Xml_InvalidXmlDocument, ResXml.Xdom_NoRootEle); - XmlDOMTextWriter xw = new XmlDOMTextWriter(filename, TextEncoding); - try - { - if (_preserveWhitespace == false) - xw.Formatting = Formatting.Indented; - WriteTo(xw); - xw.Flush(); - } - finally - { - xw.Close(); - } - } - - //Saves out the to the file with exact content in the XmlDocument. - public virtual void Save(Stream outStream) - { - XmlDOMTextWriter xw = new XmlDOMTextWriter(outStream, TextEncoding); - if (_preserveWhitespace == false) - xw.Formatting = Formatting.Indented; - WriteTo(xw); - xw.Flush(); - } - - // Saves the XML document to the specified TextWriter. - // - //Saves out the file with xmldeclaration which has encoding value equal to - //that of textwriter's encoding - public virtual void Save(TextWriter writer) - { - XmlDOMTextWriter xw = new XmlDOMTextWriter(writer); - if (_preserveWhitespace == false) - xw.Formatting = Formatting.Indented; - Save(xw); - } - - // Saves the XML document to the specified XmlWriter. - // - //Saves out the file with xmldeclaration which has encoding value equal to - //that of textwriter's encoding - public virtual void Save(XmlWriter w) - { - XmlNode n = this.FirstChild; - if (n == null) - return; - if (w.WriteState == WriteState.Start) - { - if (n is XmlDeclaration) - { - if (Standalone.Length == 0) - w.WriteStartDocument(); - else if (Standalone == "yes") - w.WriteStartDocument(true); - else if (Standalone == "no") - w.WriteStartDocument(false); - n = n.NextSibling; - } - else - { - w.WriteStartDocument(); - } - } - while (n != null) - { - //Debug.Assert( n.NodeType != XmlNodeType.XmlDeclaration ); - n.WriteTo(w); - n = n.NextSibling; - } - w.Flush(); - } - - // Saves the node to the specified XmlWriter. - // - //Writes out the to the file with exact content in the XmlDocument. - public override void WriteTo(XmlWriter w) - { - WriteContentTo(w); - } - - // Saves all the children of the node to the specified XmlWriter. - // - //Writes out the to the file with exact content in the XmlDocument. - public override void WriteContentTo(XmlWriter xw) - { - foreach (XmlNode n in this) - { - n.WriteTo(xw); - } - } - - public void Validate(ValidationEventHandler validationEventHandler) - { - Validate(validationEventHandler, this); - } - - public void Validate(ValidationEventHandler validationEventHandler, XmlNode nodeToValidate) - { - if (_schemas == null || _schemas.Count == 0) - { //Should we error - throw new InvalidOperationException(ResXml.XmlDocument_NoSchemaInfo); - } - XmlDocument parentDocument = nodeToValidate.Document; - if (parentDocument != this) - { - throw new ArgumentException(string.Format(ResXml.XmlDocument_NodeNotFromDocument, "nodeToValidate")); - } - if (nodeToValidate == this) - { - _reportValidity = false; - } - DocumentSchemaValidator validator = new DocumentSchemaValidator(this, _schemas, validationEventHandler); - validator.Validate(nodeToValidate); - if (nodeToValidate == this) - { - _reportValidity = true; - } - } - - public event XmlNodeChangedEventHandler NodeInserting - { - add - { - _onNodeInsertingDelegate += value; - } - remove - { - _onNodeInsertingDelegate -= value; - } - } - - public event XmlNodeChangedEventHandler NodeInserted - { - add - { - _onNodeInsertedDelegate += value; - } - remove - { - _onNodeInsertedDelegate -= value; - } - } - - public event XmlNodeChangedEventHandler NodeRemoving - { - add - { - _onNodeRemovingDelegate += value; - } - remove - { - _onNodeRemovingDelegate -= value; - } - } - - public event XmlNodeChangedEventHandler NodeRemoved - { - add - { - _onNodeRemovedDelegate += value; - } - remove - { - _onNodeRemovedDelegate -= value; - } - } - - public event XmlNodeChangedEventHandler NodeChanging - { - add - { - _onNodeChangingDelegate += value; - } - remove - { - _onNodeChangingDelegate -= value; - } - } - - public event XmlNodeChangedEventHandler NodeChanged - { - add - { - _onNodeChangedDelegate += value; - } - remove - { - _onNodeChangedDelegate -= value; - } - } - - internal override XmlNodeChangedEventArgs GetEventArgs(XmlNode node, XmlNode oldParent, XmlNode newParent, string oldValue, string newValue, XmlNodeChangedAction action) - { - _reportValidity = false; - - switch (action) - { - case XmlNodeChangedAction.Insert: - if (_onNodeInsertingDelegate == null && _onNodeInsertedDelegate == null) - { - return null; - } - break; - case XmlNodeChangedAction.Remove: - if (_onNodeRemovingDelegate == null && _onNodeRemovedDelegate == null) - { - return null; - } - break; - case XmlNodeChangedAction.Change: - if (_onNodeChangingDelegate == null && _onNodeChangedDelegate == null) - { - return null; - } - break; - } - return new XmlNodeChangedEventArgs(node, oldParent, newParent, oldValue, newValue, action); - } - - internal XmlNodeChangedEventArgs GetInsertEventArgsForLoad(XmlNode node, XmlNode newParent) - { - if (_onNodeInsertingDelegate == null && _onNodeInsertedDelegate == null) - { - return null; - } - string nodeValue = node.Value; - return new XmlNodeChangedEventArgs(node, null, newParent, nodeValue, nodeValue, XmlNodeChangedAction.Insert); - } - - internal override void BeforeEvent(XmlNodeChangedEventArgs args) - { - if (args != null) - { - switch (args.Action) - { - case XmlNodeChangedAction.Insert: - if (_onNodeInsertingDelegate != null) - _onNodeInsertingDelegate(this, args); - break; - - case XmlNodeChangedAction.Remove: - if (_onNodeRemovingDelegate != null) - _onNodeRemovingDelegate(this, args); - break; - - case XmlNodeChangedAction.Change: - if (_onNodeChangingDelegate != null) - _onNodeChangingDelegate(this, args); - break; - } - } - } - - internal override void AfterEvent(XmlNodeChangedEventArgs args) - { - if (args != null) - { - switch (args.Action) - { - case XmlNodeChangedAction.Insert: - if (_onNodeInsertedDelegate != null) - _onNodeInsertedDelegate(this, args); - break; - - case XmlNodeChangedAction.Remove: - if (_onNodeRemovedDelegate != null) - _onNodeRemovedDelegate(this, args); - break; - - case XmlNodeChangedAction.Change: - if (_onNodeChangedDelegate != null) - _onNodeChangedDelegate(this, args); - break; - } - } - } - - // The function such through schema info to find out if there exists a default attribute with passed in names in the passed in element - // If so, return the newly created default attribute (with children tree); - // Otherwise, return null. - - internal XmlAttribute GetDefaultAttribute(XmlElement elem, string attrPrefix, string attrLocalname, string attrNamespaceURI) - { - SchemaInfo schInfo = DtdSchemaInfo; - SchemaElementDecl ed = GetSchemaElementDecl(elem); - if (ed != null && ed.AttDefs != null) - { - IDictionaryEnumerator attrDefs = ed.AttDefs.GetEnumerator(); - while (attrDefs.MoveNext()) - { - SchemaAttDef attdef = (SchemaAttDef)attrDefs.Value; - if (attdef.Presence == SchemaDeclBase.Use.Default || - attdef.Presence == SchemaDeclBase.Use.Fixed) - { - if (attdef.Name.Name == attrLocalname) - { - if ((schInfo.SchemaType == SchemaType.DTD && attdef.Name.Namespace == attrPrefix) || - (schInfo.SchemaType != SchemaType.DTD && attdef.Name.Namespace == attrNamespaceURI)) - { - //find a def attribute with the same name, build a default attribute and return - XmlAttribute defattr = PrepareDefaultAttribute(attdef, attrPrefix, attrLocalname, attrNamespaceURI); - return defattr; - } - } - } - } - } - return null; - } - - internal String Version - { - get - { - XmlDeclaration decl = Declaration; - if (decl != null) - return decl.Version; - return null; - } - } - - internal String Encoding - { - get - { - XmlDeclaration decl = Declaration; - if (decl != null) - return decl.Encoding; - return null; - } - } - - internal String Standalone - { - get - { - XmlDeclaration decl = Declaration; - if (decl != null) - return decl.Standalone; - return null; - } - } - - internal XmlEntity GetEntityNode(String name) - { - if (DocumentType != null) - { - XmlNamedNodeMap entites = DocumentType.Entities; - if (entites != null) - return (XmlEntity)(entites.GetNamedItem(name)); - } - return null; - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - if (_reportValidity) - { - XmlElement documentElement = DocumentElement; - if (documentElement != null) - { - switch (documentElement.SchemaInfo.Validity) - { - case XmlSchemaValidity.Valid: - return ValidSchemaInfo; - case XmlSchemaValidity.Invalid: - return InvalidSchemaInfo; - } - } - } - return NotKnownSchemaInfo; - } - } - - public override String BaseURI - { - get { return baseURI; } - } - - internal void SetBaseURI(String inBaseURI) - { - baseURI = inBaseURI; - } - - internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc) - { - Debug.Assert(doc == this); - - if (!IsValidChildType(newChild.NodeType)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_TypeConflict); - - if (!CanInsertAfter(newChild, LastChild)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Location); - - XmlNodeChangedEventArgs args = GetInsertEventArgsForLoad(newChild, this); - - if (args != null) - BeforeEvent(args); - - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - - if (_lastChild == null) - { - newNode.next = newNode; - } - else - { - newNode.next = _lastChild.next; - _lastChild.next = newNode; - } - - _lastChild = newNode; - newNode.SetParentForLoad(this); - - if (args != null) - AfterEvent(args); - - return newNode; - } - - internal override XPathNodeType XPNodeType { get { return XPathNodeType.Root; } } - - internal bool HasEntityReferences - { - get - { - return fEntRefNodesPresent; - } - } - - internal XmlAttribute NamespaceXml - { - get - { - if (_namespaceXml == null) - { - _namespaceXml = new XmlAttribute(AddAttrXmlName(strXmlns, strXml, strReservedXmlns, null), this); - _namespaceXml.Value = strReservedXml; - } - return _namespaceXml; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentFragment.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentFragment.cs deleted file mode 100644 index 6e678b82136..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentFragment.cs +++ /dev/null @@ -1,200 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// DocumentFragment is a "lightweight" or "minimal" -// Document object. It is very common to want to be able to -// extract a portion of a document's tree or to create a new fragment of a -// document. Imagine implementing a user command like cut or rearranging a -// document by moving fragments around. It is desirable to have an object -// which can hold such fragments and it is quite natural to use a Node for -// this purpose. While it is true that a Document object could -// fulfil this role, a Document object can potentially be a -// heavyweight object, depending on the underlying implementation. What is -// really needed for this is a very lightweight object. -// DocumentFragment is such an object. -//

Furthermore, various operations -- such as inserting nodes as children -// of another Node -- may take DocumentFragment -// objects as arguments; this results in all the child nodes of the -// DocumentFragment being moved to the child list of this node. -//

The children of a DocumentFragment node are zero or more -// nodes representing the tops of any sub-trees defining the structure of the -// document. DocumentFragment nodes do not need to be -// well-formed XML documents (although they do need to follow the rules -// imposed upon well-formed XML parsed entities, which can have multiple top -// nodes). For example, a DocumentFragment might have only one -// child and that child node could be a Text node. Such a -// structure model represents neither an HTML document nor a well-formed XML -// document. -//

When a DocumentFragment is inserted into a -// Document (or indeed any other Node that may take -// children) the children of the DocumentFragment and not the -// DocumentFragment itself are inserted into the -// Node. This makes the DocumentFragment very -// useful when the user wishes to create nodes that are siblings; the -// DocumentFragment acts as the parent of these nodes so that the -// user can use the standard methods from the Node interface, -// such as insertBefore() and appendChild(). - -namespace Microsoft.Xml -{ - using System; - - - using System.Diagnostics; - using Microsoft.Xml.XPath; - - // Represents a lightweight object that is useful for tree insert - // operations. - public class XmlDocumentFragment : XmlNode - { - private XmlLinkedNode _lastChild; - - protected internal XmlDocumentFragment(XmlDocument ownerDocument) : base() - { - if (ownerDocument == null) - throw new ArgumentException(ResXml.Xdom_Node_Null_Doc); - parentNode = ownerDocument; - } - - // Gets the name of the node. - public override String Name - { - get { return OwnerDocument.strDocumentFragmentName; } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get { return OwnerDocument.strDocumentFragmentName; } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.DocumentFragment; } - } - - // Gets the parent of this node (for nodes that can have parents). - public override XmlNode ParentNode - { - get { return null; } - } - - // Gets the XmlDocument that contains this node. - public override XmlDocument OwnerDocument - { - get - { - return (XmlDocument)parentNode; - } - } - - // Gets or sets the markup representing just - // the children of this node. - public override string InnerXml - { - get - { - return base.InnerXml; - } - set - { - RemoveAll(); - XmlLoader loader = new XmlLoader(); - //Hack that the content is the same element - loader.ParsePartialContent(this, value, XmlNodeType.Element); - } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - XmlDocument doc = OwnerDocument; - XmlDocumentFragment clone = doc.CreateDocumentFragment(); - if (deep) - clone.CopyChildren(doc, this, deep); - return clone; - } - - internal override bool IsContainer - { - get { return true; } - } - - internal override XmlLinkedNode LastNode - { - get { return _lastChild; } - set { _lastChild = value; } - } - - internal override bool IsValidChildType(XmlNodeType type) - { - switch (type) - { - case XmlNodeType.Element: - case XmlNodeType.Text: - case XmlNodeType.EntityReference: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.CDATA: - return true; - - case XmlNodeType.XmlDeclaration: - //if there is an XmlDeclaration node, it has to be the first node; - XmlNode firstNode = FirstChild; - if (firstNode == null || firstNode.NodeType != XmlNodeType.XmlDeclaration) - return true; - else - return false; //not allowed to insert a second XmlDeclaration node - default: - return false; - } - } - internal override bool CanInsertAfter(XmlNode newChild, XmlNode refChild) - { - Debug.Assert(newChild != null); //should be checked that newChild is not null before this function call - if (newChild.NodeType == XmlNodeType.XmlDeclaration) - { - if (refChild == null) - { - //append at the end - return (LastNode == null); - } - else - return false; - } - return true; - } - - internal override bool CanInsertBefore(XmlNode newChild, XmlNode refChild) - { - Debug.Assert(newChild != null); //should be checked that newChild is not null before this function call - if (newChild.NodeType == XmlNodeType.XmlDeclaration) - { - return (refChild == null || refChild == FirstChild); - } - return true; - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - WriteContentTo(w); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - foreach (XmlNode n in this) - { - n.WriteTo(w); - } - } - - internal override XPathNodeType XPNodeType { get { return XPathNodeType.Root; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentType.cs deleted file mode 100644 index a76c9187a7b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDocumentType.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - using Microsoft.Xml.Schema; - using System.Diagnostics; - - // Contains information associated with the document type declaration. - public class XmlDocumentType : XmlLinkedNode - { - private string _name; - private string _publicId; - private string _systemId; - private string _internalSubset; - private bool _namespaces; - private XmlNamedNodeMap _entities; - private XmlNamedNodeMap _notations; - - // parsed DTD - private SchemaInfo _schemaInfo; - - protected internal XmlDocumentType(string name, string publicId, string systemId, string internalSubset, XmlDocument doc) : base(doc) - { - _name = name; - _publicId = publicId; - _systemId = systemId; - _namespaces = true; - _internalSubset = internalSubset; - Debug.Assert(doc != null); - if (!doc.IsLoading) - { - doc.IsLoading = true; - XmlLoader loader = new XmlLoader(); - loader.ParseDocumentType(this); //will edit notation nodes, etc. - doc.IsLoading = false; - } - } - - // Gets the name of the node. - public override string Name - { - get { return _name; } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get { return _name; } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.DocumentType; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateDocumentType(_name, _publicId, _systemId, _internalSubset); - } - - // - // Microsoft extensions - // - - // Gets a value indicating whether the node is read-only. - public override bool IsReadOnly - { - get - { - return true; // Make entities and notations readonly - } - } - - // Gets the collection of XmlEntity nodes declared in the document type declaration. - public XmlNamedNodeMap Entities - { - get - { - if (_entities == null) - _entities = new XmlNamedNodeMap(this); - - return _entities; - } - } - - // Gets the collection of XmlNotation nodes present in the document type declaration. - public XmlNamedNodeMap Notations - { - get - { - if (_notations == null) - _notations = new XmlNamedNodeMap(this); - - return _notations; - } - } - - // - // DOM Level 2 - // - - // Gets the value of the public identifier on the DOCTYPE declaration. - public string PublicId - { - get { return _publicId; } - } - - // Gets the value of - // the system identifier on the DOCTYPE declaration. - public string SystemId - { - get { return _systemId; } - } - - // Gets the entire value of the DTD internal subset - // on the DOCTYPE declaration. - public string InternalSubset - { - get { return _internalSubset; } - } - - internal bool ParseWithNamespaces - { - get { return _namespaces; } - set { _namespaces = value; } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteDocType(_name, _publicId, _systemId, _internalSubset); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal SchemaInfo DtdSchemaInfo - { - get - { - return _schemaInfo; - } - set - { - _schemaInfo = value; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDomTextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDomTextWriter.cs deleted file mode 100644 index 3895aae7dba..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlDomTextWriter.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.IO; - using System.Text; - using System.Runtime.Versioning; - - // Represents a writer that will make it possible to work with prefixes even - // if the namespace is not specified. - // This is not possible with XmlTextWriter. But this class inherits XmlTextWriter. - internal class XmlDOMTextWriter : XmlTextWriter - { - public XmlDOMTextWriter(Stream w, Encoding encoding) : base(w, encoding) - { - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlDOMTextWriter(String filename, Encoding encoding) : base(filename, encoding) - { - } - - public XmlDOMTextWriter(TextWriter w) : base(w) - { - } - - // Overrides the baseclass implementation so that emptystring prefixes do - // do not fail if namespace is not specified. - public override void WriteStartElement(string prefix, string localName, string ns) - { - if ((ns.Length == 0) && (prefix.Length != 0)) - prefix = ""; - - base.WriteStartElement(prefix, localName, ns); - } - - // Overrides the baseclass implementation so that emptystring prefixes do - // do not fail if namespace is not specified. - public override void WriteStartAttribute(string prefix, string localName, string ns) - { - if ((ns.Length == 0) && (prefix.Length != 0)) - prefix = ""; - - base.WriteStartAttribute(prefix, localName, ns); - } - } -} - - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElement.cs deleted file mode 100644 index 4fa44b6e152..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElement.cs +++ /dev/null @@ -1,638 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Collections; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - // Represents an element. - public class XmlElement : XmlLinkedNode - { - private XmlName _name; - private XmlAttributeCollection _attributes; - private XmlLinkedNode _lastChild; // == this for empty elements otherwise it is the last child - - internal XmlElement(XmlName name, bool empty, XmlDocument doc) : base(doc) - { - Debug.Assert(name != null); - this.parentNode = null; - if (!doc.IsLoading) - { - XmlDocument.CheckName(name.Prefix); - XmlDocument.CheckName(name.LocalName); - } - if (name.LocalName.Length == 0) - throw new ArgumentException(ResXml.Xdom_Empty_LocalName); - _name = name; - if (empty) - { - _lastChild = this; - } - } - - protected internal XmlElement(string prefix, string localName, string namespaceURI, XmlDocument doc) - : this(doc.AddXmlName(prefix, localName, namespaceURI, null), true, doc) - { - } - - internal XmlName XmlName - { - get { return _name; } - set { _name = value; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - XmlDocument doc = OwnerDocument; - bool OrigLoadingStatus = doc.IsLoading; - doc.IsLoading = true; - XmlElement element = doc.CreateElement(Prefix, LocalName, NamespaceURI); - doc.IsLoading = OrigLoadingStatus; - if (element.IsEmpty != this.IsEmpty) - element.IsEmpty = this.IsEmpty; - - if (HasAttributes) - { - foreach (XmlAttribute attr in Attributes) - { - XmlAttribute newAttr = (XmlAttribute)(attr.CloneNode(true)); - if (attr is XmlUnspecifiedAttribute && attr.Specified == false) - ((XmlUnspecifiedAttribute)newAttr).SetSpecified(false); - element.Attributes.InternalAppendAttribute(newAttr); - } - } - if (deep) - element.CopyChildren(doc, this, deep); - - return element; - } - - // Gets the name of the node. - public override string Name - { - get { return _name.Name; } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get { return _name.LocalName; } - } - - // Gets the namespace URI of this node. - public override string NamespaceURI - { - get { return _name.NamespaceURI; } - } - - // Gets or sets the namespace prefix of this node. - public override string Prefix - { - get { return _name.Prefix; } - set { _name = _name.OwnerDocument.AddXmlName(value, LocalName, NamespaceURI, SchemaInfo); } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Element; } - } - - public override XmlNode ParentNode - { - get - { - return this.parentNode; - } - } - - // Gets the XmlDocument that contains this node. - public override XmlDocument OwnerDocument - { - get - { - return _name.OwnerDocument; - } - } - - internal override bool IsContainer - { - get { return true; } - } - - //the function is provided only at Load time to speed up Load process - internal override XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc) - { - XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(newChild, this); - - if (args != null) - doc.BeforeEvent(args); - - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - - if (_lastChild == null - || _lastChild == this) - { // if LastNode == null - newNode.next = newNode; - _lastChild = newNode; // LastNode = newNode; - newNode.SetParentForLoad(this); - } - else - { - XmlLinkedNode refNode = _lastChild; // refNode = LastNode; - newNode.next = refNode.next; - refNode.next = newNode; - _lastChild = newNode; // LastNode = newNode; - if (refNode.IsText - && newNode.IsText) - { - NestTextNodes(refNode, newNode); - } - else - { - newNode.SetParentForLoad(this); - } - } - - if (args != null) - doc.AfterEvent(args); - - return newNode; - } - - // Gets or sets whether the element does not have any children. - public bool IsEmpty - { - get - { - return _lastChild == this; - } - - set - { - if (value) - { - if (_lastChild != this) - { - RemoveAllChildren(); - _lastChild = this; - } - } - else - { - if (_lastChild == this) - { - _lastChild = null; - } - } - } - } - - internal override XmlLinkedNode LastNode - { - get - { - return _lastChild == this ? null : _lastChild; - } - - set - { - _lastChild = value; - } - } - - internal override bool IsValidChildType(XmlNodeType type) - { - switch (type) - { - case XmlNodeType.Element: - case XmlNodeType.Text: - case XmlNodeType.EntityReference: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.CDATA: - return true; - - default: - return false; - } - } - - - // Gets a XmlAttributeCollection containing the list of attributes for this node. - public override XmlAttributeCollection Attributes - { - get - { - if (_attributes == null) - { - lock (OwnerDocument.objLock) - { - if (_attributes == null) - { - _attributes = new XmlAttributeCollection(this); - } - } - } - - return _attributes; - } - } - - // Gets a value indicating whether the current node - // has any attributes. - public virtual bool HasAttributes - { - get - { - if (_attributes == null) - return false; - else - return _attributes.Count > 0; - } - } - - // Returns the value for the attribute with the specified name. - public virtual string GetAttribute(string name) - { - XmlAttribute attr = GetAttributeNode(name); - if (attr != null) - return attr.Value; - return String.Empty; - } - - // Sets the value of the attribute - // with the specified name. - public virtual void SetAttribute(string name, string value) - { - XmlAttribute attr = GetAttributeNode(name); - if (attr == null) - { - attr = OwnerDocument.CreateAttribute(name); - attr.Value = value; - Attributes.InternalAppendAttribute(attr); - } - else - { - attr.Value = value; - } - } - - // Removes an attribute by name. - public virtual void RemoveAttribute(string name) - { - if (HasAttributes) - Attributes.RemoveNamedItem(name); - } - - // Returns the XmlAttribute with the specified name. - public virtual XmlAttribute GetAttributeNode(string name) - { - if (HasAttributes) - return Attributes[name]; - return null; - } - - // Adds the specified XmlAttribute. - public virtual XmlAttribute SetAttributeNode(XmlAttribute newAttr) - { - if (newAttr.OwnerElement != null) - throw new InvalidOperationException(ResXml.Xdom_Attr_InUse); - return (XmlAttribute)Attributes.SetNamedItem(newAttr); - } - - // Removes the specified XmlAttribute. - public virtual XmlAttribute RemoveAttributeNode(XmlAttribute oldAttr) - { - if (HasAttributes) - return (XmlAttribute)Attributes.Remove(oldAttr); - return null; - } - - // Returns a XmlNodeList containing - // a list of all descendant elements that match the specified name. - public virtual XmlNodeList GetElementsByTagName(string name) - { - return new XmlElementList(this, name); - } - - // - // DOM Level 2 - // - - // Returns the value for the attribute with the specified LocalName and NamespaceURI. - public virtual string GetAttribute(string localName, string namespaceURI) - { - XmlAttribute attr = GetAttributeNode(localName, namespaceURI); - if (attr != null) - return attr.Value; - return String.Empty; - } - - // Sets the value of the attribute with the specified name - // and namespace. - public virtual string SetAttribute(string localName, string namespaceURI, string value) - { - XmlAttribute attr = GetAttributeNode(localName, namespaceURI); - if (attr == null) - { - attr = OwnerDocument.CreateAttribute(string.Empty, localName, namespaceURI); - attr.Value = value; - Attributes.InternalAppendAttribute(attr); - } - else - { - attr.Value = value; - } - - return value; - } - - // Removes an attribute specified by LocalName and NamespaceURI. - public virtual void RemoveAttribute(string localName, string namespaceURI) - { - //Debug.Assert(namespaceURI != null); - RemoveAttributeNode(localName, namespaceURI); - } - - // Returns the XmlAttribute with the specified LocalName and NamespaceURI. - public virtual XmlAttribute GetAttributeNode(string localName, string namespaceURI) - { - //Debug.Assert(namespaceURI != null); - if (HasAttributes) - return Attributes[localName, namespaceURI]; - return null; - } - - // Adds the specified XmlAttribute. - public virtual XmlAttribute SetAttributeNode(string localName, string namespaceURI) - { - XmlAttribute attr = GetAttributeNode(localName, namespaceURI); - if (attr == null) - { - attr = OwnerDocument.CreateAttribute(string.Empty, localName, namespaceURI); - Attributes.InternalAppendAttribute(attr); - } - return attr; - } - - // Removes the XmlAttribute specified by LocalName and NamespaceURI. - public virtual XmlAttribute RemoveAttributeNode(string localName, string namespaceURI) - { - //Debug.Assert(namespaceURI != null); - if (HasAttributes) - { - XmlAttribute attr = GetAttributeNode(localName, namespaceURI); - Attributes.Remove(attr); - return attr; - } - return null; - } - - // Returns a XmlNodeList containing - // a list of all descendant elements that match the specified name. - public virtual XmlNodeList GetElementsByTagName(string localName, string namespaceURI) - { - //Debug.Assert(namespaceURI != null); - return new XmlElementList(this, localName, namespaceURI); - } - - // Determines whether the current node has the specified attribute. - public virtual bool HasAttribute(string name) - { - return GetAttributeNode(name) != null; - } - - // Determines whether the current node has the specified - // attribute from the specified namespace. - public virtual bool HasAttribute(string localName, string namespaceURI) - { - return GetAttributeNode(localName, namespaceURI) != null; - } - - // Saves the current node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - if (GetType() == typeof(XmlElement)) - { - // Use the non-recursive version (for XmlElement only) - WriteElementTo(w, this); - } - else - { - // Use the (potentially) recursive version - WriteStartElement(w); - - if (IsEmpty) - { - w.WriteEndElement(); - } - else - { - WriteContentTo(w); - w.WriteFullEndElement(); - } - } - } - - // This method is copied from Microsoft.Xml.Linq.ElementWriter.WriteElement but adapted to DOM - private static void WriteElementTo(XmlWriter writer, XmlElement e) - { - XmlNode root = e; - XmlNode n = e; - while (true) - { - e = n as XmlElement; - // Only use the inlined write logic for XmlElement, not for derived classes - if (e != null && e.GetType() == typeof(XmlElement)) - { - // Write the element - e.WriteStartElement(writer); - // Write the element's content - if (e.IsEmpty) - { - // No content; use a short end element - writer.WriteEndElement(); - } - else if (e._lastChild == null) - { - // No actual content; use a full end element - writer.WriteFullEndElement(); - } - else - { - // There are child node(s); move to first child - n = e.FirstChild; - Debug.Assert(n != null); - continue; - } - } - else - { - // Use virtual dispatch (might recurse) - n.WriteTo(writer); - } - // Go back to the parent after writing the last child - while (n != root && n == n.ParentNode.LastChild) - { - n = n.ParentNode; - Debug.Assert(n != null); - writer.WriteFullEndElement(); - } - if (n == root) - break; - n = n.NextSibling; - Debug.Assert(n != null); - } - } - - // Writes the start of the element (and its attributes) to the specified writer - private void WriteStartElement(XmlWriter w) - { - w.WriteStartElement(Prefix, LocalName, NamespaceURI); - - if (HasAttributes) - { - XmlAttributeCollection attrs = Attributes; - for (int i = 0; i < attrs.Count; i += 1) - { - XmlAttribute attr = attrs[i]; - attr.WriteTo(w); - } - } - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - for (XmlNode node = FirstChild; node != null; node = node.NextSibling) - { - node.WriteTo(w); - } - } - - // Removes the attribute node with the specified index from the attribute collection. - public virtual XmlNode RemoveAttributeAt(int i) - { - if (HasAttributes) - return _attributes.RemoveAt(i); - return null; - } - - // Removes all attributes from the element. - public virtual void RemoveAllAttributes() - { - if (HasAttributes) - { - _attributes.RemoveAll(); - } - } - - // Removes all the children and/or attributes - // of the current node. - public override void RemoveAll() - { - //remove all the children - base.RemoveAll(); - //remove all the attributes - RemoveAllAttributes(); - } - - internal void RemoveAllChildren() - { - base.RemoveAll(); - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - return _name; - } - } - - // Gets or sets the markup representing just - // the children of this node. - public override string InnerXml - { - get - { - return base.InnerXml; - } - set - { - RemoveAllChildren(); - XmlLoader loader = new XmlLoader(); - loader.LoadInnerXmlElement(this, value); - } - } - - // Gets or sets the concatenated values of the - // node and all its children. - public override string InnerText - { - get - { - return base.InnerText; - } - set - { - XmlLinkedNode linkedNode = LastNode; - if (linkedNode != null && //there is one child - linkedNode.NodeType == XmlNodeType.Text && //which is text node - linkedNode.next == linkedNode) // and it is the only child - { - //this branch is for perf reason, event fired when TextNode.Value is changed. - linkedNode.Value = value; - } - else - { - RemoveAllChildren(); - AppendChild(OwnerDocument.CreateTextNode(value)); - } - } - } - - public override XmlNode NextSibling - { - get - { - if (this.parentNode != null - && this.parentNode.LastNode != this) - return next; - return null; - } - } - - internal override void SetParent(XmlNode node) - { - this.parentNode = node; - } - - internal override XPathNodeType XPNodeType { get { return XPathNodeType.Element; } } - - internal override string XPLocalName { get { return LocalName; } } - - internal override string GetXPAttribute(string localName, string ns) - { - if (ns == OwnerDocument.strReservedXmlns) - return null; - XmlAttribute attr = GetAttributeNode(localName, ns); - if (attr != null) - return attr.Value; - return string.Empty; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElementList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElementList.cs deleted file mode 100644 index a33bc6f3e56..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlElementList.cs +++ /dev/null @@ -1,399 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Collections; - using System.Diagnostics; - - internal class XmlElementList : XmlNodeList - { - private string _asterisk; - private int _changeCount; //recording the total number that the dom tree has been changed ( insertion and deletetion ) - //the member vars below are saved for further reconstruction - private string _name; //only one of 2 string groups will be initialized depends on which constructor is called. - private string _localName; - private string _namespaceURI; - private XmlNode _rootNode; - // the memeber vars belwo serves the optimization of accessing of the elements in the list - private int _curInd; // -1 means the starting point for a new search round - private XmlNode _curElem; // if sets to rootNode, means the starting point for a new search round - private bool _empty; // whether the list is empty - private bool _atomized; //whether the localname and namespaceuri are aomized - private int _matchCount; // cached list count. -1 means it needs reconstruction - - private WeakReference _listener; // XmlElementListListener - - private XmlElementList(XmlNode parent) - { - Debug.Assert(parent != null); - Debug.Assert(parent.NodeType == XmlNodeType.Element || parent.NodeType == XmlNodeType.Document); - _rootNode = parent; - Debug.Assert(parent.Document != null); - _curInd = -1; - _curElem = _rootNode; - _changeCount = 0; - _empty = false; - _atomized = true; - _matchCount = -1; - // This can be a regular reference, but it would cause some kind of loop inside the GC - _listener = new WeakReference(new XmlElementListListener(parent.Document, this)); - } - - ~XmlElementList() - { - Dispose(false); - } - - internal void ConcurrencyCheck(XmlNodeChangedEventArgs args) - { - if (_atomized == false) - { - XmlNameTable nameTable = _rootNode.Document.NameTable; - _localName = nameTable.Add(_localName); - _namespaceURI = nameTable.Add(_namespaceURI); - _atomized = true; - } - if (IsMatch(args.Node)) - { - _changeCount++; - _curInd = -1; - _curElem = _rootNode; - if (args.Action == XmlNodeChangedAction.Insert) - _empty = false; - } - _matchCount = -1; - } - - internal XmlElementList(XmlNode parent, string name) : this(parent) - { - Debug.Assert(parent.Document != null); - XmlNameTable nt = parent.Document.NameTable; - Debug.Assert(nt != null); - _asterisk = nt.Add("*"); - _name = nt.Add(name); - _localName = null; - _namespaceURI = null; - } - - internal XmlElementList(XmlNode parent, string localName, string namespaceURI) : this(parent) - { - Debug.Assert(parent.Document != null); - XmlNameTable nt = parent.Document.NameTable; - Debug.Assert(nt != null); - _asterisk = nt.Add("*"); - _localName = nt.Get(localName); - _namespaceURI = nt.Get(namespaceURI); - if ((_localName == null) || (_namespaceURI == null)) - { - _empty = true; - _atomized = false; - _localName = localName; - _namespaceURI = namespaceURI; - } - _name = null; - } - - internal int ChangeCount - { - get { return _changeCount; } - } - - // return the next element node that is in PreOrder - private XmlNode NextElemInPreOrder(XmlNode curNode) - { - Debug.Assert(curNode != null); - //For preorder walking, first try its child - XmlNode retNode = curNode.FirstChild; - if (retNode == null) - { - //if no child, the next node forward will the be the NextSibling of the first ancestor which has NextSibling - //so, first while-loop find out such an ancestor (until no more ancestor or the ancestor is the rootNode - retNode = curNode; - while (retNode != null - && retNode != _rootNode - && retNode.NextSibling == null) - { - retNode = retNode.ParentNode; - } - //then if such ancestor exists, set the retNode to its NextSibling - if (retNode != null && retNode != _rootNode) - retNode = retNode.NextSibling; - } - if (retNode == _rootNode) - //if reach the rootNode, consider having walked through the whole tree and no more element after the curNode - retNode = null; - return retNode; - } - - // return the previous element node that is in PreOrder - private XmlNode PrevElemInPreOrder(XmlNode curNode) - { - Debug.Assert(curNode != null); - //For preorder walking, the previous node will be the right-most node in the tree of PreviousSibling of the curNode - XmlNode retNode = curNode.PreviousSibling; - // so if the PreviousSibling is not null, going through the tree down to find the right-most node - while (retNode != null) - { - if (retNode.LastChild == null) - break; - retNode = retNode.LastChild; - } - // if no PreviousSibling, the previous node will be the curNode's parentNode - if (retNode == null) - retNode = curNode.ParentNode; - // if the final retNode is rootNode, consider having walked through the tree and no more previous node - if (retNode == _rootNode) - retNode = null; - return retNode; - } - - // if the current node a matching element node - private bool IsMatch(XmlNode curNode) - { - if (curNode.NodeType == XmlNodeType.Element) - { - if (_name != null) - { - if (Ref.Equal(_name, _asterisk) || Ref.Equal(curNode.Name, _name)) - return true; - } - else - { - if ( - (Ref.Equal(_localName, _asterisk) || Ref.Equal(curNode.LocalName, _localName)) && - (Ref.Equal(_namespaceURI, _asterisk) || curNode.NamespaceURI == _namespaceURI) - ) - { - return true; - } - } - } - return false; - } - - private XmlNode GetMatchingNode(XmlNode n, bool bNext) - { - Debug.Assert(n != null); - XmlNode node = n; - do - { - if (bNext) - node = NextElemInPreOrder(node); - else - node = PrevElemInPreOrder(node); - } while (node != null && !IsMatch(node)); - return node; - } - - private XmlNode GetNthMatchingNode(XmlNode n, bool bNext, int nCount) - { - Debug.Assert(n != null); - XmlNode node = n; - for (int ind = 0; ind < nCount; ind++) - { - node = GetMatchingNode(node, bNext); - if (node == null) - return null; - } - return node; - } - - //the function is for the enumerator to find out the next available matching element node - public XmlNode GetNextNode(XmlNode n) - { - if (_empty == true) - return null; - XmlNode node = (n == null) ? _rootNode : n; - return GetMatchingNode(node, true); - } - - public override XmlNode Item(int index) - { - if (_rootNode == null || index < 0) - return null; - - if (_empty == true) - return null; - if (_curInd == index) - return _curElem; - int nDiff = index - _curInd; - bool bForward = (nDiff > 0); - if (nDiff < 0) - nDiff = -nDiff; - XmlNode node; - if ((node = GetNthMatchingNode(_curElem, bForward, nDiff)) != null) - { - _curInd = index; - _curElem = node; - return _curElem; - } - return null; - } - - public override int Count - { - get - { - if (_empty == true) - return 0; - if (_matchCount < 0) - { - int currMatchCount = 0; - int currChangeCount = _changeCount; - XmlNode node = _rootNode; - while ((node = GetMatchingNode(node, true)) != null) - { - currMatchCount++; - } - if (currChangeCount != _changeCount) - { - return currMatchCount; - } - _matchCount = currMatchCount; - } - return _matchCount; - } - } - - public override IEnumerator GetEnumerator() - { - if (_empty == true) - return new XmlEmptyElementListEnumerator(this); ; - return new XmlElementListEnumerator(this); - } - - protected override void PrivateDisposeNodeList() - { - GC.SuppressFinalize(this); - Dispose(true); - } - - protected virtual void Dispose(bool disposing) - { - if (_listener != null) - { - XmlElementListListener listener = (XmlElementListListener)_listener.Target; - if (listener != null) - { - listener.Unregister(); - } - _listener = null; - } - } - } - - internal class XmlElementListEnumerator : IEnumerator - { - private XmlElementList _list; - private XmlNode _curElem; - private int _changeCount; //save the total number that the dom tree has been changed ( insertion and deletetion ) when this enumerator is created - - public XmlElementListEnumerator(XmlElementList list) - { - _list = list; - _curElem = null; - _changeCount = list.ChangeCount; - } - - public bool MoveNext() - { - if (_list.ChangeCount != _changeCount) - { - //the number mismatch, there is new change(s) happened since last MoveNext() is called. - throw new InvalidOperationException(ResXml.Xdom_Enum_ElementList); - } - else - { - _curElem = _list.GetNextNode(_curElem); - } - return _curElem != null; - } - - public void Reset() - { - _curElem = null; - //reset the number of changes to be synced with current dom tree as well - _changeCount = _list.ChangeCount; - } - - public object Current - { - get { return _curElem; } - } - } - - internal class XmlEmptyElementListEnumerator : IEnumerator - { - public XmlEmptyElementListEnumerator(XmlElementList list) - { - } - - public bool MoveNext() - { - return false; - } - - public void Reset() - { - } - - public object Current - { - get { return null; } - } - } - - internal class XmlElementListListener - { - private WeakReference _elemList; - private XmlDocument _doc; - private XmlNodeChangedEventHandler _nodeChangeHandler = null; - - internal XmlElementListListener(XmlDocument doc, XmlElementList elemList) - { - _doc = doc; - _elemList = new WeakReference(elemList); - _nodeChangeHandler = new XmlNodeChangedEventHandler(this.OnListChanged); - doc.NodeInserted += _nodeChangeHandler; - doc.NodeRemoved += _nodeChangeHandler; - } - - private void OnListChanged(object sender, XmlNodeChangedEventArgs args) - { - lock (this) - { - if (_elemList != null) - { - XmlElementList el = (XmlElementList)_elemList.Target; - if (null != el) - { - el.ConcurrencyCheck(args); - } - else - { - _doc.NodeInserted -= _nodeChangeHandler; - _doc.NodeRemoved -= _nodeChangeHandler; - _elemList = null; - } - } - } - } - - // This method is called from the finalizer of XmlElementList - internal void Unregister() - { - lock (this) - { - if (_elemList != null) - { - _doc.NodeInserted -= _nodeChangeHandler; - _doc.NodeRemoved -= _nodeChangeHandler; - _elemList = null; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntity.cs deleted file mode 100644 index c2242b53a0b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntity.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Diagnostics; - - // Represents a parsed or unparsed entity in the XML document. - public class XmlEntity : XmlNode - { - private string _publicId; - private string _systemId; - private String _notationName; - private String _name; - private String _unparsedReplacementStr; - private String _baseURI; - private XmlLinkedNode _lastChild; - private bool _childrenFoliating; - - internal XmlEntity(String name, String strdata, string publicId, string systemId, String notationName, XmlDocument doc) : base(doc) - { - _name = doc.NameTable.Add(name); - _publicId = publicId; - _systemId = systemId; - _notationName = notationName; - _unparsedReplacementStr = strdata; - _childrenFoliating = false; - } - - // Throws an excption since an entity can not be cloned. - public override XmlNode CloneNode(bool deep) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Cloning); - } - - // - // Microsoft extensions - // - - // Gets a value indicating whether the node is read-only. - public override bool IsReadOnly - { - get - { - return true; // Make entities readonly - } - } - - - // Gets the name of the node. - public override string Name - { - get { return _name; } - } - - // Gets the name of the node without the namespace prefix. - public override string LocalName - { - get { return _name; } - } - - // Gets the concatenated values of the entity node and all its children. - // The property is read-only and when tried to be set, exception will be thrown. - public override string InnerText - { - get { return base.InnerText; } - set - { - throw new InvalidOperationException(ResXml.Xdom_Ent_Innertext); - } - } - - internal override bool IsContainer - { - get { return true; } - } - - internal override XmlLinkedNode LastNode - { - get - { - if (_lastChild == null && !_childrenFoliating) - { //expand the unparsedreplacementstring - _childrenFoliating = true; - //wrap the replacement string with an element - XmlLoader loader = new XmlLoader(); - loader.ExpandEntity(this); - } - return _lastChild; - } - set { _lastChild = value; } - } - - internal override bool IsValidChildType(XmlNodeType type) - { - return (type == XmlNodeType.Text || - type == XmlNodeType.Element || - type == XmlNodeType.ProcessingInstruction || - type == XmlNodeType.Comment || - type == XmlNodeType.CDATA || - type == XmlNodeType.Whitespace || - type == XmlNodeType.SignificantWhitespace || - type == XmlNodeType.EntityReference); - } - - // Gets the type of the node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Entity; } - } - - // Gets the value of the public identifier on the entity declaration. - public String PublicId - { - get { return _publicId; } - } - - // Gets the value of the system identifier on the entity declaration. - public String SystemId - { - get { return _systemId; } - } - - // Gets the name of the optional NDATA attribute on the - // entity declaration. - public String NotationName - { - get { return _notationName; } - } - - //Without override these two functions, we can't guarantee that WriteTo()/WriteContent() functions will never be called - public override String OuterXml - { - get { return String.Empty; } - } - - public override String InnerXml - { - get { return String.Empty; } - set { throw new InvalidOperationException(ResXml.Xdom_Set_InnerXml); } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - } - - public override String BaseURI - { - get { return _baseURI; } - } - - internal void SetBaseURI(String inBaseURI) - { - _baseURI = inBaseURI; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntityReference.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntityReference.cs deleted file mode 100644 index 5522d1277af..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEntityReference.cs +++ /dev/null @@ -1,216 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// EntityReference objects may be inserted into the structure -// model when an entity reference is in the source document, or when the user -// wishes to insert an entity reference. Note that character references and -// references to predefined entities are considered to be expanded by the -// HTML or XML processor so that characters are represented by their Unicode -// equivalent rather than by an entity reference. Moreover, the XML -// processor may completely expand references to entities while building the -// structure model, instead of providing EntityReference -// objects. If it does provide such objects, then for a given -// EntityReference node, it may be that there is no -// Entity node representing the referenced entity; but if such -// an Entity exists, then the child list of the -// EntityReference node is the same as that of the -// Entity node. As with the Entity node, all -// descendants of the EntityReference are readonly. -//

The resolution of the children of the EntityReference (the -// replacement value of the referenced Entity) may be lazily -// evaluated; actions by the user (such as calling the -// childNodes method on the EntityReference node) -// are assumed to trigger the evaluation. - -namespace Microsoft.Xml -{ - using System; - - - using System.Diagnostics; - - // Represents an entity reference node. - public class XmlEntityReference : XmlLinkedNode - { - private string _name; - private XmlLinkedNode _lastChild; - - protected internal XmlEntityReference(string name, XmlDocument doc) : base(doc) - { - if (!doc.IsLoading) - { - if (name.Length > 0 && name[0] == '#') - { - throw new ArgumentException(ResXml.Xdom_InvalidCharacter_EntityReference); - } - } - _name = doc.NameTable.Add(name); - doc.fEntRefNodesPresent = true; - } - - // Gets the name of the node. - public override string Name - { - get { return _name; } - } - - // Gets the name of the node without the namespace prefix. - public override string LocalName - { - get { return _name; } - } - - // Gets or sets the value of the node. - public override String Value - { - get - { - return null; - } - - set - { - throw new InvalidOperationException(ResXml.Xdom_EntRef_SetVal); - } - } - - // Gets the type of the node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.EntityReference; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - XmlEntityReference eref = OwnerDocument.CreateEntityReference(_name); - return eref; - } - - // - // Microsoft extensions - // - - // Gets a value indicating whether the node is read-only. - public override bool IsReadOnly - { - get - { - return true; // Make entity references readonly - } - } - - internal override bool IsContainer - { - get { return true; } - } - - internal override void SetParent(XmlNode node) - { - base.SetParent(node); - if (LastNode == null && node != null && node != OwnerDocument) - { - //first time insert the entity reference into the tree, we should expand its children now - XmlLoader loader = new XmlLoader(); - loader.ExpandEntityReference(this); - } - } - - internal override void SetParentForLoad(XmlNode node) - { - this.SetParent(node); - } - - internal override XmlLinkedNode LastNode - { - get - { - return _lastChild; - } - set { _lastChild = value; } - } - - internal override bool IsValidChildType(XmlNodeType type) - { - switch (type) - { - case XmlNodeType.Element: - case XmlNodeType.Text: - case XmlNodeType.EntityReference: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.CDATA: - return true; - - default: - return false; - } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteEntityRef(_name); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // -- eventually will the fix. commented out waiting for finalizing on the issue. - foreach (XmlNode n in this) - { - n.WriteTo(w); - } //still use the old code to generate the output - /* - foreach( XmlNode n in this ) { - if ( n.NodeType != XmlNodeType.EntityReference ) - n.WriteTo( w ); - else - n.WriteContentTo( w ); - }*/ - } - - public override String BaseURI - { - get - { - return OwnerDocument.BaseURI; - } - } - - private string ConstructBaseURI(string baseURI, string systemId) - { - if (baseURI == null) - return systemId; - int nCount = baseURI.LastIndexOf('/') + 1; - string buf = baseURI; - if (nCount > 0 && nCount < baseURI.Length) - buf = baseURI.Substring(0, nCount); - else if (nCount == 0) - buf = buf + "\\"; - return (buf + systemId.Replace('\\', '/')); - } - - //childrenBaseURI returns where the entity reference node's children come from - internal String ChildBaseURI - { - get - { - //get the associate entity and return its baseUri - XmlEntity ent = OwnerDocument.GetEntityNode(_name); - if (ent != null) - { - if (ent.SystemId != null && ent.SystemId.Length > 0) - return ConstructBaseURI(ent.BaseURI, ent.SystemId); - else - return ent.BaseURI; - } - return String.Empty; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEventChangedAction.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEventChangedAction.cs deleted file mode 100644 index 2c6725810c4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlEventChangedAction.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - // Specifies the type of node change - public enum XmlNodeChangedAction - { - // A node is beeing inserted in the tree. - Insert = 0, - - // A node is beeing removed from the tree. - Remove = 1, - - // A node value is beeing changed. - Change = 2 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlImplementation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlImplementation.cs deleted file mode 100644 index 35d39b9ac77..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlImplementation.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; - -namespace Microsoft.Xml -{ - using System; - - - // Provides methods for performing operations that are independent of any - // particular instance of the document object model. - public class XmlImplementation - { - private XmlNameTable _nameTable; - - // Initializes a new instance of the XmlImplementation class. - public XmlImplementation() : this(new NameTable()) - { - } - - public XmlImplementation(XmlNameTable nt) - { - _nameTable = nt; - } - - // Test if the DOM implementation implements a specific feature. - public bool HasFeature(string strFeature, string strVersion) - { - if (String.Compare("XML", strFeature, StringComparison.OrdinalIgnoreCase) == 0) - { - if (strVersion == null || strVersion == "1.0" || strVersion == "2.0") - return true; - } - return false; - } - - // Creates a new XmlDocument. All documents created from the same - // XmlImplementation object share the same name table. - public virtual XmlDocument CreateDocument() - { - return new XmlDocument(this); - } - - internal XmlNameTable NameTable - { - get { return _nameTable; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLinkedNode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLinkedNode.cs deleted file mode 100644 index 2706a93e1f4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLinkedNode.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - // Gets the node immediately preceeding or following this node. - public abstract class XmlLinkedNode : XmlNode - { - internal XmlLinkedNode next; - - internal XmlLinkedNode() : base() - { - next = null; - } - internal XmlLinkedNode(XmlDocument doc) : base(doc) - { - next = null; - } - - // Gets the node immediately preceding this node. - public override XmlNode PreviousSibling - { - get - { - XmlNode parent = ParentNode; - if (parent != null) - { - XmlNode node = parent.FirstChild; - while (node != null) - { - XmlNode nextSibling = node.NextSibling; - if (nextSibling == this) - { - break; - } - node = nextSibling; - } - return node; - } - return null; - } - } - - // Gets the node immediately following this node. - public override XmlNode NextSibling - { - get - { - XmlNode parent = ParentNode; - if (parent != null) - { - if (next != parent.FirstChild) - return next; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLoader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLoader.cs deleted file mode 100644 index c7c5ed8e8ff..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlLoader.cs +++ /dev/null @@ -1,1010 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.IO; - using System.Collections; - using System.Diagnostics; - using System.Text; - using Microsoft.Xml.Schema; - using System.Globalization; - - internal class XmlLoader - { - private XmlDocument _doc; - private XmlReader _reader; - private bool _preserveWhitespace; - - - public XmlLoader() - { - } - - internal void Load(XmlDocument doc, XmlReader reader, bool preserveWhitespace) - { - _doc = doc; - // perf: unwrap XmlTextReader if no one derived from it - if (reader.GetType() == typeof(Microsoft.Xml.XmlTextReader)) - { - _reader = ((XmlTextReader)reader).Impl; - } - else - { - _reader = reader; - } - _preserveWhitespace = preserveWhitespace; - if (doc == null) - throw new ArgumentException(ResXml.Xdom_Load_NoDocument); - if (reader == null) - throw new ArgumentException(ResXml.Xdom_Load_NoReader); - doc.SetBaseURI(reader.BaseURI); - if (reader.Settings != null - && reader.Settings.ValidationType == ValidationType.Schema) - { - doc.Schemas = reader.Settings.Schemas; - } - if (_reader.ReadState != ReadState.Interactive) - { - if (!_reader.Read()) - return; - } - LoadDocSequence(doc); - } - - //The function will start loading the document from where current XmlReader is pointing at. - private void LoadDocSequence(XmlDocument parentDoc) - { - Debug.Assert(_reader != null); - Debug.Assert(parentDoc != null); - XmlNode node = null; - while ((node = LoadNode(true)) != null) - { - parentDoc.AppendChildForLoad(node, parentDoc); - if (!_reader.Read()) - return; - } - } - - internal XmlNode ReadCurrentNode(XmlDocument doc, XmlReader reader) - { - _doc = doc; - _reader = reader; - // WS are optional only for loading (see XmlDocument.PreserveWhitespace) - _preserveWhitespace = true; - if (doc == null) - throw new ArgumentException(ResXml.Xdom_Load_NoDocument); - if (reader == null) - throw new ArgumentException(ResXml.Xdom_Load_NoReader); - - if (reader.ReadState == ReadState.Initial) - { - reader.Read(); - } - if (reader.ReadState == ReadState.Interactive) - { - XmlNode n = LoadNode(true); - - // Move to the next node - if (n.NodeType != XmlNodeType.Attribute) - reader.Read(); - - return n; - } - return null; - } - - private XmlNode LoadNode(bool skipOverWhitespace) - { - XmlReader r = _reader; - XmlNode parent = null; - XmlElement element; - IXmlSchemaInfo schemaInfo; - do - { - XmlNode node = null; - switch (r.NodeType) - { - case XmlNodeType.Element: - bool fEmptyElement = r.IsEmptyElement; - element = _doc.CreateElement(r.Prefix, r.LocalName, r.NamespaceURI); - element.IsEmpty = fEmptyElement; - - if (r.MoveToFirstAttribute()) - { - XmlAttributeCollection attributes = element.Attributes; - do - { - XmlAttribute attr = LoadAttributeNode(); - attributes.Append(attr); // special case for load - } - while (r.MoveToNextAttribute()); - r.MoveToElement(); - } - - // recursively load all children. - if (!fEmptyElement) - { - if (parent != null) - { - parent.AppendChildForLoad(element, _doc); - } - parent = element; - continue; - } - else - { - schemaInfo = r.SchemaInfo; - if (schemaInfo != null) - { - element.XmlName = _doc.AddXmlName(element.Prefix, element.LocalName, element.NamespaceURI, schemaInfo); - } - node = element; - break; - } - - case XmlNodeType.EndElement: - if (parent == null) - { - return null; - } - Debug.Assert(parent.NodeType == XmlNodeType.Element); - schemaInfo = r.SchemaInfo; - if (schemaInfo != null) - { - element = parent as XmlElement; - if (element != null) - { - element.XmlName = _doc.AddXmlName(element.Prefix, element.LocalName, element.NamespaceURI, schemaInfo); - } - } - if (parent.ParentNode == null) - { - return parent; - } - parent = parent.ParentNode; - continue; - - case XmlNodeType.EntityReference: - node = LoadEntityReferenceNode(false); - break; - - case XmlNodeType.EndEntity: - Debug.Assert(parent == null); - return null; - - case XmlNodeType.Attribute: - node = LoadAttributeNode(); - break; - - case XmlNodeType.Text: - node = _doc.CreateTextNode(r.Value); - break; - - case XmlNodeType.SignificantWhitespace: - node = _doc.CreateSignificantWhitespace(r.Value); - break; - - case XmlNodeType.Whitespace: - if (_preserveWhitespace) - { - node = _doc.CreateWhitespace(r.Value); - break; - } - else if (parent == null && !skipOverWhitespace) - { - // if called from LoadEntityReferenceNode, just return null - return null; - } - else - { - continue; - } - case XmlNodeType.CDATA: - node = _doc.CreateCDataSection(r.Value); - break; - - - case XmlNodeType.XmlDeclaration: - node = LoadDeclarationNode(); - break; - - case XmlNodeType.ProcessingInstruction: - node = _doc.CreateProcessingInstruction(r.Name, r.Value); - break; - - case XmlNodeType.Comment: - node = _doc.CreateComment(r.Value); - break; - - case XmlNodeType.DocumentType: - node = LoadDocumentTypeNode(); - break; - - default: - throw UnexpectedNodeType(r.NodeType); - } - - Debug.Assert(node != null); - if (parent != null) - { - parent.AppendChildForLoad(node, _doc); - } - else - { - return node; - } - } - while (r.Read()); - - // when the reader ended before full subtree is read, return whatever we have created so far - if (parent != null) - { - while (parent.ParentNode != null) - { - parent = parent.ParentNode; - } - } - return parent; - } - - private XmlAttribute LoadAttributeNode() - { - Debug.Assert(_reader.NodeType == XmlNodeType.Attribute); - - XmlReader r = _reader; - if (r.IsDefault) - { - return LoadDefaultAttribute(); - } - - XmlAttribute attr = _doc.CreateAttribute(r.Prefix, r.LocalName, r.NamespaceURI); - IXmlSchemaInfo schemaInfo = r.SchemaInfo; - if (schemaInfo != null) - { - attr.XmlName = _doc.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, schemaInfo); - } - while (r.ReadAttributeValue()) - { - XmlNode node; - switch (r.NodeType) - { - case XmlNodeType.Text: - node = _doc.CreateTextNode(r.Value); - break; - case XmlNodeType.EntityReference: - node = _doc.CreateEntityReference(r.LocalName); - if (r.CanResolveEntity) - { - r.ResolveEntity(); - LoadAttributeValue(node, false); - // Code internally relies on the fact that an EntRef nodes has at least one child (even an empty text node). Ensure that this holds true, - // if the reader does not present any children for the ent-ref - if (node.FirstChild == null) - { - node.AppendChildForLoad(_doc.CreateTextNode(string.Empty), _doc); - } - } - break; - default: - throw UnexpectedNodeType(r.NodeType); - } - Debug.Assert(node != null); - attr.AppendChildForLoad(node, _doc); - } - - return attr; - } - - private XmlAttribute LoadDefaultAttribute() - { - Debug.Assert(_reader.IsDefault); - - XmlReader r = _reader; - XmlAttribute attr = _doc.CreateDefaultAttribute(r.Prefix, r.LocalName, r.NamespaceURI); - IXmlSchemaInfo schemaInfo = r.SchemaInfo; - if (schemaInfo != null) - { - attr.XmlName = _doc.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, schemaInfo); - } - - LoadAttributeValue(attr, false); - - XmlUnspecifiedAttribute defAttr = attr as XmlUnspecifiedAttribute; - // If user overrides CreateDefaultAttribute, then attr will NOT be a XmlUnspecifiedAttribute instance. - if (defAttr != null) - defAttr.SetSpecified(false); - - return attr; - } - - private void LoadAttributeValue(XmlNode parent, bool direct) - { - XmlReader r = _reader; - while (r.ReadAttributeValue()) - { - XmlNode node; - switch (r.NodeType) - { - case XmlNodeType.Text: - node = direct ? new XmlText(r.Value, _doc) : _doc.CreateTextNode(r.Value); - break; - case XmlNodeType.EndEntity: - return; - case XmlNodeType.EntityReference: - node = direct ? new XmlEntityReference(_reader.LocalName, _doc) : _doc.CreateEntityReference(_reader.LocalName); - if (r.CanResolveEntity) - { - r.ResolveEntity(); - LoadAttributeValue(node, direct); - // Code internally relies on the fact that an EntRef nodes has at least one child (even an empty text node). Ensure that this holds true, - // if the reader does not present any children for the ent-ref - if (node.FirstChild == null) - { - node.AppendChildForLoad(direct ? new XmlText(string.Empty) : _doc.CreateTextNode(string.Empty), _doc); - } - } - break; - default: - throw UnexpectedNodeType(r.NodeType); - } - Debug.Assert(node != null); - parent.AppendChildForLoad(node, _doc); - } - return; - } - - private XmlEntityReference LoadEntityReferenceNode(bool direct) - { - Debug.Assert(_reader.NodeType == XmlNodeType.EntityReference); - XmlEntityReference eref = direct ? new XmlEntityReference(_reader.Name, _doc) : _doc.CreateEntityReference(_reader.Name); - if (_reader.CanResolveEntity) - { - _reader.ResolveEntity(); - while (_reader.Read() && _reader.NodeType != XmlNodeType.EndEntity) - { - XmlNode node = direct ? LoadNodeDirect() : LoadNode(false); - if (node != null) - { - eref.AppendChildForLoad(node, _doc); - } - } - // Code internally relies on the fact that an EntRef nodes has at least one child (even an empty text node). Ensure that this holds true, - // if the reader does not present any children for the ent-ref - if (eref.LastChild == null) - eref.AppendChildForLoad(_doc.CreateTextNode(string.Empty), _doc); - } - return eref; - } - - private XmlDeclaration LoadDeclarationNode() - { - Debug.Assert(_reader.NodeType == XmlNodeType.XmlDeclaration); - - //parse data - string version = null; - string encoding = null; - string standalone = null; - - // Try first to use the reader to get the xml decl "attributes". Since not all readers are required to support this, it is possible to have - // implementations that do nothing - while (_reader.MoveToNextAttribute()) - { - switch (_reader.Name) - { - case "version": - version = _reader.Value; - break; - case "encoding": - encoding = _reader.Value; - break; - case "standalone": - standalone = _reader.Value; - break; - default: - Debug.Assert(false); - break; - } - } - - // For readers that do not break xml decl into attributes, we must parse the xml decl ourselfs. We use version attr, b/c xml decl MUST contain - // at least version attr, so if the reader implements them as attr, then version must be present - if (version == null) - ParseXmlDeclarationValue(_reader.Value, out version, out encoding, out standalone); - - return _doc.CreateXmlDeclaration(version, encoding, standalone); - } - - private XmlDocumentType LoadDocumentTypeNode() - { - Debug.Assert(_reader.NodeType == XmlNodeType.DocumentType); - - String publicId = null; - String systemId = null; - String internalSubset = _reader.Value; - String localName = _reader.LocalName; - while (_reader.MoveToNextAttribute()) - { - switch (_reader.Name) - { - case "PUBLIC": - publicId = _reader.Value; - break; - case "SYSTEM": - systemId = _reader.Value; - break; - } - } - - XmlDocumentType dtNode = _doc.CreateDocumentType(localName, publicId, systemId, internalSubset); - - IDtdInfo dtdInfo = _reader.DtdInfo; - if (dtdInfo != null) - LoadDocumentType(dtdInfo, dtNode); - else - { - //construct our own XmlValidatingReader to parse the DocumentType node so we could get Entities and notations information - ParseDocumentType(dtNode); - } - - return dtNode; - } - - // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes, - // becaouse we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, becaouse - // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the - // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added. - private XmlNode LoadNodeDirect() - { - XmlReader r = _reader; - XmlNode parent = null; - do - { - XmlNode node = null; - switch (r.NodeType) - { - case XmlNodeType.Element: - bool fEmptyElement = _reader.IsEmptyElement; - XmlElement element = new XmlElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _doc); - element.IsEmpty = fEmptyElement; - - if (_reader.MoveToFirstAttribute()) - { - XmlAttributeCollection attributes = element.Attributes; - do - { - XmlAttribute attr = LoadAttributeNodeDirect(); - attributes.Append(attr); // special case for load - } while (r.MoveToNextAttribute()); - } - - // recursively load all children. - if (!fEmptyElement) - { - parent.AppendChildForLoad(element, _doc); - parent = element; - continue; - } - else - { - node = element; - break; - } - - case XmlNodeType.EndElement: - Debug.Assert(parent.NodeType == XmlNodeType.Element); - if (parent.ParentNode == null) - { - return parent; - } - parent = parent.ParentNode; - continue; - - case XmlNodeType.EntityReference: - node = LoadEntityReferenceNode(true); - break; - - case XmlNodeType.EndEntity: - continue; - - case XmlNodeType.Attribute: - node = LoadAttributeNodeDirect(); - break; - - case XmlNodeType.SignificantWhitespace: - node = new XmlSignificantWhitespace(_reader.Value, _doc); - break; - - case XmlNodeType.Whitespace: - if (_preserveWhitespace) - { - node = new XmlWhitespace(_reader.Value, _doc); - } - else - { - continue; - } - break; - - case XmlNodeType.Text: - node = new XmlText(_reader.Value, _doc); - break; - - case XmlNodeType.CDATA: - node = new XmlCDataSection(_reader.Value, _doc); - break; - - case XmlNodeType.ProcessingInstruction: - node = new XmlProcessingInstruction(_reader.Name, _reader.Value, _doc); - break; - - case XmlNodeType.Comment: - node = new XmlComment(_reader.Value, _doc); - break; - - default: - throw UnexpectedNodeType(_reader.NodeType); - } - - Debug.Assert(node != null); - if (parent != null) - { - parent.AppendChildForLoad(node, _doc); - } - else - { - return node; - } - } - while (r.Read()); - - return null; - } - - private XmlAttribute LoadAttributeNodeDirect() - { - XmlReader r = _reader; - XmlAttribute attr; - if (r.IsDefault) - { - XmlUnspecifiedAttribute defattr = new XmlUnspecifiedAttribute(r.Prefix, r.LocalName, r.NamespaceURI, _doc); - LoadAttributeValue(defattr, true); - defattr.SetSpecified(false); - return defattr; - } - else - { - attr = new XmlAttribute(r.Prefix, r.LocalName, r.NamespaceURI, _doc); - LoadAttributeValue(attr, true); - return attr; - } - } - - internal void ParseDocumentType(XmlDocumentType dtNode) - { - XmlDocument doc = dtNode.OwnerDocument; - //if xmlresolver is set on doc, use that one, otherwise use the default one being created by xmlvalidatingreader - if (doc.HasSetResolver) - ParseDocumentType(dtNode, true, doc.GetResolver()); - else - ParseDocumentType(dtNode, false, null); - } - - private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver) - { - _doc = dtNode.OwnerDocument; - XmlParserContext pc = new XmlParserContext(null, new XmlNamespaceManager(_doc.NameTable), null, null, null, null, _doc.BaseURI, string.Empty, XmlSpace.None); - XmlTextReaderImpl tr = new XmlTextReaderImpl("", XmlNodeType.Element, pc); - tr.Namespaces = dtNode.ParseWithNamespaces; - if (bUseResolver) - { - tr.XmlResolver = resolver; - } - - IDtdParser dtdParser = DtdParser.Create(); - XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr); - - IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(_doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, proxy); - LoadDocumentType(dtdInfo, dtNode); - } - - private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode) - { - SchemaInfo schInfo = dtdInfo as SchemaInfo; - if (schInfo == null) - { - throw new XmlException(ResXml.Xml_InternalError, string.Empty); - } - - dtNode.DtdSchemaInfo = schInfo; - if (schInfo != null) - { - //set the schema information into the document - _doc.DtdSchemaInfo = schInfo; - - // Notation hashtable - if (schInfo.Notations != null) - { - foreach (SchemaNotation scNot in schInfo.Notations.Values) - { - dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, _doc)); - } - } - - // Entity hashtables - if (schInfo.GeneralEntities != null) - { - foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values) - { - XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc); - ent.SetBaseURI(scEnt.DeclaredURI); - dtNode.Entities.SetNamedItem(ent); - } - } - - if (schInfo.ParameterEntities != null) - { - foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values) - { - XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc); - ent.SetBaseURI(scEnt.DeclaredURI); - dtNode.Entities.SetNamedItem(ent); - } - } - _doc.Entities = dtNode.Entities; - - //extract the elements which has attribute defined as ID from the element declarations - IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator(); - if (elementDecls != null) - { - elementDecls.Reset(); - while (elementDecls.MoveNext()) - { - SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value; - if (elementDecl.AttDefs != null) - { - IDictionaryEnumerator attDefs = elementDecl.AttDefs.GetEnumerator(); - while (attDefs.MoveNext()) - { - SchemaAttDef attdef = (SchemaAttDef)attDefs.Value; - if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID) - { - //we only register the XmlElement based on their Prefix/LocalName and skip the namespace - _doc.AddIdInfo( - _doc.AddXmlName(elementDecl.Prefix, elementDecl.Name.Name, string.Empty, null), - _doc.AddAttrXmlName(attdef.Prefix, attdef.Name.Name, string.Empty, null)); - break; - } - } - } - } - } - } - } -#pragma warning restore 618 - - private XmlParserContext GetContext(XmlNode node) - { - String lang = null; - XmlSpace spaceMode = XmlSpace.None; - XmlDocumentType docType = _doc.DocumentType; - String baseURI = _doc.BaseURI; - //constructing xmlnamespace - Hashtable prefixes = new Hashtable(); - XmlNameTable nt = _doc.NameTable; - XmlNamespaceManager mgr = new XmlNamespaceManager(nt); - bool bHasDefXmlnsAttr = false; - - // Process all xmlns, xmlns:prefix, xml:space and xml:lang attributes - while (node != null && node != _doc) - { - if (node is XmlElement && ((XmlElement)node).HasAttributes) - { - mgr.PushScope(); - foreach (XmlAttribute attr in ((XmlElement)node).Attributes) - { - if (attr.Prefix == _doc.strXmlns && prefixes.Contains(attr.LocalName) == false) - { - // Make sure the next time we will not add this prefix - prefixes.Add(attr.LocalName, attr.LocalName); - mgr.AddNamespace(attr.LocalName, attr.Value); - } - else if (!bHasDefXmlnsAttr && attr.Prefix.Length == 0 && attr.LocalName == _doc.strXmlns) - { - // Save the case xmlns="..." where xmlns is the LocalName - mgr.AddNamespace(String.Empty, attr.Value); - bHasDefXmlnsAttr = true; - } - else if (spaceMode == XmlSpace.None && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strSpace) - { - // Save xml:space context - if (attr.Value == "default") - spaceMode = XmlSpace.Default; - else if (attr.Value == "preserve") - spaceMode = XmlSpace.Preserve; - } - else if (lang == null && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strLang) - { - // Save xml:lag context - lang = attr.Value; - } - } - } - node = node.ParentNode; - } - return new XmlParserContext( - nt, - mgr, - (docType == null) ? null : docType.Name, - (docType == null) ? null : docType.PublicId, - (docType == null) ? null : docType.SystemId, - (docType == null) ? null : docType.InternalSubset, - baseURI, - lang, - spaceMode - ); - } - - - - internal XmlNamespaceManager ParsePartialContent(XmlNode parentNode, string innerxmltext, XmlNodeType nt) - { - //the function shouldn't be used to set innerxml for XmlDocument node - Debug.Assert(parentNode.NodeType != XmlNodeType.Document); - _doc = parentNode.OwnerDocument; - Debug.Assert(_doc != null); - XmlParserContext pc = GetContext(parentNode); - _reader = CreateInnerXmlReader(innerxmltext, nt, pc, _doc); - try - { - _preserveWhitespace = true; - bool bOrigLoading = _doc.IsLoading; - _doc.IsLoading = true; - - if (nt == XmlNodeType.Entity) - { - XmlNode node = null; - while (_reader.Read() && (node = LoadNodeDirect()) != null) - { - parentNode.AppendChildForLoad(node, _doc); - } - } - else - { - XmlNode node = null; - while (_reader.Read() && (node = LoadNode(true)) != null) - { - parentNode.AppendChildForLoad(node, _doc); - } - } - _doc.IsLoading = bOrigLoading; - } - finally - { - _reader.Close(); - } - return pc.NamespaceManager; - } - - internal void LoadInnerXmlElement(XmlElement node, string innerxmltext) - { - //construct a tree underneth the node - XmlNamespaceManager mgr = ParsePartialContent(node, innerxmltext, XmlNodeType.Element); - //remove the duplicate namesapce - if (node.ChildNodes.Count > 0) - RemoveDuplicateNamespace((XmlElement)node, mgr, false); - } - - internal void LoadInnerXmlAttribute(XmlAttribute node, string innerxmltext) - { - ParsePartialContent(node, innerxmltext, XmlNodeType.Attribute); - } - - - private void RemoveDuplicateNamespace(XmlElement elem, XmlNamespaceManager mgr, bool fCheckElemAttrs) - { - //remove the duplicate attributes on current node first - mgr.PushScope(); - XmlAttributeCollection attrs = elem.Attributes; - int cAttrs = attrs.Count; - if (fCheckElemAttrs && cAttrs > 0) - { - for (int i = cAttrs - 1; i >= 0; --i) - { - XmlAttribute attr = attrs[i]; - if (attr.Prefix == _doc.strXmlns) - { - string nsUri = mgr.LookupNamespace(attr.LocalName); - if (nsUri != null) - { - if (attr.Value == nsUri) - elem.Attributes.RemoveNodeAt(i); - } - else - { - // Add this namespace, so it we will behave corectly when setting "" as - // InnerXml on this foo elem where foo is like this "" - // If do not do this, then we will remove the inner p prefix definition and will let the 1st p to be in scope for - // the subsequent InnerXml_set or setting an EntRef inside. - mgr.AddNamespace(attr.LocalName, attr.Value); - } - } - else if (attr.Prefix.Length == 0 && attr.LocalName == _doc.strXmlns) - { - string nsUri = mgr.DefaultNamespace; - if (nsUri != null) - { - if (attr.Value == nsUri) - elem.Attributes.RemoveNodeAt(i); - } - else - { - // Add this namespace, so it we will behave corectly when setting "" as - // InnerXml on this foo elem where foo is like this "" - // If do not do this, then we will remove the inner p prefix definition and will let the 1st p to be in scope for - // the subsequent InnerXml_set or setting an EntRef inside. - mgr.AddNamespace(attr.LocalName, attr.Value); - } - } - } - } - //now recursively remove the duplicate attributes on the children - XmlNode child = elem.FirstChild; - while (child != null) - { - XmlElement childElem = child as XmlElement; - if (childElem != null) - RemoveDuplicateNamespace(childElem, mgr, true); - child = child.NextSibling; - } - mgr.PopScope(); - } - - private String EntitizeName(String name) - { - return "&" + name + ";"; - } - - //The function is called when expanding the entity when its children being asked - internal void ExpandEntity(XmlEntity ent) - { - ParsePartialContent(ent, EntitizeName(ent.Name), XmlNodeType.Entity); - } - - //The function is called when expanding the entity ref. ( inside XmlEntityReference.SetParent ) - internal void ExpandEntityReference(XmlEntityReference eref) - { - //when the ent ref is not associated w/ an entity, append an empty string text node as child - _doc = eref.OwnerDocument; - bool bOrigLoadingState = _doc.IsLoading; - _doc.IsLoading = true; - switch (eref.Name) - { - case "lt": - eref.AppendChildForLoad(_doc.CreateTextNode("<"), _doc); - _doc.IsLoading = bOrigLoadingState; - return; - case "gt": - eref.AppendChildForLoad(_doc.CreateTextNode(">"), _doc); - _doc.IsLoading = bOrigLoadingState; - return; - case "amp": - eref.AppendChildForLoad(_doc.CreateTextNode("&"), _doc); - _doc.IsLoading = bOrigLoadingState; - return; - case "apos": - eref.AppendChildForLoad(_doc.CreateTextNode("'"), _doc); - _doc.IsLoading = bOrigLoadingState; - return; - case "quot": - eref.AppendChildForLoad(_doc.CreateTextNode("\""), _doc); - _doc.IsLoading = bOrigLoadingState; - return; - } - - XmlNamedNodeMap entities = _doc.Entities; - foreach (XmlEntity ent in entities) - { - if (Ref.Equal(ent.Name, eref.Name)) - { - ParsePartialContent(eref, EntitizeName(eref.Name), XmlNodeType.EntityReference); - return; - } - } - //no fit so far - if (!(_doc.ActualLoadingStatus)) - { - eref.AppendChildForLoad(_doc.CreateTextNode(""), _doc); - _doc.IsLoading = bOrigLoadingState; - } - else - { - _doc.IsLoading = bOrigLoadingState; - throw new XmlException(ResXml.Xml_UndeclaredParEntity, eref.Name); - } - } - -#pragma warning disable 618 - // Creates a XmlValidatingReader suitable for parsing InnerXml strings - private XmlReader CreateInnerXmlReader(String xmlFragment, XmlNodeType nt, XmlParserContext context, XmlDocument doc) - { - XmlNodeType contentNT = nt; - if (contentNT == XmlNodeType.Entity || contentNT == XmlNodeType.EntityReference) - contentNT = XmlNodeType.Element; - - XmlTextReaderImpl tr = new XmlTextReaderImpl(xmlFragment, contentNT, context); - tr.XmlValidatingReaderCompatibilityMode = true; - if (doc.HasSetResolver) - { - tr.XmlResolver = doc.GetResolver(); - } - if (!(doc.ActualLoadingStatus)) - { - tr.DisableUndeclaredEntityCheck = true; - } - Debug.Assert(tr.EntityHandling == EntityHandling.ExpandCharEntities); - - XmlDocumentType dtdNode = doc.DocumentType; - if (dtdNode != null) - { - tr.Namespaces = dtdNode.ParseWithNamespaces; - if (dtdNode.DtdSchemaInfo != null) - { - tr.SetDtdInfo(dtdNode.DtdSchemaInfo); - } - else - { - IDtdParser dtdParser = DtdParser.Create(); - XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr); - - IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(context.BaseURI, context.DocTypeName, context.PublicId, context.SystemId, context.InternalSubset, proxy); - - // TODO: Change all of XmlDocument to IDtdInfo interfaces - dtdNode.DtdSchemaInfo = dtdInfo as SchemaInfo; - tr.SetDtdInfo(dtdInfo); - } - } - - if (nt == XmlNodeType.Entity || nt == XmlNodeType.EntityReference) - { - tr.Read(); //this will skip the first element "wrapper" - tr.ResolveEntity(); - } - return tr; - } -#pragma warning restore 618 - - internal static void ParseXmlDeclarationValue(string strValue, out string version, out string encoding, out string standalone) - { - version = null; - encoding = null; - standalone = null; - XmlTextReaderImpl tempreader = new XmlTextReaderImpl(strValue, (XmlParserContext)null); - try - { - tempreader.Read(); - //get version info. - if (tempreader.MoveToAttribute("version")) - version = tempreader.Value; - //get encoding info - if (tempreader.MoveToAttribute("encoding")) - encoding = tempreader.Value; - //get standalone info - if (tempreader.MoveToAttribute("standalone")) - standalone = tempreader.Value; - } - finally - { - tempreader.Close(); - } - } - - static internal Exception UnexpectedNodeType(XmlNodeType nodetype) - { - return new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ResXml.Xml_UnexpectedNodeType, nodetype.ToString())); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlName.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlName.cs deleted file mode 100644 index bc9726d15b8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlName.cs +++ /dev/null @@ -1,317 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Text; - using System.Diagnostics; - using Microsoft.Xml.Schema; - - internal class XmlName : IXmlSchemaInfo - { - private string _prefix; - private string _localName; - private string _ns; - private string _name; - private int _hashCode; - internal XmlDocument ownerDoc; - internal XmlName next; - - public static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo) - { - if (schemaInfo == null) - { - return new XmlName(prefix, localName, ns, hashCode, ownerDoc, next); - } - else - { - return new XmlNameEx(prefix, localName, ns, hashCode, ownerDoc, next, schemaInfo); - } - } - - internal XmlName(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next) - { - _prefix = prefix; - _localName = localName; - _ns = ns; - _name = null; - _hashCode = hashCode; - this.ownerDoc = ownerDoc; - this.next = next; - } - - public string LocalName - { - get - { - return _localName; - } - } - - public string NamespaceURI - { - get - { - return _ns; - } - } - - public string Prefix - { - get - { - return _prefix; - } - } - - public int HashCode - { - get - { - return _hashCode; - } - } - - public XmlDocument OwnerDocument - { - get - { - return ownerDoc; - } - } - - public string Name - { - get - { - if (_name == null) - { - Debug.Assert(_prefix != null); - if (_prefix.Length > 0) - { - if (_localName.Length > 0) - { - string n = string.Concat(_prefix, ":", _localName); - lock (ownerDoc.NameTable) - { - if (_name == null) - { - _name = ownerDoc.NameTable.Add(n); - } - } - } - else - { - _name = _prefix; - } - } - else - { - _name = _localName; - } - Debug.Assert(Ref.Equal(_name, ownerDoc.NameTable.Get(_name))); - } - return _name; - } - } - - public virtual XmlSchemaValidity Validity - { - get - { - return XmlSchemaValidity.NotKnown; - } - } - - public virtual bool IsDefault - { - get - { - return false; - } - } - - public virtual bool IsNil - { - get - { - return false; - } - } - - public virtual XmlSchemaSimpleType MemberType - { - get - { - return null; - } - } - - public virtual XmlSchemaType SchemaType - { - get - { - return null; - } - } - - public virtual XmlSchemaElement SchemaElement - { - get - { - return null; - } - } - - public virtual XmlSchemaAttribute SchemaAttribute - { - get - { - return null; - } - } - - public virtual bool Equals(IXmlSchemaInfo schemaInfo) - { - return schemaInfo == null; - } - - public static int GetHashCode(string name) - { - int hashCode = 0; - if (name != null) - { - for (int i = name.Length - 1; i >= 0; i--) - { - char ch = name[i]; - if (ch == ':') break; - hashCode += (hashCode << 7) ^ ch; - } - hashCode -= hashCode >> 17; - hashCode -= hashCode >> 11; - hashCode -= hashCode >> 5; - } - return hashCode; - } - } - - internal sealed class XmlNameEx : XmlName - { - private byte _flags; - private XmlSchemaSimpleType _memberType; - private XmlSchemaType _schemaType; - private object _decl; - - // flags - // 0,1 : Validity - // 2 : IsDefault - // 3 : IsNil - private const byte ValidityMask = 0x03; - private const byte IsDefaultBit = 0x04; - private const byte IsNilBit = 0x08; - - internal XmlNameEx(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo) : base(prefix, localName, ns, hashCode, ownerDoc, next) - { - SetValidity(schemaInfo.Validity); - SetIsDefault(schemaInfo.IsDefault); - SetIsNil(schemaInfo.IsNil); - _memberType = schemaInfo.MemberType; - _schemaType = schemaInfo.SchemaType; - _decl = schemaInfo.SchemaElement != null - ? (object)schemaInfo.SchemaElement - : (object)schemaInfo.SchemaAttribute; - } - - public override XmlSchemaValidity Validity - { - get - { - return ownerDoc.CanReportValidity ? (XmlSchemaValidity)(_flags & ValidityMask) : XmlSchemaValidity.NotKnown; - } - } - - public override bool IsDefault - { - get - { - return (_flags & IsDefaultBit) != 0; - } - } - - public override bool IsNil - { - get - { - return (_flags & IsNilBit) != 0; - } - } - - public override XmlSchemaSimpleType MemberType - { - get - { - return _memberType; - } - } - - public override XmlSchemaType SchemaType - { - get - { - return _schemaType; - } - } - - public override XmlSchemaElement SchemaElement - { - get - { - return _decl as XmlSchemaElement; - } - } - - public override XmlSchemaAttribute SchemaAttribute - { - get - { - return _decl as XmlSchemaAttribute; - } - } - - public void SetValidity(XmlSchemaValidity value) - { - _flags = (byte)((_flags & ~ValidityMask) | (byte)(value)); - } - - public void SetIsDefault(bool value) - { - if (value) _flags = (byte)(_flags | IsDefaultBit); - else _flags = (byte)(_flags & ~IsDefaultBit); - } - - public void SetIsNil(bool value) - { - if (value) _flags = (byte)(_flags | IsNilBit); - else _flags = (byte)(_flags & ~IsNilBit); - } - - public override bool Equals(IXmlSchemaInfo schemaInfo) - { - if (schemaInfo != null - && schemaInfo.Validity == (XmlSchemaValidity)(_flags & ValidityMask) - && schemaInfo.IsDefault == ((_flags & IsDefaultBit) != 0) - && schemaInfo.IsNil == ((_flags & IsNilBit) != 0) - && (object)schemaInfo.MemberType == (object)_memberType - && (object)schemaInfo.SchemaType == (object)_schemaType - && (object)schemaInfo.SchemaElement == (object)(_decl as XmlSchemaElement) - && (object)schemaInfo.SchemaAttribute == (object)(_decl as XmlSchemaAttribute)) - { - return true; - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.SmallXmlNodeList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.SmallXmlNodeList.cs deleted file mode 100644 index badc1411587..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.SmallXmlNodeList.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - - public partial class XmlNamedNodeMap - { - // Optimized to minimize space in the zero or one element cases. - internal struct SmallXmlNodeList - { - // If field is null, that represents an empty list. - // If field is non-null, but not an ArrayList, then the 'list' contains a single - // object. - // Otherwise, field is an ArrayList. Once the field upgrades to an ArrayList, it - // never degrades back, even if all elements are removed. - private object _field; - - public int Count - { - get - { - if (_field == null) - return 0; - - ArrayList list = _field as ArrayList; - if (list != null) - return list.Count; - - return 1; - } - } - - public object this[int index] - { - get - { - if (_field == null) - throw new ArgumentOutOfRangeException("index"); - - ArrayList list = _field as ArrayList; - if (list != null) - return list[index]; - - if (index != 0) - throw new ArgumentOutOfRangeException("index"); - - return _field; - } - } - - public void Add(object value) - { - if (_field == null) - { - if (value == null) - { - // If a single null value needs to be stored, then - // upgrade to an ArrayList - ArrayList temp = new ArrayList(); - temp.Add(null); - _field = temp; - } - else - _field = value; - - return; - } - - ArrayList list = _field as ArrayList; - if (list != null) - { - list.Add(value); - } - else - { - list = new ArrayList(); - list.Add(_field); - list.Add(value); - _field = list; - } - } - - public void RemoveAt(int index) - { - if (_field == null) - throw new ArgumentOutOfRangeException("index"); - - ArrayList list = _field as ArrayList; - if (list != null) - { - list.RemoveAt(index); - return; - } - - if (index != 0) - throw new ArgumentOutOfRangeException("index"); - - _field = null; - } - - public void Insert(int index, object value) - { - if (_field == null) - { - if (index != 0) - throw new ArgumentOutOfRangeException("index"); - Add(value); - return; - } - - ArrayList list = _field as ArrayList; - if (list != null) - { - list.Insert(index, value); - return; - } - - if (index == 0) - { - list = new ArrayList(); - list.Add(value); - list.Add(_field); - _field = list; - } - else if (index == 1) - { - list = new ArrayList(); - list.Add(_field); - list.Add(value); - _field = list; - } - else - { - throw new ArgumentOutOfRangeException("index"); - } - } - - private class SingleObjectEnumerator : IEnumerator - { - private object _loneValue; - private int _position = -1; - - public SingleObjectEnumerator(object value) - { - _loneValue = value; - } - - public object Current - { - get - { - if (_position != 0) - { - throw new InvalidOperationException(); - } - return _loneValue; - } - } - - public bool MoveNext() - { - if (_position < 0) - { - _position = 0; - return true; - } - _position = 1; - return false; - } - - public void Reset() - { - _position = -1; - } - } - - public IEnumerator GetEnumerator() - { - if (_field == null) - { - return XmlDocument.EmptyEnumerator; - } - - ArrayList list = _field as ArrayList; - if (list != null) - { - return list.GetEnumerator(); - } - - return new SingleObjectEnumerator(_field); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.cs deleted file mode 100644 index c18fbc67116..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNamedNodeMap.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - - // Represents a collection of nodes that can be accessed by name or index. - public partial class XmlNamedNodeMap : IEnumerable - { - internal XmlNode parent; - internal SmallXmlNodeList nodes; - - internal XmlNamedNodeMap(XmlNode parent) - { - this.parent = parent; - } - - // Retrieves a XmlNode specified by name. - public virtual XmlNode GetNamedItem(String name) - { - int offset = FindNodeOffset(name); - if (offset >= 0) - return (XmlNode)nodes[offset]; - return null; - } - - // Adds a XmlNode using its Name property - public virtual XmlNode SetNamedItem(XmlNode node) - { - if (node == null) - return null; - - int offset = FindNodeOffset(node.LocalName, node.NamespaceURI); - if (offset == -1) - { - AddNode(node); - return null; - } - else - { - return ReplaceNodeAt(offset, node); - } - } - - // Removes the node specified by name. - public virtual XmlNode RemoveNamedItem(String name) - { - int offset = FindNodeOffset(name); - if (offset >= 0) - { - return RemoveNodeAt(offset); - } - return null; - } - - // Gets the number of nodes in this XmlNamedNodeMap. - public virtual int Count - { - get - { - return nodes.Count; - } - } - - // Retrieves the node at the specified index in this XmlNamedNodeMap. - public virtual XmlNode Item(int index) - { - if (index < 0 || index >= nodes.Count) - return null; - try - { - return (XmlNode)nodes[index]; - } - catch (ArgumentOutOfRangeException) - { - throw new IndexOutOfRangeException(ResXml.Xdom_IndexOutOfRange); - } - } - - // - // DOM Level 2 - // - - // Retrieves a node specified by LocalName and NamespaceURI. - public virtual XmlNode GetNamedItem(String localName, String namespaceURI) - { - int offset = FindNodeOffset(localName, namespaceURI); - if (offset >= 0) - return (XmlNode)nodes[offset]; - return null; - } - - // Removes a node specified by local name and namespace URI. - public virtual XmlNode RemoveNamedItem(String localName, String namespaceURI) - { - int offset = FindNodeOffset(localName, namespaceURI); - if (offset >= 0) - { - return RemoveNodeAt(offset); - } - return null; - } - - public virtual IEnumerator GetEnumerator() - { - return nodes.GetEnumerator(); - } - - internal int FindNodeOffset(string name) - { - int c = this.Count; - for (int i = 0; i < c; i++) - { - XmlNode node = (XmlNode)nodes[i]; - - if (name == node.Name) - return i; - } - - return -1; - } - - internal int FindNodeOffset(string localName, string namespaceURI) - { - int c = this.Count; - for (int i = 0; i < c; i++) - { - XmlNode node = (XmlNode)nodes[i]; - - if (node.LocalName == localName && node.NamespaceURI == namespaceURI) - return i; - } - - return -1; - } - - internal virtual XmlNode AddNode(XmlNode node) - { - XmlNode oldParent; - if (node.NodeType == XmlNodeType.Attribute) - oldParent = ((XmlAttribute)node).OwnerElement; - else - oldParent = node.ParentNode; - string nodeValue = node.Value; - XmlNodeChangedEventArgs args = parent.GetEventArgs(node, oldParent, parent, nodeValue, nodeValue, XmlNodeChangedAction.Insert); - - if (args != null) - parent.BeforeEvent(args); - - nodes.Add(node); - node.SetParent(parent); - - if (args != null) - parent.AfterEvent(args); - - return node; - } - - internal virtual XmlNode AddNodeForLoad(XmlNode node, XmlDocument doc) - { - XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(node, parent); - if (args != null) - { - doc.BeforeEvent(args); - } - nodes.Add(node); - node.SetParent(parent); - if (args != null) - { - doc.AfterEvent(args); - } - return node; - } - - internal virtual XmlNode RemoveNodeAt(int i) - { - XmlNode oldNode = (XmlNode)nodes[i]; - - string oldNodeValue = oldNode.Value; - XmlNodeChangedEventArgs args = parent.GetEventArgs(oldNode, parent, null, oldNodeValue, oldNodeValue, XmlNodeChangedAction.Remove); - - if (args != null) - parent.BeforeEvent(args); - - nodes.RemoveAt(i); - oldNode.SetParent(null); - - if (args != null) - parent.AfterEvent(args); - - return oldNode; - } - - internal XmlNode ReplaceNodeAt(int i, XmlNode node) - { - XmlNode oldNode = RemoveNodeAt(i); - InsertNodeAt(i, node); - return oldNode; - } - - internal virtual XmlNode InsertNodeAt(int i, XmlNode node) - { - XmlNode oldParent; - if (node.NodeType == XmlNodeType.Attribute) - oldParent = ((XmlAttribute)node).OwnerElement; - else - oldParent = node.ParentNode; - - string nodeValue = node.Value; - XmlNodeChangedEventArgs args = parent.GetEventArgs(node, oldParent, parent, nodeValue, nodeValue, XmlNodeChangedAction.Insert); - - if (args != null) - parent.BeforeEvent(args); - - nodes.Insert(i, node); - node.SetParent(parent); - - if (args != null) - parent.AfterEvent(args); - - return node; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNode.cs deleted file mode 100644 index 7ef1f82779d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNode.cs +++ /dev/null @@ -1,1465 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.IO; - using System.Collections; - using System.Text; - using System.Diagnostics; - using Microsoft.Xml.Schema; - using Microsoft.Xml.XPath; - using MS.Internal.Xml.XPath; - using System.Globalization; - - // Represents a single node in the document. - [DebuggerDisplay("{debuggerDisplayProxy}")] - public abstract class XmlNode : ICloneable, IEnumerable, IXPathNavigable - { - internal XmlNode parentNode; //this pointer is reused to save the userdata information, need to prevent internal user access the pointer directly. - - internal XmlNode() - { - } - - internal XmlNode(XmlDocument doc) - { - if (doc == null) - throw new ArgumentException(ResXml.Xdom_Node_Null_Doc); - this.parentNode = doc; - } - - public virtual XPathNavigator CreateNavigator() - { - XmlDocument thisAsDoc = this as XmlDocument; - if (thisAsDoc != null) - { - return thisAsDoc.CreateNavigator(this); - } - XmlDocument doc = OwnerDocument; - Debug.Assert(doc != null); - return doc.CreateNavigator(this); - } - - // Selects the first node that matches the xpath expression - public XmlNode SelectSingleNode(string xpath) - { - XmlNodeList list = SelectNodes(xpath); - // SelectNodes returns null for certain node types - return list != null ? list[0] : null; - } - - // Selects the first node that matches the xpath expression and given namespace context. - public XmlNode SelectSingleNode(string xpath, XmlNamespaceManager nsmgr) - { - XPathNavigator xn = (this).CreateNavigator(); - //if the method is called on node types like DocType, Entity, XmlDeclaration, - //the navigator returned is null. So just return null from here for those node types. - if (xn == null) - return null; - XPathExpression exp = xn.Compile(xpath); - exp.SetContext(nsmgr); - return new XPathNodeList(xn.Select(exp))[0]; - } - - // Selects all nodes that match the xpath expression - public XmlNodeList SelectNodes(string xpath) - { - XPathNavigator n = (this).CreateNavigator(); - //if the method is called on node types like DocType, Entity, XmlDeclaration, - //the navigator returned is null. So just return null from here for those node types. - if (n == null) - return null; - return new XPathNodeList(n.Select(xpath)); - } - - // Selects all nodes that match the xpath expression and given namespace context. - public XmlNodeList SelectNodes(string xpath, XmlNamespaceManager nsmgr) - { - XPathNavigator xn = (this).CreateNavigator(); - //if the method is called on node types like DocType, Entity, XmlDeclaration, - //the navigator returned is null. So just return null from here for those node types. - if (xn == null) - return null; - XPathExpression exp = xn.Compile(xpath); - exp.SetContext(nsmgr); - return new XPathNodeList(xn.Select(exp)); - } - - // Gets the name of the node. - public abstract string Name - { - get; - } - - // Gets or sets the value of the node. - public virtual string Value - { - get { return null; } - set { throw new InvalidOperationException(string.Format(ResXml.Xdom_Node_SetVal, NodeType)); } - } - - // Gets the type of the current node. - public abstract XmlNodeType NodeType - { - get; - } - - // Gets the parent of this node (for nodes that can have parents). - public virtual XmlNode ParentNode - { - get - { - Debug.Assert(parentNode != null); - - if (parentNode.NodeType != XmlNodeType.Document) - { - return parentNode; - } - - // Linear lookup through the children of the document - XmlLinkedNode firstChild = parentNode.FirstChild as XmlLinkedNode; - if (firstChild != null) - { - XmlLinkedNode node = firstChild; - do - { - if (node == this) - { - return parentNode; - } - node = node.next; - } - while (node != null - && node != firstChild); - } - return null; - } - } - - // Gets all children of this node. - public virtual XmlNodeList ChildNodes - { - get { return new XmlChildNodes(this); } - } - - // Gets the node immediately preceding this node. - public virtual XmlNode PreviousSibling - { - get { return null; } - } - - // Gets the node immediately following this node. - public virtual XmlNode NextSibling - { - get { return null; } - } - - // Gets a XmlAttributeCollection containing the attributes - // of this node. - public virtual XmlAttributeCollection Attributes - { - get { return null; } - } - - // Gets the XmlDocument that contains this node. - public virtual XmlDocument OwnerDocument - { - get - { - Debug.Assert(parentNode != null); - if (parentNode.NodeType == XmlNodeType.Document) - return (XmlDocument)parentNode; - return parentNode.OwnerDocument; - } - } - - // Gets the first child of this node. - public virtual XmlNode FirstChild - { - get - { - XmlLinkedNode linkedNode = LastNode; - if (linkedNode != null) - return linkedNode.next; - - return null; - } - } - - // Gets the last child of this node. - public virtual XmlNode LastChild - { - get { return LastNode; } - } - - internal virtual bool IsContainer - { - get { return false; } - } - - internal virtual XmlLinkedNode LastNode - { - get { return null; } - set { } - } - - internal bool AncestorNode(XmlNode node) - { - XmlNode n = this.ParentNode; - - while (n != null && n != this) - { - if (n == node) - return true; - n = n.ParentNode; - } - - return false; - } - - //trace to the top to find out its parent node. - internal bool IsConnected() - { - XmlNode parent = ParentNode; - while (parent != null && !(parent.NodeType == XmlNodeType.Document)) - parent = parent.ParentNode; - return parent != null; - } - - // Inserts the specified node immediately before the specified reference node. - public virtual XmlNode InsertBefore(XmlNode newChild, XmlNode refChild) - { - if (this == newChild || AncestorNode(newChild)) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Child); - - if (refChild == null) - return AppendChild(newChild); - - if (!IsContainer) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Contain); - - if (refChild.ParentNode != this) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Path); - - if (newChild == refChild) - return newChild; - - XmlDocument childDoc = newChild.OwnerDocument; - XmlDocument thisDoc = OwnerDocument; - if (childDoc != null && childDoc != thisDoc && childDoc != this) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Context); - - if (!CanInsertBefore(newChild, refChild)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Location); - - if (newChild.ParentNode != null) - newChild.ParentNode.RemoveChild(newChild); - - // special case for doc-fragment. - if (newChild.NodeType == XmlNodeType.DocumentFragment) - { - XmlNode first = newChild.FirstChild; - XmlNode node = first; - if (node != null) - { - newChild.RemoveChild(node); - InsertBefore(node, refChild); - // insert the rest of the children after this one. - InsertAfter(newChild, node); - } - return first; - } - - if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_TypeConflict); - - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - XmlLinkedNode refNode = (XmlLinkedNode)refChild; - - string newChildValue = newChild.Value; - XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert); - - if (args != null) - BeforeEvent(args); - - if (refNode == FirstChild) - { - newNode.next = refNode; - LastNode.next = newNode; - newNode.SetParent(this); - - if (newNode.IsText) - { - if (refNode.IsText) - { - NestTextNodes(newNode, refNode); - } - } - } - else - { - XmlLinkedNode prevNode = (XmlLinkedNode)refNode.PreviousSibling; - - newNode.next = refNode; - prevNode.next = newNode; - newNode.SetParent(this); - - if (prevNode.IsText) - { - if (newNode.IsText) - { - NestTextNodes(prevNode, newNode); - if (refNode.IsText) - { - NestTextNodes(newNode, refNode); - } - } - else - { - if (refNode.IsText) - { - UnnestTextNodes(prevNode, refNode); - } - } - } - else - { - if (newNode.IsText) - { - if (refNode.IsText) - { - NestTextNodes(newNode, refNode); - } - } - } - } - - if (args != null) - AfterEvent(args); - - return newNode; - } - - // Inserts the specified node immediately after the specified reference node. - public virtual XmlNode InsertAfter(XmlNode newChild, XmlNode refChild) - { - if (this == newChild || AncestorNode(newChild)) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Child); - - if (refChild == null) - return PrependChild(newChild); - - if (!IsContainer) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Contain); - - if (refChild.ParentNode != this) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Path); - - if (newChild == refChild) - return newChild; - - XmlDocument childDoc = newChild.OwnerDocument; - XmlDocument thisDoc = OwnerDocument; - if (childDoc != null && childDoc != thisDoc && childDoc != this) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Context); - - if (!CanInsertAfter(newChild, refChild)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Location); - - if (newChild.ParentNode != null) - newChild.ParentNode.RemoveChild(newChild); - - // special case for doc-fragment. - if (newChild.NodeType == XmlNodeType.DocumentFragment) - { - XmlNode last = refChild; - XmlNode first = newChild.FirstChild; - XmlNode node = first; - while (node != null) - { - XmlNode next = node.NextSibling; - newChild.RemoveChild(node); - InsertAfter(node, last); - last = node; - node = next; - } - return first; - } - - if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_TypeConflict); - - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - XmlLinkedNode refNode = (XmlLinkedNode)refChild; - - string newChildValue = newChild.Value; - XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert); - - if (args != null) - BeforeEvent(args); - - if (refNode == LastNode) - { - newNode.next = refNode.next; - refNode.next = newNode; - LastNode = newNode; - newNode.SetParent(this); - - if (refNode.IsText) - { - if (newNode.IsText) - { - NestTextNodes(refNode, newNode); - } - } - } - else - { - XmlLinkedNode nextNode = refNode.next; - - newNode.next = nextNode; - refNode.next = newNode; - newNode.SetParent(this); - - if (refNode.IsText) - { - if (newNode.IsText) - { - NestTextNodes(refNode, newNode); - if (nextNode.IsText) - { - NestTextNodes(newNode, nextNode); - } - } - else - { - if (nextNode.IsText) - { - UnnestTextNodes(refNode, nextNode); - } - } - } - else - { - if (newNode.IsText) - { - if (nextNode.IsText) - { - NestTextNodes(newNode, nextNode); - } - } - } - } - - - if (args != null) - AfterEvent(args); - - return newNode; - } - - // Replaces the child node oldChild with newChild node. - public virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild) - { - XmlNode nextNode = oldChild.NextSibling; - RemoveChild(oldChild); - XmlNode node = InsertBefore(newChild, nextNode); - return oldChild; - } - - // Removes specified child node. - public virtual XmlNode RemoveChild(XmlNode oldChild) - { - if (!IsContainer) - throw new InvalidOperationException(ResXml.Xdom_Node_Remove_Contain); - - if (oldChild.ParentNode != this) - throw new ArgumentException(ResXml.Xdom_Node_Remove_Child); - - XmlLinkedNode oldNode = (XmlLinkedNode)oldChild; - - string oldNodeValue = oldNode.Value; - XmlNodeChangedEventArgs args = GetEventArgs(oldNode, this, null, oldNodeValue, oldNodeValue, XmlNodeChangedAction.Remove); - - if (args != null) - BeforeEvent(args); - - XmlLinkedNode lastNode = LastNode; - - if (oldNode == FirstChild) - { - if (oldNode == lastNode) - { - LastNode = null; - oldNode.next = null; - oldNode.SetParent(null); - } - else - { - XmlLinkedNode nextNode = oldNode.next; - - if (nextNode.IsText) - { - if (oldNode.IsText) - { - UnnestTextNodes(oldNode, nextNode); - } - } - - lastNode.next = nextNode; - oldNode.next = null; - oldNode.SetParent(null); - } - } - else - { - if (oldNode == lastNode) - { - XmlLinkedNode prevNode = (XmlLinkedNode)oldNode.PreviousSibling; - prevNode.next = oldNode.next; - LastNode = prevNode; - oldNode.next = null; - oldNode.SetParent(null); - } - else - { - XmlLinkedNode prevNode = (XmlLinkedNode)oldNode.PreviousSibling; - XmlLinkedNode nextNode = oldNode.next; - - if (nextNode.IsText) - { - if (prevNode.IsText) - { - NestTextNodes(prevNode, nextNode); - } - else - { - if (oldNode.IsText) - { - UnnestTextNodes(oldNode, nextNode); - } - } - } - - prevNode.next = nextNode; - oldNode.next = null; - oldNode.SetParent(null); - } - } - - if (args != null) - AfterEvent(args); - - return oldChild; - } - - // Adds the specified node to the beginning of the list of children of this node. - public virtual XmlNode PrependChild(XmlNode newChild) - { - return InsertBefore(newChild, FirstChild); - } - - // Adds the specified node to the end of the list of children of this node. - public virtual XmlNode AppendChild(XmlNode newChild) - { - XmlDocument thisDoc = OwnerDocument; - if (thisDoc == null) - { - thisDoc = this as XmlDocument; - } - if (!IsContainer) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Contain); - - if (this == newChild || AncestorNode(newChild)) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Child); - - if (newChild.ParentNode != null) - newChild.ParentNode.RemoveChild(newChild); - - XmlDocument childDoc = newChild.OwnerDocument; - if (childDoc != null && childDoc != thisDoc && childDoc != this) - throw new ArgumentException(ResXml.Xdom_Node_Insert_Context); - - // special case for doc-fragment. - if (newChild.NodeType == XmlNodeType.DocumentFragment) - { - XmlNode first = newChild.FirstChild; - XmlNode node = first; - while (node != null) - { - XmlNode next = node.NextSibling; - newChild.RemoveChild(node); - AppendChild(node); - node = next; - } - return first; - } - - if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_TypeConflict); - - - if (!CanInsertAfter(newChild, LastChild)) - throw new InvalidOperationException(ResXml.Xdom_Node_Insert_Location); - - string newChildValue = newChild.Value; - XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert); - - if (args != null) - BeforeEvent(args); - - XmlLinkedNode refNode = LastNode; - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - - if (refNode == null) - { - newNode.next = newNode; - LastNode = newNode; - newNode.SetParent(this); - } - else - { - newNode.next = refNode.next; - refNode.next = newNode; - LastNode = newNode; - newNode.SetParent(this); - - if (refNode.IsText) - { - if (newNode.IsText) - { - NestTextNodes(refNode, newNode); - } - } - } - - if (args != null) - AfterEvent(args); - - return newNode; - } - - //the function is provided only at Load time to speed up Load process - internal virtual XmlNode AppendChildForLoad(XmlNode newChild, XmlDocument doc) - { - XmlNodeChangedEventArgs args = doc.GetInsertEventArgsForLoad(newChild, this); - - if (args != null) - doc.BeforeEvent(args); - - XmlLinkedNode refNode = LastNode; - XmlLinkedNode newNode = (XmlLinkedNode)newChild; - - if (refNode == null) - { - newNode.next = newNode; - LastNode = newNode; - newNode.SetParentForLoad(this); - } - else - { - newNode.next = refNode.next; - refNode.next = newNode; - LastNode = newNode; - if (refNode.IsText - && newNode.IsText) - { - NestTextNodes(refNode, newNode); - } - else - { - newNode.SetParentForLoad(this); - } - } - - if (args != null) - doc.AfterEvent(args); - - return newNode; - } - - internal virtual bool IsValidChildType(XmlNodeType type) - { - return false; - } - - internal virtual bool CanInsertBefore(XmlNode newChild, XmlNode refChild) - { - return true; - } - - internal virtual bool CanInsertAfter(XmlNode newChild, XmlNode refChild) - { - return true; - } - - // Gets a value indicating whether this node has any child nodes. - public virtual bool HasChildNodes - { - get { return LastNode != null; } - } - - // Creates a duplicate of this node. - public abstract XmlNode CloneNode(bool deep); - - internal virtual void CopyChildren(XmlDocument doc, XmlNode container, bool deep) - { - for (XmlNode child = container.FirstChild; child != null; child = child.NextSibling) - { - AppendChildForLoad(child.CloneNode(deep), doc); - } - } - - // DOM Level 2 - - // Puts all XmlText nodes in the full depth of the sub-tree - // underneath this XmlNode into a "normal" form where only - // markup (e.g., tags, comments, processing instructions, CDATA sections, - // and entity references) separates XmlText nodes, that is, there - // are no adjacent XmlText nodes. - public virtual void Normalize() - { - XmlNode firstChildTextLikeNode = null; - StringBuilder sb = new StringBuilder(); - for (XmlNode crtChild = this.FirstChild; crtChild != null;) - { - XmlNode nextChild = crtChild.NextSibling; - switch (crtChild.NodeType) - { - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - { - sb.Append(crtChild.Value); - XmlNode winner = NormalizeWinner(firstChildTextLikeNode, crtChild); - if (winner == firstChildTextLikeNode) - { - this.RemoveChild(crtChild); - } - else - { - if (firstChildTextLikeNode != null) - this.RemoveChild(firstChildTextLikeNode); - firstChildTextLikeNode = crtChild; - } - break; - } - case XmlNodeType.Element: - { - crtChild.Normalize(); - goto default; - } - default: - { - if (firstChildTextLikeNode != null) - { - firstChildTextLikeNode.Value = sb.ToString(); - firstChildTextLikeNode = null; - } - sb.Remove(0, sb.Length); - break; - } - } - crtChild = nextChild; - } - if (firstChildTextLikeNode != null && sb.Length > 0) - firstChildTextLikeNode.Value = sb.ToString(); - } - - private XmlNode NormalizeWinner(XmlNode firstNode, XmlNode secondNode) - { - //first node has the priority - if (firstNode == null) - return secondNode; - Debug.Assert(firstNode.NodeType == XmlNodeType.Text - || firstNode.NodeType == XmlNodeType.SignificantWhitespace - || firstNode.NodeType == XmlNodeType.Whitespace - || secondNode.NodeType == XmlNodeType.Text - || secondNode.NodeType == XmlNodeType.SignificantWhitespace - || secondNode.NodeType == XmlNodeType.Whitespace); - if (firstNode.NodeType == XmlNodeType.Text) - return firstNode; - if (secondNode.NodeType == XmlNodeType.Text) - return secondNode; - if (firstNode.NodeType == XmlNodeType.SignificantWhitespace) - return firstNode; - if (secondNode.NodeType == XmlNodeType.SignificantWhitespace) - return secondNode; - if (firstNode.NodeType == XmlNodeType.Whitespace) - return firstNode; - if (secondNode.NodeType == XmlNodeType.Whitespace) - return secondNode; - Debug.Assert(true, "shouldn't have fall through here."); - return null; - } - - // Test if the DOM implementation implements a specific feature. - public virtual bool Supports(string feature, string version) - { - if (String.Compare("XML", feature, StringComparison.OrdinalIgnoreCase) == 0) - { - if (version == null || version == "1.0" || version == "2.0") - return true; - } - return false; - } - - // Gets the namespace URI of this node. - public virtual string NamespaceURI - { - get { return string.Empty; } - } - - // Gets or sets the namespace prefix of this node. - public virtual string Prefix - { - get { return string.Empty; } - set { } - } - - // Gets the name of the node without the namespace prefix. - public abstract string LocalName - { - get; - } - - // Microsoft extensions - - // Gets a value indicating whether the node is read-only. - public virtual bool IsReadOnly - { - get - { - XmlDocument doc = OwnerDocument; - return HasReadOnlyParent(this); - } - } - - internal static bool HasReadOnlyParent(XmlNode n) - { - while (n != null) - { - switch (n.NodeType) - { - case XmlNodeType.EntityReference: - case XmlNodeType.Entity: - return true; - - case XmlNodeType.Attribute: - n = ((XmlAttribute)n).OwnerElement; - break; - - default: - n = n.ParentNode; - break; - } - } - return false; - } - - // Creates a duplicate of this node. - public virtual XmlNode Clone() - { - return this.CloneNode(true); - } - - object ICloneable.Clone() - { - return this.CloneNode(true); - } - - // Provides a simple ForEach-style iteration over the - // collection of nodes in this XmlNamedNodeMap. - IEnumerator IEnumerable.GetEnumerator() - { - return new XmlChildEnumerator(this); - } - - public IEnumerator GetEnumerator() - { - return new XmlChildEnumerator(this); - } - - private void AppendChildText(StringBuilder builder) - { - for (XmlNode child = FirstChild; child != null; child = child.NextSibling) - { - if (child.FirstChild == null) - { - if (child.NodeType == XmlNodeType.Text || child.NodeType == XmlNodeType.CDATA - || child.NodeType == XmlNodeType.Whitespace || child.NodeType == XmlNodeType.SignificantWhitespace) - builder.Append(child.InnerText); - } - else - { - child.AppendChildText(builder); - } - } - } - - // Gets or sets the concatenated values of the node and - // all its children. - public virtual string InnerText - { - get - { - XmlNode fc = FirstChild; - if (fc == null) - { - return string.Empty; - } - if (fc.NextSibling == null) - { - XmlNodeType nodeType = fc.NodeType; - switch (nodeType) - { - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return fc.Value; - } - } - StringBuilder builder = new StringBuilder(); - AppendChildText(builder); - return builder.ToString(); - } - - set - { - XmlNode firstChild = FirstChild; - if (firstChild != null //there is one child - && firstChild.NextSibling == null // and exactly one - && firstChild.NodeType == XmlNodeType.Text)//which is a text node - { - //this branch is for perf reason and event fired when TextNode.Value is changed - firstChild.Value = value; - } - else - { - RemoveAll(); - AppendChild(OwnerDocument.CreateTextNode(value)); - } - } - } - - // Gets the markup representing this node and all its children. - public virtual string OuterXml - { - get - { - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlDOMTextWriter xw = new XmlDOMTextWriter(sw); - try - { - WriteTo(xw); - } - finally - { - xw.Close(); - } - return sw.ToString(); - } - } - - // Gets or sets the markup representing just the children of this node. - public virtual string InnerXml - { - get - { - StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); - XmlDOMTextWriter xw = new XmlDOMTextWriter(sw); - try - { - WriteContentTo(xw); - } - finally - { - xw.Close(); - } - return sw.ToString(); - } - - set - { - throw new InvalidOperationException(ResXml.Xdom_Set_InnerXml); - } - } - - public virtual IXmlSchemaInfo SchemaInfo - { - get - { - return XmlDocument.NotKnownSchemaInfo; - } - } - - public virtual String BaseURI - { - get - { - XmlNode curNode = this.ParentNode; //save one while loop since if going to here, the nodetype of this node can't be document, entity and entityref - while (curNode != null) - { - XmlNodeType nt = curNode.NodeType; - //EntityReference's children come from the dtd where they are defined. - //we need to investigate the same thing for entity's children if they are defined in an external dtd file. - if (nt == XmlNodeType.EntityReference) - return ((XmlEntityReference)curNode).ChildBaseURI; - if (nt == XmlNodeType.Document - || nt == XmlNodeType.Entity - || nt == XmlNodeType.Attribute) - return curNode.BaseURI; - curNode = curNode.ParentNode; - } - return String.Empty; - } - } - - // Saves the current node to the specified XmlWriter. - public abstract void WriteTo(XmlWriter w); - - // Saves all the children of the node to the specified XmlWriter. - public abstract void WriteContentTo(XmlWriter w); - - // Removes all the children and/or attributes - // of the current node. - public virtual void RemoveAll() - { - XmlNode child = FirstChild; - XmlNode sibling = null; - - while (child != null) - { - sibling = child.NextSibling; - RemoveChild(child); - child = sibling; - } - } - - internal XmlDocument Document - { - get - { - if (NodeType == XmlNodeType.Document) - return (XmlDocument)this; - return OwnerDocument; - } - } - - // Looks up the closest xmlns declaration for the given - // prefix that is in scope for the current node and returns - // the namespace URI in the declaration. - public virtual string GetNamespaceOfPrefix(string prefix) - { - string namespaceName = GetNamespaceOfPrefixStrict(prefix); - return namespaceName != null ? namespaceName : string.Empty; - } - - internal string GetNamespaceOfPrefixStrict(string prefix) - { - XmlDocument doc = Document; - if (doc != null) - { - prefix = doc.NameTable.Get(prefix); - if (prefix == null) - return null; - - XmlNode node = this; - while (node != null) - { - if (node.NodeType == XmlNodeType.Element) - { - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttributeCollection attrs = elem.Attributes; - if (prefix.Length == 0) - { - for (int iAttr = 0; iAttr < attrs.Count; iAttr++) - { - XmlAttribute attr = attrs[iAttr]; - if (attr.Prefix.Length == 0) - { - if (Ref.Equal(attr.LocalName, doc.strXmlns)) - { - return attr.Value; // found xmlns - } - } - } - } - else - { - for (int iAttr = 0; iAttr < attrs.Count; iAttr++) - { - XmlAttribute attr = attrs[iAttr]; - if (Ref.Equal(attr.Prefix, doc.strXmlns)) - { - if (Ref.Equal(attr.LocalName, prefix)) - { - return attr.Value; // found xmlns:prefix - } - } - else if (Ref.Equal(attr.Prefix, prefix)) - { - return attr.NamespaceURI; // found prefix:attr - } - } - } - } - if (Ref.Equal(node.Prefix, prefix)) - { - return node.NamespaceURI; - } - node = node.ParentNode; - } - else if (node.NodeType == XmlNodeType.Attribute) - { - node = ((XmlAttribute)node).OwnerElement; - } - else - { - node = node.ParentNode; - } - } - if (Ref.Equal(doc.strXml, prefix)) - { // xmlns:xml - return doc.strReservedXml; - } - else if (Ref.Equal(doc.strXmlns, prefix)) - { // xmlns:xmlns - return doc.strReservedXmlns; - } - } - return null; - } - - // Looks up the closest xmlns declaration for the given namespace - // URI that is in scope for the current node and returns - // the prefix defined in that declaration. - public virtual string GetPrefixOfNamespace(string namespaceURI) - { - string prefix = GetPrefixOfNamespaceStrict(namespaceURI); - return prefix != null ? prefix : string.Empty; - } - - internal string GetPrefixOfNamespaceStrict(string namespaceURI) - { - XmlDocument doc = Document; - if (doc != null) - { - namespaceURI = doc.NameTable.Add(namespaceURI); - - XmlNode node = this; - while (node != null) - { - if (node.NodeType == XmlNodeType.Element) - { - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttributeCollection attrs = elem.Attributes; - for (int iAttr = 0; iAttr < attrs.Count; iAttr++) - { - XmlAttribute attr = attrs[iAttr]; - if (attr.Prefix.Length == 0) - { - if (Ref.Equal(attr.LocalName, doc.strXmlns)) - { - if (attr.Value == namespaceURI) - { - return string.Empty; // found xmlns="namespaceURI" - } - } - } - else if (Ref.Equal(attr.Prefix, doc.strXmlns)) - { - if (attr.Value == namespaceURI) - { - return attr.LocalName; // found xmlns:prefix="namespaceURI" - } - } - else if (Ref.Equal(attr.NamespaceURI, namespaceURI)) - { - return attr.Prefix; // found prefix:attr - // with prefix bound to namespaceURI - } - } - } - if (Ref.Equal(node.NamespaceURI, namespaceURI)) - { - return node.Prefix; - } - node = node.ParentNode; - } - else if (node.NodeType == XmlNodeType.Attribute) - { - node = ((XmlAttribute)node).OwnerElement; - } - else - { - node = node.ParentNode; - } - } - if (Ref.Equal(doc.strReservedXml, namespaceURI)) - { // xmlns:xml - return doc.strXml; - } - else if (Ref.Equal(doc.strReservedXmlns, namespaceURI)) - { // xmlns:xmlns - return doc.strXmlns; - } - } - return null; - } - - // Retrieves the first child element with the specified name. - public virtual XmlElement this[string name] - { - get - { - for (XmlNode n = FirstChild; n != null; n = n.NextSibling) - { - if (n.NodeType == XmlNodeType.Element && n.Name == name) - return (XmlElement)n; - } - return null; - } - } - - // Retrieves the first child element with the specified LocalName and - // NamespaceURI. - public virtual XmlElement this[string localname, string ns] - { - get - { - for (XmlNode n = FirstChild; n != null; n = n.NextSibling) - { - if (n.NodeType == XmlNodeType.Element && n.LocalName == localname && n.NamespaceURI == ns) - return (XmlElement)n; - } - return null; - } - } - - internal virtual void SetParent(XmlNode node) - { - if (node == null) - { - this.parentNode = OwnerDocument; - } - else - { - this.parentNode = node; - } - } - - internal virtual void SetParentForLoad(XmlNode node) - { - this.parentNode = node; - } - - internal static void SplitName(string name, out string prefix, out string localName) - { - int colonPos = name.IndexOf(':'); // ordinal compare - if (-1 == colonPos || 0 == colonPos || name.Length - 1 == colonPos) - { - prefix = string.Empty; - localName = name; - } - else - { - prefix = name.Substring(0, colonPos); - localName = name.Substring(colonPos + 1); - } - } - - internal virtual XmlNode FindChild(XmlNodeType type) - { - for (XmlNode child = FirstChild; child != null; child = child.NextSibling) - { - if (child.NodeType == type) - { - return child; - } - } - return null; - } - - internal virtual XmlNodeChangedEventArgs GetEventArgs(XmlNode node, XmlNode oldParent, XmlNode newParent, string oldValue, string newValue, XmlNodeChangedAction action) - { - XmlDocument doc = OwnerDocument; - if (doc != null) - { - if (!doc.IsLoading) - { - if (((newParent != null && newParent.IsReadOnly) || (oldParent != null && oldParent.IsReadOnly))) - throw new InvalidOperationException(ResXml.Xdom_Node_Modify_ReadOnly); - } - return doc.GetEventArgs(node, oldParent, newParent, oldValue, newValue, action); - } - return null; - } - - internal virtual void BeforeEvent(XmlNodeChangedEventArgs args) - { - if (args != null) - OwnerDocument.BeforeEvent(args); - } - - internal virtual void AfterEvent(XmlNodeChangedEventArgs args) - { - if (args != null) - OwnerDocument.AfterEvent(args); - } - - internal virtual XmlSpace XmlSpace - { - get - { - XmlNode node = this; - XmlElement elem = null; - do - { - elem = node as XmlElement; - if (elem != null && elem.HasAttribute("xml:space")) - { - switch (XmlConvert.TrimString(elem.GetAttribute("xml:space"))) - { - case "default": - return XmlSpace.Default; - case "preserve": - return XmlSpace.Preserve; - default: - //should we throw exception if value is otherwise? - break; - } - } - node = node.ParentNode; - } - while (node != null); - return XmlSpace.None; - } - } - - internal virtual String XmlLang - { - get - { - XmlNode node = this; - XmlElement elem = null; - do - { - elem = node as XmlElement; - if (elem != null) - { - if (elem.HasAttribute("xml:lang")) - return elem.GetAttribute("xml:lang"); - } - node = node.ParentNode; - } while (node != null); - return String.Empty; - } - } - - internal virtual XPathNodeType XPNodeType - { - get - { - return (XPathNodeType)(-1); - } - } - - internal virtual string XPLocalName - { - get - { - return string.Empty; - } - } - - internal virtual string GetXPAttribute(string localName, string namespaceURI) - { - return String.Empty; - } - - internal virtual bool IsText - { - get - { - return false; - } - } - - public virtual XmlNode PreviousText - { - get - { - return null; - } - } - - internal static void NestTextNodes(XmlNode prevNode, XmlNode nextNode) - { - Debug.Assert(prevNode.IsText); - Debug.Assert(nextNode.IsText); - - nextNode.parentNode = prevNode; - } - - internal static void UnnestTextNodes(XmlNode prevNode, XmlNode nextNode) - { - Debug.Assert(prevNode.IsText); - Debug.Assert(nextNode.IsText); - - nextNode.parentNode = prevNode.ParentNode; - } - private object debuggerDisplayProxy { get { return new DebuggerDisplayXmlNodeProxy(this); } } - } - - [DebuggerDisplay("{ToString()}")] - internal struct DebuggerDisplayXmlNodeProxy - { - private XmlNode _node; - - public DebuggerDisplayXmlNodeProxy(XmlNode node) - { - _node = node; - } - - public override string ToString() - { - XmlNodeType nodeType = _node.NodeType; - string result = nodeType.ToString(); - switch (nodeType) - { - case XmlNodeType.Element: - case XmlNodeType.EntityReference: - result += ", Name=\"" + _node.Name + "\""; - break; - case XmlNodeType.Attribute: - case XmlNodeType.ProcessingInstruction: - result += ", Name=\"" + _node.Name + "\", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_node.Value) + "\""; - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Comment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.XmlDeclaration: - result += ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_node.Value) + "\""; - break; - case XmlNodeType.DocumentType: - XmlDocumentType documentType = (XmlDocumentType)_node; - result += ", Name=\"" + documentType.Name + "\", SYSTEM=\"" + documentType.SystemId + "\", PUBLIC=\"" + documentType.PublicId + "\", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(documentType.InternalSubset) + "\""; - break; - default: - break; - } - return result; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventArgs.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventArgs.cs deleted file mode 100644 index 486e8de375f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - public class XmlNodeChangedEventArgs : EventArgs - { - private XmlNodeChangedAction _action; - private XmlNode _node; - private XmlNode _oldParent; - private XmlNode _newParent; - private string _oldValue; - private string _newValue; - - public XmlNodeChangedEventArgs(XmlNode node, XmlNode oldParent, XmlNode newParent, string oldValue, string newValue, XmlNodeChangedAction action) - { - _node = node; - _oldParent = oldParent; - _newParent = newParent; - _action = action; - _oldValue = oldValue; - _newValue = newValue; - } - - public XmlNodeChangedAction Action { get { return _action; } } - - public XmlNode Node { get { return _node; } } - - public XmlNode OldParent { get { return _oldParent; } } - - public XmlNode NewParent { get { return _newParent; } } - - public string OldValue { get { return _oldValue; } } - - public string NewValue { get { return _newValue; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventHandler.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventHandler.cs deleted file mode 100644 index 24deb8446e0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeChangedEventHandler.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - public delegate void XmlNodeChangedEventHandler(object sender, XmlNodeChangedEventArgs e); -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeList.cs deleted file mode 100644 index a4df002083f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeList.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - - // Represents an ordered collection of nodes. - public abstract class XmlNodeList : IEnumerable, IDisposable - { - // Retrieves a node at the given index. - public abstract XmlNode Item(int index); - - // Gets the number of nodes in this XmlNodeList. - public abstract int Count { get; } - - // Provides a simple ForEach-style iteration over the collection of nodes in - // this XmlNodeList. - public abstract IEnumerator GetEnumerator(); - - // Retrieves a node at the given index. - [System.Runtime.CompilerServices.IndexerName("ItemOf")] - public virtual XmlNode this[int i] { get { return Item(i); } } - - void IDisposable.Dispose() - { - PrivateDisposeNodeList(); - } - - protected virtual void PrivateDisposeNodeList() { } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeReader.cs deleted file mode 100644 index f74b4f0b320..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNodeReader.cs +++ /dev/null @@ -1,1952 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Text; - using System.IO; - using System.Diagnostics; - using System.Collections; - using System.Collections.Generic; - using Microsoft.Xml.Schema; - using System.Globalization; - - internal class XmlNodeReaderNavigator - { - private XmlNode _curNode; - private XmlNode _elemNode; - private XmlNode _logNode; - private int _attrIndex; - private int _logAttrIndex; - - //presave these 2 variables since they shouldn't change. - private XmlNameTable _nameTable; - private XmlDocument _doc; - - private int _nAttrInd; //used to identify virtual attributes of DocumentType node and XmlDeclaration node - - private const String strPublicID = "PUBLIC"; - private const String strSystemID = "SYSTEM"; - private const String strVersion = "version"; - private const String strStandalone = "standalone"; - private const String strEncoding = "encoding"; - - - //caching variables for perf reasons - private int _nDeclarationAttrCount; - private int _nDocTypeAttrCount; - - //variables for roll back the moves - private int _nLogLevel; - private int _nLogAttrInd; - private bool _bLogOnAttrVal; - private bool _bCreatedOnAttribute; - - internal struct VirtualAttribute - { - internal String name; - internal String value; - - internal VirtualAttribute(String name, String value) - { - this.name = name; - this.value = value; - } - }; - - internal VirtualAttribute[] decNodeAttributes = { - new VirtualAttribute( null, null ), - new VirtualAttribute( null, null ), - new VirtualAttribute( null, null ) - }; - - internal VirtualAttribute[] docTypeNodeAttributes = { - new VirtualAttribute( null, null ), - new VirtualAttribute( null, null ) - }; - - private bool _bOnAttrVal; - - public XmlNodeReaderNavigator(XmlNode node) - { - _curNode = node; - _logNode = node; - XmlNodeType nt = _curNode.NodeType; - if (nt == XmlNodeType.Attribute) - { - _elemNode = null; - _attrIndex = -1; - _bCreatedOnAttribute = true; - } - else - { - _elemNode = node; - _attrIndex = -1; - _bCreatedOnAttribute = false; - } - //presave this for pref reason since it shouldn't change. - if (nt == XmlNodeType.Document) - _doc = (XmlDocument)_curNode; - else - _doc = node.OwnerDocument; - _nameTable = _doc.NameTable; - _nAttrInd = -1; - //initialize the caching variables - _nDeclarationAttrCount = -1; - _nDocTypeAttrCount = -1; - _bOnAttrVal = false; - _bLogOnAttrVal = false; - } - - public XmlNodeType NodeType - { - get - { - XmlNodeType nt = _curNode.NodeType; - if (_nAttrInd != -1) - { - Debug.Assert(nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType); - if (_bOnAttrVal) - return XmlNodeType.Text; - else - return XmlNodeType.Attribute; - } - return nt; - } - } - - public String NamespaceURI - { - get { return _curNode.NamespaceURI; } - } - - public String Name - { - get - { - if (_nAttrInd != -1) - { - Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType); - if (_bOnAttrVal) - return String.Empty; //Text node's name is String.Empty - else - { - Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount); - if (_curNode.NodeType == XmlNodeType.XmlDeclaration) - return decNodeAttributes[_nAttrInd].name; - else - return docTypeNodeAttributes[_nAttrInd].name; - } - } - if (IsLocalNameEmpty(_curNode.NodeType)) - return String.Empty; - return _curNode.Name; - } - } - - public String LocalName - { - get - { - if (_nAttrInd != -1) - //for the nodes in this case, their LocalName should be the same as their name - return Name; - if (IsLocalNameEmpty(_curNode.NodeType)) - return String.Empty; - return _curNode.LocalName; - } - } - - internal bool IsOnAttrVal - { - get - { - return _bOnAttrVal; - } - } - - internal XmlNode OwnerElementNode - { - get - { - if (_bCreatedOnAttribute) - return null; - return _elemNode; - } - } - - internal bool CreatedOnAttribute - { - get - { - return _bCreatedOnAttribute; - } - } - - private bool IsLocalNameEmpty(XmlNodeType nt) - { - switch (nt) - { - case XmlNodeType.None: - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Comment: - case XmlNodeType.Document: - case XmlNodeType.DocumentFragment: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.EndElement: - case XmlNodeType.EndEntity: - return true; - case XmlNodeType.Element: - case XmlNodeType.Attribute: - case XmlNodeType.EntityReference: - case XmlNodeType.Entity: - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.DocumentType: - case XmlNodeType.Notation: - case XmlNodeType.XmlDeclaration: - return false; - default: - return true; - } - } - - public String Prefix - { - get { return _curNode.Prefix; } - } - - public bool HasValue - { - //In DOM, DocumentType node and XmlDeclaration node doesn't value - //In XPathNavigator, XmlDeclaration node's value is its InnerText; DocumentType doesn't have value - //In XmlReader, DocumentType node's value is its InternalSubset which is never null ( at least String.Empty ) - get - { - if (_nAttrInd != -1) - { - //Pointing at the one of virtual attributes of Declaration or DocumentType nodes - Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType); - Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount); - return true; - } - if (_curNode.Value != null || _curNode.NodeType == XmlNodeType.DocumentType) - return true; - return false; - } - } - - public String Value - { - //See comments in HasValue - get - { - String retValue = null; - XmlNodeType nt = _curNode.NodeType; - if (_nAttrInd != -1) - { - //Pointing at the one of virtual attributes of Declaration or DocumentType nodes - Debug.Assert(nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType); - Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount); - if (_curNode.NodeType == XmlNodeType.XmlDeclaration) - return decNodeAttributes[_nAttrInd].value; - else - return docTypeNodeAttributes[_nAttrInd].value; - } - if (nt == XmlNodeType.DocumentType) - retValue = ((XmlDocumentType)_curNode).InternalSubset; //in this case nav.Value will be null - else if (nt == XmlNodeType.XmlDeclaration) - { - StringBuilder strb = new StringBuilder(String.Empty); - if (_nDeclarationAttrCount == -1) - InitDecAttr(); - for (int i = 0; i < _nDeclarationAttrCount; i++) - { - strb.Append(decNodeAttributes[i].name + "=\"" + decNodeAttributes[i].value + "\""); - if (i != (_nDeclarationAttrCount - 1)) - strb.Append(" "); - } - retValue = strb.ToString(); - } - else - retValue = _curNode.Value; - return (retValue == null) ? String.Empty : retValue; - } - } - - public String BaseURI - { - get { return _curNode.BaseURI; } - } - - public XmlSpace XmlSpace - { - get { return _curNode.XmlSpace; } - } - - public String XmlLang - { - get { return _curNode.XmlLang; } - } - - public bool IsEmptyElement - { - get - { - if (_curNode.NodeType == XmlNodeType.Element) - { - return ((XmlElement)_curNode).IsEmpty; - } - return false; - } - } - - public bool IsDefault - { - get - { - if (_curNode.NodeType == XmlNodeType.Attribute) - { - return !((XmlAttribute)_curNode).Specified; - } - return false; - } - } - - public IXmlSchemaInfo SchemaInfo - { - get - { - return _curNode.SchemaInfo; - } - } - - public XmlNameTable NameTable - { - get { return _nameTable; } - } - - public int AttributeCount - { - get - { - if (_bCreatedOnAttribute) - return 0; - XmlNodeType nt = _curNode.NodeType; - if (nt == XmlNodeType.Element) - return ((XmlElement)_curNode).Attributes.Count; - else if (nt == XmlNodeType.Attribute - || (_bOnAttrVal && nt != XmlNodeType.XmlDeclaration && nt != XmlNodeType.DocumentType)) - return _elemNode.Attributes.Count; - else if (nt == XmlNodeType.XmlDeclaration) - { - if (_nDeclarationAttrCount != -1) - return _nDeclarationAttrCount; - InitDecAttr(); - return _nDeclarationAttrCount; - } - else if (nt == XmlNodeType.DocumentType) - { - if (_nDocTypeAttrCount != -1) - return _nDocTypeAttrCount; - InitDocTypeAttr(); - return _nDocTypeAttrCount; - } - return 0; - } - } - - private void CheckIndexCondition(int attributeIndex) - { - if (attributeIndex < 0 || attributeIndex >= AttributeCount) - { - throw new ArgumentOutOfRangeException("attributeIndex"); - } - } - - //8 functions below are the helper functions to deal with virtual attributes of XmlDeclaration nodes and DocumentType nodes. - private void InitDecAttr() - { - int i = 0; - String strTemp = _doc.Version; - if (strTemp != null && strTemp.Length != 0) - { - decNodeAttributes[i].name = strVersion; - decNodeAttributes[i].value = strTemp; - i++; - } - strTemp = _doc.Encoding; - if (strTemp != null && strTemp.Length != 0) - { - decNodeAttributes[i].name = strEncoding; - decNodeAttributes[i].value = strTemp; - i++; - } - strTemp = _doc.Standalone; - if (strTemp != null && strTemp.Length != 0) - { - decNodeAttributes[i].name = strStandalone; - decNodeAttributes[i].value = strTemp; - i++; - } - _nDeclarationAttrCount = i; - } - - public String GetDeclarationAttr(XmlDeclaration decl, String name) - { - //PreCondition: curNode is pointing at Declaration node or one of its virtual attributes - if (name == strVersion) - return decl.Version; - if (name == strEncoding) - return decl.Encoding; - if (name == strStandalone) - return decl.Standalone; - return null; - } - - public String GetDeclarationAttr(int i) - { - if (_nDeclarationAttrCount == -1) - InitDecAttr(); - return decNodeAttributes[i].value; - } - - public int GetDecAttrInd(String name) - { - if (_nDeclarationAttrCount == -1) - InitDecAttr(); - for (int i = 0; i < _nDeclarationAttrCount; i++) - { - if (decNodeAttributes[i].name == name) - return i; - } - return -1; - } - - private void InitDocTypeAttr() - { - int i = 0; - XmlDocumentType docType = _doc.DocumentType; - if (docType == null) - { - _nDocTypeAttrCount = 0; - return; - } - String strTemp = docType.PublicId; - if (strTemp != null) - { - docTypeNodeAttributes[i].name = strPublicID; - docTypeNodeAttributes[i].value = strTemp; - i++; - } - strTemp = docType.SystemId; - if (strTemp != null) - { - docTypeNodeAttributes[i].name = strSystemID; - docTypeNodeAttributes[i].value = strTemp; - i++; - } - _nDocTypeAttrCount = i; - } - - public String GetDocumentTypeAttr(XmlDocumentType docType, String name) - { - //PreCondition: nav is pointing at DocumentType node or one of its virtual attributes - if (name == strPublicID) - return docType.PublicId; - if (name == strSystemID) - return docType.SystemId; - return null; - } - - public String GetDocumentTypeAttr(int i) - { - if (_nDocTypeAttrCount == -1) - InitDocTypeAttr(); - return docTypeNodeAttributes[i].value; - } - - public int GetDocTypeAttrInd(String name) - { - if (_nDocTypeAttrCount == -1) - InitDocTypeAttr(); - for (int i = 0; i < _nDocTypeAttrCount; i++) - { - if (docTypeNodeAttributes[i].name == name) - return i; - } - return -1; - } - - private String GetAttributeFromElement(XmlElement elem, String name) - { - XmlAttribute attr = elem.GetAttributeNode(name); - if (attr != null) - return attr.Value; - return null; - } - - public String GetAttribute(String name) - { - if (_bCreatedOnAttribute) - return null; - switch (_curNode.NodeType) - { - case XmlNodeType.Element: - return GetAttributeFromElement((XmlElement)_curNode, name); - case XmlNodeType.Attribute: - return GetAttributeFromElement((XmlElement)_elemNode, name); - case XmlNodeType.XmlDeclaration: - return GetDeclarationAttr((XmlDeclaration)_curNode, name); - case XmlNodeType.DocumentType: - return GetDocumentTypeAttr((XmlDocumentType)_curNode, name); - } - return null; - } - - private String GetAttributeFromElement(XmlElement elem, String name, String ns) - { - XmlAttribute attr = elem.GetAttributeNode(name, ns); - if (attr != null) - return attr.Value; - return null; - } - public String GetAttribute(String name, String ns) - { - if (_bCreatedOnAttribute) - return null; - switch (_curNode.NodeType) - { - case XmlNodeType.Element: - return GetAttributeFromElement((XmlElement)_curNode, name, ns); - case XmlNodeType.Attribute: - return GetAttributeFromElement((XmlElement)_elemNode, name, ns); - case XmlNodeType.XmlDeclaration: - return (ns.Length == 0) ? GetDeclarationAttr((XmlDeclaration)_curNode, name) : null; - case XmlNodeType.DocumentType: - return (ns.Length == 0) ? GetDocumentTypeAttr((XmlDocumentType)_curNode, name) : null; - } - return null; - } - - public String GetAttribute(int attributeIndex) - { - if (_bCreatedOnAttribute) - return null; - switch (_curNode.NodeType) - { - case XmlNodeType.Element: - CheckIndexCondition(attributeIndex); - return ((XmlElement)_curNode).Attributes[attributeIndex].Value; - case XmlNodeType.Attribute: - CheckIndexCondition(attributeIndex); - return ((XmlElement)_elemNode).Attributes[attributeIndex].Value; - case XmlNodeType.XmlDeclaration: - { - CheckIndexCondition(attributeIndex); - return GetDeclarationAttr(attributeIndex); - } - case XmlNodeType.DocumentType: - { - CheckIndexCondition(attributeIndex); - return GetDocumentTypeAttr(attributeIndex); - } - } - throw new ArgumentOutOfRangeException("attributeIndex"); //for other senario, AttributeCount is 0, i has to be out of range - } - - public void LogMove(int level) - { - _logNode = _curNode; - _nLogLevel = level; - _nLogAttrInd = _nAttrInd; - _logAttrIndex = _attrIndex; - _bLogOnAttrVal = _bOnAttrVal; - } - - //The function has to be used in pair with ResetMove when the operation fails after LogMove() is - // called because it relies on the values of nOrigLevel, logNav and nOrigAttrInd to be acurate. - public void RollBackMove(ref int level) - { - _curNode = _logNode; - level = _nLogLevel; - _nAttrInd = _nLogAttrInd; - _attrIndex = _logAttrIndex; - _bOnAttrVal = _bLogOnAttrVal; - } - - private bool IsOnDeclOrDocType - { - get - { - XmlNodeType nt = _curNode.NodeType; - return (nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType); - } - } - - public void ResetToAttribute(ref int level) - { - //the current cursor is pointing at one of the attribute children -- this could be caused by - // the calls to ReadAttributeValue(..) - if (_bCreatedOnAttribute) - return; - if (_bOnAttrVal) - { - if (IsOnDeclOrDocType) - { - level -= 2; - } - else - { - while (_curNode.NodeType != XmlNodeType.Attribute && ((_curNode = _curNode.ParentNode) != null)) - level--; - } - _bOnAttrVal = false; - } - } - - public void ResetMove(ref int level, ref XmlNodeType nt) - { - LogMove(level); - if (_bCreatedOnAttribute) - return; - if (_nAttrInd != -1) - { - Debug.Assert(IsOnDeclOrDocType); - if (_bOnAttrVal) - { - level--; - _bOnAttrVal = false; - } - _nLogAttrInd = _nAttrInd; - level--; - _nAttrInd = -1; - nt = _curNode.NodeType; - return; - } - if (_bOnAttrVal && _curNode.NodeType != XmlNodeType.Attribute) - ResetToAttribute(ref level); - if (_curNode.NodeType == XmlNodeType.Attribute) - { - _curNode = ((XmlAttribute)_curNode).OwnerElement; - _attrIndex = -1; - level--; - nt = XmlNodeType.Element; - } - if (_curNode.NodeType == XmlNodeType.Element) - _elemNode = _curNode; - } - - public bool MoveToAttribute(string name) - { - return MoveToAttribute(name, string.Empty); - } - private bool MoveToAttributeFromElement(XmlElement elem, String name, String ns) - { - XmlAttribute attr = null; - if (ns.Length == 0) - attr = elem.GetAttributeNode(name); - else - attr = elem.GetAttributeNode(name, ns); - if (attr != null) - { - _bOnAttrVal = false; - _elemNode = elem; - _curNode = attr; - _attrIndex = elem.Attributes.FindNodeOffsetNS(attr); - if (_attrIndex != -1) - { - return true; - } - } - return false; - } - - public bool MoveToAttribute(string name, string namespaceURI) - { - if (_bCreatedOnAttribute) - return false; - XmlNodeType nt = _curNode.NodeType; - if (nt == XmlNodeType.Element) - return MoveToAttributeFromElement((XmlElement)_curNode, name, namespaceURI); - else if (nt == XmlNodeType.Attribute) - return MoveToAttributeFromElement((XmlElement)_elemNode, name, namespaceURI); - else if (nt == XmlNodeType.XmlDeclaration && namespaceURI.Length == 0) - { - if ((_nAttrInd = GetDecAttrInd(name)) != -1) - { - _bOnAttrVal = false; - return true; - } - } - else if (nt == XmlNodeType.DocumentType && namespaceURI.Length == 0) - { - if ((_nAttrInd = GetDocTypeAttrInd(name)) != -1) - { - _bOnAttrVal = false; - return true; - } - } - return false; - } - - public void MoveToAttribute(int attributeIndex) - { - if (_bCreatedOnAttribute) - return; - XmlAttribute attr = null; - switch (_curNode.NodeType) - { - case XmlNodeType.Element: - CheckIndexCondition(attributeIndex); - attr = ((XmlElement)_curNode).Attributes[attributeIndex]; - if (attr != null) - { - _elemNode = _curNode; - _curNode = (XmlNode)attr; - _attrIndex = attributeIndex; - } - break; - case XmlNodeType.Attribute: - CheckIndexCondition(attributeIndex); - attr = ((XmlElement)_elemNode).Attributes[attributeIndex]; - if (attr != null) - { - _curNode = (XmlNode)attr; - _attrIndex = attributeIndex; - } - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.DocumentType: - CheckIndexCondition(attributeIndex); - _nAttrInd = attributeIndex; - break; - } - } - - public bool MoveToNextAttribute(ref int level) - { - if (_bCreatedOnAttribute) - return false; - XmlNodeType nt = _curNode.NodeType; - if (nt == XmlNodeType.Attribute) - { - if (_attrIndex >= (_elemNode.Attributes.Count - 1)) - return false; - else - { - _curNode = _elemNode.Attributes[++_attrIndex]; - return true; - } - } - else if (nt == XmlNodeType.Element) - { - if (_curNode.Attributes.Count > 0) - { - level++; - _elemNode = _curNode; - _curNode = _curNode.Attributes[0]; - _attrIndex = 0; - return true; - } - } - else if (nt == XmlNodeType.XmlDeclaration) - { - if (_nDeclarationAttrCount == -1) - InitDecAttr(); - _nAttrInd++; - if (_nAttrInd < _nDeclarationAttrCount) - { - if (_nAttrInd == 0) level++; - _bOnAttrVal = false; - return true; - } - _nAttrInd--; - } - else if (nt == XmlNodeType.DocumentType) - { - if (_nDocTypeAttrCount == -1) - InitDocTypeAttr(); - _nAttrInd++; - if (_nAttrInd < _nDocTypeAttrCount) - { - if (_nAttrInd == 0) level++; - _bOnAttrVal = false; - return true; - } - _nAttrInd--; - } - return false; - } - - public bool MoveToParent() - { - XmlNode parent = _curNode.ParentNode; - if (parent != null) - { - _curNode = parent; - if (!_bOnAttrVal) - _attrIndex = 0; - return true; - } - return false; - } - - public bool MoveToFirstChild() - { - XmlNode firstChild = _curNode.FirstChild; - if (firstChild != null) - { - _curNode = firstChild; - if (!_bOnAttrVal) - _attrIndex = -1; - return true; - } - return false; - } - - private bool MoveToNextSibling(XmlNode node) - { - XmlNode nextSibling = node.NextSibling; - if (nextSibling != null) - { - _curNode = nextSibling; - if (!_bOnAttrVal) - _attrIndex = -1; - return true; - } - return false; - } - - public bool MoveToNext() - { - if (_curNode.NodeType != XmlNodeType.Attribute) - return MoveToNextSibling(_curNode); - else - return MoveToNextSibling(_elemNode); - } - - public bool MoveToElement() - { - if (_bCreatedOnAttribute) - return false; - switch (_curNode.NodeType) - { - case XmlNodeType.Attribute: - if (_elemNode != null) - { - _curNode = _elemNode; - _attrIndex = -1; - return true; - } - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.DocumentType: - { - if (_nAttrInd != -1) - { - _nAttrInd = -1; - return true; - } - break; - } - } - return false; - } - - public String LookupNamespace(string prefix) - { - if (_bCreatedOnAttribute) - return null; - if (prefix == "xmlns") - { - return _nameTable.Add(XmlReservedNs.NsXmlNs); - } - if (prefix == "xml") - { - return _nameTable.Add(XmlReservedNs.NsXml); - } - - // construct the name of the xmlns attribute - string attrName; - if (prefix == null) - prefix = string.Empty; - if (prefix.Length == 0) - attrName = "xmlns"; - else - attrName = "xmlns:" + prefix; - - // walk up the XmlNode parent chain, looking for the xmlns attribute - XmlNode node = _curNode; - while (node != null) - { - if (node.NodeType == XmlNodeType.Element) - { - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttribute attr = elem.GetAttributeNode(attrName); - if (attr != null) - { - return attr.Value; - } - } - } - else if (node.NodeType == XmlNodeType.Attribute) - { - node = ((XmlAttribute)node).OwnerElement; - continue; - } - node = node.ParentNode; - } - if (prefix.Length == 0) - { - return string.Empty; - } - return null; - } - - internal string DefaultLookupNamespace(string prefix) - { - if (!_bCreatedOnAttribute) - { - if (prefix == "xmlns") - { - return _nameTable.Add(XmlReservedNs.NsXmlNs); - } - if (prefix == "xml") - { - return _nameTable.Add(XmlReservedNs.NsXml); - } - if (prefix == string.Empty) - { - return _nameTable.Add(string.Empty); - } - } - return null; - } - - internal String LookupPrefix(string namespaceName) - { - if (_bCreatedOnAttribute || namespaceName == null) - { - return null; - } - if (namespaceName == XmlReservedNs.NsXmlNs) - { - return _nameTable.Add("xmlns"); - } - if (namespaceName == XmlReservedNs.NsXml) - { - return _nameTable.Add("xml"); - } - if (namespaceName == string.Empty) - { - return string.Empty; - } - // walk up the XmlNode parent chain, looking for the xmlns attribute with namespaceName value - XmlNode node = _curNode; - while (node != null) - { - if (node.NodeType == XmlNodeType.Element) - { - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttributeCollection attrs = elem.Attributes; - for (int i = 0; i < attrs.Count; i++) - { - XmlAttribute a = attrs[i]; - if (a.Value == namespaceName) - { - if (a.Prefix.Length == 0 && a.LocalName == "xmlns") - { - if (LookupNamespace(string.Empty) == namespaceName) - { - return string.Empty; - } - } - else if (a.Prefix == "xmlns") - { - string pref = a.LocalName; - if (LookupNamespace(pref) == namespaceName) - { - return _nameTable.Add(pref); - } - } - } - } - } - } - else if (node.NodeType == XmlNodeType.Attribute) - { - node = ((XmlAttribute)node).OwnerElement; - continue; - } - node = node.ParentNode; - } - return null; - } - - internal IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - Dictionary dict = new Dictionary(); - if (_bCreatedOnAttribute) - return dict; - - // walk up the XmlNode parent chain and add all namespace declarations to the dictionary - XmlNode node = _curNode; - while (node != null) - { - if (node.NodeType == XmlNodeType.Element) - { - XmlElement elem = (XmlElement)node; - if (elem.HasAttributes) - { - XmlAttributeCollection attrs = elem.Attributes; - for (int i = 0; i < attrs.Count; i++) - { - XmlAttribute a = attrs[i]; - if (a.LocalName == "xmlns" && a.Prefix.Length == 0) - { - if (!dict.ContainsKey(string.Empty)) - { - dict.Add(_nameTable.Add(string.Empty), _nameTable.Add(a.Value)); - } - } - else if (a.Prefix == "xmlns") - { - string localName = a.LocalName; - if (!dict.ContainsKey(localName)) - { - dict.Add(_nameTable.Add(localName), _nameTable.Add(a.Value)); - } - } - } - } - if (scope == XmlNamespaceScope.Local) - { - break; - } - } - else if (node.NodeType == XmlNodeType.Attribute) - { - node = ((XmlAttribute)node).OwnerElement; - continue; - } - node = node.ParentNode; - }; - - if (scope != XmlNamespaceScope.Local) - { - if (dict.ContainsKey(string.Empty) && dict[string.Empty] == string.Empty) - { - dict.Remove(string.Empty); - } - if (scope == XmlNamespaceScope.All) - { - dict.Add(_nameTable.Add("xml"), _nameTable.Add(XmlReservedNs.NsXml)); - } - } - return dict; - } - - public bool ReadAttributeValue(ref int level, ref bool bResolveEntity, ref XmlNodeType nt) - { - if (_nAttrInd != -1) - { - Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType); - if (!_bOnAttrVal) - { - _bOnAttrVal = true; - level++; - nt = XmlNodeType.Text; - return true; - } - return false; - } - if (_curNode.NodeType == XmlNodeType.Attribute) - { - XmlNode firstChild = _curNode.FirstChild; - if (firstChild != null) - { - _curNode = firstChild; - nt = _curNode.NodeType; - level++; - _bOnAttrVal = true; - return true; - } - } - else if (_bOnAttrVal) - { - XmlNode nextSibling = null; - if (_curNode.NodeType == XmlNodeType.EntityReference && bResolveEntity) - { - //going down to ent ref node - _curNode = _curNode.FirstChild; - nt = _curNode.NodeType; - Debug.Assert(_curNode != null); - level++; - bResolveEntity = false; - return true; - } - else - nextSibling = _curNode.NextSibling; - if (nextSibling == null) - { - XmlNode parentNode = _curNode.ParentNode; - //Check if its parent is entity ref node is sufficient, because in this senario, ent ref node can't have more than 1 level of children that are not other ent ref nodes - if (parentNode != null && parentNode.NodeType == XmlNodeType.EntityReference) - { - //come back from ent ref node - _curNode = parentNode; - nt = XmlNodeType.EndEntity; - level--; - return true; - } - } - if (nextSibling != null) - { - _curNode = nextSibling; - nt = _curNode.NodeType; - return true; - } - else - return false; - } - return false; - } - - public XmlDocument Document - { - get - { - return _doc; - } - } - } - - // Represents a reader that provides fast, non-cached forward only stream access - // to XML data in an XmlDocument or a specific XmlNode within an XmlDocument. - public class XmlNodeReader : XmlReader, IXmlNamespaceResolver - { - private XmlNodeReaderNavigator _readerNav; - - private XmlNodeType _nodeType; // nodeType of the node that the reader is currently positioned on - private int _curDepth; // depth of attrNav ( also functions as reader's depth ) - private ReadState _readState; // current reader's state - private bool _fEOF; // flag to show if reaches the end of file - //mark to the state that EntityReference node is supposed to be resolved - private bool _bResolveEntity; - private bool _bStartFromDocument; - - private bool _bInReadBinary; - private ReadContentAsBinaryHelper _readBinaryHelper; - - - // Creates an instance of the XmlNodeReader class using the specified XmlNode. - public XmlNodeReader(XmlNode node) - { - if (node == null) - { - throw new ArgumentNullException("node"); - } - _readerNav = new XmlNodeReaderNavigator(node); - _curDepth = 0; - - _readState = ReadState.Initial; - _fEOF = false; - _nodeType = XmlNodeType.None; - _bResolveEntity = false; - _bStartFromDocument = false; - } - - //function returns if the reader currently in valid reading states - internal bool IsInReadingStates() - { - return (_readState == ReadState.Interactive); // || readState == ReadState.EndOfFile - } - - // - // Node Properties - // - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return (IsInReadingStates()) ? _nodeType : XmlNodeType.None; } - } - - // Gets the name of - // the current node, including the namespace prefix. - public override string Name - { - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.Name; - } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.LocalName; - } - } - - // Gets the namespace URN (as defined in the W3C Namespace Specification) - // of the current namespace scope. - public override string NamespaceURI - { - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.NamespaceURI; - } - } - - // Gets the namespace prefix associated with the current node. - public override string Prefix - { - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.Prefix; - } - } - - // Gets a value indicating whether - // XmlNodeReader.Value has a value to return. - public override bool HasValue - { - get - { - if (!IsInReadingStates()) - return false; - return _readerNav.HasValue; - } - } - - // Gets the text value of the current node. - public override string Value - { - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.Value; - } - } - - // Gets the depth of the - // current node in the XML element stack. - public override int Depth - { - get { return _curDepth; } - } - - // Gets the base URI of the current node. - public override String BaseURI - { - get { return _readerNav.BaseURI; } - } - - public override bool CanResolveEntity - { - get { return true; } - } - - // Gets a value indicating whether the current - // node is an empty element (for example, . - public override bool IsEmptyElement - { - get - { - if (!IsInReadingStates()) - return false; - return _readerNav.IsEmptyElement; - } - } - - // Gets a value indicating whether the current node is an - // attribute that was generated from the default value defined - // in the DTD or schema. - public override bool IsDefault - { - get - { - if (!IsInReadingStates()) - return false; - return _readerNav.IsDefault; - } - } - - // Gets the current xml:space scope. - public override XmlSpace XmlSpace - { - get - { - if (!IsInReadingStates()) - return XmlSpace.None; - return _readerNav.XmlSpace; - } - } - - // Gets the current xml:lang scope. - public override string XmlLang - { - // Assume everything is in Unicode - get - { - if (!IsInReadingStates()) - return String.Empty; - return _readerNav.XmlLang; - } - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - if (!IsInReadingStates()) - { - return null; - } - return _readerNav.SchemaInfo; - } - } - - // - // Attribute Accessors - // - - // Gets the number of attributes on the current node. - public override int AttributeCount - { - get - { - if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement) - return 0; - return _readerNav.AttributeCount; - } - } - - // Gets the value of the attribute with the specified name. - public override string GetAttribute(string name) - { - //if not on Attribute, only element node could have attributes - if (!IsInReadingStates()) - return null; - return _readerNav.GetAttribute(name); - } - - // Gets the value of the attribute with the specified name and namespace. - public override string GetAttribute(string name, string namespaceURI) - { - //if not on Attribute, only element node could have attributes - if (!IsInReadingStates()) - return null; - String ns = (namespaceURI == null) ? String.Empty : namespaceURI; - return _readerNav.GetAttribute(name, ns); - } - - // Gets the value of the attribute with the specified index. - public override string GetAttribute(int attributeIndex) - { - if (!IsInReadingStates()) - throw new ArgumentOutOfRangeException("attributeIndex"); - //CheckIndexCondition( i ); - //Debug.Assert( nav.NodeType == XmlNodeType.Element ); - return _readerNav.GetAttribute(attributeIndex); - } - - // Moves to the attribute with the specified name. - public override bool MoveToAttribute(string name) - { - if (!IsInReadingStates()) - return false; - _readerNav.ResetMove(ref _curDepth, ref _nodeType); - if (_readerNav.MoveToAttribute(name)) - { //, ref curDepth ) ) { - _curDepth++; - _nodeType = _readerNav.NodeType; - if (_bInReadBinary) - { - FinishReadBinary(); - } - return true; - } - _readerNav.RollBackMove(ref _curDepth); - return false; - } - - // Moves to the attribute with the specified name and namespace. - public override bool MoveToAttribute(string name, string namespaceURI) - { - if (!IsInReadingStates()) - return false; - _readerNav.ResetMove(ref _curDepth, ref _nodeType); - String ns = (namespaceURI == null) ? String.Empty : namespaceURI; - if (_readerNav.MoveToAttribute(name, ns)) - { //, ref curDepth ) ) { - _curDepth++; - _nodeType = _readerNav.NodeType; - if (_bInReadBinary) - { - FinishReadBinary(); - } - return true; - } - _readerNav.RollBackMove(ref _curDepth); - return false; - } - - // Moves to the attribute with the specified index. - public override void MoveToAttribute(int attributeIndex) - { - if (!IsInReadingStates()) - throw new ArgumentOutOfRangeException("attributeIndex"); - _readerNav.ResetMove(ref _curDepth, ref _nodeType); - try - { - if (AttributeCount > 0) - { - _readerNav.MoveToAttribute(attributeIndex); - if (_bInReadBinary) - { - FinishReadBinary(); - } - } - else - throw new ArgumentOutOfRangeException("attributeIndex"); - } - catch - { - _readerNav.RollBackMove(ref _curDepth); - throw; - } - _curDepth++; - _nodeType = _readerNav.NodeType; - } - - // Moves to the first attribute. - public override bool MoveToFirstAttribute() - { - if (!IsInReadingStates()) - return false; - _readerNav.ResetMove(ref _curDepth, ref _nodeType); - if (AttributeCount > 0) - { - _readerNav.MoveToAttribute(0); - _curDepth++; - _nodeType = _readerNav.NodeType; - if (_bInReadBinary) - { - FinishReadBinary(); - } - return true; - } - _readerNav.RollBackMove(ref _curDepth); - return false; - } - - // Moves to the next attribute. - public override bool MoveToNextAttribute() - { - if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement) - return false; - _readerNav.LogMove(_curDepth); - _readerNav.ResetToAttribute(ref _curDepth); - if (_readerNav.MoveToNextAttribute(ref _curDepth)) - { - _nodeType = _readerNav.NodeType; - if (_bInReadBinary) - { - FinishReadBinary(); - } - return true; - } - _readerNav.RollBackMove(ref _curDepth); - return false; - } - - // Moves to the element that contains the current attribute node. - public override bool MoveToElement() - { - if (!IsInReadingStates()) - return false; - _readerNav.LogMove(_curDepth); - _readerNav.ResetToAttribute(ref _curDepth); - if (_readerNav.MoveToElement()) - { - _curDepth--; - _nodeType = _readerNav.NodeType; - if (_bInReadBinary) - { - FinishReadBinary(); - } - return true; - } - _readerNav.RollBackMove(ref _curDepth); - return false; - } - - // - // Moving through the Stream - // - - // Reads the next node from the stream. - public override bool Read() - { - return Read(false); - } - private bool Read(bool fSkipChildren) - { - if (_fEOF) - return false; - - if (_readState == ReadState.Initial) - { - // if nav is pointing at the document node, start with its children - // otherwise,start with the node. - if ((_readerNav.NodeType == XmlNodeType.Document) || (_readerNav.NodeType == XmlNodeType.DocumentFragment)) - { - _bStartFromDocument = true; - if (!ReadNextNode(fSkipChildren)) - { - _readState = ReadState.Error; - return false; - } - } - ReSetReadingMarks(); - _readState = ReadState.Interactive; - _nodeType = _readerNav.NodeType; - //_depth = 0; - _curDepth = 0; - return true; - } - - if (_bInReadBinary) - { - FinishReadBinary(); - } - - bool bRead = false; - if ((_readerNav.CreatedOnAttribute)) - return false; - ReSetReadingMarks(); - bRead = ReadNextNode(fSkipChildren); - if (bRead) - { - return true; - } - else - { - if (_readState == ReadState.Initial || _readState == ReadState.Interactive) - _readState = ReadState.Error; - if (_readState == ReadState.EndOfFile) - _nodeType = XmlNodeType.None; - return false; - } - } - - private bool ReadNextNode(bool fSkipChildren) - { - if (_readState != ReadState.Interactive && _readState != ReadState.Initial) - { - _nodeType = XmlNodeType.None; - return false; - } - - bool bDrillDown = !fSkipChildren; - XmlNodeType nt = _readerNav.NodeType; - //only goes down when nav.NodeType is of element or of document at the initial state, other nav.NodeType will not be parsed down - //if nav.NodeType is of EntityReference, ResolveEntity() could be called to get the content parsed; - bDrillDown = bDrillDown - && (_nodeType != XmlNodeType.EndElement) - && (_nodeType != XmlNodeType.EndEntity) - && (nt == XmlNodeType.Element || (nt == XmlNodeType.EntityReference && _bResolveEntity) || - (((_readerNav.NodeType == XmlNodeType.Document) || (_readerNav.NodeType == XmlNodeType.DocumentFragment)) && _readState == ReadState.Initial)); - //first see if there are children of current node, so to move down - if (bDrillDown) - { - if (_readerNav.MoveToFirstChild()) - { - _nodeType = _readerNav.NodeType; - _curDepth++; - if (_bResolveEntity) - _bResolveEntity = false; - return true; - } - else if (_readerNav.NodeType == XmlNodeType.Element - && !_readerNav.IsEmptyElement) - { - _nodeType = XmlNodeType.EndElement; - return true; - } - else if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity) - { - _bResolveEntity = false; - _nodeType = XmlNodeType.EndEntity; - return true; - } - // if fails to move to it 1st Child, try to move to next below - return ReadForward(fSkipChildren); - } - else - { - if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity) - { - //The only way to get to here is because Skip() is called directly after ResolveEntity() - // in this case, user wants to skip the first Child of EntityRef node and fSkipChildren is true - // We want to pointing to the first child node. - if (_readerNav.MoveToFirstChild()) - { - _nodeType = _readerNav.NodeType; - _curDepth++; - } - else - { - _nodeType = XmlNodeType.EndEntity; - } - _bResolveEntity = false; - return true; - } - } - return ReadForward(fSkipChildren); //has to get the next node by moving forward - } - - private void SetEndOfFile() - { - _fEOF = true; - _readState = ReadState.EndOfFile; - _nodeType = XmlNodeType.None; - } - - private bool ReadAtZeroLevel(bool fSkipChildren) - { - Debug.Assert(_curDepth == 0); - if (!fSkipChildren - && _nodeType != XmlNodeType.EndElement - && _readerNav.NodeType == XmlNodeType.Element - && !_readerNav.IsEmptyElement) - { - _nodeType = XmlNodeType.EndElement; - return true; - } - else - { - SetEndOfFile(); - return false; - } - } - - private bool ReadForward(bool fSkipChildren) - { - if (_readState == ReadState.Error) - return false; - - if (!_bStartFromDocument && _curDepth == 0) - { - //already on top most node and we shouldn't move to next - return ReadAtZeroLevel(fSkipChildren); - } - //else either we are not on top level or we are starting from the document at the very beginning in which case - // we will need to read all the "top" most nodes - if (_readerNav.MoveToNext()) - { - _nodeType = _readerNav.NodeType; - return true; - } - else - { - //need to check its parent - if (_curDepth == 0) - return ReadAtZeroLevel(fSkipChildren); - if (_readerNav.MoveToParent()) - { - if (_readerNav.NodeType == XmlNodeType.Element) - { - _curDepth--; - _nodeType = XmlNodeType.EndElement; - return true; - } - else if (_readerNav.NodeType == XmlNodeType.EntityReference) - { - //coming back from entity reference node -- must be getting down through call ResolveEntity() - _curDepth--; - _nodeType = XmlNodeType.EndEntity; - return true; - } - return true; - } - } - return false; - } - - //the function reset the marks used for ReadChars() and MoveToAttribute(...), ReadAttributeValue(...) - private void ReSetReadingMarks() - { - //_attrValInd = -1; - _readerNav.ResetMove(ref _curDepth, ref _nodeType); - //attrNav.MoveTo( nav ); - //curDepth = _depth; - } - - // Gets a value indicating whether the reader is positioned at the - // end of the stream. - public override bool EOF - { - get { return (_readState != ReadState.Closed) && _fEOF; } - } - - // Closes the stream, changes the XmlNodeReader.ReadState - // to Closed, and sets all the properties back to zero. - public override void Close() - { - _readState = ReadState.Closed; - } - - // Gets the read state of the stream. - public override ReadState ReadState - { - get { return _readState; } - } - - // Skips to the end tag of the current element. - public override void Skip() - { - Read(true); - } - - // Reads the contents of an element as a string. - public override string ReadString() - { - if ((this.NodeType == XmlNodeType.EntityReference) && _bResolveEntity) - { - if (!this.Read()) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - } - return base.ReadString(); - } - - // - // Partial Content Read Methods - // - - // Gets a value indicating whether the current node - // has any attributes. - public override bool HasAttributes - { - get - { - return (AttributeCount > 0); - } - } - - // - // Nametable and Namespace Helpers - // - - // Gets the XmlNameTable associated with this implementation. - public override XmlNameTable NameTable - { - get { return _readerNav.NameTable; } - } - - // Resolves a namespace prefix in the current element's scope. - public override String LookupNamespace(string prefix) - { - if (!IsInReadingStates()) - return null; - string ns = _readerNav.LookupNamespace(prefix); - if (ns != null && ns.Length == 0) - { - return null; - } - return ns; - } - - // Resolves the entity reference for nodes of NodeType EntityReference. - public override void ResolveEntity() - { - if (!IsInReadingStates() || (_nodeType != XmlNodeType.EntityReference)) - throw new InvalidOperationException(ResXml.Xnr_ResolveEntity); - _bResolveEntity = true; ; - } - - // Parses the attribute value into one or more Text and/or - // EntityReference node types. - public override bool ReadAttributeValue() - { - if (!IsInReadingStates()) - return false; - if (_readerNav.ReadAttributeValue(ref _curDepth, ref _bResolveEntity, ref _nodeType)) - { - _bInReadBinary = false; - return true; - } - return false; - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - if (_readState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (!_bInReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - - // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper - _bInReadBinary = false; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count); - - // turn on bInReadBinary in again and return - _bInReadBinary = true; - return readCount; - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - if (_readState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (!_bInReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - - // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper - _bInReadBinary = false; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count); - - // turn on bInReadBinary in again and return - _bInReadBinary = true; - return readCount; - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - if (_readState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (!_bInReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - - // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper - _bInReadBinary = false; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count); - - // turn on bInReadBinary in again and return - _bInReadBinary = true; - return readCount; - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - if (_readState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (!_bInReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - } - - // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper - _bInReadBinary = false; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count); - - // turn on bInReadBinary in again and return - _bInReadBinary = true; - return readCount; - } - - private void FinishReadBinary() - { - _bInReadBinary = false; - _readBinaryHelper.Finish(); - } - - // - // IXmlNamespaceResolver - // - - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _readerNav.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _readerNav.LookupPrefix(namespaceName); - } - - String IXmlNamespaceResolver.LookupNamespace(string prefix) - { - if (!IsInReadingStates()) - { - return _readerNav.DefaultLookupNamespace(prefix); - } - string ns = _readerNav.LookupNamespace(prefix); - if (ns != null) - { - ns = _readerNav.NameTable.Add(ns); - } - return ns; - } - - // DTD/Schema info used by XmlReader.GetDtdSchemaInfo() - internal override IDtdInfo DtdInfo - { - get - { - return _readerNav.Document.DtdSchemaInfo; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNotation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNotation.cs deleted file mode 100644 index 7d01d0046db..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlNotation.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Diagnostics; - - // Contains a notation declared in the DTD or schema. - public class XmlNotation : XmlNode - { - private String _publicId; - private String _systemId; - private String _name; - - internal XmlNotation(String name, String publicId, String systemId, XmlDocument doc) : base(doc) - { - _name = doc.NameTable.Add(name); - _publicId = publicId; - _systemId = systemId; - } - - // Gets the name of the node. - public override string Name - { - get { return _name; } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get { return _name; } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.Notation; } - } - - // Throws an InvalidOperationException since Notation can not be cloned. - public override XmlNode CloneNode(bool deep) - { - throw new InvalidOperationException(ResXml.Xdom_Node_Cloning); - } - - // - // Microsoft extensions - // - - // Gets a value indicating whether the node is read-only. - public override bool IsReadOnly - { - get - { - return true; // Make notations readonly - } - } - - // Gets the value of the public identifier on the notation declaration. - public String PublicId - { - get { return _publicId; } - } - - // Gets the value of - // the system identifier on the notation declaration. - public String SystemId - { - get { return _systemId; } - } - - // Without override these two functions, we can't guarantee that WriteTo()/WriteContent() functions will never be called - public override String OuterXml - { - get { return String.Empty; } - } - - public override String InnerXml - { - get { return String.Empty; } - set { throw new InvalidOperationException(ResXml.Xdom_Set_InnerXml); } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlProcessingInstruction.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlProcessingInstruction.cs deleted file mode 100644 index 1eb29c74f29..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlProcessingInstruction.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.IO; - using System.Diagnostics; - using System.Text; - using Microsoft.Xml.XPath; - - // Represents a processing instruction, which XML defines to keep - // processor-specific information in the text of the document. - public class XmlProcessingInstruction : XmlLinkedNode - { - private string _target; - private string _data; - - protected internal XmlProcessingInstruction(string target, string data, XmlDocument doc) : base(doc) - { - _target = target; - _data = data; - } - - // Gets the name of the node. - public override String Name - { - get - { - if (_target != null) - return _target; - return String.Empty; - } - } - - // Gets the name of the current node without the namespace prefix. - public override string LocalName - { - get { return Name; } - } - - // Gets or sets the value of the node. - public override String Value - { - get { return _data; } - set { Data = value; } //use Data instead of data so that event will be fired - } - - // Gets the target of the processing instruction. - public String Target - { - get { return _target; } - } - - // Gets or sets the content of processing instruction, - // excluding the target. - public String Data - { - get { return _data; } - set - { - XmlNode parent = ParentNode; - XmlNodeChangedEventArgs args = GetEventArgs(this, parent, parent, _data, value, XmlNodeChangedAction.Change); - if (args != null) - BeforeEvent(args); - _data = value; - if (args != null) - AfterEvent(args); - } - } - - // Gets or sets the concatenated values of the node and - // all its children. - public override string InnerText - { - get { return _data; } - set { Data = value; } //use Data instead of data so that change event will be fired - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get { return XmlNodeType.ProcessingInstruction; } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateProcessingInstruction(_target, _data); - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteProcessingInstruction(_target, _data); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override string XPLocalName { get { return Name; } } - internal override XPathNodeType XPNodeType { get { return XPathNodeType.ProcessingInstruction; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlSignificantWhitespace.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlSignificantWhitespace.cs deleted file mode 100644 index 478d861c057..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlSignificantWhitespace.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using Microsoft.Xml.XPath; - using System.Text; - using System.Diagnostics; - - // Represents the text content of an element or attribute. - public class XmlSignificantWhitespace : XmlCharacterData - { - protected internal XmlSignificantWhitespace(string strData, XmlDocument doc) : base(strData, doc) - { - if (!doc.IsLoading && !base.CheckOnData(strData)) - throw new ArgumentException(ResXml.Xdom_WS_Char); - } - - // Gets the name of the node. - public override String Name - { - get - { - return OwnerDocument.strSignificantWhitespaceName; - } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get - { - return OwnerDocument.strSignificantWhitespaceName; - } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - return XmlNodeType.SignificantWhitespace; - } - } - - public override XmlNode ParentNode - { - get - { - switch (parentNode.NodeType) - { - case XmlNodeType.Document: - return base.ParentNode; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - XmlNode parent = parentNode.parentNode; - while (parent.IsText) - { - parent = parent.parentNode; - } - return parent; - default: - return parentNode; - } - } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateSignificantWhitespace(Data); - } - - public override String Value - { - get - { - return Data; - } - - set - { - if (CheckOnData(value)) - Data = value; - else - throw new ArgumentException(ResXml.Xdom_WS_Char); - } - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteString(Data); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override XPathNodeType XPNodeType - { - get - { - XPathNodeType xnt = XPathNodeType.SignificantWhitespace; - DecideXPNodeTypeForTextNodes(this, ref xnt); - return xnt; - } - } - - internal override bool IsText - { - get - { - return true; - } - } - - public override XmlNode PreviousText - { - get - { - if (parentNode.IsText) - { - return parentNode; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlText.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlText.cs deleted file mode 100644 index 1720d0c8243..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlText.cs +++ /dev/null @@ -1,163 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.Text; - using System.Diagnostics; - using Microsoft.Xml.XPath; - - // Represents the text content of an element or attribute. - public class XmlText : XmlCharacterData - { - internal XmlText(string strData) : this(strData, null) - { - } - - protected internal XmlText(string strData, XmlDocument doc) : base(strData, doc) - { - } - - // Gets the name of the node. - public override String Name - { - get - { - return OwnerDocument.strTextName; - } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get - { - return OwnerDocument.strTextName; - } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - return XmlNodeType.Text; - } - } - - public override XmlNode ParentNode - { - get - { - switch (parentNode.NodeType) - { - case XmlNodeType.Document: - return null; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - XmlNode parent = parentNode.parentNode; - while (parent.IsText) - { - parent = parent.parentNode; - } - return parent; - default: - return parentNode; - } - } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateTextNode(Data); - } - - public override String Value - { - get - { - return Data; - } - - set - { - Data = value; - XmlNode parent = parentNode; - if (parent != null && parent.NodeType == XmlNodeType.Attribute) - { - XmlUnspecifiedAttribute attr = parent as XmlUnspecifiedAttribute; - if (attr != null && !attr.Specified) - { - attr.SetSpecified(true); - } - } - } - } - - // Splits the node into two nodes at the specified offset, keeping - // both in the tree as siblings. - public virtual XmlText SplitText(int offset) - { - XmlNode parentNode = this.ParentNode; - int length = this.Length; - if (offset > length) - throw new ArgumentOutOfRangeException("offset"); - //if the text node is out of the living tree, throw exception. - if (parentNode == null) - throw new InvalidOperationException(ResXml.Xdom_TextNode_SplitText); - - int count = length - offset; - String splitData = Substring(offset, count); - DeleteData(offset, count); - XmlText newTextNode = OwnerDocument.CreateTextNode(splitData); - parentNode.InsertAfter(newTextNode, this); - return newTextNode; - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteString(Data); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override XPathNodeType XPNodeType - { - get - { - return XPathNodeType.Text; - } - } - - internal override bool IsText - { - get - { - return true; - } - } - - public override XmlNode PreviousText - { - get - { - if (parentNode.IsText) - { - return parentNode; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlUnspecifiedAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlUnspecifiedAttribute.cs deleted file mode 100644 index 11c5ddd1ae9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlUnspecifiedAttribute.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - internal class XmlUnspecifiedAttribute : XmlAttribute - { - private bool _fSpecified = false; - - - protected internal XmlUnspecifiedAttribute(string prefix, string localName, string namespaceURI, XmlDocument doc) - : base(prefix, localName, namespaceURI, doc) - { - } - - public override bool Specified - { - get { return _fSpecified; } - } - - - public override XmlNode CloneNode(bool deep) - { - //CloneNode is deep for attributes irrespective of parameter - XmlDocument doc = OwnerDocument; - XmlUnspecifiedAttribute attr = (XmlUnspecifiedAttribute)doc.CreateDefaultAttribute(Prefix, LocalName, NamespaceURI); - attr.CopyChildren(doc, this, true); - attr._fSpecified = true; //When clone, should return the specifed attribute as default - return attr; - } - - public override string InnerText - { - set - { - base.InnerText = value; - _fSpecified = true; - } - } - - public override XmlNode InsertBefore(XmlNode newChild, XmlNode refChild) - { - XmlNode node = base.InsertBefore(newChild, refChild); - _fSpecified = true; - return node; - } - - public override XmlNode InsertAfter(XmlNode newChild, XmlNode refChild) - { - XmlNode node = base.InsertAfter(newChild, refChild); - _fSpecified = true; - return node; - } - - public override XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild) - { - XmlNode node = base.ReplaceChild(newChild, oldChild); - _fSpecified = true; - return node; - } - - public override XmlNode RemoveChild(XmlNode oldChild) - { - XmlNode node = base.RemoveChild(oldChild); - _fSpecified = true; - return node; - } - - public override XmlNode AppendChild(XmlNode newChild) - { - XmlNode node = base.AppendChild(newChild); - _fSpecified = true; - return node; - } - - public override void WriteTo(XmlWriter w) - { - if (_fSpecified) - base.WriteTo(w); - } - - internal void SetSpecified(bool f) - { - _fSpecified = f; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlWhitespace.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlWhitespace.cs deleted file mode 100644 index c67faf14485..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Dom/XmlWhitespace.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using Microsoft.Xml.XPath; - using System.Text; - using System.Diagnostics; - - // Represents the text content of an element or attribute. - public class XmlWhitespace : XmlCharacterData - { - protected internal XmlWhitespace(string strData, XmlDocument doc) : base(strData, doc) - { - if (!doc.IsLoading && !base.CheckOnData(strData)) - throw new ArgumentException(ResXml.Xdom_WS_Char); - } - - // Gets the name of the node. - public override String Name - { - get - { - return OwnerDocument.strNonSignificantWhitespaceName; - } - } - - // Gets the name of the current node without the namespace prefix. - public override String LocalName - { - get - { - return OwnerDocument.strNonSignificantWhitespaceName; - } - } - - // Gets the type of the current node. - public override XmlNodeType NodeType - { - get - { - return XmlNodeType.Whitespace; - } - } - - public override XmlNode ParentNode - { - get - { - switch (parentNode.NodeType) - { - case XmlNodeType.Document: - return base.ParentNode; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - XmlNode parent = parentNode.parentNode; - while (parent.IsText) - { - parent = parent.parentNode; - } - return parent; - default: - return parentNode; - } - } - } - - public override String Value - { - get - { - return Data; - } - - set - { - if (CheckOnData(value)) - Data = value; - else - throw new ArgumentException(ResXml.Xdom_WS_Char); - } - } - - // Creates a duplicate of this node. - public override XmlNode CloneNode(bool deep) - { - Debug.Assert(OwnerDocument != null); - return OwnerDocument.CreateWhitespace(Data); - } - - // Saves the node to the specified XmlWriter. - public override void WriteTo(XmlWriter w) - { - w.WriteWhitespace(Data); - } - - // Saves all the children of the node to the specified XmlWriter. - public override void WriteContentTo(XmlWriter w) - { - // Intentionally do nothing - } - - internal override XPathNodeType XPNodeType - { - get - { - XPathNodeType xnt = XPathNodeType.Whitespace; - DecideXPNodeTypeForTextNodes(this, ref xnt); - return xnt; - } - } - - internal override bool IsText - { - get - { - return true; - } - } - - public override XmlNode PreviousText - { - get - { - if (parentNode.IsText) - { - return parentNode; - } - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/EmptyEnumerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/EmptyEnumerator.cs index 385d98e87cc..3cdfbbe7911 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/EmptyEnumerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/EmptyEnumerator.cs @@ -5,7 +5,7 @@ using System; using System.Collections; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/HWStack.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/HWStack.cs index 84c69194afa..54b10278642 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/HWStack.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/HWStack.cs @@ -5,7 +5,7 @@ using System; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IApplicationResourceStreamResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IApplicationResourceStreamResolver.cs index b42019b451a..ddbcf8b4513 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IApplicationResourceStreamResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IApplicationResourceStreamResolver.cs @@ -6,7 +6,7 @@ using System.IO; using System.ComponentModel; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IHasXmlNode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IHasXmlNode.cs index d33e11f9513..edd41194c07 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IHasXmlNode.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IHasXmlNode.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IXmlNamespaceResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IXmlNamespaceResolver.cs deleted file mode 100644 index 211ed9516d4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IXmlNamespaceResolver.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Microsoft.Xml -{ - using System; - - - // Provides read-only access to a set of (prefix, namespace) mappings. Each distinct prefix is mapped to exactly - // one namespace, but multiple prefixes may be mapped to the same namespace (e.g. xmlns:foo="ns" xmlns:bar="ns"). - public interface IXmlNamespaceResolver - { - // This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey. -#pragma warning disable 3002 - // Returns a collection of defined prefix-namespace mappings. - IDictionary GetNamespacesInScope(XmlNamespaceScope scope); -#pragma warning restore 3002 - - // Return the namespace to which the specified prefix is mapped. Returns null if the prefix isn't mapped to - // a namespace. - // The "xml" prefix is always mapped to the "http://www.w3.org/XML/1998/namespace" namespace. - // The "xmlns" prefix is always mapped to the "http://www.w3.org/2000/xmlns/" namespace. - // If the default namespace has not been defined, then the "" prefix is mapped to "" (the empty namespace). - string LookupNamespace(string prefix); - - // Return a prefix which is mapped to the specified namespace. Multiple prefixes can be mapped to the - // same namespace, and it is undefined which prefix will be returned. Returns null if no prefixes are - // mapped to the namespace. - // The "xml" prefix is always mapped to the "http://www.w3.org/XML/1998/namespace" namespace. - // The "xmlns" prefix is always mapped to the "http://www.w3.org/2000/xmlns/" namespace. - // If the default namespace has not been defined, then the "" prefix is mapped to "" (the empty namespace). - string LookupPrefix(string namespaceName); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IxmlLineInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IxmlLineInfo.cs index 2439519085c..1c381eafe95 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IxmlLineInfo.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/IxmlLineInfo.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/LineInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/LineInfo.cs index 8ca3a6d0878..58de6c2ab12 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/LineInfo.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/LineInfo.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/MtNameTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/MtNameTable.cs index 17671e88a61..4b334202ea9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/MtNameTable.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/MtNameTable.cs @@ -8,7 +8,7 @@ using System.Collections; using System.Threading; -namespace Microsoft.Xml { +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/NameTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/NameTable.cs index 3182eed2b01..dbdcae99e57 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/NameTable.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/NameTable.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Ref.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Ref.cs index 61429484615..575fe0f867c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Ref.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Ref.cs @@ -4,7 +4,7 @@ using System.Diagnostics; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlKnownDtds.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlKnownDtds.cs deleted file mode 100644 index aaff8d206f3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlKnownDtds.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Resolvers -{ - using System; - - // - // XmlPreloadedResolver is an XmlResolver that which can be pre-loaded with data. - // By default it contains well-known DTDs for XHTML 1.0 and RSS 0.91. - // Custom mappings of URIs to data can be added with the Add method. - // - [Flags] - public enum XmlKnownDtds - { - None = 0x00, - Xhtml10 = 0x01, - Rss091 = 0x02, - All = 0xFFFF, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolver.cs deleted file mode 100644 index 4051e38cb78..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolver.cs +++ /dev/null @@ -1,384 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Net; -using System.Text; -//using Microsoft.Xml.Utils; -using System.Reflection; -using System.Diagnostics; -using System.Collections.Generic; -using System.Runtime.Versioning; - -namespace Microsoft.Xml.Resolvers -{ - // - // XmlPreloadedResolver is an XmlResolver that which can be pre-loaded with data. - // By default it contains well-known DTDs for XHTML 1.0 and RSS 0.91. - // Custom mappings of URIs to data can be added with the Add method. - // - public partial class XmlPreloadedResolver : XmlResolver - { - // - // PreloadedData class - // - private abstract class PreloadedData - { - // Returns preloaded data as Stream; Stream must always be supported - internal abstract Stream AsStream(); - - // Returns preloaded data as TextReader, or throws when not supported - internal virtual TextReader AsTextReader() - { - throw new XmlException(ResXml.Xml_UnsupportedClass); - } - - // Returns true for types that are supported for this preloaded data; Stream must always be supported - internal virtual bool SupportsType(Type type) - { - if (type == null || type == typeof(Stream)) - { - return true; - } - return false; - } - }; - - // - // XmlKnownDtdData class - // - private class XmlKnownDtdData : PreloadedData - { - internal string publicId; - internal string systemId; - private string _resourceName; - - internal XmlKnownDtdData(string publicId, string systemId, string resourceName) - { - this.publicId = publicId; - this.systemId = systemId; - _resourceName = resourceName; - } - - internal override Stream AsStream() - { - throw new NotImplementedException(); - } - } - - private class ByteArrayChunk : PreloadedData - { - private byte[] _array; - private int _offset; - private int _length; - - internal ByteArrayChunk(byte[] array) - : this(array, 0, array.Length) - { - } - - internal ByteArrayChunk(byte[] array, int offset, int length) - { - _array = array; - _offset = offset; - _length = length; - } - - internal override Stream AsStream() - { - return new MemoryStream(_array, _offset, _length); - } - } - - private class StringData : PreloadedData - { - private string _str; - - internal StringData(string str) - { - _str = str; - } - - internal override Stream AsStream() - { - return new MemoryStream(Encoding.Unicode.GetBytes(_str)); - } - - internal override TextReader AsTextReader() - { - return new StringReader(_str); - } - - internal override bool SupportsType(Type type) - { - if (type == typeof(TextReader)) - { - return true; - } - return base.SupportsType(type); - } - } - - // - // Fields - // - private XmlResolver _fallbackResolver; - private Dictionary _mappings; - private XmlKnownDtds _preloadedDtds; - - // - // Static/constant fiels - // - private static XmlKnownDtdData[] s_xhtml10_Dtd = new XmlKnownDtdData[] { - new XmlKnownDtdData( "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", "xhtml1-strict.dtd" ), - new XmlKnownDtdData( "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", "xhtml1-transitional.dtd" ), - new XmlKnownDtdData( "-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd", "xhtml1-frameset.dtd" ), - new XmlKnownDtdData( "-//W3C//ENTITIES Latin 1 for XHTML//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent", "xhtml-lat1.ent" ), - new XmlKnownDtdData( "-//W3C//ENTITIES Symbols for XHTML//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent", "xhtml-symbol.ent" ), - new XmlKnownDtdData( "-//W3C//ENTITIES Special for XHTML//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent", "xhtml-special.ent" ), - }; - - private static XmlKnownDtdData[] s_rss091_Dtd = new XmlKnownDtdData[] { - new XmlKnownDtdData( "-//Netscape Communications//DTD RSS 0.91//EN", "http://my.netscape.com/publish/formats/rss-0.91.dtd", "rss-0.91.dtd" ), - }; - - // - // Constructors - // - public XmlPreloadedResolver() - : this(null) - { - } - - public XmlPreloadedResolver(XmlKnownDtds preloadedDtds) - : this(null, preloadedDtds, null) - { - } - - public XmlPreloadedResolver(XmlResolver fallbackResolver) - : this(fallbackResolver, XmlKnownDtds.All, null) - { - } - - public XmlPreloadedResolver(XmlResolver fallbackResolver, XmlKnownDtds preloadedDtds) - : this(fallbackResolver, preloadedDtds, null) - { - } - - public XmlPreloadedResolver(XmlResolver fallbackResolver, XmlKnownDtds preloadedDtds, IEqualityComparer uriComparer) - { - _fallbackResolver = fallbackResolver; - _mappings = new Dictionary(16, uriComparer); - _preloadedDtds = preloadedDtds; - - // load known DTDs - if (preloadedDtds != 0) - { - if ((preloadedDtds & XmlKnownDtds.Xhtml10) != 0) - { - AddKnownDtd(s_xhtml10_Dtd); - } - if ((preloadedDtds & XmlKnownDtds.Rss091) != 0) - { - AddKnownDtd(s_rss091_Dtd); - } - } - } - - public override Uri ResolveUri(Uri baseUri, string relativeUri) - { - // 1) special-case well-known public IDs - // 2) To make FxCop happy we need to use StartsWith() overload that takes StringComparison -> - // .StartsWith(string) is equal to .StartsWith(string, StringComparison.CurrentCulture); - if (relativeUri != null && relativeUri.StartsWith("-//", StringComparison.CurrentCulture)) - { - // 1) XHTML 1.0 public IDs - // 2) To make FxCop happy we need to use StartsWith() overload that takes StringComparison -> - // .StartsWith(string) is equal to .StartsWith(string, StringComparison.CurrentCulture); - if ((_preloadedDtds & XmlKnownDtds.Xhtml10) != 0 && relativeUri.StartsWith("-//W3C//", StringComparison.CurrentCulture)) - { - for (int i = 0; i < s_xhtml10_Dtd.Length; i++) - { - if (relativeUri == s_xhtml10_Dtd[i].publicId) - { - return new Uri(relativeUri, UriKind.Relative); - } - } - } - // RSS 0.91 public IDs - if ((_preloadedDtds & XmlKnownDtds.Rss091) != 0) - { - Debug.Assert(s_rss091_Dtd.Length == 1); - if (relativeUri == s_rss091_Dtd[0].publicId) - { - return new Uri(relativeUri, UriKind.Relative); - } - } - } - return base.ResolveUri(baseUri, relativeUri); - } - - public override Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) - { - if (absoluteUri == null) - { - throw new ArgumentNullException("absoluteUri"); - } - - PreloadedData data; - if (!_mappings.TryGetValue(absoluteUri, out data)) - { - if (_fallbackResolver != null) - { - return _fallbackResolver.GetEntity(absoluteUri, role, ofObjectToReturn); - } - throw new XmlException(string.Format(ResXml.Xml_CannotResolveUrl, absoluteUri.ToString())); - } - - if (ofObjectToReturn == null || ofObjectToReturn == typeof(Stream) || ofObjectToReturn == typeof(Object)) - { - return data.AsStream(); - } - else if (ofObjectToReturn == typeof(TextReader)) - { - return data.AsTextReader(); - } - else - { - throw new XmlException(ResXml.Xml_UnsupportedClass); - } - } - - public override ICredentials Credentials - { - set - { - if (_fallbackResolver != null) - { - _fallbackResolver.Credentials = value; - } - } - } - - public override bool SupportsType(Uri absoluteUri, Type type) - { - if (absoluteUri == null) - { - throw new ArgumentNullException("absoluteUri"); - } - - PreloadedData data; - if (!_mappings.TryGetValue(absoluteUri, out data)) - { - if (_fallbackResolver != null) - { - return _fallbackResolver.SupportsType(absoluteUri, type); - } - return base.SupportsType(absoluteUri, type); - } - - return data.SupportsType(type); - } - - public void Add(Uri uri, byte[] value) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - if (value == null) - { - throw new ArgumentNullException("value"); - } - Add(uri, new ByteArrayChunk(value, 0, value.Length)); - } - - public void Add(Uri uri, byte[] value, int offset, int count) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - if (value == null) - { - throw new ArgumentNullException("value"); - } - if (count < 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (offset < 0) - { - throw new ArgumentOutOfRangeException("offset"); - } - if (value.Length - offset < count) - { - throw new ArgumentOutOfRangeException("count"); - } - - Add(uri, new ByteArrayChunk(value, offset, count)); - } - - public void Add(Uri uri, string value) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - if (value == null) - { - throw new ArgumentNullException("value"); - } - Add(uri, new StringData(value)); - } - - public IEnumerable PreloadedUris - { - get - { - // read-only collection of keys - return _mappings.Keys; - } - } - - public void Remove(Uri uri) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - _mappings.Remove(uri); - } - - // - // Private implementation methods - // - private void Add(Uri uri, PreloadedData data) - { - Debug.Assert(uri != null); - - // override if exists - if (_mappings.ContainsKey(uri)) - { - _mappings[uri] = data; - } - else - { - _mappings.Add(uri, data); - } - } - - private void AddKnownDtd(XmlKnownDtdData[] dtdSet) - { - for (int i = 0; i < dtdSet.Length; i++) - { - XmlKnownDtdData dtdInfo = dtdSet[i]; - _mappings.Add(new Uri(dtdInfo.publicId, UriKind.RelativeOrAbsolute), dtdInfo); - _mappings.Add(new Uri(dtdInfo.systemId, UriKind.RelativeOrAbsolute), dtdInfo); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolverAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolverAsync.cs deleted file mode 100644 index 64c06205b4f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlPreloadedResolverAsync.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Threading.Tasks; - -namespace Microsoft.Xml.Resolvers -{ - // - // XmlPreloadedResolver is an XmlResolver that which can be pre-loaded with data. - // By default it contains well-known DTDs for XHTML 1.0 and RSS 0.91. - // Custom mappings of URIs to data can be added with the Add method. - // - public partial class XmlPreloadedResolver : XmlResolver - { - public override Task GetEntityAsync(Uri absoluteUri, - string role, - Type ofObjectToReturn) - { - if (absoluteUri == null) - { - throw new ArgumentNullException("absoluteUri"); - } - - PreloadedData data; - if (!_mappings.TryGetValue(absoluteUri, out data)) - { - if (_fallbackResolver != null) - { - return _fallbackResolver.GetEntityAsync(absoluteUri, role, ofObjectToReturn); - } - throw new XmlException(string.Format(ResXml.Xml_CannotResolveUrl, absoluteUri.ToString())); - } - - if (ofObjectToReturn == null || ofObjectToReturn == typeof(Stream) || ofObjectToReturn == typeof(Object)) - { - return Task.FromResult(data.AsStream()); - } - else if (ofObjectToReturn == typeof(TextReader)) - { - return Task.FromResult(data.AsTextReader()); - } - else - { - throw new XmlException(ResXml.Xml_UnsupportedClass); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlSystemPathResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlSystemPathResolver.cs deleted file mode 100644 index 6c974f4eb08..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Resolvers/XmlSystemPathResolver.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.IO; - - /// - /// Resolves external XML resources named by a Uniform Resource Identifier (URI). - /// - internal class XmlSystemPathResolver : XmlResolver - { - public XmlSystemPathResolver() - { - } - - // Maps a URI to an Object containing the actual resource. - public override Object GetEntity(Uri uri, string role, Type typeOfObjectToReturn) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - - if (typeOfObjectToReturn != null && typeOfObjectToReturn != typeof(Stream) && typeOfObjectToReturn != typeof(Object)) - { - throw new XmlException(ResXml.Xml_UnsupportedClass, string.Empty); - } - - string filePath = uri.OriginalString; - if (uri.IsAbsoluteUri) - { - if (!uri.IsFile) - throw new XmlException(ResXml.Xml_SystemPathResolverCannotOpenUri, uri.ToString()); - - filePath = uri.LocalPath; - } - - try - { - return new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); - } - catch (ArgumentException e) - { - throw new XmlException(ResXml.Xml_SystemPathResolverCannotOpenUri, uri.ToString(), e, null); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Advanced/SchemaImporterExtension.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Advanced/SchemaImporterExtension.cs index 9ee777c9e6d..f6afd00b239 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Advanced/SchemaImporterExtension.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Advanced/SchemaImporterExtension.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization.Advanced +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced { using System; - using Microsoft.Xml.Schema; - using Microsoft.Xml; + using System.Xml.Schema; + using System.Xml; using System.Collections; using System.Collections.Specialized; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Reflection; /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeExporter.cs index abfd932eb8a..44d977a1acb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeExporter.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; @@ -384,10 +385,6 @@ internal void AddPropertyChangedNotifier(CodeTypeDeclaration codeClass) { if (EnableDataBinding && codeClass != null) { - if (codeClass.BaseTypes.Count == 0) - { - codeClass.BaseTypes.Add(typeof(object)); - } codeClass.BaseTypes.Add(new CodeTypeReference(typeof(System.ComponentModel.INotifyPropertyChanged))); codeClass.Members.Add(PropertyChangedEvent); codeClass.Members.Add(RaisePropertyChangedEventMethod); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerationOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerationOptions.cs index 1a981bddb9d..a5793ce24df 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerationOptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerationOptions.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; using System.ComponentModel; /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerator.cs index 70e77fb98df..5b0ae048397 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeGenerator.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; using System.Collections.Generic; using System.Globalization; - using Microsoft.Xml; - //using Microsoft.Xml.Serialization.Configuration; + using System.Xml; + //using System.Xml.Serialization.Configuration; using System.Reflection; using System.Reflection.Emit; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifier.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifier.cs index 817c45273fd..a266cbac7ba 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifier.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifier.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Text; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifiers.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifiers.cs index 2ca0a53031f..e81a5de8f19 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifiers.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/CodeIdentifiers.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Compilation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Compilation.cs index 29e5b46d085..486d7e24b75 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Compilation.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Compilation.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Reflection.Emit; @@ -10,7 +10,7 @@ namespace Microsoft.Xml.Serialization using System.IO; using System; using System.Text; - using Microsoft.Xml; + using System.Xml; using System.Threading; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlSerializable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlSerializable.cs index 4f884193060..37e2e8a0afc 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlSerializable.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlSerializable.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlTextParser.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlTextParser.cs index af9addb7476..dd1be0edaa8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlTextParser.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IXmlTextParser.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/ImportContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/ImportContext.cs index 7413964617c..a0baa8892ef 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/ImportContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/ImportContext.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.IO; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using System.Collections; using System.Collections.Specialized; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IndentedWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IndentedWriter.cs index 2cc3bd368f6..e60a8a8e8c7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IndentedWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/IndentedWriter.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Mappings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Mappings.cs index 3c97e2a2e5a..7ee5d95aaf7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Mappings.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Mappings.cs @@ -2,15 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.Text; using System.ComponentModel; - using Microsoft.Xml; + using System.Xml; using Microsoft.CodeDom.Compiler; // These classes represent a mapping between classes and a particular XML format. @@ -1404,7 +1404,7 @@ private void RetrieveSerializableSchema() { throw new InvalidOperationException(string.Format(ResXml.XmlGetSchemaTypeMissing, _getSchemaMethod.DeclaringType.FullName, _getSchemaMethod.Name, _xsiType.Name, _xsiType.Namespace)); } - _xsdType = _xsdType.Redefined != null ? _xsdType.Redefined : _xsdType; + //_xsdType = _xsdType.Redefined != null ? _xsdType.Redefined : _xsdType; } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Models.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Models.cs index 7a80a5e533b..4c607e34d51 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Models.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Models.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NameTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NameTable.cs index e7d45eb40da..3720386847e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NameTable.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NameTable.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NamespaceList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NamespaceList.cs new file mode 100644 index 00000000000..1c7c188461e --- /dev/null +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/NamespaceList.cs @@ -0,0 +1,56 @@ +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer +{ + using System; + using System.Collections; + + internal class NamespaceList + { + internal enum ListType + { + Any, + Other, + Set + } + + private ListType _type; + private Hashtable _set; + + public NamespaceList(string namespaces, string targetNamespace) + { + bool targetNamespaceFound = targetNamespace != null && targetNamespace.Length > 0; + + if (namespaces == "##any" || namespaces == null || namespaces.Length == 0) { + _type = ListType.Any; + } + else if (namespaces == "##other") { + _type = ListType.Other; + } + else { + _type = ListType.Set; + _set = new Hashtable(); + string[] parts = namespaces.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); // split on whitespace + foreach(string s in parts) { + if (s == "##local") { + _set[""] = ""; + } + else if (s == "##targetNamespace") { + if (targetNamespaceFound) _set[targetNamespace] = targetNamespace; + } + else { + _set[s] = s; + } + } + } + } + + public ListType Type + { + get { return _type; } + } + + public ICollection Enumerate + { + get { return _set.Keys; } + } + } +} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/PrimitiveXmlSerializers.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/PrimitiveXmlSerializers.cs index a3d35acfebf..d3df42aec32 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/PrimitiveXmlSerializers.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/PrimitiveXmlSerializers.cs @@ -2,11 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; - internal class XmlSerializationPrimitiveWriter : Microsoft.Xml.Serialization.XmlSerializationWriter + using System.Xml; + internal class XmlSerializationPrimitiveWriter : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationWriter { internal void Write_string(object o) { @@ -28,7 +28,7 @@ internal void Write_int(object o) WriteEmptyTag(@"int", @""); return; } - WriteElementStringRaw(@"int", @"", Microsoft.Xml.XmlConvert.ToString((System.Int32)((System.Int32)o))); + WriteElementStringRaw(@"int", @"", System.Xml.XmlConvert.ToString((System.Int32)((System.Int32)o))); } internal void Write_boolean(object o) @@ -39,7 +39,7 @@ internal void Write_boolean(object o) WriteEmptyTag(@"boolean", @""); return; } - WriteElementStringRaw(@"boolean", @"", Microsoft.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o))); + WriteElementStringRaw(@"boolean", @"", System.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o))); } internal void Write_short(object o) @@ -50,7 +50,7 @@ internal void Write_short(object o) WriteEmptyTag(@"short", @""); return; } - WriteElementStringRaw(@"short", @"", Microsoft.Xml.XmlConvert.ToString((System.Int16)((System.Int16)o))); + WriteElementStringRaw(@"short", @"", System.Xml.XmlConvert.ToString((System.Int16)((System.Int16)o))); } internal void Write_long(object o) @@ -61,7 +61,7 @@ internal void Write_long(object o) WriteEmptyTag(@"long", @""); return; } - WriteElementStringRaw(@"long", @"", Microsoft.Xml.XmlConvert.ToString((System.Int64)((System.Int64)o))); + WriteElementStringRaw(@"long", @"", System.Xml.XmlConvert.ToString((System.Int64)((System.Int64)o))); } internal void Write_float(object o) @@ -72,7 +72,7 @@ internal void Write_float(object o) WriteEmptyTag(@"float", @""); return; } - WriteElementStringRaw(@"float", @"", Microsoft.Xml.XmlConvert.ToString((System.Single)((System.Single)o))); + WriteElementStringRaw(@"float", @"", System.Xml.XmlConvert.ToString((System.Single)((System.Single)o))); } internal void Write_double(object o) @@ -83,7 +83,7 @@ internal void Write_double(object o) WriteEmptyTag(@"double", @""); return; } - WriteElementStringRaw(@"double", @"", Microsoft.Xml.XmlConvert.ToString((System.Double)((System.Double)o))); + WriteElementStringRaw(@"double", @"", System.Xml.XmlConvert.ToString((System.Double)((System.Double)o))); } internal void Write_decimal(object o) @@ -94,7 +94,7 @@ internal void Write_decimal(object o) WriteEmptyTag(@"decimal", @""); return; } - WriteElementStringRaw(@"decimal", @"", Microsoft.Xml.XmlConvert.ToString((System.Decimal)((System.Decimal)o))); + WriteElementStringRaw(@"decimal", @"", System.Xml.XmlConvert.ToString((System.Decimal)((System.Decimal)o))); } internal void Write_dateTime(object o) @@ -116,7 +116,7 @@ internal void Write_unsignedByte(object o) WriteEmptyTag(@"unsignedByte", @""); return; } - WriteElementStringRaw(@"unsignedByte", @"", Microsoft.Xml.XmlConvert.ToString((System.Byte)((System.Byte)o))); + WriteElementStringRaw(@"unsignedByte", @"", System.Xml.XmlConvert.ToString((System.Byte)((System.Byte)o))); } internal void Write_byte(object o) @@ -127,7 +127,7 @@ internal void Write_byte(object o) WriteEmptyTag(@"byte", @""); return; } - WriteElementStringRaw(@"byte", @"", Microsoft.Xml.XmlConvert.ToString((System.SByte)((System.SByte)o))); + WriteElementStringRaw(@"byte", @"", System.Xml.XmlConvert.ToString((System.SByte)((System.SByte)o))); } internal void Write_unsignedShort(object o) @@ -138,7 +138,7 @@ internal void Write_unsignedShort(object o) WriteEmptyTag(@"unsignedShort", @""); return; } - WriteElementStringRaw(@"unsignedShort", @"", Microsoft.Xml.XmlConvert.ToString((System.UInt16)((System.UInt16)o))); + WriteElementStringRaw(@"unsignedShort", @"", System.Xml.XmlConvert.ToString((System.UInt16)((System.UInt16)o))); } internal void Write_unsignedInt(object o) @@ -149,7 +149,7 @@ internal void Write_unsignedInt(object o) WriteEmptyTag(@"unsignedInt", @""); return; } - WriteElementStringRaw(@"unsignedInt", @"", Microsoft.Xml.XmlConvert.ToString((System.UInt32)((System.UInt32)o))); + WriteElementStringRaw(@"unsignedInt", @"", System.Xml.XmlConvert.ToString((System.UInt32)((System.UInt32)o))); } internal void Write_unsignedLong(object o) @@ -160,7 +160,7 @@ internal void Write_unsignedLong(object o) WriteEmptyTag(@"unsignedLong", @""); return; } - WriteElementStringRaw(@"unsignedLong", @"", Microsoft.Xml.XmlConvert.ToString((System.UInt64)((System.UInt64)o))); + WriteElementStringRaw(@"unsignedLong", @"", System.Xml.XmlConvert.ToString((System.UInt64)((System.UInt64)o))); } internal void Write_base64Binary(object o) @@ -183,7 +183,7 @@ internal void Write_guid(object o) WriteEmptyTag(@"guid", @""); return; } - WriteElementStringRaw(@"guid", @"", Microsoft.Xml.XmlConvert.ToString((System.Guid)((System.Guid)o))); + WriteElementStringRaw(@"guid", @"", System.Xml.XmlConvert.ToString((System.Guid)((System.Guid)o))); } internal void Write_char(object o) @@ -206,7 +206,7 @@ internal void Write_QName(object o) return; } TopLevelElement(); - WriteNullableQualifiedNameLiteral(@"QName", @"", ((global::Microsoft.Xml.XmlQualifiedName)o)); + WriteNullableQualifiedNameLiteral(@"QName", @"", ((global::System.Xml.XmlQualifiedName)o)); } protected override void InitCallbacks() @@ -214,13 +214,13 @@ protected override void InitCallbacks() } } - internal class XmlSerializationPrimitiveReader : Microsoft.Xml.Serialization.XmlSerializationReader + internal class XmlSerializationPrimitiveReader : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationReader { internal object Read_string() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id1_string && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -249,12 +249,12 @@ internal object Read_int() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id3_int && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToInt32(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToInt32(Reader.ReadElementString()); } } else @@ -273,12 +273,12 @@ internal object Read_boolean() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id4_boolean && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToBoolean(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString()); } } else @@ -297,12 +297,12 @@ internal object Read_short() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id5_short && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToInt16(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToInt16(Reader.ReadElementString()); } } else @@ -321,12 +321,12 @@ internal object Read_long() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id6_long && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToInt64(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToInt64(Reader.ReadElementString()); } } else @@ -345,12 +345,12 @@ internal object Read_float() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id7_float && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToSingle(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToSingle(Reader.ReadElementString()); } } else @@ -369,12 +369,12 @@ internal object Read_double() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id8_double && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToDouble(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToDouble(Reader.ReadElementString()); } } else @@ -393,12 +393,12 @@ internal object Read_decimal() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id9_decimal && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToDecimal(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToDecimal(Reader.ReadElementString()); } } else @@ -417,7 +417,7 @@ internal object Read_dateTime() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id10_dateTime && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -441,12 +441,12 @@ internal object Read_unsignedByte() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id11_unsignedByte && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToByte(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToByte(Reader.ReadElementString()); } } else @@ -465,12 +465,12 @@ internal object Read_byte() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id12_byte && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToSByte(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToSByte(Reader.ReadElementString()); } } else @@ -489,12 +489,12 @@ internal object Read_unsignedShort() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id13_unsignedShort && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToUInt16(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToUInt16(Reader.ReadElementString()); } } else @@ -513,12 +513,12 @@ internal object Read_unsignedInt() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id14_unsignedInt && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToUInt32(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToUInt32(Reader.ReadElementString()); } } else @@ -537,12 +537,12 @@ internal object Read_unsignedLong() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id15_unsignedLong && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToUInt64(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToUInt64(Reader.ReadElementString()); } } else @@ -561,7 +561,7 @@ internal object Read_base64Binary() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id16_base64Binary && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -590,12 +590,12 @@ internal object Read_guid() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id17_guid && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o = Microsoft.Xml.XmlConvert.ToGuid(Reader.ReadElementString()); + o = System.Xml.XmlConvert.ToGuid(Reader.ReadElementString()); } } else @@ -614,7 +614,7 @@ internal object Read_char() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id18_char && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -638,7 +638,7 @@ internal object Read_QName() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id1_QName && (object)Reader.NamespaceURI == (object)_id2_Item)) { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaHelper.cs new file mode 100644 index 00000000000..dae2eb61b61 --- /dev/null +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaHelper.cs @@ -0,0 +1,27 @@ +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer +{ + using System.Runtime.CompilerServices; + using System.Xml.Schema; + + internal static class SchemaHelper + { + private static ConditionalWeakTable _preprocessed = new ConditionalWeakTable(); + + public static bool IsPreprocessed(XmlSchema schema) + { + return _preprocessed.TryGetValue(schema, out _); + } + + public static void SetPreprocessed(XmlSchema schema, bool value) + { + if (value) + { + _preprocessed.GetValue(schema, k => null); + } + else + { + _preprocessed.Remove(schema); + } + } + } +} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaImporter.cs index e19476e9c0a..8a9e06c424a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaImporter.cs @@ -2,17 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using System.Collections; using System.ComponentModel; using System.Reflection; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; - using Microsoft.Xml.Serialization.Advanced; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced; #if DEBUG using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaObjectWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaObjectWriter.cs index 83abaf45b6e..5eb21acbb9b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaObjectWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SchemaObjectWriter.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Text; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections; using System.Collections.Specialized; @@ -92,7 +93,7 @@ internal static XmlQualifiedName NameOf(XmlSchemaObject o) } else if (o is XmlSchemaNotation) { - return ((XmlSchemaNotation)o).QualifiedName; + return new XmlQualifiedName(((XmlSchemaNotation)o).Name, Namespace(o)); } else if (o is XmlSchemaSequence) { @@ -117,7 +118,7 @@ internal static XmlQualifiedName NameOf(XmlSchemaObject o) } else if (o is XmlSchemaAny) { - return new XmlQualifiedName("*", SchemaObjectWriter.ToString(((XmlSchemaAny)o).NamespaceList)); + return new XmlQualifiedName("*", ((XmlSchemaAny)o).Namespace); } else if (o is XmlSchemaIdentityConstraint) { @@ -495,7 +496,7 @@ private void Write5_XmlSchemaAnnotation(XmlSchemaAnnotation o) WriteAttribute(@"id", @"", ((System.String)o.@Id)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < a.Count; ia++) @@ -776,7 +777,7 @@ private void Write33_XmlSchemaAnyAttribute(XmlSchemaAnyAttribute o) WriteStartElement("anyAttribute"); WriteAttribute(@"id", @"", ((System.String)o.@Id)); - WriteAttribute("namespace", "", ToString(o.NamespaceList)); + WriteAttribute("namespace", "", o.Namespace); XmlSchemaContentProcessing process = o.@ProcessContents == XmlSchemaContentProcessing.@None ? XmlSchemaContentProcessing.Strict : o.@ProcessContents; WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); @@ -1154,7 +1155,7 @@ private void Write53_XmlSchemaAny(XmlSchemaAny o) WriteAttribute(@"id", @"", o.@Id); WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs)); WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs)); - WriteAttribute(@"namespace", @"", ToString(o.NamespaceList)); + WriteAttribute(@"namespace", @"", o.Namespace); XmlSchemaContentProcessing process = o.@ProcessContents == XmlSchemaContentProcessing.@None ? XmlSchemaContentProcessing.Strict : o.@ProcessContents; WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeAttribute.cs index 565887de038..bc5f5bbcee8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeOverrides.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeOverrides.cs index 758c01ab280..d70ebeeb858 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeOverrides.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributeOverrides.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.ComponentModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributes.cs index 474b1746434..b8078842836 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapAttributes.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapCodeExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapCodeExporter.cs index a9b643553ec..141bf8c9a3d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapCodeExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapCodeExporter.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; using System.IO; using System.ComponentModel; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; using System.Reflection; using System.Diagnostics; + using SysXmlSerialization = System.Xml.Serialization; // using System.Security.Permissions; /// @@ -93,7 +95,7 @@ private void ExportType(TypeMapping mapping) ExportedMappings.Add(mapping, mapping); if (mapping is EnumMapping) { - codeClass = ExportEnum((EnumMapping)mapping, typeof(SoapEnumAttribute)); + codeClass = ExportEnum((EnumMapping)mapping, typeof(SysXmlSerialization.SoapEnumAttribute)); } else if (mapping is StructMapping) { @@ -113,7 +115,7 @@ private void ExportType(TypeMapping mapping) // Add [DebuggerStepThrough] codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DebuggerStepThroughAttribute).FullName)); } - AddTypeMetadata(codeClass.CustomAttributes, typeof(SoapTypeAttribute), mapping.TypeDesc.Name, Accessor.UnescapeName(mapping.TypeName), mapping.Namespace, mapping.IncludeInSchema); + AddTypeMetadata(codeClass.CustomAttributes, typeof(SysXmlSerialization.SoapTypeAttribute), mapping.TypeDesc.Name, Accessor.UnescapeName(mapping.TypeName), mapping.Namespace, mapping.IncludeInSchema); ExportedClasses.Add(mapping, codeClass); } } @@ -123,7 +125,7 @@ private CodeTypeDeclaration ExportStruct(StructMapping mapping) { if (mapping.TypeDesc.IsRoot) { - ExportRoot(mapping, typeof(SoapIncludeAttribute)); + ExportRoot(mapping, typeof(SysXmlSerialization.SoapIncludeAttribute)); return null; } if (!mapping.IncludeInSchema) @@ -138,8 +140,10 @@ private CodeTypeDeclaration ExportStruct(StructMapping mapping) CodeNamespace.Types.Add(codeClass); - if (baseName != null && baseName.Length > 0) + if (baseName != null && baseName.Length > 0 && baseName != "Object") { + // [Fix: Redundant Inheritance] + // Explicitly skip 'Object' to avoid generating "public class MyType : Object". codeClass.BaseTypes.Add(baseName); } else @@ -149,7 +153,7 @@ private CodeTypeDeclaration ExportStruct(StructMapping mapping) if (mapping.TypeDesc.IsAbstract) codeClass.TypeAttributes |= TypeAttributes.Abstract; - CodeExporter.AddIncludeMetadata(codeClass.CustomAttributes, mapping, typeof(SoapIncludeAttribute)); + CodeExporter.AddIncludeMetadata(codeClass.CustomAttributes, mapping, typeof(SysXmlSerialization.SoapIncludeAttribute)); if (GenerateProperties) { @@ -205,7 +209,7 @@ public void AddMappingMetadata(CodeAttributeDeclarationCollection metadata, XmlM private void AddElementMetadata(CodeAttributeDeclarationCollection metadata, string elementName, TypeDesc typeDesc, bool isNullable) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SoapElementAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.SoapElementAttribute).FullName); if (elementName != null) { attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(elementName))); @@ -249,7 +253,7 @@ private void ExportMember(CodeTypeDeclaration codeClass, MemberMapping member) field = new CodeMemberField(typeof(bool).FullName, member.Name + "Specified"); field.Attributes = (field.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public; field.Comments.Add(new CodeCommentStatement(ResXml.XmlRemarks, true)); - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SoapIgnoreAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.SoapIgnoreAttribute).FullName); field.CustomAttributes.Add(attribute); codeClass.Members.Add(field); } @@ -277,7 +281,7 @@ private void ExportProperty(CodeTypeDeclaration codeClass, MemberMapping member, prop = CreatePropertyDeclaration(field, member.Name + "Specified", typeof(bool).FullName); prop.Comments.Add(new CodeCommentStatement(ResXml.XmlRemarks, true)); - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SoapIgnoreAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.SoapIgnoreAttribute).FullName); prop.CustomAttributes.Add(attribute); codeClass.Members.Add(prop); } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapElementAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapElementAttribute.cs index aeffbf154ce..70b1b40a3dd 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapElementAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapElementAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapEnumAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapEnumAttribute.cs index c0a0eebe9ea..9d3a35252f5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapEnumAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapEnumAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIgnoreAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIgnoreAttribute.cs index cb623acf911..c5e73000df7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIgnoreAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIgnoreAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIncludeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIncludeAttribute.cs index 1c932b72387..89b02693c7b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIncludeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapIncludeAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapReflectionImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapReflectionImporter.cs index 97c5b5f8d43..bac8d051d59 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapReflectionImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapReflectionImporter.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.Collections; using System.Collections.Generic; @@ -683,7 +684,7 @@ private MemberMapping ImportMemberMapping(XmlReflectionMember xmlReflectionMembe FieldModel model = new FieldModel(xmlReflectionMember.MemberName, xmlReflectionMember.MemberType, _typeScope.GetTypeDesc(xmlReflectionMember.MemberType), checkSpecified, false); member.CheckShouldPersist = model.CheckShouldPersist; member.CheckSpecified = model.CheckSpecified; - member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.HasDefaultConstructor; + member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.DefaultValue != nullConstructor; ImportAccessorMapping(member, model, a, ns, form, limiter); if (xmlReflectionMember.OverrideIsNullable) member.Elements[0].IsNullable = false; @@ -701,7 +702,7 @@ private MemberMapping ImportFieldMapping(FieldModel model, SoapAttributes a, str member.MemberInfo = model.MemberInfo; member.CheckSpecifiedMemberInfo = model.CheckSpecifiedMemberInfo; member.CheckShouldPersistMethodInfo = model.CheckShouldPersistMethodInfo; - member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.HasDefaultConstructor; + member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.DefaultValue != nullConstructor; ImportAccessorMapping(member, model, a, ns, XmlSchemaForm.Unqualified, limiter); return member; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaExporter.cs index fd94270cb74..8fb9e25c0f3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaExporter.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.ComponentModel; using System.Diagnostics; @@ -252,7 +253,7 @@ private XmlQualifiedName ExportArrayMapping(ArrayMapping mapping, string ns) // XmlSchemaAttribute attr = new XmlSchemaAttribute(); attr.RefName = s_arrayTypeQName; - XmlAttribute attribute = new XmlAttribute("wsdl", Wsdl.ArrayType, Wsdl.Namespace, Document); + XmlAttribute attribute = Document.CreateAttribute("wsdl", Wsdl.ArrayType, Wsdl.Namespace); attribute.Value = qname.Namespace + ":" + qname.Name + "[]"; attr.UnhandledAttributes = new XmlAttribute[] { attribute }; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaImporter.cs index f2ad817daa5..1dc6e728d49 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaImporter.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections; using System.ComponentModel; using System.Reflection; @@ -25,6 +26,8 @@ public class SoapSchemaImporter : SchemaImporter /// [To be supplied.] /// public SoapSchemaImporter(XmlSchemas schemas) : base(schemas, CodeGenerationOptions.GenerateProperties, null, new ImportContext()) { } + + private bool _isImportingDerivedTypesForUrType; /// /// @@ -236,7 +239,43 @@ internal override void ImportDerivedTypes(XmlQualifiedName baseName) if (item is XmlSchemaType) { XmlSchemaType type = (XmlSchemaType)item; - if (type.DerivedFrom == baseName) + bool isDerived = type.BaseXmlSchemaType?.QualifiedName == baseName; + + // [Fix: RPC/Encoded Polymorphism Support] + // In many RPC/Encoded WSDLs, types like 'AdditionalData' implicitly inherit from 'xsd:anyType' (Soap.UrType). + // If the tool is asking "Who inherits from anyType?", we must return these implicit derivations, + // effectively treating them as derived types to ensure they are imported and generated. + if (!isDerived && type is XmlSchemaComplexType && baseName.Name == Soap.UrType && baseName.Namespace == XmlSchema.Namespace) + { + if (((XmlSchemaComplexType)type).ContentModel == null && type.BaseXmlSchemaType == null) + isDerived = true; + } + + if (!isDerived && type is XmlSchemaComplexType) + { + // [Fix: Robustness] + // Fallback for missing BaseXmlSchemaType links (common in uncompiled/loosely linked schemas). + // Manually check the ContentModel for Extension or Restriction elements declaring a base type. + XmlSchemaComplexType complexType = (XmlSchemaComplexType)type; + if (complexType.ContentModel?.Content is XmlSchemaComplexContentExtension extension) + { + isDerived = extension.BaseTypeName.Name == baseName.Name && (extension.BaseTypeName.Namespace == baseName.Namespace || string.IsNullOrEmpty(extension.BaseTypeName.Namespace)); + } + else if (complexType.ContentModel?.Content is XmlSchemaComplexContentRestriction restriction) + { + isDerived = restriction.BaseTypeName.Name == baseName.Name && (restriction.BaseTypeName.Namespace == baseName.Namespace || string.IsNullOrEmpty(restriction.BaseTypeName.Namespace)); + } + else if (complexType.ContentModel?.Content is XmlSchemaSimpleContentExtension simpleExtension) + { + isDerived = simpleExtension.BaseTypeName.Name == baseName.Name && (simpleExtension.BaseTypeName.Namespace == baseName.Namespace || string.IsNullOrEmpty(simpleExtension.BaseTypeName.Namespace)); + } + else if (complexType.ContentModel?.Content is XmlSchemaSimpleContentRestriction simpleRestriction) + { + isDerived = simpleRestriction.BaseTypeName.Name == baseName.Name && (simpleRestriction.BaseTypeName.Namespace == baseName.Namespace || string.IsNullOrEmpty(simpleRestriction.BaseTypeName.Namespace)); + } + } + + if (isDerived) { ImportType(type.QualifiedName, false); } @@ -248,7 +287,25 @@ internal override void ImportDerivedTypes(XmlQualifiedName baseName) private TypeMapping ImportType(XmlQualifiedName name, bool excludeFromImport) { if (name.Name == Soap.UrType && name.Namespace == XmlSchema.Namespace) + { + // [Fix: StackOverflow Prevention] + // Prevent infinite recursion when importing derived types of 'anyType'. + // The cycle is: ImportType(anyType) -> ImportDerivedTypes(anyType) -> ImportStructType(Derived) -> ImportType(base=anyType) -> ... + // This guard ensures we only kick off the derived type discovery once for the root object. + if (!_isImportingDerivedTypesForUrType) + { + _isImportingDerivedTypesForUrType = true; + try + { + ImportDerivedTypes(name); + } + finally + { + _isImportingDerivedTypesForUrType = false; + } + } return ImportRootMapping(); + } object type = FindType(name); TypeMapping mapping = (TypeMapping)ImportedMappings[type]; if (mapping == null) @@ -267,7 +324,7 @@ private TypeMapping ImportType(XmlQualifiedName name, bool excludeFromImport) private TypeMapping ImportType(XmlSchemaComplexType type, string typeNs, bool excludeFromImport) { - if (type.Redefined != null) + if (false /*type.Redefined != null*/) { // we do not support redefine in the current version throw new NotSupportedException(string.Format(ResXml.XmlUnsupportedRedefine, type.Name, typeNs)); @@ -304,15 +361,36 @@ private StructMapping ImportStructType(XmlSchemaComplexType type, string typeNs, TypeDesc baseTypeDesc = null; Mapping baseMapping = null; - if (!type.DerivedFrom.IsEmpty) + if (type.BaseXmlSchemaType != null) { - baseMapping = ImportType(type.DerivedFrom, excludeFromImport); + baseMapping = ImportType(type.BaseXmlSchemaType.QualifiedName, excludeFromImport); if (baseMapping is StructMapping) baseTypeDesc = ((StructMapping)baseMapping).TypeDesc; else baseMapping = null; } + else + { + XmlQualifiedName baseName = null; + if (type.ContentModel?.Content is XmlSchemaComplexContentExtension extension) + { + baseName = extension.BaseTypeName; + } + else if (type.ContentModel?.Content is XmlSchemaComplexContentRestriction restriction) + { + baseName = restriction.BaseTypeName; + } + + if (baseName != null && !baseName.IsEmpty) + { + baseMapping = ImportType(baseName, excludeFromImport); + if (baseMapping is StructMapping) + baseTypeDesc = ((StructMapping)baseMapping).TypeDesc; + else + baseMapping = null; + } + } if (baseMapping == null) baseMapping = GetRootMapping(); Mapping previousMapping = (Mapping)ImportedMappings[type]; if (previousMapping != null) @@ -408,7 +486,7 @@ private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers memb else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; - if (group.IsMultipleOccurrence) + if (group.MaxOccurs > 1) throw new InvalidOperationException(string.Format(ResXml.XmlSoapUnsupportedGroupRepeat, parentType.Name, parentType.Namespace)); for (int i = 0; i < group.Items.Count; i++) { @@ -427,7 +505,7 @@ private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers memb private ElementAccessor ImportArray(XmlSchemaElement element, string ns) { if (element.SchemaType == null) return null; - if (!element.IsMultipleOccurrence) return null; + if (element.MaxOccurs <= 1) return null; XmlSchemaType type = element.SchemaType; ArrayMapping arrayMapping = ImportArrayMapping(type, ns); if (arrayMapping == null) return null; @@ -462,7 +540,7 @@ private ArrayMapping ImportArrayMapping(XmlSchemaType type, string ns) arrayMapping.TypeName = "ArrayOf" + CodeIdentifier.MakePascal(itemAccessor.Mapping.TypeName); return arrayMapping; } - if (!(type.DerivedFrom.Name == Soap.Array && type.DerivedFrom.Namespace == Soap.Encoding)) return null; + if (!(type.BaseXmlSchemaType.Name == Soap.Array && type.BaseXmlSchemaType.QualifiedName.Namespace == Soap.Encoding)) return null; // the type should be a XmlSchemaComplexType XmlSchemaContentModel model = ((XmlSchemaComplexType)type).ContentModel; @@ -534,7 +612,7 @@ private ArrayMapping ImportArrayMapping(XmlSchemaType type, string ns) if (group.Items.Count != 1 || !(group.Items[0] is XmlSchemaElement)) return null; XmlSchemaElement itemElement = (XmlSchemaElement)group.Items[0]; - if (!itemElement.IsMultipleOccurrence) return null; + if (itemElement.MaxOccurs <= 1) return null; ElementAccessor itemAccessor = ImportElement(itemElement, ns); arrayMapping.Elements = new ElementAccessor[] { itemAccessor }; arrayMapping.TypeDesc = ((TypeMapping)itemAccessor.Mapping).TypeDesc.CreateArrayTypeDesc(); @@ -565,7 +643,7 @@ private void ImportElementMember(XmlSchemaElement element, CodeIdentifiers membe } member.TypeDesc = ((TypeMapping)accessor.Mapping).TypeDesc; member.Elements = new ElementAccessor[] { accessor }; - if (element.IsMultipleOccurrence) + if (element.MaxOccurs > 1) member.TypeDesc = member.TypeDesc.CreateArrayTypeDesc(); if (element.MinOccurs == 0 && member.TypeDesc.IsValueType && !member.TypeDesc.HasIsEmpty) @@ -620,7 +698,7 @@ private TypeMapping ImportEnumeratedDataType(XmlSchemaSimpleType dataType, strin if (mapping != null) return mapping; - XmlSchemaSimpleType sourceDataType = FindDataType(dataType.DerivedFrom); + XmlSchemaSimpleType sourceDataType = FindDataType(dataType.BaseXmlSchemaType.QualifiedName); TypeDesc sourceTypeDesc = Scope.GetTypeDesc(sourceDataType); if (sourceTypeDesc != null && sourceTypeDesc != Scope.GetTypeDesc(typeof(string))) return ImportPrimitiveDataType(dataType); @@ -698,9 +776,9 @@ private TypeDesc GetDataTypeSource(XmlSchemaSimpleType dataType) TypeDesc typeDesc = Scope.GetTypeDesc(dataType); if (typeDesc != null) return typeDesc; } - if (!dataType.DerivedFrom.IsEmpty) + if (dataType.BaseXmlSchemaType != null) { - return GetDataTypeSource(FindDataType(dataType.DerivedFrom)); + return GetDataTypeSource(FindDataType(dataType.BaseXmlSchemaType.QualifiedName)); } return Scope.GetTypeDesc(typeof(string)); } @@ -731,10 +809,10 @@ private object FindType(XmlQualifiedName name) if (type != null) { XmlSchemaType encType = (XmlSchemaType)type; - XmlQualifiedName baseType = encType.DerivedFrom; - if (!baseType.IsEmpty) + XmlSchemaType baseType = encType.BaseXmlSchemaType; + if (baseType != null) { - return FindType(baseType); + return FindType(baseType.QualifiedName); } return encType; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaMember.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaMember.cs index 1599418d4ce..c7d24ed9148 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaMember.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapSchemaMember.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapTypeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapTypeAttribute.cs index 4dca8874e4e..add401739c5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapTypeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SoapTypeAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SourceInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SourceInfo.cs index fa1ee4af00a..ec78eff5969 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SourceInfo.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/SourceInfo.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; @@ -14,7 +15,7 @@ namespace Microsoft.Xml.Serialization internal class SourceInfo { //a[ia] - //((global::Microsoft.Xml.Serialization.XmlSerializerNamespaces)p[0]) + //((global::System.Xml.Serialization.XmlSerializerNamespaces)p[0]) private static Regex s_regex = new Regex("([(][(](?[^)]+)[)])?(?[^[]+)[[](?.+)[]][)]?"); //((global::Microsoft.CFx.Test.Common.TypeLibrary.IXSType_9)o), @"IXSType_9", @"", true, true); private static Regex s_regex2 = new Regex("[(][(](?[^)]+)[)](?[^)]+)[)]"); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/TypeExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/TypeExtensions.cs index ea8c8cc0562..d005a6ec9eb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/TypeExtensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/TypeExtensions.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; using System.Reflection; internal static class TypeExtensions diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Types.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Types.cs index 97ad5d2797b..313d40b7f25 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Types.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/Types.cs @@ -2,20 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.IO; using System.Reflection; using System.Collections; using System.Collections.Generic; - using Microsoft.Xml.Schema; - using Microsoft.Xml; + using System.Xml.Schema; + using System.Xml; using System.Text; using System.ComponentModel; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; - using Microsoft.Xml.Serialization.Advanced; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced; using System.Globalization; //using System.Security.Cryptography; using System.Diagnostics; @@ -89,6 +89,8 @@ internal class TypeDesc private int _weight; private Exception _exception; + internal object DefaultValue { get; set; } + internal TypeDesc(string name, string fullName, XmlSchemaType dataType, TypeKind kind, TypeDesc baseTypeDesc, TypeFlags flags, string formatterName) { _name = name.Replace('+', '.'); @@ -1422,7 +1424,15 @@ static internal XmlQualifiedName ParseWsdlArrayType(string type, out string dims { if (parent.Namespaces != null) { - string wsdlNs = (string)parent.Namespaces.Namespaces[ns]; + string wsdlNs = null; + foreach (System.Xml.XmlQualifiedName q in parent.Namespaces.ToArray()) + { + if (q.Name == ns) + { + wsdlNs = q.Namespace; + break; + } + } if (wsdlNs != null) { ns = wsdlNs; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyAttributeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyAttributeAttribute.cs index 25034231b2c..faddca14442 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyAttributeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyAttributeAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttribute.cs index 77389bda55e..b653620f229 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttributes.cs index 17e60e48b1c..3bb9aea81b7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAnyElementAttributes.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayAttribute.cs index ba5dab9cd0e..7a0c31e3d4f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttribute.cs index 5ecce53901d..a6a7169263a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttributes.cs index 579181aa09f..85817823a96 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlArrayItemAttributes.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeAttribute.cs index 811efc91c6f..3d018b2aa57 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeOverrides.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeOverrides.cs index 9ad15626c53..a28bd3aef06 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeOverrides.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributeOverrides.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.ComponentModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributes.cs index 8c801d396d4..7d6f3809b0b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlAttributes.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlChoiceIdentifierAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlChoiceIdentifierAttribute.cs index 0b82269e383..2d42f895617 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlChoiceIdentifierAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlChoiceIdentifierAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Reflection; /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCodeExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCodeExporter.cs index 9f341a3573c..24fe0df46af 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCodeExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCodeExporter.cs @@ -2,20 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; using System.IO; using System.ComponentModel; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; using System.Reflection; using System.Globalization; using System.Diagnostics; + using SysXmlSerialization = System.Xml.Serialization; // using System.Security.Permissions; - using Microsoft.Xml.Serialization.Advanced; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced; /// /// @@ -138,7 +140,7 @@ private void ExportType(TypeMapping mapping, string name, string ns, ElementAcce } else if (mapping is EnumMapping) { - codeClass = ExportEnum((EnumMapping)mapping, typeof(XmlEnumAttribute)); + codeClass = ExportEnum((EnumMapping)mapping, typeof(SysXmlSerialization.XmlEnumAttribute)); } else if (mapping is StructMapping) { @@ -161,7 +163,7 @@ private void ExportType(TypeMapping mapping, string name, string ns, ElementAcce codeClass.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DebuggerStepThroughAttribute).FullName)); // Add [DesignerCategory("code")] } - AddTypeMetadata(codeClass.CustomAttributes, typeof(XmlTypeAttribute), mapping.TypeDesc.Name, Accessor.UnescapeName(mapping.TypeName), mapping.Namespace, mapping.IncludeInSchema); + AddTypeMetadata(codeClass.CustomAttributes, typeof(SysXmlSerialization.XmlTypeAttribute), mapping.TypeDesc.Name, Accessor.UnescapeName(mapping.TypeName), mapping.Namespace, mapping.IncludeInSchema); } else if (FindAttributeDeclaration(typeof(GeneratedCodeAttribute), codeClass.CustomAttributes) == null) { @@ -180,7 +182,7 @@ private void ExportType(TypeMapping mapping, string name, string ns, ElementAcce private void AddRootMetadata(CodeAttributeDeclarationCollection metadata, TypeMapping typeMapping, string name, string ns, ElementAccessor rootElement) { - string rootAttrName = typeof(XmlRootAttribute).FullName; + string rootAttrName = typeof(SysXmlSerialization.XmlRootAttribute).FullName; // check that we haven't already added a root attribute since we can only add one foreach (CodeAttributeDeclaration attr in metadata) @@ -407,7 +409,7 @@ private object ImportDefaultValue(TypeMapping mapping, string defaultValue) } else { - if (pm.TypeDesc.HasDefaultSupport) + if (pm.TypeDesc.DefaultValue != null) { return XmlCustomFormatter.ToDefaultValue(defaultValue, pm.TypeDesc.FormatterName); } @@ -418,7 +420,7 @@ private object ImportDefaultValue(TypeMapping mapping, string defaultValue) private void AddDefaultValueAttribute(CodeMemberField field, CodeAttributeDeclarationCollection metadata, object defaultValue, TypeMapping mapping, CodeCommentStatementCollection comments, TypeDesc memberTypeDesc, Accessor accessor, CodeConstructor ctor) { string attributeName = accessor.IsFixed ? "fixed" : "default"; - if (!memberTypeDesc.HasDefaultSupport) + if (memberTypeDesc.DefaultValue == null) { if (comments != null && defaultValue is string) { @@ -481,7 +483,7 @@ private void AddDefaultValueAttribute(CodeMemberField field, CodeAttributeDeclar } PrimitiveMapping pm = (PrimitiveMapping)mapping; - if (comments != null && !pm.TypeDesc.HasDefaultSupport && pm.TypeDesc.IsMappedType) + if (comments != null && pm.TypeDesc.DefaultValue == null && pm.TypeDesc.IsMappedType) { // do not generate intializers for the user prefered types if they do not have default capability DropDefaultAttribute(accessor, comments, pm.TypeDesc.FullName); @@ -529,7 +531,7 @@ private void AddDefaultValueAttribute(CodeMemberField field, CodeAttributeDeclar field.InitExpression = initExpression; } } - if (arguments != null && pm.TypeDesc.HasDefaultSupport && accessor.IsOptional && !accessor.IsFixed) + if (arguments != null && pm.TypeDesc.DefaultValue != null && accessor.IsOptional && !accessor.IsFixed) { // Add [DefaultValueAttribute] CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(DefaultValueAttribute).FullName, arguments); @@ -561,7 +563,7 @@ private CodeTypeDeclaration ExportStruct(StructMapping mapping) { if (mapping.TypeDesc.IsRoot) { - ExportRoot(mapping, typeof(XmlIncludeAttribute)); + ExportRoot(mapping, typeof(SysXmlSerialization.XmlIncludeAttribute)); return null; } @@ -595,7 +597,7 @@ private CodeTypeDeclaration ExportStruct(StructMapping mapping) codeClass.TypeAttributes |= TypeAttributes.Abstract; } - AddIncludeMetadata(codeClass.CustomAttributes, mapping, typeof(XmlIncludeAttribute)); + AddIncludeMetadata(codeClass.CustomAttributes, mapping, typeof(SysXmlSerialization.XmlIncludeAttribute)); if (mapping.IsSequence) { @@ -704,7 +706,7 @@ private void AddMemberMetadata(CodeMemberField field, CodeAttributeDeclarationCo { if (member.Xmlns != null) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlNamespaceDeclarationsAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlNamespaceDeclarationsAttribute).FullName); metadata.Add(attribute); } else if (member.Attribute != null) @@ -794,13 +796,13 @@ private void AddMemberMetadata(CodeMemberField field, CodeAttributeDeclarationCo } if (member.ChoiceIdentifier != null) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlChoiceIdentifierAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlChoiceIdentifierAttribute).FullName); attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(member.ChoiceIdentifier.MemberName))); metadata.Add(attribute); } if (member.Ignore) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlIgnoreAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlIgnoreAttribute).FullName); metadata.Add(attribute); } } @@ -820,7 +822,7 @@ private void ExportMember(CodeTypeDeclaration codeClass, MemberMapping member, s field = new CodeMemberField(typeof(bool).FullName, member.Name + "Specified"); field.Attributes = (field.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public; field.Comments.Add(new CodeCommentStatement(ResXml.XmlRemarks, true)); - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlIgnoreAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlIgnoreAttribute).FullName); field.CustomAttributes.Add(attribute); codeClass.Members.Add(field); } @@ -848,7 +850,7 @@ private void ExportProperty(CodeTypeDeclaration codeClass, MemberMapping member, prop = CreatePropertyDeclaration(field, member.Name + "Specified", typeof(bool).FullName); prop.Comments.Add(new CodeCommentStatement(ResXml.XmlRemarks, true)); - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlIgnoreAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlIgnoreAttribute).FullName); prop.CustomAttributes.Add(attribute); codeClass.Members.Add(prop); } @@ -856,7 +858,7 @@ private void ExportProperty(CodeTypeDeclaration codeClass, MemberMapping member, private void ExportText(CodeAttributeDeclarationCollection metadata, TypeDesc typeDesc, string dataType) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlTextAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlTextAttribute).FullName); if (typeDesc != null) { attribute.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(typeDesc.FullName))); @@ -870,22 +872,22 @@ private void ExportText(CodeAttributeDeclarationCollection metadata, TypeDesc ty private void ExportAttribute(CodeAttributeDeclarationCollection metadata, string name, string ns, TypeDesc typeDesc, TypeDesc dataTypeDesc, XmlSchemaForm form) { - ExportMetadata(metadata, typeof(XmlAttributeAttribute), name, ns, typeDesc, dataTypeDesc, null, form, 0, -1); + ExportMetadata(metadata, typeof(SysXmlSerialization.XmlAttributeAttribute), name, ns, typeDesc, dataTypeDesc, null, form, 0, -1); } private void ExportArrayItem(CodeAttributeDeclarationCollection metadata, string name, string ns, TypeDesc typeDesc, TypeDesc dataTypeDesc, bool isNullable, XmlSchemaForm form, int nestingLevel) { - ExportMetadata(metadata, typeof(XmlArrayItemAttribute), name, ns, typeDesc, dataTypeDesc, isNullable ? null : (object)false, form, nestingLevel, -1); + ExportMetadata(metadata, typeof(SysXmlSerialization.XmlArrayItemAttribute), name, ns, typeDesc, dataTypeDesc, isNullable ? null : (object)false, form, nestingLevel, -1); } private void ExportElement(CodeAttributeDeclarationCollection metadata, string name, string ns, TypeDesc typeDesc, TypeDesc dataTypeDesc, bool isNullable, XmlSchemaForm form, int sequenceId) { - ExportMetadata(metadata, typeof(XmlElementAttribute), name, ns, typeDesc, dataTypeDesc, isNullable ? (object)true : null, form, 0, sequenceId); + ExportMetadata(metadata, typeof(SysXmlSerialization.XmlElementAttribute), name, ns, typeDesc, dataTypeDesc, isNullable ? (object)true : null, form, 0, sequenceId); } private void ExportArray(CodeAttributeDeclarationCollection metadata, string name, string ns, bool isNullable, XmlSchemaForm form, int sequenceId) { - ExportMetadata(metadata, typeof(XmlArrayAttribute), name, ns, null, null, isNullable ? (object)true : null, form, 0, sequenceId); + ExportMetadata(metadata, typeof(SysXmlSerialization.XmlArrayAttribute), name, ns, null, null, isNullable ? (object)true : null, form, 0, sequenceId); } private void ExportMetadata(CodeAttributeDeclarationCollection metadata, Type attributeType, string name, string ns, TypeDesc typeDesc, TypeDesc dataTypeDesc, object isNullable, XmlSchemaForm form, int nestingLevel, int sequenceId) @@ -936,13 +938,13 @@ private void ExportMetadata(CodeAttributeDeclarationCollection metadata, Type at { attribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(sequenceId))); } - if (attribute.Arguments.Count == 0 && attributeType == typeof(XmlElementAttribute)) return; + if (attribute.Arguments.Count == 0 && attributeType == typeof(SysXmlSerialization.XmlElementAttribute)) return; metadata.Add(attribute); } private void ExportAnyElement(CodeAttributeDeclarationCollection metadata, string name, string ns, int sequenceId) { - CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(XmlAnyElementAttribute).FullName); + CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlAnyElementAttribute).FullName); if (name != null && name.Length > 0) { attribute.Arguments.Add(new CodeAttributeArgument("Name", new CodePrimitiveExpression(name))); @@ -960,7 +962,7 @@ private void ExportAnyElement(CodeAttributeDeclarationCollection metadata, strin private void ExportAnyAttribute(CodeAttributeDeclarationCollection metadata) { - metadata.Add(new CodeAttributeDeclaration(typeof(XmlAnyAttributeAttribute).FullName)); + metadata.Add(new CodeAttributeDeclaration(typeof(SysXmlSerialization.XmlAnyAttributeAttribute).FullName)); } internal override void EnsureTypesExported(Accessor[] accessors, string ns) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCountingReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCountingReader.cs index fe76966a13b..67df7c2df78 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCountingReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCountingReader.cs @@ -2,13 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.IO; using System.Collections; using System.Text; using System; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; internal class XmlCountingReader : XmlReader, IXmlTextParser, IXmlLineInfo { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCustomFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCustomFormatter.cs index c429a05ad94..4913ddc0db5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCustomFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlCustomFormatter.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml; + using System.Xml; using System.Globalization; using System.ComponentModel; using System.Diagnostics; @@ -122,13 +122,34 @@ internal static void WriteArrayBase64(XmlWriter writer, byte[] inData, int start writer.WriteBase64(inData, start, count); } + + internal static string ToBinHexString(byte[] value) + { + return BitConverter.ToString(value).Replace("-", ""); + } + + internal static byte[] FromBinHexString(string value) + { + if (value == null) return null; + value = value.Trim(); + int length = value.Length; + if (length == 0) return new byte[0]; + if ((length % 2) != 0) throw new ArgumentException("Invalid BinHex value.", "value"); + byte[] bytes = new byte[length / 2]; + for (int i = 0; i < length; i += 2) + { + bytes[i / 2] = Convert.ToByte(value.Substring(i, 2), 16); + } + return bytes; + } + internal static string FromByteArrayHex(byte[] value) { if (value == null) return null; if (value.Length == 0) return ""; - return XmlConvert.ToBinHexString(value); + return ToBinHexString(value); } internal static string FromEnum(long val, string[] vals, long[] ids, string typeName) @@ -381,7 +402,7 @@ internal static byte[] ToByteArrayHex(string value) { if (value == null) return null; value = value.Trim(); - return XmlConvert.FromBinHexString(value); + return FromBinHexString(value); } internal static long ToEnum(string val, Hashtable vals, string typeName, bool validate) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttribute.cs index eb30ebae072..f3c6b263f29 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttributes.cs index 6263b29c13b..af6d885bcdb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlElementAttributes.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlEnumAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlEnumAttribute.cs index 10d631d0735..c1f46b69b25 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlEnumAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlEnumAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIgnoreAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIgnoreAttribute.cs index a123d06c9da..0acc1bfc630 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIgnoreAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIgnoreAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIncludeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIncludeAttribute.cs index 589fa6d26ae..855e889242d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIncludeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlIncludeAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMapping.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMapping.cs index e313bd0fbb3..b9c054c4d16 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMapping.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMapping.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Reflection; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; - using Microsoft.Xml; + using System.Xml; [Flags] public enum XmlMappingAccess @@ -62,7 +62,7 @@ internal TypeScope Scope /// public string ElementName { - get { return Microsoft.Xml.Serialization.Accessor.UnescapeName(Accessor.Name); } + get { return Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Accessor.UnescapeName(Accessor.Name); } } /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMemberMapping.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMemberMapping.cs index 81757629a2a..fa74afb57b1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMemberMapping.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMemberMapping.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMembersMapping.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMembersMapping.cs index 67031f438cd..6a88143d6e6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMembersMapping.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlMembersMapping.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs index c8e6a131d66..6c7243d8ed1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlNamespaceDeclarationsAttribute.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionImporter.cs index 757e237aee4..cef2caa2737 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionImporter.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections; using System.Collections.Generic; using System.ComponentModel; @@ -545,7 +546,7 @@ private SpecialMapping ImportSpecialMapping(Type type, TypeDesc typeDesc, string { XmlSchemaType xsdType = serializableMapping.XsdType; if (xsdType != null) - SetBase(serializableMapping, xsdType.DerivedFrom); + SetBase(serializableMapping, xsdType.BaseXmlSchemaType.QualifiedName); _serializables[qname] = serializableMapping; } serializableMapping.TypeName = qname.Name; @@ -600,12 +601,12 @@ internal void SetBase(SerializableMapping mapping, XmlQualifiedName baseQname) XmlSchema s = (XmlSchema)srcSchemas[0]; XmlSchemaType t = (XmlSchemaType)s.SchemaTypes[baseQname]; - t = t.Redefined != null ? t.Redefined : t; + //t = t.Redefined != null ? t.Redefined : t; if (_serializables[baseQname] == null) { SerializableMapping baseMapping = new SerializableMapping(baseQname, schemas); - SetBase(baseMapping, t.DerivedFrom); + SetBase(baseMapping, t.BaseXmlSchemaType.QualifiedName); _serializables.Add(baseQname, baseMapping); } mapping.SetBaseMapping((SerializableMapping)_serializables[baseQname]); @@ -1375,7 +1376,7 @@ private MemberMapping ImportMemberMapping(XmlReflectionMember xmlReflectionMembe FieldModel model = new FieldModel(xmlReflectionMember.MemberName, xmlReflectionMember.MemberType, _typeScope.GetTypeDesc(xmlReflectionMember.MemberType), checkSpecified, false); member.CheckShouldPersist = model.CheckShouldPersist; member.CheckSpecified = model.CheckSpecified; - member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.HasDefaultConstructor; + member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.DefaultValue != nullConstructor; Type choiceIdentifierType = null; if (a.XmlChoiceIdentifier != null) @@ -1405,7 +1406,7 @@ private MemberMapping ImportFieldMapping(StructModel parent, FieldModel model, X member.MemberInfo = model.MemberInfo; member.CheckSpecifiedMemberInfo = model.CheckSpecifiedMemberInfo; member.CheckShouldPersistMethodInfo = model.CheckShouldPersistMethodInfo; - member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.HasDefaultConstructor; + member.ReadOnly = model.ReadOnly; // || !model.FieldTypeDesc.DefaultValue != nullConstructor; Type choiceIdentifierType = null; if (a.XmlChoiceIdentifier != null) { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionMember.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionMember.cs index cfd5d789af5..c7279ec7b20 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionMember.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlReflectionMember.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlRootAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlRootAttribute.cs index 2e6116fbf24..3d634a2e092 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlRootAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlRootAttribute.cs @@ -3,10 +3,11 @@ // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaExporter.cs index 75b879961dc..9b55d4a885a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaExporter.cs @@ -2,16 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Reflection; - using Microsoft.Xml; + using System.Xml; /// /// @@ -149,7 +149,7 @@ private static bool IsAnyType(XmlSchemaType schemaType, bool mixed, bool unbound if (sequence.Items.Count == 1 && sequence.Items[0] is XmlSchemaAny) { XmlSchemaAny any = (XmlSchemaAny)sequence.Items[0]; - return (unbounded == any.IsMultipleOccurrence); + return (unbounded == any.MaxOccurs > 1); } } } @@ -765,7 +765,7 @@ private void ExportAttributeAccessor(XmlSchemaComplexType type, AttributeAccesso { XmlSchemaAttribute attribute = new XmlSchemaAttribute(); attribute.Use = XmlSchemaUse.None; - if (!accessor.HasDefault && !valueTypeOptional && accessor.Mapping.TypeDesc.IsValueType) + if (accessor.Default == null && !valueTypeOptional && accessor.Mapping.TypeDesc.IsValueType) { attribute.Use = XmlSchemaUse.Required; } @@ -832,7 +832,7 @@ private void ExportAttributeAccessor(XmlSchemaComplexType type, AttributeAccesso else if (!(accessor.Mapping is SpecialMapping)) throw new InvalidOperationException(ResXml.XmlInternalError); - if (accessor.HasDefault) + if (accessor.Default != null) { attribute.DefaultValue = ExportDefaultValue(accessor.Mapping, accessor.Default); } @@ -853,7 +853,7 @@ private void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor acc else { XmlSchemaElement element = (XmlSchemaElement)_elements[accessor]; - int minOccurs = repeats || accessor.HasDefault || (!accessor.IsNullable && !accessor.Mapping.TypeDesc.IsValueType) || valueTypeOptional ? 0 : 1; + int minOccurs = repeats || accessor.Default != null || (!accessor.IsNullable && !accessor.Mapping.TypeDesc.IsValueType) || valueTypeOptional ? 0 : 1; decimal maxOccurs = repeats || accessor.IsUnbounded ? decimal.MaxValue : 1; if (element == null) @@ -861,7 +861,7 @@ private void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor acc element = new XmlSchemaElement(); element.IsNillable = accessor.IsNullable; element.Name = accessor.Name; - if (accessor.HasDefault) + if (accessor.Default != null) element.DefaultValue = ExportDefaultValue(accessor.Mapping, accessor.Default); if (accessor.IsTopLevelInSchema) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs index 78d5a88ee97..5e40793fbee 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs @@ -2,21 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; - //using Microsoft.Xml.Serialization.Configuration; + //using System.Xml.Serialization.Configuration; using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; using System.Collections.Specialized; using System.Globalization; // using System.Security.Permissions; - using Microsoft.Xml.Serialization.Advanced; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced; #if DEBUG using System.Diagnostics; @@ -316,7 +317,7 @@ private ElementAccessor ImportElement(XmlSchemaElement element, string identifie { // we cannot re-use the accessor for the element refs ElementAccessor topAccessor = ImportElement(element.RefName, desiredMappingType, baseType); - if (element.IsMultipleOccurrence && topAccessor.Mapping is ArrayMapping) + if (element.MaxOccurs > 1 && topAccessor.Mapping is ArrayMapping) { ElementAccessor refAccessor = topAccessor.Clone(); refAccessor.IsTopLevelInSchema = false; @@ -514,7 +515,7 @@ internal override void ImportDerivedTypes(XmlQualifiedName baseName) if (item is XmlSchemaType) { XmlSchemaType type = (XmlSchemaType)item; - if (type.DerivedFrom == baseName && TypesInUse[type.Name, schema.TargetNamespace] == null) + if (type.BaseXmlSchemaType?.QualifiedName == baseName && TypesInUse[type.Name, schema.TargetNamespace] == null) { ImportType(type.QualifiedName, typeof(TypeMapping), null, TypeFlags.CanBeElementValue, false); } @@ -552,7 +553,7 @@ private TypeMapping ImportType(XmlQualifiedName name, Type desiredMappingType, T private TypeMapping ImportType(XmlSchemaComplexType type, string typeNs, string identifier, Type desiredMappingType, Type baseType, TypeFlags flags) { - if (type.Redefined != null) + if (false /*type.Redefined != null*/) { // we do not support redefine in the current version throw new NotSupportedException(string.Format(ResXml.XmlUnsupportedRedefine, type.Name, typeNs)); @@ -585,7 +586,7 @@ private TypeMapping ImportType(XmlSchemaComplexType type, string typeNs, string private MembersMapping ImportMembersType(XmlSchemaType type, string typeNs, string identifier) { - if (!type.DerivedFrom.IsEmpty) throw new InvalidOperationException(ResXml.XmlMembersDeriveError); + // if (type.BaseXmlSchemaType == null) throw new InvalidOperationException(ResXml.XmlMembersDeriveError); CodeIdentifiers memberScope = new CodeIdentifiers(); memberScope.UseCamelCasing = true; bool needExplicitOrder = false; @@ -603,9 +604,9 @@ private StructMapping ImportStructType(XmlSchemaType type, string typeNs, string TypeMapping baseMapping = null; bool isRootType = false; - if (!type.DerivedFrom.IsEmpty) + if (type.BaseXmlSchemaType != null) { - baseMapping = ImportType(type.DerivedFrom, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false); + baseMapping = ImportType(type.BaseXmlSchemaType.QualifiedName, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false); if (baseMapping is StructMapping) baseTypeDesc = ((StructMapping)baseMapping).TypeDesc; @@ -745,9 +746,9 @@ private MemberMapping[] ImportTypeMembers(XmlSchemaType type, string typeNs, str { // check if we can transfer the attribute to the base class XmlSchemaType t = type; - while (!t.DerivedFrom.IsEmpty) + while (t.BaseXmlSchemaType != null) { - t = FindType(t.DerivedFrom, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue); + t = FindType(t.BaseXmlSchemaType.QualifiedName, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue); if (IsMixed(t)) { // keep the mixed attribute on the base class @@ -843,12 +844,12 @@ private TypeItems GetTypeItems(XmlSchemaType type) { XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle; items.Particle = FindGroup(refGroup.RefName).Particle; - items.IsUnbounded = particle.IsMultipleOccurrence; + items.IsUnbounded = particle.MaxOccurs > 1; } else if (particle is XmlSchemaGroupBase) { items.Particle = (XmlSchemaGroupBase)particle; - items.IsUnbounded = particle.IsMultipleOccurrence; + items.IsUnbounded = particle.MaxOccurs > 1; } } return items; @@ -1032,7 +1033,7 @@ private bool GatherGroupChoices(XmlSchemaParticle particle, NameTable choiceElem else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; - bool groupRepeats = group.IsMultipleOccurrence; + bool groupRepeats = group.MaxOccurs > 1; XmlSchemaAny any = null; bool duplicateElements = false; for (int i = 0; i < group.Items.Count; i++) @@ -1063,11 +1064,11 @@ private bool GatherGroupChoices(XmlSchemaParticle particle, NameTable choiceElem XmlSchemaElement[] elements = GetEquivalentElements(headElement); for (int j = 0; j < elements.Length; j++) { - if (elements[j].IsMultipleOccurrence) groupRepeats = true; + if (elements[j].MaxOccurs > 1) groupRepeats = true; AddScopeElement(choiceElements, ImportElement(elements[j], identifier, typeof(TypeMapping), null, elements[j].QualifiedName.Namespace, true), ref duplicateElements, allowDuplicates); } } - if (element.IsMultipleOccurrence) groupRepeats = true; + if (element.MaxOccurs > 1) groupRepeats = true; AddScopeElement(choiceElements, ImportElement(element, identifier, typeof(TypeMapping), null, element.QualifiedName.Namespace, false), ref duplicateElements, allowDuplicates); } } @@ -1124,7 +1125,7 @@ private void ImportGroupMembers(XmlSchemaParticle particle, string identifier, C if (!refGroup.RefName.IsEmpty) { AddReference(refGroup.RefName, GroupsInUse, ResXml.XmlCircularGroupReference); - ImportGroupMembers(FindGroup(refGroup.RefName).Particle, identifier, members, membersScope, elementsScope, refGroup.RefName.Namespace, groupRepeats | refGroup.IsMultipleOccurrence, ref mixed, ref needExplicitOrder, allowDuplicates, allowUnboundedElements); + ImportGroupMembers(FindGroup(refGroup.RefName).Particle, identifier, members, membersScope, elementsScope, refGroup.RefName.Namespace, groupRepeats | refGroup.MaxOccurs > 1, ref mixed, ref needExplicitOrder, allowDuplicates, allowUnboundedElements); RemoveReference(refGroup.RefName, GroupsInUse); } } @@ -1132,7 +1133,7 @@ private void ImportGroupMembers(XmlSchemaParticle particle, string identifier, C { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; - if (group.IsMultipleOccurrence) + if (group.MaxOccurs > 1) groupRepeats = true; if (GenerateOrder && groupRepeats && group.Items.Count > 1) @@ -1275,7 +1276,7 @@ private MemberMapping ImportAnyMember(XmlSchemaAny any, string identifier, CodeI members.Add(member.Name, member); member.TypeDesc = ((TypeMapping)accessors[0].Mapping).TypeDesc; - bool repeats = any.IsMultipleOccurrence; + bool repeats = any.MaxOccurs > 1; if (mixed) { @@ -1345,7 +1346,7 @@ private ElementAccessor ImportArray(XmlSchemaElement element, string identifier, { if (repeats) return null; if (element.SchemaType == null) return null; - if (element.IsMultipleOccurrence) return null; + if (element.MaxOccurs > 1) return null; XmlSchemaType type = element.SchemaType; ArrayMapping arrayMapping = ImportArrayMapping(type, identifier, ns, repeats); if (arrayMapping == null) return null; @@ -1362,7 +1363,19 @@ private ElementAccessor ImportArray(XmlSchemaElement element, string identifier, private ArrayMapping ImportArrayMapping(XmlSchemaType type, string identifier, string ns, bool repeats) { if (!(type is XmlSchemaComplexType)) return null; - if (!type.DerivedFrom.IsEmpty) return null; + // [Fix: Polymorphism/Inheritance] + // We only disqualify the type from being an Array if it *explicitly* extends another type via ContentModel. + // Implicit inheritance from 'anyType' (where BaseXmlSchemaType is non-null but ContentModel is null) + // is standard for Arrays and must be allowed. + if (type is XmlSchemaComplexType complexType && complexType.ContentModel != null) + { + if (complexType.ContentModel.Content is XmlSchemaComplexContentExtension || + complexType.ContentModel.Content is XmlSchemaSimpleContentExtension) + { + return null; + } + } + if (IsMixed(type)) return null; Mapping previousMapping = (Mapping)ImportedMappings[type]; @@ -1389,7 +1402,7 @@ private ArrayMapping ImportArrayMapping(XmlSchemaType type, string identifier, s if (item is XmlSchemaChoice) { XmlSchemaChoice choice = (XmlSchemaChoice)item; - if (!choice.IsMultipleOccurrence) + if (choice.MaxOccurs <= 1) return null; bool needExplicitOrder = false; MemberMapping choiceMember = ImportChoiceGroup(choice, identifier, null, null, null, ns, true, ref needExplicitOrder, false); @@ -1402,15 +1415,15 @@ private ArrayMapping ImportArrayMapping(XmlSchemaType type, string identifier, s { if (item.Items.Count != 1 || !(item.Items[0] is XmlSchemaElement)) return null; XmlSchemaElement itemElement = (XmlSchemaElement)item.Items[0]; - if (!itemElement.IsMultipleOccurrence) return null; - if (IsCyclicReferencedType(itemElement, new List(1) { identifier })) + if (itemElement.MaxOccurs <= 1) return null; + /*if (IsCyclicReferencedType(itemElement, new List(1) { identifier })) { return null; - } + }*/ ElementAccessor itemAccessor = ImportElement(itemElement, identifier, typeof(TypeMapping), null, ns, false); - if (itemAccessor.Any) - return null; + // if (itemAccessor.Any) + // return null; arrayMapping.Elements = new ElementAccessor[] { itemAccessor }; arrayMapping.TypeDesc = ((TypeMapping)itemAccessor.Mapping).TypeDesc.CreateArrayTypeDesc(); arrayMapping.TypeName = (type.Name == null || type.Name.Length == 0) ? "ArrayOf" + CodeIdentifier.MakePascal(itemAccessor.Mapping.TypeDesc.Name) : type.Name; @@ -1453,7 +1466,7 @@ private bool IsCyclicReferencedType(XmlSchemaElement element, List ident if ((items.Particle is XmlSchemaSequence || items.Particle is XmlSchemaAll) && items.Particle.Items.Count == 1 && items.Particle.Items[0] is XmlSchemaElement) { XmlSchemaElement innerRefElement = (XmlSchemaElement)items.Particle.Items[0]; - if (innerRefElement.IsMultipleOccurrence) + if (innerRefElement.MaxOccurs > 1) { return IsCyclicReferencedType(innerRefElement, identifiers); } @@ -1466,7 +1479,7 @@ private bool IsCyclicReferencedType(XmlSchemaElement element, List ident private SpecialMapping ImportAnyMapping(XmlSchemaType type, string identifier, string ns, bool repeats) { if (type == null) return null; - if (!type.DerivedFrom.IsEmpty) return null; + if (type.BaseXmlSchemaType != null) return null; bool mixed = IsMixed(type); TypeItems items = GetTypeItems(type); @@ -1480,12 +1493,12 @@ private SpecialMapping ImportAnyMapping(XmlSchemaType type, string identifier, s SpecialMapping mapping = new SpecialMapping(); // check for special named any case - if (items.AnyAttribute != null && any.IsMultipleOccurrence && mixed) + if (items.AnyAttribute != null && any.MaxOccurs > 1 && mixed) { mapping.NamedAny = true; mapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlElement)); } - else if (items.AnyAttribute != null || any.IsMultipleOccurrence) + else if (items.AnyAttribute != null || any.MaxOccurs > 1) { // these only work for named any case -- otherwise import as struct return null; @@ -1511,7 +1524,7 @@ private SpecialMapping ImportAnyMapping(XmlSchemaType type, string identifier, s private void ImportElementMember(XmlSchemaElement element, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string ns, bool repeats, ref bool needExplicitOrder, bool allowDuplicates, bool allowUnboundedElements) { - repeats = repeats | element.IsMultipleOccurrence; + repeats = repeats | element.MaxOccurs > 1; XmlSchemaElement headElement = GetTopLevelElement(element); if (headElement != null && ImportSubstitutionGroupMember(headElement, identifier, members, membersScope, ns, repeats, ref needExplicitOrder, allowDuplicates)) { @@ -1548,7 +1561,7 @@ private void ImportElementMember(XmlSchemaElement element, string identifier, Co AddScopeElement(elementsScope, accessor, ref needExplicitOrder, allowDuplicates); member.Elements = new ElementAccessor[] { accessor }; - if (element.IsMultipleOccurrence || repeats) + if (element.MaxOccurs > 1 || repeats) { if (!allowUnboundedElements && accessor.Mapping is ArrayMapping) { @@ -1559,7 +1572,7 @@ private void ImportElementMember(XmlSchemaElement element, string identifier, Co member.TypeDesc = accessor.Mapping.TypeDesc.CreateArrayTypeDesc(); } - if (element.MinOccurs == 0 && member.TypeDesc.IsValueType && !element.HasDefault && !member.TypeDesc.HasIsEmpty) + if (element.MinOccurs == 0 && member.TypeDesc.IsValueType && element.DefaultValue == null && !member.TypeDesc.HasIsEmpty) { member.CheckSpecified = SpecifiedAccessor.ReadWrite; } @@ -1583,7 +1596,7 @@ private void ImportAttributeMember(XmlSchemaAttribute attribute, string identifi members.Add(member.Name, member); member.TypeDesc = accessor.IsList ? accessor.Mapping.TypeDesc.CreateArrayTypeDesc() : accessor.Mapping.TypeDesc; - if ((attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) && member.TypeDesc.IsValueType && !attribute.HasDefault && !member.TypeDesc.HasIsEmpty) + if ((attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) && member.TypeDesc.IsValueType && attribute.DefaultValue == null && !member.TypeDesc.HasIsEmpty) { member.CheckSpecified = SpecifiedAccessor.ReadWrite; } @@ -1631,9 +1644,9 @@ private bool KeepXmlnsDeclarations(XmlSchemaType type, out string xmlnsMemberNam XmlElement e = (XmlElement)node; if (e.Name == "keepNamespaceDeclarations") { - if (e.LastNode is XmlText) + if (e.LastChild is XmlText) { - xmlnsMemberName = (((XmlText)e.LastNode).Value).Trim(null); + xmlnsMemberName = (((XmlText)e.LastChild).Value).Trim(null); } return true; } @@ -1831,9 +1844,9 @@ private TypeMapping ImportEnumeratedDataType(XmlSchemaSimpleType dataType, strin return mapping; XmlSchemaType sourceType = dataType; - while (!sourceType.DerivedFrom.IsEmpty) + while (sourceType.BaseXmlSchemaType != null) { - sourceType = FindType(sourceType.DerivedFrom, TypeFlags.CanBeElementValue | TypeFlags.CanBeAttributeValue); + sourceType = FindType(sourceType.BaseXmlSchemaType.QualifiedName, TypeFlags.CanBeElementValue | TypeFlags.CanBeAttributeValue); } if (sourceType is XmlSchemaComplexType) return null; TypeDesc sourceTypeDesc = Scope.GetTypeDesc((XmlSchemaSimpleType)sourceType); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaProviderAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaProviderAttribute.cs index 6c461046d0c..a312201f860 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaProviderAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaProviderAttribute.cs @@ -3,10 +3,11 @@ // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; - using Microsoft.Xml.Schema; + using System.Xml.Schema; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemas.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemas.cs index 1599d49eda9..f3aa6e9c705 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemas.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemas.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Collections; using System.Collections.Generic; @@ -10,8 +10,8 @@ namespace Microsoft.Xml.Serialization using System; using System.Globalization; using System.ComponentModel; - using Microsoft.Xml.Serialization; - using Microsoft.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; + using System.Xml.Schema; using System.Diagnostics; using System.Threading; // using System.Security.Permissions; @@ -19,7 +19,7 @@ namespace Microsoft.Xml.Serialization using System.Security; using System.Net; using System.Reflection; - using Microsoft.Xml; + using System.Xml; /// /// @@ -75,6 +75,22 @@ public IList GetSchemas(string ns) return (IList)SchemaSet.Schemas(ns); } + public static implicit operator System.Xml.Serialization.XmlSchemas(XmlSchemas schemas) + { + if (schemas == null) return null; + System.Xml.Serialization.XmlSchemas sysSchemas = new System.Xml.Serialization.XmlSchemas(); + foreach(XmlSchema s in schemas) { sysSchemas.Add(s); } + return sysSchemas; + } + + public static implicit operator XmlSchemas(System.Xml.Serialization.XmlSchemas schemas) + { + if (schemas == null) return null; + XmlSchemas localSchemas = new XmlSchemas(); + foreach(XmlSchema s in schemas) { localSchemas.Add(s); } + return localSchemas; + } + internal SchemaObjectCache Cache { get @@ -151,8 +167,8 @@ public int Add(XmlSchema schema, Uri baseUri) { if (List.Contains(schema)) return List.IndexOf(schema); - if (baseUri != null) - schema.BaseUri = baseUri; + //if (baseUri != null) + // schema.BaseUri = baseUri; return List.Add(schema); } @@ -384,11 +400,12 @@ IEnumerator IEnumerable.GetEnumerator() internal static void Preprocess(XmlSchema schema) { - if (!schema.IsPreprocessed) + if (!SchemaHelper.IsPreprocessed(schema)) { + /* try { - XmlNameTable nameTable = new Microsoft.Xml.NameTable(); + XmlNameTable nameTable = new System.Xml.NameTable(); Preprocessor prep = new Preprocessor(nameTable, new SchemaNames(nameTable), null); prep.SchemaLocations = new Hashtable(); prep.Execute(schema, schema.TargetNamespace, false); @@ -397,6 +414,7 @@ internal static void Preprocess(XmlSchema schema) { throw CreateValidationException(e, e.Message); } + */ } } @@ -538,7 +556,7 @@ private void Merge(IList originals, XmlSchema schema) destination.Items.Add(schema.Items[i]); } } - destination.IsPreprocessed = false; + // destination.IsPreprocessed = false; Preprocess(destination); } } @@ -775,9 +793,10 @@ public void Compile(ValidationEventHandler handler, bool fullCompile) } else { + /* try { - XmlNameTable nameTable = new Microsoft.Xml.NameTable(); + XmlNameTable nameTable = new System.Xml.NameTable(); Preprocessor prep = new Preprocessor(nameTable, new SchemaNames(nameTable), null); prep.XmlResolver = null; prep.SchemaLocations = new Hashtable(); @@ -791,6 +810,7 @@ public void Compile(ValidationEventHandler handler, bool fullCompile) { throw CreateValidationException(e, e.Message); } + */ } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationGeneratedCode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationGeneratedCode.cs index 5bfe4be3ea3..8a04a63416a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationGeneratedCode.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationGeneratedCode.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationILGen.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationILGen.cs index f25cebac263..2c81a830ab3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationILGen.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationILGen.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationReader.cs index 73208a9ba9f..333efae8910 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationReader.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.IO; using System; @@ -10,15 +10,15 @@ namespace Microsoft.Xml.Serialization using System.Collections; using System.Reflection; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using System.ComponentModel; using System.Globalization; using Microsoft.CodeDom.Compiler; using System.Diagnostics; using System.Threading; // using System.Configuration; - //using Microsoft.Xml.Serialization.Configuration; + //using System.Xml.Serialization.Configuration; /// /// @@ -198,7 +198,7 @@ protected XmlDocument Document if (_d == null) { _d = new XmlDocument(_r.NameTable); - _d.SetBaseURI(_r.BaseURI); + //_d.SetBaseURI(_r.BaseURI); } return _d; } @@ -2041,7 +2041,7 @@ private object ReadXmlNodes(bool elementCanBeType) Reader.MoveToContent(); int whileIterations = 0; int readerCount = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { XmlNode xmlNode = Document.ReadNode(_r); xmlNodeList.Add(xmlNode); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriter.cs index 77bbfc5a5e0..1a95991417c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriter.cs @@ -2,14 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.IO; using System.Collections; using System.Reflection; using System.Reflection.Emit; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.ComponentModel; using System.Diagnostics; using Microsoft.CodeDom.Compiler; @@ -1655,7 +1656,7 @@ private void WriteQualifiedNameElement(string name, string ns, object defaultVal if (IsSoap) { - Writer.Write(", new Microsoft.Xml.XmlQualifiedName("); + Writer.Write(", new System.Xml.XmlQualifiedName("); WriteQuotedCSharpString(mapping.TypeName); Writer.Write(", "); WriteQuotedCSharpString(mapping.Namespace); @@ -1717,7 +1718,7 @@ private void WritePrimitiveValue(TypeDesc typeDesc, string source, bool isElemen private void WritePrimitive(string method, string name, string ns, object defaultValue, string source, TypeMapping mapping, bool writeXsiType, bool isElement, bool isNullable) { TypeDesc typeDesc = mapping.TypeDesc; - bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc.HasDefaultSupport; + bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc.DefaultValue != null; if (hasDefault) { if (mapping is EnumMapping) @@ -1781,7 +1782,7 @@ private void WritePrimitive(string method, string name, string ns, object defaul if (writeXsiType) { - Writer.Write(", new Microsoft.Xml.XmlQualifiedName("); + Writer.Write(", new System.Xml.XmlQualifiedName("); WriteQuotedCSharpString(mapping.TypeName); Writer.Write(", "); WriteQuotedCSharpString(mapping.Namespace); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriterILGen.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriterILGen.cs index 15ff6d5ebf0..6c07d2631a2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriterILGen.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializationWriterILGen.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; using System.Collections; @@ -12,7 +13,7 @@ namespace Microsoft.Xml.Serialization using System.Reflection; using System.Reflection.Emit; using System.Text; - using Microsoft.Xml.Schema; + using System.Xml.Schema; internal class XmlSerializationWriterILGen : XmlSerializationILGen { @@ -194,7 +195,7 @@ private void WritePrimitiveValue(TypeDesc typeDesc, SourceInfo source, out Type private void WritePrimitive(string method, string name, string ns, object defaultValue, SourceInfo source, TypeMapping mapping, bool writeXsiType, bool isElement, bool isNullable) { TypeDesc typeDesc = mapping.TypeDesc; - bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc.HasDefaultSupport; + bool hasDefault = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc.DefaultValue != null; if (hasDefault) { if (mapping is EnumMapping) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializer.cs index 8f12c6a41d7..6de63563c47 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializer.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.Text; using System.Threading; @@ -15,7 +16,7 @@ namespace Microsoft.Xml.Serialization using System.Security; // using System.Security.Permissions; // using System.Security.Policy; - //using Microsoft.Xml.Serialization.Configuration; + //using System.Xml.Serialization.Configuration; using System.Diagnostics; using Microsoft.CodeDom.Compiler; using System.Runtime.Versioning; @@ -674,7 +675,7 @@ public static string GetXmlSerializerAssemblyName(Type type, string defaultNames { throw new ArgumentNullException("type"); } - return Compiler.GetTempAssemblyName(type.GetTypeInfo().Assembly.GetName(), defaultNamespace); + return CodeIdentifier.MakeValid(type.GetTypeInfo().Assembly.GetName().Name) + ".XmlSerializers"; } /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerAssemblyAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerAssemblyAttribute.cs index 0d30e2ff14c..f1539b719a9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerAssemblyAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerAssemblyAttribute.cs @@ -3,7 +3,8 @@ // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerFactory.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerFactory.cs index ea2da79302a..2971c610549 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerFactory.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerFactory.cs @@ -2,19 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; using System.Text; using System.Threading; using System.Globalization; // using System.Security.Permissions; // using System.Security.Policy; - //using Microsoft.Xml.Serialization.Configuration; + //using System.Xml.Serialization.Configuration; using System.Diagnostics; using Microsoft.CodeDom.Compiler; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerNamespaces.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerNamespaces.cs index 21b1ec77ca0..422fd1fadf7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerNamespaces.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerNamespaces.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System.Collections; using System.IO; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System; /// @@ -60,8 +61,8 @@ public void Add(string prefix, string ns) if (prefix != null && prefix.Length > 0) XmlConvert.VerifyNCName(prefix); - if (ns != null && ns.Length > 0) - XmlConvert.ToUri(ns); + //if (ns != null && ns.Length > 0) + // XmlConvert.ToUri(ns); AddInternal(prefix, ns); } @@ -132,6 +133,27 @@ internal string LookupPrefix(string ns) } return null; } + + public static implicit operator System.Xml.Serialization.XmlSerializerNamespaces(XmlSerializerNamespaces ns) + { + if (ns == null) return null; + System.Xml.Serialization.XmlSerializerNamespaces sysNs = new System.Xml.Serialization.XmlSerializerNamespaces(); + foreach (System.Xml.XmlQualifiedName qname in ns.ToArray()) + { + sysNs.Add(qname.Name, qname.Namespace); + } + return sysNs; + } + + public static implicit operator XmlSerializerNamespaces(System.Xml.Serialization.XmlSerializerNamespaces ns) + { + if (ns == null) return null; + XmlSerializerNamespaces localNs = new XmlSerializerNamespaces(); + foreach (System.Xml.XmlQualifiedName qname in ns.ToArray()) + { + localNs.Add(qname.Name, qname.Namespace); + } + return localNs; + } } } - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerVersionAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerVersionAttribute.cs index b384db0c662..d61445b08c6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerVersionAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSerializerVersionAttribute.cs @@ -3,7 +3,8 @@ // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTextAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTextAttribute.cs index 491e91341a9..9e251191269 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTextAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTextAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeAttribute.cs index 99766c6cc1b..221485338c0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeAttribute.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeAttribute.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeMapping.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeMapping.cs index 00d6b5564f8..0c3d98a4c7c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeMapping.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlTypeMapping.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.Reflection; using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/_Events.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/_Events.cs index 787cd1c5693..80573e6290c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/_Events.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/_Events.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml.Serialization +using System.Xml; +namespace Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer { using System.IO; using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ValidateNames.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ValidateNames.cs index 275d742d825..d65b44f1ffe 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ValidateNames.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/ValidateNames.cs @@ -3,11 +3,11 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml.XPath; +using System.Xml.XPath; using System.Diagnostics; using System.Globalization; -namespace Microsoft.Xml +namespace System.Xml { /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/IXPathNavigable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/IXPathNavigable.cs deleted file mode 100644 index 2d1bccf537d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/IXPathNavigable.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.XPath -{ - public interface IXPathNavigable - { - XPathNavigator CreateNavigator(); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AbsoluteQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AbsoluteQuery.cs deleted file mode 100644 index 07716d728ab..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AbsoluteQuery.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal sealed class AbsoluteQuery : ContextQuery - { - public AbsoluteQuery() : base() { } - private AbsoluteQuery(AbsoluteQuery other) : base(other) { } - - public override object Evaluate(XPathNodeIterator context) - { - base.contextNode = context.Current.Clone(); - base.contextNode.MoveToRoot(); - count = 0; - return this; - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - if (context != null && context.NodeType == XPathNodeType.Root) - { - return context; - } - return null; - } - - public override XPathNodeIterator Clone() { return new AbsoluteQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AstNode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AstNode.cs deleted file mode 100644 index dddc75d407c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AstNode.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml.XPath; - - internal abstract class AstNode - { - public enum AstType - { - Axis, - Operator, - Filter, - ConstantOperand, - Function, - Group, - Root, - Variable, - Error - }; - - public abstract AstType Type { get; } - public abstract XPathResultType ReturnType { get; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AttributeQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AttributeQuery.cs deleted file mode 100644 index ace441a10dd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/AttributeQuery.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal sealed class AttributeQuery : BaseAxisQuery - { - private bool _onAttribute = false; - - public AttributeQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) { } - private AttributeQuery(AttributeQuery other) : base(other) - { - _onAttribute = other._onAttribute; - } - public override void Reset() - { - _onAttribute = false; - base.Reset(); - } - - public override XPathNavigator Advance() - { - while (true) - { - if (!_onAttribute) - { - currentNode = qyInput.Advance(); - if (currentNode == null) - { - return null; - } - position = 0; - currentNode = currentNode.Clone(); - _onAttribute = currentNode.MoveToFirstAttribute(); - } - else - { - _onAttribute = currentNode.MoveToNextAttribute(); - } - - if (_onAttribute) - { - Debug.Assert(!currentNode.NamespaceURI.Equals(XmlReservedNs.NsXmlNs)); - if (matches(currentNode)) - { - position++; - return currentNode; - } - } - } // while - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - if (context != null) - { - if (context.NodeType == XPathNodeType.Attribute && matches(context)) - { - XPathNavigator temp = context.Clone(); - if (temp.MoveToParent()) - { - return qyInput.MatchNode(temp); - } - } - } - return null; - } - - public override XPathNodeIterator Clone() { return new AttributeQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Axis.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Axis.cs deleted file mode 100644 index 49b5d0d53d9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Axis.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class Axis : AstNode - { - private AxisType _axisType; - private AstNode _input; - private string _prefix; - private string _name; - private XPathNodeType _nodeType; - protected bool abbrAxis; - - public enum AxisType - { - Ancestor, - AncestorOrSelf, - Attribute, - Child, - Descendant, - DescendantOrSelf, - Following, - FollowingSibling, - Namespace, - Parent, - Preceding, - PrecedingSibling, - Self, - None - }; - - // constructor - public Axis(AxisType axisType, AstNode input, string prefix, string name, XPathNodeType nodetype) - { - Debug.Assert(prefix != null); - Debug.Assert(name != null); - _axisType = axisType; - _input = input; - _prefix = prefix; - _name = name; - _nodeType = nodetype; - } - - // constructor - public Axis(AxisType axisType, AstNode input) - : this(axisType, input, string.Empty, string.Empty, XPathNodeType.All) - { - this.abbrAxis = true; - } - - public override AstType Type { get { return AstType.Axis; } } - - public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; } } - - public AstNode Input - { - get { return _input; } - set { _input = value; } - } - - public string Prefix { get { return _prefix; } } - public string Name { get { return _name; } } - public XPathNodeType NodeType { get { return _nodeType; } } - public AxisType TypeOfAxis { get { return _axisType; } } - public bool AbbrAxis { get { return abbrAxis; } } - - // Used by AstTree in Schema - private string _urn = string.Empty; - public string Urn - { - get { return _urn; } - set { _urn = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanExpr.cs deleted file mode 100644 index 4ee457beadd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanExpr.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Diagnostics; - using System.Globalization; - - internal sealed class BooleanExpr : ValueQuery - { - private Query _opnd1; - private Query _opnd2; - private bool _isOr; - - public BooleanExpr(Operator.Op op, Query opnd1, Query opnd2) - { - Debug.Assert(op == Operator.Op.AND || op == Operator.Op.OR); - Debug.Assert(opnd1 != null && opnd2 != null); - if (opnd1.StaticType != XPathResultType.Boolean) - { - opnd1 = new BooleanFunctions(Function.FunctionType.FuncBoolean, opnd1); - } - if (opnd2.StaticType != XPathResultType.Boolean) - { - opnd2 = new BooleanFunctions(Function.FunctionType.FuncBoolean, opnd2); - } - _opnd1 = opnd1; - _opnd2 = opnd2; - _isOr = (op == Operator.Op.OR); - } - private BooleanExpr(BooleanExpr other) : base(other) - { - _opnd1 = Clone(other._opnd1); - _opnd2 = Clone(other._opnd2); - _isOr = other._isOr; - } - - public override void SetXsltContext(XsltContext context) - { - _opnd1.SetXsltContext(context); - _opnd2.SetXsltContext(context); - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - object n1 = _opnd1.Evaluate(nodeIterator); - if (((bool)n1) == _isOr) - { - return n1; - } - return _opnd2.Evaluate(nodeIterator); - } - - public override XPathNodeIterator Clone() { return new BooleanExpr(this); } - public override XPathResultType StaticType { get { return XPathResultType.Boolean; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("op", (_isOr ? Operator.Op.OR : Operator.Op.AND).ToString()); - _opnd1.PrintQuery(w); - _opnd2.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanFunctions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanFunctions.cs deleted file mode 100644 index 5828786cf30..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/BooleanFunctions.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using FT = MS.Internal.Xml.XPath.Function.FunctionType; - - internal sealed class BooleanFunctions : ValueQuery - { - private Query _arg; - private FT _funcType; - - public BooleanFunctions(FT funcType, Query arg) - { - _arg = arg; - _funcType = funcType; - } - private BooleanFunctions(BooleanFunctions other) : base(other) - { - _arg = Clone(other._arg); - _funcType = other._funcType; - } - - public override void SetXsltContext(XsltContext context) - { - if (_arg != null) - { - _arg.SetXsltContext(context); - } - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - switch (_funcType) - { - case FT.FuncBoolean: return toBoolean(nodeIterator); - case FT.FuncNot: return Not(nodeIterator); - case FT.FuncTrue: return true; - case FT.FuncFalse: return false; - case FT.FuncLang: return Lang(nodeIterator); - } - return false; - } - - internal static bool toBoolean(double number) - { - return number != 0 && !double.IsNaN(number); - } - internal static bool toBoolean(string str) - { - return str.Length > 0; - } - - internal bool toBoolean(XPathNodeIterator nodeIterator) - { - object result = _arg.Evaluate(nodeIterator); - if (result is XPathNodeIterator) return _arg.Advance() != null; - if (result is string) return toBoolean((string)result); - if (result is double) return toBoolean((double)result); - if (result is bool) return (bool)result; - Debug.Assert(result is XPathNavigator, "Unknown value type"); - return true; - } - - public override XPathResultType StaticType { get { return XPathResultType.Boolean; } } - - private bool Not(XPathNodeIterator nodeIterator) - { - return !(bool)_arg.Evaluate(nodeIterator); - } - - private bool Lang(XPathNodeIterator nodeIterator) - { - string str = _arg.Evaluate(nodeIterator).ToString(); - string lang = nodeIterator.Current.XmlLang; - return ( - lang.StartsWith(str, StringComparison.OrdinalIgnoreCase) && - (lang.Length == str.Length || lang[str.Length] == '-') - ); - } - - public override XPathNodeIterator Clone() { return new BooleanFunctions(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", _funcType.ToString()); - if (_arg != null) - { - _arg.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheAxisQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheAxisQuery.cs deleted file mode 100644 index afd6b7e2e28..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheAxisQuery.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections.Generic; - - internal abstract class CacheAxisQuery : BaseAxisQuery - { - // int count; -- we reusing it here - protected List outputBuffer; - - public CacheAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) - { - this.outputBuffer = new List(); - this.count = 0; - } - protected CacheAxisQuery(CacheAxisQuery other) : base(other) - { - this.outputBuffer = new List(other.outputBuffer); - this.count = other.count; - } - - public override void Reset() - { - this.count = 0; - } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - outputBuffer.Clear(); - return this; - } - - public override XPathNavigator Advance() - { - Debug.Assert(0 <= count && count <= outputBuffer.Count); - if (count < outputBuffer.Count) - { - return outputBuffer[count++]; - } - return null; - } - - public override XPathNavigator Current - { - get - { - Debug.Assert(0 <= count && count <= outputBuffer.Count); - if (count == 0) - { - return null; - } - return outputBuffer[count - 1]; - } - } - - public override int CurrentPosition { get { return count; } } - public override int Count { get { return outputBuffer.Count; } } - public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheChildrenQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheChildrenQuery.cs deleted file mode 100644 index 9e85df33f71..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheChildrenQuery.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections.Generic; - using StackInt = ClonableStack; - using StackNav = ClonableStack; - - // This class implements Children axis on Ancestor & Descendant imputs. (as well as id(), preciding, following) - // The problem here is that is descenant::*/child::* and ancestor::*/child::* can produce duplicates nodes - // The algorithm havily uses the fact that in our implementation of both AncestorQuery and DecsndantQuery return nodes in document order. - // As result first child is always before or equal of next input. - // So we don't need to call DecideNextNode() when needInput == true && stack is empty. - internal sealed class CacheChildrenQuery : ChildrenQuery - { - private XPathNavigator _nextInput = null; - private StackNav _elementStk; - private StackInt _positionStk; - private bool _needInput; -#if DEBUG - private XPathNavigator _lastNode = null; -#endif - - public CacheChildrenQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base(qyInput, name, prefix, type) - { - _elementStk = new StackNav(); - _positionStk = new StackInt(); - _needInput = true; - } - private CacheChildrenQuery(CacheChildrenQuery other) : base(other) - { - _nextInput = Clone(other._nextInput); - _elementStk = other._elementStk.Clone(); - _positionStk = other._positionStk.Clone(); - _needInput = other._needInput; -#if DEBUG - _lastNode = Clone(other._lastNode); -#endif - } - - public override void Reset() - { - _nextInput = null; - _elementStk.Clear(); - _positionStk.Clear(); - _needInput = true; - base.Reset(); -#if DEBUG - _lastNode = null; -#endif - } - - public override XPathNavigator Advance() - { - do - { - if (_needInput) - { - if (_elementStk.Count == 0) - { - currentNode = GetNextInput(); - if (currentNode == null) - { - return null; - } - if (!currentNode.MoveToFirstChild()) - { - continue; - } - position = 0; - } - else - { - currentNode = _elementStk.Pop(); - position = _positionStk.Pop(); - if (!DecideNextNode()) - { - continue; - } - } - _needInput = false; - } - else - { - if (!currentNode.MoveToNext() || !DecideNextNode()) - { - _needInput = true; - continue; - } - } -#if DEBUG - if (_lastNode != null) - { - if (currentNode.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator") - { - XmlNodeOrder order = CompareNodes(_lastNode, currentNode); - Debug.Assert(order == XmlNodeOrder.Before, "Algorith error. Nodes expected to be DocOrderDistinct"); - } - } - _lastNode = currentNode.Clone(); -#endif - if (matches(currentNode)) - { - position++; - return currentNode; - } - } while (true); - } // Advance - - private bool DecideNextNode() - { - _nextInput = GetNextInput(); - if (_nextInput != null) - { - if (CompareNodes(currentNode, _nextInput) == XmlNodeOrder.After) - { - _elementStk.Push(currentNode); - _positionStk.Push(position); - currentNode = _nextInput; - _nextInput = null; - if (!currentNode.MoveToFirstChild()) - { - return false; - } - position = 0; - } - } - return true; - } - - private XPathNavigator GetNextInput() - { - XPathNavigator result; - if (_nextInput != null) - { - result = _nextInput; - _nextInput = null; - } - else - { - result = qyInput.Advance(); - if (result != null) - { - result = result.Clone(); - } - } - return result; - } - - public override XPathNodeIterator Clone() { return new CacheChildrenQuery(this); } - } // Children Query} -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheOutputQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheOutputQuery.cs deleted file mode 100644 index b3010e958f3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CacheOutputQuery.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using Microsoft.Xml.Xsl; - using System.Collections.Generic; - - internal abstract class CacheOutputQuery : Query - { - internal Query input; - // int count; -- we reusing it here - protected List outputBuffer; - - public CacheOutputQuery(Query input) - { - this.input = input; - this.outputBuffer = new List(); - this.count = 0; - } - protected CacheOutputQuery(CacheOutputQuery other) : base(other) - { - this.input = Clone(other.input); - this.outputBuffer = new List(other.outputBuffer); - this.count = other.count; - } - - public override void Reset() - { - this.count = 0; - } - - public override void SetXsltContext(XsltContext context) - { - input.SetXsltContext(context); - } - - public override object Evaluate(XPathNodeIterator context) - { - outputBuffer.Clear(); - count = 0; - return input.Evaluate(context);// This is trick. IDQuery needs this value. Otherwise we would return this. - // All subclasses should and would anyway override thismethod and return this. - } - - public override XPathNavigator Advance() - { - Debug.Assert(0 <= count && count <= outputBuffer.Count); - if (count < outputBuffer.Count) - { - return outputBuffer[count++]; - } - return null; - } - - public override XPathNavigator Current - { - get - { - Debug.Assert(0 <= count && count <= outputBuffer.Count); - if (count == 0) - { - return null; - } - return outputBuffer[count - 1]; - } - } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - public override int CurrentPosition { get { return count; } } - public override int Count { get { return outputBuffer.Count; } } - public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - input.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ChildrenQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ChildrenQuery.cs deleted file mode 100644 index 0c6e0aff4a3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ChildrenQuery.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using System.Collections; - - internal class ChildrenQuery : BaseAxisQuery - { - private XPathNodeIterator _iterator = XPathEmptyIterator.Instance; - - public ChildrenQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base(qyInput, name, prefix, type) { } - protected ChildrenQuery(ChildrenQuery other) : base(other) - { - _iterator = Clone(other._iterator); - } - - public override void Reset() - { - _iterator = XPathEmptyIterator.Instance; - base.Reset(); - } - - public override XPathNavigator Advance() - { - while (!_iterator.MoveNext()) - { - XPathNavigator input = qyInput.Advance(); - if (input == null) - { - return null; - } - if (NameTest) - { - if (TypeTest == XPathNodeType.ProcessingInstruction) - { - _iterator = new IteratorFilter(input.SelectChildren(TypeTest), Name); - } - else - { - _iterator = input.SelectChildren(Name, Namespace); - } - } - else - { - _iterator = input.SelectChildren(TypeTest); - } - position = 0; - } - position++; - currentNode = _iterator.Current; - return currentNode; - } // Advance - - public sealed override XPathNavigator MatchNode(XPathNavigator context) - { - if (context != null) - { - if (matches(context)) - { - XPathNavigator temp = context.Clone(); - if (temp.NodeType != XPathNodeType.Attribute && temp.MoveToParent()) - { - return qyInput.MatchNode(temp); - } - return null; - } - } - return null; - } - - public override XPathNodeIterator Clone() { return new ChildrenQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ClonableStack.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ClonableStack.cs deleted file mode 100644 index beeb880a2ec..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ClonableStack.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal sealed class ClonableStack : System.Collections.Generic.List - { - public ClonableStack() { } - public ClonableStack(int capacity) : base(capacity) { } - - private ClonableStack(System.Collections.Generic.IEnumerable collection) : base(collection) { } - - public void Push(T value) - { - base.Add(value); - } - - public T Pop() - { - int last = base.Count - 1; - T result = base[last]; - base.RemoveAt(last); - return result; - } - - public T Peek() - { - return base[base.Count - 1]; - } - - public ClonableStack Clone() { return new ClonableStack(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CompiledXpathExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CompiledXpathExpr.cs deleted file mode 100644 index 6db7c3c19cd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/CompiledXpathExpr.cs +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - using Microsoft.Xml.Xsl; - - internal class CompiledXpathExpr : XPathExpression - { - private Query _query; - private string _expr; - private bool _needContext; - - internal CompiledXpathExpr(Query query, string expression, bool needContext) - { - _query = query; - _expr = expression; - _needContext = needContext; - } - - internal Query QueryTree - { - get - { - if (_needContext) - { - throw XPathException.Create(ResXml.Xp_NoContext); - } - return _query; - } - } - - public override string Expression - { - get { return _expr; } - } - - public virtual void CheckErrors() - { - Debug.Assert(_query != null, "In case of error in XPath we create ErrorXPathExpression"); - } - - public override void AddSort(object expr, IComparer comparer) - { - // sort makes sense only when we are dealing with a query that - // returns a nodeset. - Query evalExpr; - if (expr is string) - { - evalExpr = new QueryBuilder().Build((string)expr, out _needContext); // this will throw if expr is invalid - } - else if (expr is CompiledXpathExpr) - { - evalExpr = ((CompiledXpathExpr)expr).QueryTree; - } - else - { - throw XPathException.Create(ResXml.Xp_BadQueryObject); - } - SortQuery sortQuery = _query as SortQuery; - if (sortQuery == null) - { - _query = sortQuery = new SortQuery(_query); - } - sortQuery.AddSort(evalExpr, comparer); - } - - public override void AddSort(object expr, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType) - { - AddSort(expr, new XPathComparerHelper(order, caseOrder, lang, dataType)); - } - - public override XPathExpression Clone() - { - return new CompiledXpathExpr(Query.Clone(_query), _expr, _needContext); - } - - public override void SetContext(XmlNamespaceManager nsManager) - { - SetContext((IXmlNamespaceResolver)nsManager); - } - - public override void SetContext(IXmlNamespaceResolver nsResolver) - { - XsltContext xsltContext = nsResolver as XsltContext; - if (xsltContext == null) - { - if (nsResolver == null) - { - nsResolver = new XmlNamespaceManager(new NameTable()); - } - xsltContext = new UndefinedXsltContext(nsResolver); - } - _query.SetXsltContext(xsltContext); - - _needContext = false; - } - - public override XPathResultType ReturnType { get { return _query.StaticType; } } - - private class UndefinedXsltContext : XsltContext - { - private IXmlNamespaceResolver _nsResolver; - - public UndefinedXsltContext(IXmlNamespaceResolver nsResolver) : base(/*dummy*/false) - { - _nsResolver = nsResolver; - } - //----- Namespace support ----- - public override string DefaultNamespace - { - get { return string.Empty; } - } - public override string LookupNamespace(string prefix) - { - Debug.Assert(prefix != null); - if (prefix.Length == 0) - { - return string.Empty; - } - string ns = _nsResolver.LookupNamespace(prefix); - if (ns == null) - { - throw XPathException.Create(ResXml.XmlUndefinedAlias, prefix); - } - return ns; - } - //----- XsltContext support ----- - public override IXsltContextVariable ResolveVariable(string prefix, string name) - { - throw XPathException.Create(ResXml.Xp_UndefinedXsltContext); - } - public override IXsltContextFunction ResolveFunction(string prefix, string name, XPathResultType[] ArgTypes) - { - throw XPathException.Create(ResXml.Xp_UndefinedXsltContext); - } - public override bool Whitespace { get { return false; } } - public override bool PreserveWhitespace(XPathNavigator node) { return false; } - public override int CompareDocument(string baseUri, string nextbaseUri) - { - return string.CompareOrdinal(baseUri, nextbaseUri); - } - } - } - - internal sealed class XPathComparerHelper : IComparer - { - private XmlSortOrder _order; - private XmlCaseOrder _caseOrder; - private CultureInfo _cinfo; - private XmlDataType _dataType; - - public XPathComparerHelper(XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType) - { - if (lang == null) - { - _cinfo = CultureInfo.CurrentCulture; // System.Threading.Thread.CurrentThread.CurrentCulture; - } - else - { - try - { - _cinfo = new CultureInfo(lang); - } - catch (System.ArgumentException) - { - throw; // Throwing an XsltException would be a breaking change - } - } - - if (order == XmlSortOrder.Descending) - { - if (caseOrder == XmlCaseOrder.LowerFirst) - { - caseOrder = XmlCaseOrder.UpperFirst; - } - else if (caseOrder == XmlCaseOrder.UpperFirst) - { - caseOrder = XmlCaseOrder.LowerFirst; - } - } - - _order = order; - _caseOrder = caseOrder; - _dataType = dataType; - } - - public int Compare(object x, object y) - { - switch (_dataType) - { - case XmlDataType.Text: - string s1 = Convert.ToString(x, _cinfo); - string s2 = Convert.ToString(y, _cinfo); - int result = string.Compare(s1, s2, /*ignoreCase:*/ _caseOrder != XmlCaseOrder.None); //, this.cinfo); - - if (result != 0 || _caseOrder == XmlCaseOrder.None) - return (_order == XmlSortOrder.Ascending) ? result : -result; - - // If we came this far, it means that strings s1 and s2 are - // equal to each other when case is ignored. Now it's time to check - // and see if they differ in case only and take into account the user - // requested case order for sorting purposes. - result = string.Compare(s1, s2, /*ignoreCase:*/ false); //, this.cinfo); - return (_caseOrder == XmlCaseOrder.LowerFirst) ? result : -result; - - case XmlDataType.Number: - double r1 = XmlConvert.ToXPathDouble(x); - double r2 = XmlConvert.ToXPathDouble(y); - result = r1.CompareTo(r2); - return (_order == XmlSortOrder.Ascending) ? result : -result; - - default: - // dataType doesn't support any other value - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - } // Compare () - } // class XPathComparerHelper -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ContextQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ContextQuery.cs deleted file mode 100644 index 2e5306c53d1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ContextQuery.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal class ContextQuery : Query - { - protected XPathNavigator contextNode; - - public ContextQuery() - { - this.count = 0; - } - protected ContextQuery(ContextQuery other) : base(other) - { - this.contextNode = other.contextNode; // Don't need to clone here - } - public override void Reset() - { - count = 0; - } - - public override XPathNavigator Current { get { return contextNode; } } - - public override object Evaluate(XPathNodeIterator context) - { - contextNode = context.Current; // We don't clone here. Because we never move it. - count = 0; - return this; - } - - public override XPathNavigator Advance() - { - if (count == 0) - { - count = 1; - return contextNode; - } - return null; - } - - public override XPathNavigator MatchNode(XPathNavigator current) - { - return current; - } - - public override XPathNodeIterator Clone() { return new ContextQuery(this); } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - public override int CurrentPosition { get { return count; } } - public override int Count { get { return 1; } } - public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantBaseQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantBaseQuery.cs deleted file mode 100644 index cd3db1391e8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantBaseQuery.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal abstract class DescendantBaseQuery : BaseAxisQuery - { - protected bool matchSelf; - protected bool abbrAxis; - - public DescendantBaseQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type, bool matchSelf, bool abbrAxis) : base(qyParent, Name, Prefix, Type) - { - this.matchSelf = matchSelf; - this.abbrAxis = abbrAxis; - } - public DescendantBaseQuery(DescendantBaseQuery other) : base(other) - { - this.matchSelf = other.matchSelf; - this.abbrAxis = other.abbrAxis; - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - if (context != null) - { - if (!abbrAxis) - { - throw XPathException.Create(ResXml.Xp_InvalidPattern); - } - XPathNavigator result = null; - if (matches(context)) - { - if (matchSelf) - { - if ((result = qyInput.MatchNode(context)) != null) - { - return result; - } - } - - XPathNavigator anc = context.Clone(); - while (anc.MoveToParent()) - { - if ((result = qyInput.MatchNode(anc)) != null) - { - return result; - } - } - } - } - return null; - } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - if (matchSelf) - { - w.WriteAttributeString("self", "yes"); - } - if (NameTest) - { - w.WriteAttributeString("name", Prefix.Length != 0 ? Prefix + ':' + Name : Name); - } - if (TypeTest != XPathNodeType.Element) - { - w.WriteAttributeString("nodeType", TypeTest.ToString()); - } - qyInput.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantOverDescendantQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantOverDescendantQuery.cs deleted file mode 100644 index 9cf76688834..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantOverDescendantQuery.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - // DescendantOverDescendantQuery: for each input it looks for the topmost descendents that matches to ns:name - // This is posible when query which has this query as its input (child query) is descendent as well. - // Work of this query doesn't depend on DOD of its input. - // It doesn't garate DOD of the output even when input is DOD. - internal sealed class DescendantOverDescendantQuery : DescendantBaseQuery - { - private int _level = 0; - - public DescendantOverDescendantQuery(Query qyParent, bool matchSelf, string name, string prefix, XPathNodeType typeTest, bool abbrAxis) : - base(qyParent, name, prefix, typeTest, matchSelf, abbrAxis) - { } - private DescendantOverDescendantQuery(DescendantOverDescendantQuery other) : base(other) - { - _level = other._level; - } - - public override void Reset() - { - _level = 0; - base.Reset(); - } - - public override XPathNavigator Advance() - { - while (true) - { - if (_level == 0) - { - currentNode = qyInput.Advance(); - position = 0; - if (currentNode == null) - { - return null; - } - if (matchSelf && matches(currentNode)) - { - position = 1; - return currentNode; - } - currentNode = currentNode.Clone(); - if (!MoveToFirstChild()) - { - continue; - } - } - else - { - if (!MoveUpUntillNext()) - { - continue; - } - } - do - { - if (matches(currentNode)) - { - position++; - return currentNode; - } - } while (MoveToFirstChild()); - } - } - - private bool MoveToFirstChild() - { - if (currentNode.MoveToFirstChild()) - { - _level++; - return true; - } - return false; - } - - private bool MoveUpUntillNext() - { // move up untill we can move next - while (!currentNode.MoveToNext()) - { - --_level; - if (_level == 0) - { - return false; - } - bool result = currentNode.MoveToParent(); - Debug.Assert(result, "Algorithm error, We always should be able to move up if level > 0"); - } - return true; - } - - public override XPathNodeIterator Clone() { return new DescendantOverDescendantQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantQuery.cs deleted file mode 100644 index d691b0de664..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DescendantQuery.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal class DescendantQuery : DescendantBaseQuery - { - private XPathNodeIterator _nodeIterator; - - internal DescendantQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type, bool matchSelf, bool abbrAxis) - : base(qyParent, Name, Prefix, Type, matchSelf, abbrAxis) { } - - public DescendantQuery(DescendantQuery other) : base(other) - { - _nodeIterator = Clone(other._nodeIterator); - } - - public override void Reset() - { - _nodeIterator = null; - base.Reset(); - } - - public override XPathNavigator Advance() - { - while (true) - { - if (_nodeIterator == null) - { - position = 0; - XPathNavigator nav = qyInput.Advance(); - if (nav == null) - { - return null; - } - if (NameTest) - { - if (TypeTest == XPathNodeType.ProcessingInstruction) - { - _nodeIterator = new IteratorFilter(nav.SelectDescendants(TypeTest, matchSelf), Name); - } - else - { - _nodeIterator = nav.SelectDescendants(Name, Namespace, matchSelf); - } - } - else - { - _nodeIterator = nav.SelectDescendants(TypeTest, matchSelf); - } - } - - if (_nodeIterator.MoveNext()) - { - position++; - currentNode = _nodeIterator.Current; - return currentNode; - } - else - { - _nodeIterator = null; - } - } - } - - public override XPathNodeIterator Clone() { return new DescendantQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DocumentOrderQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DocumentOrderQuery.cs deleted file mode 100644 index a1c488e4784..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/DocumentOrderQuery.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal sealed class DocumentOrderQuery : CacheOutputQuery - { - public DocumentOrderQuery(Query qyParent) : base(qyParent) { } - private DocumentOrderQuery(DocumentOrderQuery other) : base(other) { } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - - XPathNavigator node; - while ((node = base.input.Advance()) != null) - { - Insert(outputBuffer, node); - } - - return this; - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - return input.MatchNode(context); - } - - public override XPathNodeIterator Clone() { return new DocumentOrderQuery(this); } - } -} - - - - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/EmptyQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/EmptyQuery.cs deleted file mode 100644 index 32160fa2c8e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/EmptyQuery.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using System.Collections; - - internal sealed class EmptyQuery : Query - { - public override XPathNavigator Advance() { return null; } - public override XPathNodeIterator Clone() { return this; } - public override object Evaluate(XPathNodeIterator context) { return this; } - public override int CurrentPosition { get { return 0; } } - public override int Count { get { return 0; } } - public override QueryProps Properties { get { return QueryProps.Merge | QueryProps.Cached | QueryProps.Position | QueryProps.Count; } } - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - public override void Reset() { } - public override XPathNavigator Current { get { return null; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ExtensionQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ExtensionQuery.cs deleted file mode 100644 index 18c1746ad8d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ExtensionQuery.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.Xsl; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - - internal abstract class ExtensionQuery : Query - { - protected string prefix; - protected string name; - protected XsltContext xsltContext; - private ResetableIterator _queryIterator; - - public ExtensionQuery(string prefix, string name) : base() - { - this.prefix = prefix; - this.name = name; - } - protected ExtensionQuery(ExtensionQuery other) : base(other) - { - this.prefix = other.prefix; - this.name = other.name; - this.xsltContext = other.xsltContext; - _queryIterator = (ResetableIterator)Clone(other._queryIterator); - } - - public override void Reset() - { - if (_queryIterator != null) - { - _queryIterator.Reset(); - } - } - - public override XPathNavigator Current - { - get - { - if (_queryIterator == null) - { - throw XPathException.Create(ResXml.Xp_NodeSetExpected); - } - if (_queryIterator.CurrentPosition == 0) - { - Advance(); - } - return _queryIterator.Current; - } - } - - public override XPathNavigator Advance() - { - if (_queryIterator == null) - { - throw XPathException.Create(ResXml.Xp_NodeSetExpected); - } - if (_queryIterator.MoveNext()) - { - return _queryIterator.Current; - } - return null; - } - - public override int CurrentPosition - { - get - { - if (_queryIterator != null) - { - return _queryIterator.CurrentPosition; - } - return 0; - } - } - - protected object ProcessResult(object value) - { - if (value is string) return value; - if (value is double) return value; - if (value is bool) return value; - if (value is XPathNavigator) return value; - if (value is Int32) return (double)(Int32)value; - - if (value == null) - { - _queryIterator = XPathEmptyIterator.Instance; - return this; // We map null to NodeSet to let $null/foo work well. - } - - ResetableIterator resetable = value as ResetableIterator; - if (resetable != null) - { - // We need Clone() value because variable may be used several times - // and they shouldn't - _queryIterator = (ResetableIterator)resetable.Clone(); - return this; - } - XPathNodeIterator nodeIterator = value as XPathNodeIterator; - if (nodeIterator != null) - { - _queryIterator = new XPathArrayIterator(nodeIterator); - return this; - } - IXPathNavigable navigable = value as IXPathNavigable; - if (navigable != null) - { - return navigable.CreateNavigator(); - } - - if (value is Int16) return (double)(Int16)value; - if (value is Int64) return (double)(Int64)value; - if (value is UInt32) return (double)(UInt32)value; - if (value is UInt16) return (double)(UInt16)value; - if (value is UInt64) return (double)(UInt64)value; - if (value is Single) return (double)(Single)value; - if (value is Decimal) return (double)(Decimal)value; - return value.ToString(); - } - - protected string QName { get { return prefix.Length != 0 ? prefix + ":" + name : name; } } - - public override int Count { get { return _queryIterator == null ? 1 : _queryIterator.Count; } } - public override XPathResultType StaticType { get { return XPathResultType.Any; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Filter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Filter.cs deleted file mode 100644 index 3335241474e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Filter.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class Filter : AstNode - { - private AstNode _input; - private AstNode _condition; - - public Filter(AstNode input, AstNode condition) - { - _input = input; - _condition = condition; - } - - public override AstType Type { get { return AstType.Filter; } } - public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; } } - - public AstNode Input { get { return _input; } } - public AstNode Condition { get { return _condition; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FilterQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FilterQuery.cs deleted file mode 100644 index fea16ca0eb8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FilterQuery.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - - internal sealed class FilterQuery : BaseAxisQuery - { - private Query _cond; - private bool _noPosition; - - public FilterQuery(Query qyParent, Query cond, bool noPosition) : base(qyParent) - { - _cond = cond; - _noPosition = noPosition; - } - private FilterQuery(FilterQuery other) : base(other) - { - _cond = Clone(other._cond); - _noPosition = other._noPosition; - } - - public override void Reset() - { - _cond.Reset(); - base.Reset(); - } - - public Query Condition { get { return _cond; } } - - public override void SetXsltContext(XsltContext input) - { - base.SetXsltContext(input); - _cond.SetXsltContext(input); - if (_cond.StaticType != XPathResultType.Number && _cond.StaticType != XPathResultType.Any && _noPosition) - { - // BugBug: We can do such trick at Evaluate time only. - // But to do this FilterQuery should stop inherit from BaseAxisQuery - ReversePositionQuery query = qyInput as ReversePositionQuery; - if (query != null) - { - qyInput = query.input; - } - } - } - - public override XPathNavigator Advance() - { - while ((currentNode = qyInput.Advance()) != null) - { - if (EvaluatePredicate()) - { - position++; - return currentNode; - } - } - return null; - } - - internal bool EvaluatePredicate() - { - object value = _cond.Evaluate(qyInput); - if (value is XPathNodeIterator) return _cond.Advance() != null; - if (value is string) return ((string)value).Length != 0; - if (value is double) return (((double)value) == qyInput.CurrentPosition); - if (value is bool) return (bool)value; - Debug.Assert(value is XPathNavigator, "Unknown value type"); - return true; - } - - public override XPathNavigator MatchNode(XPathNavigator current) - { - XPathNavigator context; - if (current == null) - { - return null; - } - context = qyInput.MatchNode(current); - - if (context != null) - { - // In this switch we process some special case in wich we can calculate predicate faster then in generic case - switch (_cond.StaticType) - { - case XPathResultType.Number: - OperandQuery operand = _cond as OperandQuery; - if (operand != null) - { - double val = (double)operand.val; - ChildrenQuery childrenQuery = qyInput as ChildrenQuery; - if (childrenQuery != null) - { // foo[2], but not foo[expr][2] - XPathNavigator result = current.Clone(); - result.MoveToParent(); - int i = 0; - result.MoveToFirstChild(); - do - { - if (childrenQuery.matches(result)) - { - i++; - if (current.IsSamePosition(result)) - { - return val == i ? context : null; - } - } - } while (result.MoveToNext()); - return null; - } - AttributeQuery attributeQuery = qyInput as AttributeQuery; - if (attributeQuery != null) - {// @foo[3], but not @foo[expr][2] - XPathNavigator result = current.Clone(); - result.MoveToParent(); - int i = 0; - result.MoveToFirstAttribute(); - do - { - if (attributeQuery.matches(result)) - { - i++; - if (current.IsSamePosition(result)) - { - return val == i ? context : null; - } - } - } while (result.MoveToNextAttribute()); - return null; - } - } - break; - case XPathResultType.NodeSet: - _cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true)); - return (_cond.Advance() != null) ? context : null; - case XPathResultType.Boolean: - if (_noPosition) - { - return ((bool)_cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true))) ? context : null; - } - break; - case XPathResultType.String: - if (_noPosition) - { - return (((string)_cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true))).Length != 0) ? context : null; - } - break; - case XPathResultType_Navigator: - return context; - default: - return null; - } - /* Generic case */ - { - Evaluate(new XPathSingletonIterator(context, /*moved:*/true)); - XPathNavigator result; - while ((result = Advance()) != null) - { - if (result.IsSamePosition(current)) - { - return context; - } - } - } - } - return null; - } - - public override QueryProps Properties - { - get - { - return QueryProps.Position | (qyInput.Properties & (QueryProps.Merge | QueryProps.Reverse)); - } - } - - public override XPathNodeIterator Clone() { return new FilterQuery(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - if (!_noPosition - ) - { - w.WriteAttributeString("position", "yes"); - } - qyInput.PrintQuery(w); - _cond.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ForwardPositionQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ForwardPositionQuery.cs deleted file mode 100644 index d7a3f2c00aa..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ForwardPositionQuery.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal class ForwardPositionQuery : CacheOutputQuery - { - public ForwardPositionQuery(Query input) : base(input) - { - Debug.Assert(input != null); - } - protected ForwardPositionQuery(ForwardPositionQuery other) : base(other) { } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - - XPathNavigator node; - while ((node = base.input.Advance()) != null) - { - outputBuffer.Add(node.Clone()); - } - - return this; - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - return input.MatchNode(context); - } - - public override XPathNodeIterator Clone() { return new ForwardPositionQuery(this); } - } -} - - - - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Function.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Function.cs deleted file mode 100644 index 69e9fe3a666..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Function.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections; - - internal class Function : AstNode - { - public enum FunctionType - { - FuncLast, - FuncPosition, - FuncCount, - FuncID, - FuncLocalName, - FuncNameSpaceUri, - FuncName, - FuncString, - FuncBoolean, - FuncNumber, - FuncTrue, - FuncFalse, - FuncNot, - FuncConcat, - FuncStartsWith, - FuncContains, - FuncSubstringBefore, - FuncSubstringAfter, - FuncSubstring, - FuncStringLength, - FuncNormalize, - FuncTranslate, - FuncLang, - FuncSum, - FuncFloor, - FuncCeiling, - FuncRound, - FuncUserDefined, - }; - - private FunctionType _functionType; - private ArrayList _argumentList; - - private string _name = null; - private string _prefix = null; - - public Function(FunctionType ftype, ArrayList argumentList) - { - _functionType = ftype; - _argumentList = new ArrayList(argumentList); - } - - public Function(string prefix, string name, ArrayList argumentList) - { - _functionType = FunctionType.FuncUserDefined; - _prefix = prefix; - _name = name; - _argumentList = new ArrayList(argumentList); - } - - public Function(FunctionType ftype) - { - _functionType = ftype; - } - - public Function(FunctionType ftype, AstNode arg) - { - _functionType = ftype; - _argumentList = new ArrayList(); - _argumentList.Add(arg); - } - - public override AstType Type { get { return AstType.Function; } } - - public override XPathResultType ReturnType - { - get - { - return ReturnTypes[(int)_functionType]; - } - } - - public FunctionType TypeOfFunction { get { return _functionType; } } - public ArrayList ArgumentList { get { return _argumentList; } } - public string Prefix { get { return _prefix; } } - public string Name { get { return _name; } } - - internal static XPathResultType[] ReturnTypes = { - /* FunctionType.FuncLast */ XPathResultType.Number , - /* FunctionType.FuncPosition */ XPathResultType.Number , - /* FunctionType.FuncCount */ XPathResultType.Number , - /* FunctionType.FuncID */ XPathResultType.NodeSet, - /* FunctionType.FuncLocalName */ XPathResultType.String , - /* FunctionType.FuncNameSpaceUri */ XPathResultType.String , - /* FunctionType.FuncName */ XPathResultType.String , - /* FunctionType.FuncString */ XPathResultType.String , - /* FunctionType.FuncBoolean */ XPathResultType.Boolean, - /* FunctionType.FuncNumber */ XPathResultType.Number , - /* FunctionType.FuncTrue */ XPathResultType.Boolean, - /* FunctionType.FuncFalse */ XPathResultType.Boolean, - /* FunctionType.FuncNot */ XPathResultType.Boolean, - /* FunctionType.FuncConcat */ XPathResultType.String , - /* FunctionType.FuncStartsWith */ XPathResultType.Boolean, - /* FunctionType.FuncContains */ XPathResultType.Boolean, - /* FunctionType.FuncSubstringBefore */ XPathResultType.String , - /* FunctionType.FuncSubstringAfter */ XPathResultType.String , - /* FunctionType.FuncSubstring */ XPathResultType.String , - /* FunctionType.FuncStringLength */ XPathResultType.Number , - /* FunctionType.FuncNormalize */ XPathResultType.String , - /* FunctionType.FuncTranslate */ XPathResultType.String , - /* FunctionType.FuncLang */ XPathResultType.Boolean, - /* FunctionType.FuncSum */ XPathResultType.Number , - /* FunctionType.FuncFloor */ XPathResultType.Number , - /* FunctionType.FuncCeiling */ XPathResultType.Number , - /* FunctionType.FuncRound */ XPathResultType.Number , - /* FunctionType.FuncUserDefined */ XPathResultType.Any - }; - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FunctionQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FunctionQuery.cs deleted file mode 100644 index 9ca123a200b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/FunctionQuery.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.Xsl; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections.Generic; - - internal sealed class FunctionQuery : ExtensionQuery - { - private IList _args; - private IXsltContextFunction _function; - - public FunctionQuery(string prefix, string name, List args) : base(prefix, name) - { - _args = args; - } - private FunctionQuery(FunctionQuery other) : base(other) - { - _function = other._function; - Query[] tmp = new Query[other._args.Count]; - { - for (int i = 0; i < tmp.Length; i++) - { - tmp[i] = Clone(other._args[i]); - } - _args = tmp; - } - _args = tmp; - } - - public override void SetXsltContext(XsltContext context) - { - if (context == null) - { - throw XPathException.Create(ResXml.Xp_NoContext); - } - if (this.xsltContext != context) - { - xsltContext = context; - foreach (Query argument in _args) - { - argument.SetXsltContext(context); - } - XPathResultType[] argTypes = new XPathResultType[_args.Count]; - for (int i = 0; i < _args.Count; i++) - { - argTypes[i] = _args[i].StaticType; - } - _function = xsltContext.ResolveFunction(prefix, name, argTypes); - // KB article allows to return null, see http://support.microsoft.com/?kbid=324462#6 - if (_function == null) - { - throw XPathException.Create(ResXml.Xp_UndefFunc, QName); - } - } - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - if (xsltContext == null) - { - throw XPathException.Create(ResXml.Xp_NoContext); - } - - // calculate arguments: - object[] argVals = new object[_args.Count]; - for (int i = 0; i < _args.Count; i++) - { - argVals[i] = _args[i].Evaluate(nodeIterator); - if (argVals[i] is XPathNodeIterator) - {// ForBack Compat. To protect our queries from users. bug#372077 & 20006123 - argVals[i] = new XPathSelectionIterator(nodeIterator.Current, _args[i]); - } - } - try - { - return ProcessResult(_function.Invoke(xsltContext, argVals, nodeIterator.Current)); - } - catch (Exception ex) - { - throw XPathException.Create(ResXml.Xp_FunctionFailed, QName, ex); - } - } - - public override XPathNavigator MatchNode(XPathNavigator navigator) - { - if (name != "key" && prefix.Length != 0) - { - throw XPathException.Create(ResXml.Xp_InvalidPattern); - } - this.Evaluate(new XPathSingletonIterator(navigator, /*moved:*/true)); - XPathNavigator nav = null; - while ((nav = this.Advance()) != null) - { - if (nav.IsSamePosition(navigator)) - { - return nav; - } - } - return nav; - } - - public override XPathResultType StaticType - { - get - { - XPathResultType result = _function != null ? _function.ReturnType : XPathResultType.Any; - if (result == XPathResultType.Error) - { - // In v.1 we confused Error & Any so now for backward compatibility we should allow users to return any of them. - result = XPathResultType.Any; - } - return result; - } - } - - public override XPathNodeIterator Clone() { return new FunctionQuery(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", prefix.Length != 0 ? prefix + ':' + name : name); - foreach (Query arg in _args) - { - arg.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Group.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Group.cs deleted file mode 100644 index 0d3e1f05cc0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Group.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - internal class Group : AstNode - { - private AstNode _groupNode; - - public Group(AstNode groupNode) - { - _groupNode = groupNode; - } - public override AstType Type { get { return AstType.Group; } } - public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; } } - - public AstNode GroupNode { get { return _groupNode; } } - } -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/GroupQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/GroupQuery.cs deleted file mode 100644 index a54c84f9364..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/GroupQuery.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal sealed class GroupQuery : BaseAxisQuery - { - public GroupQuery(Query qy) : base(qy) { } - private GroupQuery(GroupQuery other) : base(other) { } - - public override XPathNavigator Advance() - { - currentNode = qyInput.Advance(); - if (currentNode != null) - { - position++; - } - return currentNode; - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - return qyInput.Evaluate(nodeIterator); - } - - public override XPathNodeIterator Clone() { return new GroupQuery(this); } - public override XPathResultType StaticType { get { return qyInput.StaticType; } } - public override QueryProps Properties { get { return QueryProps.Position; } } // Doesn't have QueryProps.Merge - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IDQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IDQuery.cs deleted file mode 100644 index 83232255d0f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IDQuery.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Diagnostics; - using System.Collections.Generic; - - internal sealed class IDQuery : CacheOutputQuery - { - public IDQuery(Query arg) : base(arg) { } - private IDQuery(IDQuery other) : base(other) { } - - public override object Evaluate(XPathNodeIterator context) - { - object argVal = base.Evaluate(context); - XPathNavigator contextNode = context.Current.Clone(); - - switch (GetXPathType(argVal)) - { - case XPathResultType.NodeSet: - XPathNavigator temp; - while ((temp = input.Advance()) != null) - { - ProcessIds(contextNode, temp.Value); - } - break; - case XPathResultType.String: - ProcessIds(contextNode, (string)argVal); - break; - case XPathResultType.Number: - ProcessIds(contextNode, StringFunctions.toString((double)argVal)); - break; - case XPathResultType.Boolean: - ProcessIds(contextNode, StringFunctions.toString((bool)argVal)); - break; - case XPathResultType_Navigator: - ProcessIds(contextNode, ((XPathNavigator)argVal).Value); - break; - } - return this; - } - - private void ProcessIds(XPathNavigator contextNode, string val) - { - string[] ids = XmlConvert.SplitString(val); - for (int idx = 0; idx < ids.Length; idx++) - { - if (contextNode.MoveToId(ids[idx])) - { - Insert(outputBuffer, contextNode); - } - } - } - - public override XPathNavigator MatchNode(XPathNavigator context) - { - Evaluate(new XPathSingletonIterator(context, /*moved:*/true)); - XPathNavigator result; - while ((result = Advance()) != null) - { - if (result.IsSamePosition(context)) - { - return context; - } - } - return null; - } - - public override XPathNodeIterator Clone() { return new IDQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IteratorFilter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IteratorFilter.cs deleted file mode 100644 index 578c5ebb464..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/IteratorFilter.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class IteratorFilter : XPathNodeIterator - { - private XPathNodeIterator _innerIterator; - private string _name; - private int _position = 0; - - internal IteratorFilter(XPathNodeIterator innerIterator, string name) - { - _innerIterator = innerIterator; - _name = name; - } - - private IteratorFilter(IteratorFilter it) - { - _innerIterator = it._innerIterator.Clone(); - _name = it._name; - _position = it._position; - } - - public override XPathNodeIterator Clone() { return new IteratorFilter(this); } - public override XPathNavigator Current { get { return _innerIterator.Current; } } - public override int CurrentPosition { get { return _position; } } - - public override bool MoveNext() - { - while (_innerIterator.MoveNext()) - { - if (_innerIterator.Current.LocalName == _name) - { - _position++; - return true; - } - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/LogicalExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/LogicalExpr.cs deleted file mode 100644 index 1278d3c3d4a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/LogicalExpr.cs +++ /dev/null @@ -1,446 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - - internal sealed class LogicalExpr : ValueQuery - { - private Operator.Op _op; - private Query _opnd1; - private Query _opnd2; - - public LogicalExpr(Operator.Op op, Query opnd1, Query opnd2) - { - Debug.Assert( - Operator.Op.LT == op || Operator.Op.GT == op || - Operator.Op.LE == op || Operator.Op.GE == op || - Operator.Op.EQ == op || Operator.Op.NE == op - ); - _op = op; - _opnd1 = opnd1; - _opnd2 = opnd2; - } - private LogicalExpr(LogicalExpr other) : base(other) - { - _op = other._op; - _opnd1 = Clone(other._opnd1); - _opnd2 = Clone(other._opnd2); - } - - public override void SetXsltContext(XsltContext context) - { - _opnd1.SetXsltContext(context); - _opnd2.SetXsltContext(context); - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - Operator.Op op = _op; - object val1 = _opnd1.Evaluate(nodeIterator); - object val2 = _opnd2.Evaluate(nodeIterator); - int type1 = (int)GetXPathType(val1); - int type2 = (int)GetXPathType(val2); - if (type1 < type2) - { - op = Operator.InvertOperator(op); - object valTemp = val1; - val1 = val2; - val2 = valTemp; - int typeTmp = type1; - type1 = type2; - type2 = typeTmp; - } - - if (op == Operator.Op.EQ || op == Operator.Op.NE) - { - return s_compXsltE[type1][type2](op, val1, val2); - } - else - { - return s_compXsltO[type1][type2](op, val1, val2); - } - } - - private delegate bool cmpXslt(Operator.Op op, object val1, object val2); - - // Number, String, Boolean, NodeSet, Navigator - private static readonly cmpXslt[][] s_compXsltE = { - new cmpXslt[] { new cmpXslt(cmpNumberNumber), null , null , null , null }, - new cmpXslt[] { new cmpXslt(cmpStringNumber), new cmpXslt(cmpStringStringE), null , null , null }, - new cmpXslt[] { new cmpXslt(cmpBoolNumberE ), new cmpXslt(cmpBoolStringE ), new cmpXslt(cmpBoolBoolE ), null , null }, - new cmpXslt[] { new cmpXslt(cmpQueryNumber ), new cmpXslt(cmpQueryStringE ), new cmpXslt(cmpQueryBoolE ), new cmpXslt(cmpQueryQueryE ), null }, - new cmpXslt[] { new cmpXslt(cmpRtfNumber ), new cmpXslt(cmpRtfStringE ), new cmpXslt(cmpRtfBoolE ), new cmpXslt(cmpRtfQueryE ), new cmpXslt(cmpRtfRtfE) }, - }; - private static readonly cmpXslt[][] s_compXsltO = { - new cmpXslt[] { new cmpXslt(cmpNumberNumber), null , null , null , null }, - new cmpXslt[] { new cmpXslt(cmpStringNumber), new cmpXslt(cmpStringStringO), null , null , null }, - new cmpXslt[] { new cmpXslt(cmpBoolNumberO ), new cmpXslt(cmpBoolStringO ), new cmpXslt(cmpBoolBoolO ), null , null }, - new cmpXslt[] { new cmpXslt(cmpQueryNumber ), new cmpXslt(cmpQueryStringO ), new cmpXslt(cmpQueryBoolO ), new cmpXslt(cmpQueryQueryO ), null }, - new cmpXslt[] { new cmpXslt(cmpRtfNumber ), new cmpXslt(cmpRtfStringO ), new cmpXslt(cmpRtfBoolO ), new cmpXslt(cmpRtfQueryO ), new cmpXslt(cmpRtfRtfO) }, - }; - - /*cmpXslt:*/ - private static bool cmpQueryQueryE(Operator.Op op, object val1, object val2) - { - Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE); - bool isEQ = (op == Operator.Op.EQ); - - NodeSet n1 = new NodeSet(val1); - NodeSet n2 = new NodeSet(val2); - - while (true) - { - if (!n1.MoveNext()) - { - return false; - } - if (!n2.MoveNext()) - { - return false; - } - - string str1 = n1.Value; - - do - { - if ((str1 == n2.Value) == isEQ) - { - return true; - } - } while (n2.MoveNext()); - n2.Reset(); - } - } - - /*cmpXslt:*/ - private static bool cmpQueryQueryO(Operator.Op op, object val1, object val2) - { - Debug.Assert( - op == Operator.Op.LT || op == Operator.Op.GT || - op == Operator.Op.LE || op == Operator.Op.GE - ); - - NodeSet n1 = new NodeSet(val1); - NodeSet n2 = new NodeSet(val2); - - while (true) - { - if (!n1.MoveNext()) - { - return false; - } - if (!n2.MoveNext()) - { - return false; - } - - double num1 = NumberFunctions.Number(n1.Value); - - do - { - if (cmpNumberNumber(op, num1, NumberFunctions.Number(n2.Value))) - { - return true; - } - } while (n2.MoveNext()); - n2.Reset(); - } - } - private static bool cmpQueryNumber(Operator.Op op, object val1, object val2) - { - NodeSet n1 = new NodeSet(val1); - double n2 = (double)val2; - - while (n1.MoveNext()) - { - if (cmpNumberNumber(op, NumberFunctions.Number(n1.Value), n2)) - { - return true; - } - } - return false; - } - - private static bool cmpQueryStringE(Operator.Op op, object val1, object val2) - { - NodeSet n1 = new NodeSet(val1); - string n2 = (string)val2; - - while (n1.MoveNext()) - { - if (cmpStringStringE(op, n1.Value, n2)) - { - return true; - } - } - return false; - } - - private static bool cmpQueryStringO(Operator.Op op, object val1, object val2) - { - NodeSet n1 = new NodeSet(val1); - double n2 = NumberFunctions.Number((string)val2); - - while (n1.MoveNext()) - { - if (cmpNumberNumberO(op, NumberFunctions.Number(n1.Value), n2)) - { - return true; - } - } - return false; - } - - private static bool cmpRtfQueryE(Operator.Op op, object val1, object val2) - { - string n1 = Rtf(val1); - NodeSet n2 = new NodeSet(val2); - - while (n2.MoveNext()) - { - if (cmpStringStringE(op, n1, n2.Value)) - { - return true; - } - } - return false; - } - - private static bool cmpRtfQueryO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number(Rtf(val1)); - NodeSet n2 = new NodeSet(val2); - - while (n2.MoveNext()) - { - if (cmpNumberNumberO(op, n1, NumberFunctions.Number(n2.Value))) - { - return true; - } - } - return false; - } - - private static bool cmpQueryBoolE(Operator.Op op, object val1, object val2) - { - NodeSet n1 = new NodeSet(val1); - bool b1 = n1.MoveNext(); - bool b2 = (bool)val2; - return cmpBoolBoolE(op, b1, b2); - } - - private static bool cmpQueryBoolO(Operator.Op op, object val1, object val2) - { - NodeSet n1 = new NodeSet(val1); - double d1 = n1.MoveNext() ? 1.0 : 0; - double d2 = NumberFunctions.Number((bool)val2); - return cmpNumberNumberO(op, d1, d2); - } - - private static bool cmpBoolBoolE(Operator.Op op, bool n1, bool n2) - { - Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE, - "Unexpected Operator.op code in cmpBoolBoolE()" - ); - return (op == Operator.Op.EQ) == (n1 == n2); - } - private static bool cmpBoolBoolE(Operator.Op op, object val1, object val2) - { - bool n1 = (bool)val1; - bool n2 = (bool)val2; - return cmpBoolBoolE(op, n1, n2); - } - - private static bool cmpBoolBoolO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number((bool)val1); - double n2 = NumberFunctions.Number((bool)val2); - return cmpNumberNumberO(op, n1, n2); - } - - private static bool cmpBoolNumberE(Operator.Op op, object val1, object val2) - { - bool n1 = (bool)val1; - bool n2 = BooleanFunctions.toBoolean((double)val2); - return cmpBoolBoolE(op, n1, n2); - } - - private static bool cmpBoolNumberO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number((bool)val1); - double n2 = (double)val2; - return cmpNumberNumberO(op, n1, n2); - } - - private static bool cmpBoolStringE(Operator.Op op, object val1, object val2) - { - bool n1 = (bool)val1; - bool n2 = BooleanFunctions.toBoolean((string)val2); - return cmpBoolBoolE(op, n1, n2); - } - - private static bool cmpRtfBoolE(Operator.Op op, object val1, object val2) - { - bool n1 = BooleanFunctions.toBoolean(Rtf(val1)); - bool n2 = (bool)val2; - return cmpBoolBoolE(op, n1, n2); - } - - private static bool cmpBoolStringO(Operator.Op op, object val1, object val2) - { - return cmpNumberNumberO(op, - NumberFunctions.Number((bool)val1), - NumberFunctions.Number((string)val2) - ); - } - - private static bool cmpRtfBoolO(Operator.Op op, object val1, object val2) - { - return cmpNumberNumberO(op, - NumberFunctions.Number(Rtf(val1)), - NumberFunctions.Number((bool)val2) - ); - } - - private static bool cmpNumberNumber(Operator.Op op, double n1, double n2) - { - switch (op) - { - case Operator.Op.LT: return (n1 < n2); - case Operator.Op.GT: return (n1 > n2); - case Operator.Op.LE: return (n1 <= n2); - case Operator.Op.GE: return (n1 >= n2); - case Operator.Op.EQ: return (n1 == n2); - case Operator.Op.NE: return (n1 != n2); - } - Debug.Fail("Unexpected Operator.op code in cmpNumberNumber()"); - return false; - } - private static bool cmpNumberNumberO(Operator.Op op, double n1, double n2) - { - switch (op) - { - case Operator.Op.LT: return (n1 < n2); - case Operator.Op.GT: return (n1 > n2); - case Operator.Op.LE: return (n1 <= n2); - case Operator.Op.GE: return (n1 >= n2); - } - Debug.Fail("Unexpected Operator.op code in cmpNumberNumberO()"); - return false; - } - private static bool cmpNumberNumber(Operator.Op op, object val1, object val2) - { - double n1 = (double)val1; - double n2 = (double)val2; - return cmpNumberNumber(op, n1, n2); - } - - private static bool cmpStringNumber(Operator.Op op, object val1, object val2) - { - double n2 = (double)val2; - double n1 = NumberFunctions.Number((string)val1); - return cmpNumberNumber(op, n1, n2); - } - - private static bool cmpRtfNumber(Operator.Op op, object val1, object val2) - { - double n2 = (double)val2; - double n1 = NumberFunctions.Number(Rtf(val1)); - return cmpNumberNumber(op, n1, n2); - } - - private static bool cmpStringStringE(Operator.Op op, string n1, string n2) - { - Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE, - "Unexpected Operator.op code in cmpStringStringE()" - ); - return (op == Operator.Op.EQ) == (n1 == n2); - } - private static bool cmpStringStringE(Operator.Op op, object val1, object val2) - { - string n1 = (string)val1; - string n2 = (string)val2; - return cmpStringStringE(op, n1, n2); - } - private static bool cmpRtfStringE(Operator.Op op, object val1, object val2) - { - string n1 = Rtf(val1); - string n2 = (string)val2; - return cmpStringStringE(op, n1, n2); - } - private static bool cmpRtfRtfE(Operator.Op op, object val1, object val2) - { - string n1 = Rtf(val1); - string n2 = Rtf(val2); - return cmpStringStringE(op, n1, n2); - } - - private static bool cmpStringStringO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number((string)val1); - double n2 = NumberFunctions.Number((string)val2); - return cmpNumberNumberO(op, n1, n2); - } - - private static bool cmpRtfStringO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number(Rtf(val1)); - double n2 = NumberFunctions.Number((string)val2); - return cmpNumberNumberO(op, n1, n2); - } - - private static bool cmpRtfRtfO(Operator.Op op, object val1, object val2) - { - double n1 = NumberFunctions.Number(Rtf(val1)); - double n2 = NumberFunctions.Number(Rtf(val2)); - return cmpNumberNumberO(op, n1, n2); - } - - public override XPathNodeIterator Clone() { return new LogicalExpr(this); } - - private struct NodeSet - { - private Query _opnd; - private XPathNavigator _current; - - public NodeSet(object opnd) - { - _opnd = (Query)opnd; - _current = null; - } - public bool MoveNext() - { - _current = _opnd.Advance(); - return _current != null; - } - - public void Reset() - { - _opnd.Reset(); - } - - public string Value { get { return _current.Value; } } - } - - private static string Rtf(object o) { return ((XPathNavigator)o).Value; } - - public override XPathResultType StaticType { get { return XPathResultType.Boolean; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("op", _op.ToString()); - _opnd1.PrintQuery(w); - _opnd2.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/MergeFilterQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/MergeFilterQuery.cs deleted file mode 100644 index c7eeb71898e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/MergeFilterQuery.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using Microsoft.Xml.Xsl; - using System.Collections.Generic; - - internal sealed class MergeFilterQuery : CacheOutputQuery - { - private Query _child; - - public MergeFilterQuery(Query input, Query child) : base(input) - { - _child = child; - } - private MergeFilterQuery(MergeFilterQuery other) : base(other) - { - _child = Clone(other._child); - } - - public override void SetXsltContext(XsltContext xsltContext) - { - base.SetXsltContext(xsltContext); - _child.SetXsltContext(xsltContext); - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - base.Evaluate(nodeIterator); - - while (input.Advance() != null) - { - _child.Evaluate(input); - XPathNavigator node; - while ((node = _child.Advance()) != null) - { - Insert(outputBuffer, node); - } - } - return this; - } - - public override XPathNavigator MatchNode(XPathNavigator current) - { - XPathNavigator context = _child.MatchNode(current); - if (context == null) - { - return null; - } - context = input.MatchNode(context); - if (context == null) - { - return null; - } - Evaluate(new XPathSingletonIterator(context.Clone(), /*moved:*/true)); - XPathNavigator result = Advance(); - while (result != null) - { - if (result.IsSamePosition(current)) - { - return context; - } - result = Advance(); - } - return null; - } - - public override XPathNodeIterator Clone() { return new MergeFilterQuery(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - input.PrintQuery(w); - _child.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NamespaceQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NamespaceQuery.cs deleted file mode 100644 index d1e4d2b87de..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NamespaceQuery.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal sealed class NamespaceQuery : BaseAxisQuery - { - private bool _onNamespace; - - public NamespaceQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) { } - private NamespaceQuery(NamespaceQuery other) : base(other) - { - _onNamespace = other._onNamespace; - } - - public override void Reset() - { - _onNamespace = false; - base.Reset(); - } - - public override XPathNavigator Advance() - { - while (true) - { - if (!_onNamespace) - { - currentNode = qyInput.Advance(); - if (currentNode == null) - { - return null; - } - position = 0; - currentNode = currentNode.Clone(); - _onNamespace = currentNode.MoveToFirstNamespace(); - } - else - { - _onNamespace = currentNode.MoveToNextNamespace(); - } - - if (_onNamespace) - { - if (matches(currentNode)) - { - position++; - return currentNode; - } - } - } // while - } // Advance - - public override bool matches(XPathNavigator e) - { - Debug.Assert(e.NodeType == XPathNodeType.Namespace); - if (e.Value.Length == 0) - { - Debug.Assert(e.LocalName.Length == 0, "Only xmlns='' can have empty string as a value"); - // Namespace axes never returns xmlns='', - // because it's not a NS declaration but rather undeclaration. - return false; - } - if (NameTest) - { - return Name.Equals(e.LocalName); - } - else - { - return true; - } - } - - public override XPathNodeIterator Clone() { return new NamespaceQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NodeFunctions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NodeFunctions.cs deleted file mode 100644 index 0d53485df47..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NodeFunctions.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using FT = MS.Internal.Xml.XPath.Function.FunctionType; - - internal sealed class NodeFunctions : ValueQuery - { - private Query _arg = null; - private FT _funcType; - private XsltContext _xsltContext; - - public NodeFunctions(FT funcType, Query arg) - { - _funcType = funcType; - _arg = arg; - } - - public override void SetXsltContext(XsltContext context) - { - _xsltContext = context.Whitespace ? context : null; - if (_arg != null) - { - _arg.SetXsltContext(context); - } - } - - private XPathNavigator EvaluateArg(XPathNodeIterator context) - { - if (_arg == null) - { - return context.Current; - } - _arg.Evaluate(context); - return _arg.Advance(); - } - - public override object Evaluate(XPathNodeIterator context) - { - XPathNavigator argVal; - - switch (_funcType) - { - case FT.FuncPosition: - return (double)context.CurrentPosition; - case FT.FuncLast: - return (double)context.Count; - case FT.FuncNameSpaceUri: - argVal = EvaluateArg(context); - if (argVal != null) - { - return argVal.NamespaceURI; - } - break; - case FT.FuncLocalName: - argVal = EvaluateArg(context); - if (argVal != null) - { - return argVal.LocalName; - } - break; - case FT.FuncName: - argVal = EvaluateArg(context); - if (argVal != null) - { - return argVal.Name; - } - break; - case FT.FuncCount: - _arg.Evaluate(context); - int count = 0; - if (_xsltContext != null) - { - XPathNavigator nav; - while ((nav = _arg.Advance()) != null) - { - if (nav.NodeType != XPathNodeType.Whitespace || _xsltContext.PreserveWhitespace(nav)) - { - count++; - } - } - } - else - { - while (_arg.Advance() != null) - { - count++; - } - } - return (double)count; - } - return string.Empty; - } - - public override XPathResultType StaticType { get { return Function.ReturnTypes[(int)_funcType]; } } - - public override XPathNodeIterator Clone() - { - NodeFunctions method = new NodeFunctions(_funcType, Clone(_arg)); - method._xsltContext = _xsltContext; - return method; - } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", _funcType.ToString()); - if (_arg != null) - { - _arg.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumberFunctions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumberFunctions.cs deleted file mode 100644 index 06031eab1a7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumberFunctions.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using System.Text; - using FT = MS.Internal.Xml.XPath.Function.FunctionType; - - internal sealed class NumberFunctions : ValueQuery - { - private Query _arg = null; - private FT _ftype; - - public NumberFunctions(FT ftype, Query arg) - { - _arg = arg; - _ftype = ftype; - } - private NumberFunctions(NumberFunctions other) : base(other) - { - _arg = Clone(other._arg); - _ftype = other._ftype; - } - - public override void SetXsltContext(XsltContext context) - { - if (_arg != null) - { - _arg.SetXsltContext(context); - } - } - - internal static double Number(bool arg) - { - return arg ? 1.0 : 0.0; - } - internal static double Number(string arg) - { - return XmlConvert.ToXPathDouble(arg); - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - switch (_ftype) - { - case FT.FuncNumber: return Number(nodeIterator); - case FT.FuncSum: return Sum(nodeIterator); - case FT.FuncFloor: return Floor(nodeIterator); - case FT.FuncCeiling: return Ceiling(nodeIterator); - case FT.FuncRound: return Round(nodeIterator); - } - return null; - } - - private double Number(XPathNodeIterator nodeIterator) - { - if (_arg == null) - { - return XmlConvert.ToXPathDouble(nodeIterator.Current.Value); - } - object argVal = _arg.Evaluate(nodeIterator); - switch (GetXPathType(argVal)) - { - case XPathResultType.NodeSet: - XPathNavigator value = _arg.Advance(); - if (value != null) - { - return Number(value.Value); - } - break; - case XPathResultType.String: - return Number((string)argVal); - case XPathResultType.Boolean: - return Number((bool)argVal); - case XPathResultType.Number: - return (double)argVal; - case XPathResultType_Navigator: - return Number(((XPathNavigator)argVal).Value); - } - return double.NaN; - } - - private double Sum(XPathNodeIterator nodeIterator) - { - double sum = 0; - _arg.Evaluate(nodeIterator); - XPathNavigator nav; - while ((nav = _arg.Advance()) != null) - { - sum += Number(nav.Value); - } - return sum; - } - - private double Floor(XPathNodeIterator nodeIterator) - { - return Math.Floor((double)_arg.Evaluate(nodeIterator)); - } - - private double Ceiling(XPathNodeIterator nodeIterator) - { - return Math.Ceiling((double)_arg.Evaluate(nodeIterator)); - } - - private double Round(XPathNodeIterator nodeIterator) - { - double n = XmlConvert.ToXPathDouble(_arg.Evaluate(nodeIterator)); - return XmlConvert.XPathRound(n); - } - - public override XPathResultType StaticType { get { return XPathResultType.Number; } } - - public override XPathNodeIterator Clone() { return new NumberFunctions(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", _ftype.ToString()); - if (_arg != null) - { - _arg.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumericExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumericExpr.cs deleted file mode 100644 index 835135b7d99..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/NumericExpr.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - - internal sealed class NumericExpr : ValueQuery - { - private Operator.Op _op; - private Query _opnd1; - private Query _opnd2; - - public NumericExpr(Operator.Op op, Query opnd1, Query opnd2) - { - Debug.Assert( - op == Operator.Op.PLUS || op == Operator.Op.MINUS || - op == Operator.Op.MUL || op == Operator.Op.DIV || - op == Operator.Op.MOD - ); - Debug.Assert(opnd1 != null && opnd2 != null); - if (opnd1.StaticType != XPathResultType.Number) - { - opnd1 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd1); - } - if (opnd2.StaticType != XPathResultType.Number) - { - opnd2 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd2); - } - _op = op; - _opnd1 = opnd1; - _opnd2 = opnd2; - } - private NumericExpr(NumericExpr other) : base(other) - { - _op = other._op; - _opnd1 = Clone(other._opnd1); - _opnd2 = Clone(other._opnd2); - } - - public override void SetXsltContext(XsltContext context) - { - _opnd1.SetXsltContext(context); - _opnd2.SetXsltContext(context); - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - return GetValue(_op, - XmlConvert.ToXPathDouble(_opnd1.Evaluate(nodeIterator)), - XmlConvert.ToXPathDouble(_opnd2.Evaluate(nodeIterator)) - ); - } - private static double GetValue(Operator.Op op, double n1, double n2) - { - Debug.Assert(op == Operator.Op.PLUS || op == Operator.Op.MINUS || op == Operator.Op.MOD || op == Operator.Op.DIV || op == Operator.Op.MUL); - switch (op) - { - case Operator.Op.PLUS: return n1 + n2; - case Operator.Op.MINUS: return n1 - n2; - case Operator.Op.MOD: return n1 % n2; - case Operator.Op.DIV: return n1 / n2; - case Operator.Op.MUL: return n1 * n2; - } - return 0; - } - - public override XPathResultType StaticType { get { return XPathResultType.Number; } } - - public override XPathNodeIterator Clone() { return new NumericExpr(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("op", _op.ToString()); - _opnd1.PrintQuery(w); - _opnd2.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operand.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operand.cs deleted file mode 100644 index 99c42a4af12..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operand.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class Operand : AstNode - { - private XPathResultType _type; - private object _val; - - public Operand(string val) - { - _type = XPathResultType.String; - _val = val; - } - - public Operand(double val) - { - _type = XPathResultType.Number; - _val = val; - } - - public Operand(bool val) - { - _type = XPathResultType.Boolean; - _val = val; - } - - public override AstType Type { get { return AstType.ConstantOperand; } } - public override XPathResultType ReturnType { get { return _type; } } - - public object OperandValue { get { return _val; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/OperandQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/OperandQuery.cs deleted file mode 100644 index 4dd43fed1fe..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/OperandQuery.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - - internal sealed class OperandQuery : ValueQuery - { - internal object val; - - public OperandQuery(object val) - { - this.val = val; - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - return val; - } - public override XPathResultType StaticType { get { return GetXPathType(val); } } - public override XPathNodeIterator Clone() { return this; } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("value", Convert.ToString(val, CultureInfo.InvariantCulture)); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operator.cs deleted file mode 100644 index bb084bcdf9e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Operator.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - internal class Operator : AstNode - { - public enum Op - { // order is alligned with XPathOperator - INVALID, - /*Logical */ - OR, - AND, - /*Equality */ - EQ, - NE, - /*Relational*/ - LT, - LE, - GT, - GE, - /*Arithmetic*/ - PLUS, - MINUS, - MUL, - DIV, - MOD, - /*Union */ - UNION, - }; - - private static Op[] s_invertOp = { - /*INVALID*/ Op.INVALID, - /*OR */ Op.INVALID, - /*END */ Op.INVALID, - /*EQ */ Op.EQ, - /*NE */ Op.NE, - /*LT */ Op.GT, - /*LE */ Op.GE, - /*GT */ Op.LT, - /*GE */ Op.LE, - }; - - static public Operator.Op InvertOperator(Operator.Op op) - { - Debug.Assert(Op.EQ <= op && op <= Op.GE); - return s_invertOp[(int)op]; - } - - private Op _opType; - private AstNode _opnd1; - private AstNode _opnd2; - - public Operator(Op op, AstNode opnd1, AstNode opnd2) - { - _opType = op; - _opnd1 = opnd1; - _opnd2 = opnd2; - } - - public override AstType Type { get { return AstType.Operator; } } - public override XPathResultType ReturnType - { - get - { - if (_opType <= Op.GE) - { - return XPathResultType.Boolean; - } - if (_opType <= Op.MOD) - { - return XPathResultType.Number; - } - return XPathResultType.NodeSet; - } - } - - public Op OperatorType { get { return _opType; } } - public AstNode Operand1 { get { return _opnd1; } } - public AstNode Operand2 { get { return _opnd2; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ParentQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ParentQuery.cs deleted file mode 100644 index 32cea2b78a1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ParentQuery.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections.Generic; - - internal sealed class ParentQuery : CacheAxisQuery - { - public ParentQuery(Query qyInput, string Name, string Prefix, XPathNodeType Type) : base(qyInput, Name, Prefix, Type) { } - private ParentQuery(ParentQuery other) : base(other) { } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - - // REVIEW: This algorithm doesn't use the fact that input is DOD. - XPathNavigator input; - while ((input = qyInput.Advance()) != null) - { - input = input.Clone(); - - if (input.MoveToParent()) - { - if (matches(input)) - { - Insert(outputBuffer, input); - } - } - } - return this; - } - - public override XPathNodeIterator Clone() { return new ParentQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Query.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Query.cs deleted file mode 100644 index 9038f9de11a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Query.cs +++ /dev/null @@ -1,264 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Diagnostics; - using System.Collections.Generic; - - // See comments to QueryBuilder.Props - // Not all of them are used currently - internal enum QueryProps - { - None = 0x00, - Position = 0x01, - Count = 0x02, - Cached = 0x04, - Reverse = 0x08, - Merge = 0x10, - }; - - - // Turn off DebuggerDisplayAttribute. in subclasses of Query. - // Calls to Current in the XPathNavigator.DebuggerDisplayProxy may change state or throw - [DebuggerDisplay("{ToString()}")] - internal abstract class Query : ResetableIterator - { - public Query() { } - protected Query(Query other) : base(other) { } - - // -- XPathNodeIterator -- - //public abstract XPathNodeIterator Clone(); - //public abstract XPathNavigator Current { get; } - //public abstract int CurrentPosition { get; } - public override bool MoveNext() { return Advance() != null; } - public override int Count - { - get - { - // Query can be ordered in reverse order. So we can't assume like base.Count that last node has greatest position. - if (count == -1) - { - Query clone = (Query)this.Clone(); - clone.Reset(); - count = 0; - while (clone.MoveNext()) count++; - } - return count; - } - } - - // ------------- ResetableIterator ----------- - // It's importent that Query is resetable. This fact is used in several plases: - // 1. In LogicalExpr: "foo = bar" - // 2. In SelectionOperator.Reset(). - // In all this cases Reset() means restart iterate through the same nodes. - // So reset shouldn't clean bufferes in query. This should be done in set context. - //public abstract void Reset(); - - // -------------------- Query ------------------ - public virtual void SetXsltContext(XsltContext context) { } - - public abstract object Evaluate(XPathNodeIterator nodeIterator); - public abstract XPathNavigator Advance(); - - public virtual XPathNavigator MatchNode(XPathNavigator current) - { - throw XPathException.Create(ResXml.Xp_InvalidPattern); - } - - public virtual double XsltDefaultPriority { get { return 0.5; } } - public abstract XPathResultType StaticType { get; } - public virtual QueryProps Properties { get { return QueryProps.Merge; } } - - // ----------------- Helper methods ------------- - public static Query Clone(Query input) - { - if (input != null) - { - return (Query)input.Clone(); - } - return null; - } - - protected static XPathNodeIterator Clone(XPathNodeIterator input) - { - if (input != null) - { - return input.Clone(); - } - return null; - } - - protected static XPathNavigator Clone(XPathNavigator input) - { - if (input != null) - { - return input.Clone(); - } - return null; - } - - // ----------------------------------------------------- - // Set of methods to support insertion to sorted buffer. - // buffer is always sorted here - - public bool Insert(List buffer, XPathNavigator nav) - { - int l = 0; - int r = buffer.Count; - - // In most cases nodes are already sorted. - // This means that nav often will be equal or after then last item in the buffer - // So let's check this first. - if (r != 0) - { - switch (CompareNodes(buffer[r - 1], nav)) - { - case XmlNodeOrder.Same: - return false; - case XmlNodeOrder.Before: - buffer.Add(nav.Clone()); - return true; - default: - r--; - break; - } - } - - while (l < r) - { - int m = GetMedian(l, r); - switch (CompareNodes(buffer[m], nav)) - { - case XmlNodeOrder.Same: - return false; - case XmlNodeOrder.Before: - l = m + 1; - break; - default: - r = m; - break; - } - } - AssertDOD(buffer, nav, l); - buffer.Insert(l, nav.Clone()); - return true; - } - - private static int GetMedian(int l, int r) - { - Debug.Assert(0 <= l && l < r); - return (int)(((uint)l + (uint)r) >> 1); - } - - public static XmlNodeOrder CompareNodes(XPathNavigator l, XPathNavigator r) - { - XmlNodeOrder cmp = l.ComparePosition(r); - if (cmp == XmlNodeOrder.Unknown) - { - XPathNavigator copy = l.Clone(); - copy.MoveToRoot(); - string baseUriL = copy.BaseURI; - if (!copy.MoveTo(r)) - { - copy = r.Clone(); - } - copy.MoveToRoot(); - string baseUriR = copy.BaseURI; - int cmpBase = string.CompareOrdinal(baseUriL, baseUriR); - cmp = ( - cmpBase < 0 ? XmlNodeOrder.Before : - cmpBase > 0 ? XmlNodeOrder.After : - /*default*/ XmlNodeOrder.Unknown - ); - } - return cmp; - } - - [Conditional("DEBUG")] - private void AssertDOD(List buffer, XPathNavigator nav, int pos) - { - if (nav.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator") return; - if (nav.GetType().ToString() == "Microsoft.Xml.DataDocumentXPathNavigator") return; - Debug.Assert(0 <= pos && pos <= buffer.Count, "Algorithm error: Insert()"); - XmlNodeOrder cmp; - if (0 < pos) - { - cmp = CompareNodes(buffer[pos - 1], nav); - Debug.Assert(cmp == XmlNodeOrder.Before, "Algorithm error: Insert()"); - } - if (pos < buffer.Count) - { - cmp = CompareNodes(nav, buffer[pos]); - Debug.Assert(cmp == XmlNodeOrder.Before, "Algorithm error: Insert()"); - } - } - - [Conditional("DEBUG")] - public static void AssertQuery(Query query) - { - Debug.Assert(query != null, "AssertQuery(): query == null"); - if (query is FunctionQuery) return; // Temp Fix. Functions (as document()) return now unordered sequences - query = Clone(query); - XPathNavigator last = null; - XPathNavigator curr; - int querySize = query.Clone().Count; - int actualSize = 0; - while ((curr = query.Advance()) != null) - { - if (curr.GetType().ToString() == "Microsoft.VisualStudio.Modeling.StoreNavigator") return; - if (curr.GetType().ToString() == "Microsoft.Xml.DataDocumentXPathNavigator") return; - Debug.Assert(curr == query.Current, "AssertQuery(): query.Advance() != query.Current"); - if (last != null) - { - if (last.NodeType == XPathNodeType.Namespace && curr.NodeType == XPathNodeType.Namespace) - { - // NamespaceQuery reports namsespaces in mixed order. - // Ignore this for now. - // It seams that this doesn't breake other queries becasue NS can't have children - } - else - { - XmlNodeOrder cmp = CompareNodes(last, curr); - Debug.Assert(cmp == XmlNodeOrder.Before, "AssertQuery(): Wrong node order"); - } - } - last = curr.Clone(); - actualSize++; - } - Debug.Assert(actualSize == querySize, "AssertQuery(): actualSize != querySize"); - } - - // =================== XPathResultType_Navigator ====================== - // In v.1.0 and v.1.1 XPathResultType.Navigator is defined == to XPathResultType.String - // This is source for multiple bugs or additional type casts. - // To fix all of them in one change in v.2 we internaly use one more value: - public const XPathResultType XPathResultType_Navigator = (XPathResultType)4; - // The biggest challenge in this change is preserve backward compatibility with v.1.1 - // To achive this in all places where we accept from or report to user XPathResultType. - // On my best knowledge this happens only in XsltContext.ResolveFunction() / IXsltContextFunction.ReturnType - - - protected XPathResultType GetXPathType(object value) - { - if (value is XPathNodeIterator) return XPathResultType.NodeSet; - if (value is string) return XPathResultType.String; - if (value is double) return XPathResultType.Number; - if (value is bool) return XPathResultType.Boolean; - Debug.Assert(value is XPathNavigator, "Unknown value type"); - return XPathResultType_Navigator; - } - - // =================== Serialization ====================== - public virtual void PrintQuery(XmlWriter w) - { - w.WriteElementString(this.GetType().Name, string.Empty); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ResetableIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ResetableIterator.cs deleted file mode 100644 index 1ae36557e42..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ResetableIterator.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal abstract class ResetableIterator : XPathNodeIterator - { - // the best place for this constructors to be is XPathNodeIterator, to avoid DCR at this time let's ground them here - public ResetableIterator() - { - base.count = -1; - } - protected ResetableIterator(ResetableIterator other) - { - base.count = other.count; - } - protected void ResetCount() - { - base.count = -1; - } - - public abstract void Reset(); - public virtual bool MoveToPosition(int pos) - { - Reset(); - for (int i = CurrentPosition; i < pos; i++) - { - if (!MoveNext()) - { - return false; - } - } - return true; - } - - // Contruct extension: CurrentPosition should return 0 if MoveNext() wasn't called after Reset() - // (behavior is not defined for XPathNodeIterator) - public abstract override int CurrentPosition { get; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ReversePositionQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ReversePositionQuery.cs deleted file mode 100644 index fc8a464249c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ReversePositionQuery.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal sealed class ReversePositionQuery : ForwardPositionQuery - { - public ReversePositionQuery(Query input) : base(input) { } - private ReversePositionQuery(ReversePositionQuery other) : base(other) { } - - public override XPathNodeIterator Clone() { return new ReversePositionQuery(this); } - public override int CurrentPosition { get { return outputBuffer.Count - count + 1; } } - public override QueryProps Properties { get { return base.Properties | QueryProps.Reverse; } } - } -} - - - - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Root.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Root.cs deleted file mode 100644 index c224c189aed..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Root.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - - internal class Root : AstNode - { - public Root() { } - - public override AstType Type { get { return AstType.Root; } } - public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/SortQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/SortQuery.cs deleted file mode 100644 index 1f255d411f4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/SortQuery.cs +++ /dev/null @@ -1,234 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Diagnostics; - using System.Collections; - using System.Collections.Generic; - - internal sealed class SortQuery : Query - { - private List _results; - private XPathSortComparer _comparer; - private Query _qyInput; - - public SortQuery(Query qyInput) - { - Debug.Assert(qyInput != null, "Sort Query needs an input query tree to work on"); - _results = new List(); - _comparer = new XPathSortComparer(); - _qyInput = qyInput; - count = 0; - } - private SortQuery(SortQuery other) : base(other) - { - _results = new List(other._results); - _comparer = other._comparer.Clone(); - _qyInput = Clone(other._qyInput); - count = 0; - } - - public override void Reset() { count = 0; } - - public override void SetXsltContext(XsltContext xsltContext) - { - _qyInput.SetXsltContext(xsltContext); - if ( - _qyInput.StaticType != XPathResultType.NodeSet && - _qyInput.StaticType != XPathResultType.Any - ) - { - throw XPathException.Create(ResXml.Xp_NodeSetExpected); - } - } - - private void BuildResultsList() - { - Int32 numSorts = _comparer.NumSorts; - - Debug.Assert(numSorts > 0, "Why was the sort query created?"); - - XPathNavigator eNext; - while ((eNext = _qyInput.Advance()) != null) - { - SortKey key = new SortKey(numSorts, /*originalPosition:*/_results.Count, eNext.Clone()); - - for (Int32 j = 0; j < numSorts; j++) - { - key[j] = _comparer.Expression(j).Evaluate(_qyInput); - } - - _results.Add(key); - } - _results.Sort(_comparer); - } - - public override object Evaluate(XPathNodeIterator context) - { - _qyInput.Evaluate(context); - _results.Clear(); - BuildResultsList(); - count = 0; - return this; - } - - public override XPathNavigator Advance() - { - Debug.Assert(0 <= count && count <= _results.Count); - if (count < _results.Count) - { - return _results[count++].Node; - } - return null; - } - - public override XPathNavigator Current - { - get - { - Debug.Assert(0 <= count && count <= _results.Count); - if (count == 0) - { - return null; - } - return _results[count - 1].Node; - } - } - - internal void AddSort(Query evalQuery, IComparer comparer) - { - _comparer.AddSort(evalQuery, comparer); - } - - public override XPathNodeIterator Clone() { return new SortQuery(this); } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - public override int CurrentPosition { get { return count; } } - public override int Count { get { return _results.Count; } } - public override QueryProps Properties { get { return QueryProps.Cached | QueryProps.Position | QueryProps.Count; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - _qyInput.PrintQuery(w); - w.WriteElementString("XPathSortComparer", "... PrintTree() not implemented ..."); - w.WriteEndElement(); - } - } // class SortQuery - - internal sealed class SortKey - { - private Int32 _numKeys; - private object[] _keys; - private int _originalPosition; - private XPathNavigator _node; - - public SortKey(int numKeys, int originalPosition, XPathNavigator node) - { - _numKeys = numKeys; - _keys = new object[numKeys]; - _originalPosition = originalPosition; - _node = node; - } - - public object this[int index] - { - get { return _keys[index]; } - set { _keys[index] = value; } - } - - public int NumKeys { get { return _numKeys; } } - public int OriginalPosition { get { return _originalPosition; } } - public XPathNavigator Node { get { return _node; } } - } // class SortKey - - internal sealed class XPathSortComparer : IComparer - { - private const int minSize = 3; - private Query[] _expressions; - private IComparer[] _comparers; - private int _numSorts; - - public XPathSortComparer(int size) - { - if (size <= 0) size = minSize; - _expressions = new Query[size]; - _comparers = new IComparer[size]; - } - public XPathSortComparer() : this(minSize) { } - - public void AddSort(Query evalQuery, IComparer comparer) - { - Debug.Assert(_expressions.Length == _comparers.Length); - Debug.Assert(0 < _expressions.Length); - Debug.Assert(0 <= _numSorts && _numSorts <= _expressions.Length); - // Ajust array sizes if needed. - if (_numSorts == _expressions.Length) - { - Query[] newExpressions = new Query[_numSorts * 2]; - IComparer[] newComparers = new IComparer[_numSorts * 2]; - for (int i = 0; i < _numSorts; i++) - { - newExpressions[i] = _expressions[i]; - newComparers[i] = _comparers[i]; - } - _expressions = newExpressions; - _comparers = newComparers; - } - Debug.Assert(_numSorts < _expressions.Length); - - // Fixup expression to handle node-set return type: - if (evalQuery.StaticType == XPathResultType.NodeSet || evalQuery.StaticType == XPathResultType.Any) - { - evalQuery = new StringFunctions(Function.FunctionType.FuncString, new Query[] { evalQuery }); - } - - _expressions[_numSorts] = evalQuery; - _comparers[_numSorts] = comparer; - _numSorts++; - } - - public int NumSorts { get { return _numSorts; } } - - public Query Expression(int i) - { - return _expressions[i]; - } - - int IComparer.Compare(SortKey x, SortKey y) - { - Debug.Assert(x != null && y != null, "Oops!! what happened?"); - int result = 0; - for (int i = 0; i < x.NumKeys; i++) - { - result = _comparers[i].Compare(x[i], y[i]); - if (result != 0) - { - return result; - } - } - - // if after all comparisions, the two sort keys are still equal, preserve the doc order - return x.OriginalPosition - y.OriginalPosition; - } - - internal XPathSortComparer Clone() - { - XPathSortComparer clone = new XPathSortComparer(_numSorts); - - for (int i = 0; i < _numSorts; i++) - { - clone._comparers[i] = _comparers[i]; - clone._expressions[i] = (Query)_expressions[i].Clone(); // Expressions should be cloned because Query should be cloned - } - clone._numSorts = _numSorts; - return clone; - } - } // class XPathSortComparer -} // namespace diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/StringFunctions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/StringFunctions.cs deleted file mode 100644 index 2f95a06fffb..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/StringFunctions.cs +++ /dev/null @@ -1,285 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using System.Globalization; - using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Collections.Generic; - using System.Diagnostics; - - internal sealed class StringFunctions : ValueQuery - { - private Function.FunctionType _funcType; - private IList _argList; - - public StringFunctions(Function.FunctionType funcType, IList argList) - { - Debug.Assert(argList != null, "Use 'new Query[]{}' instead."); - _funcType = funcType; - _argList = argList; - } - private StringFunctions(StringFunctions other) : base(other) - { - _funcType = other._funcType; - Query[] tmp = new Query[other._argList.Count]; - { - for (int i = 0; i < tmp.Length; i++) - { - tmp[i] = Clone(other._argList[i]); - } - } - _argList = tmp; - } - - public override void SetXsltContext(XsltContext context) - { - for (int i = 0; i < _argList.Count; i++) - { - _argList[i].SetXsltContext(context); - } - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - switch (_funcType) - { - case Function.FunctionType.FuncString: return toString(nodeIterator); - case Function.FunctionType.FuncConcat: return Concat(nodeIterator); - case Function.FunctionType.FuncStartsWith: return StartsWith(nodeIterator); - case Function.FunctionType.FuncContains: return Contains(nodeIterator); - case Function.FunctionType.FuncSubstringBefore: return SubstringBefore(nodeIterator); - case Function.FunctionType.FuncSubstringAfter: return SubstringAfter(nodeIterator); - case Function.FunctionType.FuncSubstring: return Substring(nodeIterator); - case Function.FunctionType.FuncStringLength: return StringLength(nodeIterator); - case Function.FunctionType.FuncNormalize: return Normalize(nodeIterator); - case Function.FunctionType.FuncTranslate: return Translate(nodeIterator); - } - return string.Empty; - } - - internal static string toString(double num) - { - return num.ToString("R", NumberFormatInfo.InvariantInfo); - } - - internal static string toString(bool b) - { - return b ? "true" : "false"; - } - - private string toString(XPathNodeIterator nodeIterator) - { - if (_argList.Count > 0) - { - object argVal = _argList[0].Evaluate(nodeIterator); - - switch (GetXPathType(argVal)) - { - case XPathResultType.NodeSet: - XPathNavigator value = _argList[0].Advance(); - return value != null ? value.Value : string.Empty; - case XPathResultType.String: - return (string)argVal; - case XPathResultType.Boolean: - return ((bool)argVal) ? "true" : "false"; - case XPathResultType_Navigator: - return ((XPathNavigator)argVal).Value; - default: - Debug.Assert(GetXPathType(argVal) == XPathResultType.Number); - return toString((double)argVal); - } - } - return nodeIterator.Current.Value; - } - - public override XPathResultType StaticType - { - get - { - if (_funcType == Function.FunctionType.FuncStringLength) - { - return XPathResultType.Number; - } - if ( - _funcType == Function.FunctionType.FuncStartsWith || - _funcType == Function.FunctionType.FuncContains - ) - { - return XPathResultType.Boolean; - } - return XPathResultType.String; - } - } - - private string Concat(XPathNodeIterator nodeIterator) - { - int count = 0; - StringBuilder s = new StringBuilder(); - while (count < _argList.Count) - { - s.Append(_argList[count++].Evaluate(nodeIterator).ToString()); - } - return s.ToString(); - } - - private bool StartsWith(XPathNodeIterator nodeIterator) - { - string s1 = _argList[0].Evaluate(nodeIterator).ToString(); - string s2 = _argList[1].Evaluate(nodeIterator).ToString(); - return s1.Length >= s2.Length && string.CompareOrdinal(s1, 0, s2, 0, s2.Length) == 0; - } - - private static readonly CompareInfo s_compareInfo = CultureInfo.InvariantCulture.CompareInfo; - - private bool Contains(XPathNodeIterator nodeIterator) - { - string s1 = _argList[0].Evaluate(nodeIterator).ToString(); - string s2 = _argList[1].Evaluate(nodeIterator).ToString(); - return s_compareInfo.IndexOf(s1, s2, CompareOptions.Ordinal) >= 0; - } - - private string SubstringBefore(XPathNodeIterator nodeIterator) - { - string s1 = _argList[0].Evaluate(nodeIterator).ToString(); - string s2 = _argList[1].Evaluate(nodeIterator).ToString(); - if (s2.Length == 0) { return s2; } - int idx = s_compareInfo.IndexOf(s1, s2, CompareOptions.Ordinal); - return (idx < 1) ? string.Empty : s1.Substring(0, idx); - } - - private string SubstringAfter(XPathNodeIterator nodeIterator) - { - string s1 = _argList[0].Evaluate(nodeIterator).ToString(); - string s2 = _argList[1].Evaluate(nodeIterator).ToString(); - if (s2.Length == 0) { return s1; } - int idx = s_compareInfo.IndexOf(s1, s2, CompareOptions.Ordinal); - return (idx < 0) ? string.Empty : s1.Substring(idx + s2.Length); - } - - private string Substring(XPathNodeIterator nodeIterator) - { - string str1 = _argList[0].Evaluate(nodeIterator).ToString(); - double num = XmlConvert.XPathRound(XmlConvert.ToXPathDouble(_argList[1].Evaluate(nodeIterator))) - 1; - - if (Double.IsNaN(num) || str1.Length <= num) - { - return string.Empty; - } - if (_argList.Count == 3) - { - double num1 = XmlConvert.XPathRound(XmlConvert.ToXPathDouble(_argList[2].Evaluate(nodeIterator))); - if (Double.IsNaN(num1)) - { - return string.Empty; - } - if (num < 0 || num1 < 0) - { - num1 = num + num1; - // NOTE: condition is true for NaN - if (!(num1 > 0)) - { - return string.Empty; - } - num = 0; - } - double maxlength = str1.Length - num; - if (num1 > maxlength) - { - num1 = maxlength; - } - return str1.Substring((int)num, (int)num1); - } - if (num < 0) - { - num = 0; - } - return str1.Substring((int)num); - } - - private Double StringLength(XPathNodeIterator nodeIterator) - { - if (_argList.Count > 0) - { - return _argList[0].Evaluate(nodeIterator).ToString().Length; - } - return nodeIterator.Current.Value.Length; - } - - private string Normalize(XPathNodeIterator nodeIterator) - { - string str1; - if (_argList.Count > 0) - { - str1 = _argList[0].Evaluate(nodeIterator).ToString(); - } - else - { - str1 = nodeIterator.Current.Value; - } - str1 = XmlConvert.TrimString(str1); - int count = 0; - StringBuilder str2 = new StringBuilder(); - bool FirstSpace = true; - XmlCharType xmlCharType = XmlCharType.Instance; - while (count < str1.Length) - { - if (!xmlCharType.IsWhiteSpace(str1[count])) - { - FirstSpace = true; - str2.Append(str1[count]); - } - else if (FirstSpace) - { - FirstSpace = false; - str2.Append(' '); - } - count++; - } - return str2.ToString(); - } - private string Translate(XPathNodeIterator nodeIterator) - { - string str1 = _argList[0].Evaluate(nodeIterator).ToString(); - string str2 = _argList[1].Evaluate(nodeIterator).ToString(); - string str3 = _argList[2].Evaluate(nodeIterator).ToString(); - int count = 0, index; - StringBuilder str = new StringBuilder(); - while (count < str1.Length) - { - index = str2.IndexOf(str1[count]); - if (index != -1) - { - if (index < str3.Length) - { - str.Append(str3[index]); - } - } - else - { - str.Append(str1[count]); - } - count++; - } - return str.ToString(); - } - - public override XPathNodeIterator Clone() { return new StringFunctions(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", _funcType.ToString()); - foreach (Query arg in _argList) - { - arg.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/UnionExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/UnionExpr.cs deleted file mode 100644 index 73e42a2712c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/UnionExpr.cs +++ /dev/null @@ -1,179 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using Microsoft.Xml.Xsl; - - internal sealed class UnionExpr : Query - { - internal Query qy1, qy2; - private bool _advance1,_advance2; - private XPathNavigator _currentNode; - private XPathNavigator _nextNode; - - public UnionExpr(Query query1, Query query2) - { - this.qy1 = query1; - this.qy2 = query2; - _advance1 = true; - _advance2 = true; - } - private UnionExpr(UnionExpr other) : base(other) - { - this.qy1 = Clone(other.qy1); - this.qy2 = Clone(other.qy2); - _advance1 = other._advance1; - _advance2 = other._advance2; - _currentNode = Clone(other._currentNode); - _nextNode = Clone(other._nextNode); - } - - public override void Reset() - { - qy1.Reset(); - qy2.Reset(); - _advance1 = true; - _advance2 = true; - _nextNode = null; - } - - public override void SetXsltContext(XsltContext xsltContext) - { - qy1.SetXsltContext(xsltContext); - qy2.SetXsltContext(xsltContext); - } - - public override object Evaluate(XPathNodeIterator context) - { - qy1.Evaluate(context); - qy2.Evaluate(context); - _advance1 = true; - _advance2 = true; - _nextNode = null; - base.ResetCount(); - return this; - } - - private XPathNavigator ProcessSamePosition(XPathNavigator result) - { - _currentNode = result; - _advance1 = _advance2 = true; - return result; - } - - private XPathNavigator ProcessBeforePosition(XPathNavigator res1, XPathNavigator res2) - { - _nextNode = res2; - _advance2 = false; - _advance1 = true; - _currentNode = res1; - return res1; - } - - private XPathNavigator ProcessAfterPosition(XPathNavigator res1, XPathNavigator res2) - { - _nextNode = res1; - _advance1 = false; - _advance2 = true; - _currentNode = res2; - return res2; - } - - public override XPathNavigator Advance() - { - XPathNavigator res1, res2; - XmlNodeOrder order = 0; - if (_advance1) - { - res1 = qy1.Advance(); - } - else - { - res1 = _nextNode; - } - if (_advance2) - { - res2 = qy2.Advance(); - } - else - { - res2 = _nextNode; - } - if (res1 != null && res2 != null) - { - order = CompareNodes(res1, res2); - } - else if (res2 == null) - { - _advance1 = true; - _advance2 = false; - _currentNode = res1; - _nextNode = null; - return res1; - } - else - { - _advance1 = false; - _advance2 = true; - _currentNode = res2; - _nextNode = null; - return res2; - } - - if (order == XmlNodeOrder.Before) - { - return ProcessBeforePosition(res1, res2); - } - else if (order == XmlNodeOrder.After) - { - return ProcessAfterPosition(res1, res2); - } - else - { - // BugBug. In case of Unknown we sorting as the same. - return ProcessSamePosition(res1); - } - } - - public override XPathNavigator MatchNode(XPathNavigator xsltContext) - { - if (xsltContext != null) - { - XPathNavigator result = qy1.MatchNode(xsltContext); - if (result != null) - { - return result; - } - return qy2.MatchNode(xsltContext); - } - return null; - } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - - public override XPathNodeIterator Clone() { return new UnionExpr(this); } - - public override XPathNavigator Current { get { return _currentNode; } } - public override int CurrentPosition { get { throw new InvalidOperationException(); } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - if (qy1 != null) - { - qy1.PrintQuery(w); - } - if (qy2 != null) - { - qy2.PrintQuery(w); - } - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ValueQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ValueQuery.cs deleted file mode 100644 index c7017f59122..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/ValueQuery.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using System.Globalization; - using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Xsl; - using System.Collections.Generic; - using System.Diagnostics; - - internal abstract class ValueQuery : Query - { - public ValueQuery() { } - protected ValueQuery(ValueQuery other) : base(other) { } - public sealed override void Reset() { } - public sealed override XPathNavigator Current { get { throw XPathException.Create(ResXml.Xp_NodeSetExpected); } } - public sealed override int CurrentPosition { get { throw XPathException.Create(ResXml.Xp_NodeSetExpected); } } - public sealed override int Count { get { throw XPathException.Create(ResXml.Xp_NodeSetExpected); } } - public sealed override XPathNavigator Advance() { throw XPathException.Create(ResXml.Xp_NodeSetExpected); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Variable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Variable.cs deleted file mode 100644 index 6fa9803b877..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/Variable.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - - internal class Variable : AstNode - { - private string _localname; - private string _prefix; - - public Variable(string name, string prefix) - { - _localname = name; - _prefix = prefix; - } - - public override AstType Type { get { return AstType.Variable; } } - public override XPathResultType ReturnType { get { return XPathResultType.Any; } } - - public string Localname { get { return _localname; } } - public string Prefix { get { return _prefix; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/VariableQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/VariableQuery.cs deleted file mode 100644 index 45b642cdb26..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/VariableQuery.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - - internal sealed class VariableQuery : ExtensionQuery - { - private IXsltContextVariable _variable; - - public VariableQuery(string name, string prefix) : base(prefix, name) { } - private VariableQuery(VariableQuery other) : base(other) - { - _variable = other._variable; - } - - public override void SetXsltContext(XsltContext context) - { - if (context == null) - { - throw XPathException.Create(ResXml.Xp_NoContext); - } - - if (this.xsltContext != context) - { - xsltContext = context; - _variable = xsltContext.ResolveVariable(prefix, name); - // Since null is allowed for ResolveFunction, allow it for ResolveVariable as well - if (_variable == null) - { - throw XPathException.Create(ResXml.Xp_UndefVar, QName); - } - } - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - if (xsltContext == null) - { - throw XPathException.Create(ResXml.Xp_NoContext); - } - - return ProcessResult(_variable.Evaluate(xsltContext)); - } - - public override XPathResultType StaticType - { - get - { - if (_variable != null) - { // Temp. fix to overcome dependency on static type - return GetXPathType(Evaluate(null)); - } - XPathResultType result = _variable != null ? _variable.VariableType : XPathResultType.Any; - if (result == XPathResultType.Error) - { - // In v.1 we confused Error & Any so now for backward compatibility we should allow users to return any of them. - result = XPathResultType.Any; - } - return result; - } - } - - public override XPathNodeIterator Clone() { return new VariableQuery(this); } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - w.WriteAttributeString("name", prefix.Length != 0 ? prefix + ':' + name : name); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorIterator.cs deleted file mode 100644 index 0294165952c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorIterator.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class XPathAncestorIterator : XPathAxisIterator - { - public XPathAncestorIterator(XPathNavigator nav, XPathNodeType type, bool matchSelf) : base(nav, type, matchSelf) { } - public XPathAncestorIterator(XPathNavigator nav, string name, string namespaceURI, bool matchSelf) : base(nav, name, namespaceURI, matchSelf) { } - public XPathAncestorIterator(XPathAncestorIterator other) : base(other) { } - - public override bool MoveNext() - { - if (first) - { - first = false; - if (matchSelf && Matches) - { - position = 1; - return true; - } - } - - while (nav.MoveToParent()) - { - if (Matches) - { - position++; - return true; - } - } - return false; - } - - public override XPathNodeIterator Clone() { return new XPathAncestorIterator(this); } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorQuery.cs deleted file mode 100644 index 3ce32a323ee..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAncestorQuery.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections.Generic; - - internal sealed class XPathAncestorQuery : CacheAxisQuery - { - private bool _matchSelf; - - public XPathAncestorQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest, bool matchSelf) : base(qyInput, name, prefix, typeTest) - { - _matchSelf = matchSelf; - } - private XPathAncestorQuery(XPathAncestorQuery other) : base(other) - { - _matchSelf = other._matchSelf; - } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - - XPathNavigator ancestor = null; - XPathNavigator input; - while ((input = qyInput.Advance()) != null) - { - if (_matchSelf) - { - if (matches(input)) - { - if (!Insert(outputBuffer, input)) - { - // If input is already in output buffer all its ancestors are in a buffer as well. - continue; - } - } - } - if (ancestor == null || !ancestor.MoveTo(input)) - { - ancestor = input.Clone(); - } - while (ancestor.MoveToParent()) - { - if (matches(ancestor)) - { - if (!Insert(outputBuffer, ancestor)) - { - // If input is already in output buffer all its ancestors are in a buffer as well. - break; - } - } - } - } - return this; - } - - public override XPathNodeIterator Clone() { return new XPathAncestorQuery(this); } - public override int CurrentPosition { get { return outputBuffer.Count - count + 1; } } - public override QueryProps Properties { get { return base.Properties | QueryProps.Reverse; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - if (_matchSelf) - { - w.WriteAttributeString("self", "yes"); - } - if (NameTest) - { - w.WriteAttributeString("name", Prefix.Length != 0 ? Prefix + ':' + Name : Name); - } - if (TypeTest != XPathNodeType.Element) - { - w.WriteAttributeString("nodeType", TypeTest.ToString()); - } - qyInput.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathArrayIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathArrayIterator.cs deleted file mode 100644 index 75be793f3da..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathArrayIterator.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Diagnostics; -using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.XPath; - -namespace MS.Internal.Xml.XPath -{ - [DebuggerDisplay("Position={CurrentPosition}, Current={debuggerDisplayProxy, nq}")] - internal class XPathArrayIterator : ResetableIterator - { - protected IList list; - protected int index; - - public XPathArrayIterator(IList list) - { - this.list = list; - } - - public XPathArrayIterator(XPathArrayIterator it) - { - this.list = it.list; - this.index = it.index; - } - - public XPathArrayIterator(XPathNodeIterator nodeIterator) - { - this.list = new ArrayList(); - while (nodeIterator.MoveNext()) - { - this.list.Add(nodeIterator.Current.Clone()); - } - } - - public IList AsList - { - get { return this.list; } - } - - public override XPathNodeIterator Clone() - { - return new XPathArrayIterator(this); - } - - public override XPathNavigator Current - { - get - { - Debug.Assert(index <= list.Count); - - if (index < 1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - return (XPathNavigator)list[index - 1]; - } - } - - public override int CurrentPosition { get { return index; } } - public override int Count { get { return list.Count; } } - - public override bool MoveNext() - { - Debug.Assert(index <= list.Count); - if (index == list.Count) - { - return false; - } - index++; - return true; - } - - public override void Reset() - { - index = 0; - } - - public override IEnumerator GetEnumerator() - { - return list.GetEnumerator(); - } - - private object debuggerDisplayProxy { get { return index < 1 ? null : (object)new XPathNavigator.DebuggerDisplayProxy(Current); } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAxisIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAxisIterator.cs deleted file mode 100644 index e431bf8ddab..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathAxisIterator.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal abstract class XPathAxisIterator : XPathNodeIterator - { - internal XPathNavigator nav; - internal XPathNodeType type; - internal string name; - internal string uri; - internal int position; - internal bool matchSelf; - internal bool first = true; - - public XPathAxisIterator(XPathNavigator nav, bool matchSelf) - { - this.nav = nav; - this.matchSelf = matchSelf; - } - - public XPathAxisIterator(XPathNavigator nav, XPathNodeType type, bool matchSelf) : this(nav, matchSelf) - { - this.type = type; - } - - public XPathAxisIterator(XPathNavigator nav, string name, string namespaceURI, bool matchSelf) : this(nav, matchSelf) - { - if (name == null) throw new ArgumentNullException("name"); - if (namespaceURI == null) throw new ArgumentNullException("namespaceURI"); - - this.name = name; - this.uri = namespaceURI; - } - - public XPathAxisIterator(XPathAxisIterator it) - { - this.nav = it.nav.Clone(); - this.type = it.type; - this.name = it.name; - this.uri = it.uri; - this.position = it.position; - this.matchSelf = it.matchSelf; - this.first = it.first; - } - - public override XPathNavigator Current - { - get { return nav; } - } - - public override int CurrentPosition - { - get { return position; } - } - - // Nodetype Matching - Given nodetype matches the navigator's nodetype - //Given nodetype is all . So it matches everything - //Given nodetype is text - Matches text, WS, Significant WS - protected virtual bool Matches - { - get - { - if (name == null) - { - return ( - type == nav.NodeType || - type == XPathNodeType.All || - type == XPathNodeType.Text && ( - nav.NodeType == XPathNodeType.Whitespace || - nav.NodeType == XPathNodeType.SignificantWhitespace - ) - ); - } - else - { - return ( - nav.NodeType == XPathNodeType.Element && - (name.Length == 0 || name == nav.LocalName) && - (uri == nav.NamespaceURI) - ); - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathChildIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathChildIterator.cs deleted file mode 100644 index 58b6be550e3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathChildIterator.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class XPathChildIterator : XPathAxisIterator - { - public XPathChildIterator(XPathNavigator nav, XPathNodeType type) : base(nav, type, /*matchSelf:*/false) { } - public XPathChildIterator(XPathNavigator nav, string name, string namespaceURI) : base(nav, name, namespaceURI, /*matchSelf:*/false) { } - public XPathChildIterator(XPathChildIterator it) : base(it) { } - - public override XPathNodeIterator Clone() - { - return new XPathChildIterator(this); - } - - public override bool MoveNext() - { - while ((first) ? nav.MoveToFirstChild() : nav.MoveToNext()) - { - first = false; - if (Matches) - { - position++; - return true; - } - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathDescendantIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathDescendantIterator.cs deleted file mode 100644 index e4468937812..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathDescendantIterator.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using Microsoft.Xml.XPath; - - internal class XPathDescendantIterator : XPathAxisIterator - { - private int _level = 0; - - public XPathDescendantIterator(XPathNavigator nav, XPathNodeType type, bool matchSelf) : base(nav, type, matchSelf) { } - public XPathDescendantIterator(XPathNavigator nav, string name, string namespaceURI, bool matchSelf) : base(nav, name, namespaceURI, matchSelf) { } - - public XPathDescendantIterator(XPathDescendantIterator it) : base(it) - { - _level = it._level; - } - - public override XPathNodeIterator Clone() - { - return new XPathDescendantIterator(this); - } - - public override bool MoveNext() - { - if (first) - { - first = false; - if (matchSelf && Matches) - { - position = 1; - return true; - } - } - - while (true) - { - if (nav.MoveToFirstChild()) - { - _level++; - } - else - { - while (true) - { - if (_level == 0) - { - return false; - } - if (nav.MoveToNext()) - { - break; - } - nav.MoveToParent(); - _level--; - } - } - - if (Matches) - { - position++; - return true; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathEmptyIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathEmptyIterator.cs deleted file mode 100644 index a7d25beb548..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathEmptyIterator.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - - internal sealed class XPathEmptyIterator : ResetableIterator - { - private XPathEmptyIterator() { } - public override XPathNodeIterator Clone() { return this; } - - public override XPathNavigator Current - { - get { return null; } - } - - public override int CurrentPosition - { - get { return 0; } - } - - public override int Count - { - get { return 0; } - } - - public override bool MoveNext() - { - return false; - } - - public override void Reset() { } - - // -- Instance - public static XPathEmptyIterator Instance = new XPathEmptyIterator(); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathMultyIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathMultyIterator.cs deleted file mode 100644 index cd149c8c84e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathMultyIterator.cs +++ /dev/null @@ -1,187 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - - internal class XPathMultyIterator : ResetableIterator - { - protected ResetableIterator[] arr; - protected int firstNotEmpty; - protected int position; - - public XPathMultyIterator(ArrayList inputArray) - { - // NOTE: We do not clone the passed inputArray supposing that it is not changed outside of this class - this.arr = new ResetableIterator[inputArray.Count]; - for (int i = 0; i < this.arr.Length; i++) - { - this.arr[i] = new XPathArrayIterator((ArrayList)inputArray[i]); - } - Init(); - } - - private void Init() - { - for (int i = 0; i < arr.Length; i++) - { - Advance(i); - } - for (int i = arr.Length - 2; firstNotEmpty <= i;) - { - if (SiftItem(i)) - { - i--; - } - } - } - - // returns false is iterator at pos reached it's end & as a result head of the array may be moved - private bool Advance(int pos) - { - if (!arr[pos].MoveNext()) - { - if (firstNotEmpty != pos) - { - ResetableIterator empty = arr[pos]; - Array.Copy(arr, firstNotEmpty, arr, firstNotEmpty + 1, pos - firstNotEmpty); - arr[firstNotEmpty] = empty; - } - firstNotEmpty++; - return false; - } - return true; - } - -#if false - string dump { get { return Dump(); } } - - string Dump(ResetableIterator it) { - it = (ResetableIterator) it.Clone(); - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - sb.Append("("); - do { - XPathNavigator nav = it.Current.Clone(); - nav.MoveToAttribute("id1", ""); - sb.Append(nav.Value); - sb.Append(", "); - } while (it.MoveNext()); - sb.Length = sb.Length - 2; - sb.Append(")"); - return sb.ToString(); - } - - string Dump() { - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - for (int i = 0; i < arr.Length; i ++) { - sb.Append(i); - sb.Append(": "); - if (i < firstNotEmpty) { - sb.Append("()"); - } else { - sb.Append(Dump(arr[i])); - } - sb.Append("; "); - } - return sb.ToString(); - } -#endif - - // Invariant: a[i] < a[i+1] for i > item - // returns flase is head of the list was moved & as a result consistancy of list depends on head consistancy. - private bool SiftItem(int item) - { - Debug.Assert(firstNotEmpty <= item && item < arr.Length); - ResetableIterator it = arr[item]; - while (item + 1 < arr.Length) - { - XmlNodeOrder order = Query.CompareNodes(it.Current, arr[item + 1].Current); - if (order == XmlNodeOrder.Before) - { - break; - } - if (order == XmlNodeOrder.After) - { - arr[item] = arr[item + 1]; - //arr[item + 1] = it; - item++; - } - else - { // Same - arr[item] = it; - if (!Advance(item)) - { - return false; - } - it = arr[item]; - } - } - arr[item] = it; - return true; - } - - public override void Reset() - { - firstNotEmpty = 0; - position = 0; - for (int i = 0; i < arr.Length; i++) - { - arr[i].Reset(); - } - Init(); - } - - public XPathMultyIterator(XPathMultyIterator it) - { - this.arr = (ResetableIterator[])it.arr.Clone(); - this.firstNotEmpty = it.firstNotEmpty; - this.position = it.position; - } - - public override XPathNodeIterator Clone() - { - return new XPathMultyIterator(this); - } - - public override XPathNavigator Current - { - get - { - Debug.Assert(position != 0, "MoveNext() wasn't called"); - Debug.Assert(firstNotEmpty < arr.Length, "MoveNext() returned false"); - return arr[firstNotEmpty].Current; - } - } - - public override int CurrentPosition { get { return position; } } - - public override bool MoveNext() - { - // NOTE: MoveNext() may be called even if the previous call to MoveNext() returned false, SQLBUDT 330810 - if (firstNotEmpty >= arr.Length) - { - return false; - } - if (position != 0) - { - if (Advance(firstNotEmpty)) - { - SiftItem(firstNotEmpty); - } - if (firstNotEmpty >= arr.Length) - { - return false; - } - } - position++; - return true; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathParser.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathParser.cs deleted file mode 100644 index 5df836188a4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathParser.cs +++ /dev/null @@ -1,889 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Runtime.InteropServices; - using System.Collections; - - internal class XPathParser - { - private XPathScanner _scanner; - - private XPathParser(XPathScanner scanner) - { - _scanner = scanner; - } - - public static AstNode ParseXPathExpresion(string xpathExpresion) - { - XPathScanner scanner = new XPathScanner(xpathExpresion); - XPathParser parser = new XPathParser(scanner); - AstNode result = parser.ParseExpresion(null); - if (scanner.Kind != XPathScanner.LexKind.Eof) - { - throw XPathException.Create(ResXml.Xp_InvalidToken, scanner.SourceText); - } - return result; - } - - public static AstNode ParseXPathPattern(string xpathPattern) - { - XPathScanner scanner = new XPathScanner(xpathPattern); - XPathParser parser = new XPathParser(scanner); - AstNode result = parser.ParsePattern(null); - if (scanner.Kind != XPathScanner.LexKind.Eof) - { - throw XPathException.Create(ResXml.Xp_InvalidToken, scanner.SourceText); - } - return result; - } - - // --------------- Expresion Parsing ---------------------- - - - //The recursive is like - //ParseOrExpr->ParseAndExpr->ParseEqualityExpr->ParseRelationalExpr...->ParseFilterExpr->ParsePredicate->ParseExpresion - //So put 200 limitation here will max cause about 2000~3000 depth stack. - private int _parseDepth = 0; - private const int MaxParseDepth = 200; - - private AstNode ParseExpresion(AstNode qyInput) - { - if (++_parseDepth > MaxParseDepth) - { - throw XPathException.Create(ResXml.Xp_QueryTooComplex); - } - AstNode result = ParseOrExpr(qyInput); - --_parseDepth; - return result; - } - - //>> OrExpr ::= ( OrExpr 'or' )? AndExpr - private AstNode ParseOrExpr(AstNode qyInput) - { - AstNode opnd = ParseAndExpr(qyInput); - - do - { - if (!TestOp("or")) - { - return opnd; - } - NextLex(); - opnd = new Operator(Operator.Op.OR, opnd, ParseAndExpr(qyInput)); - } while (true); - } - - //>> AndExpr ::= ( AndExpr 'and' )? EqualityExpr - private AstNode ParseAndExpr(AstNode qyInput) - { - AstNode opnd = ParseEqualityExpr(qyInput); - - do - { - if (!TestOp("and")) - { - return opnd; - } - NextLex(); - opnd = new Operator(Operator.Op.AND, opnd, ParseEqualityExpr(qyInput)); - } while (true); - } - - //>> EqualityOp ::= '=' | '!=' - //>> EqualityExpr ::= ( EqualityExpr EqualityOp )? RelationalExpr - private AstNode ParseEqualityExpr(AstNode qyInput) - { - AstNode opnd = ParseRelationalExpr(qyInput); - - do - { - Operator.Op op = ( - _scanner.Kind == XPathScanner.LexKind.Eq ? Operator.Op.EQ : - _scanner.Kind == XPathScanner.LexKind.Ne ? Operator.Op.NE : - /*default :*/ Operator.Op.INVALID - ); - if (op == Operator.Op.INVALID) - { - return opnd; - } - NextLex(); - opnd = new Operator(op, opnd, ParseRelationalExpr(qyInput)); - } while (true); - } - - //>> RelationalOp ::= '<' | '>' | '<=' | '>=' - //>> RelationalExpr ::= ( RelationalExpr RelationalOp )? AdditiveExpr - private AstNode ParseRelationalExpr(AstNode qyInput) - { - AstNode opnd = ParseAdditiveExpr(qyInput); - - do - { - Operator.Op op = ( - _scanner.Kind == XPathScanner.LexKind.Lt ? Operator.Op.LT : - _scanner.Kind == XPathScanner.LexKind.Le ? Operator.Op.LE : - _scanner.Kind == XPathScanner.LexKind.Gt ? Operator.Op.GT : - _scanner.Kind == XPathScanner.LexKind.Ge ? Operator.Op.GE : - /*default :*/ Operator.Op.INVALID - ); - if (op == Operator.Op.INVALID) - { - return opnd; - } - NextLex(); - opnd = new Operator(op, opnd, ParseAdditiveExpr(qyInput)); - } while (true); - } - - //>> AdditiveOp ::= '+' | '-' - //>> AdditiveExpr ::= ( AdditiveExpr AdditiveOp )? MultiplicativeExpr - private AstNode ParseAdditiveExpr(AstNode qyInput) - { - AstNode opnd = ParseMultiplicativeExpr(qyInput); - - do - { - Operator.Op op = ( - _scanner.Kind == XPathScanner.LexKind.Plus ? Operator.Op.PLUS : - _scanner.Kind == XPathScanner.LexKind.Minus ? Operator.Op.MINUS : - /*default :*/ Operator.Op.INVALID - ); - if (op == Operator.Op.INVALID) - { - return opnd; - } - NextLex(); - opnd = new Operator(op, opnd, ParseMultiplicativeExpr(qyInput)); - } while (true); - } - - //>> MultiplicativeOp ::= '*' | 'div' | 'mod' - //>> MultiplicativeExpr ::= ( MultiplicativeExpr MultiplicativeOp )? UnaryExpr - private AstNode ParseMultiplicativeExpr(AstNode qyInput) - { - AstNode opnd = ParseUnaryExpr(qyInput); - - do - { - Operator.Op op = ( - _scanner.Kind == XPathScanner.LexKind.Star ? Operator.Op.MUL : - TestOp("div") ? Operator.Op.DIV : - TestOp("mod") ? Operator.Op.MOD : - /*default :*/ Operator.Op.INVALID - ); - if (op == Operator.Op.INVALID) - { - return opnd; - } - NextLex(); - opnd = new Operator(op, opnd, ParseUnaryExpr(qyInput)); - } while (true); - } - - //>> UnaryExpr ::= UnionExpr | '-' UnaryExpr - private AstNode ParseUnaryExpr(AstNode qyInput) - { - bool minus = false; - while (_scanner.Kind == XPathScanner.LexKind.Minus) - { - NextLex(); - minus = !minus; - } - - if (minus) - { - return new Operator(Operator.Op.MUL, ParseUnionExpr(qyInput), new Operand(-1)); - } - else - { - return ParseUnionExpr(qyInput); - } - } - - //>> UnionExpr ::= ( UnionExpr '|' )? PathExpr - private AstNode ParseUnionExpr(AstNode qyInput) - { - AstNode opnd = ParsePathExpr(qyInput); - - do - { - if (_scanner.Kind != XPathScanner.LexKind.Union) - { - return opnd; - } - NextLex(); - AstNode opnd2 = ParsePathExpr(qyInput); - CheckNodeSet(opnd.ReturnType); - CheckNodeSet(opnd2.ReturnType); - opnd = new Operator(Operator.Op.UNION, opnd, opnd2); - } while (true); - } - - private static bool IsNodeType(XPathScanner scaner) - { - return ( - scaner.Prefix.Length == 0 && ( - scaner.Name == "node" || - scaner.Name == "text" || - scaner.Name == "processing-instruction" || - scaner.Name == "comment" - ) - ); - } - - //>> PathOp ::= '/' | '//' - //>> PathExpr ::= LocationPath | - //>> FilterExpr ( PathOp RelativeLocationPath )? - private AstNode ParsePathExpr(AstNode qyInput) - { - AstNode opnd; - if (IsPrimaryExpr(_scanner)) - { // in this moment we shoud distinct LocationPas vs FilterExpr (which starts from is PrimaryExpr) - opnd = ParseFilterExpr(qyInput); - if (_scanner.Kind == XPathScanner.LexKind.Slash) - { - NextLex(); - opnd = ParseRelativeLocationPath(opnd); - } - else if (_scanner.Kind == XPathScanner.LexKind.SlashSlash) - { - NextLex(); - opnd = ParseRelativeLocationPath(new Axis(Axis.AxisType.DescendantOrSelf, opnd)); - } - } - else - { - opnd = ParseLocationPath(null); - } - - return opnd; - } - - //>> FilterExpr ::= PrimaryExpr | FilterExpr Predicate - private AstNode ParseFilterExpr(AstNode qyInput) - { - AstNode opnd = ParsePrimaryExpr(qyInput); - while (_scanner.Kind == XPathScanner.LexKind.LBracket) - { - // opnd must be a query - opnd = new Filter(opnd, ParsePredicate(opnd)); - } - return opnd; - } - - //>> Predicate ::= '[' Expr ']' - private AstNode ParsePredicate(AstNode qyInput) - { - AstNode opnd; - - // we have predicates. Check that input type is NodeSet - CheckNodeSet(qyInput.ReturnType); - - PassToken(XPathScanner.LexKind.LBracket); - opnd = ParseExpresion(qyInput); - PassToken(XPathScanner.LexKind.RBracket); - - return opnd; - } - - //>> LocationPath ::= RelativeLocationPath | AbsoluteLocationPath - private AstNode ParseLocationPath(AstNode qyInput) - { - if (_scanner.Kind == XPathScanner.LexKind.Slash) - { - NextLex(); - AstNode opnd = new Root(); - - if (IsStep(_scanner.Kind)) - { - opnd = ParseRelativeLocationPath(opnd); - } - return opnd; - } - else if (_scanner.Kind == XPathScanner.LexKind.SlashSlash) - { - NextLex(); - return ParseRelativeLocationPath(new Axis(Axis.AxisType.DescendantOrSelf, new Root())); - } - else - { - return ParseRelativeLocationPath(qyInput); - } - } // ParseLocationPath - - //>> PathOp ::= '/' | '//' - //>> RelativeLocationPath ::= ( RelativeLocationPath PathOp )? Step - private AstNode ParseRelativeLocationPath(AstNode qyInput) - { - AstNode opnd = qyInput; - do - { - opnd = ParseStep(opnd); - if (XPathScanner.LexKind.SlashSlash == _scanner.Kind) - { - NextLex(); - opnd = new Axis(Axis.AxisType.DescendantOrSelf, opnd); - } - else if (XPathScanner.LexKind.Slash == _scanner.Kind) - { - NextLex(); - } - else - { - break; - } - } - while (true); - - return opnd; - } - - private static bool IsStep(XPathScanner.LexKind lexKind) - { - return ( - lexKind == XPathScanner.LexKind.Dot || - lexKind == XPathScanner.LexKind.DotDot || - lexKind == XPathScanner.LexKind.At || - lexKind == XPathScanner.LexKind.Axe || - lexKind == XPathScanner.LexKind.Star || - lexKind == XPathScanner.LexKind.Name // NodeTest is also Name - ); - } - - //>> Step ::= '.' | '..' | ( AxisName '::' | '@' )? NodeTest Predicate* - private AstNode ParseStep(AstNode qyInput) - { - AstNode opnd; - if (XPathScanner.LexKind.Dot == _scanner.Kind) - { //>> '.' - NextLex(); - opnd = new Axis(Axis.AxisType.Self, qyInput); - } - else if (XPathScanner.LexKind.DotDot == _scanner.Kind) - { //>> '..' - NextLex(); - opnd = new Axis(Axis.AxisType.Parent, qyInput); - } - else - { //>> ( AxisName '::' | '@' )? NodeTest Predicate* - Axis.AxisType axisType = Axis.AxisType.Child; - switch (_scanner.Kind) - { - case XPathScanner.LexKind.At: //>> '@' - axisType = Axis.AxisType.Attribute; - NextLex(); - break; - case XPathScanner.LexKind.Axe: //>> AxisName '::' - axisType = GetAxis(_scanner); - NextLex(); - break; - } - XPathNodeType nodeType = ( - axisType == Axis.AxisType.Attribute ? XPathNodeType.Attribute : - // axisType == Axis.AxisType.Namespace ? XPathNodeType.Namespace : // No Idea why it's this way but othervise Axes doesn't work - /* default: */ XPathNodeType.Element - ); - - opnd = ParseNodeTest(qyInput, axisType, nodeType); - - while (XPathScanner.LexKind.LBracket == _scanner.Kind) - { - opnd = new Filter(opnd, ParsePredicate(opnd)); - } - } - return opnd; - } - - //>> NodeTest ::= NameTest | 'comment ()' | 'text ()' | 'node ()' | 'processing-instruction (' Literal ? ')' - private AstNode ParseNodeTest(AstNode qyInput, Axis.AxisType axisType, XPathNodeType nodeType) - { - string nodeName, nodePrefix; - - switch (_scanner.Kind) - { - case XPathScanner.LexKind.Name: - if (_scanner.CanBeFunction && IsNodeType(_scanner)) - { - nodePrefix = string.Empty; - nodeName = string.Empty; - nodeType = ( - _scanner.Name == "comment" ? XPathNodeType.Comment : - _scanner.Name == "text" ? XPathNodeType.Text : - _scanner.Name == "node" ? XPathNodeType.All : - _scanner.Name == "processing-instruction" ? XPathNodeType.ProcessingInstruction : - /* default: */ XPathNodeType.Root - ); - Debug.Assert(nodeType != XPathNodeType.Root); - NextLex(); - - PassToken(XPathScanner.LexKind.LParens); - - if (nodeType == XPathNodeType.ProcessingInstruction) - { - if (_scanner.Kind != XPathScanner.LexKind.RParens) - { //>> 'processing-instruction (' Literal ')' - CheckToken(XPathScanner.LexKind.String); - nodeName = _scanner.StringValue; - NextLex(); - } - } - - PassToken(XPathScanner.LexKind.RParens); - } - else - { - nodePrefix = _scanner.Prefix; - nodeName = _scanner.Name; - NextLex(); - if (nodeName == "*") - { - nodeName = string.Empty; - } - } - break; - case XPathScanner.LexKind.Star: - nodePrefix = string.Empty; - nodeName = string.Empty; - NextLex(); - break; - default: - throw XPathException.Create(ResXml.Xp_NodeSetExpected, _scanner.SourceText); - } - return new Axis(axisType, qyInput, nodePrefix, nodeName, nodeType); - } - - private static bool IsPrimaryExpr(XPathScanner scanner) - { - return ( - scanner.Kind == XPathScanner.LexKind.String || - scanner.Kind == XPathScanner.LexKind.Number || - scanner.Kind == XPathScanner.LexKind.Dollar || - scanner.Kind == XPathScanner.LexKind.LParens || - scanner.Kind == XPathScanner.LexKind.Name && scanner.CanBeFunction && !IsNodeType(scanner) - ); - } - - //>> PrimaryExpr ::= Literal | Number | VariableReference | '(' Expr ')' | FunctionCall - private AstNode ParsePrimaryExpr(AstNode qyInput) - { - Debug.Assert(IsPrimaryExpr(_scanner)); - AstNode opnd = null; - switch (_scanner.Kind) - { - case XPathScanner.LexKind.String: - opnd = new Operand(_scanner.StringValue); - NextLex(); - break; - case XPathScanner.LexKind.Number: - opnd = new Operand(_scanner.NumberValue); - NextLex(); - break; - case XPathScanner.LexKind.Dollar: - NextLex(); - CheckToken(XPathScanner.LexKind.Name); - opnd = new Variable(_scanner.Name, _scanner.Prefix); - NextLex(); - break; - case XPathScanner.LexKind.LParens: - NextLex(); - opnd = ParseExpresion(qyInput); - if (opnd.Type != AstNode.AstType.ConstantOperand) - { - opnd = new Group(opnd); - } - PassToken(XPathScanner.LexKind.RParens); - break; - case XPathScanner.LexKind.Name: - if (_scanner.CanBeFunction && !IsNodeType(_scanner)) - { - opnd = ParseMethod(null); - } - break; - } - Debug.Assert(opnd != null, "IsPrimaryExpr() was true. We should recognize this lex."); - return opnd; - } - - private AstNode ParseMethod(AstNode qyInput) - { - ArrayList argList = new ArrayList(); - string name = _scanner.Name; - string prefix = _scanner.Prefix; - PassToken(XPathScanner.LexKind.Name); - PassToken(XPathScanner.LexKind.LParens); - if (_scanner.Kind != XPathScanner.LexKind.RParens) - { - do - { - argList.Add(ParseExpresion(qyInput)); - if (_scanner.Kind == XPathScanner.LexKind.RParens) - { - break; - } - PassToken(XPathScanner.LexKind.Comma); - } while (true); - } - PassToken(XPathScanner.LexKind.RParens); - if (prefix.Length == 0) - { - ParamInfo pi = (ParamInfo)s_functionTable[name]; - if (pi != null) - { - int argCount = argList.Count; - if (argCount < pi.Minargs) - { - throw XPathException.Create(ResXml.Xp_InvalidNumArgs, name, _scanner.SourceText); - } - if (pi.FType == Function.FunctionType.FuncConcat) - { - for (int i = 0; i < argCount; i++) - { - AstNode arg = (AstNode)argList[i]; - if (arg.ReturnType != XPathResultType.String) - { - arg = new Function(Function.FunctionType.FuncString, arg); - } - argList[i] = arg; - } - } - else - { - if (pi.Maxargs < argCount) - { - throw XPathException.Create(ResXml.Xp_InvalidNumArgs, name, _scanner.SourceText); - } - if (pi.ArgTypes.Length < argCount) - { - argCount = pi.ArgTypes.Length; // argument we have the type specified (can be < pi.Minargs) - } - for (int i = 0; i < argCount; i++) - { - AstNode arg = (AstNode)argList[i]; - if ( - pi.ArgTypes[i] != XPathResultType.Any && - pi.ArgTypes[i] != arg.ReturnType - ) - { - switch (pi.ArgTypes[i]) - { - case XPathResultType.NodeSet: - if (!(arg is Variable) && !(arg is Function && arg.ReturnType == XPathResultType.Any)) - { - throw XPathException.Create(ResXml.Xp_InvalidArgumentType, name, _scanner.SourceText); - } - break; - case XPathResultType.String: - arg = new Function(Function.FunctionType.FuncString, arg); - break; - case XPathResultType.Number: - arg = new Function(Function.FunctionType.FuncNumber, arg); - break; - case XPathResultType.Boolean: - arg = new Function(Function.FunctionType.FuncBoolean, arg); - break; - } - argList[i] = arg; - } - } - } - return new Function(pi.FType, argList); - } - } - return new Function(prefix, name, argList); - } - - // --------------- Pattern Parsing ---------------------- - - //>> Pattern ::= ( Pattern '|' )? LocationPathPattern - private AstNode ParsePattern(AstNode qyInput) - { - AstNode opnd = ParseLocationPathPattern(qyInput); - - do - { - if (_scanner.Kind != XPathScanner.LexKind.Union) - { - return opnd; - } - NextLex(); - opnd = new Operator(Operator.Op.UNION, opnd, ParseLocationPathPattern(qyInput)); - } while (true); - } - - //>> LocationPathPattern ::= '/' | RelativePathPattern | '//' RelativePathPattern | '/' RelativePathPattern - //>> | IdKeyPattern (('/' | '//') RelativePathPattern)? - private AstNode ParseLocationPathPattern(AstNode qyInput) - { - AstNode opnd = null; - switch (_scanner.Kind) - { - case XPathScanner.LexKind.Slash: - NextLex(); - opnd = new Root(); - if (_scanner.Kind == XPathScanner.LexKind.Eof || _scanner.Kind == XPathScanner.LexKind.Union) - { - return opnd; - } - break; - case XPathScanner.LexKind.SlashSlash: - NextLex(); - opnd = new Axis(Axis.AxisType.DescendantOrSelf, new Root()); - break; - case XPathScanner.LexKind.Name: - if (_scanner.CanBeFunction) - { - opnd = ParseIdKeyPattern(qyInput); - if (opnd != null) - { - switch (_scanner.Kind) - { - case XPathScanner.LexKind.Slash: - NextLex(); - break; - case XPathScanner.LexKind.SlashSlash: - NextLex(); - opnd = new Axis(Axis.AxisType.DescendantOrSelf, opnd); - break; - default: - return opnd; - } - } - } - break; - } - return ParseRelativePathPattern(opnd); - } - - //>> IdKeyPattern ::= 'id' '(' Literal ')' | 'key' '(' Literal ',' Literal ')' - private AstNode ParseIdKeyPattern(AstNode qyInput) - { - Debug.Assert(_scanner.CanBeFunction); - ArrayList argList = new ArrayList(); - if (_scanner.Prefix.Length == 0) - { - if (_scanner.Name == "id") - { - ParamInfo pi = (ParamInfo)s_functionTable["id"]; - NextLex(); ; - PassToken(XPathScanner.LexKind.LParens); - CheckToken(XPathScanner.LexKind.String); - argList.Add(new Operand(_scanner.StringValue)); - NextLex(); - PassToken(XPathScanner.LexKind.RParens); - return new Function(pi.FType, argList); - } - if (_scanner.Name == "key") - { - NextLex(); - PassToken(XPathScanner.LexKind.LParens); - CheckToken(XPathScanner.LexKind.String); - argList.Add(new Operand(_scanner.StringValue)); - NextLex(); - PassToken(XPathScanner.LexKind.Comma); - CheckToken(XPathScanner.LexKind.String); - argList.Add(new Operand(_scanner.StringValue)); - NextLex(); - PassToken(XPathScanner.LexKind.RParens); - return new Function("", "key", argList); - } - } - return null; - } - - //>> PathOp ::= '/' | '//' - //>> RelativePathPattern ::= ( RelativePathPattern PathOp )? StepPattern - private AstNode ParseRelativePathPattern(AstNode qyInput) - { - AstNode opnd = ParseStepPattern(qyInput); - if (XPathScanner.LexKind.SlashSlash == _scanner.Kind) - { - NextLex(); - opnd = ParseRelativePathPattern(new Axis(Axis.AxisType.DescendantOrSelf, opnd)); - } - else if (XPathScanner.LexKind.Slash == _scanner.Kind) - { - NextLex(); - opnd = ParseRelativePathPattern(opnd); - } - return opnd; - } - - //>> StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* - //>> ChildOrAttributeAxisSpecifier ::= @ ? | ('child' | 'attribute') '::' - private AstNode ParseStepPattern(AstNode qyInput) - { - AstNode opnd; - Axis.AxisType axisType = Axis.AxisType.Child; - switch (_scanner.Kind) - { - case XPathScanner.LexKind.At: //>> '@' - axisType = Axis.AxisType.Attribute; - NextLex(); - break; - case XPathScanner.LexKind.Axe: //>> AxisName '::' - axisType = GetAxis(_scanner); - if (axisType != Axis.AxisType.Child && axisType != Axis.AxisType.Attribute) - { - throw XPathException.Create(ResXml.Xp_InvalidToken, _scanner.SourceText); - } - NextLex(); - break; - } - XPathNodeType nodeType = ( - axisType == Axis.AxisType.Attribute ? XPathNodeType.Attribute : - /* default: */ XPathNodeType.Element - ); - - opnd = ParseNodeTest(qyInput, axisType, nodeType); - - while (XPathScanner.LexKind.LBracket == _scanner.Kind) - { - opnd = new Filter(opnd, ParsePredicate(opnd)); - } - return opnd; - } - - // --------------- Helper methods ---------------------- - - private void CheckToken(XPathScanner.LexKind t) - { - if (_scanner.Kind != t) - { - throw XPathException.Create(ResXml.Xp_InvalidToken, _scanner.SourceText); - } - } - - private void PassToken(XPathScanner.LexKind t) - { - CheckToken(t); - NextLex(); - } - - private void NextLex() - { - _scanner.NextLex(); - } - - private bool TestOp(string op) - { - return ( - _scanner.Kind == XPathScanner.LexKind.Name && - _scanner.Prefix.Length == 0 && - _scanner.Name.Equals(op) - ); - } - - private void CheckNodeSet(XPathResultType t) - { - if (t != XPathResultType.NodeSet && t != XPathResultType.Any) - { - throw XPathException.Create(ResXml.Xp_NodeSetExpected, _scanner.SourceText); - } - } - - // ---------------------------------------------------------------- - private static readonly XPathResultType[] s_temparray1 = { }; - private static readonly XPathResultType[] s_temparray2 = { XPathResultType.NodeSet }; - private static readonly XPathResultType[] s_temparray3 = { XPathResultType.Any }; - private static readonly XPathResultType[] s_temparray4 = { XPathResultType.String }; - private static readonly XPathResultType[] s_temparray5 = { XPathResultType.String, XPathResultType.String }; - private static readonly XPathResultType[] s_temparray6 = { XPathResultType.String, XPathResultType.Number, XPathResultType.Number }; - private static readonly XPathResultType[] s_temparray7 = { XPathResultType.String, XPathResultType.String, XPathResultType.String }; - private static readonly XPathResultType[] s_temparray8 = { XPathResultType.Boolean }; - private static readonly XPathResultType[] s_temparray9 = { XPathResultType.Number }; - - private class ParamInfo - { - private Function.FunctionType _ftype; - private int _minargs; - private int _maxargs; - private XPathResultType[] _argTypes; - - public Function.FunctionType FType { get { return _ftype; } } - public int Minargs { get { return _minargs; } } - public int Maxargs { get { return _maxargs; } } - public XPathResultType[] ArgTypes { get { return _argTypes; } } - - internal ParamInfo(Function.FunctionType ftype, int minargs, int maxargs, XPathResultType[] argTypes) - { - _ftype = ftype; - _minargs = minargs; - _maxargs = maxargs; - _argTypes = argTypes; - } - } //ParamInfo - - private static Hashtable s_functionTable = CreateFunctionTable(); - private static Hashtable CreateFunctionTable() - { - Hashtable table = new Hashtable(36); - table.Add("last", new ParamInfo(Function.FunctionType.FuncLast, 0, 0, s_temparray1)); - table.Add("position", new ParamInfo(Function.FunctionType.FuncPosition, 0, 0, s_temparray1)); - table.Add("name", new ParamInfo(Function.FunctionType.FuncName, 0, 1, s_temparray2)); - table.Add("namespace-uri", new ParamInfo(Function.FunctionType.FuncNameSpaceUri, 0, 1, s_temparray2)); - table.Add("local-name", new ParamInfo(Function.FunctionType.FuncLocalName, 0, 1, s_temparray2)); - table.Add("count", new ParamInfo(Function.FunctionType.FuncCount, 1, 1, s_temparray2)); - table.Add("id", new ParamInfo(Function.FunctionType.FuncID, 1, 1, s_temparray3)); - table.Add("string", new ParamInfo(Function.FunctionType.FuncString, 0, 1, s_temparray3)); - table.Add("concat", new ParamInfo(Function.FunctionType.FuncConcat, 2, 100, s_temparray4)); - table.Add("starts-with", new ParamInfo(Function.FunctionType.FuncStartsWith, 2, 2, s_temparray5)); - table.Add("contains", new ParamInfo(Function.FunctionType.FuncContains, 2, 2, s_temparray5)); - table.Add("substring-before", new ParamInfo(Function.FunctionType.FuncSubstringBefore, 2, 2, s_temparray5)); - table.Add("substring-after", new ParamInfo(Function.FunctionType.FuncSubstringAfter, 2, 2, s_temparray5)); - table.Add("substring", new ParamInfo(Function.FunctionType.FuncSubstring, 2, 3, s_temparray6)); - table.Add("string-length", new ParamInfo(Function.FunctionType.FuncStringLength, 0, 1, s_temparray4)); - table.Add("normalize-space", new ParamInfo(Function.FunctionType.FuncNormalize, 0, 1, s_temparray4)); - table.Add("translate", new ParamInfo(Function.FunctionType.FuncTranslate, 3, 3, s_temparray7)); - table.Add("boolean", new ParamInfo(Function.FunctionType.FuncBoolean, 1, 1, s_temparray3)); - table.Add("not", new ParamInfo(Function.FunctionType.FuncNot, 1, 1, s_temparray8)); - table.Add("true", new ParamInfo(Function.FunctionType.FuncTrue, 0, 0, s_temparray8)); - table.Add("false", new ParamInfo(Function.FunctionType.FuncFalse, 0, 0, s_temparray8)); - table.Add("lang", new ParamInfo(Function.FunctionType.FuncLang, 1, 1, s_temparray4)); - table.Add("number", new ParamInfo(Function.FunctionType.FuncNumber, 0, 1, s_temparray3)); - table.Add("sum", new ParamInfo(Function.FunctionType.FuncSum, 1, 1, s_temparray2)); - table.Add("floor", new ParamInfo(Function.FunctionType.FuncFloor, 1, 1, s_temparray9)); - table.Add("ceiling", new ParamInfo(Function.FunctionType.FuncCeiling, 1, 1, s_temparray9)); - table.Add("round", new ParamInfo(Function.FunctionType.FuncRound, 1, 1, s_temparray9)); - return table; - } - - private static Hashtable s_axesTable = CreateAxesTable(); - private static Hashtable CreateAxesTable() - { - Hashtable table = new Hashtable(13); - table.Add("ancestor", Axis.AxisType.Ancestor); - table.Add("ancestor-or-self", Axis.AxisType.AncestorOrSelf); - table.Add("attribute", Axis.AxisType.Attribute); - table.Add("child", Axis.AxisType.Child); - table.Add("descendant", Axis.AxisType.Descendant); - table.Add("descendant-or-self", Axis.AxisType.DescendantOrSelf); - table.Add("following", Axis.AxisType.Following); - table.Add("following-sibling", Axis.AxisType.FollowingSibling); - table.Add("namespace", Axis.AxisType.Namespace); - table.Add("parent", Axis.AxisType.Parent); - table.Add("preceding", Axis.AxisType.Preceding); - table.Add("preceding-sibling", Axis.AxisType.PrecedingSibling); - table.Add("self", Axis.AxisType.Self); - return table; - } - - private Axis.AxisType GetAxis(XPathScanner scaner) - { - Debug.Assert(scaner.Kind == XPathScanner.LexKind.Axe); - object axis = s_axesTable[scaner.Name]; - if (axis == null) - { - throw XPathException.Create(ResXml.Xp_InvalidToken, _scanner.SourceText); - } - return (Axis.AxisType)axis; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathScanner.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathScanner.cs deleted file mode 100644 index afce623e641..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathScanner.cs +++ /dev/null @@ -1,406 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Text; - using System.Collections; - - internal sealed class XPathScanner - { - private string _xpathExpr; - private int _xpathExprIndex; - private LexKind _kind; - private char _currentChar; - private string _name; - private string _prefix; - private string _stringValue; - private double _numberValue = double.NaN; - private bool _canBeFunction; - private XmlCharType _xmlCharType = XmlCharType.Instance; - - public XPathScanner(string xpathExpr) - { - if (xpathExpr == null) - { - throw XPathException.Create(ResXml.Xp_ExprExpected, string.Empty); - } - _xpathExpr = xpathExpr; - NextChar(); - NextLex(); - } - - public string SourceText { get { return _xpathExpr; } } - - private char CurerntChar { get { return _currentChar; } } - - private bool NextChar() - { - Debug.Assert(0 <= _xpathExprIndex && _xpathExprIndex <= _xpathExpr.Length); - if (_xpathExprIndex < _xpathExpr.Length) - { - _currentChar = _xpathExpr[_xpathExprIndex++]; - return true; - } - else - { - _currentChar = '\0'; - return false; - } - } - -#if XML10_FIFTH_EDITION - private char PeekNextChar() { - Debug.Assert(0 <= xpathExprIndex && xpathExprIndex <= xpathExpr.Length); - if (xpathExprIndex < xpathExpr.Length) { - return xpathExpr[xpathExprIndex]; - } - else { - Debug.Assert(xpathExprIndex == xpathExpr.Length); - return '\0'; - } - } -#endif - - public LexKind Kind { get { return _kind; } } - - public string Name - { - get - { - Debug.Assert(_kind == LexKind.Name || _kind == LexKind.Axe); - Debug.Assert(_name != null); - return _name; - } - } - - public string Prefix - { - get - { - Debug.Assert(_kind == LexKind.Name); - Debug.Assert(_prefix != null); - return _prefix; - } - } - - public string StringValue - { - get - { - Debug.Assert(_kind == LexKind.String); - Debug.Assert(_stringValue != null); - return _stringValue; - } - } - - public double NumberValue - { - get - { - Debug.Assert(_kind == LexKind.Number); - Debug.Assert(_numberValue != double.NaN); - return _numberValue; - } - } - - // To parse PathExpr we need a way to distinct name from function. - // THis distinction can't be done without context: "or (1 != 0)" this this a function or 'or' in OrExp - public bool CanBeFunction - { - get - { - Debug.Assert(_kind == LexKind.Name); - return _canBeFunction; - } - } - - private void SkipSpace() - { - while (_xmlCharType.IsWhiteSpace(this.CurerntChar) && NextChar()) ; - } - - public bool NextLex() - { - SkipSpace(); - switch (this.CurerntChar) - { - case '\0': - _kind = LexKind.Eof; - return false; - case ',': - case '@': - case '(': - case ')': - case '|': - case '*': - case '[': - case ']': - case '+': - case '-': - case '=': - case '#': - case '$': - _kind = (LexKind)Convert.ToInt32(this.CurerntChar, CultureInfo.InvariantCulture); - NextChar(); - break; - case '<': - _kind = LexKind.Lt; - NextChar(); - if (this.CurerntChar == '=') - { - _kind = LexKind.Le; - NextChar(); - } - break; - case '>': - _kind = LexKind.Gt; - NextChar(); - if (this.CurerntChar == '=') - { - _kind = LexKind.Ge; - NextChar(); - } - break; - case '!': - _kind = LexKind.Bang; - NextChar(); - if (this.CurerntChar == '=') - { - _kind = LexKind.Ne; - NextChar(); - } - break; - case '.': - _kind = LexKind.Dot; - NextChar(); - if (this.CurerntChar == '.') - { - _kind = LexKind.DotDot; - NextChar(); - } - else if (XmlCharType.IsDigit(this.CurerntChar)) - { - _kind = LexKind.Number; - _numberValue = ScanFraction(); - } - break; - case '/': - _kind = LexKind.Slash; - NextChar(); - if (this.CurerntChar == '/') - { - _kind = LexKind.SlashSlash; - NextChar(); - } - break; - case '"': - case '\'': - _kind = LexKind.String; - _stringValue = ScanString(); - break; - default: - if (XmlCharType.IsDigit(this.CurerntChar)) - { - _kind = LexKind.Number; - _numberValue = ScanNumber(); - } - else if (_xmlCharType.IsStartNCNameSingleChar(this.CurerntChar) -#if XML10_FIFTH_EDITION - || xmlCharType.IsNCNameHighSurrogateChar(this.CurerntChar) -#endif - ) - { - _kind = LexKind.Name; - _name = ScanName(); - _prefix = string.Empty; - // "foo:bar" is one lexem not three because it doesn't allow spaces in between - // We should distinct it from "foo::" and need process "foo ::" as well - if (this.CurerntChar == ':') - { - NextChar(); - // can be "foo:bar" or "foo::" - if (this.CurerntChar == ':') - { // "foo::" - NextChar(); - _kind = LexKind.Axe; - } - else - { // "foo:*", "foo:bar" or "foo: " - _prefix = _name; - if (this.CurerntChar == '*') - { - NextChar(); - _name = "*"; - } - else if (_xmlCharType.IsStartNCNameSingleChar(this.CurerntChar) -#if XML10_FIFTH_EDITION - || xmlCharType.IsNCNameHighSurrogateChar(this.CurerntChar) -#endif - ) - { - _name = ScanName(); - } - else - { - throw XPathException.Create(ResXml.Xp_InvalidName, SourceText); - } - } - } - else - { - SkipSpace(); - if (this.CurerntChar == ':') - { - NextChar(); - // it can be "foo ::" or just "foo :" - if (this.CurerntChar == ':') - { - NextChar(); - _kind = LexKind.Axe; - } - else - { - throw XPathException.Create(ResXml.Xp_InvalidName, SourceText); - } - } - } - SkipSpace(); - _canBeFunction = (this.CurerntChar == '('); - } - else - { - throw XPathException.Create(ResXml.Xp_InvalidToken, SourceText); - } - break; - } - return true; - } - - private double ScanNumber() - { - Debug.Assert(this.CurerntChar == '.' || XmlCharType.IsDigit(this.CurerntChar)); - int start = _xpathExprIndex - 1; - int len = 0; - while (XmlCharType.IsDigit(this.CurerntChar)) - { - NextChar(); len++; - } - if (this.CurerntChar == '.') - { - NextChar(); len++; - while (XmlCharType.IsDigit(this.CurerntChar)) - { - NextChar(); len++; - } - } - return XmlConvert.ToXPathDouble(_xpathExpr.Substring(start, len)); - } - - private double ScanFraction() - { - Debug.Assert(XmlCharType.IsDigit(this.CurerntChar)); - int start = _xpathExprIndex - 2; - Debug.Assert(0 <= start && _xpathExpr[start] == '.'); - int len = 1; // '.' - while (XmlCharType.IsDigit(this.CurerntChar)) - { - NextChar(); len++; - } - return XmlConvert.ToXPathDouble(_xpathExpr.Substring(start, len)); - } - - private string ScanString() - { - char endChar = this.CurerntChar; - NextChar(); - int start = _xpathExprIndex - 1; - int len = 0; - while (this.CurerntChar != endChar) - { - if (!NextChar()) - { - throw XPathException.Create(ResXml.Xp_UnclosedString); - } - len++; - } - Debug.Assert(this.CurerntChar == endChar); - NextChar(); - return _xpathExpr.Substring(start, len); - } - - private string ScanName() - { - Debug.Assert(_xmlCharType.IsStartNCNameSingleChar(this.CurerntChar) -#if XML10_FIFTH_EDITION - || xmlCharType.IsNCNameHighSurrogateChar(this.CurerntChar) -#endif - ); - int start = _xpathExprIndex - 1; - int len = 0; - - for (; ; ) - { - if (_xmlCharType.IsNCNameSingleChar(this.CurerntChar)) - { - NextChar(); - len++; - } -#if XML10_FIFTH_EDITION - else if (xmlCharType.IsNCNameSurrogateChar(this.PeekNextChar(), this.CurerntChar)) { - NextChar(); - NextChar(); - len += 2; - } -#endif - else - { - break; - } - } - return _xpathExpr.Substring(start, len); - } - - public enum LexKind - { - Comma = ',', - Slash = '/', - At = '@', - Dot = '.', - LParens = '(', - RParens = ')', - LBracket = '[', - RBracket = ']', - Star = '*', - Plus = '+', - Minus = '-', - Eq = '=', - Lt = '<', - Gt = '>', - Bang = '!', - Dollar = '$', - Apos = '\'', - Quote = '"', - Union = '|', - Ne = 'N', // != - Le = 'L', // <= - Ge = 'G', // >= - And = 'A', // && - Or = 'O', // || - DotDot = 'D', // .. - SlashSlash = 'S', // // - Name = 'n', // XML _Name - String = 's', // Quoted string constant - Number = 'd', // _Number constant - Axe = 'a', // Axe (like child::) - Eof = 'E', - }; - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelectionIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelectionIterator.cs deleted file mode 100644 index c42d0d92e6a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelectionIterator.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - // We need this wrapper object to: - // 1. Calculate position - // 2. Protect internal query.Current from user who may call MoveNext(). - internal class XPathSelectionIterator : ResetableIterator - { - private XPathNavigator _nav; - private Query _query; - private int _position; - - internal XPathSelectionIterator(XPathNavigator nav, Query query) - { - _nav = nav.Clone(); - _query = query; - } - - protected XPathSelectionIterator(XPathSelectionIterator it) - { - _nav = it._nav.Clone(); - _query = (Query)it._query.Clone(); - _position = it._position; - } - - public override void Reset() - { - _query.Reset(); - } - - public override bool MoveNext() - { - XPathNavigator n = _query.Advance(); - if (n != null) - { - _position++; - if (!_nav.MoveTo(n)) - { - _nav = n.Clone(); - } - return true; - } - return false; - } - - public override int Count { get { return _query.Count; } } - public override XPathNavigator Current { get { return _nav; } } - public override int CurrentPosition { get { return _position; } } - public override XPathNodeIterator Clone() { return new XPathSelectionIterator(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelfQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelfQuery.cs deleted file mode 100644 index 2db13946ef3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSelfQuery.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal sealed class XPathSelfQuery : BaseAxisQuery - { - public XPathSelfQuery(Query qyInput, string Name, string Prefix, XPathNodeType Type) : base(qyInput, Name, Prefix, Type) { } - private XPathSelfQuery(XPathSelfQuery other) : base(other) { } - - public override XPathNavigator Advance() - { - while ((currentNode = qyInput.Advance()) != null) - { - if (matches(currentNode)) - { - position = 1; - return currentNode; - } - } - return null; - } - - public override XPathNodeIterator Clone() { return new XPathSelfQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSingletonIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSingletonIterator.cs deleted file mode 100644 index 65d82b3d583..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XPathSingletonIterator.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - - internal class XPathSingletonIterator : ResetableIterator - { - private XPathNavigator _nav; - private int _position; - - public XPathSingletonIterator(XPathNavigator nav) - { - Debug.Assert(nav != null); - _nav = nav; - } - - public XPathSingletonIterator(XPathNavigator nav, bool moved) : this(nav) - { - if (moved) - { - _position = 1; - } - } - - public XPathSingletonIterator(XPathSingletonIterator it) - { - _nav = it._nav.Clone(); - _position = it._position; - } - - public override XPathNodeIterator Clone() - { - return new XPathSingletonIterator(this); - } - - public override XPathNavigator Current - { - get { return _nav; } - } - - public override int CurrentPosition - { - get { return _position; } - } - - public override int Count - { - get { return 1; } - } - - public override bool MoveNext() - { - if (_position == 0) - { - _position = 1; - return true; - } - return false; - } - - public override void Reset() - { - _position = 0; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XmlIteratorQuery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XmlIteratorQuery.cs deleted file mode 100644 index e5fa9c85946..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/XmlIteratorQuery.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.Collections; - - internal class XmlIteratorQuery : Query - { - private ResetableIterator _it; - - public XmlIteratorQuery(XPathNodeIterator it) - { - _it = it as ResetableIterator; - if (_it == null) - { - _it = new XPathArrayIterator(it); - } - } - protected XmlIteratorQuery(XmlIteratorQuery other) : base(other) - { - _it = (ResetableIterator)other._it.Clone(); - } - - public override XPathNavigator Current { get { return _it.Current; } } - - public override XPathNavigator Advance() - { - if (_it.MoveNext()) - { - return _it.Current; - } - return null; - } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - - public override void Reset() - { - _it.Reset(); - } - - public override XPathNodeIterator Clone() { return new XmlIteratorQuery(this); } - - public override int CurrentPosition { get { return _it.CurrentPosition; } } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - return _it; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/baseaxisquery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/baseaxisquery.cs deleted file mode 100644 index 7870dcd0b5e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/baseaxisquery.cs +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using Microsoft.Xml.Xsl; - using System.Collections; - - internal abstract class BaseAxisQuery : Query - { - internal Query qyInput; - private bool _nameTest; - private string _name; - private string _prefix; - private string _nsUri; - private XPathNodeType _typeTest; - - // these two things are the state of this class - // that need to be reset whenever the context changes. - protected XPathNavigator currentNode; - protected int position; - - protected BaseAxisQuery(Query qyInput) - { - _name = string.Empty; - _prefix = string.Empty; - _nsUri = string.Empty; - this.qyInput = qyInput; - } - protected BaseAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) - { - Debug.Assert(qyInput != null); - this.qyInput = qyInput; - _name = name; - _prefix = prefix; - _typeTest = typeTest; - _nameTest = prefix.Length != 0 || name.Length != 0; - _nsUri = string.Empty; - } - protected BaseAxisQuery(BaseAxisQuery other) : base(other) - { - this.qyInput = Clone(other.qyInput); - _name = other._name; - _prefix = other._prefix; - _nsUri = other._nsUri; - _typeTest = other._typeTest; - _nameTest = other._nameTest; - this.position = other.position; - this.currentNode = other.currentNode; - } - - public override void Reset() - { - position = 0; - currentNode = null; // After this current will not point to context node from Evaluate() call - // But this is ok, becuase there is no public Reset() on XPathNodeIterator - qyInput.Reset(); - } - - public override void SetXsltContext(XsltContext context) - { - Debug.Assert(context != null); - _nsUri = context.LookupNamespace(_prefix); - qyInput.SetXsltContext(context); - } - - protected string Name { get { return _name; } } - protected string Prefix { get { return _prefix; } } - protected string Namespace { get { return _nsUri; } } - protected bool NameTest { get { return _nameTest; } } - protected XPathNodeType TypeTest { get { return _typeTest; } } - - public override int CurrentPosition { get { return position; } } - public override XPathNavigator Current { get { return currentNode; } } - - public virtual bool matches(XPathNavigator e) - { - if ( - TypeTest == e.NodeType || - TypeTest == XPathNodeType.All || - TypeTest == XPathNodeType.Text && (e.NodeType == XPathNodeType.Whitespace || e.NodeType == XPathNodeType.SignificantWhitespace) - ) - { - if (NameTest) - { - if (_name.Equals(e.LocalName) || _name.Length == 0) - { - if (_nsUri.Equals(e.NamespaceURI)) - { - return true; - } - } - } - else - { - return true; - } - } - return false; - } - - public override object Evaluate(XPathNodeIterator nodeIterator) - { - ResetCount(); - Reset(); - qyInput.Evaluate(nodeIterator); - AssertQuery(qyInput); - return this; - } - - public override double XsltDefaultPriority - { - get - { - if (qyInput.GetType() != typeof(ContextQuery)) - { - return 0.5; // a/b a[b] id('s')/a - } - Debug.Assert(this is AttributeQuery || this is ChildrenQuery); - if (_name.Length != 0) - { - return 0; // p:foo, foo, processing-instruction("foo") - } - if (_prefix.Length != 0) - { - return -0.25; // p:* - } - return -0.5; // *, text(), node() - } - } - - public override XPathResultType StaticType { get { return XPathResultType.NodeSet; } } - - public override void PrintQuery(XmlWriter w) - { - w.WriteStartElement(this.GetType().Name); - if (NameTest) - { - w.WriteAttributeString("name", Prefix.Length != 0 ? Prefix + ':' + Name : Name); - } - if (TypeTest != XPathNodeType.Element) - { - w.WriteAttributeString("nodeType", TypeTest.ToString()); - } - qyInput.PrintQuery(w); - w.WriteEndElement(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingquery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingquery.cs deleted file mode 100644 index 7d0043b5e05..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingquery.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - - internal sealed class FollowingQuery : BaseAxisQuery - { - private XPathNavigator _input; - private XPathNodeIterator _iterator; - - public FollowingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) { } - private FollowingQuery(FollowingQuery other) : base(other) - { - _input = Clone(other._input); - _iterator = Clone(other._iterator); - } - - public override void Reset() - { - _iterator = null; - base.Reset(); - } - - public override XPathNavigator Advance() - { - if (_iterator == null) - { - _input = qyInput.Advance(); - if (_input == null) - { - return null; - } - - XPathNavigator prev; - do - { - prev = _input.Clone(); - _input = qyInput.Advance(); - } while (prev.IsDescendant(_input)); - _input = prev; - - _iterator = XPathEmptyIterator.Instance; - } - - while (!_iterator.MoveNext()) - { - bool matchSelf; - if (_input.NodeType == XPathNodeType.Attribute || _input.NodeType == XPathNodeType.Namespace) - { - _input.MoveToParent(); - matchSelf = false; - } - else - { - while (!_input.MoveToNext()) - { - if (!_input.MoveToParent()) - { - return null; - } - } - matchSelf = true; - } - if (NameTest) - { - _iterator = _input.SelectDescendants(Name, Namespace, matchSelf); - } - else - { - _iterator = _input.SelectDescendants(TypeTest, matchSelf); - } - } - position++; - currentNode = _iterator.Current; - return currentNode; - } - - public override XPathNodeIterator Clone() { return new FollowingQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingsibling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingsibling.cs deleted file mode 100644 index b4a39e39cef..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/followingsibling.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections.Generic; - using StackNav = ClonableStack; - - internal sealed class FollSiblingQuery : BaseAxisQuery - { - private StackNav _elementStk; - private List _parentStk; - private XPathNavigator _nextInput; - - public FollSiblingQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base(qyInput, name, prefix, type) - { - _elementStk = new StackNav(); - _parentStk = new List(); - } - private FollSiblingQuery(FollSiblingQuery other) : base(other) - { - _elementStk = other._elementStk.Clone(); - _parentStk = new List(other._parentStk); - _nextInput = Clone(other._nextInput); - } - - public override void Reset() - { - _elementStk.Clear(); - _parentStk.Clear(); - _nextInput = null; - base.Reset(); - } - - private bool Visited(XPathNavigator nav) - { - XPathNavigator parent = nav.Clone(); - parent.MoveToParent(); - for (int i = 0; i < _parentStk.Count; i++) - { - if (parent.IsSamePosition(_parentStk[i])) - { - return true; - } - } - _parentStk.Add(parent); - return false; - } - - private XPathNavigator FetchInput() - { - XPathNavigator input; - do - { - input = qyInput.Advance(); - if (input == null) - { - return null; - } - } while (Visited(input)); - return input.Clone(); - } - - public override XPathNavigator Advance() - { - while (true) - { - if (currentNode == null) - { - if (_nextInput == null) - { - _nextInput = FetchInput(); // This can happen at the begining and at the end - } - if (_elementStk.Count == 0) - { - if (_nextInput == null) - { - return null; - } - currentNode = _nextInput; - _nextInput = FetchInput(); - } - else - { - currentNode = _elementStk.Pop(); - } - } - - while (currentNode.IsDescendant(_nextInput)) - { - _elementStk.Push(currentNode); - currentNode = _nextInput; - _nextInput = qyInput.Advance(); - if (_nextInput != null) - { - _nextInput = _nextInput.Clone(); - } - } - - while (currentNode.MoveToNext()) - { - if (matches(currentNode)) - { - position++; - return currentNode; - } - } - currentNode = null; - } - } // Advance - - public override XPathNodeIterator Clone() { return new FollSiblingQuery(this); } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingquery.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingquery.cs deleted file mode 100644 index f0f1977c2b1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingquery.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections.Generic; - using StackNav = ClonableStack; - - // Algorithm: - // Input assumption: qyInput is in DocOrder. - // Preceding of a sequence of nodes will be preceding of last node in DocOrder in that sequence. - // Because qyInput is in DO last input is last node in DO. -- "last" - // If last node is attribute or namespace move last to it element. - // Push this last node and all its ancestors into the ancestorStk. The root node will be the top-most element on the stack. - // Create descendent iterator from the root. -- "workIterator" - // Advancing workIterator we meet all nodes from the ancestorStk in stack order. Nodes in ancestorStk do no belong to the - // the 'preceding' axis and must be ignored. - // Last node in ancestorStk is a centinel node; when we pop it from ancestorStk, we should stop iterations. - - internal sealed class PrecedingQuery : BaseAxisQuery - { - private XPathNodeIterator _workIterator; - private StackNav _ancestorStk; - - public PrecedingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) - { - _ancestorStk = new StackNav(); - } - private PrecedingQuery(PrecedingQuery other) : base(other) - { - _workIterator = Clone(other._workIterator); - _ancestorStk = other._ancestorStk.Clone(); - } - - public override void Reset() - { - _workIterator = null; - _ancestorStk.Clear(); - base.Reset(); - } - - public override XPathNavigator Advance() - { - if (_workIterator == null) - { - XPathNavigator last; - { - XPathNavigator input = qyInput.Advance(); - if (input == null) - { - return null; - } - last = input.Clone(); - do - { - last.MoveTo(input); - } while ((input = qyInput.Advance()) != null); - - if (last.NodeType == XPathNodeType.Attribute || last.NodeType == XPathNodeType.Namespace) - { - last.MoveToParent(); - } - } - // Fill ancestorStk : - do - { - _ancestorStk.Push(last.Clone()); - } while (last.MoveToParent()); - // Create workIterator : - // last.MoveToRoot(); We are on root already - _workIterator = last.SelectDescendants(XPathNodeType.All, true); - } - - while (_workIterator.MoveNext()) - { - currentNode = _workIterator.Current; - if (currentNode.IsSamePosition(_ancestorStk.Peek())) - { - _ancestorStk.Pop(); - if (_ancestorStk.Count == 0) - { - currentNode = null; - _workIterator = null; - Debug.Assert(qyInput.Advance() == null, "we read all qyInput.Advance() already"); - return null; - } - continue; - } - if (matches(currentNode)) - { - position++; - return currentNode; - } - } - Debug.Fail("Algorithm error: we missed the centinel node"); - return null; - } - - public override XPathNodeIterator Clone() { return new PrecedingQuery(this); } - public override QueryProps Properties { get { return base.Properties | QueryProps.Reverse; } } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingsibling.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingsibling.cs deleted file mode 100644 index d8e31a8a092..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/precedingsibling.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections.Generic; - - // This class can be rewritten much more efficient. - // Algorithm could be like one for FollowingSibling: - // - Build InputArrays: pares (first, sentinel) - // -- Cash all input nodes as sentinel - // -- Add firts node of its parent for each input node. - // -- Sort these pares by first nodes. - // - Advance algorithm will look like: - // -- For each row in InputArays we will output first node + all its following nodes which are < sentinel - // -- Before outputing each node in row #I we will check that it is < first node in row #I+1 - // --- if true we actualy output it - // --- if false, we hold with row #I and apply this algorith starting for row #I+1 - // --- when we done with #I+1 we continue with row #I - - internal class PreSiblingQuery : CacheAxisQuery - { - public PreSiblingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest) : base(qyInput, name, prefix, typeTest) { } - protected PreSiblingQuery(PreSiblingQuery other) : base(other) { } - - private bool NotVisited(XPathNavigator nav, List parentStk) - { - XPathNavigator nav1 = nav.Clone(); - nav1.MoveToParent(); - for (int i = 0; i < parentStk.Count; i++) - { - if (nav1.IsSamePosition(parentStk[i])) - { - return false; - } - } - parentStk.Add(nav1); - return true; - } - - public override object Evaluate(XPathNodeIterator context) - { - base.Evaluate(context); - - // Fill up base.outputBuffer - List parentStk = new List(); - Stack inputStk = new Stack(); - while ((currentNode = qyInput.Advance()) != null) - { - inputStk.Push(currentNode.Clone()); - } - while (inputStk.Count != 0) - { - XPathNavigator input = inputStk.Pop(); - if (input.NodeType == XPathNodeType.Attribute || input.NodeType == XPathNodeType.Namespace) - { - continue; - } - if (NotVisited(input, parentStk)) - { - XPathNavigator prev = input.Clone(); - if (prev.MoveToParent()) - { - bool test = prev.MoveToFirstChild(); - Debug.Assert(test, "We just moved to parent, how we can not have first child?"); - while (!prev.IsSamePosition(input)) - { - if (matches(prev)) - { - Insert(outputBuffer, prev); - } - if (!prev.MoveToNext()) - { - Debug.Fail("We managed to miss sentinel node (input)"); - break; - } - } - } - } - } - return this; - } - - public override XPathNodeIterator Clone() { return new PreSiblingQuery(this); } - public override QueryProps Properties { get { return base.Properties | QueryProps.Reverse; } } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/querybuilder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/querybuilder.cs deleted file mode 100644 index 7c5edfc3adb..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/Internal/querybuilder.cs +++ /dev/null @@ -1,542 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.Xml.XPath -{ - using System; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Collections; - using System.Collections.Generic; - using FT = Function.FunctionType; - - internal sealed class QueryBuilder - { - // Note: Up->Doun, Down->Up: - // For operators order is normal: 1 + 2 --> Operator+(1, 2) - // For pathes order is reversed: a/b -> ChildQuery_B(input: ChildQuery_A(input: ContextQuery())) - // Input flags. We pass them Up->Down. - // Using them upper query set states wich controls how inner query will be built. - private enum Flags - { - None = 0x00, - SmartDesc = 0x01, - PosFilter = 0x02, // Node has this flag set when it has position predicate applied to it - Filter = 0x04, // Subtree we compiling will be filtered. i.e. Flag not set on rightmost filter. - } - // Output props. We return them Down->Up. - // These are properties of Query tree we have built already. - // These properties are closely related to QueryProps exposed by Query node itself. - // They have the following difference: - // QueryProps describe property of node they are (belong like Reverse) - // these Props describe acumulated properties of the tree (like nonFlat) - private enum Props - { - None = 0x00, - PosFilter = 0x01, // This filter or inner filter was positional: foo[1] or foo[1][true()] - HasPosition = 0x02, // Expression may ask position() of the context - HasLast = 0x04, // Expression may ask last() of the context - NonFlat = 0x08, // Some nodes may be descendent of otheres - } - - // comment are aproximate. This is my best understanding: - private string _query; - private bool _allowVar; - private bool _allowKey; - private bool _allowCurrent; - private bool _needContext; - private BaseAxisQuery _firstInput; // Input of the leftmost predicate. Set by leftmost predicate, used in rightmost one - - private void Reset() - { - _parseDepth = 0; - _needContext = false; - } - - private Query ProcessAxis(Axis root, Flags flags, out Props props) - { - Query result = null; - if (root.Prefix.Length > 0) - { - _needContext = true; - } - _firstInput = null; - Query qyInput; - { - if (root.Input != null) - { - Flags inputFlags = Flags.None; - if ((flags & Flags.PosFilter) == 0) - { - Axis input = root.Input as Axis; - if (input != null) - { - if ( - root.TypeOfAxis == Axis.AxisType.Child && - input.TypeOfAxis == Axis.AxisType.DescendantOrSelf && input.NodeType == XPathNodeType.All - ) - { - Query qyGrandInput; - if (input.Input != null) - { - qyGrandInput = ProcessNode(input.Input, Flags.SmartDesc, out props); - } - else - { - qyGrandInput = new ContextQuery(); - props = Props.None; - } - result = new DescendantQuery(qyGrandInput, root.Name, root.Prefix, root.NodeType, false, input.AbbrAxis); - if ((props & Props.NonFlat) != 0) - { - result = new DocumentOrderQuery(result); - } - props |= Props.NonFlat; - return result; - } - } - if (root.TypeOfAxis == Axis.AxisType.Descendant || root.TypeOfAxis == Axis.AxisType.DescendantOrSelf) - { - inputFlags |= Flags.SmartDesc; - } - } - - qyInput = ProcessNode(root.Input, inputFlags, out props); - } - else - { - qyInput = new ContextQuery(); - props = Props.None; - } - } - - switch (root.TypeOfAxis) - { - case Axis.AxisType.Ancestor: - result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, false); - props |= Props.NonFlat; - break; - case Axis.AxisType.AncestorOrSelf: - result = new XPathAncestorQuery(qyInput, root.Name, root.Prefix, root.NodeType, true); - props |= Props.NonFlat; - break; - case Axis.AxisType.Child: - if ((props & Props.NonFlat) != 0) - { - result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType); - } - else - { - result = new ChildrenQuery(qyInput, root.Name, root.Prefix, root.NodeType); - } - break; - case Axis.AxisType.Parent: - result = new ParentQuery(qyInput, root.Name, root.Prefix, root.NodeType); - break; - case Axis.AxisType.Descendant: - if ((flags & Flags.SmartDesc) != 0) - { - result = new DescendantOverDescendantQuery(qyInput, false, root.Name, root.Prefix, root.NodeType, /*abbrAxis:*/false); - } - else - { - result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, false, /*abbrAxis:*/false); - if ((props & Props.NonFlat) != 0) - { - result = new DocumentOrderQuery(result); - } - } - props |= Props.NonFlat; - break; - case Axis.AxisType.DescendantOrSelf: - if ((flags & Flags.SmartDesc) != 0) - { - result = new DescendantOverDescendantQuery(qyInput, true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis); - } - else - { - result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.NodeType, true, root.AbbrAxis); - if ((props & Props.NonFlat) != 0) - { - result = new DocumentOrderQuery(result); - } - } - props |= Props.NonFlat; - break; - case Axis.AxisType.Preceding: - result = new PrecedingQuery(qyInput, root.Name, root.Prefix, root.NodeType); - props |= Props.NonFlat; - break; - case Axis.AxisType.Following: - result = new FollowingQuery(qyInput, root.Name, root.Prefix, root.NodeType); - props |= Props.NonFlat; - break; - case Axis.AxisType.FollowingSibling: - result = new FollSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType); - if ((props & Props.NonFlat) != 0) - { - result = new DocumentOrderQuery(result); - } - break; - case Axis.AxisType.PrecedingSibling: - result = new PreSiblingQuery(qyInput, root.Name, root.Prefix, root.NodeType); - break; - case Axis.AxisType.Attribute: - result = new AttributeQuery(qyInput, root.Name, root.Prefix, root.NodeType); - break; - case Axis.AxisType.Self: - result = new XPathSelfQuery(qyInput, root.Name, root.Prefix, root.NodeType); - break; - case Axis.AxisType.Namespace: - if ((root.NodeType == XPathNodeType.All || root.NodeType == XPathNodeType.Element || root.NodeType == XPathNodeType.Attribute) && root.Prefix.Length == 0) - { - result = new NamespaceQuery(qyInput, root.Name, root.Prefix, root.NodeType); - } - else - { - result = new EmptyQuery(); - } - break; - default: - throw XPathException.Create(ResXml.Xp_NotSupported, _query); - } - - return result; - } - - private bool CanBeNumber(Query q) - { - return ( - q.StaticType == XPathResultType.Any || - q.StaticType == XPathResultType.Number - ); - } - - private Query ProcessFilter(Filter root, Flags flags, out Props props) - { - bool first = ((flags & Flags.Filter) == 0); - - Props propsCond; - Query cond = ProcessNode(root.Condition, Flags.None, out propsCond); - - if ( - CanBeNumber(cond) || - (propsCond & (Props.HasPosition | Props.HasLast)) != 0 - ) - { - propsCond |= Props.HasPosition; - flags |= Flags.PosFilter; - } - - // We don't want DescendantOverDescendant pattern to be recognized here (in case descendent::foo[expr]/descendant::bar) - // So we clean this flag here: - flags &= ~Flags.SmartDesc; - // ToDo: Instead it would be nice to wrap descendent::foo[expr] into special query that will flatten it -- i.e. - // remove all nodes that are descendant of other nodes. This is very easy becuase for sorted nodesets all children - // follow its parent. One step caching. This can be easyly done by rightmost DescendantQuery itsef. - // Interesting note! Can we garatee that DescendantOverDescendant returns flat nodeset? This defenetely true if it's input is flat. - - Query qyInput = ProcessNode(root.Input, flags | Flags.Filter, out props); - - if (root.Input.Type != AstNode.AstType.Filter) - { - // Props.PosFilter is for nested filters only. - // We clean it here to avoid cleaning it in all other ast nodes. - props &= ~Props.PosFilter; - } - if ((propsCond & Props.HasPosition) != 0) - { - // this condition is positional rightmost filter should be avare of this. - props |= Props.PosFilter; - } - - /*merging predicates*/ - { - FilterQuery qyFilter = qyInput as FilterQuery; - if (qyFilter != null && (propsCond & Props.HasPosition) == 0 && qyFilter.Condition.StaticType != XPathResultType.Any) - { - Query prevCond = qyFilter.Condition; - if (prevCond.StaticType == XPathResultType.Number) - { - prevCond = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(FT.FuncPosition, null), prevCond); - } - cond = new BooleanExpr(Operator.Op.AND, prevCond, cond); - qyInput = qyFilter.qyInput; - } - } - - if ((props & Props.PosFilter) != 0 && qyInput is DocumentOrderQuery) - { - qyInput = ((DocumentOrderQuery)qyInput).input; - } - if (_firstInput == null) - { - _firstInput = qyInput as BaseAxisQuery; - } - - bool merge = (qyInput.Properties & QueryProps.Merge) != 0; - bool reverse = (qyInput.Properties & QueryProps.Reverse) != 0; - if ((propsCond & Props.HasPosition) != 0) - { - if (reverse) - { - qyInput = new ReversePositionQuery(qyInput); - } - else if ((propsCond & Props.HasLast) != 0) - { - qyInput = new ForwardPositionQuery(qyInput); - } - } - - if (first && _firstInput != null) - { - if (merge && (props & Props.PosFilter) != 0) - { - qyInput = new FilterQuery(qyInput, cond, /*noPosition:*/false); - Query parent = _firstInput.qyInput; - if (!(parent is ContextQuery)) - { // we don't need to wrap filter with MergeFilterQuery when cardinality is parent <: ? - _firstInput.qyInput = new ContextQuery(); - _firstInput = null; - return new MergeFilterQuery(parent, qyInput); - } - _firstInput = null; - return qyInput; - } - _firstInput = null; - } - return new FilterQuery(qyInput, cond, /*noPosition:*/(propsCond & Props.HasPosition) == 0); - } - - private Query ProcessOperator(Operator root, out Props props) - { - Props props1, props2; - Query op1 = ProcessNode(root.Operand1, Flags.None, out props1); - Query op2 = ProcessNode(root.Operand2, Flags.None, out props2); - props = props1 | props2; - switch (root.OperatorType) - { - case Operator.Op.PLUS: - case Operator.Op.MINUS: - case Operator.Op.MUL: - case Operator.Op.MOD: - case Operator.Op.DIV: - return new NumericExpr(root.OperatorType, op1, op2); - case Operator.Op.LT: - case Operator.Op.GT: - case Operator.Op.LE: - case Operator.Op.GE: - case Operator.Op.EQ: - case Operator.Op.NE: - return new LogicalExpr(root.OperatorType, op1, op2); - case Operator.Op.OR: - case Operator.Op.AND: - return new BooleanExpr(root.OperatorType, op1, op2); - case Operator.Op.UNION: - props |= Props.NonFlat; - return new UnionExpr(op1, op2); - default: return null; - } - } - - private Query ProcessVariable(Variable root) - { - _needContext = true; - if (!_allowVar) - { - throw XPathException.Create(ResXml.Xp_InvalidKeyPattern, _query); - } - return new VariableQuery(root.Localname, root.Prefix); - } - - private Query ProcessFunction(Function root, out Props props) - { - props = Props.None; - Query qy = null; - switch (root.TypeOfFunction) - { - case FT.FuncLast: - qy = new NodeFunctions(root.TypeOfFunction, null); - props |= Props.HasLast; - return qy; - case FT.FuncPosition: - qy = new NodeFunctions(root.TypeOfFunction, null); - props |= Props.HasPosition; - return qy; - case FT.FuncCount: - return new NodeFunctions(FT.FuncCount, - ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props) - ); - case FT.FuncID: - qy = new IDQuery(ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props)); - props |= Props.NonFlat; - return qy; - case FT.FuncLocalName: - case FT.FuncNameSpaceUri: - case FT.FuncName: - if (root.ArgumentList != null && root.ArgumentList.Count > 0) - { - return new NodeFunctions(root.TypeOfFunction, - ProcessNode((AstNode)(root.ArgumentList[0]), Flags.None, out props) - ); - } - else - { - return new NodeFunctions(root.TypeOfFunction, null); - } - case FT.FuncString: - case FT.FuncConcat: - case FT.FuncStartsWith: - case FT.FuncContains: - case FT.FuncSubstringBefore: - case FT.FuncSubstringAfter: - case FT.FuncSubstring: - case FT.FuncStringLength: - case FT.FuncNormalize: - case FT.FuncTranslate: - return new StringFunctions(root.TypeOfFunction, ProcessArguments(root.ArgumentList, out props)); - case FT.FuncNumber: - case FT.FuncSum: - case FT.FuncFloor: - case FT.FuncCeiling: - case FT.FuncRound: - if (root.ArgumentList != null && root.ArgumentList.Count > 0) - { - return new NumberFunctions(root.TypeOfFunction, - ProcessNode((AstNode)root.ArgumentList[0], Flags.None, out props) - ); - } - else - { - return new NumberFunctions(Function.FunctionType.FuncNumber, null); - } - case FT.FuncTrue: - case FT.FuncFalse: - return new BooleanFunctions(root.TypeOfFunction, null); - case FT.FuncNot: - case FT.FuncLang: - case FT.FuncBoolean: - return new BooleanFunctions(root.TypeOfFunction, - ProcessNode((AstNode)root.ArgumentList[0], Flags.None, out props) - ); - case FT.FuncUserDefined: - _needContext = true; - if (!_allowCurrent && root.Name == "current" && root.Prefix.Length == 0) - { - throw XPathException.Create(ResXml.Xp_CurrentNotAllowed); - } - if (!_allowKey && root.Name == "key" && root.Prefix.Length == 0) - { - throw XPathException.Create(ResXml.Xp_InvalidKeyPattern, _query); - } - qy = new FunctionQuery(root.Prefix, root.Name, ProcessArguments(root.ArgumentList, out props)); - props |= Props.NonFlat; - return qy; - default: - throw XPathException.Create(ResXml.Xp_NotSupported, _query); - } - } - - private List ProcessArguments(ArrayList args, out Props props) - { - int numArgs = args != null ? args.Count : 0; - List argList = new List(numArgs); - props = Props.None; - for (int count = 0; count < numArgs; count++) - { - Props argProps; - argList.Add(ProcessNode((AstNode)args[count], Flags.None, out argProps)); - props |= argProps; - } - return argList; - } - - private int _parseDepth = 0; - private const int MaxParseDepth = 1024; - - private Query ProcessNode(AstNode root, Flags flags, out Props props) - { - if (++_parseDepth > MaxParseDepth) - { - throw XPathException.Create(ResXml.Xp_QueryTooComplex); - } - - Debug.Assert(root != null, "root != null"); - Query result = null; - props = Props.None; - switch (root.Type) - { - case AstNode.AstType.Axis: - result = ProcessAxis((Axis)root, flags, out props); - break; - case AstNode.AstType.Operator: - result = ProcessOperator((Operator)root, out props); - break; - case AstNode.AstType.Filter: - result = ProcessFilter((Filter)root, flags, out props); - break; - case AstNode.AstType.ConstantOperand: - result = new OperandQuery(((Operand)root).OperandValue); - break; - case AstNode.AstType.Variable: - result = ProcessVariable((Variable)root); - break; - case AstNode.AstType.Function: - result = ProcessFunction((Function)root, out props); - break; - case AstNode.AstType.Group: - result = new GroupQuery(ProcessNode(((Group)root).GroupNode, Flags.None, out props)); - break; - case AstNode.AstType.Root: - result = new AbsoluteQuery(); - break; - default: - Debug.Assert(false, "Unknown QueryType encountered!!"); - break; - } - --_parseDepth; - return result; - } - - private Query Build(AstNode root, string query) - { - Reset(); - Props props; - _query = query; - Query result = ProcessNode(root, Flags.None, out props); - return result; - } - - internal Query Build(string query, bool allowVar, bool allowKey) - { - _allowVar = allowVar; - _allowKey = allowKey; - _allowCurrent = true; - return Build(XPathParser.ParseXPathExpresion(query), query); - } - - internal Query Build(string query, out bool needContext) - { - Query result = Build(query, true, true); - needContext = _needContext; - return result; - } - - internal Query BuildPatternQuery(string query, bool allowVar, bool allowKey) - { - _allowVar = allowVar; - _allowKey = allowKey; - _allowCurrent = false; - return Build(XPathParser.ParseXPathPattern(query), query); - } - - internal Query BuildPatternQuery(string query, out bool needContext) - { - Query result = BuildPatternQuery(query, true, true); - needContext = _needContext; - return result; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathDocument.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathDocument.cs deleted file mode 100644 index 91336b7847f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathDocument.cs +++ /dev/null @@ -1,472 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using System.Collections.Generic; -using MS.Internal.Xml.Cache; -using System.Diagnostics; -using System.Text; -using System.Runtime.Versioning; - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - - /// - /// XDocument follows the XPath/XQuery data model. All nodes in the tree reference the document, - /// and the document references the root node of the tree. All namespaces are stored out-of-line, - /// in an Element --> In-Scope-Namespaces map. - /// - public class XPathDocument : IXPathNavigable - { - private XPathNode[] _pageText,_pageRoot,_pageXmlNmsp; - private int _idxText,_idxRoot,_idxXmlNmsp; - private XmlNameTable _nameTable; - private bool _hasLineInfo; - private Dictionary _mapNmsp; - private Dictionary _idValueMap; - - /// - /// Flags that control Load behavior. - /// - internal enum LoadFlags - { - None = 0, - AtomizeNames = 1, // Do not assume that names passed to XPathDocumentBuilder have been pre-atomized, and atomize them - Fragment = 2, // Create a document with no document node - } - - - //----------------------------------------------- - // Creation Methods - //----------------------------------------------- - - /// - /// Create a new empty document. - /// - internal XPathDocument() - { - _nameTable = new NameTable(); - } - - /// - /// Create a new empty document. All names should be atomized using "nameTable". - /// - internal XPathDocument(XmlNameTable nameTable) - { - if (nameTable == null) - throw new ArgumentNullException("nameTable"); - - _nameTable = nameTable; - } - - /// - /// Create a new document and load the content from the reader. - /// - public XPathDocument(XmlReader reader) : this(reader, XmlSpace.Default) - { - } - - /// - /// Create a new document from "reader", with whitespace handling controlled according to "space". - /// - public XPathDocument(XmlReader reader, XmlSpace space) - { - if (reader == null) - throw new ArgumentNullException("reader"); - - LoadFromReader(reader, space); - } - - /// - /// Create a new document and load the content from the text reader. - /// - public XPathDocument(TextReader textReader) - { - XmlTextReaderImpl reader = SetupReader(new XmlTextReaderImpl(string.Empty, textReader)); - - try - { - LoadFromReader(reader, XmlSpace.Default); - } - finally - { - reader.Close(); - } - } - - /// - /// Create a new document and load the content from the stream. - /// - public XPathDocument(Stream stream) - { - XmlTextReaderImpl reader = SetupReader(new XmlTextReaderImpl(string.Empty, stream)); - - try - { - LoadFromReader(reader, XmlSpace.Default); - } - finally - { - reader.Close(); - } - } - - /// - /// Create a new document and load the content from the Uri. - /// - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XPathDocument(string uri) : this(uri, XmlSpace.Default) - { - } - - /// - /// Create a new document and load the content from the Uri, with whitespace handling controlled according to "space". - /// - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XPathDocument(string uri, XmlSpace space) - { - XmlTextReaderImpl reader = SetupReader(new XmlTextReaderImpl(uri)); - - try - { - LoadFromReader(reader, space); - } - finally - { - reader.Close(); - } - } - - /// - /// Create a writer that can be used to create nodes in this document. The root node will be assigned "baseUri", and flags - /// can be passed to indicate that names should be atomized by the builder and/or a fragment should be created. - /// - internal XmlRawWriter LoadFromWriter(LoadFlags flags, string baseUri) - { - return new XPathDocumentBuilder(this, null, baseUri, flags); - } - - /// - /// Create a writer that can be used to create nodes in this document. The root node will be assigned "baseUri", and flags - /// can be passed to indicate that names should be atomized by the builder and/or a fragment should be created. - /// - internal void LoadFromReader(XmlReader reader, XmlSpace space) - { - XPathDocumentBuilder builder; - IXmlLineInfo lineInfo; - string xmlnsUri; - bool topLevelReader; - int initialDepth; - - if (reader == null) - throw new ArgumentNullException("reader"); - - // Determine line number provider - lineInfo = reader as IXmlLineInfo; - if (lineInfo == null || !lineInfo.HasLineInfo()) - lineInfo = null; - _hasLineInfo = (lineInfo != null); - - _nameTable = reader.NameTable; - builder = new XPathDocumentBuilder(this, lineInfo, reader.BaseURI, LoadFlags.None); - - try - { - // Determine whether reader is in initial state - topLevelReader = (reader.ReadState == ReadState.Initial); - initialDepth = reader.Depth; - - // Get atomized xmlns uri - Debug.Assert((object)_nameTable.Get(string.Empty) == (object)string.Empty, "NameTable must contain atomized string.Empty"); - xmlnsUri = _nameTable.Get(XmlReservedNs.NsXmlNs); - - // Read past Initial state; if there are no more events then load is complete - if (topLevelReader && !reader.Read()) - return; - - // Read all events - do - { - // If reader began in intermediate state, return when all siblings have been read - if (!topLevelReader && reader.Depth < initialDepth) - return; - - switch (reader.NodeType) - { - case XmlNodeType.Element: - { - bool isEmptyElement = reader.IsEmptyElement; - - builder.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.BaseURI); - - // Add attribute and namespace nodes to element - while (reader.MoveToNextAttribute()) - { - string namespaceUri = reader.NamespaceURI; - - if ((object)namespaceUri == (object)xmlnsUri) - { - if (reader.Prefix.Length == 0) - { - // Default namespace declaration "xmlns" - Debug.Assert(reader.LocalName == "xmlns"); - builder.WriteNamespaceDeclaration(string.Empty, reader.Value); - } - else - { - Debug.Assert(reader.Prefix == "xmlns"); - builder.WriteNamespaceDeclaration(reader.LocalName, reader.Value); - } - } - else - { - builder.WriteStartAttribute(reader.Prefix, reader.LocalName, namespaceUri); - builder.WriteString(reader.Value, TextBlockType.Text); - builder.WriteEndAttribute(); - } - } - - if (isEmptyElement) - builder.WriteEndElement(true); - break; - } - - case XmlNodeType.EndElement: - builder.WriteEndElement(false); - break; - - case XmlNodeType.Text: - case XmlNodeType.CDATA: - builder.WriteString(reader.Value, TextBlockType.Text); - break; - - case XmlNodeType.SignificantWhitespace: - if (reader.XmlSpace == XmlSpace.Preserve) - builder.WriteString(reader.Value, TextBlockType.SignificantWhitespace); - else - // Significant whitespace without xml:space="preserve" is not significant in XPath/XQuery data model - goto case XmlNodeType.Whitespace; - break; - - case XmlNodeType.Whitespace: - // We intentionally ignore the reader.XmlSpace property here and blindly trust - // the reported node type. If the reported information is not in sync - // (in this case if the reader.XmlSpace == Preserve) then we make the choice - // to trust the reported node type. Since we have no control over the input reader - // we can't even assert here. - - // Always filter top-level whitespace - if (space == XmlSpace.Preserve && (!topLevelReader || reader.Depth != 0)) - builder.WriteString(reader.Value, TextBlockType.Whitespace); - break; - - case XmlNodeType.Comment: - builder.WriteComment(reader.Value); - break; - - case XmlNodeType.ProcessingInstruction: - builder.WriteProcessingInstruction(reader.LocalName, reader.Value, reader.BaseURI); - break; - - case XmlNodeType.EntityReference: - reader.ResolveEntity(); - break; - - case XmlNodeType.DocumentType: - // Create ID tables - IDtdInfo info = reader.DtdInfo; - if (info != null) - builder.CreateIdTables(info); - break; - - case XmlNodeType.EndEntity: - case XmlNodeType.None: - case XmlNodeType.XmlDeclaration: - break; - } - } - while (reader.Read()); - } - finally - { - builder.Close(); - } - } - - /// - /// Create a navigator positioned on the root node of the document. - /// - public XPathNavigator CreateNavigator() - { - return new XPathDocumentNavigator(_pageRoot, _idxRoot, null, 0); - } - - - //----------------------------------------------- - // Document Properties - //----------------------------------------------- - - /// - /// Return the name table used to atomize all name parts (local name, namespace uri, prefix). - /// - internal XmlNameTable NameTable - { - get { return _nameTable; } - } - - /// - /// Return true if line number information is recorded in the cache. - /// - internal bool HasLineInfo - { - get { return _hasLineInfo; } - } - - /// - /// Return the singleton collapsed text node associated with the document. One physical text node - /// represents each logical text node in the document that is the only content-typed child of its - /// element parent. - /// - internal int GetCollapsedTextNode(out XPathNode[] pageText) - { - pageText = _pageText; - return _idxText; - } - - /// - /// Set the page and index where the singleton collapsed text node is stored. - /// - internal void SetCollapsedTextNode(XPathNode[] pageText, int idxText) - { - _pageText = pageText; - _idxText = idxText; - } - - /// - /// Return the root node of the document. This may not be a node of type XPathNodeType.Root if this - /// is a document fragment. - /// - internal int GetRootNode(out XPathNode[] pageRoot) - { - pageRoot = _pageRoot; - return _idxRoot; - } - - /// - /// Set the page and index where the root node is stored. - /// - internal void SetRootNode(XPathNode[] pageRoot, int idxRoot) - { - _pageRoot = pageRoot; - _idxRoot = idxRoot; - } - - /// - /// Every document has an implicit xmlns:xml namespace node. - /// - internal int GetXmlNamespaceNode(out XPathNode[] pageXmlNmsp) - { - pageXmlNmsp = _pageXmlNmsp; - return _idxXmlNmsp; - } - - /// - /// Set the page and index where the implicit xmlns:xml node is stored. - /// - internal void SetXmlNamespaceNode(XPathNode[] pageXmlNmsp, int idxXmlNmsp) - { - _pageXmlNmsp = pageXmlNmsp; - _idxXmlNmsp = idxXmlNmsp; - } - - /// - /// Associate a namespace node with an element. - /// - internal void AddNamespace(XPathNode[] pageElem, int idxElem, XPathNode[] pageNmsp, int idxNmsp) - { - Debug.Assert(pageElem[idxElem].NodeType == XPathNodeType.Element && pageNmsp[idxNmsp].NodeType == XPathNodeType.Namespace); - - if (_mapNmsp == null) - _mapNmsp = new Dictionary(); - - _mapNmsp.Add(new XPathNodeRef(pageElem, idxElem), new XPathNodeRef(pageNmsp, idxNmsp)); - } - - /// - /// Lookup the namespace nodes associated with an element. - /// - internal int LookupNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp) - { - XPathNodeRef nodeRef = new XPathNodeRef(pageElem, idxElem); - Debug.Assert(pageElem[idxElem].NodeType == XPathNodeType.Element); - - // Check whether this element has any local namespaces - if (_mapNmsp == null || !_mapNmsp.ContainsKey(nodeRef)) - { - pageNmsp = null; - return 0; - } - - // Yes, so return the page and index of the first local namespace node - nodeRef = _mapNmsp[nodeRef]; - - pageNmsp = nodeRef.Page; - return nodeRef.Index; - } - - /// - /// Add an element indexed by ID value. - /// - internal void AddIdElement(string id, XPathNode[] pageElem, int idxElem) - { - if (_idValueMap == null) - _idValueMap = new Dictionary(); - - if (!_idValueMap.ContainsKey(id)) - _idValueMap.Add(id, new XPathNodeRef(pageElem, idxElem)); - } - - /// - /// Lookup the element node associated with the specified ID value. - /// - internal int LookupIdElement(string id, out XPathNode[] pageElem) - { - XPathNodeRef nodeRef; - - if (_idValueMap == null || !_idValueMap.ContainsKey(id)) - { - pageElem = null; - return 0; - } - - // Extract page and index from XPathNodeRef - nodeRef = _idValueMap[id]; - pageElem = nodeRef.Page; - return nodeRef.Index; - } - - - //----------------------------------------------- - // Helper Methods - //----------------------------------------------- - - /// - /// Set properties on the reader so that it is backwards-compatible with V1. - /// - private XmlTextReaderImpl SetupReader(XmlTextReaderImpl reader) - { - reader.EntityHandling = EntityHandling.ExpandEntities; - reader.XmlValidatingReaderCompatibilityMode = true; - return reader; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathException.cs deleted file mode 100644 index a7d9a10963b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathException.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.XPath -{ - using System; - using System.IO; - using System.Resources; - using System.Diagnostics; - // using System.Security.Permissions; - - // Represents the exception that is thrown when there is error processing an - // XPath expression. - // [Serializable], - public class XPathException : System.Exception - { - // we need to keep this members for V1 serialization compatibility - private string _res; - private string[] _args; - - // message != null for V1 & V2 exceptions deserialized in Whidbey - // message == null for created V2 exceptions; the exception message is stored in Exception._message - private string _message = null; - - public XPathException() : this(string.Empty, (Exception)null) { } - - public XPathException(string message) : this(message, (Exception)null) { } - - public XPathException(string message, Exception innerException) : - this(ResXml.Xml_UserException, new string[] { message }, innerException) - { - } - - internal static XPathException Create(string res) - { - return new XPathException(res, (string[])null); - } - - internal static XPathException Create(string res, string arg) - { - return new XPathException(res, new string[] { arg }); - } - - internal static XPathException Create(string res, string arg, string arg2) - { - return new XPathException(res, new string[] { arg, arg2 }); - } - - internal static XPathException Create(string res, string arg, Exception innerException) - { - return new XPathException(res, new string[] { arg }, innerException); - } - - private XPathException(string res, string[] args) : - this(res, args, null) - { - } - - private XPathException(string res, string[] args, Exception inner) : - base(CreateMessage(res, args), inner) - { - HResult = HResults.XmlXPath; - _res = res; - _args = args; - } - - private static string CreateMessage(string res, string[] args) - { - try - { - string message = string.Format(res, args); - if (message == null) - message = "UNKNOWN(" + res + ")"; - return message; - } - catch (MissingManifestResourceException) - { - return "UNKNOWN(" + res + ")"; - } - } - - public override string Message - { - get - { - return (_message == null) ? base.Message : _message; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathExpr.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathExpr.cs deleted file mode 100644 index 27efe05c75b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathExpr.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - using System.Collections; - using MS.Internal.Xml.XPath; - - public enum XmlSortOrder - { - Ascending = 1, - Descending = 2, - } - - public enum XmlCaseOrder - { - None = 0, - UpperFirst = 1, - LowerFirst = 2, - } - - public enum XmlDataType - { - Text = 1, - Number = 2, - } - - public enum XPathResultType - { - Number = 0, - String = 1, - Boolean = 2, - NodeSet = 3, - Navigator = XPathResultType.String, - Any = 5, - Error - }; - - public abstract class XPathExpression - { - internal XPathExpression() { } - - public abstract string Expression { get; } - - public abstract void AddSort(object expr, IComparer comparer); - - public abstract void AddSort(object expr, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType); - - public abstract XPathExpression Clone(); - - public abstract void SetContext(XmlNamespaceManager nsManager); - - public abstract void SetContext(IXmlNamespaceResolver nsResolver); - - public abstract XPathResultType ReturnType { get; } - - public static XPathExpression Compile(string xpath) - { - return Compile(xpath, /*nsResolver:*/null); - } - - public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver) - { - bool hasPrefix; - Query query = new QueryBuilder().Build(xpath, out hasPrefix); - CompiledXpathExpr expr = new CompiledXpathExpr(query, xpath, hasPrefix); - if (null != nsResolver) - { - expr.SetContext(nsResolver); - } - return expr; - } - - private void PrintQuery(XmlWriter w) - { - ((CompiledXpathExpr)this).QueryTree.PrintQuery(w); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathItem.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathItem.cs deleted file mode 100644 index 6194893e1a5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathItem.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using Microsoft.Xml.Schema; - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - /// - /// Base class for XPathNavigator and XmlAtomicValue. - /// - public abstract class XPathItem - { - /// - /// True if this item is a node, and not an atomic value. - /// - public abstract bool IsNode { get; } - - /// - /// Returns Xsd type of atomic value, or of node's content. - /// - public abstract XmlSchemaType XmlType { get; } - - /// - /// Typed and untyped value accessors. - /// - public abstract string Value { get; } - public abstract object TypedValue { get; } - public abstract Type ValueType { get; } - public abstract bool ValueAsBoolean { get; } - public abstract DateTime ValueAsDateTime { get; } - public abstract double ValueAsDouble { get; } - public abstract int ValueAsInt { get; } - public abstract long ValueAsLong { get; } - public virtual object ValueAs(Type returnType) { return ValueAs(returnType, null); } - public abstract object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver); - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNamespaceScope.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNamespaceScope.cs deleted file mode 100644 index 92016088b38..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNamespaceScope.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.XPath -{ - using System; - - public enum XPathNamespaceScope - { - All, - ExcludeXml, - Local - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigator.cs deleted file mode 100644 index 4c3c0a5010b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigator.cs +++ /dev/null @@ -1,2291 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.ComponentModel; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using Microsoft.Xml.Schema; -using System.Diagnostics; -//using System.Diagnostics.Contracts; -using System.Security; -// using System.Security.Policy; -// using System.Security.Permissions; -using System.Text; -using Microsoft.Xml; -using MS.Internal.Xml.Cache; -using MS.Internal.Xml.XPath; - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - // Provides a navigation interface API using XPath data model. - [DebuggerDisplay("{debuggerDisplayProxy}")] -#if CONTRACTS_FULL - [ContractClass(typeof(XPathNavigatorContract))] -#endif - public abstract class XPathNavigator : XPathItem, ICloneable, IXPathNavigable, IXmlNamespaceResolver - { - internal static readonly XPathNavigatorKeyComparer comparer = new XPathNavigatorKeyComparer(); - - //----------------------------------------------- - // Object - //----------------------------------------------- - - public override string ToString() - { - return Value; - } - - //----------------------------------------------- - // XPathItem - //----------------------------------------------- - - public override sealed bool IsNode - { - get { return true; } - } - - public override XmlSchemaType XmlType - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - XmlSchemaType memberType = schemaInfo.MemberType; - if (memberType != null) - { - return memberType; - } - return schemaInfo.SchemaType; - } - } - return null; - } - } - - public virtual void SetValue(string value) - { - throw new NotSupportedException(); - } - - public override object TypedValue - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ChangeType(Value, datatype.ValueType, this); - } - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ChangeType(datatype.ParseValue(Value, NameTable, this), datatype.ValueType, this); - } - } - } - } - return Value; - } - } - - public virtual void SetTypedValue(object typedValue) - { - if (typedValue == null) - { - throw new ArgumentNullException("typedValue"); - } - switch (NodeType) - { - case XPathNodeType.Element: - case XPathNodeType.Attribute: - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - string value = null; - IXmlSchemaInfo schemaInfo = SchemaInfo; - if (schemaInfo != null) - { - XmlSchemaType schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - value = schemaType.ValueConverter.ToString(typedValue, this); - XmlSchemaDatatype datatype = schemaType.Datatype; - if (datatype != null) - { - datatype.ParseValue(value, NameTable, this); - } - } - } - if (value == null) - { - value = XmlUntypedConverter.Untyped.ToString(typedValue, this); - } - SetValue(value); - } - - public override Type ValueType - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return datatype.ValueType; - } - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return datatype.ValueType; - } - } - } - } - return typeof(string); - } - } - - public override bool ValueAsBoolean - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ToBoolean(Value); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ToBoolean(datatype.ParseValue(Value, NameTable, this)); - } - } - } - } - return XmlUntypedConverter.Untyped.ToBoolean(Value); - } - } - - public override DateTime ValueAsDateTime - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ToDateTime(Value); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ToDateTime(datatype.ParseValue(Value, NameTable, this)); - } - } - } - } - return XmlUntypedConverter.Untyped.ToDateTime(Value); - } - } - - public override double ValueAsDouble - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ToDouble(Value); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ToDouble(datatype.ParseValue(Value, NameTable, this)); - } - } - } - } - return XmlUntypedConverter.Untyped.ToDouble(Value); - } - } - - public override int ValueAsInt - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ToInt32(Value); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ToInt32(datatype.ParseValue(Value, NameTable, this)); - } - } - } - } - return XmlUntypedConverter.Untyped.ToInt32(Value); - } - } - - public override long ValueAsLong - { - get - { - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ToInt64(Value); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ToInt64(datatype.ParseValue(Value, NameTable, this)); - } - } - } - } - return XmlUntypedConverter.Untyped.ToInt64(Value); - } - } - - public override object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver) - { - if (nsResolver == null) - { - nsResolver = this; - } - IXmlSchemaInfo schemaInfo = SchemaInfo; - XmlSchemaType schemaType; - XmlSchemaDatatype datatype; - if (schemaInfo != null) - { - if (schemaInfo.Validity == XmlSchemaValidity.Valid) - { - schemaType = schemaInfo.MemberType; - if (schemaType == null) - { - schemaType = schemaInfo.SchemaType; - } - if (schemaType != null) - { - return schemaType.ValueConverter.ChangeType(Value, returnType, nsResolver); - } - } - else - { - schemaType = schemaInfo.SchemaType; - if (schemaType != null) - { - datatype = schemaType.Datatype; - if (datatype != null) - { - return schemaType.ValueConverter.ChangeType(datatype.ParseValue(Value, NameTable, nsResolver), returnType, nsResolver); - } - } - } - } - return XmlUntypedConverter.Untyped.ChangeType(Value, returnType, nsResolver); - } - - //----------------------------------------------- - // ICloneable - //----------------------------------------------- - - object ICloneable.Clone() - { - return Clone(); - } - - //----------------------------------------------- - // IXPathNavigable - //----------------------------------------------- - - public virtual XPathNavigator CreateNavigator() - { - return Clone(); - } - - //----------------------------------------------- - // IXmlNamespaceResolver - //----------------------------------------------- - - public abstract XmlNameTable NameTable { get; } - - public virtual string LookupNamespace(string prefix) - { - if (prefix == null) - return null; - - if (NodeType != XPathNodeType.Element) - { - XPathNavigator navSave = Clone(); - - // If current item is not an element, then try parent - if (navSave.MoveToParent()) - return navSave.LookupNamespace(prefix); - } - else if (MoveToNamespace(prefix)) - { - string namespaceURI = Value; - MoveToParent(); - return namespaceURI; - } - - // Check for "", "xml", and "xmlns" prefixes - if (prefix.Length == 0) - return string.Empty; - else if (prefix == "xml") - return XmlReservedNs.NsXml; - else if (prefix == "xmlns") - return XmlReservedNs.NsXmlNs; - - return null; - } - - public virtual string LookupPrefix(string namespaceURI) - { - if (namespaceURI == null) - return null; - - XPathNavigator navClone = Clone(); - - if (NodeType != XPathNodeType.Element) - { - // If current item is not an element, then try parent - if (navClone.MoveToParent()) - return navClone.LookupPrefix(namespaceURI); - } - else - { - if (navClone.MoveToFirstNamespace(XPathNamespaceScope.All)) - { - // Loop until a matching namespace is found - do - { - if (namespaceURI == navClone.Value) - return navClone.LocalName; - } - while (navClone.MoveToNextNamespace(XPathNamespaceScope.All)); - } - } - - // Check for default, "xml", and "xmlns" namespaces - if (namespaceURI == LookupNamespace(string.Empty)) - return string.Empty; - else if (namespaceURI == XmlReservedNs.NsXml) - return "xml"; - else if (namespaceURI == XmlReservedNs.NsXmlNs) - return "xmlns"; - - return null; - } - - // This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey. -#pragma warning disable 3002 - public virtual IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { -#pragma warning restore 3002 - XPathNodeType nt = NodeType; - if ((nt != XPathNodeType.Element && scope != XmlNamespaceScope.Local) || nt == XPathNodeType.Attribute || nt == XPathNodeType.Namespace) - { - XPathNavigator navSave = Clone(); - - // If current item is not an element, then try parent - if (navSave.MoveToParent()) - return navSave.GetNamespacesInScope(scope); - } - - Dictionary dict = new Dictionary(); - - // "xml" prefix always in scope - if (scope == XmlNamespaceScope.All) - dict["xml"] = XmlReservedNs.NsXml; - - // Now add all in-scope namespaces - if (MoveToFirstNamespace((XPathNamespaceScope)scope)) - { - do - { - string prefix = LocalName; - string ns = Value; - - // Exclude xmlns="" declarations unless scope = Local - if (prefix.Length != 0 || ns.Length != 0 || scope == XmlNamespaceScope.Local) - dict[prefix] = ns; - } - while (MoveToNextNamespace((XPathNamespaceScope)scope)); - - MoveToParent(); - } - - return dict; - } - - //----------------------------------------------- - // XPathNavigator - //----------------------------------------------- - - // Returns an object of type IKeyComparer. Using this the navigators can be hashed - // on the basis of actual position it represents rather than the clr reference of - // the navigator object. - public static IEqualityComparer NavigatorComparer - { - get { return comparer; } - } - - public abstract XPathNavigator Clone(); - - public abstract XPathNodeType NodeType { get; } - - public abstract string LocalName { get; } - - public abstract string Name { get; } - - public abstract string NamespaceURI { get; } - - public abstract string Prefix { get; } - - public abstract string BaseURI { get; } - - public abstract bool IsEmptyElement { get; } - - public virtual string XmlLang - { - get - { - XPathNavigator navClone = Clone(); - do - { - if (navClone.MoveToAttribute("lang", XmlReservedNs.NsXml)) - return navClone.Value; - } - while (navClone.MoveToParent()); - - return string.Empty; - } - } - - public virtual XmlReader ReadSubtree() - { - switch (NodeType) - { - case XPathNodeType.Root: - case XPathNodeType.Element: - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - return CreateReader(); - } - - public virtual void WriteSubtree(XmlWriter writer) - { - if (null == writer) - throw new ArgumentNullException("writer"); - writer.WriteNode(this, true); - } - - public virtual object UnderlyingObject - { - get { return null; } - } - - public virtual bool HasAttributes - { - get - { - if (!MoveToFirstAttribute()) - return false; - - MoveToParent(); - return true; - } - } - - public virtual string GetAttribute(string localName, string namespaceURI) - { - string value; - - if (!MoveToAttribute(localName, namespaceURI)) - return ""; - - value = Value; - MoveToParent(); - - return value; - } - - public virtual bool MoveToAttribute(string localName, string namespaceURI) - { - if (MoveToFirstAttribute()) - { - do - { - if (localName == LocalName && namespaceURI == NamespaceURI) - return true; - } - while (MoveToNextAttribute()); - - MoveToParent(); - } - - return false; - } - - public abstract bool MoveToFirstAttribute(); - - public abstract bool MoveToNextAttribute(); - - public virtual string GetNamespace(string name) - { - string value; - - if (!MoveToNamespace(name)) - { - if (name == "xml") - return XmlReservedNs.NsXml; - if (name == "xmlns") - return XmlReservedNs.NsXmlNs; - return string.Empty; - } - - value = Value; - MoveToParent(); - - return value; - } - - public virtual bool MoveToNamespace(string name) - { - if (MoveToFirstNamespace(XPathNamespaceScope.All)) - { - do - { - if (name == LocalName) - return true; - } - while (MoveToNextNamespace(XPathNamespaceScope.All)); - - MoveToParent(); - } - - return false; - } - - public abstract bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope); - - public abstract bool MoveToNextNamespace(XPathNamespaceScope namespaceScope); - - public bool MoveToFirstNamespace() { return MoveToFirstNamespace(XPathNamespaceScope.All); } - - public bool MoveToNextNamespace() { return MoveToNextNamespace(XPathNamespaceScope.All); } - - public abstract bool MoveToNext(); - - public abstract bool MoveToPrevious(); - - public virtual bool MoveToFirst() - { - switch (NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - // MoveToFirst should only succeed for content-typed nodes - return false; - } - - if (!MoveToParent()) - return false; - - return MoveToFirstChild(); - } - - public abstract bool MoveToFirstChild(); - - public abstract bool MoveToParent(); - - public virtual void MoveToRoot() - { - while (MoveToParent()) - ; - } - - public abstract bool MoveTo(XPathNavigator other); - - public abstract bool MoveToId(string id); - - public virtual bool MoveToChild(string localName, string namespaceURI) - { - if (MoveToFirstChild()) - { - do - { - if (NodeType == XPathNodeType.Element && localName == LocalName && namespaceURI == NamespaceURI) - return true; - } - while (MoveToNext()); - MoveToParent(); - } - - return false; - } - - public virtual bool MoveToChild(XPathNodeType type) - { - if (MoveToFirstChild()) - { - int mask = GetContentKindMask(type); - do - { - if (((1 << (int)NodeType) & mask) != 0) - return true; - } - while (MoveToNext()); - - MoveToParent(); - } - - return false; - } - - public virtual bool MoveToFollowing(string localName, string namespaceURI) - { - return MoveToFollowing(localName, namespaceURI, null); - } - - public virtual bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end) - { - XPathNavigator navSave = Clone(); - - if (end != null) - { - switch (end.NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - // Scan until we come to the next content-typed node - // after the attribute or namespace node - end = end.Clone(); - end.MoveToNonDescendant(); - break; - } - } - switch (NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - if (!MoveToParent()) - { - // Restore previous position and return false - // MoveTo(navSave); - return false; - } - break; - } - do - { - if (!MoveToFirstChild()) - { - // Look for next sibling - while (true) - { - if (MoveToNext()) - break; - - if (!MoveToParent()) - { - // Restore previous position and return false - MoveTo(navSave); - return false; - } - } - } - - // Have we reached the end of the scan? - if (end != null && IsSamePosition(end)) - { - // Restore previous position and return false - MoveTo(navSave); - return false; - } - } - while (NodeType != XPathNodeType.Element - || localName != LocalName - || namespaceURI != NamespaceURI); - - return true; - } - - public virtual bool MoveToFollowing(XPathNodeType type) - { - return MoveToFollowing(type, null); - } - - public virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end) - { - XPathNavigator navSave = Clone(); - int mask = GetContentKindMask(type); - - if (end != null) - { - switch (end.NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - // Scan until we come to the next content-typed node - // after the attribute or namespace node - end = end.Clone(); - end.MoveToNonDescendant(); - break; - } - } - switch (NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - if (!MoveToParent()) - { - // Restore previous position and return false - // MoveTo(navSave); - return false; - } - break; - } - do - { - if (!MoveToFirstChild()) - { - // Look for next sibling - while (true) - { - if (MoveToNext()) - break; - - if (!MoveToParent()) - { - // Restore previous position and return false - MoveTo(navSave); - return false; - } - } - } - - // Have we reached the end of the scan? - if (end != null && IsSamePosition(end)) - { - // Restore previous position and return false - MoveTo(navSave); - return false; - } - } - while (((1 << (int)NodeType) & mask) == 0); - - return true; - } - - public virtual bool MoveToNext(string localName, string namespaceURI) - { - XPathNavigator navClone = Clone(); - - while (MoveToNext()) - { - if (NodeType == XPathNodeType.Element && localName == LocalName && namespaceURI == NamespaceURI) - return true; - } - MoveTo(navClone); - return false; - } - - public virtual bool MoveToNext(XPathNodeType type) - { - XPathNavigator navClone = Clone(); - int mask = GetContentKindMask(type); - - while (MoveToNext()) - { - if (((1 << (int)NodeType) & mask) != 0) - return true; - } - - MoveTo(navClone); - return false; - } - - public virtual bool HasChildren - { - get - { - if (MoveToFirstChild()) - { - MoveToParent(); - return true; - } - return false; - } - } - - public abstract bool IsSamePosition(XPathNavigator other); - - public virtual bool IsDescendant(XPathNavigator nav) - { - if (nav != null) - { - nav = nav.Clone(); - while (nav.MoveToParent()) - if (nav.IsSamePosition(this)) - return true; - } - return false; - } - - public virtual XmlNodeOrder ComparePosition(XPathNavigator nav) - { - if (nav == null) - { - return XmlNodeOrder.Unknown; - } - - if (IsSamePosition(nav)) - return XmlNodeOrder.Same; - - XPathNavigator n1 = this.Clone(); - XPathNavigator n2 = nav.Clone(); - - int depth1 = GetDepth(n1.Clone()); - int depth2 = GetDepth(n2.Clone()); - - if (depth1 > depth2) - { - while (depth1 > depth2) - { - n1.MoveToParent(); - depth1--; - } - if (n1.IsSamePosition(n2)) - return XmlNodeOrder.After; - } - - if (depth2 > depth1) - { - while (depth2 > depth1) - { - n2.MoveToParent(); - depth2--; - } - if (n1.IsSamePosition(n2)) - return XmlNodeOrder.Before; - } - - XPathNavigator parent1 = n1.Clone(); - XPathNavigator parent2 = n2.Clone(); - - while (true) - { - if (!parent1.MoveToParent() || !parent2.MoveToParent()) - return XmlNodeOrder.Unknown; - - if (parent1.IsSamePosition(parent2)) - { - if (n1.GetType().ToString() != "Microsoft.VisualStudio.Modeling.StoreNavigator") - { - Debug.Assert(CompareSiblings(n1.Clone(), n2.Clone()) != CompareSiblings(n2.Clone(), n1.Clone()), "IsSamePosition() on custom navigator returns incosistent results"); - } - return CompareSiblings(n1, n2); - } - - n1.MoveToParent(); - n2.MoveToParent(); - } - } - - public virtual IXmlSchemaInfo SchemaInfo - { - get { return this as IXmlSchemaInfo; } - } - - public virtual bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler) - { - IXmlSchemaInfo schemaInfo; - XmlSchemaType schemaType = null; - XmlSchemaElement schemaElement = null; - XmlSchemaAttribute schemaAttribute = null; - - switch (NodeType) - { - case XPathNodeType.Root: - if (schemas == null) - { - throw new InvalidOperationException(ResXml.XPathDocument_MissingSchemas); - } - schemaType = null; - break; - case XPathNodeType.Element: - if (schemas == null) - { - throw new InvalidOperationException(ResXml.XPathDocument_MissingSchemas); - } - schemaInfo = SchemaInfo; - if (schemaInfo != null) - { - schemaType = schemaInfo.SchemaType; - schemaElement = schemaInfo.SchemaElement; - } - if (schemaType == null - && schemaElement == null) - { - throw new InvalidOperationException(string.Format(ResXml.XPathDocument_NotEnoughSchemaInfo, null)); - } - break; - case XPathNodeType.Attribute: - if (schemas == null) - { - throw new InvalidOperationException(ResXml.XPathDocument_MissingSchemas); - } - schemaInfo = SchemaInfo; - if (schemaInfo != null) - { - schemaType = schemaInfo.SchemaType; - schemaAttribute = schemaInfo.SchemaAttribute; - } - if (schemaType == null - && schemaAttribute == null) - { - throw new InvalidOperationException(string.Format(ResXml.XPathDocument_NotEnoughSchemaInfo, null)); - } - break; - default: - throw new InvalidOperationException(string.Format(ResXml.XPathDocument_ValidateInvalidNodeType, null)); - } - - Debug.Assert(schemaType != null || this.NodeType == XPathNodeType.Root, "schemaType != null || this.NodeType == XPathNodeType.Root"); - - XmlReader reader = CreateReader(); - - CheckValidityHelper validityTracker = new CheckValidityHelper(validationEventHandler, reader as XPathNavigatorReader); - validationEventHandler = new ValidationEventHandler(validityTracker.ValidationCallback); - XmlReader validatingReader = GetValidatingReader(reader, schemas, validationEventHandler, schemaType, schemaElement, schemaAttribute); - - while (validatingReader.Read()) - ; - - return validityTracker.IsValid; - } - - private XmlReader GetValidatingReader(XmlReader reader, XmlSchemaSet schemas, ValidationEventHandler validationEvent, XmlSchemaType schemaType, XmlSchemaElement schemaElement, XmlSchemaAttribute schemaAttribute) - { - if (schemaAttribute != null) - { - return schemaAttribute.Validate(reader, null, schemas, validationEvent); - } - else if (schemaElement != null) - { - return schemaElement.Validate(reader, null, schemas, validationEvent); - } - else if (schemaType != null) - { - return schemaType.Validate(reader, null, schemas, validationEvent); - } - Debug.Assert(schemas != null, "schemas != null"); - XmlReaderSettings readerSettings = new XmlReaderSettings(); - readerSettings.ConformanceLevel = ConformanceLevel.Auto; - readerSettings.ValidationType = ValidationType.Schema; - readerSettings.Schemas = schemas; - readerSettings.ValidationEventHandler += validationEvent; - return XmlReader.Create(reader, readerSettings); - } - - private class CheckValidityHelper - { - private bool _isValid; - private ValidationEventHandler _nextEventHandler; - private XPathNavigatorReader _reader; - - internal CheckValidityHelper(ValidationEventHandler nextEventHandler, XPathNavigatorReader reader) - { - _isValid = true; - _nextEventHandler = nextEventHandler; - _reader = reader; - } - - internal void ValidationCallback(object sender, ValidationEventArgs args) - { - Debug.Assert(args != null); - if (args.Severity == XmlSeverityType.Error) - _isValid = false; - XmlSchemaValidationException exception = args.Exception as XmlSchemaValidationException; - if (exception != null && _reader != null) - exception.SetSourceObject(_reader.UnderlyingObject); - - if (_nextEventHandler != null) - { - _nextEventHandler(sender, args); - } - else if (exception != null && args.Severity == XmlSeverityType.Error) - { - throw exception; - } - } - - internal bool IsValid - { - get { return _isValid; } - } - } - - public virtual XPathExpression Compile(string xpath) - { - return XPathExpression.Compile(xpath); - } - - public virtual XPathNavigator SelectSingleNode(string xpath) - { - return SelectSingleNode(XPathExpression.Compile(xpath)); - } - - public virtual XPathNavigator SelectSingleNode(string xpath, IXmlNamespaceResolver resolver) - { - return SelectSingleNode(XPathExpression.Compile(xpath, resolver)); - } - - public virtual XPathNavigator SelectSingleNode(XPathExpression expression) - { - // BUGBUG: this actually caches _all_ matching nodes... - XPathNodeIterator iter = this.Select(expression); - if (iter.MoveNext()) - { - return iter.Current; - } - return null; - } - - public virtual XPathNodeIterator Select(string xpath) - { - //Contract.Ensures(Contract.Result() != null); - - return this.Select(XPathExpression.Compile(xpath)); - } - - public virtual XPathNodeIterator Select(string xpath, IXmlNamespaceResolver resolver) - { - //Contract.Ensures(Contract.Result() != null); - - return this.Select(XPathExpression.Compile(xpath, resolver)); - } - - public virtual XPathNodeIterator Select(XPathExpression expr) - { - //Contract.Ensures(Contract.Result() != null); - - XPathNodeIterator result = Evaluate(expr) as XPathNodeIterator; - if (result == null) - { - throw XPathException.Create(ResXml.Xp_NodeSetExpected); - } - return result; - } - - public virtual object Evaluate(string xpath) - { - return Evaluate(XPathExpression.Compile(xpath), null); - } - - public virtual object Evaluate(string xpath, IXmlNamespaceResolver resolver) - { - return this.Evaluate(XPathExpression.Compile(xpath, resolver)); - } - - public virtual object Evaluate(XPathExpression expr) - { - return Evaluate(expr, null); - } - - public virtual object Evaluate(XPathExpression expr, XPathNodeIterator context) - { - CompiledXpathExpr cexpr = expr as CompiledXpathExpr; - if (cexpr == null) - { - throw XPathException.Create(ResXml.Xp_BadQueryObject); - } - Query query = Query.Clone(cexpr.QueryTree); - query.Reset(); - - if (context == null) - { - context = new XPathSingletonIterator(this.Clone(), /*moved:*/true); - } - - object result = query.Evaluate(context); - - if (result is XPathNodeIterator) - { - return new XPathSelectionIterator(context.Current, query); - } - - return result; - } - - public virtual bool Matches(XPathExpression expr) - { - CompiledXpathExpr cexpr = expr as CompiledXpathExpr; - if (cexpr == null) - throw XPathException.Create(ResXml.Xp_BadQueryObject); - - // We should clone query because some Query.MatchNode() alter expression state and this may brake - // SelectionIterators that are runing using this Query - // Excample of MatchNode() that alret the state is FilterQuery.MatchNode() - Query query = Query.Clone(cexpr.QueryTree); - - try - { - return query.MatchNode(this) != null; - } - catch (XPathException) - { - throw XPathException.Create(ResXml.Xp_InvalidPattern, cexpr.Expression); - } - } - - public virtual bool Matches(string xpath) - { - return Matches(CompileMatchPattern(xpath)); - } - - public virtual XPathNodeIterator SelectChildren(XPathNodeType type) - { - return new XPathChildIterator(this.Clone(), type); - } - - public virtual XPathNodeIterator SelectChildren(string name, string namespaceURI) - { - return new XPathChildIterator(this.Clone(), name, namespaceURI); - } - - public virtual XPathNodeIterator SelectAncestors(XPathNodeType type, bool matchSelf) - { - return new XPathAncestorIterator(this.Clone(), type, matchSelf); - } - - public virtual XPathNodeIterator SelectAncestors(string name, string namespaceURI, bool matchSelf) - { - return new XPathAncestorIterator(this.Clone(), name, namespaceURI, matchSelf); - } - - public virtual XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf) - { - return new XPathDescendantIterator(this.Clone(), type, matchSelf); - } - - public virtual XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf) - { - return new XPathDescendantIterator(this.Clone(), name, namespaceURI, matchSelf); - } - - public virtual bool CanEdit - { - get - { - return false; - } - } - - public virtual XmlWriter PrependChild() - { - throw new NotSupportedException(); - } - - public virtual XmlWriter AppendChild() - { - throw new NotSupportedException(); - } - - public virtual XmlWriter InsertAfter() - { - throw new NotSupportedException(); - } - - public virtual XmlWriter InsertBefore() - { - throw new NotSupportedException(); - } - - public virtual XmlWriter CreateAttributes() - { - throw new NotSupportedException(); - } - - public virtual XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace) - { - throw new NotSupportedException(); - } - - public virtual void ReplaceSelf(string newNode) - { - XmlReader reader = CreateContextReader(newNode, false); - ReplaceSelf(reader); - } - - public virtual void ReplaceSelf(XmlReader newNode) - { - if (newNode == null) - { - throw new ArgumentNullException("newNode"); - } - XPathNodeType type = NodeType; - if (type == XPathNodeType.Root - || type == XPathNodeType.Attribute - || type == XPathNodeType.Namespace) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlWriter writer = ReplaceRange(this); - BuildSubtree(newNode, writer); - writer.Close(); - } - - public virtual void ReplaceSelf(XPathNavigator newNode) - { - if (newNode == null) - { - throw new ArgumentNullException("newNode"); - } - XmlReader reader = newNode.CreateReader(); - ReplaceSelf(reader); - } - - // Returns the markup representing the current node and all of its children. - public virtual string OuterXml - { - get - { - StringWriter stringWriter; - XmlWriterSettings writerSettings; - XmlWriter xmlWriter; - - // Attributes and namespaces are not allowed at the top-level by the well-formed writer - if (NodeType == XPathNodeType.Attribute) - { - return string.Concat(Name, "=\"", Value, "\""); - } - else if (NodeType == XPathNodeType.Namespace) - { - if (LocalName.Length == 0) - return string.Concat("xmlns=\"", Value, "\""); - else - return string.Concat("xmlns:", LocalName, "=\"", Value, "\""); - } - - stringWriter = new StringWriter(CultureInfo.InvariantCulture); - - writerSettings = new XmlWriterSettings(); - writerSettings.Indent = true; - writerSettings.OmitXmlDeclaration = true; - writerSettings.ConformanceLevel = ConformanceLevel.Auto; - - xmlWriter = XmlWriter.Create(stringWriter, writerSettings); - try - { - xmlWriter.WriteNode(this, true); - } - finally - { - xmlWriter.Close(); - } - - return stringWriter.ToString(); - } - - set - { - ReplaceSelf(value); - } - } - - // Returns the markup representing just the children of the current node. - public virtual string InnerXml - { - get - { - switch (NodeType) - { - case XPathNodeType.Root: - case XPathNodeType.Element: - StringWriter stringWriter; - XmlWriterSettings writerSettings; - XmlWriter xmlWriter; - - stringWriter = new StringWriter(CultureInfo.InvariantCulture); - - writerSettings = new XmlWriterSettings(); - writerSettings.Indent = true; - writerSettings.OmitXmlDeclaration = true; - writerSettings.ConformanceLevel = ConformanceLevel.Auto; - xmlWriter = XmlWriter.Create(stringWriter, writerSettings); - - try - { - if (MoveToFirstChild()) - { - do - { - xmlWriter.WriteNode(this, true); - } - while (MoveToNext()); - - // Restore position - MoveToParent(); - } - } - finally - { - xmlWriter.Close(); - } - return stringWriter.ToString(); - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - return Value; - default: - return string.Empty; - } - } - - set - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - switch (NodeType) - { - case XPathNodeType.Root: - case XPathNodeType.Element: - XPathNavigator edit = CreateNavigator(); - while (edit.MoveToFirstChild()) - { - edit.DeleteSelf(); - } - if (value.Length != 0) - { - edit.AppendChild(value); - } - break; - case XPathNodeType.Attribute: - SetValue(value); - break; - default: - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - } - } - - public virtual void AppendChild(string newChild) - { - XmlReader reader = CreateContextReader(newChild, true); - AppendChild(reader); - } - - public virtual void AppendChild(XmlReader newChild) - { - if (newChild == null) - { - throw new ArgumentNullException("newChild"); - } - XmlWriter writer = AppendChild(); - BuildSubtree(newChild, writer); - writer.Close(); - } - - public virtual void AppendChild(XPathNavigator newChild) - { - if (newChild == null) - { - throw new ArgumentNullException("newChild"); - } - if (!IsValidChildType(newChild.NodeType)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlReader reader = newChild.CreateReader(); - AppendChild(reader); - } - - public virtual void PrependChild(string newChild) - { - XmlReader reader = CreateContextReader(newChild, true); - PrependChild(reader); - } - - public virtual void PrependChild(XmlReader newChild) - { - if (newChild == null) - { - throw new ArgumentNullException("newChild"); - } - XmlWriter writer = PrependChild(); - BuildSubtree(newChild, writer); - writer.Close(); - } - - public virtual void PrependChild(XPathNavigator newChild) - { - if (newChild == null) - { - throw new ArgumentNullException("newChild"); - } - if (!IsValidChildType(newChild.NodeType)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlReader reader = newChild.CreateReader(); - PrependChild(reader); - } - - public virtual void InsertBefore(string newSibling) - { - XmlReader reader = CreateContextReader(newSibling, false); - InsertBefore(reader); - } - - public virtual void InsertBefore(XmlReader newSibling) - { - if (newSibling == null) - { - throw new ArgumentNullException("newSibling"); - } - XmlWriter writer = InsertBefore(); - BuildSubtree(newSibling, writer); - writer.Close(); - } - - public virtual void InsertBefore(XPathNavigator newSibling) - { - if (newSibling == null) - { - throw new ArgumentNullException("newSibling"); - } - if (!IsValidSiblingType(newSibling.NodeType)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlReader reader = newSibling.CreateReader(); - InsertBefore(reader); - } - - public virtual void InsertAfter(string newSibling) - { - XmlReader reader = CreateContextReader(newSibling, false); - InsertAfter(reader); - } - - public virtual void InsertAfter(XmlReader newSibling) - { - if (newSibling == null) - { - throw new ArgumentNullException("newSibling"); - } - XmlWriter writer = InsertAfter(); - BuildSubtree(newSibling, writer); - writer.Close(); - } - - public virtual void InsertAfter(XPathNavigator newSibling) - { - if (newSibling == null) - { - throw new ArgumentNullException("newSibling"); - } - if (!IsValidSiblingType(newSibling.NodeType)) - { - throw new InvalidOperationException(ResXml.Xpn_BadPosition); - } - XmlReader reader = newSibling.CreateReader(); - InsertAfter(reader); - } - - public virtual void DeleteRange(XPathNavigator lastSiblingToDelete) - { - throw new NotSupportedException(); - } - - public virtual void DeleteSelf() - { - DeleteRange(this); - } - - public virtual void PrependChildElement(string prefix, string localName, string namespaceURI, string value) - { - XmlWriter writer = PrependChild(); - writer.WriteStartElement(prefix, localName, namespaceURI); - if (value != null) - { - writer.WriteString(value); - } - writer.WriteEndElement(); - writer.Close(); - } - - public virtual void AppendChildElement(string prefix, string localName, string namespaceURI, string value) - { - XmlWriter writer = AppendChild(); - writer.WriteStartElement(prefix, localName, namespaceURI); - if (value != null) - { - writer.WriteString(value); - } - writer.WriteEndElement(); - writer.Close(); - } - - public virtual void InsertElementBefore(string prefix, string localName, string namespaceURI, string value) - { - XmlWriter writer = InsertBefore(); - writer.WriteStartElement(prefix, localName, namespaceURI); - if (value != null) - { - writer.WriteString(value); - } - writer.WriteEndElement(); - writer.Close(); - } - - public virtual void InsertElementAfter(string prefix, string localName, string namespaceURI, string value) - { - XmlWriter writer = InsertAfter(); - writer.WriteStartElement(prefix, localName, namespaceURI); - if (value != null) - { - writer.WriteString(value); - } - writer.WriteEndElement(); - writer.Close(); - } - - public virtual void CreateAttribute(string prefix, string localName, string namespaceURI, string value) - { - XmlWriter writer = CreateAttributes(); - writer.WriteStartAttribute(prefix, localName, namespaceURI); - if (value != null) - { - writer.WriteString(value); - } - writer.WriteEndAttribute(); - writer.Close(); - } - - //----------------------------------------------- - // Internal - //----------------------------------------------- - - internal bool MoveToPrevious(string localName, string namespaceURI) - { - XPathNavigator navClone = Clone(); - - localName = (localName != null) ? NameTable.Get(localName) : null; - while (MoveToPrevious()) - { - if (NodeType == XPathNodeType.Element && (object)localName == (object)LocalName && namespaceURI == NamespaceURI) - return true; - } - - MoveTo(navClone); - return false; - } - - internal bool MoveToPrevious(XPathNodeType type) - { - XPathNavigator navClone = Clone(); - int mask = GetContentKindMask(type); - - while (MoveToPrevious()) - { - if (((1 << (int)NodeType) & mask) != 0) - return true; - } - - MoveTo(navClone); - return false; - } - - internal bool MoveToNonDescendant() - { - // If current node is document, there is no next non-descendant - if (NodeType == XPathNodeType.Root) - return false; - - // If sibling exists, it is the next non-descendant - if (MoveToNext()) - return true; - - // The current node is either an attribute, namespace, or last child node - XPathNavigator navSave = Clone(); - - if (!MoveToParent()) - return false; - - switch (navSave.NodeType) - { - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - // Next node in document order is first content-child of parent - if (MoveToFirstChild()) - return true; - break; - } - - while (!MoveToNext()) - { - if (!MoveToParent()) - { - // Restore original position and return false - MoveTo(navSave); - return false; - } - } - - return true; - } - - /// - /// Returns ordinal number of attribute, namespace or child node within its parent. - /// Order is reversed for attributes and child nodes to avoid O(N**2) running time. - /// This property is useful for debugging, and also used in UniqueId implementation. - /// - internal uint IndexInParent - { - get - { - XPathNavigator nav = this.Clone(); - uint idx = 0; - - switch (NodeType) - { - case XPathNodeType.Attribute: - while (nav.MoveToNextAttribute()) - { - idx++; - } - break; - case XPathNodeType.Namespace: - while (nav.MoveToNextNamespace()) - { - idx++; - } - break; - default: - while (nav.MoveToNext()) - { - idx++; - } - break; - } - return idx; - } - } - - internal static readonly char[] NodeTypeLetter = new char[] { - 'R', // Root - 'E', // Element - 'A', // Attribute - 'N', // Namespace - 'T', // Text - 'S', // SignificantWhitespace - 'W', // Whitespace - 'P', // ProcessingInstruction - 'C', // Comment - 'X', // All - }; - - internal static readonly char[] UniqueIdTbl = new char[] { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', - '5', '6' - }; - - // Requirements for id: - // 1. must consist of alphanumeric characters only - // 2. must begin with an alphabetic character - // 3. same id is generated for the same node - // 4. ids are unique - // - // id = node type letter + reverse path to root in terms of encoded IndexInParent integers from node to root seperated by 0's if needed - internal virtual string UniqueId - { - get - { - XPathNavigator nav = this.Clone(); - StringBuilder sb = new StringBuilder(); - - // Ensure distinguishing attributes, namespaces and child nodes - sb.Append(NodeTypeLetter[(int)NodeType]); - - while (true) - { - uint idx = nav.IndexInParent; - if (!nav.MoveToParent()) - { - break; - } - if (idx <= 0x1f) - { - sb.Append(UniqueIdTbl[idx]); - } - else - { - sb.Append('0'); - do - { - sb.Append(UniqueIdTbl[idx & 0x1f]); - idx >>= 5; - } while (idx != 0); - sb.Append('0'); - } - } - return sb.ToString(); - } - } - - private static XPathExpression CompileMatchPattern(string xpath) - { - bool hasPrefix; - Query query = new QueryBuilder().BuildPatternQuery(xpath, out hasPrefix); - return new CompiledXpathExpr(query, xpath, hasPrefix); - } - - private static int GetDepth(XPathNavigator nav) - { - int depth = 0; - while (nav.MoveToParent()) - { - depth++; - } - return depth; - } - - // XPath based comparison for namespaces, attributes and other - // items with the same parent element. - // - // n2 - // namespace(0) attribute(-1) other(-2) - // n1 - // namespace(0) ?(0) before(-1) before(-2) - // attribute(1) after(1) ?(0) before(-1) - // other (2) after(2) after(1) ?(0) - private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2) - { - int cmp = 0; - -#if DEBUG - Debug.Assert(!n1.IsSamePosition(n2)); - XPathNavigator p1 = n1.Clone(), p2 = n2.Clone(); - Debug.Assert(p1.MoveToParent() && p2.MoveToParent() && p1.IsSamePosition(p2)); -#endif - switch (n1.NodeType) - { - case XPathNodeType.Namespace: - break; - case XPathNodeType.Attribute: - cmp += 1; - break; - default: - cmp += 2; - break; - } - switch (n2.NodeType) - { - case XPathNodeType.Namespace: - if (cmp == 0) - { - while (n1.MoveToNextNamespace()) - { - if (n1.IsSamePosition(n2)) - { - return XmlNodeOrder.Before; - } - } - } - break; - case XPathNodeType.Attribute: - cmp -= 1; - if (cmp == 0) - { - while (n1.MoveToNextAttribute()) - { - if (n1.IsSamePosition(n2)) - { - return XmlNodeOrder.Before; - } - } - } - break; - default: - cmp -= 2; - if (cmp == 0) - { - while (n1.MoveToNext()) - { - if (n1.IsSamePosition(n2)) - { - return XmlNodeOrder.Before; - } - } - } - break; - } - return cmp < 0 ? XmlNodeOrder.Before : XmlNodeOrder.After; - } - - internal static XmlNamespaceManager GetNamespaces(IXmlNamespaceResolver resolver) - { - XmlNamespaceManager mngr = new XmlNamespaceManager(new NameTable()); - IDictionary dictionary = resolver.GetNamespacesInScope(XmlNamespaceScope.All); - foreach (KeyValuePair pair in dictionary) - { - //"xmlns " is always in the namespace manager so adding it would throw an exception - if (pair.Key != "xmlns") - mngr.AddNamespace(pair.Key, pair.Value); - } - return mngr; - } - - // Get mask that will allow XPathNodeType content matching to be performed using only a shift and an and operation - internal const int AllMask = 0x7FFFFFFF; - internal const int NoAttrNmspMask = AllMask & ~(1 << (int)XPathNodeType.Attribute) & ~(1 << (int)XPathNodeType.Namespace); - internal const int TextMask = (1 << (int)XPathNodeType.Text) | (1 << (int)XPathNodeType.SignificantWhitespace) | (1 << (int)XPathNodeType.Whitespace); - internal static readonly int[] ContentKindMasks = { - (1 << (int) XPathNodeType.Root), // Root - (1 << (int) XPathNodeType.Element), // Element - 0, // Attribute (not content) - 0, // Namespace (not content) - TextMask, // Text - (1 << (int) XPathNodeType.SignificantWhitespace), // SignificantWhitespace - (1 << (int) XPathNodeType.Whitespace), // Whitespace - (1 << (int) XPathNodeType.ProcessingInstruction), // ProcessingInstruction - (1 << (int) XPathNodeType.Comment), // Comment - NoAttrNmspMask, // All - }; - - internal static int GetContentKindMask(XPathNodeType type) - { - return ContentKindMasks[(int)type]; - } - - internal static int GetKindMask(XPathNodeType type) - { - if (type == XPathNodeType.All) - return AllMask; - else if (type == XPathNodeType.Text) - return TextMask; - - return (1 << (int)type); - } - - internal static bool IsText(XPathNodeType type) - { - //return ((1 << (int) type) & TextMask) != 0; - return (uint)(type - XPathNodeType.Text) <= (XPathNodeType.Whitespace - XPathNodeType.Text); - } - - // Lax check for potential child item. - private bool IsValidChildType(XPathNodeType type) - { - switch (NodeType) - { - case XPathNodeType.Root: - switch (type) - { - case XPathNodeType.Element: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - case XPathNodeType.ProcessingInstruction: - case XPathNodeType.Comment: - return true; - } - break; - case XPathNodeType.Element: - switch (type) - { - case XPathNodeType.Element: - case XPathNodeType.Text: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - case XPathNodeType.ProcessingInstruction: - case XPathNodeType.Comment: - return true; - } - break; - } - return false; - } - - // Lax check for potential sibling item. - private bool IsValidSiblingType(XPathNodeType type) - { - switch (NodeType) - { - case XPathNodeType.Element: - case XPathNodeType.Text: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - case XPathNodeType.ProcessingInstruction: - case XPathNodeType.Comment: - switch (type) - { - case XPathNodeType.Element: - case XPathNodeType.Text: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Whitespace: - case XPathNodeType.ProcessingInstruction: - case XPathNodeType.Comment: - return true; - } - break; - } - return false; - } - - private XmlReader CreateReader() - { - return XPathNavigatorReader.Create(this); - } - - private XmlReader CreateContextReader(string xml, bool fromCurrentNode) - { - if (xml == null) - { - throw new ArgumentNullException("xml"); - } - - // We have to set the namespace context for the reader. - XPathNavigator editor = CreateNavigator(); - // scope starts from parent. - XmlNamespaceManager mgr = new XmlNamespaceManager(NameTable); - if (!fromCurrentNode) - { - editor.MoveToParent(); // should always succeed. - } - if (editor.MoveToFirstNamespace(XPathNamespaceScope.All)) - { - do - { - mgr.AddNamespace(editor.LocalName, editor.Value); - } - while (editor.MoveToNextNamespace(XPathNamespaceScope.All)); - } - // BUGBUG: How can we preserve the whitespace setting - XmlParserContext context = new XmlParserContext(NameTable, mgr, null, XmlSpace.Default); - XmlTextReader reader = new XmlTextReader(xml, XmlNodeType.Element, context); - // BUGBUG: Whitespace handling?? - reader.WhitespaceHandling = WhitespaceHandling.Significant; - return reader; - } - - internal void BuildSubtree(XmlReader reader, XmlWriter writer) - { - // important (perf) string literal... - string xmlnsUri = XmlReservedNs.NsXmlNs; // http://www.w3.org/2000/xmlns/ - ReadState readState = reader.ReadState; - - if (readState != ReadState.Initial - && readState != ReadState.Interactive) - { - throw new ArgumentException(ResXml.Xml_InvalidOperation, "reader"); - } - int level = 0; - if (readState == ReadState.Initial) - { - if (!reader.Read()) - return; - level++; // if start in initial, read everything (not just first) - } - do - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); - bool isEmptyElement = reader.IsEmptyElement; - - while (reader.MoveToNextAttribute()) - { - if ((object)reader.NamespaceURI == (object)xmlnsUri) - { - if (reader.Prefix.Length == 0) - { - // Default namespace declaration "xmlns" - Debug.Assert(reader.LocalName == "xmlns"); - writer.WriteAttributeString("", "xmlns", xmlnsUri, reader.Value); - } - else - { - Debug.Assert(reader.Prefix == "xmlns"); - writer.WriteAttributeString("xmlns", reader.LocalName, xmlnsUri, reader.Value); - } - } - else - { - writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI); - writer.WriteString(reader.Value); - writer.WriteEndAttribute(); - } - } - - reader.MoveToElement(); - if (isEmptyElement) - { - // there might still be a value, if there is a default value specified in the schema - writer.WriteEndElement(); - } - else - { - level++; - } - break; - case XmlNodeType.EndElement: - writer.WriteFullEndElement(); - //should not read beyond the level of the reader's original position. - level--; - break; - case XmlNodeType.Text: - case XmlNodeType.CDATA: - writer.WriteString(reader.Value); - break; - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.Whitespace: - // BUGBUG : this might be a problem when we go back to v1 navigator. - writer.WriteString(reader.Value); - break; - case XmlNodeType.Comment: - writer.WriteComment(reader.Value); - break; - case XmlNodeType.ProcessingInstruction: - writer.WriteProcessingInstruction(reader.LocalName, reader.Value); - break; - case XmlNodeType.EntityReference: - reader.ResolveEntity(); // REVIEW: - break; - case XmlNodeType.EndEntity: - case XmlNodeType.None: - case XmlNodeType.DocumentType: - case XmlNodeType.XmlDeclaration: - break; - case XmlNodeType.Attribute: - if ((object)reader.NamespaceURI == (object)xmlnsUri) - { - if (reader.Prefix.Length == 0) - { - // Default namespace declaration "xmlns" - Debug.Assert(reader.LocalName == "xmlns"); - writer.WriteAttributeString("", "xmlns", xmlnsUri, reader.Value); - } - else - { - Debug.Assert(reader.Prefix == "xmlns"); - writer.WriteAttributeString("xmlns", reader.LocalName, xmlnsUri, reader.Value); - } - } - else - { - writer.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI); - writer.WriteString(reader.Value); - writer.WriteEndAttribute(); - } - break; - } - } - while (reader.Read() && (level > 0)); - } - - private object debuggerDisplayProxy { get { return new DebuggerDisplayProxy(this); } } - - [DebuggerDisplay("{ToString()}")] - internal struct DebuggerDisplayProxy - { - private XPathNavigator _nav; - public DebuggerDisplayProxy(XPathNavigator nav) - { - _nav = nav; - } - public override string ToString() - { - string result = _nav.NodeType.ToString(); - switch (_nav.NodeType) - { - case XPathNodeType.Element: - result += ", Name=\"" + _nav.Name + '"'; - break; - case XPathNodeType.Attribute: - case XPathNodeType.Namespace: - case XPathNodeType.ProcessingInstruction: - result += ", Name=\"" + _nav.Name + '"'; - result += ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_nav.Value) + '"'; - break; - case XPathNodeType.Text: - case XPathNodeType.Whitespace: - case XPathNodeType.SignificantWhitespace: - case XPathNodeType.Comment: - result += ", Value=\"" + XmlConvert.EscapeValueForDebuggerDisplay(_nav.Value) + '"'; - break; - } - return result; - } - } - } - -#if CONTRACTS_FULL - [ContractClassFor(typeof(XPathNavigator))] - internal abstract class XPathNavigatorContract : XPathNavigator - { - public override XPathNavigator Clone() - { - Contract.Ensures(Contract.Result() != null); - return default(XPathNavigator); - } - - public override XmlNameTable NameTable { - get { - Contract.Ensures(Contract.Result() != null); - return default(XmlNameTable); - } - } - } -#endif -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorKeyComparer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorKeyComparer.cs deleted file mode 100644 index d03b3f40545..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorKeyComparer.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; -using MS.Internal.Xml.Cache; - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - internal class XPathNavigatorKeyComparer : IEqualityComparer - { - bool IEqualityComparer.Equals(Object obj1, Object obj2) - { - XPathNavigator nav1 = obj1 as XPathNavigator; - XPathNavigator nav2 = obj2 as XPathNavigator; - if ((nav1 != null) && (nav2 != null)) - { - if (nav1.IsSamePosition(nav2)) - return true; - } - return false; - } - - int IEqualityComparer.GetHashCode(Object obj) - { - int hashCode; - XPathNavigator nav; - XPathDocumentNavigator xpdocNav; - - if (obj == null) - { - throw new ArgumentNullException("obj"); - } - else if (null != (xpdocNav = obj as XPathDocumentNavigator)) - { - hashCode = xpdocNav.GetPositionHashCode(); - } - else if (null != (nav = obj as XPathNavigator)) - { - Object underlyingObject = nav.UnderlyingObject; - if (underlyingObject != null) - { - hashCode = underlyingObject.GetHashCode(); - } - else - { - hashCode = (int)nav.NodeType; - hashCode ^= nav.LocalName.GetHashCode(); - hashCode ^= nav.Prefix.GetHashCode(); - hashCode ^= nav.NamespaceURI.GetHashCode(); - } - } - else - { - hashCode = obj.GetHashCode(); - } - return hashCode; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorReader.cs deleted file mode 100644 index c6de5456124..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNavigatorReader.cs +++ /dev/null @@ -1,1340 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xml.Schema; -using System.Collections; -using System.Diagnostics; -using System.Collections.Generic; - - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - - /// - /// Reader that traverses the subtree rooted at the current position of the specified navigator. - /// - internal class XPathNavigatorReader : XmlReader, IXmlNamespaceResolver - { - private enum State - { - Initial, - Content, - EndElement, - Attribute, - AttrVal, - InReadBinary, - EOF, - Closed, - Error, - } - - private XPathNavigator _nav; - private XPathNavigator _navToRead; - private int _depth; - private State _state; - private XmlNodeType _nodeType; - private int _attrCount; - private bool _readEntireDocument; - - protected IXmlLineInfo lineInfo; - protected IXmlSchemaInfo schemaInfo; - - private ReadContentAsBinaryHelper _readBinaryHelper; - private State _savedState; - - internal const string space = "space"; - - internal static XmlNodeType[] convertFromXPathNodeType = { - XmlNodeType.Document, // XPathNodeType.Root - XmlNodeType.Element, // XPathNodeType.Element - XmlNodeType.Attribute, // XPathNodeType.Attribute - XmlNodeType.Attribute, // XPathNodeType.Namespace - XmlNodeType.Text, // XPathNodeType.Text - XmlNodeType.SignificantWhitespace, // XPathNodeType.SignificantWhitespace - XmlNodeType.Whitespace, // XPathNodeType.Whitespace - XmlNodeType.ProcessingInstruction, // XPathNodeType.ProcessingInstruction - XmlNodeType.Comment, // XPathNodeType.Comment - XmlNodeType.None // XPathNodeType.All - }; - - /// - /// Translates an XPathNodeType value into the corresponding XmlNodeType value. - /// XPathNodeType.Whitespace and XPathNodeType.SignificantWhitespace are mapped into XmlNodeType.Text. - /// - internal static XmlNodeType ToXmlNodeType(XPathNodeType typ) - { - return XPathNavigatorReader.convertFromXPathNodeType[(int)typ]; - } - - internal object UnderlyingObject - { - get - { - return _nav.UnderlyingObject; - } - } - - static public XPathNavigatorReader Create(XPathNavigator navToRead) - { - XPathNavigator nav = navToRead.Clone(); - IXmlLineInfo xli = nav as IXmlLineInfo; - IXmlSchemaInfo xsi = nav as IXmlSchemaInfo; -#if NAVREADER_SUPPORTSLINEINFO - if (null == xsi) { - if (null == xli) { - return new XPathNavigatorReader(nav, xli, xsi); - } - else { - return new XPathNavigatorReaderWithLI(nav, xli, xsi); - } - } - else { - if (null == xli) { - return new XPathNavigatorReaderWithSI(nav, xli, xsi); - } - else { - return new XPathNavigatorReaderWithLIAndSI(nav, xli, xsi); - } - } -#else - if (null == xsi) - { - return new XPathNavigatorReader(nav, xli, xsi); - } - else - { - return new XPathNavigatorReaderWithSI(nav, xli, xsi); - } -#endif - } - - protected XPathNavigatorReader(XPathNavigator navToRead, IXmlLineInfo xli, IXmlSchemaInfo xsi) - { - // Need clone that can be moved independently of original navigator - _navToRead = navToRead; - this.lineInfo = xli; - this.schemaInfo = xsi; - _nav = XmlEmptyNavigator.Singleton; - _state = State.Initial; - _depth = 0; - _nodeType = XPathNavigatorReader.ToXmlNodeType(_nav.NodeType); - } - - protected bool IsReading - { - get { return _state > State.Initial && _state < State.EOF; } - } - - internal override XmlNamespaceManager NamespaceManager - { - get { return XPathNavigator.GetNamespaces(this); } - } - - - //----------------------------------------------- - // IXmlNamespaceResolver -- pass through to Navigator - //----------------------------------------------- - public override XmlNameTable NameTable - { - get - { - return _navToRead.NameTable; - } - } - - IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) - { - return _nav.GetNamespacesInScope(scope); - } - - string IXmlNamespaceResolver.LookupNamespace(string prefix) - { - return _nav.LookupNamespace(prefix); - } - - string IXmlNamespaceResolver.LookupPrefix(string namespaceName) - { - return _nav.LookupPrefix(namespaceName); - } - - //----------------------------------------------- - // XmlReader -- pass through to Navigator - //----------------------------------------------- - - public override XmlReaderSettings Settings - { - get - { - XmlReaderSettings rs = new XmlReaderSettings(); - rs.NameTable = this.NameTable; - rs.ConformanceLevel = ConformanceLevel.Fragment; - rs.CheckCharacters = false; - rs.ReadOnly = true; - return rs; - } - } - - public override IXmlSchemaInfo SchemaInfo - { - get - { - // Special case attribute text (this.nav points to attribute even though current state is Text) - if (_nodeType == XmlNodeType.Text) - return null; - return _nav.SchemaInfo; - } - } - - public override System.Type ValueType - { - get { return _nav.ValueType; } - } - - public override XmlNodeType NodeType - { - get { return _nodeType; } - } - - public override string NamespaceURI - { - get - { - //NamespaceUri for namespace nodes is different in case of XPathNavigator and Reader - if (_nav.NodeType == XPathNodeType.Namespace) - return this.NameTable.Add(XmlReservedNs.NsXmlNs); - //Special case attribute text node - if (this.NodeType == XmlNodeType.Text) - return string.Empty; - return _nav.NamespaceURI; - } - } - - public override string LocalName - { - get - { - //Default namespace in case of reader has a local name value of 'xmlns' - if (_nav.NodeType == XPathNodeType.Namespace && _nav.LocalName.Length == 0) - return this.NameTable.Add("xmlns"); - //Special case attribute text node - if (this.NodeType == XmlNodeType.Text) - return string.Empty; - return _nav.LocalName; - } - } - - public override string Prefix - { - get - { - //Prefix for namespace nodes is different in case of XPathNavigator and Reader - if (_nav.NodeType == XPathNodeType.Namespace && _nav.LocalName.Length != 0) - return this.NameTable.Add("xmlns"); - //Special case attribute text node - if (this.NodeType == XmlNodeType.Text) - return string.Empty; - return _nav.Prefix; - } - } - - public override string BaseURI - { - get - { - //reader returns BaseUri even before read method is called. - if (_state == State.Initial) - return _navToRead.BaseURI; - return _nav.BaseURI; - } - } - - public override bool IsEmptyElement - { - get - { - return _nav.IsEmptyElement; - } - } - - public override XmlSpace XmlSpace - { - get - { - XPathNavigator tempNav = _nav.Clone(); - do - { - if (tempNav.MoveToAttribute(XPathNavigatorReader.space, XmlReservedNs.NsXml)) - { - switch (XmlConvert.TrimString(tempNav.Value)) - { - case "default": - return XmlSpace.Default; - case "preserve": - return XmlSpace.Preserve; - default: - break; - } - tempNav.MoveToParent(); - } - } - while (tempNav.MoveToParent()); - return XmlSpace.None; - } - } - - public override string XmlLang - { - get - { - return _nav.XmlLang; - } - } - - public override bool HasValue - { - get - { - if ((_nodeType != XmlNodeType.Element) - && (_nodeType != XmlNodeType.Document) - && (_nodeType != XmlNodeType.EndElement) - && (_nodeType != XmlNodeType.None)) - return true; - return false; - } - } - - public override string Value - { - get - { - if ((_nodeType != XmlNodeType.Element) - && (_nodeType != XmlNodeType.Document) - && (_nodeType != XmlNodeType.EndElement) - && (_nodeType != XmlNodeType.None)) - return _nav.Value; - return string.Empty; - } - } - - private XPathNavigator GetElemNav() - { - XPathNavigator tempNav; - switch (_state) - { - case State.Content: - return _nav.Clone(); - case State.Attribute: - case State.AttrVal: - tempNav = _nav.Clone(); - if (tempNav.MoveToParent()) - return tempNav; - break; - case State.InReadBinary: - _state = _savedState; - XPathNavigator nav = GetElemNav(); - _state = State.InReadBinary; - return nav; - } - return null; - } - - private XPathNavigator GetElemNav(out int depth) - { - XPathNavigator nav = null; - switch (_state) - { - case State.Content: - if (_nodeType == XmlNodeType.Element) - nav = _nav.Clone(); - depth = _depth; - break; - case State.Attribute: - nav = _nav.Clone(); - nav.MoveToParent(); - depth = _depth - 1; - break; - case State.AttrVal: - nav = _nav.Clone(); - nav.MoveToParent(); - depth = _depth - 2; - break; - case State.InReadBinary: - _state = _savedState; - nav = GetElemNav(out depth); - _state = State.InReadBinary; - break; - default: - depth = _depth; - break; - } - return nav; - } - - private void MoveToAttr(XPathNavigator nav, int depth) - { - _nav.MoveTo(nav); - _depth = depth; - _nodeType = XmlNodeType.Attribute; - _state = State.Attribute; - } - - public override int AttributeCount - { - get - { - if (_attrCount < 0) - { - // attribute count works for element, regardless of where you are in start tag - XPathNavigator tempNav = GetElemNav(); - int count = 0; - if (null != tempNav) - { - if (tempNav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - do - { - count++; - } while (tempNav.MoveToNextNamespace((XPathNamespaceScope.Local))); - tempNav.MoveToParent(); - } - if (tempNav.MoveToFirstAttribute()) - { - do - { - count++; - } while (tempNav.MoveToNextAttribute()); - } - } - _attrCount = count; - } - return _attrCount; - } - } - - public override string GetAttribute(string name) - { - // reader allows calling GetAttribute, even when positioned inside attributes - XPathNavigator nav = _nav; - switch (nav.NodeType) - { - case XPathNodeType.Element: - break; - case XPathNodeType.Attribute: - nav = nav.Clone(); - if (!nav.MoveToParent()) - return null; - break; - default: - return null; - } - string prefix, localname; - ValidateNames.SplitQName(name, out prefix, out localname); - if (0 == prefix.Length) - { - if (localname == "xmlns") - return nav.GetNamespace(string.Empty); - if ((object)nav == (object)_nav) - nav = nav.Clone(); - if (nav.MoveToAttribute(localname, string.Empty)) - return nav.Value; - } - else - { - if (prefix == "xmlns") - return nav.GetNamespace(localname); - if ((object)nav == (object)_nav) - nav = nav.Clone(); - if (nav.MoveToFirstAttribute()) - { - do - { - if (nav.LocalName == localname && nav.Prefix == prefix) - return nav.Value; - } while (nav.MoveToNextAttribute()); - } - } - return null; - } - - public override string GetAttribute(string localName, string namespaceURI) - { - if (null == localName) - throw new ArgumentNullException("localName"); - // reader allows calling GetAttribute, even when positioned inside attributes - XPathNavigator nav = _nav; - switch (nav.NodeType) - { - case XPathNodeType.Element: - break; - case XPathNodeType.Attribute: - nav = nav.Clone(); - if (!nav.MoveToParent()) - return null; - break; - default: - return null; - } - // are they really looking for a namespace-decl? - if (namespaceURI == XmlReservedNs.NsXmlNs) - { - if (localName == "xmlns") - localName = string.Empty; - return nav.GetNamespace(localName); - } - if (null == namespaceURI) - namespaceURI = string.Empty; - // We need to clone the navigator and move the clone to the attribute to see whether the attribute exists, - // because XPathNavigator.GetAttribute return string.Empty for both when the the attribute is not there or when - // it has an empty value. XmlReader.GetAttribute must return null if the attribute does not exist. - if ((object)nav == (object)_nav) - nav = nav.Clone(); - if (nav.MoveToAttribute(localName, namespaceURI)) - { - return nav.Value; - } - else - { - return null; - } - } - - private static string GetNamespaceByIndex(XPathNavigator nav, int index, out int count) - { - string thisValue = nav.Value; - string value = null; - if (nav.MoveToNextNamespace(XPathNamespaceScope.Local)) - { - value = GetNamespaceByIndex(nav, index, out count); - } - else - { - count = 0; - } - if (count == index) - { - Debug.Assert(value == null); - value = thisValue; - } - count++; - return value; - } - - public override string GetAttribute(int index) - { - if (index < 0) - goto Error; - XPathNavigator nav = GetElemNav(); - if (null == nav) - goto Error; - if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - // namespaces are returned in reverse order, - // but we want to return them in the correct order, - // so first count the namespaces - int nsCount; - string value = GetNamespaceByIndex(nav, index, out nsCount); - if (null != value) - { - return value; - } - index -= nsCount; - nav.MoveToParent(); - } - if (nav.MoveToFirstAttribute()) - { - do - { - if (index == 0) - return nav.Value; - index--; - } while (nav.MoveToNextAttribute()); - } - // can't find it... error - Error: - throw new ArgumentOutOfRangeException("index"); - } - - - public override bool MoveToAttribute(string localName, string namespaceName) - { - if (null == localName) - throw new ArgumentNullException("localName"); - int depth = _depth; - XPathNavigator nav = GetElemNav(out depth); - if (null != nav) - { - if (namespaceName == XmlReservedNs.NsXmlNs) - { - if (localName == "xmlns") - localName = string.Empty; - if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - do - { - if (nav.LocalName == localName) - goto FoundMatch; - } while (nav.MoveToNextNamespace(XPathNamespaceScope.Local)); - } - } - else - { - if (null == namespaceName) - namespaceName = string.Empty; - if (nav.MoveToAttribute(localName, namespaceName)) - goto FoundMatch; - } - } - return false; - - FoundMatch: - if (_state == State.InReadBinary) - { - _readBinaryHelper.Finish(); - _state = _savedState; - } - MoveToAttr(nav, depth + 1); - return true; - } - - public override bool MoveToFirstAttribute() - { - int depth; - XPathNavigator nav = GetElemNav(out depth); - if (null != nav) - { - if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - // attributes are in reverse order - while (nav.MoveToNextNamespace(XPathNamespaceScope.Local)) - ; - goto FoundMatch; - } - if (nav.MoveToFirstAttribute()) - { - goto FoundMatch; - } - } - return false; - FoundMatch: - if (_state == State.InReadBinary) - { - _readBinaryHelper.Finish(); - _state = _savedState; - } - MoveToAttr(nav, depth + 1); - return true; - } - - public override bool MoveToNextAttribute() - { - switch (_state) - { - case State.Content: - return MoveToFirstAttribute(); - - case State.Attribute: - { - if (XPathNodeType.Attribute == _nav.NodeType) - return _nav.MoveToNextAttribute(); - - // otherwise it is on a namespace... namespace are in reverse order - Debug.Assert(XPathNodeType.Namespace == _nav.NodeType); - XPathNavigator nav = _nav.Clone(); - if (!nav.MoveToParent()) - return false; // shouldn't happen - if (!nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - return false; // shouldn't happen - if (nav.IsSamePosition(_nav)) - { - // this was the last one... start walking attributes - nav.MoveToParent(); - if (!nav.MoveToFirstAttribute()) - return false; - // otherwise we are there - _nav.MoveTo(nav); - return true; - } - else - { - XPathNavigator prev = nav.Clone(); - for (; ; ) - { - if (!nav.MoveToNextNamespace(XPathNamespaceScope.Local)) - { - Debug.Fail("Couldn't find Namespace Node! Should not happen!"); - return false; - } - if (nav.IsSamePosition(_nav)) - { - _nav.MoveTo(prev); - return true; - } - prev.MoveTo(nav); - } - // found previous namespace position - } - } - case State.AttrVal: - _depth--; - _state = State.Attribute; - if (!MoveToNextAttribute()) - { - _depth++; - _state = State.AttrVal; - return false; - } - _nodeType = XmlNodeType.Attribute; - return true; - - case State.InReadBinary: - _state = _savedState; - if (!MoveToNextAttribute()) - { - _state = State.InReadBinary; - return false; - } - _readBinaryHelper.Finish(); - return true; - - default: - return false; - } - } - - public override bool MoveToAttribute(string name) - { - int depth; - XPathNavigator nav = GetElemNav(out depth); - if (null == nav) - return false; - - string prefix, localname; - ValidateNames.SplitQName(name, out prefix, out localname); - - // watch for a namespace name - bool IsXmlnsNoPrefix = false; - if ((IsXmlnsNoPrefix = (0 == prefix.Length && localname == "xmlns")) - || (prefix == "xmlns")) - { - if (IsXmlnsNoPrefix) - localname = string.Empty; - if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) - { - do - { - if (nav.LocalName == localname) - goto FoundMatch; - } while (nav.MoveToNextNamespace(XPathNamespaceScope.Local)); - } - } - else if (0 == prefix.Length) - { - // the empty prefix always means empty namespaceUri for attributes - if (nav.MoveToAttribute(localname, string.Empty)) - goto FoundMatch; - } - else - { - if (nav.MoveToFirstAttribute()) - { - do - { - if (nav.LocalName == localname && nav.Prefix == prefix) - goto FoundMatch; - } while (nav.MoveToNextAttribute()); - } - } - return false; - - FoundMatch: - if (_state == State.InReadBinary) - { - _readBinaryHelper.Finish(); - _state = _savedState; - } - MoveToAttr(nav, depth + 1); - return true; - } - - public override bool MoveToElement() - { - switch (_state) - { - case State.Attribute: - case State.AttrVal: - if (!_nav.MoveToParent()) - return false; - _depth--; - if (_state == State.AttrVal) - _depth--; - _state = State.Content; - _nodeType = XmlNodeType.Element; - return true; - case State.InReadBinary: - _state = _savedState; - if (!MoveToElement()) - { - _state = State.InReadBinary; - return false; - } - _readBinaryHelper.Finish(); - break; - } - return false; - } - - public override bool EOF - { - get - { - return _state == State.EOF; - } - } - - public override ReadState ReadState - { - get - { - switch (_state) - { - case State.Initial: - return ReadState.Initial; - case State.Content: - case State.EndElement: - case State.Attribute: - case State.AttrVal: - case State.InReadBinary: - return ReadState.Interactive; - case State.EOF: - return ReadState.EndOfFile; - case State.Closed: - return ReadState.Closed; - default: - return ReadState.Error; - } - } - } - - public override void ResolveEntity() - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); - } - - public override bool ReadAttributeValue() - { - if (_state == State.InReadBinary) - { - _readBinaryHelper.Finish(); - _state = _savedState; - } - if (_state == State.Attribute) - { - _state = State.AttrVal; - _nodeType = XmlNodeType.Text; - _depth++; - return true; - } - return false; - } - - public override bool CanReadBinaryContent - { - get - { - return true; - } - } - - public override int ReadContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_state != State.InReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _state; - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count); - - // turn on InReadBinary state again and return - _savedState = _state; - _state = State.InReadBinary; - return readCount; - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_state != State.InReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _state; - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count); - - // turn on InReadBinary state again and return - _savedState = _state; - _state = State.InReadBinary; - return readCount; - } - - public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_state != State.InReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _state; - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count); - - // turn on InReadBinary state again and return - _savedState = _state; - _state = State.InReadBinary; - return readCount; - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - if (ReadState != ReadState.Interactive) - { - return 0; - } - - // init ReadContentAsBinaryHelper when called first time - if (_state != State.InReadBinary) - { - _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this); - _savedState = _state; - } - - // turn off InReadBinary state in order to have a normal Read() behavior when called from readBinaryHelper - _state = _savedState; - - // call to the helper - int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count); - - // turn on InReadBinary state again and return - _savedState = _state; - _state = State.InReadBinary; - return readCount; - } - - public override string LookupNamespace(string prefix) - { - return _nav.LookupNamespace(prefix); - } - - /// - /// Current depth in subtree. - /// - public override int Depth - { - get { return _depth; } - } - - /// - /// Move to the next reader state. Return false if that is ReaderState.Closed. - /// - public override bool Read() - { - _attrCount = -1; - switch (_state) - { - case State.Error: - case State.Closed: - case State.EOF: - return false; - - case State.Initial: - // Starting state depends on the navigator's item type - _nav = _navToRead; - _state = State.Content; - if (XPathNodeType.Root == _nav.NodeType) - { - if (!_nav.MoveToFirstChild()) - { - SetEOF(); - return false; - } - _readEntireDocument = true; - } - else if (XPathNodeType.Attribute == _nav.NodeType) - { - _state = State.Attribute; - } - _nodeType = ToXmlNodeType(_nav.NodeType); - break; - - case State.Content: - if (_nav.MoveToFirstChild()) - { - _nodeType = ToXmlNodeType(_nav.NodeType); - _depth++; - _state = State.Content; - } - else if (_nodeType == XmlNodeType.Element - && !_nav.IsEmptyElement) - { - _nodeType = XmlNodeType.EndElement; - _state = State.EndElement; - } - else - goto case State.EndElement; - break; - - case State.EndElement: - if (0 == _depth && !_readEntireDocument) - { - SetEOF(); - return false; - } - else if (_nav.MoveToNext()) - { - _nodeType = ToXmlNodeType(_nav.NodeType); - _state = State.Content; - } - else if (_depth > 0 && _nav.MoveToParent()) - { - Debug.Assert(_nav.NodeType == XPathNodeType.Element, _nav.NodeType.ToString() + " == XPathNodeType.Element"); - _nodeType = XmlNodeType.EndElement; - _state = State.EndElement; - _depth--; - } - else - { - SetEOF(); - return false; - } - break; - - case State.Attribute: - case State.AttrVal: - if (!_nav.MoveToParent()) - { - SetEOF(); - return false; - } - _nodeType = ToXmlNodeType(_nav.NodeType); - _depth--; - if (_state == State.AttrVal) - _depth--; - goto case State.Content; - case State.InReadBinary: - _state = _savedState; - _readBinaryHelper.Finish(); - return Read(); - } - return true; - } - - - /// - /// End reading by transitioning into the Closed state. - /// - public override void Close() - { - _nav = XmlEmptyNavigator.Singleton; - _nodeType = XmlNodeType.None; - _state = State.Closed; - _depth = 0; - } - - /// - /// set reader to EOF state - /// - private void SetEOF() - { - _nav = XmlEmptyNavigator.Singleton; - _nodeType = XmlNodeType.None; - _state = State.EOF; - _depth = 0; - } - } - -#if NAVREADER_SUPPORTSLINEINFO - internal class XPathNavigatorReaderWithLI : XPathNavigatorReader, Microsoft.Xml.IXmlLineInfo { - internal XPathNavigatorReaderWithLI( XPathNavigator navToRead, IXmlLineInfo xli, IXmlSchemaInfo xsi ) - : base( navToRead, xli, xsi ) { - } - - //----------------------------------------------- - // IXmlLineInfo - //----------------------------------------------- - - public virtual bool HasLineInfo() { return IsReading ? this.lineInfo.HasLineInfo() : false; } - public virtual int LineNumber { get { return IsReading ? this.lineInfo.LineNumber : 0; } } - public virtual int LinePosition { get { return IsReading ? this.lineInfo.LinePosition : 0; } } - } - - internal class XPathNavigatorReaderWithLIAndSI : XPathNavigatorReaderWithLI, Microsoft.Xml.IXmlLineInfo, Microsoft.Xml.Schema.IXmlSchemaInfo { - internal XPathNavigatorReaderWithLIAndSI( XPathNavigator navToRead, IXmlLineInfo xli, IXmlSchemaInfo xsi ) - : base( navToRead, xli, xsi ) { - } - - //----------------------------------------------- - // IXmlSchemaInfo - //----------------------------------------------- - - public virtual XmlSchemaValidity Validity { get { return IsReading ? this.schemaInfo.Validity : XmlSchemaValidity.NotKnown; } } - public override bool IsDefault { get { return IsReading ? this.schemaInfo.IsDefault : false; } } - public virtual bool IsNil { get { return IsReading ? this.schemaInfo.IsNil : false; } } - public virtual XmlSchemaSimpleType MemberType { get { return IsReading ? this.schemaInfo.MemberType : null; } } - public virtual XmlSchemaType SchemaType { get { return IsReading ? this.schemaInfo.SchemaType : null; } } - public virtual XmlSchemaElement SchemaElement { get { return IsReading ? this.schemaInfo.SchemaElement : null; } } - public virtual XmlSchemaAttribute SchemaAttribute { get { return IsReading ? this.schemaInfo.SchemaAttribute : null; } } - } -#endif - - internal class XPathNavigatorReaderWithSI : XPathNavigatorReader, Microsoft.Xml.Schema.IXmlSchemaInfo - { - internal XPathNavigatorReaderWithSI(XPathNavigator navToRead, IXmlLineInfo xli, IXmlSchemaInfo xsi) - : base(navToRead, xli, xsi) - { - } - - //----------------------------------------------- - // IXmlSchemaInfo - //----------------------------------------------- - - public virtual XmlSchemaValidity Validity { get { return IsReading ? this.schemaInfo.Validity : XmlSchemaValidity.NotKnown; } } - public override bool IsDefault { get { return IsReading ? this.schemaInfo.IsDefault : false; } } - public virtual bool IsNil { get { return IsReading ? this.schemaInfo.IsNil : false; } } - public virtual XmlSchemaSimpleType MemberType { get { return IsReading ? this.schemaInfo.MemberType : null; } } - public virtual XmlSchemaType SchemaType { get { return IsReading ? this.schemaInfo.SchemaType : null; } } - public virtual XmlSchemaElement SchemaElement { get { return IsReading ? this.schemaInfo.SchemaElement : null; } } - public virtual XmlSchemaAttribute SchemaAttribute { get { return IsReading ? this.schemaInfo.SchemaAttribute : null; } } - } - - /// - /// The XmlEmptyNavigator exposes a document node with no children. - /// Only one XmlEmptyNavigator exists per AppDomain (Singleton). That's why the constructor is private. - /// Use the Singleton property to get the EmptyNavigator. - /// - internal class XmlEmptyNavigator : XPathNavigator - { - private static volatile XmlEmptyNavigator s_singleton; - - private XmlEmptyNavigator() - { - } - - public static XmlEmptyNavigator Singleton - { - get - { - if (XmlEmptyNavigator.s_singleton == null) - XmlEmptyNavigator.s_singleton = new XmlEmptyNavigator(); - return XmlEmptyNavigator.s_singleton; - } - } - - //----------------------------------------------- - // XmlReader - //----------------------------------------------- - - public override XPathNodeType NodeType - { - get { return XPathNodeType.All; } - } - - public override string NamespaceURI - { - get { return string.Empty; } - } - - public override string LocalName - { - get { return string.Empty; } - } - - public override string Name - { - get { return string.Empty; } - } - - public override string Prefix - { - get { return string.Empty; } - } - - public override string BaseURI - { - get { return string.Empty; } - } - - public override string Value - { - get { return string.Empty; } - } - - public override bool IsEmptyElement - { - get { return false; } - } - - public override string XmlLang - { - get { return string.Empty; } - } - - public override bool HasAttributes - { - get { return false; } - } - - public override bool HasChildren - { - get { return false; } - } - - - //----------------------------------------------- - // IXmlNamespaceResolver - //----------------------------------------------- - - public override XmlNameTable NameTable - { - get { return new NameTable(); } - } - - public override bool MoveToFirstChild() - { - return false; - } - - public override void MoveToRoot() - { - //always on root - return; - } - - public override bool MoveToNext() - { - return false; - } - - public override bool MoveToPrevious() - { - return false; - } - - public override bool MoveToFirst() - { - return false; - } - - public override bool MoveToFirstAttribute() - { - return false; - } - - public override bool MoveToNextAttribute() - { - return false; - } - - public override bool MoveToId(string id) - { - return false; - } - - public override string GetAttribute(string localName, string namespaceName) - { - return null; - } - - public override bool MoveToAttribute(string localName, string namespaceName) - { - return false; - } - - public override string GetNamespace(string name) - { - return null; - } - - public override bool MoveToNamespace(string prefix) - { - return false; - } - - - public override bool MoveToFirstNamespace(XPathNamespaceScope scope) - { - return false; - } - - public override bool MoveToNextNamespace(XPathNamespaceScope scope) - { - return false; - } - - public override bool MoveToParent() - { - return false; - } - - public override bool MoveTo(XPathNavigator other) - { - // Only one instance of XmlEmptyNavigator exists on the system - return (object)this == (object)other; - } - - public override XmlNodeOrder ComparePosition(XPathNavigator other) - { - // Only one instance of XmlEmptyNavigator exists on the system - return ((object)this == (object)other) ? XmlNodeOrder.Same : XmlNodeOrder.Unknown; - } - - public override bool IsSamePosition(XPathNavigator other) - { - // Only one instance of XmlEmptyNavigator exists on the system - return (object)this == (object)other; - } - - - //----------------------------------------------- - // XPathNavigator2 - //----------------------------------------------- - public override XPathNavigator Clone() - { - // Singleton, so clone just returns this - return this; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeIterator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeIterator.cs deleted file mode 100644 index ffeb5b23ac7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeIterator.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.Diagnostics; -using System.Text; - -namespace Microsoft.Xml.XPath -{ - using System; - using Microsoft.Xml; - - - [DebuggerDisplay("Position={CurrentPosition}, Current={debuggerDisplayProxy}")] - public abstract class XPathNodeIterator : ICloneable, IEnumerable - { - internal int count = -1; - - object ICloneable.Clone() { return this.Clone(); } - - public abstract XPathNodeIterator Clone(); - public abstract bool MoveNext(); - public abstract XPathNavigator Current { get; } - public abstract int CurrentPosition { get; } - public virtual int Count - { - get - { - if (count == -1) - { - XPathNodeIterator clone = this.Clone(); - while (clone.MoveNext()) ; - count = clone.CurrentPosition; - } - return count; - } - } - public virtual IEnumerator GetEnumerator() - { - return new Enumerator(this); - } - - private object debuggerDisplayProxy { get { return Current == null ? null : (object)new XPathNavigator.DebuggerDisplayProxy(Current); } } - - /// - /// Implementation of a resetable enumerator that is linked to the XPathNodeIterator used to create it. - /// - private class Enumerator : IEnumerator - { - private XPathNodeIterator _original; // Keep original XPathNodeIterator in case Reset() is called - private XPathNodeIterator _current; - private bool _iterationStarted; - - public Enumerator(XPathNodeIterator original) - { - _original = original.Clone(); - } - - public virtual object Current - { - get - { - // 1. Do not reuse the XPathNavigator, as we do in XPathNodeIterator - // 2. Throw exception if current position is before first node or after the last node - if (_iterationStarted) - { - // Current is null if iterator is positioned after the last node - if (_current == null) - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumFinished, string.Empty)); - - return _current.Current.Clone(); - } - - // User must call MoveNext before accessing Current property - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - } - - public virtual bool MoveNext() - { - // Delegate to XPathNodeIterator - if (!_iterationStarted) - { - // Reset iteration to original position - _current = _original.Clone(); - _iterationStarted = true; - } - - if (_current == null || !_current.MoveNext()) - { - // Iteration complete - _current = null; - return false; - } - return true; - } - - public virtual void Reset() - { - _iterationStarted = false; - } - } - - private struct DebuggerDisplayProxy - { - private XPathNodeIterator _nodeIterator; - - public DebuggerDisplayProxy(XPathNodeIterator nodeIterator) - { - _nodeIterator = nodeIterator; - } - - public override string ToString() - { - // Position={CurrentPosition}, Current={Current == null ? null : (object) new XPathNavigator.DebuggerDisplayProxy(Current)} - StringBuilder sb = new StringBuilder(); - sb.Append("Position="); - sb.Append(_nodeIterator.CurrentPosition); - sb.Append(", Current="); - if (_nodeIterator.Current == null) - { - sb.Append("null"); - } - else - { - sb.Append('{'); - sb.Append(new XPathNavigator.DebuggerDisplayProxy(_nodeIterator.Current).ToString()); - sb.Append('}'); - } - return sb.ToString(); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeType.cs deleted file mode 100644 index 48b39fb09b1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XPath/XPathNodeType.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.XPath -{ - using System; - - public enum XPathNodeType - { - Root, - Element, - Attribute, - Namespace, - Text, - SignificantWhitespace, - Whitespace, - ProcessingInstruction, - Comment, - All, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlCharType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlCharType.cs index 4bbc5a2a71a..bd7748283f5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlCharType.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlCharType.cs @@ -6,7 +6,7 @@ #endif -//#define XMLCHARTYPE_USE_RESOURCE // load the character properties from resources (XmlCharType.bin must be linked to Microsoft.Xml.dll) +//#define XMLCHARTYPE_USE_RESOURCE // load the character properties from resources (XmlCharType.bin must be linked to System.Xml.dll) //#define XMLCHARTYPE_GEN_RESOURCE // generate the character properties into XmlCharType.bin #if XMLCHARTYPE_GEN_RESOURCE || XMLCHARTYPE_USE_RESOURCE @@ -16,7 +16,7 @@ using System.Threading; using System.Diagnostics; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlComplianceUtil.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlComplianceUtil.cs index e4c728562d5..89205d22557 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlComplianceUtil.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlComplianceUtil.cs @@ -5,7 +5,7 @@ using System; using System.IO; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlConvert.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlConvert.cs deleted file mode 100644 index 8d11725f9c6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlConvert.cs +++ /dev/null @@ -1,1883 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.IO; - using System.Text; - using System.Globalization; - using Microsoft.Xml.Schema; - using System.Diagnostics; - using System.Collections; - using System.Text.RegularExpressions; - - // ExceptionType enum is used inside XmlConvert to specify which type of exception should be thrown at some of the verification and exception creating methods - internal enum ExceptionType - { - ArgumentException, - XmlException, - } - - // Options for serializing and deserializing DateTime - public enum XmlDateTimeSerializationMode - { - Local, - Utc, - Unspecified, - RoundtripKind, - } - - /// - /// - /// Encodes and decodes XML names according to - /// the "Encoding of arbitrary Unicode Characters in XML Names" specification. - /// - public class XmlConvert - { - // - // Static fields with implicit initialization - // - private static XmlCharType s_xmlCharType = XmlCharType.Instance; - - internal static char[] crt = new char[] { '\n', '\r', '\t' }; - - /// - /// - /// - /// Converts names, such - /// as DataTable or - /// DataColumn names, that contain characters that are not permitted in - /// XML names to valid names. - /// - public static string EncodeName(string name) - { - return EncodeName(name, true/*Name_not_NmToken*/, false/*Local?*/); - } - - /// - /// - /// Verifies the name is valid - /// according to production [7] in the XML spec. - /// - public static string EncodeNmToken(string name) - { - return EncodeName(name, false/*Name_not_NmToken*/, false/*Local?*/); - } - - /// - /// - /// Converts names, such as DataTable or DataColumn names, that contain - /// characters that are not permitted in XML names to valid names. - /// - public static string EncodeLocalName(string name) - { - return EncodeName(name, true/*Name_not_NmToken*/, true/*Local?*/); - } - - /// - /// - /// - /// Transforms an XML name into an object name (such as DataTable or DataColumn). - /// - - public static string DecodeName(string name) - { - if (name == null || name.Length == 0) - return name; - - StringBuilder bufBld = null; - - int length = name.Length; - int copyPosition = 0; - - int underscorePos = name.IndexOf('_'); - MatchCollection mc = null; - IEnumerator en = null; - if (underscorePos >= 0) - { - if (s_decodeCharPattern == null) - { - s_decodeCharPattern = new Regex("_[Xx]([0-9a-fA-F]{4}|[0-9a-fA-F]{8})_"); - } - mc = s_decodeCharPattern.Matches(name, underscorePos); - en = mc.GetEnumerator(); - } - else - { - return name; - } - int matchPos = -1; - if (en != null && en.MoveNext()) - { - Match m = (Match)en.Current; - matchPos = m.Index; - } - - for (int position = 0; position < length - s_encodedCharLength + 1; position++) - { - if (position == matchPos) - { - if (en.MoveNext()) - { - Match m = (Match)en.Current; - matchPos = m.Index; - } - - if (bufBld == null) - { - bufBld = new StringBuilder(length + 20); - } - bufBld.Append(name, copyPosition, position - copyPosition); - - if (name[position + 6] != '_') - { //_x1234_ - Int32 u = - FromHex(name[position + 2]) * 0x10000000 + - FromHex(name[position + 3]) * 0x1000000 + - FromHex(name[position + 4]) * 0x100000 + - FromHex(name[position + 5]) * 0x10000 + - - FromHex(name[position + 6]) * 0x1000 + - FromHex(name[position + 7]) * 0x100 + - FromHex(name[position + 8]) * 0x10 + - FromHex(name[position + 9]); - - if (u >= 0x00010000) - { - if (u <= 0x0010ffff) - { //convert to two chars - copyPosition = position + s_encodedCharLength + 4; - char lowChar, highChar; - XmlCharType.SplitSurrogateChar(u, out lowChar, out highChar); - bufBld.Append(highChar); - bufBld.Append(lowChar); - } - //else bad ucs-4 char dont convert - } - else - { //convert to single char - copyPosition = position + s_encodedCharLength + 4; - bufBld.Append((char)u); - } - position += s_encodedCharLength - 1 + 4; //just skip - } - else - { - copyPosition = position + s_encodedCharLength; - bufBld.Append((char)( - FromHex(name[position + 2]) * 0x1000 + - FromHex(name[position + 3]) * 0x100 + - FromHex(name[position + 4]) * 0x10 + - FromHex(name[position + 5]))); - position += s_encodedCharLength - 1; - } - } - } - if (copyPosition == 0) - { - return name; - } - else - { - if (copyPosition < length) - { - bufBld.Append(name, copyPosition, length - copyPosition); - } - return bufBld.ToString(); - } - } - - private static string EncodeName(string name, /*Name_not_NmToken*/ bool first, bool local) - { - if (string.IsNullOrEmpty(name)) - { - return name; - } - - StringBuilder bufBld = null; - int length = name.Length; - int copyPosition = 0; - int position = 0; - - int underscorePos = name.IndexOf('_'); - MatchCollection mc = null; - IEnumerator en = null; - if (underscorePos >= 0) - { - if (s_encodeCharPattern == null) - { - s_encodeCharPattern = new Regex("(?<=_)[Xx]([0-9a-fA-F]{4}|[0-9a-fA-F]{8})_"); - } - mc = s_encodeCharPattern.Matches(name, underscorePos); - en = mc.GetEnumerator(); - } - - int matchPos = -1; - if (en != null && en.MoveNext()) - { - Match m = (Match)en.Current; - matchPos = m.Index - 1; - } - if (first) - { - if ((!s_xmlCharType.IsStartNCNameCharXml4e(name[0]) && (local || (!local && name[0] != ':'))) || - matchPos == 0) - { - if (bufBld == null) - { - bufBld = new StringBuilder(length + 20); - } - bufBld.Append("_x"); - if (length > 1 && XmlCharType.IsHighSurrogate(name[0]) && XmlCharType.IsLowSurrogate(name[1])) - { - int x = name[0]; - int y = name[1]; - Int32 u = XmlCharType.CombineSurrogateChar(y, x); - bufBld.Append(u.ToString("X8", CultureInfo.InvariantCulture)); - position++; - copyPosition = 2; - } - else - { - bufBld.Append(((Int32)name[0]).ToString("X4", CultureInfo.InvariantCulture)); - copyPosition = 1; - } - - bufBld.Append("_"); - position++; - - if (matchPos == 0) - if (en.MoveNext()) - { - Match m = (Match)en.Current; - matchPos = m.Index - 1; - } - } - } - for (; position < length; position++) - { - if ((local && !s_xmlCharType.IsNCNameCharXml4e(name[position])) || - (!local && !s_xmlCharType.IsNameCharXml4e(name[position])) || - (matchPos == position)) - { - if (bufBld == null) - { - bufBld = new StringBuilder(length + 20); - } - if (matchPos == position) - if (en.MoveNext()) - { - Match m = (Match)en.Current; - matchPos = m.Index - 1; - } - - bufBld.Append(name, copyPosition, position - copyPosition); - bufBld.Append("_x"); - if ((length > position + 1) && XmlCharType.IsHighSurrogate(name[position]) && XmlCharType.IsLowSurrogate(name[position + 1])) - { - int x = name[position]; - int y = name[position + 1]; - Int32 u = XmlCharType.CombineSurrogateChar(y, x); - bufBld.Append(u.ToString("X8", CultureInfo.InvariantCulture)); - copyPosition = position + 2; - position++; - } - else - { - bufBld.Append(((Int32)name[position]).ToString("X4", CultureInfo.InvariantCulture)); - copyPosition = position + 1; - } - bufBld.Append("_"); - } - } - if (copyPosition == 0) - { - return name; - } - else - { - if (copyPosition < length) - { - bufBld.Append(name, copyPosition, length - copyPosition); - } - return bufBld.ToString(); - } - } - - private static readonly int s_encodedCharLength = 7; // ("_xFFFF_".Length); - private static volatile Regex s_encodeCharPattern; - private static volatile Regex s_decodeCharPattern; - private static int FromHex(char digit) - { - return (digit <= '9') - ? ((int)digit - (int)'0') - : (((digit <= 'F') - ? ((int)digit - (int)'A') - : ((int)digit - (int)'a')) - + 10); - } - - internal static byte[] FromBinHexString(string s) - { - return FromBinHexString(s, true); - } - - internal static byte[] FromBinHexString(string s, bool allowOddCount) - { - if (s == null) - { - throw new ArgumentNullException("s"); - } - return BinHexDecoder.Decode(s.ToCharArray(), allowOddCount); - } - - internal static string ToBinHexString(byte[] inArray) - { - if (inArray == null) - { - throw new ArgumentNullException("inArray"); - } - return BinHexEncoder.Encode(inArray, 0, inArray.Length); - } - - // - // Verification methods for strings - // - /// - /// - /// - /// - /// - public static string VerifyName(string name) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - if (name.Length == 0) - { - throw new ArgumentNullException("name", ResXml.Xml_EmptyName); - } - - // parse name - int endPos = ValidateNames.ParseNameNoNamespaces(name, 0); - - if (endPos != name.Length) - { - // did not parse to the end -> there is invalid character at endPos - throw CreateInvalidNameCharException(name, endPos, ExceptionType.XmlException); - } - return name; - } - - - internal static Exception TryVerifyName(string name) - { - if (name == null || name.Length == 0) - { - return new XmlException(ResXml.Xml_EmptyName, string.Empty); - } - - int endPos = ValidateNames.ParseNameNoNamespaces(name, 0); - if (endPos != name.Length) - { - return new XmlException(endPos == 0 ? ResXml.Xml_BadStartNameChar : ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos)); - } - return null; - } - - internal static string VerifyQName(string name) - { - return VerifyQName(name, ExceptionType.XmlException); - } - - internal static unsafe string VerifyQName(string name, ExceptionType exceptionType) - { - if (name == null || name.Length == 0) - { - throw new ArgumentNullException("name"); - } - - int colonPosition = -1; - - int endPos = ValidateNames.ParseQName(name, 0, out colonPosition); - if (endPos != name.Length) - { - throw CreateException(ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos), exceptionType, 0, endPos + 1); - } - return name; - } - - /// - /// - /// - /// - /// - public static string VerifyNCName(string name) - { - return VerifyNCName(name, ExceptionType.XmlException); - } - - internal static string VerifyNCName(string name, ExceptionType exceptionType) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - if (name.Length == 0) - { - throw new ArgumentNullException("name", ResXml.Xml_EmptyLocalName); - } - - int end = ValidateNames.ParseNCName(name, 0); - - if (end != name.Length) - { - // If the string is not a valid NCName, then throw or return false - throw CreateInvalidNameCharException(name, end, exceptionType); - } - - return name; - } - - internal static Exception TryVerifyNCName(string name) - { - int len = ValidateNames.ParseNCName(name); - - if (len == 0 || len != name.Length) - { - return ValidateNames.GetInvalidNameException(name, 0, len); - } - return null; - } - - /// - /// - /// - /// - /// - public static string VerifyTOKEN(string token) - { - if (token == null || token.Length == 0) - { - return token; - } - if (token[0] == ' ' || token[token.Length - 1] == ' ' || token.IndexOfAny(crt) != -1 || token.IndexOf(" ", StringComparison.Ordinal) != -1) - { - throw new XmlException(ResXml.Sch_NotTokenString, token); - } - return token; - } - - internal static Exception TryVerifyTOKEN(string token) - { - if (token == null || token.Length == 0) - { - return null; - } - if (token[0] == ' ' || token[token.Length - 1] == ' ' || token.IndexOfAny(crt) != -1 || token.IndexOf(" ", StringComparison.Ordinal) != -1) - { - return new XmlException(ResXml.Sch_NotTokenString, token); - } - return null; - } - - /// - /// - /// - /// - /// - public static string VerifyNMTOKEN(string name) - { - return VerifyNMTOKEN(name, ExceptionType.XmlException); - } - - internal static string VerifyNMTOKEN(string name, ExceptionType exceptionType) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - if (name.Length == 0) - { - throw CreateException(ResXml.Xml_InvalidNmToken, name, exceptionType); - } - - int endPos = ValidateNames.ParseNmtokenNoNamespaces(name, 0); - - if (endPos != name.Length) - { - throw CreateException(ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos), exceptionType, 0, endPos + 1); - } - return name; - } - - internal static Exception TryVerifyNMTOKEN(string name) - { - if (name == null || name.Length == 0) - { - return new XmlException(ResXml.Xml_EmptyName, string.Empty); - } - int endPos = ValidateNames.ParseNmtokenNoNamespaces(name, 0); - if (endPos != name.Length) - { - return new XmlException(ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, endPos)); - } - return null; - } - - - internal static string VerifyNormalizedString(string str) - { - if (str.IndexOfAny(crt) != -1) - { - throw new XmlSchemaException(ResXml.Sch_NotNormalizedString, str); - } - return str; - } - - internal static Exception TryVerifyNormalizedString(string str) - { - if (str.IndexOfAny(crt) != -1) - { - return new XmlSchemaException(ResXml.Sch_NotNormalizedString, str); - } - return null; - } - - // Verification method for XML characters as defined in XML spec production [2] Char. - // Throws XmlException if invalid character is found, otherwise returns the input string. - public static string VerifyXmlChars(string content) - { - if (content == null) - { - throw new ArgumentNullException("content"); - } - VerifyCharData(content, ExceptionType.XmlException); - return content; - } - - // Verification method for XML public ID characters as defined in XML spec production [13] PubidChar. - // Throws XmlException if invalid character is found, otherwise returns the input string. - public static string VerifyPublicId(string publicId) - { - if (publicId == null) - { - throw new ArgumentNullException("publicId"); - } - - // returns the position of invalid character or -1 - int pos = s_xmlCharType.IsPublicId(publicId); - if (pos != -1) - { - throw CreateInvalidCharException(publicId, pos, ExceptionType.XmlException); - } - - return publicId; - } - - // Verification method for XML whitespace characters as defined in XML spec production [3] S. - // Throws XmlException if invalid character is found, otherwise returns the input string. - public static string VerifyWhitespace(string content) - { - if (content == null) - { - throw new ArgumentNullException("content"); - } - - // returns the position of invalid character or -1 - int pos = s_xmlCharType.IsOnlyWhitespaceWithPos(content); - if (pos != -1) - { - throw new XmlException(ResXml.Xml_InvalidWhitespaceCharacter, XmlException.BuildCharExceptionArgs(content, pos), 0, pos + 1); - } - return content; - } - - // - // Verification methods for single characters and surrogates - // - // In cases where the direct call into XmlCharType would not get automatically inlined (because of the use of byte* field), - // direct access to the XmlCharType.charProperties is used instead (= manual inlining). - // - - // Start name character types - as defined in Namespaces XML 1.0 spec (second edition) production [6] NCNameStartChar - // combined with the production [4] NameStartChar of XML 1.0 spec - public static unsafe bool IsStartNCNameChar(char ch) - { - return (s_xmlCharType.charProperties[ch] & XmlCharType.fNCStartNameSC) != 0; - } - -#if XML10_FIFTH_EDITION - public static bool IsStartNCNameSurrogatePair(char lowChar, char highChar) { - return xmlCharType.IsNCNameSurrogateChar(lowChar, highChar); - } -#endif - - // Name character types - as defined in Namespaces XML 1.0 spec (second edition) production [6] NCNameStartChar - // combined with the production [4] NameChar of XML 1.0 spec - public static unsafe bool IsNCNameChar(char ch) - { - return (s_xmlCharType.charProperties[ch] & XmlCharType.fNCNameSC) != 0; - } - -#if XML10_FIFTH_EDITION - public static bool IsNCNameSurrogatePair(char lowChar, char highChar) { - return xmlCharType.IsNCNameSurrogateChar(lowChar, highChar); - } -#endif - - // Valid XML character � as defined in XML 1.0 spec (fifth edition) production [2] Char - public static unsafe bool IsXmlChar(char ch) - { - return (s_xmlCharType.charProperties[ch] & XmlCharType.fCharData) != 0; - } - - public static bool IsXmlSurrogatePair(char lowChar, char highChar) - { - return XmlCharType.IsHighSurrogate(highChar) && XmlCharType.IsLowSurrogate(lowChar); - } - - // Valid PUBLIC ID character � as defined in XML 1.0 spec (fifth edition) production [13] PublidChar - public static bool IsPublicIdChar(char ch) - { - return s_xmlCharType.IsPubidChar(ch); - } - - // Valid Xml white space � as defined in XML 1.0 spec (fifth edition) production [3] S - public static unsafe bool IsWhitespaceChar(char ch) - { - return (s_xmlCharType.charProperties[ch] & XmlCharType.fWhitespace) != 0; - } - - // Value convertors: - // - // String representation of Base types in XML (xsd) sometimes differ from - // one common language runtime offer and for all types it has to be locale independent. - // o -- means that XmlConvert pass through to common language runtime converter with InvariantInfo FormatInfo - // x -- means we doing something special to make a convertion. - // - // From: To: Bol Chr SBy Byt I16 U16 I32 U32 I64 U64 Sgl Dbl Dec Dat Tim Str uid - // ------------------------------------------------------------------------------ - // Boolean x - // Char o - // SByte o - // Byte o - // Int16 o - // UInt16 o - // Int32 o - // UInt32 o - // Int64 o - // UInt64 o - // Single x - // Double x - // Decimal o - // DateTime x - // String x o o o o o o o o o o x x o o x - // Guid x - // ----------------------------------------------------------------------------- - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Boolean value) - { - return value ? "true" : "false"; - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Char value) - { - return value.ToString(); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Decimal value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static string ToString(SByte value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Int16 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Int32 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Int64 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Byte value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static string ToString(UInt16 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static string ToString(UInt32 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static string ToString(UInt64 value) - { - return value.ToString(null, NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Single value) - { - if (Single.IsNegativeInfinity(value)) return "-INF"; - if (Single.IsPositiveInfinity(value)) return "INF"; - if (IsNegativeZero((double)value)) - { - return ("-0"); - } - return value.ToString("R", NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Double value) - { - if (Double.IsNegativeInfinity(value)) return "-INF"; - if (Double.IsPositiveInfinity(value)) return "INF"; - if (IsNegativeZero(value)) - { - return ("-0"); - } - return value.ToString("R", NumberFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(TimeSpan value) - { - return new XsdDuration(value).ToString(); - } - - /// - /// - /// [To be supplied.] - /// - [Obsolete("Use XmlConvert.ToString() that takes in XmlDateTimeSerializationMode")] - public static string ToString(DateTime value) - { - return ToString(value, "yyyy-MM-ddTHH:mm:ss.fffffffzzzzzz"); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(DateTime value, string format) - { - return value.ToString(format, DateTimeFormatInfo.InvariantInfo); - } - /// - /// - /// [To be supplied.] - /// - public static string ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption) - { - switch (dateTimeOption) - { - case XmlDateTimeSerializationMode.Local: - value = SwitchToLocalTime(value); - break; - - case XmlDateTimeSerializationMode.Utc: - value = SwitchToUtcTime(value); - break; - - case XmlDateTimeSerializationMode.Unspecified: - value = new DateTime(value.Ticks, DateTimeKind.Unspecified); - break; - - case XmlDateTimeSerializationMode.RoundtripKind: - break; - - default: - throw new ArgumentException(string.Format(ResXml.Sch_InvalidDateTimeOption, dateTimeOption, "dateTimeOption")); - } - XsdDateTime xsdDateTime = new XsdDateTime(value, XsdDateTimeFlags.DateTime); - return xsdDateTime.ToString(); - } - - public static string ToString(DateTimeOffset value) - { - XsdDateTime xsdDateTime = new XsdDateTime(value); - return xsdDateTime.ToString(); - } - - public static string ToString(DateTimeOffset value, string format) - { - return value.ToString(format, DateTimeFormatInfo.InvariantInfo); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(Guid value) - { - return value.ToString(); - } - - /// - /// - /// [To be supplied.] - /// - public static Boolean ToBoolean(string s) - { - s = TrimString(s); - if (s == "1" || s == "true") return true; - if (s == "0" || s == "false") return false; - throw new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Boolean")); - } - - internal static Exception TryToBoolean(string s, out Boolean result) - { - s = TrimString(s); - if (s == "0" || s == "false") - { - result = false; - return null; - } - else if (s == "1" || s == "true") - { - result = true; - return null; - } - result = false; - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Boolean")); - } - - /// - /// - /// [To be supplied.] - /// - public static Char ToChar(string s) - { - if (s == null) - { - throw new ArgumentNullException("s"); - } - if (s.Length != 1) - { - throw new FormatException(ResXml.XmlConvert_NotOneCharString); - } - return s[0]; - } - - internal static Exception TryToChar(string s, out Char result) - { - if (!Char.TryParse(s, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Char")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Decimal ToDecimal(string s) - { - return Decimal.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToDecimal(string s, out Decimal result) - { - if (!Decimal.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Decimal")); - } - return null; - } - - internal static Decimal ToInteger(string s) - { - return Decimal.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToInteger(string s, out Decimal result) - { - if (!Decimal.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Integer")); - } - return null; - } - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static SByte ToSByte(string s) - { - return SByte.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToSByte(string s, out SByte result) - { - if (!SByte.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "SByte")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Int16 ToInt16(string s) - { - return Int16.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToInt16(string s, out Int16 result) - { - if (!Int16.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Int16")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Int32 ToInt32(string s) - { - return Int32.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToInt32(string s, out Int32 result) - { - if (!Int32.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Int32")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Int64 ToInt64(string s) - { - return Int64.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToInt64(string s, out Int64 result) - { - if (!Int64.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Int64")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Byte ToByte(string s) - { - return Byte.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToByte(string s, out Byte result) - { - if (!Byte.TryParse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Byte")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static UInt16 ToUInt16(string s) - { - return UInt16.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToUInt16(string s, out UInt16 result) - { - if (!UInt16.TryParse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "UInt16")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static UInt32 ToUInt32(string s) - { - return UInt32.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - - internal static Exception TryToUInt32(string s, out UInt32 result) - { - if (!UInt32.TryParse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "UInt32")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - // [CLSCompliant(false)] - public static UInt64 ToUInt64(string s) - { - return UInt64.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - } - - internal static Exception TryToUInt64(string s, out UInt64 result) - { - if (!UInt64.TryParse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "UInt64")); - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Single ToSingle(string s) - { - s = TrimString(s); - if (s == "-INF") return Single.NegativeInfinity; - if (s == "INF") return Single.PositiveInfinity; - float f = Single.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, NumberFormatInfo.InvariantInfo); - if (f == 0 && s[0] == '-') - { - return -0f; - } - return f; - } - - internal static Exception TryToSingle(string s, out Single result) - { - s = TrimString(s); - if (s == "-INF") - { - result = Single.NegativeInfinity; - return null; - } - else if (s == "INF") - { - result = Single.PositiveInfinity; - return null; - } - else if (!Single.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Single")); - } - if (result == 0 && s[0] == '-') - { - result = -0f; - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static Double ToDouble(string s) - { - s = TrimString(s); - if (s == "-INF") return Double.NegativeInfinity; - if (s == "INF") return Double.PositiveInfinity; - double dVal = Double.Parse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo); - if (dVal == 0 && s[0] == '-') - { - return -0d; - } - return dVal; - } - - internal static Exception TryToDouble(string s, out double result) - { - s = TrimString(s); - if (s == "-INF") - { - result = Double.NegativeInfinity; - return null; - } - else if (s == "INF") - { - result = Double.PositiveInfinity; - return null; - } - else if (!Double.TryParse(s, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, NumberFormatInfo.InvariantInfo, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Double")); - } - if (result == 0 && s[0] == '-') - { - result = -0d; - } - return null; - } - - internal static Double ToXPathDouble(Object o) - { - string str = o as string; - if (str != null) - { - str = TrimString(str); - if (str.Length != 0 && str[0] != '+') - { - double d; - if (Double.TryParse(str, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out d)) - { - return d; - } - } - return Double.NaN; - } - if (o is double) - { - return (double)o; - } - if (o is bool) - { - return ((bool)o) ? 1.0 : 0.0; - } - try - { - return Convert.ToDouble(o, NumberFormatInfo.InvariantInfo); - } - catch (FormatException) - { - } - catch (OverflowException) - { - } - catch (ArgumentNullException) { } - return Double.NaN; - } - - internal static String ToXPathString(Object value) - { - string s = value as string; - if (s != null) - { - return s; - } - else if (value is double) - { - return ((double)value).ToString("R", NumberFormatInfo.InvariantInfo); - } - else if (value is bool) - { - return (bool)value ? "true" : "false"; - } - else - { - return Convert.ToString(value, NumberFormatInfo.InvariantInfo); - } - } - - internal static Double XPathRound(Double value) - { - double temp = Math.Round(value); - return (value - temp == 0.5) ? temp + 1 : temp; - } - - /// - /// - /// [To be supplied.] - /// - public static TimeSpan ToTimeSpan(string s) - { - XsdDuration duration; - TimeSpan timeSpan; - - try - { - duration = new XsdDuration(s); - } - catch (Exception) - { - // Remap exception for v1 compatibility - throw new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "TimeSpan")); - } - - timeSpan = duration.ToTimeSpan(); - - return timeSpan; - } - - internal static Exception TryToTimeSpan(string s, out TimeSpan result) - { - XsdDuration duration; - Exception exception; - - exception = XsdDuration.TryParse(s, out duration); - if (exception != null) - { - result = TimeSpan.MinValue; - return exception; - } - else - { - return duration.TryToTimeSpan(out result); - } - } - - // use AllDateTimeFormats property to access the formats - private static volatile string[] s_allDateTimeFormats; - - // NOTE: Do not use this property for reference comparison. It may not be unique. - private static string[] AllDateTimeFormats - { - get - { - if (s_allDateTimeFormats == null) - { - CreateAllDateTimeFormats(); - } - return s_allDateTimeFormats; - } - } - - private static void CreateAllDateTimeFormats() - { - if (s_allDateTimeFormats == null) - { - // no locking; the array is immutable so it's not a problem that it may get initialized more than once - s_allDateTimeFormats = new string[] { - "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzzzzz", //dateTime - "yyyy-MM-ddTHH:mm:ss.FFFFFFF", - "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ", - "HH:mm:ss.FFFFFFF", //time - "HH:mm:ss.FFFFFFFZ", - "HH:mm:ss.FFFFFFFzzzzzz", - "yyyy-MM-dd", // date - "yyyy-MM-ddZ", - "yyyy-MM-ddzzzzzz", - "yyyy-MM", // yearMonth - "yyyy-MMZ", - "yyyy-MMzzzzzz", - "yyyy", // year - "yyyyZ", - "yyyyzzzzzz", - "--MM-dd", // monthDay - "--MM-ddZ", - "--MM-ddzzzzzz", - "---dd", // day - "---ddZ", - "---ddzzzzzz", - "--MM--", // month - "--MM--Z", - "--MM--zzzzzz", - }; - } - } - - /// - /// - /// [To be supplied.] - /// - [Obsolete("Use XmlConvert.ToDateTime() that takes in XmlDateTimeSerializationMode")] - public static DateTime ToDateTime(string s) - { - return ToDateTime(s, AllDateTimeFormats); - } - - /// - /// - /// [To be supplied.] - /// - public static DateTime ToDateTime(string s, string format) - { - return DateTime.ParseExact(s, format, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite); - } - - /// - /// - /// [To be supplied.] - /// - public static DateTime ToDateTime(string s, string[] formats) - { - return DateTime.ParseExact(s, formats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite); - } - - /// - /// - /// [To be supplied.] - /// - public static DateTime ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption) - { - XsdDateTime xsdDateTime = new XsdDateTime(s, XsdDateTimeFlags.AllXsd); - DateTime dt = (DateTime)xsdDateTime; - - switch (dateTimeOption) - { - case XmlDateTimeSerializationMode.Local: - dt = SwitchToLocalTime(dt); - break; - - case XmlDateTimeSerializationMode.Utc: - dt = SwitchToUtcTime(dt); - break; - - case XmlDateTimeSerializationMode.Unspecified: - dt = new DateTime(dt.Ticks, DateTimeKind.Unspecified); - break; - - case XmlDateTimeSerializationMode.RoundtripKind: - break; - - default: - throw new ArgumentException(string.Format(ResXml.Sch_InvalidDateTimeOption, dateTimeOption, "dateTimeOption")); - } - return dt; - } - - public static DateTimeOffset ToDateTimeOffset(string s) - { - if (s == null) - { - throw new ArgumentNullException("s"); - } - XsdDateTime xsdDateTime = new XsdDateTime(s, XsdDateTimeFlags.AllXsd); - DateTimeOffset dateTimeOffset = (DateTimeOffset)xsdDateTime; - return dateTimeOffset; - } - - public static DateTimeOffset ToDateTimeOffset(string s, string format) - { - if (s == null) - { - throw new ArgumentNullException("s"); - } - return DateTimeOffset.ParseExact(s, format, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite); - } - - public static DateTimeOffset ToDateTimeOffset(string s, string[] formats) - { - if (s == null) - { - throw new ArgumentNullException("s"); - } - return DateTimeOffset.ParseExact(s, formats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite); - } - - /// - /// - /// [To be supplied.] - /// - public static Guid ToGuid(string s) - { - return new Guid(s); - } - - internal static Exception TryToGuid(string s, out Guid result) - { - Exception exception = null; - - result = Guid.Empty; - - try - { - result = new Guid(s); - } - catch (ArgumentException) - { - exception = new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Guid")); - } - catch (FormatException) - { - exception = new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Guid")); - } - return exception; - } - - private static DateTime SwitchToLocalTime(DateTime value) - { - switch (value.Kind) - { - case DateTimeKind.Local: - return value; - - case DateTimeKind.Unspecified: - return new DateTime(value.Ticks, DateTimeKind.Local); - - case DateTimeKind.Utc: - return value.ToLocalTime(); - } - return value; - } - - private static DateTime SwitchToUtcTime(DateTime value) - { - switch (value.Kind) - { - case DateTimeKind.Utc: - return value; - - case DateTimeKind.Unspecified: - return new DateTime(value.Ticks, DateTimeKind.Utc); - - case DateTimeKind.Local: - return value.ToUniversalTime(); - } - return value; - } - - internal static Uri ToUri(string s) - { - if (s != null && s.Length > 0) - { //string.Empty is a valid uri but not " " - s = TrimString(s); - if (s.Length == 0 || s.IndexOf("##", StringComparison.Ordinal) != -1) - { - throw new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Uri")); - } - } - Uri uri; - if (!Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out uri)) - { - throw new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Uri")); - } - return uri; - } - - internal static Exception TryToUri(string s, out Uri result) - { - result = null; - - if (s != null && s.Length > 0) - { //string.Empty is a valid uri but not " " - s = TrimString(s); - if (s.Length == 0 || s.IndexOf("##", StringComparison.Ordinal) != -1) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Uri")); - } - } - if (!Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out result)) - { - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, "Uri")); - } - return null; - } - - // Compares the given character interval and string and returns true if the characters are identical - internal static bool StrEqual(char[] chars, int strPos1, int strLen1, string str2) - { - if (strLen1 != str2.Length) - { - return false; - } - - int i = 0; - while (i < strLen1 && chars[strPos1 + i] == str2[i]) - { - i++; - } - return i == strLen1; - } - - // XML whitespace characters, http://www.w3.org/TR/REC-xml#NT-S - internal static readonly char[] WhitespaceChars = new char[] { ' ', '\t', '\n', '\r' }; - - // Trim a string using XML whitespace characters - internal static string TrimString(string value) - { - return value.Trim(WhitespaceChars); - } - - // Trim beginning of a string using XML whitespace characters - internal static string TrimStringStart(string value) - { - return value.TrimStart(WhitespaceChars); - } - - // Trim end of a string using XML whitespace characters - internal static string TrimStringEnd(string value) - { - return value.TrimEnd(WhitespaceChars); - } - - // Split a string into a whitespace-separated list of tokens - internal static string[] SplitString(string value) - { - return value.Split(WhitespaceChars, StringSplitOptions.RemoveEmptyEntries); - } - - internal static string[] SplitString(string value, StringSplitOptions splitStringOptions) - { - return value.Split(WhitespaceChars, splitStringOptions); - } - - internal static bool IsNegativeZero(double value) - { - // Simple equals function will report that -0 is equal to +0, so compare bits instead - if (value == 0 && DoubleToInt64Bits(value) == DoubleToInt64Bits(-0e0)) - { - return true; - } - return false; - } - - private static unsafe long DoubleToInt64Bits(double value) - { - // NOTE: BitConverter.DoubleToInt64Bits is missing in Silverlight - return *((long*)&value); - } - - internal static void VerifyCharData(string data, ExceptionType exceptionType) - { - VerifyCharData(data, exceptionType, exceptionType); - } - - internal static unsafe void VerifyCharData(string data, ExceptionType invCharExceptionType, ExceptionType invSurrogateExceptionType) - { - if (data == null || data.Length == 0) - { - return; - } - - int i = 0; - int len = data.Length; - for (; ; ) - { - while (i < len && (s_xmlCharType.charProperties[data[i]] & XmlCharType.fCharData) != 0) - { - i++; - } - if (i == len) - { - return; - } - - char ch = data[i]; - if (XmlCharType.IsHighSurrogate(ch)) - { - if (i + 1 == len) - { - throw CreateException(ResXml.Xml_InvalidSurrogateMissingLowChar, invSurrogateExceptionType, 0, i + 1); - } - ch = data[i + 1]; - if (XmlCharType.IsLowSurrogate(ch)) - { - i += 2; - continue; - } - else - { - throw CreateInvalidSurrogatePairException(data[i + 1], data[i], invSurrogateExceptionType, 0, i + 1); - } - } - throw CreateInvalidCharException(data, i, invCharExceptionType); - } - } - - internal static unsafe void VerifyCharData(char[] data, int offset, int len, ExceptionType exceptionType) - { - if (data == null || len == 0) - { - return; - } - - int i = offset; - int endPos = offset + len; - for (; ; ) - { - while (i < endPos && (s_xmlCharType.charProperties[data[i]] & XmlCharType.fCharData) != 0) - { - i++; - } - if (i == endPos) - { - return; - } - - char ch = data[i]; - if (XmlCharType.IsHighSurrogate(ch)) - { - if (i + 1 == endPos) - { - throw CreateException(ResXml.Xml_InvalidSurrogateMissingLowChar, exceptionType, 0, offset - i + 1); - } - ch = data[i + 1]; - if (XmlCharType.IsLowSurrogate(ch)) - { - i += 2; - continue; - } - else - { - throw CreateInvalidSurrogatePairException(data[i + 1], data[i], exceptionType, 0, offset - i + 1); - } - } - throw CreateInvalidCharException(data, len, i, exceptionType); - } - } - - internal static string EscapeValueForDebuggerDisplay(string value) - { - StringBuilder sb = null; - int i = 0; - int start = 0; - while (i < value.Length) - { - char ch = value[i]; - if ((int)ch < 0x20 || ch == '"') - { - if (sb == null) - { - sb = new StringBuilder(value.Length + 4); - } - if (i - start > 0) - { - sb.Append(value, start, i - start); - } - start = i + 1; - switch (ch) - { - case '"': - sb.Append("\\\""); - break; - case '\r': - sb.Append("\\r"); - break; - case '\n': - sb.Append("\\n"); - break; - case '\t': - sb.Append("\\t"); - break; - default: - sb.Append(ch); - break; - } - } - i++; - } - if (sb == null) - { - return value; - } - if (i - start > 0) - { - sb.Append(value, start, i - start); - } - return sb.ToString(); - } - - internal static Exception CreateException(string res, ExceptionType exceptionType) - { - return CreateException(res, exceptionType, 0, 0); - } - - internal static Exception CreateException(string res, ExceptionType exceptionType, int lineNo, int linePos) - { - switch (exceptionType) - { - case ExceptionType.ArgumentException: - return new ArgumentException(res); - case ExceptionType.XmlException: - default: - return new XmlException(res, string.Empty, lineNo, linePos); - } - } - - internal static Exception CreateException(string res, string arg, ExceptionType exceptionType) - { - return CreateException(res, arg, exceptionType, 0, 0); - } - - internal static Exception CreateException(string res, string arg, ExceptionType exceptionType, int lineNo, int linePos) - { - switch (exceptionType) - { - case ExceptionType.ArgumentException: - return new ArgumentException(string.Format(res, arg)); - case ExceptionType.XmlException: - default: - return new XmlException(res, arg, lineNo, linePos); - } - } - - internal static Exception CreateException(string res, string[] args, ExceptionType exceptionType) - { - return CreateException(res, args, exceptionType, 0, 0); - } - - internal static Exception CreateException(string res, string[] args, ExceptionType exceptionType, int lineNo, int linePos) - { - switch (exceptionType) - { - case ExceptionType.ArgumentException: - return new ArgumentException(string.Format(res, args)); - case ExceptionType.XmlException: - default: - return new XmlException(res, args, lineNo, linePos); - } - } - - internal static Exception CreateInvalidSurrogatePairException(char low, char hi) - { - return CreateInvalidSurrogatePairException(low, hi, ExceptionType.ArgumentException); - } - - internal static Exception CreateInvalidSurrogatePairException(char low, char hi, ExceptionType exceptionType) - { - return CreateInvalidSurrogatePairException(low, hi, exceptionType, 0, 0); - } - - internal static Exception CreateInvalidSurrogatePairException(char low, char hi, ExceptionType exceptionType, int lineNo, int linePos) - { - string[] args = new string[] { - ((uint)hi).ToString( "X", CultureInfo.InvariantCulture ), - ((uint)low).ToString( "X", CultureInfo.InvariantCulture ) - }; - return CreateException(ResXml.Xml_InvalidSurrogatePairWithArgs, args, exceptionType, lineNo, linePos); - } - - internal static Exception CreateInvalidHighSurrogateCharException(char hi) - { - return CreateInvalidHighSurrogateCharException(hi, ExceptionType.ArgumentException); - } - - internal static Exception CreateInvalidHighSurrogateCharException(char hi, ExceptionType exceptionType) - { - return CreateInvalidHighSurrogateCharException(hi, exceptionType, 0, 0); - } - - internal static Exception CreateInvalidHighSurrogateCharException(char hi, ExceptionType exceptionType, int lineNo, int linePos) - { - return CreateException(ResXml.Xml_InvalidSurrogateHighChar, ((uint)hi).ToString("X", CultureInfo.InvariantCulture), exceptionType, lineNo, linePos); - } - - internal static Exception CreateInvalidCharException(char[] data, int length, int invCharPos) - { - return CreateInvalidCharException(data, length, invCharPos, ExceptionType.ArgumentException); - } - - internal static Exception CreateInvalidCharException(char[] data, int length, int invCharPos, ExceptionType exceptionType) - { - return CreateException(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(data, length, invCharPos), exceptionType, 0, invCharPos + 1); - } - - internal static Exception CreateInvalidCharException(string data, int invCharPos) - { - return CreateInvalidCharException(data, invCharPos, ExceptionType.ArgumentException); - } - - internal static Exception CreateInvalidCharException(string data, int invCharPos, ExceptionType exceptionType) - { - return CreateException(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(data, invCharPos), exceptionType, 0, invCharPos + 1); - } - - internal static Exception CreateInvalidCharException(char invChar, char nextChar) - { - return CreateInvalidCharException(invChar, nextChar, ExceptionType.ArgumentException); - } - - internal static Exception CreateInvalidCharException(char invChar, char nextChar, ExceptionType exceptionType) - { - return CreateException(ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(invChar, nextChar), exceptionType); - } - - internal static Exception CreateInvalidNameCharException(string name, int index, ExceptionType exceptionType) - { - return CreateException(index == 0 ? ResXml.Xml_BadStartNameChar : ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(name, index), exceptionType, 0, index + 1); - } - - internal static ArgumentException CreateInvalidNameArgumentException(string name, string argumentName) - { - return (name == null) ? new ArgumentNullException(argumentName) : new ArgumentException(ResXml.Xml_EmptyName, argumentName); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlEncoding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlEncoding.cs index 70a3ba23c6f..b8892eb6450 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlEncoding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlEncoding.cs @@ -5,7 +5,7 @@ using System.Text; using System.Diagnostics; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlException.cs index 0689b6a9e95..ee3124776b7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlException.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlException.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; using System.IO; @@ -271,4 +271,4 @@ e is NullReferenceException ); } }; -} // namespace Microsoft.Xml +} // namespace System.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNameTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNameTable.cs deleted file mode 100644 index df90f1721e0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNameTable.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - /// - /// - /// Table of atomized string objects. This provides an - /// efficient means for the XML parser to use the same string object for all - /// repeated element and attribute names in an XML document. This class is - /// - /// . - /// - public abstract class XmlNameTable - { - /// - /// - /// Gets the atomized String object containing the same - /// chars as the specified range of chars in the given char array. - /// - public abstract String Get(char[] array, int offset, int length); - - /// - /// - /// - /// Gets the atomized String object containing the same - /// value as the specified string. - /// - /// - public abstract String Get(String array); - - /// - /// - /// Creates a new atom for the characters at the specified range - /// of chararacters in the specified string. - /// - public abstract String Add(char[] array, int offset, int length); - - /// - /// - /// - /// Creates a new atom for the specified string. - /// - /// - public abstract String Add(String array); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceManager.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceManager.cs deleted file mode 100644 index cde8151c826..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceManager.cs +++ /dev/null @@ -1,373 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - using System.IO; - using System.Collections; - using System.Diagnostics; - using System.Collections.Generic; - - public class XmlNamespaceManager : IXmlNamespaceResolver, IEnumerable - { - private static volatile IXmlNamespaceResolver s_EmptyResolver; - - private struct NamespaceDeclaration - { - public string prefix; - public string uri; - public int scopeId; - public int previousNsIndex; - - public void Set(string prefix, string uri, int scopeId, int previousNsIndex) - { - this.prefix = prefix; - this.uri = uri; - this.scopeId = scopeId; - this.previousNsIndex = previousNsIndex; - } - } - - // array with namespace declarations - private NamespaceDeclaration[] _nsdecls; - - // index of last declaration - private int _lastDecl = 0; - - // name table - private XmlNameTable _nameTable; - - // ID (depth) of the current scope - private int _scopeId; - - // hash table for faster lookup when there is lots of namespaces - private Dictionary _hashTable; - private bool _useHashtable; - - // atomized prefixes for "xml" and "xmlns" - private string _xml; - private string _xmlNs; - - // Constants - private const int MinDeclsCountForHashtable = 16; - - internal static IXmlNamespaceResolver EmptyResolver - { - get - { - if (s_EmptyResolver == null) - { - // no locking; the empty resolver is immutable so it's not a problem that it may get initialized more than once - s_EmptyResolver = new XmlNamespaceManager(new NameTable()); - } - return s_EmptyResolver; - } - } - - internal XmlNamespaceManager() - { - } - - public XmlNamespaceManager(XmlNameTable nameTable) - { - _nameTable = nameTable; - _xml = nameTable.Add("xml"); - _xmlNs = nameTable.Add("xmlns"); - - _nsdecls = new NamespaceDeclaration[8]; - string emptyStr = nameTable.Add(string.Empty); - _nsdecls[0].Set(emptyStr, emptyStr, -1, -1); - _nsdecls[1].Set(_xmlNs, nameTable.Add(XmlReservedNs.NsXmlNs), -1, -1); - _nsdecls[2].Set(_xml, nameTable.Add(XmlReservedNs.NsXml), 0, -1); - _lastDecl = 2; - _scopeId = 1; - } - - public virtual XmlNameTable NameTable - { - get - { - return _nameTable; - } - } - - public virtual string DefaultNamespace - { - get - { - string defaultNs = LookupNamespace(string.Empty); - return (defaultNs == null) ? string.Empty : defaultNs; - } - } - - public virtual void PushScope() - { - _scopeId++; - } - - public virtual bool PopScope() - { - int decl = _lastDecl; - if (_scopeId == 1) - { - return false; - } - while (_nsdecls[decl].scopeId == _scopeId) - { - if (_useHashtable) - { - _hashTable[_nsdecls[decl].prefix] = _nsdecls[decl].previousNsIndex; - } - decl--; - Debug.Assert(decl >= 2); - } - _lastDecl = decl; - _scopeId--; - return true; - } - - public virtual void AddNamespace(string prefix, string uri) - { - if (uri == null) - throw new ArgumentNullException("uri"); - - if (prefix == null) - throw new ArgumentNullException("prefix"); - - prefix = _nameTable.Add(prefix); - uri = _nameTable.Add(uri); - - if ((Ref.Equal(_xml, prefix) && !uri.Equals(XmlReservedNs.NsXml))) - { - throw new ArgumentException(ResXml.Xml_XmlPrefix); - } - if (Ref.Equal(_xmlNs, prefix)) - { - throw new ArgumentException(ResXml.Xml_XmlnsPrefix); - } - - int declIndex = LookupNamespaceDecl(prefix); - int previousDeclIndex = -1; - if (declIndex != -1) - { - if (_nsdecls[declIndex].scopeId == _scopeId) - { - // redefine if in the same scope - _nsdecls[declIndex].uri = uri; - return; - } - else - { - // othewise link - previousDeclIndex = declIndex; - } - } - - // set new namespace declaration - if (_lastDecl == _nsdecls.Length - 1) - { - NamespaceDeclaration[] newNsdecls = new NamespaceDeclaration[_nsdecls.Length * 2]; - Array.Copy(_nsdecls, 0, newNsdecls, 0, _nsdecls.Length); - _nsdecls = newNsdecls; - } - - _nsdecls[++_lastDecl].Set(prefix, uri, _scopeId, previousDeclIndex); - - // add to hashTable - if (_useHashtable) - { - _hashTable[prefix] = _lastDecl; - } - // or create a new hashTable if the threashold has been reached - else if (_lastDecl >= MinDeclsCountForHashtable) - { - // add all to hash table - Debug.Assert(_hashTable == null); - _hashTable = new Dictionary(_lastDecl); - for (int i = 0; i <= _lastDecl; i++) - { - _hashTable[_nsdecls[i].prefix] = i; - } - _useHashtable = true; - } - } - - public virtual void RemoveNamespace(string prefix, string uri) - { - if (uri == null) - { - throw new ArgumentNullException("uri"); - } - if (prefix == null) - { - throw new ArgumentNullException("prefix"); - } - - int declIndex = LookupNamespaceDecl(prefix); - while (declIndex != -1) - { - if (String.Equals(_nsdecls[declIndex].uri, uri) && _nsdecls[declIndex].scopeId == _scopeId) - { - _nsdecls[declIndex].uri = null; - } - declIndex = _nsdecls[declIndex].previousNsIndex; - } - } - - public virtual IEnumerator GetEnumerator() - { - Dictionary prefixes = new Dictionary(_lastDecl + 1); - for (int thisDecl = 0; thisDecl <= _lastDecl; thisDecl++) - { - if (_nsdecls[thisDecl].uri != null) - { - prefixes[_nsdecls[thisDecl].prefix] = _nsdecls[thisDecl].prefix; - } - } - return prefixes.Keys.GetEnumerator(); - } - - // This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey. -#pragma warning disable 3002 - public virtual IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { -#pragma warning restore 3002 - int i = 0; - switch (scope) - { - case XmlNamespaceScope.All: - i = 2; - break; - case XmlNamespaceScope.ExcludeXml: - i = 3; - break; - case XmlNamespaceScope.Local: - i = _lastDecl; - while (_nsdecls[i].scopeId == _scopeId) - { - i--; - Debug.Assert(i >= 2); - } - i++; - break; - } - - Dictionary dict = new Dictionary(_lastDecl - i + 1); - for (; i <= _lastDecl; i++) - { - string prefix = _nsdecls[i].prefix; - string uri = _nsdecls[i].uri; - Debug.Assert(prefix != null); - - if (uri != null) - { - if (uri.Length > 0 || prefix.Length > 0 || scope == XmlNamespaceScope.Local) - { - dict[prefix] = uri; - } - else - { - // default namespace redeclared to "" -> remove from list for all scopes other than local - dict.Remove(prefix); - } - } - } - return dict; - } - - public virtual string LookupNamespace(string prefix) - { - int declIndex = LookupNamespaceDecl(prefix); - return (declIndex == -1) ? null : _nsdecls[declIndex].uri; - } - - private int LookupNamespaceDecl(string prefix) - { - if (_useHashtable) - { - int declIndex; - if (_hashTable.TryGetValue(prefix, out declIndex)) - { - while (declIndex != -1 && _nsdecls[declIndex].uri == null) - { - declIndex = _nsdecls[declIndex].previousNsIndex; - } - return declIndex; - } - return -1; - } - else - { - // First assume that prefix is atomized - for (int thisDecl = _lastDecl; thisDecl >= 0; thisDecl--) - { - if ((object)_nsdecls[thisDecl].prefix == (object)prefix && _nsdecls[thisDecl].uri != null) - { - return thisDecl; - } - } - - // Non-atomized lookup - for (int thisDecl = _lastDecl; thisDecl >= 0; thisDecl--) - { - if (String.Equals(_nsdecls[thisDecl].prefix, prefix) && _nsdecls[thisDecl].uri != null) - { - return thisDecl; - } - } - } - return -1; - } - - public virtual string LookupPrefix(string uri) - { - // Don't assume that prefix is atomized - for (int thisDecl = _lastDecl; thisDecl >= 0; thisDecl--) - { - if (String.Equals(_nsdecls[thisDecl].uri, uri)) - { - string prefix = _nsdecls[thisDecl].prefix; - if (String.Equals(LookupNamespace(prefix), uri)) - { - return prefix; - } - } - } - return null; - } - - public virtual bool HasNamespace(string prefix) - { - // Don't assume that prefix is atomized - for (int thisDecl = _lastDecl; _nsdecls[thisDecl].scopeId == _scopeId; thisDecl--) - { - if (String.Equals(_nsdecls[thisDecl].prefix, prefix) && _nsdecls[thisDecl].uri != null) - { - if (prefix.Length > 0 || _nsdecls[thisDecl].uri.Length > 0) - { - return true; - } - return false; - } - } - return false; - } - - internal bool GetNamespaceDeclaration(int idx, out string prefix, out string uri) - { - idx = _lastDecl - idx; - if (idx < 0) - { - prefix = uri = null; - return false; - } - - prefix = _nsdecls[idx].prefix; - uri = _nsdecls[idx].uri; - - return true; - } - } //XmlNamespaceManager -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceScope.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceScope.cs deleted file mode 100644 index eb3bc76ca28..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNamespaceScope.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - - /// - /// - /// [To be supplied.] - /// - public enum XmlNamespaceScope - { - /// - /// - /// [To be supplied.] - /// - All, - - /// - /// - /// [To be supplied.] - /// - ExcludeXml, - - /// - /// - /// [To be supplied.] - /// - Local, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeOrder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeOrder.cs index abf97035e13..31cb1ab1383 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeOrder.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeOrder.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeType.cs deleted file mode 100644 index d798c275396..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNodeType.cs +++ /dev/null @@ -1,223 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml -{ - using System; - - /// - /// - /// Specifies the type of node. - /// - public enum XmlNodeType - { - /// - /// - /// For XPathNavigator, cursor is not positioned - /// on a node. - /// - None, - /// - /// - /// - /// An Element. - /// - /// - /// Example XML: <Name> - /// - /// An Element node can have - /// the following child node types: Element, Text, Comment, ProcessingInstruction, - /// CDATA, and EntityReference. The Element node can be the child of the Document, - /// DocumentFragment, EntityReference, and Element nodes. - /// - Element, - /// - /// - /// - /// An - /// Attribute. - /// - /// - /// Example XML: id='123' - /// - /// - /// An Attribute node can have the following child node types: Text and - /// EntityReference. The Attribute node does not appear as the child node of any - /// other node type; note that it is not considered a child node of an Element. - /// - /// - Attribute, - /// - /// - /// - /// The - /// text content of an element. - /// - /// - /// A Text node cannot have any child nodes. The Text node can appear as the - /// child node of the Attribute, DocumentFragment, Element, and EntityReference - /// nodes. - /// - /// - Text, - /// - /// - /// A CDATA section. - /// Example XML: <![CDATA[my escaped text]]> - /// CDATA sections are used to escape blocks of text that would otherwise be - /// recognized as markup. A CDATASection node cannot have any child nodes. The - /// CDATASection node can appear as the child of the DocumentFragment, - /// EntityReference, and Element nodes. - /// - CDATA, - /// - /// - /// A reference to an entity. - /// Example XML: &foo; - /// This applies to all entities, including character entity references. An - /// EntityReference node can have the following child node types: Element, - /// ProcessingInstruction, Comment, Text, CDATASection, and EntityReference. The - /// EntityReference node can appear as the child of the Attribute, DocumentFragment, - /// Element, and EntityReference nodes. - /// - EntityReference, - /// - /// - /// An entity declaration. - /// Example XML: <!ENTITY ...> - /// An Entity node can have child nodes that represent the expanded entity (for - /// example, Text and EntityReference nodes). The Entity node can appear as the - /// child of the DocumentType node. - /// - Entity, - /// - /// - /// - /// A processing instruction (PI). - /// - /// - /// Example XML: <?pi test?> - /// - /// - /// A PI node cannot have any child nodes. The PI node can - /// appear as the child of the Document, DocumentFragment, Element, and - /// EntityReference nodes. - /// - /// - ProcessingInstruction, - /// - /// - /// - /// A Comment. - /// - /// - /// Example XML: <!-- my comment --> - /// - /// - /// A Comment node cannot have any child nodes. The Comment node can appear as - /// the child of the Document, DocumentFragment, Element, and EntityReference - /// nodes. - /// - /// - Comment, - /// - /// - /// - /// A document object, which, as the root of the document tree, provides access - /// to the entire XML document. - /// - /// - /// A Document node can have the following child node types: Element (maximum of - /// one), ProcessingInstruction, Comment, and DocumentType. The Document node cannot - /// appear as the child of any node types. - /// - /// - Document, - /// - /// - /// - /// The document type declaration, indicated by the <!DOCTYPE> tag. - /// - /// - /// Example XML: <!DOCTYPE ...> - /// - /// - /// A DocumentType node can have the following child node types: Notation and - /// Entity. The DocumentType node can appear as the child of the Document node. - /// - /// - DocumentType, - /// - /// - /// - /// A document fragment. - /// - /// - /// The DocumentFragment node associates a node or subtree with a document - /// without actually being contained within the document. A DocumentFragment node - /// can have the following child node types: Element, ProcessingInstruction, - /// Comment, Text, CDATASection, and EntityReference. The DocumentFragment node - /// cannot appear as the child of any node types. - /// - /// - DocumentFragment, - /// - /// - /// - /// A notation in the document type declaration. - /// - /// - /// Example XML: <!NOTATION ...> - /// - /// - /// A Notation node cannot have any child nodes. The Notation node can appear as - /// the child of the DocumentType node. - /// - /// - Notation, - /// - /// - /// - /// Whitespace between markup. - /// - /// - Whitespace, - /// - /// - /// - /// Whitespace between markup in a mixed content model. - /// - /// - SignificantWhitespace, - /// - /// - /// Returned when XmlReader gets to the end of an element. - /// Example XML: </foo> - /// - EndElement, - /// - /// - /// Returned when XmlReader gets to the end of the entity - /// replacement as a result of a call to - /// . - /// - EndEntity, - /// - /// - /// - /// The XML declaration node.. - /// - /// - /// Example XML: <?xml version='1.0'?>; - /// - /// - /// This has to be the first node in the document. It can have no children. - /// It is a child of the root node. It can have attributes that provide version - /// and encoding information. - /// - /// - XmlDeclaration - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNullResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNullResolver.cs index 1f9db3b7889..cf95c13a9ed 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNullResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlNullResolver.cs @@ -4,7 +4,7 @@ using System.Net; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlQualifiedName.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlQualifiedName.cs deleted file mode 100644 index ebdad4116f4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlQualifiedName.cs +++ /dev/null @@ -1,246 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - using System; - - using System.Collections; - using System.Diagnostics; - using Microsoft.Win32; - using System.Reflection; - using System.Security; - // using System.Security.Permissions; - - /// - /// - /// [To be supplied.] - /// - // [Serializable], - public class XmlQualifiedName - { - private delegate int HashCodeOfStringDelegate(string s, int sLen, long additionalEntropy); - private static HashCodeOfStringDelegate s_hashCodeDelegate = null; - private string _name; - private string _ns; - - [NonSerialized] - private Int32 _hash; - - /// - /// - /// [To be supplied.] - /// - public static readonly XmlQualifiedName Empty = new XmlQualifiedName(string.Empty); - - /// - /// - /// [To be supplied.] - /// - public XmlQualifiedName() : this(string.Empty, string.Empty) { } - - /// - /// - /// [To be supplied.] - /// - public XmlQualifiedName(string name) : this(name, string.Empty) { } - - /// - /// - /// [To be supplied.] - /// - public XmlQualifiedName(string name, string ns) - { - _ns = ns == null ? string.Empty : ns; - _name = name == null ? string.Empty : name; - } - - /// - /// - /// [To be supplied.] - /// - public string Namespace - { - get { return _ns; } - } - - /// - /// - /// [To be supplied.] - /// - public string Name - { - get { return _name; } - } - - /// - /// - /// [To be supplied.] - /// - public override int GetHashCode() - { - if (_hash == 0) - { - _hash = SecureStringHasher.Instance.GetHashCode(Name); - } - - return _hash; - } - - /// - /// - /// [To be supplied.] - /// - public bool IsEmpty - { - get { return Name.Length == 0 && Namespace.Length == 0; } - } - - /// - /// - /// [To be supplied.] - /// - public override string ToString() - { - return Namespace.Length == 0 ? Name : string.Concat(Namespace, ":", Name); - } - - /// - /// - /// [To be supplied.] - /// - public override bool Equals(object other) - { - XmlQualifiedName qname; - - if ((object)this == other) - { - return true; - } - - qname = other as XmlQualifiedName; - if (qname != null) - { - return (Name == qname.Name && Namespace == qname.Namespace); - } - return false; - } - - /// - /// - /// [To be supplied.] - /// - public static bool operator ==(XmlQualifiedName a, XmlQualifiedName b) - { - if ((object)a == (object)b) - return true; - - if ((object)a == null || (object)b == null) - return false; - - return (a.Name == b.Name && a.Namespace == b.Namespace); - } - - /// - /// - /// [To be supplied.] - /// - public static bool operator !=(XmlQualifiedName a, XmlQualifiedName b) - { - return !(a == b); - } - - /// - /// - /// [To be supplied.] - /// - public static string ToString(string name, string ns) - { - return ns == null || ns.Length == 0 ? name : ns + ":" + name; - } - - [SecuritySafeCritical] - // [ReflectionPermission(SecurityAction.Assert, Unrestricted = true)] - - private static int GetHashCodeOfString(string s, int length, long additionalEntropy) - { - // This is the fallback method for calling the regular hashcode method - return s.GetHashCode(); - } - - // --------- Some useful internal stuff ----------------- - internal void Init(string name, string ns) - { - Debug.Assert(name != null && ns != null); - _name = name; - _ns = ns; - _hash = 0; - } - - internal void SetNamespace(string ns) - { - Debug.Assert(ns != null); - _ns = ns; //Not changing hash since ns is not used to compute hashcode - } - - internal void Verify() - { - XmlConvert.VerifyNCName(_name); - if (_ns.Length != 0) - { - XmlConvert.ToUri(_ns); - } - } - - internal void Atomize(XmlNameTable nameTable) - { - Debug.Assert(_name != null); - _name = nameTable.Add(_name); - _ns = nameTable.Add(_ns); - } - - internal static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix) - { - string localName; - ValidateNames.ParseQNameThrow(s, out prefix, out localName); - - string uri = nsmgr.LookupNamespace(prefix); - if (uri == null) - { - if (prefix.Length != 0) - { - throw new XmlException(ResXml.Xml_UnknownNs, prefix); - } - else - { //Re-map namespace of empty prefix to string.Empty when there is no default namespace declared - uri = string.Empty; - } - } - return new XmlQualifiedName(localName, uri); - } - - internal XmlQualifiedName Clone() - { - return (XmlQualifiedName)MemberwiseClone(); - } - - internal static int Compare(XmlQualifiedName a, XmlQualifiedName b) - { - if (null == a) - { - return (null == b) ? 0 : -1; - } - if (null == b) - { - return 1; - } - int i = String.CompareOrdinal(a.Namespace, b.Namespace); - if (i == 0) - { - i = String.CompareOrdinal(a.Name, b.Name); - } - return i; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlReservedNS.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlReservedNS.cs index 1a8f16b6b0b..98304856a4b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlReservedNS.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlReservedNS.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolver.cs index b2fd7b45e99..08567d231c7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolver.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { using System; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolverAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolverAsync.cs index 905e6f20a5c..269d2e9480c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolverAsync.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlResolverAsync.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlUrlResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlUrlResolver.cs index 42a58bb1cd9..b4fc6b80b5b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlUrlResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlUrlResolver.cs @@ -8,7 +8,7 @@ //using System.Net.Cache; using System.Runtime.Versioning; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlXapResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlXapResolver.cs index e9356a573b9..b668af92162 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlXapResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/XmlXapResolver.cs @@ -6,7 +6,7 @@ using System.IO; using System.ComponentModel; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltArgumentList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltArgumentList.cs deleted file mode 100644 index 0d8c7a54c65..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltArgumentList.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -// using System.Security.Permissions; - -namespace Microsoft.Xml.Xsl -{ - using System; - using Microsoft.Xml; - - - public abstract class XsltMessageEncounteredEventArgs : EventArgs - { - public abstract string Message { get; } - } - - public delegate void XsltMessageEncounteredEventHandler(object sender, XsltMessageEncounteredEventArgs e); - - public class XsltArgumentList - { - private Hashtable _parameters = new Hashtable(); - private Hashtable _extensions = new Hashtable(); - - // Used for reporting xsl:message's during execution - internal XsltMessageEncounteredEventHandler xsltMessageEncountered = null; - - public XsltArgumentList() { } - - public object GetParam(string name, string namespaceUri) - { - return _parameters[new XmlQualifiedName(name, namespaceUri)]; - } - - public object GetExtensionObject(string namespaceUri) - { - return _extensions[namespaceUri]; - } - - public void AddParam(string name, string namespaceUri, object parameter) - { - CheckArgumentNull(name, "name"); - CheckArgumentNull(namespaceUri, "namespaceUri"); - CheckArgumentNull(parameter, "parameter"); - - XmlQualifiedName qname = new XmlQualifiedName(name, namespaceUri); - qname.Verify(); - _parameters.Add(qname, parameter); - } - - public void AddExtensionObject(string namespaceUri, object extension) - { - CheckArgumentNull(namespaceUri, "namespaceUri"); - CheckArgumentNull(extension, "extension"); - _extensions.Add(namespaceUri, extension); - } - - public object RemoveParam(string name, string namespaceUri) - { - XmlQualifiedName qname = new XmlQualifiedName(name, namespaceUri); - object parameter = _parameters[qname]; - _parameters.Remove(qname); - return parameter; - } - - public object RemoveExtensionObject(string namespaceUri) - { - object extension = _extensions[namespaceUri]; - _extensions.Remove(namespaceUri); - return extension; - } - - public event XsltMessageEncounteredEventHandler XsltMessageEncountered - { - add - { - xsltMessageEncountered += value; - } - remove - { - xsltMessageEncountered -= value; - } - } - - public void Clear() - { - _parameters.Clear(); - _extensions.Clear(); - xsltMessageEncountered = null; - } - - private static void CheckArgumentNull(object param, string paramName) - { - if (param == null) - { - throw new ArgumentNullException(paramName); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltCommand.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltCommand.cs deleted file mode 100644 index 2b95bfb1cdd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltCommand.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; -// using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Reflection; -using System.Security; -// using System.Security.Permissions; -using Microsoft.Xml.XPath; -// using Microsoft.Xml.Xsl.Runtime; - -namespace Microsoft.Xml.Xsl -{ - using System; - using Microsoft.Xml; - - /// - /// Helper class implementing multiple overloads - /// - public abstract class XsltCommand - { - private static XmlReaderSettings s_readerSettings; - - static XsltCommand() - { - s_readerSettings = new XmlReaderSettings(); - s_readerSettings.DtdProcessing = DtdProcessing.Prohibit; - s_readerSettings.ReadOnly = true; - } - - /// - /// Writer settings specified in the stylesheet - /// - public abstract XmlWriterSettings OutputSettings { get; } - - //------------------------------------------------ - // Transform methods which take an IXPathNavigable - //------------------------------------------------ - - public void Transform(IXPathNavigable input, XmlWriter results) - { - CheckArguments(input, results); - Transform(input, (XsltArgumentList)null, results, new XmlUrlResolver()); - } - - public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results) - { - CheckArguments(input, results); - Transform(input, arguments, results, new XmlUrlResolver()); - } - - public void Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) - { - CheckArguments(input, results); - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(input, arguments, writer, new XmlUrlResolver()); - } - } - - public void Transform(IXPathNavigable input, XsltArgumentList arguments, Stream results) - { - CheckArguments(input, results); - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(input, arguments, writer, new XmlUrlResolver()); - } - } - - //------------------------------------------------ - // Transform methods which take an XmlReader - //------------------------------------------------ - - public void Transform(XmlReader input, XmlWriter results) - { - CheckArguments(input, results); - Transform(input, (XsltArgumentList)null, results, new XmlUrlResolver()); - } - - public void Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results) - { - CheckArguments(input, results); - Transform(input, arguments, results, new XmlUrlResolver()); - } - - public void Transform(XmlReader input, XsltArgumentList arguments, TextWriter results) - { - CheckArguments(input, results); - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(input, arguments, writer, new XmlUrlResolver()); - } - } - - public void Transform(XmlReader input, XsltArgumentList arguments, Stream results) - { - CheckArguments(input, results); - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(input, arguments, writer, new XmlUrlResolver()); - } - } - - //------------------------------------------------ - // Transform methods which take a uri - //------------------------------------------------ - - // [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void Transform(string inputUri, XmlWriter results) - { - CheckArguments(inputUri, results); - using (XmlReader reader = XmlReader.Create(inputUri, s_readerSettings)) - { - Transform(reader, (XsltArgumentList)null, results, new XmlUrlResolver()); - } - } - - // [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void Transform(string inputUri, XsltArgumentList arguments, XmlWriter results) - { - CheckArguments(inputUri, results); - using (XmlReader reader = XmlReader.Create(inputUri, s_readerSettings)) - { - Transform(reader, arguments, results, new XmlUrlResolver()); - } - } - - // [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void Transform(string inputUri, XsltArgumentList arguments, TextWriter results) - { - CheckArguments(inputUri, results); - using (XmlReader reader = XmlReader.Create(inputUri, s_readerSettings)) - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(reader, arguments, writer, new XmlUrlResolver()); - } - } - - // [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void Transform(string inputUri, XsltArgumentList arguments, Stream results) - { - CheckArguments(inputUri, results); - using (XmlReader reader = XmlReader.Create(inputUri, s_readerSettings)) - using (XmlWriter writer = XmlWriter.Create(results, OutputSettings)) - { - Transform(reader, arguments, writer, new XmlUrlResolver()); - } - } - - // [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void Transform(string inputUri, string resultsFile) - { - if (inputUri == null) - throw new ArgumentNullException("inputUri"); - - if (resultsFile == null) - throw new ArgumentNullException("resultsFile"); - - // SQLBUDT 276415: Prevent wiping out the content of the input file if the output file is the same - using (XmlReader reader = XmlReader.Create(inputUri, s_readerSettings)) - using (XmlWriter writer = XmlWriter.Create(resultsFile, OutputSettings)) - { - Transform(reader, (XsltArgumentList)null, writer, new XmlUrlResolver()); - } - } - - //------------------------------------------------ - // Main Transform overloads - //------------------------------------------------ - - public abstract void Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver); - - public abstract void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver); - - //------------------------------------------------ - // Helper methods - //------------------------------------------------ - - private static void CheckArguments(object input, object results) - { - if (input == null) - throw new ArgumentNullException("input"); - - if (results == null) - throw new ArgumentNullException("results"); - } - - private static void CheckArguments(string inputUri, object results) - { - if (inputUri == null) - throw new ArgumentNullException("inputUri"); - - if (results == null) - throw new ArgumentNullException("results"); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltContext.cs deleted file mode 100644 index 7c715465bf8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltContext.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using Microsoft.Xml.XPath; - -namespace Microsoft.Xml.Xsl -{ - using System; - using Microsoft.Xml; - - public interface IXsltContextFunction - { - int Minargs { get; } - int Maxargs { get; } - XPathResultType ReturnType { get; } - XPathResultType[] ArgTypes { get; } - object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext); - } - - public interface IXsltContextVariable - { - bool IsLocal { get; } - bool IsParam { get; } - XPathResultType VariableType { get; } - object Evaluate(XsltContext xsltContext); - } - - public abstract class XsltContext : XmlNamespaceManager - { - protected XsltContext(NameTable table) : base(table) { } - protected XsltContext() : base(new NameTable()) { } - // This dummy XsltContext that doesn't actualy initialize XmlNamespaceManager - // is used by XsltCompileContext - internal XsltContext(bool dummy) : base() { } - public abstract IXsltContextVariable ResolveVariable(string prefix, string name); - public abstract IXsltContextFunction ResolveFunction(string prefix, string name, XPathResultType[] ArgTypes); - public abstract bool Whitespace { get; } - public abstract bool PreserveWhitespace(XPathNavigator node); - public abstract int CompareDocument(string baseUri, string nextbaseUri); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltSettings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltSettings.cs deleted file mode 100644 index 71ecc9d091e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Xslt/XsltSettings.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.CodeDom.Compiler; - -namespace Microsoft.Xml.Xsl -{ - using System; - using Microsoft.Xml; - - public sealed class XsltSettings - { - private bool _enableDocumentFunction; - private bool _enableScript; - private bool _checkOnly; - private bool _includeDebugInformation; - private int _warningLevel = -1; // -1 means not set - private bool _treatWarningsAsErrors; - private TempFileCollection _tempFiles; - - public XsltSettings() { } - - public XsltSettings(bool enableDocumentFunction, bool enableScript) - { - _enableDocumentFunction = enableDocumentFunction; - _enableScript = enableScript; - } - - public static XsltSettings Default - { - get { return new XsltSettings(false, false); } - } - - public static XsltSettings TrustedXslt - { - get { return new XsltSettings(true, true); } - } - - public bool EnableDocumentFunction - { - get { return _enableDocumentFunction; } - set { _enableDocumentFunction = value; } - } - - public bool EnableScript - { - get { return _enableScript; } - set { _enableScript = value; } - } - - internal bool CheckOnly - { - get { return _checkOnly; } - set { _checkOnly = value; } - } - - internal bool IncludeDebugInformation - { - get { return _includeDebugInformation; } - set { _includeDebugInformation = value; } - } - - internal int WarningLevel - { - get { return _warningLevel; } - set { _warningLevel = value; } - } - - internal bool TreatWarningsAsErrors - { - get { return _treatWarningsAsErrors; } - set { _treatWarningsAsErrors = value; } - } - - internal TempFileCollection TempFiles - { - get { return _tempFiles; } - set { _tempFiles = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/AstTree.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/AstTree.cs deleted file mode 100644 index 2004f12853b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/AstTree.cs +++ /dev/null @@ -1,733 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - using Microsoft.Xml.XPath; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Collections; - using Microsoft.Xml.Schema; - using MS.Internal.Xml.XPath; - - /*--------------------------------------------------------------------------------------------- * - * Dynamic Part Below... * - * -------------------------------------------------------------------------------------------- */ - - // stack element class - // this one needn't change, even the parameter in methods - internal class AxisElement - { - internal DoubleLinkAxis curNode; // current under-checking node during navigating - internal int rootDepth; // root depth -- contextDepth + 1 if ! isDss; context + {1...} if isDss - internal int curDepth; // current depth - internal bool isMatch; // current is already matching or waiting for matching - - internal DoubleLinkAxis CurNode - { - get { return this.curNode; } - } - - // constructor - internal AxisElement(DoubleLinkAxis node, int depth) - { - this.curNode = node; - this.rootDepth = this.curDepth = depth; - this.isMatch = false; - } - - internal void SetDepth(int depth) - { - this.rootDepth = this.curDepth = depth; - return; - } - - // "a/b/c" pointer from b move to a - // needn't change even tree structure changes - internal void MoveToParent(int depth, ForwardAxis parent) - { - // "a/b/c", trying to match b (current node), but meet the end of a, so move pointer to a - if (depth == this.curDepth - 1) - { - // really need to move the current node pointer to parent - // what i did here is for seperating the case of IsDss or only IsChild - // bcoz in the first case i need to expect "a" from random depth - // -1 means it doesn't expect some specific depth (referecing the dealing to -1 in movetochild method - // while in the second case i can't change the root depth which is 1. - if ((this.curNode.Input == parent.RootNode) && (parent.IsDss)) - { - this.curNode = parent.RootNode; - this.rootDepth = this.curDepth = -1; - return; - } - else if (this.curNode.Input != null) - { // else cur-depth --, cur-node change - this.curNode = (DoubleLinkAxis)(this.curNode.Input); - this.curDepth--; - return; - } - else return; - } - // "a/b/c", trying to match b (current node), but meet the end of x (another child of a) - // or maybe i matched, now move out the current node - // or move out after failing to match attribute - // the node i m next expecting is still the current node - else if (depth == this.curDepth) - { // after matched or [2] failed in matching attribute - if (this.isMatch) - { - this.isMatch = false; - } - } - return; // this node is still what i am expecting - // ignore - } - - // equal & ! attribute then move - // "a/b/c" pointer from a move to b - // return true if reach c and c is an element and c is the axis - internal bool MoveToChild(string name, string URN, int depth, ForwardAxis parent) - { - // an attribute can never be the same as an element - if (Asttree.IsAttribute(this.curNode)) - { - return false; - } - - // either moveToParent or moveToChild status will have to be changed into unmatch... - if (this.isMatch) - { - this.isMatch = false; - } - if (!AxisStack.Equal(this.curNode.Name, this.curNode.Urn, name, URN)) - { - return false; - } - if (this.curDepth == -1) - { - SetDepth(depth); - } - else if (depth > this.curDepth) - { - return false; - } - // matched ... - if (this.curNode == parent.TopNode) - { - this.isMatch = true; - return true; - } - // move down this.curNode - DoubleLinkAxis nowNode = (DoubleLinkAxis)(this.curNode.Next); - if (Asttree.IsAttribute(nowNode)) - { - this.isMatch = true; // for attribute - return false; - } - this.curNode = nowNode; - this.curDepth++; - return false; - } - } - - internal class AxisStack - { - // property - private ArrayList _stack; // of AxisElement - private ForwardAxis _subtree; // reference to the corresponding subtree - private ActiveAxis _parent; - - internal ForwardAxis Subtree - { - get { return _subtree; } - } - - internal int Length - { // stack length - get { return _stack.Count; } - } - - // instructor - public AxisStack(ForwardAxis faxis, ActiveAxis parent) - { - _subtree = faxis; - _stack = new ArrayList(); - _parent = parent; // need to use its contextdepth each time.... - - // improvement: - // if ! isDss, there has nothing to do with Push/Pop, only one copy each time will be kept - // if isDss, push and pop each time.... - if (!faxis.IsDss) - { // keep an instance - this.Push(1); // context depth + 1 - } - // else just keep stack empty - } - - // method - internal void Push(int depth) - { - AxisElement eaxis = new AxisElement(_subtree.RootNode, depth); - _stack.Add(eaxis); - } - - internal void Pop() - { - _stack.RemoveAt(Length - 1); - } - - // used in the beginning of .// and MoveToChild - // didn't consider Self, only consider name - internal static bool Equal(string thisname, string thisURN, string name, string URN) - { - // which means "b" in xpath, no namespace should be specified - if (thisURN == null) - { - if (!((URN == null) || (URN.Length == 0))) - { - return false; - } - } - // != "*" - else if ((thisURN.Length != 0) && (thisURN != URN)) - { - return false; - } - // != "a:*" || "*" - if ((thisname.Length != 0) && (thisname != name)) - { - return false; - } - return true; - } - - // "a/b/c" pointer from b move to a - // needn't change even tree structure changes - internal void MoveToParent(string name, string URN, int depth) - { - if (_subtree.IsSelfAxis) - { - return; - } - - for (int i = 0; i < _stack.Count; ++i) - { - ((AxisElement)_stack[i]).MoveToParent(depth, _subtree); - } - - // in ".//"'s case, since each time you push one new element while match, why not pop one too while match? - if (_subtree.IsDss && Equal(_subtree.RootNode.Name, _subtree.RootNode.Urn, name, URN)) - { - Pop(); - } // only the last one - } - - // "a/b/c" pointer from a move to b - // return true if reach c - internal bool MoveToChild(string name, string URN, int depth) - { - bool result = false; - // push first - if (_subtree.IsDss && Equal(_subtree.RootNode.Name, _subtree.RootNode.Urn, name, URN)) - { - Push(-1); - } - for (int i = 0; i < _stack.Count; ++i) - { - if (((AxisElement)_stack[i]).MoveToChild(name, URN, depth, _subtree)) - { - result = true; - } - } - return result; - } - - // attribute can only at the topaxis part - // dealing with attribute only here, didn't go into stack element at all - // stack element only deal with moving the pointer around elements - internal bool MoveToAttribute(string name, string URN, int depth) - { - if (!_subtree.IsAttribute) - { - return false; - } - if (!Equal(_subtree.TopNode.Name, _subtree.TopNode.Urn, name, URN)) - { - return false; - } - - bool result = false; - - // no stack element for single attribute, so dealing with it seperately - if (_subtree.TopNode.Input == null) - { - return (_subtree.IsDss || (depth == 1)); - } - - for (int i = 0; i < _stack.Count; ++i) - { - AxisElement eaxis = (AxisElement)_stack[i]; - if ((eaxis.isMatch) && (eaxis.CurNode == _subtree.TopNode.Input)) - { - result = true; - } - } - return result; - } - } - - // whenever an element is under identity-constraint, an instance of this class will be called - // only care about property at this time - internal class ActiveAxis - { - // consider about reactivating.... the stack should be clear right?? - // just reset contextDepth & isActive.... - private int _currentDepth; // current depth, trace the depth by myself... movetochild, movetoparent, movetoattribute - private bool _isActive; // not active any more after moving out context node - private Asttree _axisTree; // reference to the whole tree - // for each subtree i need to keep a stack... - private ArrayList _axisStack; // of AxisStack - - public int CurrentDepth - { - get { return _currentDepth; } - } - - // if an instance is !IsActive, then it can be reactive and reuse - // still need thinking..... - internal void Reactivate() - { - _isActive = true; - _currentDepth = -1; - } - - internal ActiveAxis(Asttree axisTree) - { - _axisTree = axisTree; // only a pointer. do i need it? - _currentDepth = -1; // context depth is 0 -- enforce moveToChild for the context node - // otherwise can't deal with "." node - _axisStack = new ArrayList(axisTree.SubtreeArray.Count); // defined length - // new one stack element for each one - for (int i = 0; i < axisTree.SubtreeArray.Count; ++i) - { - AxisStack stack = new AxisStack((ForwardAxis)axisTree.SubtreeArray[i], this); - _axisStack.Add(stack); - } - _isActive = true; - } - - public bool MoveToStartElement(string localname, string URN) - { - if (!_isActive) - { - return false; - } - - // for each: - _currentDepth++; - bool result = false; - for (int i = 0; i < _axisStack.Count; ++i) - { - AxisStack stack = (AxisStack)_axisStack[i]; - // special case for self tree "." | ".//." - if (stack.Subtree.IsSelfAxis) - { - if (stack.Subtree.IsDss || (this.CurrentDepth == 0)) - result = true; - continue; - } - - // otherwise if it's context node then return false - if (this.CurrentDepth == 0) continue; - - if (stack.MoveToChild(localname, URN, _currentDepth)) - { - result = true; - // even already know the last result is true, still need to continue... - // run everyone once - } - } - return result; - } - - // return result doesn't have any meaning until in SelectorActiveAxis - public virtual bool EndElement(string localname, string URN) - { - // need to think if the early quitting will affect reactivating.... - if (_currentDepth == 0) - { // leave context node - _isActive = false; - _currentDepth--; - } - if (!_isActive) - { - return false; - } - for (int i = 0; i < _axisStack.Count; ++i) - { - ((AxisStack)_axisStack[i]).MoveToParent(localname, URN, _currentDepth); - } - _currentDepth--; - return false; - } - - // Secondly field interface - public bool MoveToAttribute(string localname, string URN) - { - if (!_isActive) - { - return false; - } - bool result = false; - for (int i = 0; i < _axisStack.Count; ++i) - { - if (((AxisStack)_axisStack[i]).MoveToAttribute(localname, URN, _currentDepth + 1)) - { // don't change depth for attribute, but depth is add 1 - result = true; - } - } - return result; - } - } - - /* ---------------------------------------------------------------------------------------------- * - * Static Part Below... * - * ---------------------------------------------------------------------------------------------- */ - - // each node in the xpath tree - internal class DoubleLinkAxis : Axis - { - internal Axis next; - - internal Axis Next - { - get { return this.next; } - set { this.next = value; } - } - - //constructor - internal DoubleLinkAxis(Axis axis, DoubleLinkAxis inputaxis) - : base(axis.TypeOfAxis, inputaxis, axis.Prefix, axis.Name, axis.NodeType) - { - this.next = null; - this.Urn = axis.Urn; - this.abbrAxis = axis.AbbrAxis; - if (inputaxis != null) - { - inputaxis.Next = this; - } - } - - // recursive here - internal static DoubleLinkAxis ConvertTree(Axis axis) - { - if (axis == null) - { - return null; - } - return (new DoubleLinkAxis(axis, ConvertTree((Axis)(axis.Input)))); - } - } - - - - // only keep axis, rootNode, isAttribute, isDss inside - // act as an element tree for the Asttree - internal class ForwardAxis - { - // Axis tree - private DoubleLinkAxis _topNode; - private DoubleLinkAxis _rootNode; // the root for reverse Axis - - // Axis tree property - private bool _isAttribute; // element or attribute? "@"? - private bool _isDss; // has ".//" in front of it? - private bool _isSelfAxis; // only one node in the tree, and it's "." (self) node - - internal DoubleLinkAxis RootNode - { - get { return _rootNode; } - } - - internal DoubleLinkAxis TopNode - { - get { return _topNode; } - } - - internal bool IsAttribute - { - get { return _isAttribute; } - } - - // has ".//" in front of it? - internal bool IsDss - { - get { return _isDss; } - } - - internal bool IsSelfAxis - { - get { return _isSelfAxis; } - } - - public ForwardAxis(DoubleLinkAxis axis, bool isdesorself) - { - _isDss = isdesorself; - _isAttribute = Asttree.IsAttribute(axis); - _topNode = axis; - _rootNode = axis; - while (_rootNode.Input != null) - { - _rootNode = (DoubleLinkAxis)(_rootNode.Input); - } - // better to calculate it out, since it's used so often, and if the top is self then the whole tree is self - _isSelfAxis = Asttree.IsSelf(_topNode); - } - } - - // static, including an array of ForwardAxis (this is the whole picture) - internal class Asttree - { - // set private then give out only get access, to keep it intact all along - private ArrayList _fAxisArray; - private string _xpathexpr; - private bool _isField; // field or selector - private XmlNamespaceManager _nsmgr; - - internal ArrayList SubtreeArray - { - get { return _fAxisArray; } - } - - // when making a new instance for Asttree, we do the compiling, and create the static tree instance - public Asttree(string xPath, bool isField, XmlNamespaceManager nsmgr) - { - _xpathexpr = xPath; - _isField = isField; - _nsmgr = nsmgr; - // checking grammar... and build fAxisArray - this.CompileXPath(xPath, isField, nsmgr); // might throw exception in the middle - } - - // only for debug -#if DEBUG - public void PrintTree(StreamWriter msw) - { - for (int i = 0; i < _fAxisArray.Count; ++i) - { - ForwardAxis axis = (ForwardAxis)_fAxisArray[i]; - msw.WriteLine("", axis.IsDss, axis.IsAttribute); - DoubleLinkAxis printaxis = axis.TopNode; - while (printaxis != null) - { - msw.WriteLine(" "); - msw.WriteLine(" {0} ", printaxis.Urn); - msw.WriteLine(" {0} ", printaxis.Prefix); - msw.WriteLine(" {0} ", printaxis.Name); - msw.WriteLine(" {0} ", printaxis.NodeType); - msw.WriteLine(" {0} ", printaxis.TypeOfAxis); - msw.WriteLine(" "); - printaxis = (DoubleLinkAxis)(printaxis.Input); - } - msw.WriteLine(""); - } - } -#endif - - // this part is for parsing restricted xpath from grammar - private static bool IsNameTest(Axis ast) - { - // Type = Element, abbrAxis = false - // all are the same, has child:: or not - return ((ast.TypeOfAxis == Axis.AxisType.Child) && (ast.NodeType == XPathNodeType.Element)); - } - - internal static bool IsAttribute(Axis ast) - { - return ((ast.TypeOfAxis == Axis.AxisType.Attribute) && (ast.NodeType == XPathNodeType.Attribute)); - } - - private static bool IsDescendantOrSelf(Axis ast) - { - return ((ast.TypeOfAxis == Axis.AxisType.DescendantOrSelf) && (ast.NodeType == XPathNodeType.All) && (ast.AbbrAxis)); - } - - internal static bool IsSelf(Axis ast) - { - return ((ast.TypeOfAxis == Axis.AxisType.Self) && (ast.NodeType == XPathNodeType.All) && (ast.AbbrAxis)); - } - - // don't return true or false, if it's invalid path, just throw exception during the process - // for whitespace thing, i will directly trim the tree built here... - public void CompileXPath(string xPath, bool isField, XmlNamespaceManager nsmgr) - { - if ((xPath == null) || (xPath.Length == 0)) - { - throw new XmlSchemaException(ResXml.Sch_EmptyXPath, string.Empty); - } - - // firstly i still need to have an ArrayList to store tree only... - // can't new ForwardAxis right away - string[] xpath = xPath.Split('|'); - ArrayList AstArray = new ArrayList(xpath.Length); - _fAxisArray = new ArrayList(xpath.Length); - - // throw compile exceptions - // can i only new one builder here then run compile several times?? - try - { - for (int i = 0; i < xpath.Length; ++i) - { - // default ! isdesorself (no .//) - Axis ast = (Axis)(XPathParser.ParseXPathExpresion(xpath[i])); - AstArray.Add(ast); - } - } - catch - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - - Axis stepAst; - for (int i = 0; i < AstArray.Count; ++i) - { - Axis ast = (Axis)AstArray[i]; - // Restricted form - // field can have an attribute: - - // throw exceptions during casting - if ((stepAst = ast) == null) - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - - Axis top = stepAst; - - // attribute will have namespace too - // field can have top attribute - if (IsAttribute(stepAst)) - { - if (!isField) - { - throw new XmlSchemaException(ResXml.Sch_SelectorAttr, xPath); - } - else - { - SetURN(stepAst, nsmgr); - try - { - stepAst = (Axis)(stepAst.Input); - } - catch - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - } - } - - // field or selector - while ((stepAst != null) && (IsNameTest(stepAst) || IsSelf(stepAst))) - { - // trim tree "." node, if it's not the top one - if (IsSelf(stepAst) && (ast != stepAst)) - { - top.Input = stepAst.Input; - } - else - { - top = stepAst; - // set the URN - if (IsNameTest(stepAst)) - { - SetURN(stepAst, nsmgr); - } - } - try - { - stepAst = (Axis)(stepAst.Input); - } - catch - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - } - - // the rest part can only be .// or null - // trim the rest part, but need compile the rest part first - top.Input = null; - if (stepAst == null) - { // top "." and has other element beneath, trim this "." node too - if (IsSelf(ast) && (ast.Input != null)) - { - _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), false)); - } - else - { - _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), false)); - } - continue; - } - if (!IsDescendantOrSelf(stepAst)) - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - try - { - stepAst = (Axis)(stepAst.Input); - } - catch - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - if ((stepAst == null) || (!IsSelf(stepAst)) || (stepAst.Input != null)) - { - throw new XmlSchemaException(ResXml.Sch_ICXpathError, xPath); - } - - // trim top "." if it's not the only node - if (IsSelf(ast) && (ast.Input != null)) - { - _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree((Axis)(ast.Input)), true)); - } - else - { - _fAxisArray.Add(new ForwardAxis(DoubleLinkAxis.ConvertTree(ast), true)); - } - } - } - - // depending on axis.Name & axis.Prefix, i will set the axis.URN; - // also, record urn from prefix during this - // 4 different types of element or attribute (with @ before it) combinations: - // (1) a:b (2) b (3) * (4) a:* - // i will check xpath to be strictly conformed from these forms - // for (1) & (4) i will have URN set properly - // for (2) the URN is null - // for (3) the URN is empty - private void SetURN(Axis axis, XmlNamespaceManager nsmgr) - { - if (axis.Prefix.Length != 0) - { // (1) (4) - axis.Urn = nsmgr.LookupNamespace(axis.Prefix); - - if (axis.Urn == null) - { - throw new XmlSchemaException(ResXml.Sch_UnresolvedPrefix, axis.Prefix); - } - } - else if (axis.Name.Length != 0) - { // (2) - axis.Urn = null; - } - else - { // (3) - axis.Urn = ""; - } - } - }// Asttree -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BaseProcessor.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BaseProcessor.cs deleted file mode 100644 index 5968c65b872..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BaseProcessor.cs +++ /dev/null @@ -1,295 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.Text; - using System.Diagnostics; - - internal class BaseProcessor - { - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private ValidationEventHandler _eventHandler; - private XmlSchemaCompilationSettings _compilationSettings; - private int _errorCount = 0; - private string _nsXml; - - public BaseProcessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) - : this(nameTable, schemaNames, eventHandler, new XmlSchemaCompilationSettings()) { } //Use the default for XmlSchemaCollection - - public BaseProcessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings) - { - Debug.Assert(nameTable != null); - _nameTable = nameTable; - _schemaNames = schemaNames; - _eventHandler = eventHandler; - _compilationSettings = compilationSettings; - _nsXml = nameTable.Add(XmlReservedNs.NsXml); - } - - protected XmlNameTable NameTable - { - get { return _nameTable; } - } - - protected SchemaNames SchemaNames - { - get - { - if (_schemaNames == null) - { - _schemaNames = new SchemaNames(_nameTable); - } - return _schemaNames; - } - } - - protected ValidationEventHandler EventHandler - { - get { return _eventHandler; } - } - - protected XmlSchemaCompilationSettings CompilationSettings - { - get { return _compilationSettings; } - } - - protected bool HasErrors - { - get { return _errorCount != 0; } - } - - protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) - { - if (qname.Name.Length == 0) - { - return; - } - XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; - - if (existingObject != null) - { - if (existingObject == item) - { - return; - } - string code = ResXml.Sch_DupGlobalElement; - if (item is XmlSchemaAttributeGroup) - { - string ns = _nameTable.Add(qname.Namespace); - if (Ref.Equal(ns, _nsXml)) - { //Check for xml namespace - XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); - XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname]; - if ((object)existingObject == (object)builtInAttributeGroup) - { - table.Insert(qname, item); - return; - } - else if ((object)item == (object)builtInAttributeGroup) - { //trying to overwrite customer's component with built-in, ignore built-in - return; - } - } - else if (IsValidAttributeGroupRedefine(existingObject, item, table)) - { //check for redefines - return; - } - code = ResXml.Sch_DupAttributeGroup; - } - else if (item is XmlSchemaAttribute) - { - string ns = _nameTable.Add(qname.Namespace); - if (Ref.Equal(ns, _nsXml)) - { - XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); - XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname]; - if ((object)existingObject == (object)builtInAttribute) - { //replace built-in one - table.Insert(qname, item); - return; - } - else if ((object)item == (object)builtInAttribute) - { //trying to overwrite customer's component with built-in, ignore built-in - return; - } - } - code = ResXml.Sch_DupGlobalAttribute; - } - else if (item is XmlSchemaSimpleType) - { - if (IsValidTypeRedefine(existingObject, item, table)) - { - return; - } - code = ResXml.Sch_DupSimpleType; - } - else if (item is XmlSchemaComplexType) - { - if (IsValidTypeRedefine(existingObject, item, table)) - { - return; - } - code = ResXml.Sch_DupComplexType; - } - else if (item is XmlSchemaGroup) - { - if (IsValidGroupRedefine(existingObject, item, table)) - { //check for redefines - return; - } - code = ResXml.Sch_DupGroup; - } - else if (item is XmlSchemaNotation) - { - code = ResXml.Sch_DupNotation; - } - else if (item is XmlSchemaIdentityConstraint) - { - code = ResXml.Sch_DupIdentityConstraint; - } - else - { - Debug.Assert(item is XmlSchemaElement); - } - SendValidationEvent(code, qname.ToString(), item); - } - else - { - table.Add(qname, item); - } - } - - private bool IsValidAttributeGroupRedefine(XmlSchemaObject existingObject, XmlSchemaObject item, XmlSchemaObjectTable table) - { - XmlSchemaAttributeGroup attGroup = item as XmlSchemaAttributeGroup; - XmlSchemaAttributeGroup existingAttGroup = existingObject as XmlSchemaAttributeGroup; - if (existingAttGroup == attGroup.Redefined) - { //attribute group is the redefinition of existingObject - if (existingAttGroup.AttributeUses.Count == 0) - { //If the existing one is not already compiled, then replace. - table.Insert(attGroup.QualifiedName, attGroup); //Update with redefined entry - return true; - } - } - else if (existingAttGroup.Redefined == attGroup) - { //Redefined type already exists in the set, original type is added after redefined type, ignore the original type - return true; - } - return false; - } - - private bool IsValidGroupRedefine(XmlSchemaObject existingObject, XmlSchemaObject item, XmlSchemaObjectTable table) - { - XmlSchemaGroup group = item as XmlSchemaGroup; - XmlSchemaGroup existingGroup = existingObject as XmlSchemaGroup; - if (existingGroup == group.Redefined) - { //group is the redefinition of existingObject - if (existingGroup.CanonicalParticle == null) - { //If the existing one is not already compiled, then replace. - table.Insert(group.QualifiedName, group); //Update with redefined entry - return true; - } - } - else if (existingGroup.Redefined == group) - { //Redefined type already exists in the set, original type is added after redefined type, ignore the original type - return true; - } - return false; - } - - private bool IsValidTypeRedefine(XmlSchemaObject existingObject, XmlSchemaObject item, XmlSchemaObjectTable table) - { - XmlSchemaType schemaType = item as XmlSchemaType; - XmlSchemaType existingType = existingObject as XmlSchemaType; - if (existingType == schemaType.Redefined) - { //schemaType is the redefinition of existingObject - if (existingType.ElementDecl == null) - { //If the existing one is not already compiled, then replace. - table.Insert(schemaType.QualifiedName, schemaType); //Update with redefined entry - return true; - } - } - else if (existingType.Redefined == schemaType) - { //Redefined type already exists in the set, original type is added after redefined type, ignore the original type - return true; - } - return false; - } - - protected void SendValidationEvent(string code, XmlSchemaObject source) - { - SendValidationEvent(new XmlSchemaException(code, source), XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string msg, XmlSchemaObject source) - { - SendValidationEvent(new XmlSchemaException(code, msg, source), XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string msg1, string msg2, XmlSchemaObject source) - { - SendValidationEvent(new XmlSchemaException(code, new string[] { msg1, msg2 }, source), XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string[] args, Exception innerException, XmlSchemaObject source) - { - SendValidationEvent(new XmlSchemaException(code, args, innerException, source.SourceUri, source.LineNumber, source.LinePosition, source), XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string msg1, string msg2, string sourceUri, int lineNumber, int linePosition) - { - SendValidationEvent(new XmlSchemaException(code, new string[] { msg1, msg2 }, sourceUri, lineNumber, linePosition), XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, XmlSchemaObject source, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, source), severity); - } - - protected void SendValidationEvent(XmlSchemaException e) - { - SendValidationEvent(e, XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string msg, XmlSchemaObject source, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, msg, source), severity); - } - - protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) - { - if (severity == XmlSeverityType.Error) - { - _errorCount++; - } - if (_eventHandler != null) - { - _eventHandler(null, new ValidationEventArgs(e, severity)); - } - else if (severity == XmlSeverityType.Error) - { - throw e; - } - } - - protected void SendValidationEventNoThrow(XmlSchemaException e, XmlSeverityType severity) - { - if (severity == XmlSeverityType.Error) - { - _errorCount++; - } - if (_eventHandler != null) - { - _eventHandler(null, new ValidationEventArgs(e, severity)); - } - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BitSet.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BitSet.cs deleted file mode 100644 index 392acfaf6bc..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/BitSet.cs +++ /dev/null @@ -1,273 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Text; - using System.Diagnostics; - - internal sealed class BitSet - { - private const int bitSlotShift = 5; - private const int bitSlotMask = (1 << bitSlotShift) - 1; - - private int _count; - private uint[] _bits; - - private BitSet() - { - } - - public BitSet(int count) - { - _count = count; - _bits = new uint[Subscript(count + bitSlotMask)]; - } - - public int Count - { - get { return _count; } - } - - public bool this[int index] - { - get - { - return Get(index); - } - } - - public void Clear() - { - int bitsLength = _bits.Length; - for (int i = bitsLength; i-- > 0;) - { - _bits[i] = 0; - } - } - - public void Clear(int index) - { - int nBitSlot = Subscript(index); - EnsureLength(nBitSlot + 1); - _bits[nBitSlot] &= ~((uint)1 << (index & bitSlotMask)); - } - - public void Set(int index) - { - int nBitSlot = Subscript(index); - EnsureLength(nBitSlot + 1); - _bits[nBitSlot] |= (uint)1 << (index & bitSlotMask); - } - - - public bool Get(int index) - { - bool fResult = false; - if (index < _count) - { - int nBitSlot = Subscript(index); - fResult = ((_bits[nBitSlot] & (1 << (index & bitSlotMask))) != 0); - } - return fResult; - } - - public int NextSet(int startFrom) - { - Debug.Assert(startFrom >= -1 && startFrom <= _count); - int offset = startFrom + 1; - if (offset == _count) - { - return -1; - } - int nBitSlot = Subscript(offset); - offset &= bitSlotMask; - uint word = _bits[nBitSlot] >> offset; - // locate non-empty slot - while (word == 0) - { - if ((++nBitSlot) == _bits.Length) - { - return -1; - } - offset = 0; - word = _bits[nBitSlot]; - } - while ((word & (uint)1) == 0) - { - word >>= 1; - offset++; - } - return (nBitSlot << bitSlotShift) + offset; - } - - public void And(BitSet other) - { - /* - * Need to synchronize both this and other-> - * This might lead to deadlock if one thread grabs them in one order - * while another thread grabs them the other order. - * Use a trick from Doug Lea's book on concurrency, - * somewhat complicated because BitSet overrides hashCode(). - */ - if (this == other) - { - return; - } - int bitsLength = _bits.Length; - int setLength = other._bits.Length; - int n = (bitsLength > setLength) ? setLength : bitsLength; - for (int i = n; i-- > 0;) - { - _bits[i] &= other._bits[i]; - } - for (; n < bitsLength; n++) - { - _bits[n] = 0; - } - } - - - public void Or(BitSet other) - { - if (this == other) - { - return; - } - int setLength = other._bits.Length; - EnsureLength(setLength); - for (int i = setLength; i-- > 0;) - { - _bits[i] |= other._bits[i]; - } - } - - public override int GetHashCode() - { - int h = 1234; - for (int i = _bits.Length; --i >= 0;) - { - h ^= (int)_bits[i] * (i + 1); - } - return (int)((h >> 32) ^ h); - } - - - public override bool Equals(object obj) - { - // assume the same type - if (obj != null) - { - if (this == obj) - { - return true; - } - BitSet other = (BitSet)obj; - - int bitsLength = _bits.Length; - int setLength = other._bits.Length; - int n = (bitsLength > setLength) ? setLength : bitsLength; - for (int i = n; i-- > 0;) - { - if (_bits[i] != other._bits[i]) - { - return false; - } - } - if (bitsLength > n) - { - for (int i = bitsLength; i-- > n;) - { - if (_bits[i] != 0) - { - return false; - } - } - } - else - { - for (int i = setLength; i-- > n;) - { - if (other._bits[i] != 0) - { - return false; - } - } - } - return true; - } - return false; - } - - public BitSet Clone() - { - BitSet newset = new BitSet(); - newset._count = _count; - newset._bits = (uint[])_bits.Clone(); - return newset; - } - - - public bool IsEmpty - { - get - { - uint k = 0; - for (int i = 0; i < _bits.Length; i++) - { - k |= _bits[i]; - } - return k == 0; - } - } - - public bool Intersects(BitSet other) - { - int i = Math.Min(_bits.Length, other._bits.Length); - while (--i >= 0) - { - if ((_bits[i] & other._bits[i]) != 0) - { - return true; - } - } - return false; - } - - private int Subscript(int bitIndex) - { - return bitIndex >> bitSlotShift; - } - - private void EnsureLength(int nRequiredLength) - { - /* Doesn't need to be synchronized because it's an internal method. */ - if (nRequiredLength > _bits.Length) - { - /* Ask for larger of doubled size or required size */ - int request = 2 * _bits.Length; - if (request < nRequiredLength) - request = nRequiredLength; - uint[] newBits = new uint[request]; - Array.Copy(_bits, newBits, _bits.Length); - _bits = newBits; - } - } - -#if DEBUG - public void Dump(StringBuilder bb) - { - for (int i = 0; i < _count; i++) - { - bb.Append(Get(i) ? "1" : "0"); - } - } -#endif - }; -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ChameleonKey.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ChameleonKey.cs deleted file mode 100644 index f6cf64ac758..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ChameleonKey.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using System.Diagnostics; - using Microsoft.Xml.Serialization; - - // Case insensitive file name key for use in a hashtable. - - internal class ChameleonKey - { - internal string targetNS; - internal Uri chameleonLocation; - // Original schema (used for reference equality only) - // stored only when the chameleonLocation is an empty URI in which case the location - // is not a good enough identification of the schema - internal XmlSchema originalSchema; - private int _hashCode; - - /// - /// Creates a new chameleon key - an identification for a chameleon schema instance - /// - /// The target namespace of the instance of the chameleon schema - /// The original (chameleon) schema (the one without the target namespace). - /// This is used to get the location (base uri) and to identify the schema. - public ChameleonKey(string ns, XmlSchema originalSchema) - { - targetNS = ns; - chameleonLocation = originalSchema.BaseUri; - if (chameleonLocation.OriginalString.Length == 0) - { - // Only store the original schema when the location is empty URI - // by doing this we effectively allow multiple chameleon schemas for the same target namespace - // and URI, but that only makes sense for empty URI (not specified) - this.originalSchema = originalSchema; - } - } - - public override int GetHashCode() - { - if (_hashCode == 0) - { - _hashCode = targetNS.GetHashCode() + chameleonLocation.GetHashCode() + - (originalSchema == null ? 0 : originalSchema.GetHashCode()); - } - return _hashCode; - } - - public override bool Equals(object obj) - { - if (Ref.ReferenceEquals(this, obj)) - { - return true; - } - ChameleonKey cKey = obj as ChameleonKey; - if (cKey != null) - { - // We want to compare the target NS and the schema location. - // If the location is empty (but only then) we also want to compare the original schema instance. - // As noted above the originalSchema is null if the chameleonLocation is non-empty. As a result we - // can simply compare the reference to the original schema always (regardless of the schemalocation). - Debug.Assert((chameleonLocation.OriginalString.Length == 0 && originalSchema != null) - || (chameleonLocation.OriginalString.Length != 0 && originalSchema == null)); - return this.targetNS.Equals(cKey.targetNS) && this.chameleonLocation.Equals(cKey.chameleonLocation) && - Ref.ReferenceEquals(originalSchema, cKey.originalSchema); - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/CompiledIdentityConstraint.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/CompiledIdentityConstraint.cs deleted file mode 100644 index 64c5493f634..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/CompiledIdentityConstraint.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Text; - using System.Collections; - using System.Diagnostics; - using Microsoft.Xml.XPath; - using MS.Internal.Xml.XPath; - - internal class CompiledIdentityConstraint - { - internal XmlQualifiedName name = XmlQualifiedName.Empty; - private ConstraintRole _role; - private Asttree _selector; - private Asttree[] _fields; - internal XmlQualifiedName refer = XmlQualifiedName.Empty; - - public enum ConstraintRole - { - Unique, - Key, - Keyref - } - - public ConstraintRole Role - { - get { return _role; } - } - - public Asttree Selector - { - get { return _selector; } - } - - public Asttree[] Fields - { - get { return _fields; } - } - - public static readonly CompiledIdentityConstraint Empty = new CompiledIdentityConstraint(); - - private CompiledIdentityConstraint() { } - - public CompiledIdentityConstraint(XmlSchemaIdentityConstraint constraint, XmlNamespaceManager nsmgr) - { - this.name = constraint.QualifiedName; - - //public Asttree (string xPath, bool isField, XmlNamespaceManager nsmgr) - try - { - _selector = new Asttree(constraint.Selector.XPath, false, nsmgr); - } - catch (XmlSchemaException e) - { - e.SetSource(constraint.Selector); - throw e; - } - XmlSchemaObjectCollection fields = constraint.Fields; - Debug.Assert(fields.Count > 0); - _fields = new Asttree[fields.Count]; - for (int idxField = 0; idxField < fields.Count; idxField++) - { - try - { - _fields[idxField] = new Asttree(((XmlSchemaXPath)fields[idxField]).XPath, true, nsmgr); - } - catch (XmlSchemaException e) - { - e.SetSource(constraint.Fields[idxField]); - throw e; - } - } - if (constraint is XmlSchemaUnique) - { - _role = ConstraintRole.Unique; - } - else if (constraint is XmlSchemaKey) - { - _role = ConstraintRole.Key; - } - else - { // XmlSchemaKeyref - _role = ConstraintRole.Keyref; - this.refer = ((XmlSchemaKeyref)constraint).Refer; - } - } - } -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ConstraintStruct.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ConstraintStruct.cs deleted file mode 100644 index bc271e9493e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ConstraintStruct.cs +++ /dev/null @@ -1,552 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Text; - using System.Collections; - using System.Globalization; - using System.Diagnostics; - - internal sealed class ConstraintStruct - { - // for each constraint - internal CompiledIdentityConstraint constraint; // pointer to constraint - internal SelectorActiveAxis axisSelector; - internal ArrayList axisFields; // Add tableDim * LocatedActiveAxis in a loop - internal Hashtable qualifiedTable; // Checking confliction - internal Hashtable keyrefTable; // several keyref tables having connections to this one is possible - private int _tableDim; // dimension of table = numbers of fields; - - internal int TableDim - { - get { return _tableDim; } - } - - internal ConstraintStruct(CompiledIdentityConstraint constraint) - { - this.constraint = constraint; - _tableDim = constraint.Fields.Length; - this.axisFields = new ArrayList(); // empty fields - this.axisSelector = new SelectorActiveAxis(constraint.Selector, this); - if (this.constraint.Role != CompiledIdentityConstraint.ConstraintRole.Keyref) - { - this.qualifiedTable = new Hashtable(); - } - } - } - - // ActiveAxis plus the location plus the state of matching in the constraint table : only for field - internal class LocatedActiveAxis : ActiveAxis - { - private int _column; // the column in the table (the field sequence) - internal bool isMatched; // if it's matched, then fill value in the validator later - internal KeySequence Ks; // associated with a keysequence it will fills in - - internal int Column - { - get { return _column; } - } - - internal LocatedActiveAxis(Asttree astfield, KeySequence ks, int column) : base(astfield) - { - this.Ks = ks; - _column = column; - this.isMatched = false; - } - - internal void Reactivate(KeySequence ks) - { - Reactivate(); - this.Ks = ks; - } - } - - // exist for optimization purpose - // ActiveAxis plus - // 1. overload endelement function from parent to return result - // 2. combine locatedactiveaxis and keysequence more closely - // 3. enable locatedactiveaxis reusing (the most important optimization point) - // 4. enable ks adding to hashtable right after moving out selector node (to enable 3) - // 5. will modify locatedactiveaxis class accordingly - // 6. taking care of updating ConstraintStruct.axisFields - // 7. remove constraintTable from ConstraintStruct - // 8. still need centralized locatedactiveaxis for movetoattribute purpose - internal class SelectorActiveAxis : ActiveAxis - { - private ConstraintStruct _cs; // pointer of constraintstruct, to enable 6 - private ArrayList _KSs; // stack of KSStruct, will not become less - private int _KSpointer = 0; // indicate current stack top (next available element); - - public bool EmptyStack - { - get { return _KSpointer == 0; } - } - - public int lastDepth - { - get { return (_KSpointer == 0) ? -1 : ((KSStruct)_KSs[_KSpointer - 1]).depth; } - } - - public SelectorActiveAxis(Asttree axisTree, ConstraintStruct cs) : base(axisTree) - { - _KSs = new ArrayList(); - _cs = cs; - } - - public override bool EndElement(string localname, string URN) - { - base.EndElement(localname, URN); - if (_KSpointer > 0 && this.CurrentDepth == lastDepth) - { - return true; - // next step PopPS, and insert into hash - } - return false; - } - - // update constraintStruct.axisFields as well, if it's new LocatedActiveAxis - public int PushKS(int errline, int errcol) - { - // new KeySequence each time - KeySequence ks = new KeySequence(_cs.TableDim, errline, errcol); - - // needs to clear KSStruct before using - KSStruct kss; - if (_KSpointer < _KSs.Count) - { - // reuse, clear up KSs.KSpointer - kss = (KSStruct)_KSs[_KSpointer]; - kss.ks = ks; - // reactivate LocatedActiveAxis - for (int i = 0; i < _cs.TableDim; i++) - { - kss.fields[i].Reactivate(ks); // reassociate key sequence - } - } - else - { // "==", new - kss = new KSStruct(ks, _cs.TableDim); - for (int i = 0; i < _cs.TableDim; i++) - { - kss.fields[i] = new LocatedActiveAxis(_cs.constraint.Fields[i], ks, i); - _cs.axisFields.Add(kss.fields[i]); // new, add to axisFields - } - _KSs.Add(kss); - } - - kss.depth = this.CurrentDepth - 1; - - return (_KSpointer++); - } - - public KeySequence PopKS() - { - return ((KSStruct)_KSs[--_KSpointer]).ks; - } - } - - internal class KSStruct - { - public int depth; // depth of selector when it matches - public KeySequence ks; // ks of selector when it matches and assigned -- needs to new each time - public LocatedActiveAxis[] fields; // array of fields activeaxis when it matches and assigned - - public KSStruct(KeySequence ks, int dim) - { - this.ks = ks; - this.fields = new LocatedActiveAxis[dim]; - } - } - - internal class TypedObject - { - private class DecimalStruct - { - private bool _isDecimal = false; // rare case it will be used... - private decimal[] _dvalue; // to accelerate equals operation. array <-> list - - public bool IsDecimal - { - get { return _isDecimal; } - set { _isDecimal = value; } - } - - public decimal[] Dvalue - { - get { return _dvalue; } - } - - public DecimalStruct() - { - _dvalue = new decimal[1]; - } - //list - public DecimalStruct(int dim) - { - _dvalue = new decimal[dim]; - } - } - - private DecimalStruct _dstruct = null; - private object _ovalue; - private string _svalue; // only for output - private XmlSchemaDatatype _xsdtype; - private int _dim = 1; - private bool _isList = false; - - public int Dim - { - get { return _dim; } - } - - public bool IsList - { - get { return _isList; } - } - - public bool IsDecimal - { - get - { - Debug.Assert(_dstruct != null); - return _dstruct.IsDecimal; - } - } - public decimal[] Dvalue - { - get - { - Debug.Assert(_dstruct != null); - return _dstruct.Dvalue; - } - } - - public object Value - { - get { return _ovalue; } - set { _ovalue = value; } - } - - public XmlSchemaDatatype Type - { - get { return _xsdtype; } - set { _xsdtype = value; } - } - - public TypedObject(object obj, string svalue, XmlSchemaDatatype xsdtype) - { - _ovalue = obj; - _svalue = svalue; - _xsdtype = xsdtype; - if (xsdtype.Variety == XmlSchemaDatatypeVariety.List || - xsdtype is Datatype_base64Binary || - xsdtype is Datatype_hexBinary) - { - _isList = true; - _dim = ((Array)obj).Length; - } - } - - public override string ToString() - { - // only for exception - return _svalue; - } - - public void SetDecimal() - { - if (_dstruct != null) - { - return; - } - - // Debug.Assert(!this.IsDecimal); - switch (_xsdtype.TypeCode) - { - case XmlTypeCode.Byte: - case XmlTypeCode.UnsignedByte: - case XmlTypeCode.Short: - case XmlTypeCode.UnsignedShort: - case XmlTypeCode.Int: - case XmlTypeCode.UnsignedInt: - case XmlTypeCode.Long: - case XmlTypeCode.UnsignedLong: - case XmlTypeCode.Decimal: - case XmlTypeCode.Integer: - case XmlTypeCode.PositiveInteger: - case XmlTypeCode.NonNegativeInteger: - case XmlTypeCode.NegativeInteger: - case XmlTypeCode.NonPositiveInteger: - - if (_isList) - { - _dstruct = new DecimalStruct(_dim); - for (int i = 0; i < _dim; i++) - { - _dstruct.Dvalue[i] = Convert.ToDecimal(((Array)_ovalue).GetValue(i), NumberFormatInfo.InvariantInfo); - } - } - else - { //not list - _dstruct = new DecimalStruct(); - //possibility of list of length 1. - _dstruct.Dvalue[0] = Convert.ToDecimal(_ovalue, NumberFormatInfo.InvariantInfo); - } - _dstruct.IsDecimal = true; - break; - - default: - if (_isList) - { - _dstruct = new DecimalStruct(_dim); - } - else - { - _dstruct = new DecimalStruct(); - } - break; - } - } - - private bool ListDValueEquals(TypedObject other) - { - for (int i = 0; i < this.Dim; i++) - { - if (this.Dvalue[i] != other.Dvalue[i]) - { - return false; - } - } - return true; - } - - public bool Equals(TypedObject other) - { - // ? one is list with one member, another is not list -- still might be equal - if (this.Dim != other.Dim) - { - return false; - } - - if (this.Type != other.Type) - { - //Check if types are comparable - if (!(this.Type.IsComparable(other.Type))) - { - return false; - } - other.SetDecimal(); // can't use cast and other.Type.IsEqual (value1, value2) - this.SetDecimal(); - if (this.IsDecimal && other.IsDecimal) - { //Both are decimal / derived types - return this.ListDValueEquals(other); - } - } - - // not-Decimal derivation or type equal - if (this.IsList) - { - if (other.IsList) - { //Both are lists and values are XmlAtomicValue[] or clrvalue[]. So use Datatype_List.Compare - return this.Type.Compare(this.Value, other.Value) == 0; - } - else - { //this is a list and other is a single value - Array arr1 = this.Value as System.Array; - XmlAtomicValue[] atomicValues1 = arr1 as XmlAtomicValue[]; - if (atomicValues1 != null) - { // this is a list of union - return atomicValues1.Length == 1 && atomicValues1.GetValue(0).Equals(other.Value); - } - else - { - return arr1.Length == 1 && arr1.GetValue(0).Equals(other.Value); - } - } - } - else if (other.IsList) - { - Array arr2 = other.Value as System.Array; - XmlAtomicValue[] atomicValues2 = arr2 as XmlAtomicValue[]; - if (atomicValues2 != null) - { // other is a list of union - return atomicValues2.Length == 1 && atomicValues2.GetValue(0).Equals(this.Value); - } - else - { - return arr2.Length == 1 && arr2.GetValue(0).Equals(this.Value); - } - } - else - { //Both are not lists - return this.Value.Equals(other.Value); - } - } - } - - internal class KeySequence - { - private TypedObject[] _ks; - private int _dim; - private int _hashcode = -1; - private int _posline,_poscol; // for error reporting - - internal KeySequence(int dim, int line, int col) - { - Debug.Assert(dim > 0); - _dim = dim; - _ks = new TypedObject[dim]; - _posline = line; - _poscol = col; - } - - public int PosLine - { - get { return _posline; } - } - - public int PosCol - { - get { return _poscol; } - } - - public KeySequence(TypedObject[] ks) - { - _ks = ks; - _dim = ks.Length; - _posline = _poscol = 0; - } - - public object this[int index] - { - get - { - object result = _ks[index]; - return result; - } - set - { - _ks[index] = (TypedObject)value; - } - } - - // return true if no null field - internal bool IsQualified() - { - for (int i = 0; i < _ks.Length; ++i) - { - if ((_ks[i] == null) || (_ks[i].Value == null)) return false; - } - return true; - } - - // it's not directly suit for hashtable, because it's always calculating address - public override int GetHashCode() - { - if (_hashcode != -1) - { - return _hashcode; - } - _hashcode = 0; // indicate it's changed. even the calculated hashcode below is 0 - for (int i = 0; i < _ks.Length; i++) - { - if (_ks[i] != null) - { - // extract its primitive value to calculate hashcode - // decimal is handled differently to enable among different CLR types - _ks[i].SetDecimal(); - if (_ks[i].IsDecimal) - { - for (int j = 0; j < _ks[i].Dim; j++) - { - _hashcode += _ks[i].Dvalue[j].GetHashCode(); - } - } - // BUGBUG: will need to change below parts, using canonical presentation. - else - { - Array arr = _ks[i].Value as System.Array; - if (arr != null) - { - XmlAtomicValue[] atomicValues = arr as XmlAtomicValue[]; - if (atomicValues != null) - { - for (int j = 0; j < atomicValues.Length; j++) - { - _hashcode += ((XmlAtomicValue)atomicValues.GetValue(j)).TypedValue.GetHashCode(); - } - } - else - { - for (int j = 0; j < ((Array)_ks[i].Value).Length; j++) - { - _hashcode += ((Array)_ks[i].Value).GetValue(j).GetHashCode(); - } - } - } - else - { //not a list - _hashcode += _ks[i].Value.GetHashCode(); - } - } - } - } - return _hashcode; - } - - // considering about derived type - public override bool Equals(object other) - { - /*if (LocalAppContextSwitches.IgnoreEmptyKeySequences) { - // each key sequence member can have different type - KeySequence keySequence = (KeySequence)other; - for (int i = 0; i < this.ks.Length; i++) { - if (!this.ks[i].Equals(keySequence.ks[i])) { - return false; - } - } - return true; - } - else*/ - { - // each key sequence member can have different type - KeySequence keySequence = (KeySequence)other; - for (int i = 0; i < _ks.Length; i++) - { - if (!(_ks[i] == null && keySequence._ks[i] == null) && (_ks[i] == null || keySequence._ks[i] == null || !_ks[i].Equals(keySequence._ks[i]))) - { - return false; - } - } - return true; - } - } - - public override string ToString() - { - /*if (LocalAppContextSwitches.IgnoreEmptyKeySequences) { - StringBuilder sb = new StringBuilder(); - sb.Append(this.ks[0].ToString()); - for (int i = 1; i < this.ks.Length; i++) { - sb.Append(" "); - sb.Append(this.ks[i].ToString()); - } - return sb.ToString(); - } - else*/ - { - StringBuilder sb = new StringBuilder(); - sb.Append(_ks[0].ToString()); - for (int i = 1; i < _ks.Length; i++) - { - sb.Append(" "); - sb.Append(_ks[i] == null ? "{}" : _ks[i].ToString()); - } - return sb.ToString(); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ContentValidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ContentValidator.cs deleted file mode 100644 index caa9ce1da0f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ContentValidator.cs +++ /dev/null @@ -1,2360 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Diagnostics; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - #region ExceptionSymbolsPositions - - /// - /// UPA violations will throw this exception - /// - internal class UpaException : Exception - { - private object _particle1; - private object _particle2; - public UpaException(object particle1, object particle2) - { - _particle1 = particle1; - _particle2 = particle2; - } - public object Particle1 { get { return _particle1; } } - public object Particle2 { get { return _particle2; } } - } - - /// - /// SymbolsDictionary is a map between names that ContextValidator recognizes and symbols - int symbol[XmlQualifiedName name]. - /// There are two types of name - full names and wildcards (namespace is specified, local name is anythig). - /// Wildcard excludes all full names that would match by the namespace part. - /// SymbolsDictionry alwas recognizes all the symbols - the last one is a true wildcard - - /// both name and namespace can be anything that none of the other symbols matched. - /// - internal class SymbolsDictionary - { - private int _last = 0; - private Hashtable _names; - private Hashtable _wildcards = null; - private ArrayList _particles; - private object _particleLast = null; - private bool _isUpaEnforced = true; - - public SymbolsDictionary() - { - _names = new Hashtable(); - _particles = new ArrayList(); - } - - public int Count - { - // last one is a "*:*" any wildcard - get { return _last + 1; } - } - - public int CountOfNames - { - get { return _names.Count; } - } - - /// - /// True is particle can be deterministically attributed from the symbol and conversion to DFA is possible. - /// - public bool IsUpaEnforced - { - get { return _isUpaEnforced; } - set { _isUpaEnforced = value; } - } - - /// - /// Add name and return it's number - /// - public int AddName(XmlQualifiedName name, object particle) - { - object lookup = _names[name]; - if (lookup != null) - { - int symbol = (int)lookup; - if (_particles[symbol] != particle) - { - _isUpaEnforced = false; - } - return symbol; - } - else - { - _names.Add(name, _last); - _particles.Add(particle); - Debug.Assert(_particles.Count == _last + 1); - return _last++; - } - } - - public void AddNamespaceList(NamespaceList list, object particle, bool allowLocal) - { - switch (list.Type) - { - case NamespaceList.ListType.Any: - _particleLast = particle; - break; - case NamespaceList.ListType.Other: - // Create a symbol for the excluded namespace, but don't set a particle for it. - AddWildcard(list.Excluded, null); - if (!allowLocal) - { - AddWildcard(string.Empty, null); //##local is not allowed - } - break; - case NamespaceList.ListType.Set: - foreach (string wildcard in list.Enumerate) - { - AddWildcard(wildcard, particle); - } - break; - } - } - - private void AddWildcard(string wildcard, object particle) - { - if (_wildcards == null) - { - _wildcards = new Hashtable(); - } - object lookup = _wildcards[wildcard]; - if (lookup == null) - { - _wildcards.Add(wildcard, _last); - _particles.Add(particle); - Debug.Assert(_particles.Count == _last + 1); - _last++; - } - else if (particle != null) - { - _particles[(int)lookup] = particle; - } - } - - public ICollection GetNamespaceListSymbols(NamespaceList list) - { - ArrayList match = new ArrayList(); - foreach (XmlQualifiedName name in _names.Keys) - { - if (name != XmlQualifiedName.Empty && list.Allows(name)) - { - match.Add(_names[name]); - } - } - if (_wildcards != null) - { - foreach (string wildcard in _wildcards.Keys) - { - if (list.Allows(wildcard)) - { - match.Add(_wildcards[wildcard]); - } - } - } - if (list.Type == NamespaceList.ListType.Any || list.Type == NamespaceList.ListType.Other) - { - match.Add(_last); // add wildcard - } - return match; - } - - /// - /// Find the symbol for the given name. If neither names nor wilcards match it last (*.*) symbol will be returned - /// - public int this[XmlQualifiedName name] - { - get - { - object lookup = _names[name]; - if (lookup != null) - { - return (int)lookup; - } - if (_wildcards != null) - { - lookup = _wildcards[name.Namespace]; - if (lookup != null) - { - return (int)lookup; - } - } - return _last; // true wildcard - } - } - - /// - /// Check if a name exists in the symbol dictionary - /// - public bool Exists(XmlQualifiedName name) - { - object lookup = _names[name]; - if (lookup != null) - { - return true; - } - return false; - } - - /// - /// Return content processing mode for the symbol - /// - public object GetParticle(int symbol) - { - return symbol == _last ? _particleLast : _particles[symbol]; - } - - /// - /// Output symbol's name - /// - public string NameOf(int symbol) - { - foreach (DictionaryEntry de in _names) - { - if ((int)de.Value == symbol) - { - return ((XmlQualifiedName)de.Key).ToString(); - } - } - if (_wildcards != null) - { - foreach (DictionaryEntry de in _wildcards) - { - if ((int)de.Value == symbol) - { - return (string)de.Key + ":*"; - } - } - } - return "##other:*"; - } - } - - internal struct Position - { - public int symbol; - public object particle; - public Position(int symbol, object particle) - { - this.symbol = symbol; - this.particle = particle; - } - } - - internal class Positions - { - private ArrayList _positions = new ArrayList(); - - public int Add(int symbol, object particle) - { - return _positions.Add(new Position(symbol, particle)); - } - - public Position this[int pos] - { - get { return (Position)_positions[pos]; } - } - - public int Count - { - get { return _positions.Count; } - } - } - #endregion - - #region SystaxTree - /// - /// Base class for the systax tree nodes - /// - internal abstract class SyntaxTreeNode - { - /// - /// Expand NamesapceListNode and RangeNode nodes. All other nodes - /// - public abstract void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions); - - /// - /// Clone the syntaxTree. We need to pass symbolsByPosition because leaf nodes have to add themselves to it. - /// - public abstract SyntaxTreeNode Clone(Positions positions); - - /// - /// From a regular expression to a DFA - /// Compilers by Aho, Sethi, Ullman. - /// ISBN 0-201-10088-6, p135 - /// Construct firstpos, lastpos and calculate followpos - /// - public abstract void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos); - - /// - /// Returns nullable property that is being used by ConstructPos - /// - public abstract bool IsNullable { get; } - - /// - /// Returns true if node is a range node - /// - public virtual bool IsRangeNode - { - get - { - return false; - } - } - - /// - /// Print syntax tree - /// -#if DEBUG - public abstract void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions); -#endif - } - - /// - /// Terminal of the syntax tree - /// - internal class LeafNode : SyntaxTreeNode - { - private int _pos; - - public LeafNode(int pos) - { - _pos = pos; - } - - public int Pos - { - get { return _pos; } - set { _pos = value; } - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - // do nothing - } - - public override SyntaxTreeNode Clone(Positions positions) - { - return new LeafNode(positions.Add(positions[_pos].symbol, positions[_pos].particle)); - } - - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - firstpos.Set(_pos); - lastpos.Set(_pos); - } - - public override bool IsNullable - { - get { return false; } - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - bb.Append("\"" + symbols.NameOf(positions[_pos].symbol) + "\""); - } -#endif - } - - /// - /// Temporary node to represent NamespaceList. Will be expended as a choice of symbols - /// - internal class NamespaceListNode : SyntaxTreeNode - { - protected NamespaceList namespaceList; - protected object particle; - - public NamespaceListNode(NamespaceList namespaceList, object particle) - { - this.namespaceList = namespaceList; - this.particle = particle; - } - - public override SyntaxTreeNode Clone(Positions positions) - { - // NamespaceListNode nodes have to be removed prior to that - throw new InvalidOperationException(); - } - - public virtual ICollection GetResolvedSymbols(SymbolsDictionary symbols) - { - return symbols.GetNamespaceListSymbols(namespaceList); - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - SyntaxTreeNode replacementNode = null; - foreach (int symbol in GetResolvedSymbols(symbols)) - { - if (symbols.GetParticle(symbol) != particle) - { - symbols.IsUpaEnforced = false; - } - LeafNode node = new LeafNode(positions.Add(symbol, particle)); - if (replacementNode == null) - { - replacementNode = node; - } - else - { - InteriorNode choice = new ChoiceNode(); - choice.LeftChild = replacementNode; - choice.RightChild = node; - replacementNode = choice; - } - } - if (parent.LeftChild == this) - { - parent.LeftChild = replacementNode; - } - else - { - parent.RightChild = replacementNode; - } - } - - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - // NamespaceListNode nodes have to be removed prior to that - throw new InvalidOperationException(); - } - - public override bool IsNullable - { - // NamespaceListNode nodes have to be removed prior to that - get { throw new InvalidOperationException(); } - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - bb.Append("[" + namespaceList.ToString() + "]"); - } -#endif - } - - /// - /// Base class for all internal node. Note that only sequence and choice have right child - /// - internal abstract class InteriorNode : SyntaxTreeNode - { - private SyntaxTreeNode _leftChild; - private SyntaxTreeNode _rightChild; - - public SyntaxTreeNode LeftChild - { - get { return _leftChild; } - set { _leftChild = value; } - } - - public SyntaxTreeNode RightChild - { - get { return _rightChild; } - set { _rightChild = value; } - } - - public override SyntaxTreeNode Clone(Positions positions) - { - InteriorNode other = (InteriorNode)this.MemberwiseClone(); - other.LeftChild = _leftChild.Clone(positions); - if (_rightChild != null) - { - other.RightChild = _rightChild.Clone(positions); - } - return other; - } - - //no recursive version of expand tree for Sequence and Choice node - protected void ExpandTreeNoRecursive(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - Stack nodeStack = new Stack(); - InteriorNode this_ = this; - while (true) - { - if (this_._leftChild is ChoiceNode || this_._leftChild is SequenceNode) - { - nodeStack.Push(this_); - this_ = (InteriorNode)this_._leftChild; - continue; - } - this_._leftChild.ExpandTree(this_, symbols, positions); - - ProcessRight: - if (this_._rightChild != null) - { - this_._rightChild.ExpandTree(this_, symbols, positions); - } - - if (nodeStack.Count == 0) - break; - - this_ = nodeStack.Pop(); - goto ProcessRight; - } - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - _leftChild.ExpandTree(this, symbols, positions); - if (_rightChild != null) - { - _rightChild.ExpandTree(this, symbols, positions); - } - } - } - - - internal sealed class SequenceNode : InteriorNode - { - private struct SequenceConstructPosContext - { - public SequenceNode this_; - public BitSet firstpos; - public BitSet lastpos; - public BitSet lastposLeft; - public BitSet firstposRight; - - public SequenceConstructPosContext(SequenceNode node, BitSet firstpos, BitSet lastpos) - { - this_ = node; - this.firstpos = firstpos; - this.lastpos = lastpos; - - lastposLeft = null; - firstposRight = null; - } - } - - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - Stack contextStack = new Stack(); - SequenceConstructPosContext context = new SequenceConstructPosContext(this, firstpos, lastpos); - - while (true) - { - SequenceNode this_ = context.this_; - context.lastposLeft = new BitSet(lastpos.Count); - if (this_.LeftChild is SequenceNode) - { - contextStack.Push(context); - context = new SequenceConstructPosContext((SequenceNode)this_.LeftChild, context.firstpos, context.lastposLeft); - continue; - } - this_.LeftChild.ConstructPos(context.firstpos, context.lastposLeft, followpos); - - ProcessRight: - context.firstposRight = new BitSet(firstpos.Count); - this_.RightChild.ConstructPos(context.firstposRight, context.lastpos, followpos); - - if (this_.LeftChild.IsNullable && !this_.RightChild.IsRangeNode) - { - context.firstpos.Or(context.firstposRight); - } - if (this_.RightChild.IsNullable) - { - context.lastpos.Or(context.lastposLeft); - } - for (int pos = context.lastposLeft.NextSet(-1); pos != -1; pos = context.lastposLeft.NextSet(pos)) - { - followpos[pos].Or(context.firstposRight); - } - if (this_.RightChild.IsRangeNode) - { //firstpos is leftchild.firstpos as the or with firstposRight has not been done as it is a rangenode - ((LeafRangeNode)this_.RightChild).NextIteration = context.firstpos.Clone(); - } - - if (contextStack.Count == 0) - break; - - context = contextStack.Pop(); - this_ = context.this_; - goto ProcessRight; - } - } - - public override bool IsNullable - { - get - { - SyntaxTreeNode n; - SequenceNode this_ = this; - do - { - if (this_.RightChild.IsRangeNode && ((LeafRangeNode)this_.RightChild).Min == 0) - return true; - if (!this_.RightChild.IsNullable && !this_.RightChild.IsRangeNode) - return false; - n = this_.LeftChild; - this_ = n as SequenceNode; - } - while (this_ != null); - return n.IsNullable; - } - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - ExpandTreeNoRecursive(parent, symbols, positions); - } - -#if DEBUG - internal static void WritePos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "FirstPos: "); - WriteBitSet(firstpos); - - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "LastPos: "); - WriteBitSet(lastpos); - - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "Followpos: "); - for (int i = 0; i < followpos.Length; i++) - { - WriteBitSet(followpos[i]); - } - } - internal static void WriteBitSet(BitSet curpos) - { - int[] list = new int[curpos.Count]; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - list[pos] = 1; - } - //for(int i = 0; i < list.Length; i++) { - // Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, list[i] + " "); - //} - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); - } - - - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - Stack nodeStack = new Stack(); - SequenceNode this_ = this; - - while (true) - { - bb.Append("("); - if (this_.LeftChild is SequenceNode) - { - nodeStack.Push(this_); - this_ = (SequenceNode)this_.LeftChild; - continue; - } - this_.LeftChild.Dump(bb, symbols, positions); - - ProcessRight: - bb.Append(", "); - this_.RightChild.Dump(bb, symbols, positions); - bb.Append(")"); - if (nodeStack.Count == 0) - break; - - this_ = nodeStack.Pop(); - goto ProcessRight; - } - } -#endif - - } - - internal sealed class ChoiceNode : InteriorNode - { - private static void ConstructChildPos(SyntaxTreeNode child, BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - BitSet firstPosTemp = new BitSet(firstpos.Count); - BitSet lastPosTemp = new BitSet(lastpos.Count); - child.ConstructPos(firstPosTemp, lastPosTemp, followpos); - firstpos.Or(firstPosTemp); - lastpos.Or(lastPosTemp); - } - - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - BitSet firstPosTemp = new BitSet(firstpos.Count); - BitSet lastPosTemp = new BitSet(lastpos.Count); - SyntaxTreeNode n; - ChoiceNode this_ = this; - do - { - ConstructChildPos(this_.RightChild, firstPosTemp, lastPosTemp, followpos); - n = this_.LeftChild; - this_ = n as ChoiceNode; - } while (this_ != null); - - n.ConstructPos(firstpos, lastpos, followpos); - firstpos.Or(firstPosTemp); - lastpos.Or(lastPosTemp); - } - - public override bool IsNullable - { - get - { - SyntaxTreeNode n; - ChoiceNode this_ = this; - do - { - if (this_.RightChild.IsNullable) - return true; - n = this_.LeftChild; - this_ = n as ChoiceNode; - } - while (this_ != null); - return n.IsNullable; - } - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - ExpandTreeNoRecursive(parent, symbols, positions); - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - Stack nodeStack = new Stack(); - ChoiceNode this_ = this; - - while (true) - { - bb.Append("("); - if (this_.LeftChild is ChoiceNode) - { - nodeStack.Push(this_); - this_ = (ChoiceNode)this_.LeftChild; - continue; - } - this_.LeftChild.Dump(bb, symbols, positions); - - ProcessRight: - bb.Append(" | "); - this_.RightChild.Dump(bb, symbols, positions); - bb.Append(")"); - if (nodeStack.Count == 0) - break; - - this_ = nodeStack.Pop(); - goto ProcessRight; - } - } -#endif - } - - internal sealed class PlusNode : InteriorNode - { - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - LeftChild.ConstructPos(firstpos, lastpos, followpos); - for (int pos = lastpos.NextSet(-1); pos != -1; pos = lastpos.NextSet(pos)) - { - followpos[pos].Or(firstpos); - } - } - - public override bool IsNullable - { - get { return LeftChild.IsNullable; } - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - LeftChild.Dump(bb, symbols, positions); - bb.Append("+"); - } -#endif - } - - internal sealed class QmarkNode : InteriorNode - { - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - LeftChild.ConstructPos(firstpos, lastpos, followpos); - } - - public override bool IsNullable - { - get { return true; } - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - LeftChild.Dump(bb, symbols, positions); - bb.Append("?"); - } -#endif - } - - internal sealed class StarNode : InteriorNode - { - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) - { - LeftChild.ConstructPos(firstpos, lastpos, followpos); - for (int pos = lastpos.NextSet(-1); pos != -1; pos = lastpos.NextSet(pos)) - { - followpos[pos].Or(firstpos); - } - } - - public override bool IsNullable - { - get { return true; } - } - -#if DEBUG - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) - { - LeftChild.Dump(bb, symbols, positions); - bb.Append("*"); - } -#endif - } - -#if EXPANDRANGE - /// - /// Temporary node to occurance range. Will be expended to a sequence of terminals - /// - sealed class RangeNode : InteriorNode { - int min; - int max; - - public RangeNode(int min, int max) { - this.min = min; - this.max = max; - } - - public int Max { - get { return max;} - } - - public int Min { - get { return min;} - } - - public override SyntaxTreeNode Clone(Positions positions) { - // range nodes have to be removed prior to that - throw new InvalidOperationException(); - } - - /// - /// Expand tree will replace a{min, max} using following algorithm. Bare in mind that this sequence will have at least two leaves - /// if min == 0 (max cannot be unbounded) - /// a?, ... a? - /// \__ __/ - /// max - /// else - /// if max == unbounded - /// a, ... a, a* - /// \__ __/ - /// min - /// else - /// a, ... a, a?, ... a? - /// \__ __/ \__ __/ - /// min max - min - /// - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { - LeftChild.ExpandTree(this, symbols, positions); - SyntaxTreeNode replacementNode = null; - if (min == 0) { - Debug.Assert(max != int.MaxValue); - replacementNode = NewQmark(LeftChild); - for (int i = 0; i < max - 1; i ++) { - replacementNode = NewSequence(replacementNode, NewQmark(LeftChild.Clone(positions))); - } - } - else { - replacementNode = LeftChild; - for (int i = 0; i < min - 1; i ++) { - replacementNode = NewSequence(replacementNode, LeftChild.Clone(positions)); - } - if (max == int.MaxValue) { - replacementNode = NewSequence(replacementNode, NewStar(LeftChild.Clone(positions))); - } - else { - for (int i = 0; i < max - min; i ++) { - replacementNode = NewSequence(replacementNode, NewQmark(LeftChild.Clone(positions))); - } - } - } - if (parent.LeftChild == this) { - parent.LeftChild = replacementNode; - } - else { - parent.RightChild = replacementNode; - } - } - - private SyntaxTreeNode NewSequence(SyntaxTreeNode leftChild, SyntaxTreeNode rightChild) { - InteriorNode sequence = new SequenceNode(); - sequence.LeftChild = leftChild; - sequence.RightChild = rightChild; - return sequence; - } - - private SyntaxTreeNode NewStar(SyntaxTreeNode leftChild) { - InteriorNode star = new StarNode(); - star.LeftChild = leftChild; - return star; - } - - private SyntaxTreeNode NewQmark(SyntaxTreeNode leftChild) { - InteriorNode qmark = new QmarkNode(); - qmark.LeftChild = leftChild; - return qmark; - } - - public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) { - throw new InvalidOperationException(); - } - - public override bool IsNullable { - get { throw new InvalidOperationException(); } - } - - public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) { - LeftChild.Dump(bb, symbols, positions); - bb.Append("{" + Convert.ToString(min, NumberFormatInfo.InvariantInfo) + ", " + Convert.ToString(max, NumberFormatInfo.InvariantInfo) + "}"); - } - - } -#endif - - - /// - /// Using range node as one of the terminals - /// - internal sealed class LeafRangeNode : LeafNode - { - private decimal _min; - private decimal _max; - private BitSet _nextIteration; - - public LeafRangeNode(decimal min, decimal max) : this(-1, min, max) { } - - public LeafRangeNode(int pos, decimal min, decimal max) : base(pos) - { - _min = min; - _max = max; - } - - public decimal Max - { - get { return _max; } - } - - public decimal Min - { - get { return _min; } - } - - public BitSet NextIteration - { - get - { - return _nextIteration; - } - set - { - _nextIteration = value; - } - } - - public override SyntaxTreeNode Clone(Positions positions) - { - return new LeafRangeNode(this.Pos, _min, _max); - } - - public override bool IsRangeNode - { - get - { - return true; - } - } - - public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) - { - Debug.Assert(parent is SequenceNode); - Debug.Assert(this == parent.RightChild); - //change the range node min to zero if left is nullable - if (parent.LeftChild.IsNullable) - { - _min = 0; - } - } - } - - #endregion - - #region ContentValidator - /// - /// Basic ContentValidator - /// - internal class ContentValidator - { - private XmlSchemaContentType _contentType; - private bool _isOpen; //For XDR Content Models or ANY - private bool _isEmptiable; - - public static readonly ContentValidator Empty = new ContentValidator(XmlSchemaContentType.Empty); - public static readonly ContentValidator TextOnly = new ContentValidator(XmlSchemaContentType.TextOnly, false, false); - public static readonly ContentValidator Mixed = new ContentValidator(XmlSchemaContentType.Mixed); - public static readonly ContentValidator Any = new ContentValidator(XmlSchemaContentType.Mixed, true, true); - - public ContentValidator(XmlSchemaContentType contentType) - { - _contentType = contentType; - _isEmptiable = true; - } - - protected ContentValidator(XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) - { - _contentType = contentType; - _isOpen = isOpen; - _isEmptiable = isEmptiable; - } - - public XmlSchemaContentType ContentType - { - get { return _contentType; } - } - - public bool PreserveWhitespace - { - get { return _contentType == XmlSchemaContentType.TextOnly || _contentType == XmlSchemaContentType.Mixed; } - } - - public virtual bool IsEmptiable - { - get { return _isEmptiable; } - } - - public bool IsOpen - { - get - { - if (_contentType == XmlSchemaContentType.TextOnly || _contentType == XmlSchemaContentType.Empty) - return false; - else - return _isOpen; - } - set { _isOpen = value; } - } - - public virtual void InitValidation(ValidationState context) - { - // do nothin' - } - - public virtual object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - if (_contentType == XmlSchemaContentType.TextOnly || _contentType == XmlSchemaContentType.Empty) - { //Cannot have elements in TextOnly or Empty content - context.NeedValidateChildren = false; - } - errorCode = -1; - return null; - } - - public virtual bool CompleteValidation(ValidationState context) - { - return true; - } - - public virtual ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) - { - return null; - } - - public virtual ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) - { - return null; - } - - public static void AddParticleToExpected(XmlSchemaParticle p, XmlSchemaSet schemaSet, ArrayList particles) - { - AddParticleToExpected(p, schemaSet, particles, false); - } - - public static void AddParticleToExpected(XmlSchemaParticle p, XmlSchemaSet schemaSet, ArrayList particles, bool global) - { - if (!particles.Contains(p)) - { - particles.Add(p); - } - //Only then it can be head of substitutionGrp, if it is, add its members - XmlSchemaElement elem = p as XmlSchemaElement; - if (elem != null && (global || !elem.RefName.IsEmpty)) - { - XmlSchemaObjectTable substitutionGroups = schemaSet.SubstitutionGroups; - XmlSchemaSubstitutionGroup grp = (XmlSchemaSubstitutionGroup)substitutionGroups[elem.QualifiedName]; - if (grp != null) - { - //Grp members wil contain the head as well, so filter head as we added it already - for (int i = 0; i < grp.Members.Count; ++i) - { - XmlSchemaElement member = (XmlSchemaElement)grp.Members[i]; - if (!elem.QualifiedName.Equals(member.QualifiedName) && !particles.Contains(member)) - { //A member might have been directly present as an element in the content model - particles.Add(member); - } - } - } - } - } - } - - internal sealed class ParticleContentValidator : ContentValidator - { - private SymbolsDictionary _symbols; - private Positions _positions; - private Stack _stack; // parsing context - private SyntaxTreeNode _contentNode; // content model points to syntax tree - private bool _isPartial; // whether the closure applies to partial or the whole node that is on top of the stack - private int _minMaxNodesCount; - private bool _enableUpaCheck; - - public ParticleContentValidator(XmlSchemaContentType contentType) : this(contentType, true) - { - } - - public ParticleContentValidator(XmlSchemaContentType contentType, bool enableUpaCheck) : base(contentType) - { - _enableUpaCheck = enableUpaCheck; - } - - public override void InitValidation(ValidationState context) - { - // ParticleContentValidator cannot be used during validation - throw new InvalidOperationException(); - } - - public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - // ParticleContentValidator cannot be used during validation - throw new InvalidOperationException(); - } - - public override bool CompleteValidation(ValidationState context) - { - // ParticleContentValidator cannot be used during validation - throw new InvalidOperationException(); - } - - public void Start() - { - _symbols = new SymbolsDictionary(); - _positions = new Positions(); - _stack = new Stack(); - } - - public void OpenGroup() - { - _stack.Push(null); - } - - public void CloseGroup() - { - SyntaxTreeNode node = (SyntaxTreeNode)_stack.Pop(); - if (node == null) - { - return; - } - if (_stack.Count == 0) - { - _contentNode = node; - _isPartial = false; - } - else - { - // some collapsing to do... - InteriorNode inNode = (InteriorNode)_stack.Pop(); - if (inNode != null) - { - inNode.RightChild = node; - node = inNode; - _isPartial = true; - } - else - { - _isPartial = false; - } - _stack.Push(node); - } - } - - public bool Exists(XmlQualifiedName name) - { - if (_symbols.Exists(name)) - { - return true; - } - return false; - } - - public void AddName(XmlQualifiedName name, object particle) - { - AddLeafNode(new LeafNode(_positions.Add(_symbols.AddName(name, particle), particle))); - } - - public void AddNamespaceList(NamespaceList namespaceList, object particle) - { - _symbols.AddNamespaceList(namespaceList, particle, false); - AddLeafNode(new NamespaceListNode(namespaceList, particle)); - } - - private void AddLeafNode(SyntaxTreeNode node) - { - if (_stack.Count > 0) - { - InteriorNode inNode = (InteriorNode)_stack.Pop(); - if (inNode != null) - { - inNode.RightChild = node; - node = inNode; - } - } - _stack.Push(node); - _isPartial = true; - } - - public void AddChoice() - { - SyntaxTreeNode node = (SyntaxTreeNode)_stack.Pop(); - InteriorNode choice = new ChoiceNode(); - choice.LeftChild = node; - _stack.Push(choice); - } - - public void AddSequence() - { - SyntaxTreeNode node = (SyntaxTreeNode)_stack.Pop(); - InteriorNode sequence = new SequenceNode(); - sequence.LeftChild = node; - _stack.Push(sequence); - } - - public void AddStar() - { - Closure(new StarNode()); - } - - public void AddPlus() - { - Closure(new PlusNode()); - } - - public void AddQMark() - { - Closure(new QmarkNode()); - } - - public void AddLeafRange(decimal min, decimal max) - { - LeafRangeNode rNode = new LeafRangeNode(min, max); - int pos = _positions.Add(-2, rNode); - rNode.Pos = pos; - - InteriorNode sequence = new SequenceNode(); - sequence.RightChild = rNode; - Closure(sequence); - _minMaxNodesCount++; - } - -#if EXPANDRANGE - public void AddRange(int min, int max) { - Closure(new RangeNode(min, max)); - } -#endif - private void Closure(InteriorNode node) - { - if (_stack.Count > 0) - { - SyntaxTreeNode topNode = (SyntaxTreeNode)_stack.Pop(); - InteriorNode inNode = topNode as InteriorNode; - if (_isPartial && inNode != null) - { - // need to reach in and wrap right hand side of element. - // and n remains the same. - node.LeftChild = inNode.RightChild; - inNode.RightChild = node; - } - else - { - // wrap terminal or any node - node.LeftChild = topNode; - topNode = node; - } - _stack.Push(topNode); - } - else if (_contentNode != null) - { //If there is content to wrap - // wrap whole content - node.LeftChild = _contentNode; - _contentNode = node; - } - } - - public ContentValidator Finish() - { - return Finish(true); - } - - public ContentValidator Finish(bool useDFA) - { - Debug.Assert(ContentType == XmlSchemaContentType.ElementOnly || ContentType == XmlSchemaContentType.Mixed); - if (_contentNode == null) - { - if (ContentType == XmlSchemaContentType.Mixed) - { - string ctype = IsOpen ? "Any" : "TextOnly"; - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContentType: " + ctype); - return IsOpen ? ContentValidator.Any : ContentValidator.TextOnly; - } - else - { - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContent: EMPTY"); - Debug.Assert(!IsOpen); - return ContentValidator.Empty; - } - } - -#if DEBUG - StringBuilder bb = new StringBuilder(); - _contentNode.Dump(bb, _symbols, _positions); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContent : " + bb.ToString()); -#endif - - // Add end marker - InteriorNode contentRoot = new SequenceNode(); - contentRoot.LeftChild = _contentNode; - LeafNode endMarker = new LeafNode(_positions.Add(_symbols.AddName(XmlQualifiedName.Empty, null), null)); - contentRoot.RightChild = endMarker; - - // Eliminate NamespaceListNode(s) and RangeNode(s) - _contentNode.ExpandTree(contentRoot, _symbols, _positions); - -#if DEBUG - bb = new StringBuilder(); - contentRoot.LeftChild.Dump(bb, _symbols, _positions); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tExpended: " + bb.ToString()); -#endif - - // calculate followpos - int symbolsCount = _symbols.Count; - int positionsCount = _positions.Count; - BitSet firstpos = new BitSet(positionsCount); - BitSet lastpos = new BitSet(positionsCount); - BitSet[] followpos = new BitSet[positionsCount]; - for (int i = 0; i < positionsCount; i++) - { - followpos[i] = new BitSet(positionsCount); - } - contentRoot.ConstructPos(firstpos, lastpos, followpos); - - if (_minMaxNodesCount > 0) - { //If the tree has any terminal range nodes - BitSet positionsWithRangeTerminals; - BitSet[] minMaxFollowPos = CalculateTotalFollowposForRangeNodes(firstpos, followpos, out positionsWithRangeTerminals); - - if (_enableUpaCheck) - { - CheckCMUPAWithLeafRangeNodes(GetApplicableMinMaxFollowPos(firstpos, positionsWithRangeTerminals, minMaxFollowPos)); - for (int i = 0; i < positionsCount; i++) - { - CheckCMUPAWithLeafRangeNodes(GetApplicableMinMaxFollowPos(followpos[i], positionsWithRangeTerminals, minMaxFollowPos)); - } - } - return new RangeContentValidator(firstpos, followpos, _symbols, _positions, endMarker.Pos, this.ContentType, contentRoot.LeftChild.IsNullable, positionsWithRangeTerminals, _minMaxNodesCount); - } - else - { - int[][] transitionTable = null; - // if each symbol has unique particle we are golden - if (!_symbols.IsUpaEnforced) - { - if (_enableUpaCheck) - { - // multiple positions that match the same symbol have different particles, but they never follow the same position - CheckUniqueParticleAttribution(firstpos, followpos); - } - } - else if (useDFA) - { - // Can return null if the number of states reaches higher than 8192 / positionsCount - transitionTable = BuildTransitionTable(firstpos, followpos, endMarker.Pos); - } -#if DEBUG - bb = new StringBuilder(); - Dump(bb, followpos, transitionTable); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, bb.ToString()); -#endif - if (transitionTable != null) - { - return new DfaContentValidator(transitionTable, _symbols, this.ContentType, this.IsOpen, contentRoot.LeftChild.IsNullable); - } - else - { - return new NfaContentValidator(firstpos, followpos, _symbols, _positions, endMarker.Pos, this.ContentType, this.IsOpen, contentRoot.LeftChild.IsNullable); - } - } - } - - private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals) - { - int positionsCount = _positions.Count; //terminals - posWithRangeTerminals = new BitSet(positionsCount); - - //Compute followpos for each range node - //For any range node that is surrounded by an outer range node, its follow positions will include those of the outer range node - BitSet[] minmaxFollowPos = new BitSet[_minMaxNodesCount]; - int localMinMaxNodesCount = 0; - - for (int i = positionsCount - 1; i >= 0; i--) - { - Position p = _positions[i]; - if (p.symbol == -2) - { //P is a LeafRangeNode - LeafRangeNode lrNode = p.particle as LeafRangeNode; - Debug.Assert(lrNode != null); - BitSet tempFollowPos = new BitSet(positionsCount); - tempFollowPos.Clear(); - tempFollowPos.Or(followpos[i]); //Add the followpos of the range node - if (lrNode.Min != lrNode.Max) - { //If they are the same, then followpos cannot include the firstpos - tempFollowPos.Or(lrNode.NextIteration); //Add the nextIteration of the range node (this is the firstpos of its parent's leftChild) - } - - //For each position in the bitset, if it is a outer range node (pos > i), then add its followpos as well to the current node's followpos - for (int pos = tempFollowPos.NextSet(-1); pos != -1; pos = tempFollowPos.NextSet(pos)) - { - if (pos > i) - { - Position p1 = _positions[pos]; - if (p1.symbol == -2) - { - LeafRangeNode lrNode1 = p1.particle as LeafRangeNode; - Debug.Assert(lrNode1 != null); - tempFollowPos.Or(minmaxFollowPos[lrNode1.Pos]); - } - } - } - //set the followpos built to the index in the BitSet[] - minmaxFollowPos[localMinMaxNodesCount] = tempFollowPos; - lrNode.Pos = localMinMaxNodesCount++; - posWithRangeTerminals.Set(i); - } - } - return minmaxFollowPos; - } - - private void CheckCMUPAWithLeafRangeNodes(BitSet curpos) - { - object[] symbolMatches = new object[_symbols.Count]; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - Position currentPosition = _positions[pos]; - int symbol = currentPosition.symbol; - if (symbol >= 0) - { //its not a range position - if (symbolMatches[symbol] != null) - { - throw new UpaException(symbolMatches[symbol], currentPosition.particle); - } - else - { - symbolMatches[symbol] = currentPosition.particle; - } - } - } - } - - //For each position, this method calculates the additional follows of any range nodes that need to be added to its followpos - //((ab?)2-4)c, Followpos of a is b as well as that of node R(2-4) = c - private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) - { - if (curpos.Intersects(posWithRangeTerminals)) - { - BitSet newSet = new BitSet(_positions.Count); //Doing work again - newSet.Or(curpos); - newSet.And(posWithRangeTerminals); - curpos = curpos.Clone(); - for (int pos = newSet.NextSet(-1); pos != -1; pos = newSet.NextSet(pos)) - { - LeafRangeNode lrNode = _positions[pos].particle as LeafRangeNode; - curpos.Or(minmaxFollowPos[lrNode.Pos]); - } - } - return curpos; - } - - private void CheckUniqueParticleAttribution(BitSet firstpos, BitSet[] followpos) - { - CheckUniqueParticleAttribution(firstpos); - for (int i = 0; i < _positions.Count; i++) - { - CheckUniqueParticleAttribution(followpos[i]); - } - } - - private void CheckUniqueParticleAttribution(BitSet curpos) - { - // particles will be attributed uniquely if the same symbol never poins to two different ones - object[] particles = new object[_symbols.Count]; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - // if position can follow - int symbol = _positions[pos].symbol; - if (particles[symbol] == null) - { - // set particle for the symbol - particles[symbol] = _positions[pos].particle; - } - else if (particles[symbol] != _positions[pos].particle) - { - throw new UpaException(particles[symbol], _positions[pos].particle); - } - // two different position point to the same symbol and particle - that's OK - } - } - - /// - /// Algorithm 3.5 Construction of a DFA from a regular expression - /// - private int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos) - { - const int TimeConstant = 8192; //(MaxStates * MaxPositions should be a constant) - int positionsCount = _positions.Count; - int MaxStatesCount = TimeConstant / positionsCount; - int symbolsCount = _symbols.Count; - - // transition table (Dtran in the book) - ArrayList transitionTable = new ArrayList(); - - // state lookup table (Dstate in the book) - Hashtable stateTable = new Hashtable(); - - // Add empty set that would signal an error - stateTable.Add(new BitSet(positionsCount), -1); - - // lists unmarked states - Queue unmarked = new Queue(); - - // initially, the only unmarked state in Dstates is firstpo(root) - int state = 0; - unmarked.Enqueue(firstpos); - stateTable.Add(firstpos, 0); - transitionTable.Add(new int[symbolsCount + 1]); - - // while there is an umnarked state T in Dstates do begin - while (unmarked.Count > 0) - { - BitSet statePosSet = (BitSet)unmarked.Dequeue(); // all positions that constitute DFA state - Debug.Assert(state == (int)stateTable[statePosSet]); // just make sure that statePosSet is for correct state - int[] transition = (int[])transitionTable[state]; - if (statePosSet[endMarkerPos]) - { - transition[symbolsCount] = 1; // accepting - } - - // for each input symbol a do begin - for (int symbol = 0; symbol < symbolsCount; symbol++) - { - // let U be the set of positions that are in followpos(p) - // for some position p in T - // such that the symbol at position p is a - BitSet newset = new BitSet(positionsCount); - for (int pos = statePosSet.NextSet(-1); pos != -1; pos = statePosSet.NextSet(pos)) - { - if (symbol == _positions[pos].symbol) - { - newset.Or(followpos[pos]); - } - } - - // if U is not empty and is not in Dstates then - // add U as an unmarked state to Dstates - object lookup = stateTable[newset]; - if (lookup != null) - { - transition[symbol] = (int)lookup; - } - else - { - // construct new state - int newState = stateTable.Count - 1; - if (newState >= MaxStatesCount) - { - return null; - } - unmarked.Enqueue(newset); - stateTable.Add(newset, newState); - transitionTable.Add(new int[symbolsCount + 1]); - transition[symbol] = newState; - } - } - state++; - } - // now convert transition table to array - return (int[][])transitionTable.ToArray(typeof(int[])); - } - -#if DEBUG - private void Dump(StringBuilder bb, BitSet[] followpos, int[][] transitionTable) - { - // Temporary printout - bb.AppendLine("Positions"); - for (int i = 0; i < _positions.Count; i++) - { - bb.AppendLine(i + " " + _positions[i].symbol.ToString(NumberFormatInfo.InvariantInfo) + " " + _symbols.NameOf(_positions[i].symbol)); - } - bb.AppendLine("Followpos"); - for (int i = 0; i < _positions.Count; i++) - { - for (int j = 0; j < _positions.Count; j++) - { - bb.Append(followpos[i][j] ? "X" : "O"); - } - bb.AppendLine(); - } - if (transitionTable != null) - { - // Temporary printout - bb.AppendLine("Transitions"); - for (int i = 0; i < transitionTable.Length; i++) - { - for (int j = 0; j < _symbols.Count; j++) - { - if (transitionTable[i][j] == -1) - { - bb.Append(" x "); - } - else - { - bb.AppendFormat(" {0:000} ", transitionTable[i][j]); - } - } - bb.AppendLine(transitionTable[i][_symbols.Count] == 1 ? "+" : ""); - } - } - } -#endif - } - - /// - /// Deterministic Finite Automata - /// Compilers by Aho, Sethi, Ullman. - /// ISBN 0-201-10088-6, pp. 115, 116, 140 - /// - internal sealed class DfaContentValidator : ContentValidator - { - private int[][] _transitionTable; - private SymbolsDictionary _symbols; - - /// - /// Algorithm 3.5 Construction of a DFA from a regular expression - /// - internal DfaContentValidator( - int[][] transitionTable, SymbolsDictionary symbols, - XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) : base(contentType, isOpen, isEmptiable) - { - _transitionTable = transitionTable; - _symbols = symbols; - } - - public override void InitValidation(ValidationState context) - { - context.CurrentState.State = 0; - context.HasMatched = _transitionTable[0][_symbols.Count] > 0; - } - - /// - /// Algorithm 3.1 Simulating a DFA - /// - public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - int symbol = _symbols[name]; - int state = _transitionTable[context.CurrentState.State][symbol]; - errorCode = 0; - if (state != -1) - { - context.CurrentState.State = state; - context.HasMatched = _transitionTable[context.CurrentState.State][_symbols.Count] > 0; - return _symbols.GetParticle(symbol); // OK - } - if (IsOpen && context.HasMatched) - { - // XDR allows any well-formed contents after matched. - return null; - } - context.NeedValidateChildren = false; - errorCode = -1; - return null; // will never be here - } - - public override bool CompleteValidation(ValidationState context) - { - if (!context.HasMatched) - { - return false; - } - return true; - } - - public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) - { - ArrayList names = null; - int[] transition = _transitionTable[context.CurrentState.State]; - if (transition != null) - { - for (int i = 0; i < transition.Length - 1; i++) - { - if (transition[i] != -1) - { - if (names == null) - { - names = new ArrayList(); - } - XmlSchemaParticle p = (XmlSchemaParticle)_symbols.GetParticle(i); - if (p == null) - { - string s = _symbols.NameOf(i); - if (s.Length != 0) - { - names.Add(s); - } - } - else - { - string s = p.NameString; - if (!names.Contains(s)) - { - names.Add(s); - } - } - } - } - } - return names; - } - - public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) - { - ArrayList particles = new ArrayList(); - int[] transition = _transitionTable[context.CurrentState.State]; - if (transition != null) - { - for (int i = 0; i < transition.Length - 1; i++) - { - if (transition[i] != -1) - { - XmlSchemaParticle p = (XmlSchemaParticle)_symbols.GetParticle(i); - if (p == null) - { - continue; - } - AddParticleToExpected(p, schemaSet, particles); - } - } - } - return particles; - } - } - - /// - /// Nondeterministic Finite Automata - /// Compilers by Aho, Sethi, Ullman. - /// ISBN 0-201-10088-6, pp. 126,140 - /// - internal sealed class NfaContentValidator : ContentValidator - { - private BitSet _firstpos; - private BitSet[] _followpos; - private SymbolsDictionary _symbols; - private Positions _positions; - private int _endMarkerPos; - - internal NfaContentValidator( - BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, - XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) : base(contentType, isOpen, isEmptiable) - { - _firstpos = firstpos; - _followpos = followpos; - _symbols = symbols; - _positions = positions; - _endMarkerPos = endMarkerPos; - } - - public override void InitValidation(ValidationState context) - { - context.CurPos[0] = _firstpos.Clone(); - context.CurPos[1] = new BitSet(_firstpos.Count); - context.CurrentState.CurPosIndex = 0; - } - - /// - /// Algorithm 3.4 Simulation of an NFA - /// - public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - BitSet curpos = context.CurPos[context.CurrentState.CurPosIndex]; - int next = (context.CurrentState.CurPosIndex + 1) % 2; - BitSet nextpos = context.CurPos[next]; - nextpos.Clear(); - int symbol = _symbols[name]; - object particle = null; - errorCode = 0; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - // if position can follow - if (symbol == _positions[pos].symbol) - { - nextpos.Or(_followpos[pos]); - particle = _positions[pos].particle; //Between element and wildcard, element will be in earlier pos than wildcard since we add the element nodes to the list of positions first - break; // and then ExpandTree for the namespace nodes which adds the wildcards to the positions list - } - } - if (!nextpos.IsEmpty) - { - context.CurrentState.CurPosIndex = next; - return particle; - } - if (IsOpen && curpos[_endMarkerPos]) - { - // XDR allows any well-formed contents after matched. - return null; - } - context.NeedValidateChildren = false; - errorCode = -1; - return null; // will never be here - } - -#if FINDUPA_PARTICLE - private bool FindUPAParticle(ref object originalParticle, object newParticle) { - if (originalParticle == null) { - originalParticle = newParticle; - if (originalParticle is XmlSchemaElement) { //if the first particle is element, then break, otherwise try to find an element - return true; - } - } - else if (newParticle is XmlSchemaElement) { - if (originalParticle is XmlSchemaAny) { //Weak wildcards, element takes precendence over any - originalParticle = newParticle; - return true; - } - } - return false; - } -#endif - - public override bool CompleteValidation(ValidationState context) - { - if (!context.CurPos[context.CurrentState.CurPosIndex][_endMarkerPos]) - { - return false; - } - return true; - } - - public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) - { - ArrayList names = null; - BitSet curpos = context.CurPos[context.CurrentState.CurPosIndex]; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - if (names == null) - { - names = new ArrayList(); - } - XmlSchemaParticle p = (XmlSchemaParticle)_positions[pos].particle; - if (p == null) - { - string s = _symbols.NameOf(_positions[pos].symbol); - if (s.Length != 0) - { - names.Add(s); - } - } - else - { - string s = p.NameString; - if (!names.Contains(s)) - { - names.Add(s); - } - } - } - return names; - } - - public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) - { - ArrayList particles = new ArrayList(); - BitSet curpos = context.CurPos[context.CurrentState.CurPosIndex]; - for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) - { - XmlSchemaParticle p = (XmlSchemaParticle)_positions[pos].particle; - if (p == null) - { - continue; - } - else - { - AddParticleToExpected(p, schemaSet, particles); - } - } - return particles; - } - } - - internal struct RangePositionInfo - { - public BitSet curpos; - public decimal[] rangeCounters; - } - - internal sealed class RangeContentValidator : ContentValidator - { - private BitSet _firstpos; - private BitSet[] _followpos; - private BitSet _positionsWithRangeTerminals; - private SymbolsDictionary _symbols; - private Positions _positions; - private int _minMaxNodesCount; - private int _endMarkerPos; - - internal RangeContentValidator( - BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, XmlSchemaContentType contentType, bool isEmptiable, BitSet positionsWithRangeTerminals, int minmaxNodesCount) : base(contentType, false, isEmptiable) - { - _firstpos = firstpos; - _followpos = followpos; - _symbols = symbols; - _positions = positions; - _positionsWithRangeTerminals = positionsWithRangeTerminals; - _minMaxNodesCount = minmaxNodesCount; - _endMarkerPos = endMarkerPos; - } - - public override void InitValidation(ValidationState context) - { - int positionsCount = _positions.Count; - List runningPositions = context.RunningPositions; - if (runningPositions != null) - { - Debug.Assert(_minMaxNodesCount != 0); - runningPositions.Clear(); - } - else - { - runningPositions = new List(); - context.RunningPositions = runningPositions; - } - RangePositionInfo rposInfo = new RangePositionInfo(); - rposInfo.curpos = _firstpos.Clone(); - - rposInfo.rangeCounters = new decimal[_minMaxNodesCount]; - runningPositions.Add(rposInfo); - context.CurrentState.NumberOfRunningPos = 1; - context.HasMatched = rposInfo.curpos.Get(_endMarkerPos); - } - - public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - errorCode = 0; - int symbol = _symbols[name]; - bool hasSeenFinalPosition = false; - List runningPositions = context.RunningPositions; - int matchCount = context.CurrentState.NumberOfRunningPos; - int k = 0; - RangePositionInfo rposInfo; - - int pos = -1; - int firstMatchedIndex = -1; - bool matched = false; - -#if RANGE_DEBUG - WriteRunningPositions("Current running positions to match", runningPositions, name, matchCount); -#endif - - while (k < matchCount) - { //we are looking for the first match in the list of bitsets - rposInfo = runningPositions[k]; - BitSet curpos = rposInfo.curpos; - for (int matchpos = curpos.NextSet(-1); matchpos != -1; matchpos = curpos.NextSet(matchpos)) - { //In all sets, have to scan all positions because of Disabled UPA possibility - if (symbol == _positions[matchpos].symbol) - { - pos = matchpos; - if (firstMatchedIndex == -1) - { // get the first match for this symbol - firstMatchedIndex = k; - } - matched = true; - break; - } - } - if (matched && _positions[pos].particle is XmlSchemaElement) - { //We found a match in the list, break at that bitset - break; - } - else - { - k++; - } - } - - if (k == matchCount && pos != -1) - { // we did find a match but that was any and hence continued ahead for element - k = firstMatchedIndex; - } - if (k < matchCount) - { //There is a match - if (k != 0) - { //If the first bitset itself matched, then no need to remove anything -#if RANGE_DEBUG - WriteRunningPositions("Removing unmatched entries till the first match", runningPositions, XmlQualifiedName.Empty, k); -#endif - runningPositions.RemoveRange(0, k); //Delete entries from 0 to k-1 - } - matchCount = matchCount - k; - k = 0; // Since we re-sized the array - while (k < matchCount) - { - rposInfo = runningPositions[k]; - matched = rposInfo.curpos.Get(pos); //Look for the bitset that matches the same position as pos - if (matched) - { //If match found, get the follow positions of the current matched position -#if RANGE_DEBUG - Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "Matched position: " + pos + " "); SequenceNode.WriteBitSet(rposInfo.curpos); - Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "Follow pos of Matched position: "); SequenceNode.WriteBitSet(followpos[pos]); -#endif - rposInfo.curpos = _followpos[pos]; //Note that we are copying the same counters of the current position to that of the follow position - runningPositions[k] = rposInfo; - k++; - } - else - { //Clear the current pos and get another position from the list to start matching - matchCount--; - if (matchCount > 0) - { - RangePositionInfo lastrpos = runningPositions[matchCount]; - runningPositions[matchCount] = runningPositions[k]; - runningPositions[k] = lastrpos; - } - } - } - } - else - { //There is no match - matchCount = 0; - } - - if (matchCount > 0) - { - Debug.Assert(_minMaxNodesCount > 0); - if (matchCount >= 10000) - { - context.TooComplex = true; - matchCount /= 2; - } -#if RANGE_DEBUG - WriteRunningPositions("Matched positions to expand ", runningPositions, name, matchCount); -#endif - - for (k = matchCount - 1; k >= 0; k--) - { - int j = k; - BitSet currentRunningPosition = runningPositions[k].curpos; - hasSeenFinalPosition = hasSeenFinalPosition || currentRunningPosition.Get(_endMarkerPos); //Accepting position reached if the current position BitSet contains the endPosition - while (matchCount < 10000 && currentRunningPosition.Intersects(_positionsWithRangeTerminals)) - { - //Now might add 2 more positions to followpos - //1. nextIteration of the rangeNode, which is firstpos of its parent's leftChild - //2. Followpos of the range node - - BitSet countingPosition = currentRunningPosition.Clone(); - countingPosition.And(_positionsWithRangeTerminals); - int cPos = countingPosition.NextSet(-1); //Get the first position where leaf range node appears - LeafRangeNode lrNode = _positions[cPos].particle as LeafRangeNode; //For a position with leaf range node, the particle is the node itself - Debug.Assert(lrNode != null); - - rposInfo = runningPositions[j]; - if (matchCount + 2 >= runningPositions.Count) - { - runningPositions.Add(new RangePositionInfo()); - runningPositions.Add(new RangePositionInfo()); - } - RangePositionInfo newRPosInfo = runningPositions[matchCount]; - if (newRPosInfo.rangeCounters == null) - { - newRPosInfo.rangeCounters = new decimal[_minMaxNodesCount]; - } - Array.Copy(rposInfo.rangeCounters, 0, newRPosInfo.rangeCounters, 0, rposInfo.rangeCounters.Length); - decimal count = ++newRPosInfo.rangeCounters[lrNode.Pos]; - - if (count == lrNode.Max) - { - newRPosInfo.curpos = _followpos[cPos]; //since max has been reached, Get followposition of range node - newRPosInfo.rangeCounters[lrNode.Pos] = 0; //reset counter - runningPositions[matchCount] = newRPosInfo; - j = matchCount++; - } - else if (count < lrNode.Min) - { - newRPosInfo.curpos = lrNode.NextIteration; - runningPositions[matchCount] = newRPosInfo; - matchCount++; - break; - } - else - { // min <= count < max - newRPosInfo.curpos = lrNode.NextIteration; //set currentpos to firstpos of node which has the range - runningPositions[matchCount] = newRPosInfo; - j = matchCount + 1; - newRPosInfo = runningPositions[j]; - if (newRPosInfo.rangeCounters == null) - { - newRPosInfo.rangeCounters = new decimal[_minMaxNodesCount]; - } - Array.Copy(rposInfo.rangeCounters, 0, newRPosInfo.rangeCounters, 0, rposInfo.rangeCounters.Length); - newRPosInfo.curpos = _followpos[cPos]; - newRPosInfo.rangeCounters[lrNode.Pos] = 0; - runningPositions[j] = newRPosInfo; - matchCount += 2; - } - currentRunningPosition = runningPositions[j].curpos; - hasSeenFinalPosition = hasSeenFinalPosition || currentRunningPosition.Get(_endMarkerPos); - } - } - context.HasMatched = hasSeenFinalPosition; - context.CurrentState.NumberOfRunningPos = matchCount; - return _positions[pos].particle; - } //matchcount > 0 - errorCode = -1; - context.NeedValidateChildren = false; - return null; - } - -#if RANGE_DEBUG - private void WriteRunningPositions(string text, List runningPositions, XmlQualifiedName name, int length) { - int counter = 0; - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, text + name.Name); - while (counter < length) { - BitSet curpos = runningPositions[counter].curpos; - SequenceNode.WriteBitSet(curpos); - for(int rcnt = 0; rcnt < runningPositions[counter].rangeCounters.Length; rcnt++) { - Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "RangeCounter[" + rcnt + "]" + runningPositions[counter].rangeCounters[rcnt] + " "); - } - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); - // // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); - counter++; - } - } -#endif - public override bool CompleteValidation(ValidationState context) - { - return context.HasMatched; - } - - public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) - { - ArrayList names = null; - BitSet expectedPos; - if (context.RunningPositions != null) - { - List runningPositions = context.RunningPositions; - expectedPos = new BitSet(_positions.Count); - for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--) - { - Debug.Assert(runningPositions[i].curpos != null); - expectedPos.Or(runningPositions[i].curpos); - } - for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) - { - if (names == null) - { - names = new ArrayList(); - } - int symbol = _positions[pos].symbol; - if (symbol >= 0) - { //non range nodes - XmlSchemaParticle p = _positions[pos].particle as XmlSchemaParticle; - if (p == null) - { - string s = _symbols.NameOf(_positions[pos].symbol); - if (s.Length != 0) - { - names.Add(s); - } - } - else - { - string s = p.NameString; - if (!names.Contains(s)) - { - names.Add(s); - } - } - } - } - } - return names; - } - - public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) - { - ArrayList particles = new ArrayList(); - BitSet expectedPos; - if (context.RunningPositions != null) - { - List runningPositions = context.RunningPositions; - expectedPos = new BitSet(_positions.Count); - for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--) - { - Debug.Assert(runningPositions[i].curpos != null); - expectedPos.Or(runningPositions[i].curpos); - } - for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) - { - int symbol = _positions[pos].symbol; - if (symbol >= 0) - { //non range nodes - XmlSchemaParticle p = _positions[pos].particle as XmlSchemaParticle; - if (p == null) - { - continue; - } - AddParticleToExpected(p, schemaSet, particles); - } - } - } - return particles; - } - } - - internal sealed class AllElementsContentValidator : ContentValidator - { - private Hashtable _elements; // unique terminal names to positions in Bitset mapping - private object[] _particles; - private BitSet _isRequired; // required flags - private int _countRequired = 0; - - public AllElementsContentValidator(XmlSchemaContentType contentType, int size, bool isEmptiable) : base(contentType, false, isEmptiable) - { - _elements = new Hashtable(size); - _particles = new object[size]; - _isRequired = new BitSet(size); - } - - public bool AddElement(XmlQualifiedName name, object particle, bool isEmptiable) - { - if (_elements[name] != null) - { - return false; - } - int i = _elements.Count; - _elements.Add(name, i); - _particles[i] = particle; - if (!isEmptiable) - { - _isRequired.Set(i); - _countRequired++; - } - return true; - } - - public override bool IsEmptiable - { - get { return base.IsEmptiable || _countRequired == 0; } - } - - public override void InitValidation(ValidationState context) - { - Debug.Assert(_elements.Count > 0); - context.AllElementsSet = new BitSet(_elements.Count); //TODO if already non-null can clear - context.CurrentState.AllElementsRequired = -1; // no elements at all - } - - public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) - { - object lookup = _elements[name]; - errorCode = 0; - if (lookup == null) - { - context.NeedValidateChildren = false; - return null; - } - int index = (int)lookup; - if (context.AllElementsSet[index]) - { - errorCode = -2; - return null; - } - if (context.CurrentState.AllElementsRequired == -1) - { - context.CurrentState.AllElementsRequired = 0; - } - context.AllElementsSet.Set(index); - if (_isRequired[index]) - { - context.CurrentState.AllElementsRequired++; - } - return _particles[index]; - } - - public override bool CompleteValidation(ValidationState context) - { - if (context.CurrentState.AllElementsRequired == _countRequired || IsEmptiable && context.CurrentState.AllElementsRequired == -1) - { - return true; - } - return false; - } - - public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) - { - ArrayList names = null; - foreach (DictionaryEntry entry in _elements) - { - if (!context.AllElementsSet[(int)entry.Value] && (!isRequiredOnly || _isRequired[(int)entry.Value])) - { - if (names == null) - { - names = new ArrayList(); - } - names.Add(entry.Key); - } - } - return names; - } - - public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) - { - ArrayList expectedParticles = new ArrayList(); - foreach (DictionaryEntry entry in _elements) - { - if (!context.AllElementsSet[(int)entry.Value] && (!isRequiredOnly || _isRequired[(int)entry.Value])) - { - AddParticleToExpected(_particles[(int)entry.Value] as XmlSchemaParticle, schemaSet, expectedParticles); - } - } - return expectedParticles; - } - } - #endregion -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DatatypeImplementation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DatatypeImplementation.cs deleted file mode 100644 index 9d7f0e075d6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DatatypeImplementation.cs +++ /dev/null @@ -1,3998 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.IO; - using System.Collections; - using System.Diagnostics; - using System.Globalization; - using System.Text; - using System.Text.RegularExpressions; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - using Microsoft.Xml.Serialization; - using System.Reflection; - - /// - public enum XmlSchemaDatatypeVariety - { - /// - Atomic, - /// - List, - /// - Union - } - - internal class XsdSimpleValue - { //Wrapper to store XmlType and TypedValue together - private XmlSchemaSimpleType _xmlType; - private object _typedValue; - - public XsdSimpleValue(XmlSchemaSimpleType st, object value) - { - _xmlType = st; - _typedValue = value; - } - - public XmlSchemaSimpleType XmlType - { - get - { - return _xmlType; - } - } - - public object TypedValue - { - get - { - return _typedValue; - } - } - } - - - [Flags] - internal enum RestrictionFlags - { - Length = 0x0001, - MinLength = 0x0002, - MaxLength = 0x0004, - Pattern = 0x0008, - Enumeration = 0x0010, - WhiteSpace = 0x0020, - MaxInclusive = 0x0040, - MaxExclusive = 0x0080, - MinInclusive = 0x0100, - MinExclusive = 0x0200, - TotalDigits = 0x0400, - FractionDigits = 0x0800, - } - - internal enum XmlSchemaWhiteSpace - { - Preserve, - Replace, - Collapse, - } - - internal class RestrictionFacets - { - internal int Length; - internal int MinLength; - internal int MaxLength; - internal ArrayList Patterns; - internal ArrayList Enumeration; - internal XmlSchemaWhiteSpace WhiteSpace; - internal object MaxInclusive; - internal object MaxExclusive; - internal object MinInclusive; - internal object MinExclusive; - internal int TotalDigits; - internal int FractionDigits; - internal RestrictionFlags Flags = 0; - internal RestrictionFlags FixedFlags = 0; - } - - internal abstract class DatatypeImplementation : XmlSchemaDatatype - { - private XmlSchemaDatatypeVariety _variety = XmlSchemaDatatypeVariety.Atomic; - private RestrictionFacets _restriction = null; - private DatatypeImplementation _baseType = null; - private XmlValueConverter _valueConverter; - private XmlSchemaType _parentSchemaType; - - private static Hashtable s_builtinTypes = new Hashtable(); - private static XmlSchemaSimpleType[] s_enumToTypeCode = new XmlSchemaSimpleType[(int)XmlTypeCode.DayTimeDuration + 1]; - private static XmlSchemaSimpleType s_anySimpleType; - private static XmlSchemaSimpleType s_anyAtomicType; - private static XmlSchemaSimpleType s_untypedAtomicType; - private static XmlSchemaSimpleType s_yearMonthDurationType; - private static XmlSchemaSimpleType s_dayTimeDurationType; - private static volatile XmlSchemaSimpleType s_normalizedStringTypeV1Compat; - private static volatile XmlSchemaSimpleType s_tokenTypeV1Compat; - - private const int anySimpleTypeIndex = 11; - - internal static XmlQualifiedName QnAnySimpleType = new XmlQualifiedName("anySimpleType", XmlReservedNs.NsXs); - internal static XmlQualifiedName QnAnyType = new XmlQualifiedName("anyType", XmlReservedNs.NsXs); - - //Create facet checkers - internal static FacetsChecker stringFacetsChecker = new StringFacetsChecker(); - internal static FacetsChecker miscFacetsChecker = new MiscFacetsChecker(); - internal static FacetsChecker numeric2FacetsChecker = new Numeric2FacetsChecker(); - internal static FacetsChecker binaryFacetsChecker = new BinaryFacetsChecker(); - internal static FacetsChecker dateTimeFacetsChecker = new DateTimeFacetsChecker(); - internal static FacetsChecker durationFacetsChecker = new DurationFacetsChecker(); - internal static FacetsChecker listFacetsChecker = new ListFacetsChecker(); - internal static FacetsChecker qnameFacetsChecker = new QNameFacetsChecker(); - internal static FacetsChecker unionFacetsChecker = new UnionFacetsChecker(); - - static DatatypeImplementation() - { - CreateBuiltinTypes(); - } - - internal static XmlSchemaSimpleType AnySimpleType { get { return s_anySimpleType; } } - - // Additional built-in XQuery simple types - internal static XmlSchemaSimpleType AnyAtomicType { get { return s_anyAtomicType; } } - internal static XmlSchemaSimpleType UntypedAtomicType { get { return s_untypedAtomicType; } } - internal static XmlSchemaSimpleType YearMonthDurationType { get { return s_yearMonthDurationType; } } - internal static XmlSchemaSimpleType DayTimeDurationType { get { return s_dayTimeDurationType; } } - - internal new static DatatypeImplementation FromXmlTokenizedType(XmlTokenizedType token) - { - return s_tokenizedTypes[(int)token]; - } - - internal new static DatatypeImplementation FromXmlTokenizedTypeXsd(XmlTokenizedType token) - { - return s_tokenizedTypesXsd[(int)token]; - } - - internal new static DatatypeImplementation FromXdrName(string name) - { - int i = Array.BinarySearch(s_xdrTypes, name, null); - return i < 0 ? null : (DatatypeImplementation)s_xdrTypes[i]; - } - - private static DatatypeImplementation FromTypeName(string name) - { - int i = Array.BinarySearch(s_xsdTypes, name, null); - return i < 0 ? null : (DatatypeImplementation)s_xsdTypes[i]; - } - - /// - /// Begin the creation of an XmlSchemaSimpleType object that will be used to represent a static built-in type. - /// Once StartBuiltinType has been called for all built-in types, FinishBuiltinType should be called in order - /// to create links between the types. - /// - internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType) - { - XmlSchemaSimpleType simpleType; - Debug.Assert(qname != null && dataType != null); - - simpleType = new XmlSchemaSimpleType(); - simpleType.SetQualifiedName(qname); - simpleType.SetDatatype(dataType); - simpleType.ElementDecl = new SchemaElementDecl(dataType); - simpleType.ElementDecl.SchemaType = simpleType; - - return simpleType; - } - - /// - /// Finish constructing built-in types by setting up derivation and list links. - /// - internal static void FinishBuiltinType(XmlSchemaSimpleType derivedType, XmlSchemaSimpleType baseType) - { - Debug.Assert(derivedType != null && baseType != null); - - // Create link from the derived type to the base type - derivedType.SetBaseSchemaType(baseType); - derivedType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) - { //Content is restriction - XmlSchemaSimpleTypeRestriction restContent = new XmlSchemaSimpleTypeRestriction(); - restContent.BaseTypeName = baseType.QualifiedName; - derivedType.Content = restContent; - } - - // Create link from a list type to its member type - if (derivedType.Datatype.Variety == XmlSchemaDatatypeVariety.List) - { - XmlSchemaSimpleTypeList listContent = new XmlSchemaSimpleTypeList(); - derivedType.SetDerivedBy(XmlSchemaDerivationMethod.List); - switch (derivedType.Datatype.TypeCode) - { - case XmlTypeCode.NmToken: - listContent.ItemType = listContent.BaseItemType = s_enumToTypeCode[(int)XmlTypeCode.NmToken]; - break; - - case XmlTypeCode.Entity: - listContent.ItemType = listContent.BaseItemType = s_enumToTypeCode[(int)XmlTypeCode.Entity]; - break; - - case XmlTypeCode.Idref: - listContent.ItemType = listContent.BaseItemType = s_enumToTypeCode[(int)XmlTypeCode.Idref]; - break; - } - derivedType.Content = listContent; - } - } - - internal static void CreateBuiltinTypes() - { - XmlQualifiedName qname; - - //Build anySimpleType - SchemaDatatypeMap sdm = s_xsdTypes[anySimpleTypeIndex]; //anySimpleType - qname = new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs); - DatatypeImplementation dt = FromTypeName(qname.Name); - s_anySimpleType = StartBuiltinType(qname, dt); - dt._parentSchemaType = s_anySimpleType; - s_builtinTypes.Add(qname, s_anySimpleType); - - // Start construction of each built-in Xsd type - XmlSchemaSimpleType simpleType; - for (int i = 0; i < s_xsdTypes.Length; i++) - { //Create all types - if (i == anySimpleTypeIndex) - { //anySimpleType - continue; - } - sdm = s_xsdTypes[i]; - - qname = new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs); - dt = FromTypeName(qname.Name); - simpleType = StartBuiltinType(qname, dt); - dt._parentSchemaType = simpleType; - - s_builtinTypes.Add(qname, simpleType); - if (dt._variety == XmlSchemaDatatypeVariety.Atomic) - { - s_enumToTypeCode[(int)dt.TypeCode] = simpleType; - } - } - - // Finish construction of each built-in Xsd type - for (int i = 0; i < s_xsdTypes.Length; i++) - { - if (i == anySimpleTypeIndex) - { //anySimpleType - continue; - } - sdm = s_xsdTypes[i]; - XmlSchemaSimpleType derivedType = (XmlSchemaSimpleType)s_builtinTypes[new XmlQualifiedName(sdm.Name, XmlReservedNs.NsXs)]; - XmlSchemaSimpleType baseType; - - if (sdm.ParentIndex == anySimpleTypeIndex) - { - FinishBuiltinType(derivedType, s_anySimpleType); - } - else - { //derived types whose index > 0 - baseType = (XmlSchemaSimpleType)s_builtinTypes[new XmlQualifiedName(((SchemaDatatypeMap)(s_xsdTypes[sdm.ParentIndex])).Name, XmlReservedNs.NsXs)]; - FinishBuiltinType(derivedType, baseType); - } - } - - // Construct xdt:anyAtomicType type (derived from xs:anySimpleType) - qname = new XmlQualifiedName("anyAtomicType", XmlReservedNs.NsXQueryDataType); - s_anyAtomicType = StartBuiltinType(qname, s_c_anyAtomicType); - s_c_anyAtomicType._parentSchemaType = s_anyAtomicType; - FinishBuiltinType(s_anyAtomicType, s_anySimpleType); - s_builtinTypes.Add(qname, s_anyAtomicType); - s_enumToTypeCode[(int)XmlTypeCode.AnyAtomicType] = s_anyAtomicType; - - // Construct xdt:untypedAtomic type (derived from xdt:anyAtomicType) - qname = new XmlQualifiedName("untypedAtomic", XmlReservedNs.NsXQueryDataType); - s_untypedAtomicType = StartBuiltinType(qname, s_c_untypedAtomicType); - s_c_untypedAtomicType._parentSchemaType = s_untypedAtomicType; - FinishBuiltinType(s_untypedAtomicType, s_anyAtomicType); - s_builtinTypes.Add(qname, s_untypedAtomicType); - s_enumToTypeCode[(int)XmlTypeCode.UntypedAtomic] = s_untypedAtomicType; - - // Construct xdt:yearMonthDuration type (derived from xs:duration) - qname = new XmlQualifiedName("yearMonthDuration", XmlReservedNs.NsXQueryDataType); - s_yearMonthDurationType = StartBuiltinType(qname, s_yearMonthDuration); - s_yearMonthDuration._parentSchemaType = s_yearMonthDurationType; - FinishBuiltinType(s_yearMonthDurationType, s_enumToTypeCode[(int)XmlTypeCode.Duration]); - s_builtinTypes.Add(qname, s_yearMonthDurationType); - s_enumToTypeCode[(int)XmlTypeCode.YearMonthDuration] = s_yearMonthDurationType; - - // Construct xdt:dayTimeDuration type (derived from xs:duration) - qname = new XmlQualifiedName("dayTimeDuration", XmlReservedNs.NsXQueryDataType); - s_dayTimeDurationType = StartBuiltinType(qname, s_dayTimeDuration); - s_dayTimeDuration._parentSchemaType = s_dayTimeDurationType; - FinishBuiltinType(s_dayTimeDurationType, s_enumToTypeCode[(int)XmlTypeCode.Duration]); - s_builtinTypes.Add(qname, s_dayTimeDurationType); - s_enumToTypeCode[(int)XmlTypeCode.DayTimeDuration] = s_dayTimeDurationType; - } - - internal static XmlSchemaSimpleType GetSimpleTypeFromTypeCode(XmlTypeCode typeCode) - { - return s_enumToTypeCode[(int)typeCode]; - } - - internal static XmlSchemaSimpleType GetSimpleTypeFromXsdType(XmlQualifiedName qname) - { - return (XmlSchemaSimpleType)s_builtinTypes[qname]; - } - - internal static XmlSchemaSimpleType GetNormalizedStringTypeV1Compat() - { - if (s_normalizedStringTypeV1Compat == null) - { - XmlSchemaSimpleType correctType = GetSimpleTypeFromTypeCode(XmlTypeCode.NormalizedString); - XmlSchemaSimpleType tempNormalizedStringTypeV1Compat = correctType.Clone() as XmlSchemaSimpleType; - tempNormalizedStringTypeV1Compat.SetDatatype(c_normalizedStringV1Compat); - tempNormalizedStringTypeV1Compat.ElementDecl = new SchemaElementDecl(c_normalizedStringV1Compat); - tempNormalizedStringTypeV1Compat.ElementDecl.SchemaType = tempNormalizedStringTypeV1Compat; - s_normalizedStringTypeV1Compat = tempNormalizedStringTypeV1Compat; - } - return s_normalizedStringTypeV1Compat; - } - - internal static XmlSchemaSimpleType GetTokenTypeV1Compat() - { - if (s_tokenTypeV1Compat == null) - { - XmlSchemaSimpleType correctType = GetSimpleTypeFromTypeCode(XmlTypeCode.Token); - XmlSchemaSimpleType tempTokenTypeV1Compat = correctType.Clone() as XmlSchemaSimpleType; - tempTokenTypeV1Compat.SetDatatype(c_tokenV1Compat); - tempTokenTypeV1Compat.ElementDecl = new SchemaElementDecl(c_tokenV1Compat); - tempTokenTypeV1Compat.ElementDecl.SchemaType = tempTokenTypeV1Compat; - s_tokenTypeV1Compat = tempTokenTypeV1Compat; - } - return s_tokenTypeV1Compat; - } - - internal static XmlSchemaSimpleType[] GetBuiltInTypes() - { - return s_enumToTypeCode; - } - - internal static XmlTypeCode GetPrimitiveTypeCode(XmlTypeCode typeCode) - { - XmlSchemaSimpleType currentType = s_enumToTypeCode[(int)typeCode]; - while (currentType.BaseXmlSchemaType != DatatypeImplementation.AnySimpleType) - { - currentType = currentType.BaseXmlSchemaType as XmlSchemaSimpleType; - Debug.Assert(currentType != null); - } - return currentType.TypeCode; - } - - internal override XmlSchemaDatatype DeriveByRestriction(XmlSchemaObjectCollection facets, XmlNameTable nameTable, XmlSchemaType schemaType) - { - DatatypeImplementation dt = (DatatypeImplementation)MemberwiseClone(); - dt._restriction = this.FacetsChecker.ConstructRestriction(this, facets, nameTable); - dt._baseType = this; - dt._parentSchemaType = schemaType; - dt._valueConverter = null; //re-set old datatype's valueconverter - return dt; - } - - internal override XmlSchemaDatatype DeriveByList(XmlSchemaType schemaType) - { - return DeriveByList(0, schemaType); - } - - internal XmlSchemaDatatype DeriveByList(int minSize, XmlSchemaType schemaType) - { - if (_variety == XmlSchemaDatatypeVariety.List) - { - throw new XmlSchemaException(ResXml.Sch_ListFromNonatomic, string.Empty); - } - else if (_variety == XmlSchemaDatatypeVariety.Union && !((Datatype_union)this).HasAtomicMembers()) - { - throw new XmlSchemaException(ResXml.Sch_ListFromNonatomic, string.Empty); - } - DatatypeImplementation dt = new Datatype_List(this, minSize); - dt._variety = XmlSchemaDatatypeVariety.List; - dt._restriction = null; - dt._baseType = s_c_anySimpleType; //Base type of a union is anySimpleType - dt._parentSchemaType = schemaType; - return dt; - } - - internal new static DatatypeImplementation DeriveByUnion(XmlSchemaSimpleType[] types, XmlSchemaType schemaType) - { - DatatypeImplementation dt = new Datatype_union(types); - dt._baseType = s_c_anySimpleType; //Base type of a union is anySimpleType - dt._variety = XmlSchemaDatatypeVariety.Union; - dt._parentSchemaType = schemaType; - return dt; - } - - internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) {/*noop*/} - - public override bool IsDerivedFrom(XmlSchemaDatatype datatype) - { - if (datatype == null) - { - return false; - } - - //Common case - Derived by restriction - for (DatatypeImplementation dt = this; dt != null; dt = dt._baseType) - { - if (dt == datatype) - { - return true; - } - } - if (((DatatypeImplementation)datatype)._baseType == null) - { //Both are built-in types - Type derivedType = this.GetType(); - Type baseType = datatype.GetType(); - return baseType == derivedType || derivedType.GetTypeInfo().IsSubclassOf(baseType); - } - else if (datatype.Variety == XmlSchemaDatatypeVariety.Union && !datatype.HasLexicalFacets && !datatype.HasValueFacets && _variety != XmlSchemaDatatypeVariety.Union) - { //base type is union (not a restriction of union) and derived type is not union - return ((Datatype_union)datatype).IsUnionBaseOf(this); - } - else if ((_variety == XmlSchemaDatatypeVariety.Union || _variety == XmlSchemaDatatypeVariety.List) && _restriction == null) - { //derived type is union (not a restriction) - return (datatype == s_anySimpleType.Datatype); - } - return false; - } - - internal override bool IsEqual(object o1, object o2) - { - //// Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceVerbose, string.Format("\t\tSchemaDatatype.IsEqual({0}, {1})", o1, o2)); - return Compare(o1, o2) == 0; - } - - internal override bool IsComparable(XmlSchemaDatatype dtype) - { - XmlTypeCode thisCode = this.TypeCode; - XmlTypeCode otherCode = dtype.TypeCode; - - if (thisCode == otherCode) - { //They are both same built-in type or one is list and the other is list's itemType - return true; - } - if (GetPrimitiveTypeCode(thisCode) == GetPrimitiveTypeCode(otherCode)) - { - return true; - } - if (this.IsDerivedFrom(dtype) || dtype.IsDerivedFrom(this)) - { //One is union and the other is a member of the union - return true; - } - return false; - } - - internal virtual XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) { return null; } - - internal override FacetsChecker FacetsChecker { get { return miscFacetsChecker; } } - - internal override XmlValueConverter ValueConverter - { - get - { - if (_valueConverter == null) - { - _valueConverter = CreateValueConverter(_parentSchemaType); - } - return _valueConverter; - } - } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.None; } } - - public override Type ValueType { get { return typeof(string); } } - - public override XmlSchemaDatatypeVariety Variety { get { return _variety; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.None; } } - - internal override RestrictionFacets Restriction - { - get - { - return _restriction; - } - set - { - _restriction = value; - } - } - internal override bool HasLexicalFacets - { - get - { - RestrictionFlags flags = _restriction != null ? _restriction.Flags : 0; - if (flags != 0 && (flags & (RestrictionFlags.Pattern | RestrictionFlags.WhiteSpace | RestrictionFlags.TotalDigits | RestrictionFlags.FractionDigits)) != 0) - { - return true; - } - return false; - } - } - internal override bool HasValueFacets - { - get - { - RestrictionFlags flags = _restriction != null ? _restriction.Flags : 0; - if (flags != 0 && (flags & (RestrictionFlags.Length | RestrictionFlags.MinLength | RestrictionFlags.MaxLength | RestrictionFlags.MaxExclusive | RestrictionFlags.MaxInclusive | RestrictionFlags.MinExclusive | RestrictionFlags.MinInclusive | RestrictionFlags.TotalDigits | RestrictionFlags.FractionDigits | RestrictionFlags.Enumeration)) != 0) - { - return true; - } - return false; - } - } - - protected DatatypeImplementation Base { get { return _baseType; } } - - internal abstract Type ListValueType { get; } - - internal abstract RestrictionFlags ValidRestrictionFlags { get; } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Preserve; } } - - internal override object ParseValue(string s, Type typDest, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - return ValueConverter.ChangeType(ParseValue(s, nameTable, nsmgr), typDest, nsmgr); - } - - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - object typedValue; - Exception exception = TryParseValue(s, nameTable, nsmgr, out typedValue); - if (exception != null) - { - throw new XmlSchemaException(ResXml.Sch_InvalidValueDetailed, new string[] { s, GetTypeName(), exception.Message }, exception, null, 0, 0, null); - } - if (this.Variety == XmlSchemaDatatypeVariety.Union) - { - XsdSimpleValue simpleValue = typedValue as XsdSimpleValue; - return simpleValue.TypedValue; - } - return typedValue; - } - - internal override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, bool createAtomicValue) - { - if (createAtomicValue) - { - object typedValue; - Exception exception = TryParseValue(s, nameTable, nsmgr, out typedValue); - if (exception != null) - { - throw new XmlSchemaException(ResXml.Sch_InvalidValueDetailed, new string[] { s, GetTypeName(), exception.Message }, exception, null, 0, 0, null); - } - return typedValue; - } - else - { - return ParseValue(s, nameTable, nsmgr); - } - } - - internal override Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver namespaceResolver, out object typedValue) - { - Exception exception = null; - typedValue = null; - if (value == null) - { - return new ArgumentNullException("value"); - } - string s = value as string; - if (s != null) - { - return TryParseValue(s, nameTable, namespaceResolver, out typedValue); - } - try - { - object valueToCheck = value; - if (value.GetType() != this.ValueType) - { - valueToCheck = this.ValueConverter.ChangeType(value, this.ValueType, namespaceResolver); - } - if (this.HasLexicalFacets) - { - string s1 = (string)this.ValueConverter.ChangeType(value, typeof(System.String), namespaceResolver); //Using value here to avoid info loss - exception = this.FacetsChecker.CheckLexicalFacets(ref s1, this); - if (exception != null) goto Error; - } - if (this.HasValueFacets) - { - exception = this.FacetsChecker.CheckValueFacets(valueToCheck, this); - if (exception != null) goto Error; - } - typedValue = valueToCheck; - return null; - } - catch (FormatException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (InvalidCastException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (OverflowException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (ArgumentException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - - Error: - return exception; - } - - internal string GetTypeName() - { - XmlSchemaType simpleType = _parentSchemaType; - string typeName; - if (simpleType == null || simpleType.QualifiedName.IsEmpty) - { //If no QName, get typecode, no line info since it is not pertinent without file name - typeName = TypeCodeString; - } - else - { - typeName = simpleType.QualifiedName.ToString(); - } - return typeName; - } - - // XSD types - static private readonly DatatypeImplementation s_c_anySimpleType = new Datatype_anySimpleType(); - static private readonly DatatypeImplementation s_anyURI = new Datatype_anyURI(); - static private readonly DatatypeImplementation s_base64Binary = new Datatype_base64Binary(); - static private readonly DatatypeImplementation s_boolean = new Datatype_boolean(); - static private readonly DatatypeImplementation s_byte = new Datatype_byte(); - static private readonly DatatypeImplementation s_char = new Datatype_char(); // XDR - static private readonly DatatypeImplementation s_date = new Datatype_date(); - static private readonly DatatypeImplementation s_dateTime = new Datatype_dateTime(); - static private readonly DatatypeImplementation s_dateTimeNoTz = new Datatype_dateTimeNoTimeZone(); // XDR - static private readonly DatatypeImplementation s_dateTimeTz = new Datatype_dateTimeTimeZone(); // XDR - static private readonly DatatypeImplementation s_day = new Datatype_day(); - static private readonly DatatypeImplementation s_decimal = new Datatype_decimal(); - static private readonly DatatypeImplementation s_double = new Datatype_double(); - static private readonly DatatypeImplementation s_doubleXdr = new Datatype_doubleXdr(); // XDR - static private readonly DatatypeImplementation s_duration = new Datatype_duration(); - static private readonly DatatypeImplementation s_ENTITY = new Datatype_ENTITY(); - static private readonly DatatypeImplementation s_ENTITIES = (DatatypeImplementation)s_ENTITY.DeriveByList(1, null); - static private readonly DatatypeImplementation s_ENUMERATION = new Datatype_ENUMERATION(); // XDR - static private readonly DatatypeImplementation s_fixed = new Datatype_fixed(); - static private readonly DatatypeImplementation s_float = new Datatype_float(); - static private readonly DatatypeImplementation s_floatXdr = new Datatype_floatXdr(); // XDR - static private readonly DatatypeImplementation s_hexBinary = new Datatype_hexBinary(); - static private readonly DatatypeImplementation s_ID = new Datatype_ID(); - static private readonly DatatypeImplementation s_IDREF = new Datatype_IDREF(); - static private readonly DatatypeImplementation s_IDREFS = (DatatypeImplementation)s_IDREF.DeriveByList(1, null); - static private readonly DatatypeImplementation s_int = new Datatype_int(); - static private readonly DatatypeImplementation s_integer = new Datatype_integer(); - static private readonly DatatypeImplementation s_language = new Datatype_language(); - static private readonly DatatypeImplementation s_long = new Datatype_long(); - static private readonly DatatypeImplementation s_month = new Datatype_month(); - static private readonly DatatypeImplementation s_monthDay = new Datatype_monthDay(); - static private readonly DatatypeImplementation s_name = new Datatype_Name(); - static private readonly DatatypeImplementation s_NCName = new Datatype_NCName(); - static private readonly DatatypeImplementation s_negativeInteger = new Datatype_negativeInteger(); - static private readonly DatatypeImplementation s_NMTOKEN = new Datatype_NMTOKEN(); - static private readonly DatatypeImplementation s_NMTOKENS = (DatatypeImplementation)s_NMTOKEN.DeriveByList(1, null); - static private readonly DatatypeImplementation s_nonNegativeInteger = new Datatype_nonNegativeInteger(); - static private readonly DatatypeImplementation s_nonPositiveInteger = new Datatype_nonPositiveInteger(); - static private readonly DatatypeImplementation s_normalizedString = new Datatype_normalizedString(); - static private readonly DatatypeImplementation s_NOTATION = new Datatype_NOTATION(); - static private readonly DatatypeImplementation s_positiveInteger = new Datatype_positiveInteger(); - static private readonly DatatypeImplementation s_QName = new Datatype_QName(); - static private readonly DatatypeImplementation s_QNameXdr = new Datatype_QNameXdr(); //XDR - static private readonly DatatypeImplementation s_short = new Datatype_short(); - static private readonly DatatypeImplementation s_string = new Datatype_string(); - static private readonly DatatypeImplementation s_time = new Datatype_time(); - static private readonly DatatypeImplementation s_timeNoTz = new Datatype_timeNoTimeZone(); // XDR - static private readonly DatatypeImplementation s_timeTz = new Datatype_timeTimeZone(); // XDR - static private readonly DatatypeImplementation s_token = new Datatype_token(); - static private readonly DatatypeImplementation s_unsignedByte = new Datatype_unsignedByte(); - static private readonly DatatypeImplementation s_unsignedInt = new Datatype_unsignedInt(); - static private readonly DatatypeImplementation s_unsignedLong = new Datatype_unsignedLong(); - static private readonly DatatypeImplementation s_unsignedShort = new Datatype_unsignedShort(); - static private readonly DatatypeImplementation s_uuid = new Datatype_uuid(); // XDR - static private readonly DatatypeImplementation s_year = new Datatype_year(); - static private readonly DatatypeImplementation s_yearMonth = new Datatype_yearMonth(); - - //V1 compat types - static internal readonly DatatypeImplementation c_normalizedStringV1Compat = new Datatype_normalizedStringV1Compat(); - static internal readonly DatatypeImplementation c_tokenV1Compat = new Datatype_tokenV1Compat(); - - // XQuery types - static private readonly DatatypeImplementation s_c_anyAtomicType = new Datatype_anyAtomicType(); - static private readonly DatatypeImplementation s_dayTimeDuration = new Datatype_dayTimeDuration(); - static private readonly DatatypeImplementation s_c_untypedAtomicType = new Datatype_untypedAtomicType(); - static private readonly DatatypeImplementation s_yearMonthDuration = new Datatype_yearMonthDuration(); - - - private class SchemaDatatypeMap : IComparable - { - private string _name; - private DatatypeImplementation _type; - private int _parentIndex; - - internal SchemaDatatypeMap(string name, DatatypeImplementation type) - { - _name = name; - _type = type; - } - - internal SchemaDatatypeMap(string name, DatatypeImplementation type, int parentIndex) - { - _name = name; - _type = type; - _parentIndex = parentIndex; - } - public static explicit operator DatatypeImplementation(SchemaDatatypeMap sdm) { return sdm._type; } - - public string Name - { - get - { - return _name; - } - } - - public int ParentIndex - { - get - { - return _parentIndex; - } - } - - public int CompareTo(object obj) { return string.Compare(_name, (string)obj, StringComparison.Ordinal); } - } - - private static readonly DatatypeImplementation[] s_tokenizedTypes = { - s_string, // CDATA - s_ID, // ID - s_IDREF, // IDREF - s_IDREFS, // IDREFS - s_ENTITY, // ENTITY - s_ENTITIES, // ENTITIES - s_NMTOKEN, // NMTOKEN - s_NMTOKENS, // NMTOKENS - s_NOTATION, // NOTATION - s_ENUMERATION, // ENUMERATION - s_QNameXdr, // QName - s_NCName, // NCName - null - }; - - private static readonly DatatypeImplementation[] s_tokenizedTypesXsd = { - s_string, // CDATA - s_ID, // ID - s_IDREF, // IDREF - s_IDREFS, // IDREFS - s_ENTITY, // ENTITY - s_ENTITIES, // ENTITIES - s_NMTOKEN, // NMTOKEN - s_NMTOKENS, // NMTOKENS - s_NOTATION, // NOTATION - s_ENUMERATION, // ENUMERATION - s_QName, // QName - s_NCName, // NCName - null - }; - - private static readonly SchemaDatatypeMap[] s_xdrTypes = { - new SchemaDatatypeMap("bin.base64", s_base64Binary), - new SchemaDatatypeMap("bin.hex", s_hexBinary), - new SchemaDatatypeMap("boolean", s_boolean), - new SchemaDatatypeMap("char", s_char), - new SchemaDatatypeMap("date", s_date), - new SchemaDatatypeMap("dateTime", s_dateTimeNoTz), - new SchemaDatatypeMap("dateTime.tz", s_dateTimeTz), - new SchemaDatatypeMap("decimal", s_decimal), - new SchemaDatatypeMap("entities", s_ENTITIES), - new SchemaDatatypeMap("entity", s_ENTITY), - new SchemaDatatypeMap("enumeration", s_ENUMERATION), - new SchemaDatatypeMap("fixed.14.4", s_fixed), - new SchemaDatatypeMap("float", s_doubleXdr), - new SchemaDatatypeMap("float.ieee.754.32", s_floatXdr), - new SchemaDatatypeMap("float.ieee.754.64", s_doubleXdr), - new SchemaDatatypeMap("i1", s_byte), - new SchemaDatatypeMap("i2", s_short), - new SchemaDatatypeMap("i4", s_int), - new SchemaDatatypeMap("i8", s_long), - new SchemaDatatypeMap("id", s_ID), - new SchemaDatatypeMap("idref", s_IDREF), - new SchemaDatatypeMap("idrefs", s_IDREFS), - new SchemaDatatypeMap("int", s_int), - new SchemaDatatypeMap("nmtoken", s_NMTOKEN), - new SchemaDatatypeMap("nmtokens", s_NMTOKENS), - new SchemaDatatypeMap("notation", s_NOTATION), - new SchemaDatatypeMap("number", s_doubleXdr), - new SchemaDatatypeMap("r4", s_floatXdr), - new SchemaDatatypeMap("r8", s_doubleXdr), - new SchemaDatatypeMap("string", s_string), - new SchemaDatatypeMap("time", s_timeNoTz), - new SchemaDatatypeMap("time.tz", s_timeTz), - new SchemaDatatypeMap("ui1", s_unsignedByte), - new SchemaDatatypeMap("ui2", s_unsignedShort), - new SchemaDatatypeMap("ui4", s_unsignedInt), - new SchemaDatatypeMap("ui8", s_unsignedLong), - new SchemaDatatypeMap("uri", s_anyURI), - new SchemaDatatypeMap("uuid", s_uuid) - }; - - - private static readonly SchemaDatatypeMap[] s_xsdTypes = { - new SchemaDatatypeMap("ENTITIES", s_ENTITIES, 11), - new SchemaDatatypeMap("ENTITY", s_ENTITY, 11), - new SchemaDatatypeMap("ID", s_ID, 5), - new SchemaDatatypeMap("IDREF", s_IDREF, 5), - new SchemaDatatypeMap("IDREFS", s_IDREFS, 11), - - new SchemaDatatypeMap("NCName", s_NCName, 9), - new SchemaDatatypeMap("NMTOKEN", s_NMTOKEN, 40), - new SchemaDatatypeMap("NMTOKENS", s_NMTOKENS, 11), - new SchemaDatatypeMap("NOTATION", s_NOTATION, 11), - - new SchemaDatatypeMap("Name", s_name, 40), - new SchemaDatatypeMap("QName", s_QName, 11), //-> 10 - - new SchemaDatatypeMap("anySimpleType", s_c_anySimpleType, -1), - new SchemaDatatypeMap("anyURI", s_anyURI, 11), - new SchemaDatatypeMap("base64Binary", s_base64Binary, 11), - new SchemaDatatypeMap("boolean", s_boolean, 11), - new SchemaDatatypeMap("byte", s_byte, 37), - new SchemaDatatypeMap("date", s_date, 11), - new SchemaDatatypeMap("dateTime", s_dateTime, 11), - new SchemaDatatypeMap("decimal", s_decimal, 11), - new SchemaDatatypeMap("double", s_double, 11), - new SchemaDatatypeMap("duration", s_duration, 11), //->20 - - new SchemaDatatypeMap("float", s_float, 11), - new SchemaDatatypeMap("gDay", s_day, 11), - new SchemaDatatypeMap("gMonth", s_month, 11), - new SchemaDatatypeMap("gMonthDay", s_monthDay, 11), - new SchemaDatatypeMap("gYear", s_year, 11), - new SchemaDatatypeMap("gYearMonth", s_yearMonth, 11), - new SchemaDatatypeMap("hexBinary", s_hexBinary, 11), - new SchemaDatatypeMap("int", s_int, 31), - new SchemaDatatypeMap("integer", s_integer, 18), - new SchemaDatatypeMap("language", s_language, 40), //->30 - new SchemaDatatypeMap("long", s_long, 29), - - new SchemaDatatypeMap("negativeInteger", s_negativeInteger, 34), - - new SchemaDatatypeMap("nonNegativeInteger", s_nonNegativeInteger, 29), - new SchemaDatatypeMap("nonPositiveInteger", s_nonPositiveInteger, 29), - new SchemaDatatypeMap("normalizedString", s_normalizedString, 38), - - new SchemaDatatypeMap("positiveInteger", s_positiveInteger, 33), - - new SchemaDatatypeMap("short", s_short, 28), - new SchemaDatatypeMap("string", s_string, 11), - new SchemaDatatypeMap("time", s_time, 11), - new SchemaDatatypeMap("token", s_token, 35), //->40 - new SchemaDatatypeMap("unsignedByte", s_unsignedByte, 44), - new SchemaDatatypeMap("unsignedInt", s_unsignedInt, 43), - new SchemaDatatypeMap("unsignedLong", s_unsignedLong, 33), - new SchemaDatatypeMap("unsignedShort", s_unsignedShort, 42), - }; - - protected int Compare(byte[] value1, byte[] value2) - { - int length = value1.Length; - if (length != value2.Length) - { - return -1; - } - for (int i = 0; i < length; i++) - { - if (value1[i] != value2[i]) - { - return -1; - } - } - return 0; - } - -#if PRIYAL - protected object GetValueToCheck(object value, IXmlNamespaceResolver nsmgr) { - object valueToCheck = value; - string resId; - if (CanConvert(value, value.GetType(), this.ValueType, out resId)) { - valueToCheck = this.ValueConverter.ChangeType(value, this.ValueType, nsmgr); - } - else { - throw new XmlSchemaException(resId, string.Empty); - } - return valueToCheck; - } -#endif - } - - - //List type - internal class Datatype_List : Datatype_anySimpleType - { - private DatatypeImplementation _itemType; - private int _minListSize; - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - XmlSchemaType listItemType = null; - XmlSchemaSimpleType simpleType; - XmlSchemaComplexType complexType; - complexType = schemaType as XmlSchemaComplexType; - - if (complexType != null) - { - do - { - simpleType = complexType.BaseXmlSchemaType as XmlSchemaSimpleType; - if (simpleType != null) - { - break; - } - complexType = complexType.BaseXmlSchemaType as XmlSchemaComplexType; - } while (complexType != null && complexType != XmlSchemaComplexType.AnyType); - } - else - { - simpleType = schemaType as XmlSchemaSimpleType; - } - if (simpleType != null) - { - do - { - XmlSchemaSimpleTypeList listType = simpleType.Content as XmlSchemaSimpleTypeList; - if (listType != null) - { - listItemType = listType.BaseItemType; - break; - } - simpleType = simpleType.BaseXmlSchemaType as XmlSchemaSimpleType; - } while (simpleType != null && simpleType != DatatypeImplementation.AnySimpleType); - } - - if (listItemType == null) - { //Get built-in simple type for the typecode - listItemType = DatatypeImplementation.GetSimpleTypeFromTypeCode(schemaType.Datatype.TypeCode); - } - - return XmlListConverter.Create(listItemType.ValueConverter); - } - - internal Datatype_List(DatatypeImplementation type) : this(type, 0) - { - } - internal Datatype_List(DatatypeImplementation type, int minListSize) - { - _itemType = type; - _minListSize = minListSize; - } - - internal override int Compare(object value1, object value2) - { - System.Array arr1 = (System.Array)value1; - System.Array arr2 = (System.Array)value2; - - Debug.Assert(arr1 != null && arr2 != null); - int length = arr1.Length; - if (length != arr2.Length) - { - return -1; - } - XmlAtomicValue[] atomicValues1 = arr1 as XmlAtomicValue[]; - if (atomicValues1 != null) - { - XmlAtomicValue[] atomicValues2 = arr2 as XmlAtomicValue[]; - Debug.Assert(atomicValues2 != null); - XmlSchemaType xmlType1; - for (int i = 0; i < atomicValues1.Length; i++) - { - xmlType1 = atomicValues1[i].XmlType; - if (xmlType1 != atomicValues2[i].XmlType || !xmlType1.Datatype.IsEqual(atomicValues1[i].TypedValue, atomicValues2[i].TypedValue)) - { - return -1; - } - } - return 0; - } - else - { - for (int i = 0; i < arr1.Length; i++) - { - if (_itemType.Compare(arr1.GetValue(i), arr2.GetValue(i)) != 0) - { - return -1; - } - } - return 0; - } - } - - public override Type ValueType { get { return ListValueType; } } - - public override XmlTokenizedType TokenizedType { get { return _itemType.TokenizedType; } } - - internal override Type ListValueType { get { return _itemType.ListValueType; } } - - internal override FacetsChecker FacetsChecker { get { return listFacetsChecker; } } - - public override XmlTypeCode TypeCode - { - get - { - return _itemType.TypeCode; - } - } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | RestrictionFlags.MinLength | RestrictionFlags.MaxLength | RestrictionFlags.Enumeration | RestrictionFlags.WhiteSpace | RestrictionFlags.Pattern; - } - } - internal DatatypeImplementation ItemType { get { return _itemType; } } - - internal override Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver namespaceResolver, out object typedValue) - { - Exception exception; - if (value == null) - { - throw new ArgumentNullException("value"); - } - string s = value as string; - typedValue = null; - if (s != null) - { - return TryParseValue(s, nameTable, namespaceResolver, out typedValue); - } - - try - { - object valueToCheck = this.ValueConverter.ChangeType(value, this.ValueType, namespaceResolver); - Array valuesToCheck = valueToCheck as Array; - Debug.Assert(valuesToCheck != null); - - bool checkItemLexical = _itemType.HasLexicalFacets; - bool checkItemValue = _itemType.HasValueFacets; - object item; - FacetsChecker itemFacetsChecker = _itemType.FacetsChecker; - XmlValueConverter itemValueConverter = _itemType.ValueConverter; - - for (int i = 0; i < valuesToCheck.Length; i++) - { - item = valuesToCheck.GetValue(i); - if (checkItemLexical) - { - string s1 = (string)itemValueConverter.ChangeType(item, typeof(System.String), namespaceResolver); - exception = itemFacetsChecker.CheckLexicalFacets(ref s1, _itemType); - if (exception != null) goto Error; - } - if (checkItemValue) - { - exception = itemFacetsChecker.CheckValueFacets(item, _itemType); - if (exception != null) goto Error; - } - } - - //Check facets on the list itself - if (this.HasLexicalFacets) - { - string s1 = (string)this.ValueConverter.ChangeType(valueToCheck, typeof(System.String), namespaceResolver); - exception = listFacetsChecker.CheckLexicalFacets(ref s1, this); - if (exception != null) goto Error; - } - if (this.HasValueFacets) - { - exception = listFacetsChecker.CheckValueFacets(valueToCheck, this); - if (exception != null) goto Error; - } - typedValue = valueToCheck; - return null; - } - catch (FormatException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (InvalidCastException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (OverflowException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (ArgumentException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - - Error: - return exception; - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = listFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - ArrayList values = new ArrayList(); - object array; - if (_itemType.Variety == XmlSchemaDatatypeVariety.Union) - { - object unionTypedValue; - string[] splitString = XmlConvert.SplitString(s); - for (int i = 0; i < splitString.Length; ++i) - { - //Parse items in list according to the itemType - exception = _itemType.TryParseValue(splitString[i], nameTable, nsmgr, out unionTypedValue); - if (exception != null) goto Error; - - XsdSimpleValue simpleValue = (XsdSimpleValue)unionTypedValue; - values.Add(new XmlAtomicValue(simpleValue.XmlType, simpleValue.TypedValue, nsmgr)); - } - array = values.ToArray(typeof(XmlAtomicValue)); - } - else - { //Variety == List or Atomic - string[] splitString = XmlConvert.SplitString(s); - for (int i = 0; i < splitString.Length; ++i) - { - exception = _itemType.TryParseValue(splitString[i], nameTable, nsmgr, out typedValue); - if (exception != null) goto Error; - - values.Add(typedValue); - } - array = values.ToArray(_itemType.ValueType); - Debug.Assert(array.GetType() == ListValueType); - } - if (values.Count < _minListSize) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = listFacetsChecker.CheckValueFacets(array, this); - if (exception != null) goto Error; - - typedValue = array; - - return null; - - Error: - return exception; - } - } - - //Union datatype - internal class Datatype_union : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(object); - private static readonly Type s_listValueType = typeof(object[]); - private XmlSchemaSimpleType[] _types; - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlUnionConverter.Create(schemaType); - } - - internal Datatype_union(XmlSchemaSimpleType[] types) - { - _types = types; - } - - internal override int Compare(object value1, object value2) - { - XsdSimpleValue simpleValue1 = value1 as XsdSimpleValue; - XsdSimpleValue simpleValue2 = value2 as XsdSimpleValue; - - if (simpleValue1 == null || simpleValue2 == null) - { - return -1; - } - XmlSchemaType schemaType1 = simpleValue1.XmlType; - XmlSchemaType schemaType2 = simpleValue2.XmlType; - - if (schemaType1 == schemaType2) - { - XmlSchemaDatatype datatype = schemaType1.Datatype; - return datatype.Compare(simpleValue1.TypedValue, simpleValue2.TypedValue); - } - return -1; - } - - public override Type ValueType { get { return s_atomicValueType; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.AnyAtomicType; } } - - internal override FacetsChecker FacetsChecker { get { return unionFacetsChecker; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.Enumeration; - } - } - - internal XmlSchemaSimpleType[] BaseMemberTypes - { - get - { - return _types; - } - } - - internal bool HasAtomicMembers() - { - for (int i = 0; i < _types.Length; ++i) - { - if (_types[i].Datatype.Variety == XmlSchemaDatatypeVariety.List) - { - return false; - } - } - return true; - } - - internal bool IsUnionBaseOf(DatatypeImplementation derivedType) - { - for (int i = 0; i < _types.Length; ++i) - { - if (derivedType.IsDerivedFrom(_types[i].Datatype)) - { - return true; - } - } - return false; - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - XmlSchemaSimpleType memberType = null; - - typedValue = null; - - exception = unionFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - //Parse string to CLR value - for (int i = 0; i < _types.Length; ++i) - { - exception = _types[i].Datatype.TryParseValue(s, nameTable, nsmgr, out typedValue); - if (exception == null) - { - memberType = _types[i]; - break; - } - } - if (memberType == null) - { - exception = new XmlSchemaException(ResXml.Sch_UnionFailedEx, s); - goto Error; - } - - typedValue = new XsdSimpleValue(memberType, typedValue); - exception = unionFacetsChecker.CheckValueFacets(typedValue, this); - if (exception != null) goto Error; - - return null; - - Error: - return exception; - } - - internal override Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - if (value == null) - { - throw new ArgumentNullException("value"); - } - typedValue = null; - string s = value as string; - if (s != null) - { - return TryParseValue(s, nameTable, nsmgr, out typedValue); - } - - object valueToCheck = null; - XmlSchemaSimpleType memberType = null; - for (int i = 0; i < _types.Length; ++i) - { - if (_types[i].Datatype.TryParseValue(value, nameTable, nsmgr, out valueToCheck) == null) - { //no error - memberType = _types[i]; - break; - } - } - if (valueToCheck == null) - { - exception = new XmlSchemaException(ResXml.Sch_UnionFailedEx, value.ToString()); - goto Error; - } - try - { - if (this.HasLexicalFacets) - { - string s1 = (string)this.ValueConverter.ChangeType(valueToCheck, typeof(System.String), nsmgr); //Using value here to avoid info loss - exception = unionFacetsChecker.CheckLexicalFacets(ref s1, this); - if (exception != null) goto Error; - } - typedValue = new XsdSimpleValue(memberType, valueToCheck); - if (this.HasValueFacets) - { - exception = unionFacetsChecker.CheckValueFacets(typedValue, this); - if (exception != null) goto Error; - } - return null; - } - catch (FormatException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (InvalidCastException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (OverflowException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - catch (ArgumentException e) - { //Catching for exceptions thrown by ValueConverter - exception = e; - } - - Error: - return exception; - } - } - - - // Primitive datatypes - internal class Datatype_anySimpleType : DatatypeImplementation - { - private static readonly Type s_atomicValueType = typeof(string); - private static readonly Type s_listValueType = typeof(string[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlUntypedConverter.Untyped; - } - - internal override FacetsChecker FacetsChecker { get { return miscFacetsChecker; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.AnyAtomicType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.None; } } - - internal override RestrictionFlags ValidRestrictionFlags { get { return 0; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override int Compare(object value1, object value2) - { - //Changed StringComparison.CurrentCulture to StringComparison.Ordinal to handle zero-weight code points like the cyrillic E - return String.Compare(value1.ToString(), value2.ToString(), StringComparison.Ordinal); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - typedValue = XmlComplianceUtil.NonCDataNormalize(s); //Whitespace facet is treated as collapse since thats the way it was in Everett - return null; - } - } - - internal class Datatype_anyAtomicType : Datatype_anySimpleType - { - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlAnyConverter.AnyAtomic; - } - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Preserve; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.AnyAtomicType; } } - } - - internal class Datatype_untypedAtomicType : Datatype_anyAtomicType - { - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlUntypedConverter.Untyped; - } - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Preserve; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.UntypedAtomic; } } - } - - - /* - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_string : Datatype_anySimpleType - { - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlStringConverter.Create(schemaType); - } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Preserve; } } - - internal override FacetsChecker FacetsChecker { get { return stringFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.String; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.CDATA; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = stringFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - exception = stringFacetsChecker.CheckValueFacets(s, this); - if (exception != null) goto Error; - - typedValue = s; - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - */ - internal class Datatype_boolean : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(bool); - private static readonly Type s_listValueType = typeof(bool[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlBooleanConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return miscFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Boolean; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.WhiteSpace; - } - } - - internal override int Compare(object value1, object value2) - { - return ((bool)value1).CompareTo((bool)value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - typedValue = null; - - exception = miscFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - bool boolValue; - exception = XmlConvert.TryToBoolean(s, out boolValue); - if (exception != null) goto Error; - - typedValue = boolValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_float : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(float); - private static readonly Type s_listValueType = typeof(float[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlNumeric2Converter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return numeric2FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Float; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace | - RestrictionFlags.MinExclusive | - RestrictionFlags.MinInclusive | - RestrictionFlags.MaxExclusive | - RestrictionFlags.MaxInclusive; - } - } - - internal override int Compare(object value1, object value2) - { - return ((float)value1).CompareTo((float)value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = numeric2FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - float singleValue; - exception = XmlConvert.TryToSingle(s, out singleValue); - if (exception != null) goto Error; - - exception = numeric2FacetsChecker.CheckValueFacets(singleValue, this); - if (exception != null) goto Error; - - typedValue = singleValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_double : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(double); - private static readonly Type s_listValueType = typeof(double[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlNumeric2Converter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return numeric2FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Double; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace | - RestrictionFlags.MinExclusive | - RestrictionFlags.MinInclusive | - RestrictionFlags.MaxExclusive | - RestrictionFlags.MaxInclusive; - } - } - - internal override int Compare(object value1, object value2) - { - return ((double)value1).CompareTo((double)value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - typedValue = null; - - exception = numeric2FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - double doubleValue; - exception = XmlConvert.TryToDouble(s, out doubleValue); - if (exception != null) goto Error; - - exception = numeric2FacetsChecker.CheckValueFacets(doubleValue, this); - if (exception != null) goto Error; - - typedValue = doubleValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_decimal : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(decimal); - private static readonly Type s_listValueType = typeof(decimal[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(decimal.MinValue, decimal.MaxValue); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlNumeric10Converter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Decimal; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.TotalDigits | - RestrictionFlags.FractionDigits | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace | - RestrictionFlags.MinExclusive | - RestrictionFlags.MinInclusive | - RestrictionFlags.MaxExclusive | - RestrictionFlags.MaxInclusive; - } - } - - internal override int Compare(object value1, object value2) - { - return ((decimal)value1).CompareTo((decimal)value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - decimal decimalValue; - exception = XmlConvert.TryToDecimal(s, out decimalValue); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets(decimalValue, this); - if (exception != null) goto Error; - - typedValue = decimalValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_duration : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(TimeSpan); - private static readonly Type s_listValueType = typeof(TimeSpan[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return durationFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Duration; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace | - RestrictionFlags.MinExclusive | - RestrictionFlags.MinInclusive | - RestrictionFlags.MaxExclusive | - RestrictionFlags.MaxInclusive; - } - } - - internal override int Compare(object value1, object value2) - { - return ((TimeSpan)value1).CompareTo((TimeSpan)value2); - } - - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - typedValue = null; - - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = durationFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - TimeSpan timeSpanValue; - exception = XmlConvert.TryToTimeSpan(s, out timeSpanValue); - if (exception != null) goto Error; - - exception = durationFacetsChecker.CheckValueFacets(timeSpanValue, this); - if (exception != null) goto Error; - - typedValue = timeSpanValue; - - return null; - - Error: - return exception; - } - } - - internal class Datatype_yearMonthDuration : Datatype_duration - { - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - typedValue = null; - - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = durationFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - XsdDuration duration; - exception = XsdDuration.TryParse(s, XsdDuration.DurationType.YearMonthDuration, out duration); - if (exception != null) goto Error; - - TimeSpan timeSpanValue; - - exception = duration.TryToTimeSpan(XsdDuration.DurationType.YearMonthDuration, out timeSpanValue); - if (exception != null) goto Error; - - exception = durationFacetsChecker.CheckValueFacets(timeSpanValue, this); - if (exception != null) goto Error; - - typedValue = timeSpanValue; - - return null; - - Error: - return exception; - } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.YearMonthDuration; } } - } - - internal class Datatype_dayTimeDuration : Datatype_duration - { - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = durationFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - XsdDuration duration; - exception = XsdDuration.TryParse(s, XsdDuration.DurationType.DayTimeDuration, out duration); - if (exception != null) goto Error; - - TimeSpan timeSpanValue; - exception = duration.TryToTimeSpan(XsdDuration.DurationType.DayTimeDuration, out timeSpanValue); - if (exception != null) goto Error; - - exception = durationFacetsChecker.CheckValueFacets(timeSpanValue, this); - if (exception != null) goto Error; - - typedValue = timeSpanValue; - - return null; - - Error: - return exception; - } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.DayTimeDuration; } } - } - - internal class Datatype_dateTimeBase : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(DateTime); - private static readonly Type s_listValueType = typeof(DateTime[]); - private XsdDateTimeFlags _dateTimeFlags; - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlDateTimeConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return dateTimeFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.DateTime; } } - - internal Datatype_dateTimeBase() - { - } - - internal Datatype_dateTimeBase(XsdDateTimeFlags dateTimeFlags) - { - _dateTimeFlags = dateTimeFlags; - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace | - RestrictionFlags.MinExclusive | - RestrictionFlags.MinInclusive | - RestrictionFlags.MaxExclusive | - RestrictionFlags.MaxInclusive; - } - } - - internal override int Compare(object value1, object value2) - { - DateTime dateTime1 = (DateTime)value1; - DateTime dateTime2 = (DateTime)value2; - if (dateTime1.Kind == DateTimeKind.Unspecified || dateTime2.Kind == DateTimeKind.Unspecified) - { //If either of them are unspecified, do not convert zones - return dateTime1.CompareTo(dateTime2); - } - dateTime1 = dateTime1.ToUniversalTime(); - return dateTime1.CompareTo(dateTime2.ToUniversalTime()); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - typedValue = null; - - exception = dateTimeFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - XsdDateTime dateTime; - if (!XsdDateTime.TryParse(s, _dateTimeFlags, out dateTime)) - { - exception = new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, _dateTimeFlags.ToString())); - goto Error; - } - - DateTime dateTimeValue = DateTime.MinValue; - try - { - dateTimeValue = (DateTime)dateTime; - } - catch (ArgumentException e) - { - exception = e; - goto Error; - } - - exception = dateTimeFacetsChecker.CheckValueFacets(dateTimeValue, this); - if (exception != null) goto Error; - - typedValue = dateTimeValue; - - return null; - - Error: - return exception; - } - } - - internal class Datatype_dateTimeNoTimeZone : Datatype_dateTimeBase - { - internal Datatype_dateTimeNoTimeZone() : base(XsdDateTimeFlags.XdrDateTimeNoTz) { } - } - - internal class Datatype_dateTimeTimeZone : Datatype_dateTimeBase - { - internal Datatype_dateTimeTimeZone() : base(XsdDateTimeFlags.XdrDateTime) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_dateTime : Datatype_dateTimeBase - { - internal Datatype_dateTime() : base(XsdDateTimeFlags.DateTime) { } - } - - internal class Datatype_timeNoTimeZone : Datatype_dateTimeBase - { - internal Datatype_timeNoTimeZone() : base(XsdDateTimeFlags.XdrTimeNoTz) { } - } - - internal class Datatype_timeTimeZone : Datatype_dateTimeBase - { - internal Datatype_timeTimeZone() : base(XsdDateTimeFlags.Time) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_time : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Time; } } - - internal Datatype_time() : base(XsdDateTimeFlags.Time) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_date : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Date; } } - - internal Datatype_date() : base(XsdDateTimeFlags.Date) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_yearMonth : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.GYearMonth; } } - - internal Datatype_yearMonth() : base(XsdDateTimeFlags.GYearMonth) { } - } - - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_year : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.GYear; } } - - internal Datatype_year() : base(XsdDateTimeFlags.GYear) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_monthDay : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.GMonthDay; } } - - internal Datatype_monthDay() : base(XsdDateTimeFlags.GMonthDay) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_day : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.GDay; } } - - internal Datatype_day() : base(XsdDateTimeFlags.GDay) { } - } - - - /* - - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_month : Datatype_dateTimeBase - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.GMonth; } } - - internal Datatype_month() : base(XsdDateTimeFlags.GMonth) { } - } - - /* - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_hexBinary : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(byte[]); - private static readonly Type s_listValueType = typeof(byte[][]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return binaryFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.HexBinary; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - internal override int Compare(object value1, object value2) - { - return Compare((byte[])value1, (byte[])value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = binaryFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - byte[] byteArrayValue = null; - try - { - byteArrayValue = XmlConvert.FromBinHexString(s, false); - } - catch (ArgumentException e) - { - exception = e; - goto Error; - } - catch (XmlException e) - { - exception = e; - goto Error; - } - - exception = binaryFacetsChecker.CheckValueFacets(byteArrayValue, this); - if (exception != null) goto Error; - - typedValue = byteArrayValue; - - return null; - - Error: - return exception; - } - } - - - /* - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_base64Binary : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(byte[]); - private static readonly Type s_listValueType = typeof(byte[][]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return binaryFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Base64Binary; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - internal override int Compare(object value1, object value2) - { - return Compare((byte[])value1, (byte[])value2); - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = binaryFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - byte[] byteArrayValue = null; - try - { - byteArrayValue = Convert.FromBase64String(s); - } - catch (ArgumentException e) - { - exception = e; - goto Error; - } - catch (FormatException e) - { - exception = e; - goto Error; - } - - exception = binaryFacetsChecker.CheckValueFacets(byteArrayValue, this); - if (exception != null) goto Error; - - typedValue = byteArrayValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_anyURI : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(Uri); - private static readonly Type s_listValueType = typeof(Uri[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return stringFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.AnyUri; } } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check validity of Uri - } - } - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - internal override int Compare(object value1, object value2) - { - return ((Uri)value1).Equals((Uri)value2) ? 0 : -1; - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = stringFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - Uri uri; - exception = XmlConvert.TryToUri(s, out uri); - if (exception != null) goto Error; - - string stringValue = uri.OriginalString; - exception = ((StringFacetsChecker)stringFacetsChecker).CheckValueFacets(stringValue, this, false); - if (exception != null) goto Error; - - typedValue = uri; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - - - - - - - - - - - - */ - internal class Datatype_QName : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(XmlQualifiedName); - private static readonly Type s_listValueType = typeof(XmlQualifiedName[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return qnameFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.QName; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.QName; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = qnameFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - XmlQualifiedName qname = null; - try - { - string prefix; - qname = XmlQualifiedName.Parse(s, nsmgr, out prefix); - } - catch (ArgumentException e) - { - exception = e; - goto Error; - } - catch (XmlException e) - { - exception = e; - goto Error; - } - - exception = qnameFacetsChecker.CheckValueFacets(qname, this); - if (exception != null) goto Error; - - typedValue = qname; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_normalizedString : Datatype_string - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NormalizedString; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Replace; } } - - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check validity of NormalizedString - } - } - } - - internal class Datatype_normalizedStringV1Compat : Datatype_string - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NormalizedString; } } - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check validity of NormalizedString - } - } - } - - /* - - - - - - - - - */ - internal class Datatype_token : Datatype_normalizedString - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Token; } } - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - } - - internal class Datatype_tokenV1Compat : Datatype_normalizedStringV1Compat - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Token; } } - } - - /* - - - - - - - - - pattern specifies the content of section 2.12 of XML 1.0e2 - and RFC 1766 - - - - - - */ - internal class Datatype_language : Datatype_token - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Language; } } - } - - /* - - - - - - - - - pattern matches production 7 from the XML spec - - - - - - */ - internal class Datatype_NMTOKEN : Datatype_token - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NmToken; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.NMTOKEN; } } - } - - /* - - - - - - - - - pattern matches production 5 from the XML spec - - - - - - */ - internal class Datatype_Name : Datatype_token - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Name; } } - } - - /* - - - - - - - - - pattern matches production 4 from the Namespaces in XML spec - - - - - - */ - internal class Datatype_NCName : Datatype_Name - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NCName; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = stringFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - exception = stringFacetsChecker.CheckValueFacets(s, this); - if (exception != null) goto Error; - - nameTable.Add(s); - - typedValue = s; - return null; - - Error: - return exception; - } - } - - /* - - - - - - - */ - internal class Datatype_ID : Datatype_NCName - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Id; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.ID; } } - } - - /* - - - - - - - */ - internal class Datatype_IDREF : Datatype_NCName - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Idref; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.IDREF; } } - } - - /* - - - - - - - */ - internal class Datatype_ENTITY : Datatype_NCName - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Entity; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.ENTITY; } } - } - - /* - - - - - - - - - - - - - - - - - NOTATION cannot be used directly in a schema; rather a type - must be derived from it by specifying at least one enumeration - facet whose value is the name of a NOTATION declared in the - schema. - - - - - - - */ - internal class Datatype_NOTATION : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(XmlQualifiedName); - private static readonly Type s_listValueType = typeof(XmlQualifiedName[]); - - internal override XmlValueConverter CreateValueConverter(XmlSchemaType schemaType) - { - return XmlMiscConverter.Create(schemaType); - } - - internal override FacetsChecker FacetsChecker { get { return qnameFacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Notation; } } - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.NOTATION; } } - - internal override RestrictionFlags ValidRestrictionFlags - { - get - { - return RestrictionFlags.Length | - RestrictionFlags.MinLength | - RestrictionFlags.MaxLength | - RestrictionFlags.Pattern | - RestrictionFlags.Enumeration | - RestrictionFlags.WhiteSpace; - } - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get { return XmlSchemaWhiteSpace.Collapse; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - - exception = qnameFacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - XmlQualifiedName qname = null; - try - { - string prefix; - qname = XmlQualifiedName.Parse(s, nsmgr, out prefix); - } - catch (ArgumentException e) - { - exception = e; - goto Error; - } - catch (XmlException e) - { - exception = e; - goto Error; - } - - exception = qnameFacetsChecker.CheckValueFacets(qname, this); - if (exception != null) goto Error; - - typedValue = qname; - - return null; - - Error: - return exception; - } - - internal override void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller) - { - // Only datatypes that are derived from NOTATION by specifying a value for enumeration can be used in a schema. - // Furthermore, the value of all enumeration facets must match the name of a notation declared in the current schema. // - for (Datatype_NOTATION dt = this; dt != null; dt = (Datatype_NOTATION)dt.Base) - { - if (dt.Restriction != null && (dt.Restriction.Flags & RestrictionFlags.Enumeration) != 0) - { - for (int i = 0; i < dt.Restriction.Enumeration.Count; ++i) - { - XmlQualifiedName notation = (XmlQualifiedName)dt.Restriction.Enumeration[i]; - if (!notations.Contains(notation)) - { - throw new XmlSchemaException(ResXml.Sch_NotationRequired, caller); - } - } - return; - } - } - throw new XmlSchemaException(ResXml.Sch_NotationRequired, caller); - } - } - - /* - - - - - - - - - */ - internal class Datatype_integer : Datatype_decimal - { - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Integer; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - decimal decimalValue; - exception = XmlConvert.TryToInteger(s, out decimalValue); - if (exception != null) goto Error; - - exception = FacetsChecker.CheckValueFacets(decimalValue, this); - if (exception != null) goto Error; - - typedValue = decimalValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_nonPositiveInteger : Datatype_integer - { - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(decimal.MinValue, decimal.Zero); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NonPositiveInteger; } } - - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check range - } - } - } - - - /* - - - - - - - - - */ - internal class Datatype_negativeInteger : Datatype_nonPositiveInteger - { - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(decimal.MinValue, decimal.MinusOne); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NegativeInteger; } } - } - - - /* - - - - - - - - - - - - - - */ - internal class Datatype_long : Datatype_integer - { - private static readonly Type s_atomicValueType = typeof(long); - private static readonly Type s_listValueType = typeof(long[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(long.MinValue, long.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check range - } - } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Long; } } - - internal override int Compare(object value1, object value2) - { - return ((long)value1).CompareTo((long)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - long int64Value; - exception = XmlConvert.TryToInt64(s, out int64Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets(int64Value, this); - if (exception != null) goto Error; - - typedValue = int64Value; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - */ - internal class Datatype_int : Datatype_long - { - private static readonly Type s_atomicValueType = typeof(int); - private static readonly Type s_listValueType = typeof(int[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(int.MinValue, int.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Int; } } - - internal override int Compare(object value1, object value2) - { - return ((int)value1).CompareTo((int)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - int int32Value; - exception = XmlConvert.TryToInt32(s, out int32Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets(int32Value, this); - if (exception != null) goto Error; - - typedValue = int32Value; - - return null; - - Error: - return exception; - } - } - - - /* - - - - - - - - - - */ - internal class Datatype_short : Datatype_int - { - private static readonly Type s_atomicValueType = typeof(short); - private static readonly Type s_listValueType = typeof(short[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(short.MinValue, short.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Short; } } - - internal override int Compare(object value1, object value2) - { - return ((short)value1).CompareTo((short)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - short int16Value; - exception = XmlConvert.TryToInt16(s, out int16Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets(int16Value, this); - if (exception != null) goto Error; - - typedValue = int16Value; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - - */ - internal class Datatype_byte : Datatype_short - { - private static readonly Type s_atomicValueType = typeof(sbyte); - private static readonly Type s_listValueType = typeof(sbyte[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(sbyte.MinValue, sbyte.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.Byte; } } - - internal override int Compare(object value1, object value2) - { - return ((sbyte)value1).CompareTo((sbyte)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - sbyte sbyteValue; - exception = XmlConvert.TryToSByte(s, out sbyteValue); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets((short)sbyteValue, this); - if (exception != null) goto Error; - - typedValue = sbyteValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_nonNegativeInteger : Datatype_integer - { - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(decimal.Zero, decimal.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.NonNegativeInteger; } } - - internal override bool HasValueFacets - { - get - { - return true; //Built-in facet to check range - } - } - } - - /* - - - - - - - - - - - - - */ - internal class Datatype_unsignedLong : Datatype_nonNegativeInteger - { - private static readonly Type s_atomicValueType = typeof(ulong); - private static readonly Type s_listValueType = typeof(ulong[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(ulong.MinValue, ulong.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.UnsignedLong; } } - - internal override int Compare(object value1, object value2) - { - return ((ulong)value1).CompareTo((ulong)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - ulong uint64Value; - exception = XmlConvert.TryToUInt64(s, out uint64Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets((decimal)uint64Value, this); - if (exception != null) goto Error; - - typedValue = uint64Value; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_unsignedInt : Datatype_unsignedLong - { - private static readonly Type s_atomicValueType = typeof(uint); - private static readonly Type s_listValueType = typeof(uint[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(uint.MinValue, uint.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.UnsignedInt; } } - - internal override int Compare(object value1, object value2) - { - return ((uint)value1).CompareTo((uint)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - uint uint32Value; - exception = XmlConvert.TryToUInt32(s, out uint32Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets((long)uint32Value, this); - if (exception != null) goto Error; - - typedValue = uint32Value; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_unsignedShort : Datatype_unsignedInt - { - private static readonly Type s_atomicValueType = typeof(ushort); - private static readonly Type s_listValueType = typeof(ushort[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(ushort.MinValue, ushort.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.UnsignedShort; } } - - internal override int Compare(object value1, object value2) - { - return ((ushort)value1).CompareTo((ushort)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - ushort uint16Value; - exception = XmlConvert.TryToUInt16(s, out uint16Value); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets((int)uint16Value, this); - if (exception != null) goto Error; - - typedValue = uint16Value; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_unsignedByte : Datatype_unsignedShort - { - private static readonly Type s_atomicValueType = typeof(byte); - private static readonly Type s_listValueType = typeof(byte[]); - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(byte.MinValue, byte.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.UnsignedByte; } } - - internal override int Compare(object value1, object value2) - { - return ((byte)value1).CompareTo((byte)value2); - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - exception = s_numeric10FacetsChecker.CheckLexicalFacets(ref s, this); - if (exception != null) goto Error; - - byte byteValue; - exception = XmlConvert.TryToByte(s, out byteValue); - if (exception != null) goto Error; - - exception = s_numeric10FacetsChecker.CheckValueFacets((short)byteValue, this); - if (exception != null) goto Error; - - typedValue = byteValue; - - return null; - - Error: - return exception; - } - } - - /* - - - - - - - - - */ - internal class Datatype_positiveInteger : Datatype_nonNegativeInteger - { - private static readonly FacetsChecker s_numeric10FacetsChecker = new Numeric10FacetsChecker(decimal.One, decimal.MaxValue); - - internal override FacetsChecker FacetsChecker { get { return s_numeric10FacetsChecker; } } - - public override XmlTypeCode TypeCode { get { return XmlTypeCode.PositiveInteger; } } - } - - /* - XDR - */ - internal class Datatype_doubleXdr : Datatype_double - { - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - double value; - try - { - value = XmlConvert.ToDouble(s); - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - if (double.IsInfinity(value) || double.IsNaN(value)) - { - throw new XmlSchemaException(ResXml.Sch_InvalidValue, s); - } - return value; - } - } - - internal class Datatype_floatXdr : Datatype_float - { - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - float value; - try - { - value = XmlConvert.ToSingle(s); - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - if (float.IsInfinity(value) || float.IsNaN(value)) - { - throw new XmlSchemaException(ResXml.Sch_InvalidValue, s); - } - return value; - } - } - - internal class Datatype_QNameXdr : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(XmlQualifiedName); - private static readonly Type s_listValueType = typeof(XmlQualifiedName[]); - - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.QName; } } - - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - if (s == null || s.Length == 0) - { - throw new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - if (nsmgr == null) - { - throw new ArgumentNullException("nsmgr"); - } - string prefix; - try - { - return XmlQualifiedName.Parse(s.Trim(), nsmgr, out prefix); - } - catch (XmlSchemaException e) - { - throw e; - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - } - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - } - - internal class Datatype_ENUMERATION : Datatype_NMTOKEN - { - public override XmlTokenizedType TokenizedType { get { return XmlTokenizedType.ENUMERATION; } } - } - - internal class Datatype_char : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(char); - private static readonly Type s_listValueType = typeof(char[]); - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override RestrictionFlags ValidRestrictionFlags { get { return 0; } } //XDR only - - internal override int Compare(object value1, object value2) - { - // this should be culture sensitive - comparing values - return ((char)value1).CompareTo((char)value2); - } - - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - try - { - return XmlConvert.ToChar(s); - } - catch (XmlSchemaException e) - { - throw e; - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - char charValue; - exception = XmlConvert.TryToChar(s, out charValue); - if (exception != null) goto Error; - - typedValue = charValue; - - return null; - - Error: - return exception; - } - } - - internal class Datatype_fixed : Datatype_decimal - { - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - Exception exception; - - try - { - Numeric10FacetsChecker facetsChecker = this.FacetsChecker as Numeric10FacetsChecker; - decimal value = XmlConvert.ToDecimal(s); - exception = facetsChecker.CheckTotalAndFractionDigits(value, 14 + 4, 4, true, true); - if (exception != null) goto Error; - - return value; - } - catch (XmlSchemaException e) - { - throw e; - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - Error: - throw exception; - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - decimal decimalValue; - exception = XmlConvert.TryToDecimal(s, out decimalValue); - if (exception != null) goto Error; - - Numeric10FacetsChecker facetsChecker = this.FacetsChecker as Numeric10FacetsChecker; - exception = facetsChecker.CheckTotalAndFractionDigits(decimalValue, 14 + 4, 4, true, true); - if (exception != null) goto Error; - - typedValue = decimalValue; - - return null; - - Error: - return exception; - } - } - - internal class Datatype_uuid : Datatype_anySimpleType - { - private static readonly Type s_atomicValueType = typeof(Guid); - private static readonly Type s_listValueType = typeof(Guid[]); - - public override Type ValueType { get { return s_atomicValueType; } } - - internal override Type ListValueType { get { return s_listValueType; } } - - internal override RestrictionFlags ValidRestrictionFlags { get { return 0; } } - - internal override int Compare(object value1, object value2) - { - return ((Guid)value1).Equals(value2) ? 0 : -1; - } - - public override object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr) - { - try - { - return XmlConvert.ToGuid(s); - } - catch (XmlSchemaException e) - { - throw e; - } - catch (Exception e) - { - throw new XmlSchemaException(string.Format(ResXml.Sch_InvalidValue, s), e); - } - } - - internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) - { - Exception exception; - - typedValue = null; - - Guid guid; - exception = XmlConvert.TryToGuid(s, out guid); - if (exception != null) goto Error; - - typedValue = guid; - - return null; - - Error: - return exception; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DtdParser.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DtdParser.cs deleted file mode 100644 index f07cc8d10c9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/DtdParser.cs +++ /dev/null @@ -1,3691 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -using System; -using System.IO; -using System.Text; -using Microsoft.Xml.Schema; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; - -using BufferBuilder = System.Text.StringBuilder; - -namespace Microsoft.Xml -{ - using System; - - - internal partial class DtdParser : IDtdParser - { - // - // Private types - // - private enum Token - { - CDATA = XmlTokenizedType.CDATA, // == 0 - ID = XmlTokenizedType.ID, // == 1 - IDREF = XmlTokenizedType.IDREF, // == 2 - IDREFS = XmlTokenizedType.IDREFS, // == 3 - ENTITY = XmlTokenizedType.ENTITY, // == 4 - ENTITIES = XmlTokenizedType.ENTITIES, // == 5 - NMTOKEN = XmlTokenizedType.NMTOKEN, // == 6 - NMTOKENS = XmlTokenizedType.NMTOKENS, // == 7 - NOTATION = XmlTokenizedType.NOTATION, // == 8 - None, - PERef, - AttlistDecl, - ElementDecl, - EntityDecl, - NotationDecl, - Comment, - PI, - CondSectionStart, - CondSectionEnd, - Eof, - REQUIRED, - IMPLIED, - FIXED, - QName, - Name, - Nmtoken, - Quote, - LeftParen, - RightParen, - GreaterThan, - Or, - LeftBracket, - RightBracket, - PUBLIC, - SYSTEM, - Literal, - DOCTYPE, - NData, - Percent, - Star, - QMark, - Plus, - PCDATA, - Comma, - ANY, - EMPTY, - IGNORE, - INCLUDE, - } - - private enum ScanningFunction - { - SubsetContent, - Name, - QName, - Nmtoken, - Doctype1, - Doctype2, - Element1, - Element2, - Element3, - Element4, - Element5, - Element6, - Element7, - Attlist1, - Attlist2, - Attlist3, - Attlist4, - Attlist5, - Attlist6, - Attlist7, - Entity1, - Entity2, - Entity3, - Notation1, - CondSection1, - CondSection2, - CondSection3, - Literal, - SystemId, - PublicId1, - PublicId2, - ClosingTag, - ParamEntitySpace, - None, - } - - private enum LiteralType - { - AttributeValue, - EntityReplText, - SystemOrPublicID - } - - private class UndeclaredNotation - { - internal string name; - internal int lineNo; - internal int linePos; - internal UndeclaredNotation next; - - internal UndeclaredNotation(string name, int lineNo, int linePos) - { - this.name = name; - this.lineNo = lineNo; - this.linePos = linePos; - this.next = null; - } - } - - // - // Fields - // - // connector to reader - private IDtdParserAdapter _readerAdapter; - private IDtdParserAdapterWithValidation _readerAdapterWithValidation; - - // name table - private XmlNameTable _nameTable; - - // final schema info - private SchemaInfo _schemaInfo; - - // XmlCharType instance - private XmlCharType _xmlCharType = XmlCharType.Instance; - - // system & public id - private string _systemId = string.Empty; - private string _publicId = string.Empty; - - // flags - private bool _normalize = true; - private bool _validate = false; - private bool _supportNamespaces = true; - private bool _v1Compat = false; - - // cached character buffer - private char[] _chars; - private int _charsUsed; - private int _curPos; - - // scanning function for the next token - private ScanningFunction _scanningFunction; - private ScanningFunction _nextScaningFunction; - private ScanningFunction _savedScanningFunction; // this one is used only for adding spaces around parameter entities - - // flag if whitespace seen before token - private bool _whitespaceSeen; - - // start position of the last token (for name and value) - private int _tokenStartPos; - - // colon position (for name) - private int _colonPos; - - // value of the internal subset - private BufferBuilder _internalSubsetValueSb = null; - - // entities - private int _externalEntitiesDepth = 0; - private int _currentEntityId = 0; - - // free-floating DTD support - private bool _freeFloatingDtd = false; - private bool _hasFreeFloatingInternalSubset = false; - - // misc - private BufferBuilder _stringBuilder; - private int _condSectionDepth = 0; - private LineInfo _literalLineInfo = new LineInfo(0, 0); - private char _literalQuoteChar = '"'; - private string _documentBaseUri = string.Empty; - private string _externalDtdBaseUri = string.Empty; - - private Dictionary _undeclaredNotations = null; - private int[] _condSectionEntityIds = null; - - private const int CondSectionEntityIdsInitialSize = 2; - - // - // Constructor - // - - static DtdParser() - { -#if DEBUG - // The absolute numbering is utilized in attribute type parsing - Debug.Assert((int)Token.CDATA == (int)XmlTokenizedType.CDATA && (int)XmlTokenizedType.CDATA == 0); - Debug.Assert((int)Token.ID == (int)XmlTokenizedType.ID && (int)XmlTokenizedType.ID == 1); - Debug.Assert((int)Token.IDREF == (int)XmlTokenizedType.IDREF && (int)XmlTokenizedType.IDREF == 2); - Debug.Assert((int)Token.IDREFS == (int)XmlTokenizedType.IDREFS && (int)XmlTokenizedType.IDREFS == 3); - Debug.Assert((int)Token.ENTITY == (int)XmlTokenizedType.ENTITY && (int)XmlTokenizedType.ENTITY == 4); - Debug.Assert((int)Token.ENTITIES == (int)XmlTokenizedType.ENTITIES && (int)XmlTokenizedType.ENTITIES == 5); - Debug.Assert((int)Token.NMTOKEN == (int)XmlTokenizedType.NMTOKEN && (int)XmlTokenizedType.NMTOKEN == 6); - Debug.Assert((int)Token.NMTOKENS == (int)XmlTokenizedType.NMTOKENS && (int)XmlTokenizedType.NMTOKENS == 7); - Debug.Assert((int)Token.NOTATION == (int)XmlTokenizedType.NOTATION && (int)XmlTokenizedType.NOTATION == 8); -#endif - } - - private DtdParser() - { - } - - internal static IDtdParser Create() - { - return new DtdParser(); - } - - // - // Initialization methods - // - - private void Initialize(IDtdParserAdapter readerAdapter) - { - Debug.Assert(readerAdapter != null); - _readerAdapter = readerAdapter; - _readerAdapterWithValidation = readerAdapter as IDtdParserAdapterWithValidation; - - _nameTable = readerAdapter.NameTable; - - IDtdParserAdapterWithValidation raWithValidation = readerAdapter as IDtdParserAdapterWithValidation; - if (raWithValidation != null) - { - _validate = raWithValidation.DtdValidation; - } - IDtdParserAdapterV1 raV1 = readerAdapter as IDtdParserAdapterV1; - if (raV1 != null) - { - _v1Compat = raV1.V1CompatibilityMode; - _normalize = raV1.Normalization; - _supportNamespaces = raV1.Namespaces; - } - - _schemaInfo = new SchemaInfo(); - _schemaInfo.SchemaType = SchemaType.DTD; - - _stringBuilder = new BufferBuilder(); - - Uri baseUri = readerAdapter.BaseUri; - if (baseUri != null) - { - _documentBaseUri = baseUri.ToString(); - } - - _freeFloatingDtd = false; - } - - private void InitializeFreeFloatingDtd(string baseUri, string docTypeName, string publicId, string systemId, string internalSubset, IDtdParserAdapter adapter) - { - Initialize(adapter); - - if (docTypeName == null || docTypeName.Length == 0) - { - throw XmlConvert.CreateInvalidNameArgumentException(docTypeName, "docTypeName"); - } - - // check doctype name - XmlConvert.VerifyName(docTypeName); - int colonPos = docTypeName.IndexOf(':'); - if (colonPos == -1) - { - _schemaInfo.DocTypeName = new XmlQualifiedName(_nameTable.Add(docTypeName)); - } - else - { - _schemaInfo.DocTypeName = new XmlQualifiedName(_nameTable.Add(docTypeName.Substring(0, colonPos)), - _nameTable.Add(docTypeName.Substring(colonPos + 1))); - } - - int i; - // check system id - if (systemId != null && systemId.Length > 0) - { - if ((i = _xmlCharType.IsOnlyCharData(systemId)) >= 0) - { - ThrowInvalidChar(_curPos, systemId, i); - } - _systemId = systemId; - } - - // check public id - if (publicId != null && publicId.Length > 0) - { - if ((i = _xmlCharType.IsPublicId(publicId)) >= 0) - { - ThrowInvalidChar(_curPos, publicId, i); - } - _publicId = publicId; - } - - // init free-floating internal subset - if (internalSubset != null && internalSubset.Length > 0) - { - _readerAdapter.PushInternalDtd(baseUri, internalSubset); - _hasFreeFloatingInternalSubset = true; - } - - Uri baseUriOb = _readerAdapter.BaseUri; - if (baseUriOb != null) - { - _documentBaseUri = baseUriOb.ToString(); - } - - _freeFloatingDtd = true; - } - - // - // IDtdParser interface - // - #region IDtdParser Members - - IDtdInfo IDtdParser.ParseInternalDtd(IDtdParserAdapter adapter, bool saveInternalSubset) - { - Initialize(adapter); - Parse(saveInternalSubset); - return _schemaInfo; - } - - IDtdInfo IDtdParser.ParseFreeFloatingDtd(string baseUri, string docTypeName, string publicId, string systemId, string internalSubset, IDtdParserAdapter adapter) - { - InitializeFreeFloatingDtd(baseUri, docTypeName, publicId, systemId, internalSubset, adapter); - Parse(false); - return _schemaInfo; - } - #endregion - - // - // Private properties - // - private bool ParsingInternalSubset - { - get - { - return _externalEntitiesDepth == 0; - } - } - - private bool IgnoreEntityReferences - { - get - { - return _scanningFunction == ScanningFunction.CondSection3; - } - } - - private bool SaveInternalSubsetValue - { - get - { - return _readerAdapter.EntityStackLength == 0 && _internalSubsetValueSb != null; - } - } - - private bool ParsingTopLevelMarkup - { - get - { - return _scanningFunction == ScanningFunction.SubsetContent || - (_scanningFunction == ScanningFunction.ParamEntitySpace && _savedScanningFunction == ScanningFunction.SubsetContent); - } - } - - private bool SupportNamespaces - { - get - { - return _supportNamespaces; - } - } - - private bool Normalize - { - get - { - return _normalize; - } - } - - // - // Parsing methods - // - - private void Parse(bool saveInternalSubset) - { - if (_freeFloatingDtd) - { - ParseFreeFloatingDtd(); - } - else - { - ParseInDocumentDtd(saveInternalSubset); - } - - _schemaInfo.Finish(); - - // check undeclared forward references - if (_validate && _undeclaredNotations != null) - { - foreach (UndeclaredNotation un in _undeclaredNotations.Values) - { - UndeclaredNotation tmpUn = un; - while (tmpUn != null) - { - SendValidationEvent(XmlSeverityType.Error, new XmlSchemaException(ResXml.Sch_UndeclaredNotation, un.name, BaseUriStr, (int)un.lineNo, (int)un.linePos)); - tmpUn = tmpUn.next; - } - } - } - } - - private void ParseInDocumentDtd(bool saveInternalSubset) - { - LoadParsingBuffer(); - - _scanningFunction = ScanningFunction.QName; - _nextScaningFunction = ScanningFunction.Doctype1; - - // doctype name - if (GetToken(false) != Token.QName) - { - OnUnexpectedError(); - } - _schemaInfo.DocTypeName = GetNameQualified(true); - - // SYSTEM or PUBLIC id - Token token = GetToken(false); - if (token == Token.SYSTEM || token == Token.PUBLIC) - { - ParseExternalId(token, Token.DOCTYPE, out _publicId, out _systemId); - - token = GetToken(false); - } - - switch (token) - { - case Token.LeftBracket: - if (saveInternalSubset) - { - SaveParsingBuffer(); // this will cause saving the internal subset right from the point after '[' - _internalSubsetValueSb = new BufferBuilder(); - } - ParseInternalSubset(); - break; - case Token.GreaterThan: - break; - default: - OnUnexpectedError(); - break; - } - SaveParsingBuffer(); - - if (_systemId != null && _systemId.Length > 0) - { - ParseExternalSubset(); - } - } - - private void ParseFreeFloatingDtd() - { - if (_hasFreeFloatingInternalSubset) - { - LoadParsingBuffer(); - ParseInternalSubset(); - SaveParsingBuffer(); - } - - if (_systemId != null && _systemId.Length > 0) - { - ParseExternalSubset(); - } - } - - private void ParseInternalSubset() - { - Debug.Assert(ParsingInternalSubset); - ParseSubset(); - } - - private void ParseExternalSubset() - { - Debug.Assert(_externalEntitiesDepth == 0); - - // push external subset - if (!_readerAdapter.PushExternalSubset(_systemId, _publicId)) - { - return; - } - - Uri baseUri = _readerAdapter.BaseUri; - if (baseUri != null) - { - _externalDtdBaseUri = baseUri.ToString(); - } - - _externalEntitiesDepth++; - LoadParsingBuffer(); - - // parse - ParseSubset(); - -#if DEBUG - Debug.Assert(_readerAdapter.EntityStackLength == 0 || - (_freeFloatingDtd && _readerAdapter.EntityStackLength == 1)); -#endif - } - - private void ParseSubset() - { - int startTagEntityId; - for (; ; ) - { - Token token = GetToken(false); - startTagEntityId = _currentEntityId; - switch (token) - { - case Token.AttlistDecl: - ParseAttlistDecl(); - break; - - case Token.ElementDecl: - ParseElementDecl(); - break; - - case Token.EntityDecl: - ParseEntityDecl(); - break; - - case Token.NotationDecl: - ParseNotationDecl(); - break; - - case Token.Comment: - ParseComment(); - break; - - case Token.PI: - ParsePI(); - break; - - case Token.CondSectionStart: - if (ParsingInternalSubset) - { - Throw(_curPos - 3, ResXml.Xml_InvalidConditionalSection); // 3==strlen(" 0) - { - _condSectionDepth--; - if (_validate && _currentEntityId != _condSectionEntityIds[_condSectionDepth]) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - } - else - { - Throw(_curPos - 3, ResXml.Xml_UnexpectedCDataEnd); - } - break; - case Token.RightBracket: - if (ParsingInternalSubset) - { - if (_condSectionDepth != 0) - { - Throw(_curPos, ResXml.Xml_UnclosedConditionalSection); - } - // append the rest to internal subset value but not the closing ']' - if (_internalSubsetValueSb != null) - { - Debug.Assert(_curPos > 0 && _chars[_curPos - 1] == ']'); - SaveParsingBuffer(_curPos - 1); - _schemaInfo.InternalDtdSubset = _internalSubsetValueSb.ToString(); - _internalSubsetValueSb = null; - } - // check '>' - if (GetToken(false) != Token.GreaterThan) - { - ThrowUnexpectedToken(_curPos, ">"); - } -#if DEBUG - // check entity nesting - Debug.Assert(_readerAdapter.EntityStackLength == 0 || - (_freeFloatingDtd && _readerAdapter.EntityStackLength == 1)); -#endif - } - else - { - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - } - return; - case Token.Eof: - if (ParsingInternalSubset && !_freeFloatingDtd) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - if (_condSectionDepth != 0) - { - Throw(_curPos, ResXml.Xml_UnclosedConditionalSection); - } - return; - default: - Debug.Assert(false); - break; - } - - Debug.Assert(_scanningFunction == ScanningFunction.SubsetContent); - - if (_currentEntityId != startTagEntityId) - { - if (_validate) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - else - { - if (!_v1Compat) - { - Throw(_curPos, ResXml.Sch_ParEntityRefNesting); - } - } - } - } - } - - private void ParseAttlistDecl() - { - if (GetToken(true) != Token.QName) - { - goto UnexpectedError; - } - - // element name - XmlQualifiedName elementName = GetNameQualified(true); - SchemaElementDecl elementDecl; - if (!_schemaInfo.ElementDecls.TryGetValue(elementName, out elementDecl)) - { - if (!_schemaInfo.UndeclaredElementDecls.TryGetValue(elementName, out elementDecl)) - { - elementDecl = new SchemaElementDecl(elementName, elementName.Namespace); - _schemaInfo.UndeclaredElementDecls.Add(elementName, elementDecl); - } - } - - SchemaAttDef attrDef = null; - for (; ; ) - { - switch (GetToken(false)) - { - case Token.QName: - XmlQualifiedName attrName = GetNameQualified(true); - attrDef = new SchemaAttDef(attrName, attrName.Namespace); - attrDef.IsDeclaredInExternal = !ParsingInternalSubset; - attrDef.LineNumber = (int)LineNo; - attrDef.LinePosition = (int)LinePos - (_curPos - _tokenStartPos); - break; - case Token.GreaterThan: - if (_v1Compat) - { - // check xml:space and xml:lang - // BUG BUG: For backward compatibility, we check the correct type and values of the - // xml:space attribute only on the last attribute in the list. - // See Webdata bugs #97457 and #93935. - if (attrDef != null && attrDef.Prefix.Length > 0 && attrDef.Prefix.Equals("xml") && attrDef.Name.Name == "space") - { - attrDef.Reserved = SchemaAttDef.Reserve.XmlSpace; - if (attrDef.Datatype.TokenizedType != XmlTokenizedType.ENUMERATION) - { - Throw(ResXml.Xml_EnumerationRequired, string.Empty, attrDef.LineNumber, attrDef.LinePosition); - } - if (_validate) - { - attrDef.CheckXmlSpace(_readerAdapterWithValidation.ValidationEventHandling); - } - } - } - return; - default: - goto UnexpectedError; - } - - bool attrDefAlreadyExists = (elementDecl.GetAttDef(attrDef.Name) != null); - - ParseAttlistType(attrDef, elementDecl, attrDefAlreadyExists); - ParseAttlistDefault(attrDef, attrDefAlreadyExists); - - // check xml:space and xml:lang - if (attrDef.Prefix.Length > 0 && attrDef.Prefix.Equals("xml")) - { - if (attrDef.Name.Name == "space") - { - if (_v1Compat) - { - // BUG BUG: For backward compatibility, we check the correct type and values of the - // xml:space attribute only on the last attribute in the list, and mark it as reserved - // only its value is correct (=prevent XmlTextReader from fhrowing on invalid value). - // See Webdata bugs #98168, #97457 and #93935. - string val = attrDef.DefaultValueExpanded.Trim(); - if (val.Equals("preserve") || val.Equals("default")) - { - attrDef.Reserved = SchemaAttDef.Reserve.XmlSpace; - } - } - else - { - attrDef.Reserved = SchemaAttDef.Reserve.XmlSpace; - if (attrDef.TokenizedType != XmlTokenizedType.ENUMERATION) - { - Throw(ResXml.Xml_EnumerationRequired, string.Empty, attrDef.LineNumber, attrDef.LinePosition); - } - if (_validate) - { - attrDef.CheckXmlSpace(_readerAdapterWithValidation.ValidationEventHandling); - } - } - } - else if (attrDef.Name.Name == "lang") - { - attrDef.Reserved = SchemaAttDef.Reserve.XmlLang; - } - } - - // add attribute to element decl - if (!attrDefAlreadyExists) - { - elementDecl.AddAttDef(attrDef); - } - } - - UnexpectedError: - OnUnexpectedError(); - } - - private void ParseAttlistType(SchemaAttDef attrDef, SchemaElementDecl elementDecl, bool ignoreErrors) - { - Token token = GetToken(true); - - if (token != Token.CDATA) - { - elementDecl.HasNonCDataAttribute = true; - } - - if (IsAttributeValueType(token)) - { - attrDef.TokenizedType = (XmlTokenizedType)(int)token; - attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType(attrDef.Datatype.TypeCode); - - switch (token) - { - case Token.NOTATION: - break; - case Token.ID: - if (_validate && elementDecl.IsIdDeclared) - { - SchemaAttDef idAttrDef = elementDecl.GetAttDef(attrDef.Name); - if ((idAttrDef == null || idAttrDef.Datatype.TokenizedType != XmlTokenizedType.ID) && !ignoreErrors) - { - SendValidationEvent(XmlSeverityType.Error, ResXml.Sch_IdAttrDeclared, elementDecl.Name.ToString()); - } - } - elementDecl.IsIdDeclared = true; - return; - default: - return; - } - // check notation constrains - if (_validate) - { - if (elementDecl.IsNotationDeclared && !ignoreErrors) - { - SendValidationEvent(_curPos - 8, XmlSeverityType.Error, ResXml.Sch_DupNotationAttribute, elementDecl.Name.ToString()); // 8 == strlen("NOTATION") - } - else - { - if (elementDecl.ContentValidator != null && - elementDecl.ContentValidator.ContentType == XmlSchemaContentType.Empty && - !ignoreErrors) - { - SendValidationEvent(_curPos - 8, XmlSeverityType.Error, ResXml.Sch_NotationAttributeOnEmptyElement, elementDecl.Name.ToString());// 8 == strlen("NOTATION") - } - elementDecl.IsNotationDeclared = true; - } - } - - if (GetToken(true) != Token.LeftParen) - { - goto UnexpectedError; - } - - // parse notation list - if (GetToken(false) != Token.Name) - { - goto UnexpectedError; - } - for (; ; ) - { - string notationName = GetNameString(); - if (!_schemaInfo.Notations.ContainsKey(notationName)) - { - AddUndeclaredNotation(notationName); - } - if (_validate && !_v1Compat && attrDef.Values != null && attrDef.Values.Contains(notationName) && !ignoreErrors) - { - SendValidationEvent(XmlSeverityType.Error, new XmlSchemaException(ResXml.Xml_AttlistDuplNotationValue, notationName, BaseUriStr, (int)LineNo, (int)LinePos)); - } - attrDef.AddValue(notationName); - - switch (GetToken(false)) - { - case Token.Or: - if (GetToken(false) != Token.Name) - { - goto UnexpectedError; - } - continue; - case Token.RightParen: - return; - default: - goto UnexpectedError; - } - } - } - else if (token == Token.LeftParen) - { - attrDef.TokenizedType = XmlTokenizedType.ENUMERATION; - attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType(attrDef.Datatype.TypeCode); - - // parse nmtoken list - if (GetToken(false) != Token.Nmtoken) - goto UnexpectedError; - attrDef.AddValue(GetNameString()); - - for (; ; ) - { - switch (GetToken(false)) - { - case Token.Or: - if (GetToken(false) != Token.Nmtoken) - goto UnexpectedError; - string nmtoken = GetNmtokenString(); - if (_validate && !_v1Compat && attrDef.Values != null && attrDef.Values.Contains(nmtoken) && !ignoreErrors) - { - SendValidationEvent(XmlSeverityType.Error, new XmlSchemaException(ResXml.Xml_AttlistDuplEnumValue, nmtoken, BaseUriStr, (int)LineNo, (int)LinePos)); - } - attrDef.AddValue(nmtoken); - break; - case Token.RightParen: - return; - default: - goto UnexpectedError; - } - } - } - else - { - goto UnexpectedError; - } - - UnexpectedError: - OnUnexpectedError(); - } - - private void ParseAttlistDefault(SchemaAttDef attrDef, bool ignoreErrors) - { - switch (GetToken(true)) - { - case Token.REQUIRED: - attrDef.Presence = SchemaDeclBase.Use.Required; - return; - case Token.IMPLIED: - attrDef.Presence = SchemaDeclBase.Use.Implied; - return; - case Token.FIXED: - attrDef.Presence = SchemaDeclBase.Use.Fixed; - if (GetToken(true) != Token.Literal) - { - goto UnexpectedError; - } - break; - case Token.Literal: - break; - default: - goto UnexpectedError; - } - - if (_validate && attrDef.Datatype.TokenizedType == XmlTokenizedType.ID && !ignoreErrors) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_AttListPresence, string.Empty); - } - - if (attrDef.TokenizedType != XmlTokenizedType.CDATA) - { - // non-CDATA attribute type normalization - strip spaces - attrDef.DefaultValueExpanded = GetValueWithStrippedSpaces(); - } - else - { - attrDef.DefaultValueExpanded = GetValue(); - } - attrDef.ValueLineNumber = (int)_literalLineInfo.lineNo; - attrDef.ValueLinePosition = (int)_literalLineInfo.linePos + 1; - - DtdValidator.SetDefaultTypedValue(attrDef, _readerAdapter); - return; - - UnexpectedError: - OnUnexpectedError(); - } - - private void ParseElementDecl() - { - // element name - if (GetToken(true) != Token.QName) - { - goto UnexpectedError; - } - - // get schema decl for element - SchemaElementDecl elementDecl = null; - XmlQualifiedName name = GetNameQualified(true); - - if (_schemaInfo.ElementDecls.TryGetValue(name, out elementDecl)) - { - if (_validate) - { - SendValidationEvent(_curPos - name.Name.Length, XmlSeverityType.Error, ResXml.Sch_DupElementDecl, GetNameString()); - } - } - else - { - if (_schemaInfo.UndeclaredElementDecls.TryGetValue(name, out elementDecl)) - { - _schemaInfo.UndeclaredElementDecls.Remove(name); - } - else - { - elementDecl = new SchemaElementDecl(name, name.Namespace); - } - _schemaInfo.ElementDecls.Add(name, elementDecl); - } - elementDecl.IsDeclaredInExternal = !ParsingInternalSubset; - - // content spec - switch (GetToken(true)) - { - case Token.EMPTY: - elementDecl.ContentValidator = ContentValidator.Empty; - break; - case Token.ANY: - elementDecl.ContentValidator = ContentValidator.Any; - break; - case Token.LeftParen: - int startParenEntityId = _currentEntityId; - switch (GetToken(false)) - { - case Token.PCDATA: - { - ParticleContentValidator pcv = new ParticleContentValidator(XmlSchemaContentType.Mixed); - pcv.Start(); - pcv.OpenGroup(); - - ParseElementMixedContent(pcv, startParenEntityId); - - elementDecl.ContentValidator = pcv.Finish(true); - break; - } - case Token.None: - { - ParticleContentValidator pcv = null; - pcv = new ParticleContentValidator(XmlSchemaContentType.ElementOnly); - pcv.Start(); - pcv.OpenGroup(); - - ParseElementOnlyContent(pcv, startParenEntityId); - - elementDecl.ContentValidator = pcv.Finish(true); - break; - } - default: - goto UnexpectedError; - } - break; - default: - goto UnexpectedError; - } - if (GetToken(false) != Token.GreaterThan) - { - ThrowUnexpectedToken(_curPos, ">"); - } - return; - - UnexpectedError: - OnUnexpectedError(); - } - - - private class ParseElementOnlyContent_LocalFrame - { - public ParseElementOnlyContent_LocalFrame(int startParentEntityIdParam) - { - startParenEntityId = startParentEntityIdParam; - parsingSchema = Token.None; - } - - // pcv doesn't need to be stored for each frame as it never changes - public int startParenEntityId; - public Token parsingSchema; - } - - private void ParseElementOnlyContent(ParticleContentValidator pcv, int startParenEntityId) - { - Stack localFrames = new Stack(); - ParseElementOnlyContent_LocalFrame currentFrame = new ParseElementOnlyContent_LocalFrame(startParenEntityId); - localFrames.Push(currentFrame); - - RecursiveCall: - - Loop: - switch (GetToken(false)) - { - case Token.QName: - pcv.AddName(GetNameQualified(true), null); - ParseHowMany(pcv); - break; - case Token.LeftParen: - pcv.OpenGroup(); - - // We could just do this: - // ParseElementOnlyContent( pcv, currentEntityId ); - // - // But that would be recursion - so we will simulate the call using our localFrames stack - // instead. - currentFrame = - new ParseElementOnlyContent_LocalFrame(_currentEntityId); - localFrames.Push(currentFrame); - goto RecursiveCall; - // And we should return here when we return from recursion call - // but it's the same as returning after the switch statement - - case Token.GreaterThan: - Throw(_curPos, ResXml.Xml_InvalidContentModel); - goto Return; - default: - goto UnexpectedError; - } - - ReturnFromRecursiveCall: - switch (GetToken(false)) - { - case Token.Comma: - if (currentFrame.parsingSchema == Token.Or) - { - Throw(_curPos, ResXml.Xml_InvalidContentModel); - } - pcv.AddSequence(); - currentFrame.parsingSchema = Token.Comma; - break; - case Token.Or: - if (currentFrame.parsingSchema == Token.Comma) - { - Throw(_curPos, ResXml.Xml_InvalidContentModel); - } - pcv.AddChoice(); - currentFrame.parsingSchema = Token.Or; - break; - case Token.RightParen: - pcv.CloseGroup(); - if (_validate && _currentEntityId != currentFrame.startParenEntityId) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - ParseHowMany(pcv); - goto Return; - case Token.GreaterThan: - Throw(_curPos, ResXml.Xml_InvalidContentModel); - goto Return; - default: - goto UnexpectedError; - } - goto Loop; - - UnexpectedError: - OnUnexpectedError(); - - Return: - // This is equivalent to return; statement - // we simlate it using our localFrames stack - localFrames.Pop(); - if (localFrames.Count > 0) - { - currentFrame = (ParseElementOnlyContent_LocalFrame)localFrames.Peek(); - goto ReturnFromRecursiveCall; - } - else - { - return; - } - } - - private void ParseHowMany(ParticleContentValidator pcv) - { - switch (GetToken(false)) - { - case Token.Star: - pcv.AddStar(); - return; - case Token.QMark: - pcv.AddQMark(); - return; - case Token.Plus: - pcv.AddPlus(); - return; - default: - return; - } - } - - private void ParseElementMixedContent(ParticleContentValidator pcv, int startParenEntityId) - { - bool hasNames = false; - int connectorEntityId = -1; - int contentEntityId = _currentEntityId; - - for (; ; ) - { - switch (GetToken(false)) - { - case Token.RightParen: - pcv.CloseGroup(); - if (_validate && _currentEntityId != startParenEntityId) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - if (GetToken(false) == Token.Star && hasNames) - { - pcv.AddStar(); - } - else if (hasNames) - { - ThrowUnexpectedToken(_curPos, "*"); - } - return; - case Token.Or: - if (!hasNames) - { - hasNames = true; - } - else - { - pcv.AddChoice(); - } - if (_validate) - { - connectorEntityId = _currentEntityId; - if (contentEntityId < connectorEntityId) - { // entity repl.text starting with connector - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - } - - if (GetToken(false) != Token.QName) - { - goto default; - } - - XmlQualifiedName name = GetNameQualified(true); - if (pcv.Exists(name) && _validate) - { - SendValidationEvent(XmlSeverityType.Error, ResXml.Sch_DupElement, name.ToString()); - } - pcv.AddName(name, null); - - if (_validate) - { - contentEntityId = _currentEntityId; - if (contentEntityId < connectorEntityId) - { // entity repl.text ending with connector - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - } - continue; - default: - OnUnexpectedError(); - break; - } - } - } - - private void ParseEntityDecl() - { - bool isParamEntity = false; - SchemaEntity entity = null; - - // get entity name and type - switch (GetToken(true)) - { - case Token.Percent: - isParamEntity = true; - if (GetToken(true) != Token.Name) - { - goto UnexpectedError; - } - goto case Token.Name; - case Token.Name: - // create entity object - XmlQualifiedName entityName = GetNameQualified(false); - entity = new SchemaEntity(entityName, isParamEntity); - - entity.BaseURI = BaseUriStr; - entity.DeclaredURI = (_externalDtdBaseUri.Length == 0) ? _documentBaseUri : _externalDtdBaseUri; - - if (isParamEntity) - { - if (!_schemaInfo.ParameterEntities.ContainsKey(entityName)) - { - _schemaInfo.ParameterEntities.Add(entityName, entity); - } - } - else - { - if (!_schemaInfo.GeneralEntities.ContainsKey(entityName)) - { - _schemaInfo.GeneralEntities.Add(entityName, entity); - } - } - entity.DeclaredInExternal = !ParsingInternalSubset; - entity.ParsingInProgress = true; - break; - default: - goto UnexpectedError; - } - - Token token = GetToken(true); - switch (token) - { - case Token.PUBLIC: - case Token.SYSTEM: - string systemId; - string publicId; - - ParseExternalId(token, Token.EntityDecl, out publicId, out systemId); - - entity.IsExternal = true; - entity.Url = systemId; - entity.Pubid = publicId; - - if (GetToken(false) == Token.NData) - { - if (isParamEntity) - { - ThrowUnexpectedToken(_curPos - 5, ">"); // 5 == strlen("NDATA") - } - if (!_whitespaceSeen) - { - Throw(_curPos - 5, ResXml.Xml_ExpectingWhiteSpace, "NDATA"); - } - - if (GetToken(true) != Token.Name) - { - goto UnexpectedError; - } - - entity.NData = GetNameQualified(false); - string notationName = entity.NData.Name; - if (!_schemaInfo.Notations.ContainsKey(notationName)) - { - AddUndeclaredNotation(notationName); - } - } - break; - case Token.Literal: - entity.Text = GetValue(); - entity.Line = (int)_literalLineInfo.lineNo; - entity.Pos = (int)_literalLineInfo.linePos; - break; - default: - goto UnexpectedError; - } - - if (GetToken(false) == Token.GreaterThan) - { - entity.ParsingInProgress = false; - return; - } - - UnexpectedError: - OnUnexpectedError(); - } - - private void ParseNotationDecl() - { - // notation name - if (GetToken(true) != Token.Name) - { - OnUnexpectedError(); - } - - XmlQualifiedName notationName = GetNameQualified(false); - SchemaNotation notation = null; - if (!_schemaInfo.Notations.ContainsKey(notationName.Name)) - { - if (_undeclaredNotations != null) - { - _undeclaredNotations.Remove(notationName.Name); - } - notation = new SchemaNotation(notationName); - _schemaInfo.Notations.Add(notation.Name.Name, notation); - } - else - { - // duplicate notation - if (_validate) - { - SendValidationEvent(_curPos - notationName.Name.Length, XmlSeverityType.Error, ResXml.Sch_DupNotation, notationName.Name); - } - } - - // public / system id - Token token = GetToken(true); - if (token == Token.SYSTEM || token == Token.PUBLIC) - { - string notationPublicId, notationSystemId; - - ParseExternalId(token, Token.NOTATION, out notationPublicId, out notationSystemId); - - if (notation != null) - { - notation.SystemLiteral = notationSystemId; - notation.Pubid = notationPublicId; - } - } - else - { - OnUnexpectedError(); - } - - if (GetToken(false) != Token.GreaterThan) - OnUnexpectedError(); - } - - private void AddUndeclaredNotation(string notationName) - { - if (_undeclaredNotations == null) - { - _undeclaredNotations = new Dictionary(); - } - UndeclaredNotation un = new UndeclaredNotation(notationName, LineNo, LinePos - notationName.Length); - UndeclaredNotation loggedUn; - if (_undeclaredNotations.TryGetValue(notationName, out loggedUn)) - { - un.next = loggedUn.next; - loggedUn.next = un; - } - else - { - _undeclaredNotations.Add(notationName, un); - } - } - - private void ParseComment() - { - SaveParsingBuffer(); - try - { - if (SaveInternalSubsetValue) - { - _readerAdapter.ParseComment(_internalSubsetValueSb); - _internalSubsetValueSb.Append("-->"); - } - else - { - _readerAdapter.ParseComment(null); - } - } - catch (XmlException e) - { - if (e.ResString == ResXml.Xml_UnexpectedEOF && _currentEntityId != 0) - { - SendValidationEvent(XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, null); - } - else - { - throw; - } - } - LoadParsingBuffer(); - } - - private void ParsePI() - { - SaveParsingBuffer(); - if (SaveInternalSubsetValue) - { - _readerAdapter.ParsePI(_internalSubsetValueSb); - _internalSubsetValueSb.Append("?>"); - } - else - { - _readerAdapter.ParsePI(null); - } - LoadParsingBuffer(); - } - - private void ParseCondSection() - { - int csEntityId = _currentEntityId; - - switch (GetToken(false)) - { - case Token.INCLUDE: - if (GetToken(false) != Token.LeftBracket) - { - goto default; - } - if (_validate && csEntityId != _currentEntityId) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - if (_validate) - { - if (_condSectionEntityIds == null) - { - _condSectionEntityIds = new int[CondSectionEntityIdsInitialSize]; - } - else if (_condSectionEntityIds.Length == _condSectionDepth) - { - int[] tmp = new int[_condSectionEntityIds.Length * 2]; - Array.Copy(_condSectionEntityIds, 0, tmp, 0, _condSectionEntityIds.Length); - _condSectionEntityIds = tmp; - } - _condSectionEntityIds[_condSectionDepth] = csEntityId; - } - _condSectionDepth++; - break; - case Token.IGNORE: - if (GetToken(false) != Token.LeftBracket) - { - goto default; - } - if (_validate && csEntityId != _currentEntityId) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - // the content of the ignore section is parsed & skipped by scanning function - if (GetToken(false) != Token.CondSectionEnd) - { - goto default; - } - if (_validate && csEntityId != _currentEntityId) - { - SendValidationEvent(_curPos, XmlSeverityType.Error, ResXml.Sch_ParEntityRefNesting, string.Empty); - } - break; - default: - OnUnexpectedError(); - break; - } - } - - private void ParseExternalId(Token idTokenType, Token declType, out string publicId, out string systemId) - { - LineInfo keywordLineInfo = new LineInfo(LineNo, LinePos - 6); - publicId = null; - systemId = null; - - if (GetToken(true) != Token.Literal) - { - ThrowUnexpectedToken(_curPos, "\"", "'"); - } - - if (idTokenType == Token.SYSTEM) - { - systemId = GetValue(); - - if (systemId.IndexOf('#') >= 0) - { - Throw(_curPos - systemId.Length - 1, ResXml.Xml_FragmentId, new string[] { systemId.Substring(systemId.IndexOf('#')), systemId }); - } - - if (declType == Token.DOCTYPE && !_freeFloatingDtd) - { - _literalLineInfo.linePos++; - _readerAdapter.OnSystemId(systemId, keywordLineInfo, _literalLineInfo); - } - } - else - { - Debug.Assert(idTokenType == Token.PUBLIC); - publicId = GetValue(); - - // verify if it contains chars valid for public ids - int i; - if ((i = _xmlCharType.IsPublicId(publicId)) >= 0) - { - ThrowInvalidChar(_curPos - 1 - publicId.Length + i, publicId, i); - } - - if (declType == Token.DOCTYPE && !_freeFloatingDtd) - { - _literalLineInfo.linePos++; - _readerAdapter.OnPublicId(publicId, keywordLineInfo, _literalLineInfo); - - if (GetToken(false) == Token.Literal) - { - if (!_whitespaceSeen) - { - Throw(ResXml.Xml_ExpectingWhiteSpace, new string(_literalQuoteChar, 1), (int)_literalLineInfo.lineNo, (int)_literalLineInfo.linePos); - } - systemId = GetValue(); - _literalLineInfo.linePos++; - _readerAdapter.OnSystemId(systemId, keywordLineInfo, _literalLineInfo); - } - else - { - ThrowUnexpectedToken(_curPos, "\"", "'"); - } - } - else - { - if (GetToken(false) == Token.Literal) - { - if (!_whitespaceSeen) - { - Throw(ResXml.Xml_ExpectingWhiteSpace, new string(_literalQuoteChar, 1), (int)_literalLineInfo.lineNo, (int)_literalLineInfo.linePos); - } - systemId = GetValue(); - } - else if (declType != Token.NOTATION) - { - ThrowUnexpectedToken(_curPos, "\"", "'"); - } - } - } - } - // - // Scanning methods - works directly with parsing buffer - // - private Token GetToken(bool needWhiteSpace) - { - _whitespaceSeen = false; - for (; ; ) - { - switch (_chars[_curPos]) - { - case (char)0: - if (_curPos == _charsUsed) - { - goto ReadData; - } - else - { - ThrowInvalidChar(_chars, _charsUsed, _curPos); - } - break; - case (char)0xA: - _whitespaceSeen = true; - _curPos++; - _readerAdapter.OnNewLine(_curPos); - continue; - case (char)0xD: - _whitespaceSeen = true; - if (_chars[_curPos + 1] == (char)0xA) - { - if (Normalize) - { - SaveParsingBuffer(); // EOL normalization of 0xD 0xA - _readerAdapter.CurrentPosition++; - } - _curPos += 2; - } - else if (_curPos + 1 < _charsUsed || _readerAdapter.IsEof) - { - _chars[_curPos] = (char)0xA; // EOL normalization of 0xD - _curPos++; - } - else - { - goto ReadData; - } - _readerAdapter.OnNewLine(_curPos); - continue; - case (char)0x9: - case (char)0x20: - _whitespaceSeen = true; - _curPos++; - continue; - case '%': - if (_charsUsed - _curPos < 2) - { - goto ReadData; - } - if (!_xmlCharType.IsWhiteSpace(_chars[_curPos + 1])) - { - if (IgnoreEntityReferences) - { - _curPos++; - } - else - { - HandleEntityReference(true, false, false); - } - continue; - } - goto default; - default: - if (needWhiteSpace && !_whitespaceSeen && _scanningFunction != ScanningFunction.ParamEntitySpace) - { - Throw(_curPos, ResXml.Xml_ExpectingWhiteSpace, ParseUnexpectedToken(_curPos)); - } - _tokenStartPos = _curPos; - SwitchAgain: - switch (_scanningFunction) - { - case ScanningFunction.Name: return ScanNameExpected(); - case ScanningFunction.QName: return ScanQNameExpected(); - case ScanningFunction.Nmtoken: return ScanNmtokenExpected(); - case ScanningFunction.SubsetContent: return ScanSubsetContent(); - case ScanningFunction.Doctype1: return ScanDoctype1(); - case ScanningFunction.Doctype2: return ScanDoctype2(); - case ScanningFunction.Element1: return ScanElement1(); - case ScanningFunction.Element2: return ScanElement2(); - case ScanningFunction.Element3: return ScanElement3(); - case ScanningFunction.Element4: return ScanElement4(); - case ScanningFunction.Element5: return ScanElement5(); - case ScanningFunction.Element6: return ScanElement6(); - case ScanningFunction.Element7: return ScanElement7(); - case ScanningFunction.Attlist1: return ScanAttlist1(); - case ScanningFunction.Attlist2: return ScanAttlist2(); - case ScanningFunction.Attlist3: return ScanAttlist3(); - case ScanningFunction.Attlist4: return ScanAttlist4(); - case ScanningFunction.Attlist5: return ScanAttlist5(); - case ScanningFunction.Attlist6: return ScanAttlist6(); - case ScanningFunction.Attlist7: return ScanAttlist7(); - case ScanningFunction.Notation1: return ScanNotation1(); - case ScanningFunction.SystemId: return ScanSystemId(); - case ScanningFunction.PublicId1: return ScanPublicId1(); - case ScanningFunction.PublicId2: return ScanPublicId2(); - case ScanningFunction.Entity1: return ScanEntity1(); - case ScanningFunction.Entity2: return ScanEntity2(); - case ScanningFunction.Entity3: return ScanEntity3(); - case ScanningFunction.CondSection1: return ScanCondSection1(); - case ScanningFunction.CondSection2: return ScanCondSection2(); - case ScanningFunction.CondSection3: return ScanCondSection3(); - case ScanningFunction.ClosingTag: return ScanClosingTag(); - case ScanningFunction.ParamEntitySpace: - _whitespaceSeen = true; - _scanningFunction = _savedScanningFunction; - goto SwitchAgain; - default: - Debug.Assert(false); - return Token.None; - } - } - ReadData: - if (_readerAdapter.IsEof || ReadData() == 0) - { - if (HandleEntityEnd(false)) - { - continue; - } - if (_scanningFunction == ScanningFunction.SubsetContent) - { - return Token.Eof; - } - else - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - } - } - - private Token ScanSubsetContent() - { - for (; ; ) - { - switch (_chars[_curPos]) - { - case '<': - switch (_chars[_curPos + 1]) - { - case '!': - switch (_chars[_curPos + 2]) - { - case 'E': - if (_chars[_curPos + 3] == 'L') - { - if (_charsUsed - _curPos < 9) - { - goto ReadData; - } - if (_chars[_curPos + 4] != 'E' || _chars[_curPos + 5] != 'M' || - _chars[_curPos + 6] != 'E' || _chars[_curPos + 7] != 'N' || - _chars[_curPos + 8] != 'T') - { - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - } - _curPos += 9; - _scanningFunction = ScanningFunction.QName; - _nextScaningFunction = ScanningFunction.Element1; - return Token.ElementDecl; - } - else if (_chars[_curPos + 3] == 'N') - { - if (_charsUsed - _curPos < 8) - { - goto ReadData; - } - if (_chars[_curPos + 4] != 'T' || _chars[_curPos + 5] != 'I' || - _chars[_curPos + 6] != 'T' || _chars[_curPos + 7] != 'Y') - { - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - } - _curPos += 8; - _scanningFunction = ScanningFunction.Entity1; - return Token.EntityDecl; - } - else - { - if (_charsUsed - _curPos < 4) - { - goto ReadData; - } - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - return Token.None; - } - - case 'A': - if (_charsUsed - _curPos < 9) - { - goto ReadData; - } - if (_chars[_curPos + 3] != 'T' || _chars[_curPos + 4] != 'T' || - _chars[_curPos + 5] != 'L' || _chars[_curPos + 6] != 'I' || - _chars[_curPos + 7] != 'S' || _chars[_curPos + 8] != 'T') - { - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - } - _curPos += 9; - _scanningFunction = ScanningFunction.QName; - _nextScaningFunction = ScanningFunction.Attlist1; - return Token.AttlistDecl; - - case 'N': - if (_charsUsed - _curPos < 10) - { - goto ReadData; - } - if (_chars[_curPos + 3] != 'O' || _chars[_curPos + 4] != 'T' || - _chars[_curPos + 5] != 'A' || _chars[_curPos + 6] != 'T' || - _chars[_curPos + 7] != 'I' || _chars[_curPos + 8] != 'O' || - _chars[_curPos + 9] != 'N') - { - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - } - _curPos += 10; - _scanningFunction = ScanningFunction.Name; - _nextScaningFunction = ScanningFunction.Notation1; - return Token.NotationDecl; - - case '[': - _curPos += 3; - _scanningFunction = ScanningFunction.CondSection1; - return Token.CondSectionStart; - case '-': - if (_chars[_curPos + 3] == '-') - { - _curPos += 4; - return Token.Comment; - } - else - { - if (_charsUsed - _curPos < 4) - { - goto ReadData; - } - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - break; - } - default: - if (_charsUsed - _curPos < 3) - { - goto ReadData; - } - Throw(_curPos + 2, ResXml.Xml_ExpectDtdMarkup); - break; - } - break; - case '?': - _curPos += 2; - return Token.PI; - default: - if (_charsUsed - _curPos < 2) - { - goto ReadData; - } - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - return Token.None; - } - break; - case ']': - if (_charsUsed - _curPos < 2 && !_readerAdapter.IsEof) - { - goto ReadData; - } - if (_chars[_curPos + 1] != ']') - { - _curPos++; - _scanningFunction = ScanningFunction.ClosingTag; - return Token.RightBracket; - } - if (_charsUsed - _curPos < 3 && !_readerAdapter.IsEof) - { - goto ReadData; - } - if (_chars[_curPos + 1] == ']' && _chars[_curPos + 2] == '>') - { - _curPos += 3; - return Token.CondSectionEnd; - } - goto default; - default: - if (_charsUsed - _curPos == 0) - { - goto ReadData; - } - Throw(_curPos, ResXml.Xml_ExpectDtdMarkup); - break; - } - ReadData: - if (ReadData() == 0) - { - Throw(_charsUsed, ResXml.Xml_IncompleteDtdContent); - } - } - } - - private Token ScanNameExpected() - { - ScanName(); - _scanningFunction = _nextScaningFunction; - return Token.Name; - } - - private Token ScanQNameExpected() - { - ScanQName(); - _scanningFunction = _nextScaningFunction; - return Token.QName; - } - - private Token ScanNmtokenExpected() - { - ScanNmtoken(); - _scanningFunction = _nextScaningFunction; - return Token.Nmtoken; - } - - private Token ScanDoctype1() - { - switch (_chars[_curPos]) - { - case 'P': - if (!EatPublicKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.Doctype2; - _scanningFunction = ScanningFunction.PublicId1; - return Token.PUBLIC; - case 'S': - if (!EatSystemKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.Doctype2; - _scanningFunction = ScanningFunction.SystemId; - return Token.SYSTEM; - case '[': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.LeftBracket; - case '>': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - default: - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - return Token.None; - } - } - - private Token ScanDoctype2() - { - switch (_chars[_curPos]) - { - case '[': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.LeftBracket; - case '>': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - default: - Throw(_curPos, ResXml.Xml_ExpectSubOrClose); - return Token.None; - } - } - - private Token ScanClosingTag() - { - if (_chars[_curPos] != '>') - { - ThrowUnexpectedToken(_curPos, ">"); - } - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - } - - private Token ScanElement1() - { - for (; ; ) - { - switch (_chars[_curPos]) - { - case '(': - _scanningFunction = ScanningFunction.Element2; - _curPos++; - return Token.LeftParen; - case 'E': - if (_charsUsed - _curPos < 5) - { - goto ReadData; - } - if (_chars[_curPos + 1] == 'M' && _chars[_curPos + 2] == 'P' && - _chars[_curPos + 3] == 'T' && _chars[_curPos + 4] == 'Y') - { - _curPos += 5; - _scanningFunction = ScanningFunction.ClosingTag; - return Token.EMPTY; - } - goto default; - case 'A': - if (_charsUsed - _curPos < 3) - { - goto ReadData; - } - if (_chars[_curPos + 1] == 'N' && _chars[_curPos + 2] == 'Y') - { - _curPos += 3; - _scanningFunction = ScanningFunction.ClosingTag; - return Token.ANY; - } - goto default; - default: - Throw(_curPos, ResXml.Xml_InvalidContentModel); - break; - } - ReadData: - if (ReadData() == 0) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - } - - private Token ScanElement2() - { - if (_chars[_curPos] == '#') - { - while (_charsUsed - _curPos < 7) - { - if (ReadData() == 0) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - if (_chars[_curPos + 1] == 'P' && _chars[_curPos + 2] == 'C' && - _chars[_curPos + 3] == 'D' && _chars[_curPos + 4] == 'A' && - _chars[_curPos + 5] == 'T' && _chars[_curPos + 6] == 'A') - { - _curPos += 7; - _scanningFunction = ScanningFunction.Element6; - return Token.PCDATA; - } - else - { - Throw(_curPos + 1, ResXml.Xml_ExpectPcData); - } - } - - _scanningFunction = ScanningFunction.Element3; - return Token.None; - } - - private Token ScanElement3() - { - switch (_chars[_curPos]) - { - case '(': - _curPos++; - return Token.LeftParen; - case '>': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - default: - ScanQName(); - _scanningFunction = ScanningFunction.Element4; - return Token.QName; - } - } - - private Token ScanElement4() - { - _scanningFunction = ScanningFunction.Element5; - - Token t; - switch (_chars[_curPos]) - { - case '*': - t = Token.Star; - break; - case '?': - t = Token.QMark; - break; - case '+': - t = Token.Plus; - break; - default: - return Token.None; - } - if (_whitespaceSeen) - { - Throw(_curPos, ResXml.Xml_ExpectNoWhitespace); - } - _curPos++; - return t; - } - - private Token ScanElement5() - { - switch (_chars[_curPos]) - { - case ',': - _curPos++; - _scanningFunction = ScanningFunction.Element3; - return Token.Comma; - case '|': - _curPos++; - _scanningFunction = ScanningFunction.Element3; - return Token.Or; - case ')': - _curPos++; - _scanningFunction = ScanningFunction.Element4; - return Token.RightParen; - case '>': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - default: - Throw(_curPos, ResXml.Xml_ExpectOp); - return Token.None; - } - } - - private Token ScanElement6() - { - switch (_chars[_curPos]) - { - case ')': - _curPos++; - _scanningFunction = ScanningFunction.Element7; - return Token.RightParen; - case '|': - _curPos++; - _nextScaningFunction = ScanningFunction.Element6; - _scanningFunction = ScanningFunction.QName; - return Token.Or; - default: - ThrowUnexpectedToken(_curPos, ")", "|"); - return Token.None; - } - } - - private Token ScanElement7() - { - _scanningFunction = ScanningFunction.ClosingTag; - if (_chars[_curPos] == '*' && !_whitespaceSeen) - { - _curPos++; - return Token.Star; - } - return Token.None; - } - - private Token ScanAttlist1() - { - switch (_chars[_curPos]) - { - case '>': - _curPos++; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.GreaterThan; - default: - if (!_whitespaceSeen) - { - Throw(_curPos, ResXml.Xml_ExpectingWhiteSpace, ParseUnexpectedToken(_curPos)); - } - ScanQName(); - _scanningFunction = ScanningFunction.Attlist2; - return Token.QName; - } - } - - private Token ScanAttlist2() - { - for (; ; ) - { - switch (_chars[_curPos]) - { - case '(': - _curPos++; - _scanningFunction = ScanningFunction.Nmtoken; - _nextScaningFunction = ScanningFunction.Attlist5; - return Token.LeftParen; - case 'C': - if (_charsUsed - _curPos < 5) - goto ReadData; - if (_chars[_curPos + 1] != 'D' || _chars[_curPos + 2] != 'A' || - _chars[_curPos + 3] != 'T' || _chars[_curPos + 4] != 'A') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType1); - } - _curPos += 5; - _scanningFunction = ScanningFunction.Attlist6; - return Token.CDATA; - case 'E': - if (_charsUsed - _curPos < 9) - goto ReadData; - _scanningFunction = ScanningFunction.Attlist6; - if (_chars[_curPos + 1] != 'N' || _chars[_curPos + 2] != 'T' || - _chars[_curPos + 3] != 'I' || _chars[_curPos + 4] != 'T') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - switch (_chars[_curPos + 5]) - { - case 'I': - if (_chars[_curPos + 6] != 'E' || _chars[_curPos + 7] != 'S') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - _curPos += 8; - return Token.ENTITIES; - case 'Y': - _curPos += 6; - return Token.ENTITY; - default: - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - break; - } - break; - case 'I': - if (_charsUsed - _curPos < 6) - goto ReadData; - _scanningFunction = ScanningFunction.Attlist6; - if (_chars[_curPos + 1] != 'D') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - - if (_chars[_curPos + 2] != 'R') - { - _curPos += 2; - return Token.ID; - } - - if (_chars[_curPos + 3] != 'E' || _chars[_curPos + 4] != 'F') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - - if (_chars[_curPos + 5] != 'S') - { - _curPos += 5; - return Token.IDREF; - } - else - { - _curPos += 6; - return Token.IDREFS; - } - case 'N': - if (_charsUsed - _curPos < 8 && !_readerAdapter.IsEof) - { - goto ReadData; - } - switch (_chars[_curPos + 1]) - { - case 'O': - if (_chars[_curPos + 2] != 'T' || _chars[_curPos + 3] != 'A' || - _chars[_curPos + 4] != 'T' || _chars[_curPos + 5] != 'I' || - _chars[_curPos + 6] != 'O' || _chars[_curPos + 7] != 'N') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - _curPos += 8; - _scanningFunction = ScanningFunction.Attlist3; - return Token.NOTATION; - case 'M': - if (_chars[_curPos + 2] != 'T' || _chars[_curPos + 3] != 'O' || - _chars[_curPos + 4] != 'K' || _chars[_curPos + 5] != 'E' || - _chars[_curPos + 6] != 'N') - { - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - } - _scanningFunction = ScanningFunction.Attlist6; - - if (_chars[_curPos + 7] == 'S') - { - _curPos += 8; - return Token.NMTOKENS; - } - else - { - _curPos += 7; - return Token.NMTOKEN; - } - default: - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - break; - } - break; - default: - Throw(_curPos, ResXml.Xml_InvalidAttributeType); - break; - } - - ReadData: - if (ReadData() == 0) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - } - - private Token ScanAttlist3() - { - if (_chars[_curPos] == '(') - { - _curPos++; - _scanningFunction = ScanningFunction.Name; - _nextScaningFunction = ScanningFunction.Attlist4; - return Token.LeftParen; - } - else - { - ThrowUnexpectedToken(_curPos, "("); - return Token.None; - } - } - - private Token ScanAttlist4() - { - switch (_chars[_curPos]) - { - case ')': - _curPos++; - _scanningFunction = ScanningFunction.Attlist6; - return Token.RightParen; - case '|': - _curPos++; - _scanningFunction = ScanningFunction.Name; - _nextScaningFunction = ScanningFunction.Attlist4; - return Token.Or; - default: - ThrowUnexpectedToken(_curPos, ")", "|"); - return Token.None; - } - } - - private Token ScanAttlist5() - { - switch (_chars[_curPos]) - { - case ')': - _curPos++; - _scanningFunction = ScanningFunction.Attlist6; - return Token.RightParen; - case '|': - _curPos++; - _scanningFunction = ScanningFunction.Nmtoken; - _nextScaningFunction = ScanningFunction.Attlist5; - return Token.Or; - default: - ThrowUnexpectedToken(_curPos, ")", "|"); - return Token.None; - } - } - - private Token ScanAttlist6() - { - for (; ; ) - { - switch (_chars[_curPos]) - { - case '"': - case '\'': - ScanLiteral(LiteralType.AttributeValue); - _scanningFunction = ScanningFunction.Attlist1; - return Token.Literal; - case '#': - if (_charsUsed - _curPos < 6) - goto ReadData; - switch (_chars[_curPos + 1]) - { - case 'R': - if (_charsUsed - _curPos < 9) - goto ReadData; - if (_chars[_curPos + 2] != 'E' || _chars[_curPos + 3] != 'Q' || - _chars[_curPos + 4] != 'U' || _chars[_curPos + 5] != 'I' || - _chars[_curPos + 6] != 'R' || _chars[_curPos + 7] != 'E' || - _chars[_curPos + 8] != 'D') - { - Throw(_curPos, ResXml.Xml_ExpectAttType); - } - _curPos += 9; - _scanningFunction = ScanningFunction.Attlist1; - return Token.REQUIRED; - case 'I': - if (_charsUsed - _curPos < 8) - goto ReadData; - if (_chars[_curPos + 2] != 'M' || _chars[_curPos + 3] != 'P' || - _chars[_curPos + 4] != 'L' || _chars[_curPos + 5] != 'I' || - _chars[_curPos + 6] != 'E' || _chars[_curPos + 7] != 'D') - { - Throw(_curPos, ResXml.Xml_ExpectAttType); - } - _curPos += 8; - _scanningFunction = ScanningFunction.Attlist1; - return Token.IMPLIED; - case 'F': - if (_chars[_curPos + 2] != 'I' || _chars[_curPos + 3] != 'X' || - _chars[_curPos + 4] != 'E' || _chars[_curPos + 5] != 'D') - { - Throw(_curPos, ResXml.Xml_ExpectAttType); - } - _curPos += 6; - _scanningFunction = ScanningFunction.Attlist7; - return Token.FIXED; - default: - Throw(_curPos, ResXml.Xml_ExpectAttType); - break; - } - break; - default: - Throw(_curPos, ResXml.Xml_ExpectAttType); - break; - } - ReadData: - if (ReadData() == 0) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - } - - private Token ScanAttlist7() - { - switch (_chars[_curPos]) - { - case '"': - case '\'': - ScanLiteral(LiteralType.AttributeValue); - _scanningFunction = ScanningFunction.Attlist1; - return Token.Literal; - default: - ThrowUnexpectedToken(_curPos, "\"", "'"); - return Token.None; - } - } - - private Token ScanLiteral(LiteralType literalType) - { - Debug.Assert(_chars[_curPos] == '"' || _chars[_curPos] == '\''); - - char quoteChar = _chars[_curPos]; - char replaceChar = (literalType == LiteralType.AttributeValue) ? (char)0x20 : (char)0xA; - int startQuoteEntityId = _currentEntityId; - - _literalLineInfo.Set(LineNo, LinePos); - - _curPos++; - _tokenStartPos = _curPos; - - _stringBuilder.Length = 0; - - for (; ; ) - { - unsafe - { - while ((_xmlCharType.charProperties[_chars[_curPos]] & XmlCharType.fAttrValue) != 0 && _chars[_curPos] != '%') - { - _curPos++; - } - } - - if (_chars[_curPos] == quoteChar && _currentEntityId == startQuoteEntityId) - { - if (_stringBuilder.Length > 0) - { - _stringBuilder.Append(_chars, _tokenStartPos, _curPos - _tokenStartPos); - } - _curPos++; - _literalQuoteChar = quoteChar; - return Token.Literal; - } - - int tmp1 = _curPos - _tokenStartPos; - if (tmp1 > 0) - { - _stringBuilder.Append(_chars, _tokenStartPos, tmp1); - _tokenStartPos = _curPos; - } - - switch (_chars[_curPos]) - { - case '"': - case '\'': - case '>': - _curPos++; - continue; - // eol - case (char)0xA: - _curPos++; - if (Normalize) - { - _stringBuilder.Append(replaceChar); // For attributes: CDATA normalization of 0xA - _tokenStartPos = _curPos; - } - _readerAdapter.OnNewLine(_curPos); - continue; - case (char)0xD: - if (_chars[_curPos + 1] == (char)0xA) - { - if (Normalize) - { - if (literalType == LiteralType.AttributeValue) - { - _stringBuilder.Append(_readerAdapter.IsEntityEolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA - } - else - { - _stringBuilder.Append(_readerAdapter.IsEntityEolNormalized ? "\u000D\u000A" : "\u000A"); // EOL normalization of 0xD 0xA - } - _tokenStartPos = _curPos + 2; - - SaveParsingBuffer(); // EOL normalization of 0xD 0xA in internal subset value - _readerAdapter.CurrentPosition++; - } - _curPos += 2; - } - else if (_curPos + 1 == _charsUsed) - { - goto ReadData; - } - else - { - _curPos++; - if (Normalize) - { - _stringBuilder.Append(replaceChar); // For attributes: CDATA normalization of 0xD and 0xD 0xA - _tokenStartPos = _curPos; // For entities: EOL normalization of 0xD and 0xD 0xA - } - } - _readerAdapter.OnNewLine(_curPos); - continue; - // tab - case (char)0x9: - if (literalType == LiteralType.AttributeValue && Normalize) - { - _stringBuilder.Append((char)0x20); // For attributes: CDATA normalization of 0x9 - _tokenStartPos++; - } - _curPos++; - continue; - // attribute values cannot contain '<' - case '<': - if (literalType == LiteralType.AttributeValue) - { - Throw(_curPos, ResXml.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0')); - } - _curPos++; - continue; - // parameter entity reference - case '%': - if (literalType != LiteralType.EntityReplText) - { - _curPos++; - continue; - } - HandleEntityReference(true, true, literalType == LiteralType.AttributeValue); - _tokenStartPos = _curPos; - continue; - // general entity reference - case '&': - if (literalType == LiteralType.SystemOrPublicID) - { - _curPos++; - continue; - } - if (_curPos + 1 == _charsUsed) - { - goto ReadData; - } - // numeric characters reference - if (_chars[_curPos + 1] == '#') - { - SaveParsingBuffer(); - int endPos = _readerAdapter.ParseNumericCharRef(SaveInternalSubsetValue ? _internalSubsetValueSb : null); - LoadParsingBuffer(); - _stringBuilder.Append(_chars, _curPos, endPos - _curPos); - _readerAdapter.CurrentPosition = endPos; - _tokenStartPos = endPos; - _curPos = endPos; - continue; - } - else - { - // general entity reference - SaveParsingBuffer(); - if (literalType == LiteralType.AttributeValue) - { - int endPos = _readerAdapter.ParseNamedCharRef(true, SaveInternalSubsetValue ? _internalSubsetValueSb : null); - LoadParsingBuffer(); - - if (endPos >= 0) - { - _stringBuilder.Append(_chars, _curPos, endPos - _curPos); - _readerAdapter.CurrentPosition = endPos; - _tokenStartPos = endPos; - _curPos = endPos; - continue; - } - else - { - HandleEntityReference(false, true, true); - _tokenStartPos = _curPos; - } - continue; - } - else - { - int endPos = _readerAdapter.ParseNamedCharRef(false, null); - LoadParsingBuffer(); - - if (endPos >= 0) - { - _tokenStartPos = _curPos; - _curPos = endPos; - continue; - } - else - { - _stringBuilder.Append('&'); - _curPos++; - _tokenStartPos = _curPos; - // Bypass general entities in entity values - XmlQualifiedName entityName = ScanEntityName(); - VerifyEntityReference(entityName, false, false, false); - } - continue; - } - } - default: - // end of buffer - if (_curPos == _charsUsed) - { - goto ReadData; - } - // surrogate chars - else - { - char ch = _chars[_curPos]; - if (XmlCharType.IsHighSurrogate(ch)) - { - if (_curPos + 1 == _charsUsed) - { - goto ReadData; - } - _curPos++; - if (XmlCharType.IsLowSurrogate(_chars[_curPos])) - { - _curPos++; - continue; - } - } - ThrowInvalidChar(_chars, _charsUsed, _curPos); - return Token.None; - } - } - - ReadData: - Debug.Assert(_curPos - _tokenStartPos == 0); - - // read new characters into the buffer - if (_readerAdapter.IsEof || ReadData() == 0) - { - if (literalType == LiteralType.SystemOrPublicID || !HandleEntityEnd(true)) - { - Throw(_curPos, ResXml.Xml_UnclosedQuote); - } - } - _tokenStartPos = _curPos; - } - } - - private XmlQualifiedName ScanEntityName() - { - try - { - ScanName(); - } - catch (XmlException e) - { - Throw(ResXml.Xml_ErrorParsingEntityName, string.Empty, e.LineNumber, e.LinePosition); - } - - if (_chars[_curPos] != ';') - { - ThrowUnexpectedToken(_curPos, ";"); - } - XmlQualifiedName entityName = GetNameQualified(false); - _curPos++; - - return entityName; - } - - private Token ScanNotation1() - { - switch (_chars[_curPos]) - { - case 'P': - if (!EatPublicKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.ClosingTag; - _scanningFunction = ScanningFunction.PublicId1; - return Token.PUBLIC; - case 'S': - if (!EatSystemKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.ClosingTag; - _scanningFunction = ScanningFunction.SystemId; - return Token.SYSTEM; - default: - Throw(_curPos, ResXml.Xml_ExpectExternalOrPublicId); - return Token.None; - } - } - - private Token ScanSystemId() - { - if (_chars[_curPos] != '"' && _chars[_curPos] != '\'') - { - ThrowUnexpectedToken(_curPos, "\"", "'"); - } - - ScanLiteral(LiteralType.SystemOrPublicID); - - _scanningFunction = _nextScaningFunction; - return Token.Literal; - } - - private Token ScanEntity1() - { - if (_chars[_curPos] == '%') - { - _curPos++; - _nextScaningFunction = ScanningFunction.Entity2; - _scanningFunction = ScanningFunction.Name; - return Token.Percent; - } - else - { - ScanName(); - _scanningFunction = ScanningFunction.Entity2; - return Token.Name; - } - } - - private Token ScanEntity2() - { - switch (_chars[_curPos]) - { - case 'P': - if (!EatPublicKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.Entity3; - _scanningFunction = ScanningFunction.PublicId1; - return Token.PUBLIC; - case 'S': - if (!EatSystemKeyword()) - { - Throw(_curPos, ResXml.Xml_ExpectExternalOrClose); - } - _nextScaningFunction = ScanningFunction.Entity3; - _scanningFunction = ScanningFunction.SystemId; - return Token.SYSTEM; - - case '"': - case '\'': - ScanLiteral(LiteralType.EntityReplText); - _scanningFunction = ScanningFunction.ClosingTag; - return Token.Literal; - default: - Throw(_curPos, ResXml.Xml_ExpectExternalIdOrEntityValue); - return Token.None; - } - } - - private Token ScanEntity3() - { - if (_chars[_curPos] == 'N') - { - while (_charsUsed - _curPos < 5) - { - if (ReadData() == 0) - { - goto End; - } - } - if (_chars[_curPos + 1] == 'D' && _chars[_curPos + 2] == 'A' && - _chars[_curPos + 3] == 'T' && _chars[_curPos + 4] == 'A') - { - _curPos += 5; - _scanningFunction = ScanningFunction.Name; - _nextScaningFunction = ScanningFunction.ClosingTag; - return Token.NData; - } - } - End: - _scanningFunction = ScanningFunction.ClosingTag; - return Token.None; - } - - private Token ScanPublicId1() - { - if (_chars[_curPos] != '"' && _chars[_curPos] != '\'') - { - ThrowUnexpectedToken(_curPos, "\"", "'"); - } - - ScanLiteral(LiteralType.SystemOrPublicID); - - _scanningFunction = ScanningFunction.PublicId2; - return Token.Literal; - } - - private Token ScanPublicId2() - { - if (_chars[_curPos] != '"' && _chars[_curPos] != '\'') - { - _scanningFunction = _nextScaningFunction; - return Token.None; - } - - ScanLiteral(LiteralType.SystemOrPublicID); - _scanningFunction = _nextScaningFunction; - - return Token.Literal; - } - - private Token ScanCondSection1() - { - if (_chars[_curPos] != 'I') - { - Throw(_curPos, ResXml.Xml_ExpectIgnoreOrInclude); - } - _curPos++; - - for (; ; ) - { - if (_charsUsed - _curPos < 5) - { - goto ReadData; - } - switch (_chars[_curPos]) - { - case 'N': - if (_charsUsed - _curPos < 6) - { - goto ReadData; - } - if (_chars[_curPos + 1] != 'C' || _chars[_curPos + 2] != 'L' || - _chars[_curPos + 3] != 'U' || _chars[_curPos + 4] != 'D' || - _chars[_curPos + 5] != 'E' || _xmlCharType.IsNameSingleChar(_chars[_curPos + 6]) -#if XML10_FIFTH_EDITION - || xmlCharType.IsNCNameHighSurrogateChar( chars[curPos+6] ) -#endif - ) - { - goto default; - } - _nextScaningFunction = ScanningFunction.SubsetContent; - _scanningFunction = ScanningFunction.CondSection2; - _curPos += 6; - return Token.INCLUDE; - case 'G': - if (_chars[_curPos + 1] != 'N' || _chars[_curPos + 2] != 'O' || - _chars[_curPos + 3] != 'R' || _chars[_curPos + 4] != 'E' || - _xmlCharType.IsNameSingleChar(_chars[_curPos + 5]) -#if XML10_FIFTH_EDITION - ||xmlCharType.IsNCNameHighSurrogateChar( chars[curPos+5] ) -#endif - ) - { - goto default; - } - _nextScaningFunction = ScanningFunction.CondSection3; - _scanningFunction = ScanningFunction.CondSection2; - _curPos += 5; - return Token.IGNORE; - default: - Throw(_curPos - 1, ResXml.Xml_ExpectIgnoreOrInclude); - return Token.None; - } - ReadData: - if (ReadData() == 0) - { - Throw(_curPos, ResXml.Xml_IncompleteDtdContent); - } - } - } - - private Token ScanCondSection2() - { - if (_chars[_curPos] != '[') - { - ThrowUnexpectedToken(_curPos, "["); - } - _curPos++; - _scanningFunction = _nextScaningFunction; - return Token.LeftBracket; - } - - private Token ScanCondSection3() - { - int ignoreSectionDepth = 0; - - // skip ignored part - for (; ; ) - { - unsafe - { - while ((_xmlCharType.charProperties[_chars[_curPos]] & XmlCharType.fText) != 0 && _chars[_curPos] != ']') - { - _curPos++; - } - } - - switch (_chars[_curPos]) - { - case '"': - case '\'': - case (char)0x9: - case '&': - _curPos++; - continue; - // eol - case (char)0xA: - _curPos++; - _readerAdapter.OnNewLine(_curPos); - continue; - case (char)0xD: - if (_chars[_curPos + 1] == (char)0xA) - { - _curPos += 2; - } - else if (_curPos + 1 < _charsUsed || _readerAdapter.IsEof) - { - _curPos++; - } - else - { - goto ReadData; - } - _readerAdapter.OnNewLine(_curPos); - continue; - case '<': - if (_charsUsed - _curPos < 3) - { - goto ReadData; - } - if (_chars[_curPos + 1] != '!' || _chars[_curPos + 2] != '[') - { - _curPos++; - continue; - } - ignoreSectionDepth++; - _curPos += 3; - continue; - case ']': - if (_charsUsed - _curPos < 3) - { - goto ReadData; - } - if (_chars[_curPos + 1] != ']' || _chars[_curPos + 2] != '>') - { - _curPos++; - continue; - } - if (ignoreSectionDepth > 0) - { - ignoreSectionDepth--; - _curPos += 3; - continue; - } - else - { - _curPos += 3; - _scanningFunction = ScanningFunction.SubsetContent; - return Token.CondSectionEnd; - } - default: - // end of buffer - if (_curPos == _charsUsed) - { - goto ReadData; - } - // surrogate chars - else - { - char ch = _chars[_curPos]; - if (XmlCharType.IsHighSurrogate(ch)) - { - if (_curPos + 1 == _charsUsed) - { - goto ReadData; - } - _curPos++; - if (XmlCharType.IsLowSurrogate(_chars[_curPos])) - { - _curPos++; - continue; - } - } - ThrowInvalidChar(_chars, _charsUsed, _curPos); - return Token.None; - } - } - - ReadData: - // read new characters into the buffer - if (_readerAdapter.IsEof || ReadData() == 0) - { - if (HandleEntityEnd(false)) - { - continue; - } - Throw(_curPos, ResXml.Xml_UnclosedConditionalSection); - } - _tokenStartPos = _curPos; - } - } - - private void ScanName() - { - ScanQName(false); - } - - private void ScanQName() - { - ScanQName(SupportNamespaces); - } - - private void ScanQName(bool isQName) - { - _tokenStartPos = _curPos; - int colonOffset = -1; - - for (; ; ) - { - unsafe - { - if ((_xmlCharType.charProperties[_chars[_curPos]] & XmlCharType.fNCStartNameSC) != 0 || _chars[_curPos] == ':') - { // if ( xmlCharType.IsStartNCNameSingleChar(chars[curPos]) || chars[curPos] == ':' ) { - - _curPos++; - } -#if XML10_FIFTH_EDITION - else if ( curPos + 1 < charsUsed && xmlCharType.IsNCNameSurrogateChar(chars[curPos+1], chars[curPos])) { - curPos += 2; - } -#endif - else - { - if (_curPos + 1 >= _charsUsed) - { - if (ReadDataInName()) - { - continue; - } - Throw(_curPos, ResXml.Xml_UnexpectedEOF, "Name"); - } - else - { - Throw(_curPos, ResXml.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(_chars, _charsUsed, _curPos)); - } - } - } - - ContinueName: - - unsafe - { - for (; ; ) - { - if ((_xmlCharType.charProperties[_chars[_curPos]] & XmlCharType.fNCNameSC) != 0) - { // while ( xmlCharType.IsNCNameSingleChar(chars[curPos]) ) { - - _curPos++; - } -#if XML10_FIFTH_EDITION - else if ( curPos + 1 < charsUsed && xmlCharType.IsNameSurrogateChar(chars[curPos + 1], chars[curPos]) ) { - curPos += 2; - } -#endif - else - { - break; - } - } - } - - if (_chars[_curPos] == ':') - { - if (isQName) - { - if (colonOffset != -1) - { - Throw(_curPos, ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(':', '\0')); - } - colonOffset = _curPos - _tokenStartPos; - _curPos++; - continue; - } - else - { - _curPos++; - goto ContinueName; - } - } - // end of buffer - else if (_curPos == _charsUsed -#if XML10_FIFTH_EDITION - || ( curPos + 1 == charsUsed && xmlCharType.IsNCNameHighSurrogateChar( chars[curPos] ) ) -#endif - ) - { - if (ReadDataInName()) - { - goto ContinueName; - } - if (_tokenStartPos == _curPos) - { - Throw(_curPos, ResXml.Xml_UnexpectedEOF, "Name"); - } - } - // end of name - _colonPos = (colonOffset == -1) ? -1 : _tokenStartPos + colonOffset; - return; - } - } - - private bool ReadDataInName() - { - int offset = _curPos - _tokenStartPos; - _curPos = _tokenStartPos; - bool newDataRead = (ReadData() != 0); - _tokenStartPos = _curPos; - _curPos += offset; - return newDataRead; - } - - private void ScanNmtoken() - { - _tokenStartPos = _curPos; - - for (; ; ) - { - unsafe - { - for (; ; ) - { - if ((_xmlCharType.charProperties[_chars[_curPos]] & XmlCharType.fNCNameSC) != 0 || _chars[_curPos] == ':') - { // if ( xmlCharType.IsNCNameChar(chars[curPos]) || chars[curPos] == ':' ) { - - _curPos++; - } -#if XML10_FIFTH_EDITION - else if (curPos + 1 < charsUsed && xmlCharType.IsNCNameSurrogateChar(chars[curPos + 1], chars[curPos])) { - curPos += 2; - } -#endif - else - { - break; - } - } - } - - if (_curPos < _charsUsed -#if XML10_FIFTH_EDITION - && ( !xmlCharType.IsNCNameHighSurrogateChar( chars[curPos] ) || curPos + 1 < charsUsed ) -#endif - ) - { - if (_curPos - _tokenStartPos == 0) - { - Throw(_curPos, ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(_chars, _charsUsed, _curPos)); - } - return; - } - - int len = _curPos - _tokenStartPos; - _curPos = _tokenStartPos; - if (ReadData() == 0) - { - if (len > 0) - { - _tokenStartPos = _curPos; - _curPos += len; - return; - } - Throw(_curPos, ResXml.Xml_UnexpectedEOF, "NmToken"); - } - _tokenStartPos = _curPos; - _curPos += len; - } - } - - private bool EatPublicKeyword() - { - Debug.Assert(_chars[_curPos] == 'P'); - while (_charsUsed - _curPos < 6) - { - if (ReadData() == 0) - { - return false; - } - } - if (_chars[_curPos + 1] != 'U' || _chars[_curPos + 2] != 'B' || - _chars[_curPos + 3] != 'L' || _chars[_curPos + 4] != 'I' || - _chars[_curPos + 5] != 'C') - { - return false; - } - _curPos += 6; - return true; - } - - private bool EatSystemKeyword() - { - Debug.Assert(_chars[_curPos] == 'S'); - while (_charsUsed - _curPos < 6) - { - if (ReadData() == 0) - { - return false; - } - } - if (_chars[_curPos + 1] != 'Y' || _chars[_curPos + 2] != 'S' || - _chars[_curPos + 3] != 'T' || _chars[_curPos + 4] != 'E' || - _chars[_curPos + 5] != 'M') - { - return false; - } - _curPos += 6; - return true; - } - - // - // Scanned data getters - // - private XmlQualifiedName GetNameQualified(bool canHavePrefix) - { - Debug.Assert(_curPos - _tokenStartPos > 0); - if (_colonPos == -1) - { - return new XmlQualifiedName(_nameTable.Add(_chars, _tokenStartPos, _curPos - _tokenStartPos)); - } - else - { - if (canHavePrefix) - { - return new XmlQualifiedName(_nameTable.Add(_chars, _colonPos + 1, _curPos - _colonPos - 1), - _nameTable.Add(_chars, _tokenStartPos, _colonPos - _tokenStartPos)); - } - else - { - Throw(_tokenStartPos, ResXml.Xml_ColonInLocalName, GetNameString()); - return null; - } - } - } - - private string GetNameString() - { - Debug.Assert(_curPos - _tokenStartPos > 0); - return new string(_chars, _tokenStartPos, _curPos - _tokenStartPos); - } - - private string GetNmtokenString() - { - return GetNameString(); - } - - private string GetValue() - { - if (_stringBuilder.Length == 0) - { - return new string(_chars, _tokenStartPos, _curPos - _tokenStartPos - 1); - } - else - { - return _stringBuilder.ToString(); - } - } - - private string GetValueWithStrippedSpaces() - { - Debug.Assert(_curPos == 0 || _chars[_curPos - 1] == '"' || _chars[_curPos - 1] == '\''); - // We cannot StripSpaces directly in the buffer - we need the original value inthe buffer intact so that the internal subset value is correct - string val = (_stringBuilder.Length == 0) ? new string(_chars, _tokenStartPos, _curPos - _tokenStartPos - 1) : _stringBuilder.ToString(); - return StripSpaces(val); - } - - // - // Parsing buffer maintainance methods - // - private int ReadData() - { - SaveParsingBuffer(); - int charsRead = _readerAdapter.ReadData(); - LoadParsingBuffer(); - return charsRead; - } - - private void LoadParsingBuffer() - { - _chars = _readerAdapter.ParsingBuffer; - _charsUsed = _readerAdapter.ParsingBufferLength; - _curPos = _readerAdapter.CurrentPosition; - } - - private void SaveParsingBuffer() - { - SaveParsingBuffer(_curPos); - } - - private void SaveParsingBuffer(int internalSubsetValueEndPos) - { - if (SaveInternalSubsetValue) - { - Debug.Assert(_internalSubsetValueSb != null); - - int readerCurPos = _readerAdapter.CurrentPosition; - if (internalSubsetValueEndPos - readerCurPos > 0) - { - _internalSubsetValueSb.Append(_chars, readerCurPos, internalSubsetValueEndPos - readerCurPos); - } - } - _readerAdapter.CurrentPosition = _curPos; - } - - // - // Entity handling - // - private bool HandleEntityReference(bool paramEntity, bool inLiteral, bool inAttribute) - { - Debug.Assert(_chars[_curPos] == '&' || _chars[_curPos] == '%'); - _curPos++; - - return HandleEntityReference(ScanEntityName(), paramEntity, inLiteral, inAttribute); - } - - private bool HandleEntityReference(XmlQualifiedName entityName, bool paramEntity, bool inLiteral, bool inAttribute) - { - Debug.Assert(_chars[_curPos - 1] == ';'); - - SaveParsingBuffer(); - if (paramEntity && ParsingInternalSubset && !ParsingTopLevelMarkup) - { - Throw(_curPos - entityName.Name.Length - 1, ResXml.Xml_InvalidParEntityRef); - } - - SchemaEntity entity = VerifyEntityReference(entityName, paramEntity, true, inAttribute); - if (entity == null) - { - return false; - } - if (entity.ParsingInProgress) - { - Throw(_curPos - entityName.Name.Length - 1, paramEntity ? ResXml.Xml_RecursiveParEntity : ResXml.Xml_RecursiveGenEntity, entityName.Name); - } - - int newEntityId; - if (entity.IsExternal) - { - if (!_readerAdapter.PushEntity(entity, out newEntityId)) - { - return false; - } - _externalEntitiesDepth++; - } - else - { - if (entity.Text.Length == 0) - { - return false; - } - - if (!_readerAdapter.PushEntity(entity, out newEntityId)) - { - return false; - } - } - _currentEntityId = newEntityId; - - if (paramEntity && !inLiteral && _scanningFunction != ScanningFunction.ParamEntitySpace) - { - _savedScanningFunction = _scanningFunction; - _scanningFunction = ScanningFunction.ParamEntitySpace; - } - - LoadParsingBuffer(); - return true; - } - - private bool HandleEntityEnd(bool inLiteral) - { - SaveParsingBuffer(); - - IDtdEntityInfo oldEntity; - if (!_readerAdapter.PopEntity(out oldEntity, out _currentEntityId)) - { - return false; - } - LoadParsingBuffer(); - - if (oldEntity == null) - { - // external subset popped - Debug.Assert(!ParsingInternalSubset || _freeFloatingDtd); - Debug.Assert(_currentEntityId == 0); - if (_scanningFunction == ScanningFunction.ParamEntitySpace) - { - _scanningFunction = _savedScanningFunction; - } - return false; - } - - if (oldEntity.IsExternal) - { - _externalEntitiesDepth--; - } - - if (!inLiteral && _scanningFunction != ScanningFunction.ParamEntitySpace) - { - _savedScanningFunction = _scanningFunction; - _scanningFunction = ScanningFunction.ParamEntitySpace; - } - - return true; - } - - private SchemaEntity VerifyEntityReference(XmlQualifiedName entityName, bool paramEntity, bool mustBeDeclared, bool inAttribute) - { - Debug.Assert(_chars[_curPos - 1] == ';'); - - SchemaEntity entity; - if (paramEntity) - { - _schemaInfo.ParameterEntities.TryGetValue(entityName, out entity); - } - else - { - _schemaInfo.GeneralEntities.TryGetValue(entityName, out entity); - } - - if (entity == null) - { - if (paramEntity) - { - if (_validate) - { - SendValidationEvent(_curPos - entityName.Name.Length - 1, XmlSeverityType.Error, ResXml.Xml_UndeclaredParEntity, entityName.Name); - } - } - else if (mustBeDeclared) - { - if (!ParsingInternalSubset) - { - if (_validate) - { - SendValidationEvent(_curPos - entityName.Name.Length - 1, XmlSeverityType.Error, ResXml.Xml_UndeclaredEntity, entityName.Name); - } - } - else - { - Throw(_curPos - entityName.Name.Length - 1, ResXml.Xml_UndeclaredEntity, entityName.Name); - } - } - return null; - } - - if (!entity.NData.IsEmpty) - { - Throw(_curPos - entityName.Name.Length - 1, ResXml.Xml_UnparsedEntityRef, entityName.Name); - } - - if (inAttribute && entity.IsExternal) - { - Throw(_curPos - entityName.Name.Length - 1, ResXml.Xml_ExternalEntityInAttValue, entityName.Name); - } - - return entity; - } - - // - // Helper methods and properties - // - private void SendValidationEvent(int pos, XmlSeverityType severity, string code, string arg) - { - Debug.Assert(_validate); - SendValidationEvent(severity, new XmlSchemaException(code, arg, BaseUriStr, (int)LineNo, (int)LinePos + (pos - _curPos))); - } - - private void SendValidationEvent(XmlSeverityType severity, string code, string arg) - { - Debug.Assert(_validate); - SendValidationEvent(severity, new XmlSchemaException(code, arg, BaseUriStr, (int)LineNo, (int)LinePos)); - } - - private void SendValidationEvent(XmlSeverityType severity, XmlSchemaException e) - { - Debug.Assert(_validate); - IValidationEventHandling eventHandling = _readerAdapterWithValidation.ValidationEventHandling; - if (eventHandling != null) - { - eventHandling.SendEvent(e, severity); - } - } - - private bool IsAttributeValueType(Token token) - { - return (int)token >= (int)Token.CDATA && (int)token <= (int)Token.NOTATION; - } - - private int LineNo - { - get - { - return _readerAdapter.LineNo; - } - } - - private int LinePos - { - get - { - return _curPos - _readerAdapter.LineStartPosition; - } - } - - private string BaseUriStr - { - get - { - Uri tmp = _readerAdapter.BaseUri; - return (tmp != null) ? tmp.ToString() : string.Empty; - } - } - - private void OnUnexpectedError() - { - Debug.Assert(false, "This is an unexpected error that should have been handled in the ScanXXX methods."); - Throw(_curPos, ResXml.Xml_InternalError); - } - - private void Throw(int curPos, string res) - { - Throw(curPos, res, string.Empty); - } - - private void Throw(int curPos, string res, string arg) - { - _curPos = curPos; - Uri baseUri = _readerAdapter.BaseUri; - _readerAdapter.Throw(new XmlException(res, arg, (int)LineNo, (int)LinePos, baseUri == null ? null : baseUri.ToString())); - } - private void Throw(int curPos, string res, string[] args) - { - _curPos = curPos; - Uri baseUri = _readerAdapter.BaseUri; - _readerAdapter.Throw(new XmlException(res, args, (int)LineNo, (int)LinePos, baseUri == null ? null : baseUri.ToString())); - } - - private void Throw(string res, string arg, int lineNo, int linePos) - { - Uri baseUri = _readerAdapter.BaseUri; - _readerAdapter.Throw(new XmlException(res, arg, (int)lineNo, (int)linePos, baseUri == null ? null : baseUri.ToString())); - } - - private void ThrowInvalidChar(int pos, string data, int invCharPos) - { - Throw(pos, ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(data, invCharPos)); - } - - private void ThrowInvalidChar(char[] data, int length, int invCharPos) - { - Throw(invCharPos, ResXml.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(data, length, invCharPos)); - } - - private void ThrowUnexpectedToken(int pos, string expectedToken) - { - ThrowUnexpectedToken(pos, expectedToken, null); - } - - private void ThrowUnexpectedToken(int pos, string expectedToken1, string expectedToken2) - { - string unexpectedToken = ParseUnexpectedToken(pos); - if (expectedToken2 != null) - { - Throw(_curPos, ResXml.Xml_UnexpectedTokens2, new string[3] { unexpectedToken, expectedToken1, expectedToken2 }); - } - else - { - Throw(_curPos, ResXml.Xml_UnexpectedTokenEx, new string[2] { unexpectedToken, expectedToken1 }); - } - } - - private string ParseUnexpectedToken(int startPos) - { - if (_xmlCharType.IsNCNameSingleChar(_chars[startPos]) -#if XML10_FIFTH_EDITION - || xmlCharType.IsNCNameHighSurrogateChar( chars[startPos] ) -#endif - ) - { // postpone the proper surrogate checking to the loop below - int endPos = startPos; - for (; ; ) - { - if (_xmlCharType.IsNCNameSingleChar(_chars[endPos])) - { - endPos++; - } -#if XML10_FIFTH_EDITION - else if ( chars[endPos] != 0 && // check for end of the buffer - xmlCharType.IsNCNameSurrogateChar( chars[endPos], chars[endPos + 1] ) ) { - endPos += 2; - } -#endif - else - { - break; - } - } - int len = endPos - startPos; - return new string(_chars, startPos, len > 0 ? len : 1); - } - else - { - Debug.Assert(startPos < _charsUsed); - return new string(_chars, startPos, 1); - } - } - - // StripSpaces removes spaces at the beginning and at the end of the value and replaces sequences of spaces with a single space - // !!! This method exists in 2 copies, here and in the XmlTextReaderImplHelper.cs - // If you're changing this one, please also fix the other one. - // (This is necessary due to packaging) - internal static string StripSpaces(string value) - { - int len = value.Length; - if (len <= 0) - { - return string.Empty; - } - - int startPos = 0; - StringBuilder norValue = null; - - while (value[startPos] == 0x20) - { - startPos++; - if (startPos == len) - { - return " "; - } - } - - int i; - for (i = startPos; i < len; i++) - { - if (value[i] == 0x20) - { - int j = i + 1; - while (j < len && value[j] == 0x20) - { - j++; - } - if (j == len) - { - if (norValue == null) - { - return value.Substring(startPos, i - startPos); - } - else - { - norValue.Append(value, startPos, i - startPos); - return norValue.ToString(); - } - } - if (j > i + 1) - { - if (norValue == null) - { - norValue = new StringBuilder(len); - } - norValue.Append(value, startPos, i - startPos + 1); - startPos = j; - i = j - 1; - } - } - } - if (norValue == null) - { - return (startPos == 0) ? value : value.Substring(startPos, len - startPos); - } - else - { - if (i > startPos) - { - norValue.Append(value, startPos, i - startPos); - } - return norValue.ToString(); - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/FacetChecker.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/FacetChecker.cs deleted file mode 100644 index 3b3b73932dc..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/FacetChecker.cs +++ /dev/null @@ -1,1732 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.ComponentModel; - using Microsoft.Xml; - using System.Diagnostics; - using System.Collections; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Globalization; - - /// - internal abstract class FacetsChecker - { - private struct FacetsCompiler - { - private DatatypeImplementation _datatype; - private RestrictionFacets _derivedRestriction; - - private RestrictionFlags _baseFlags; - private RestrictionFlags _baseFixedFlags; - private RestrictionFlags _validRestrictionFlags; - - //Helpers - private XmlSchemaDatatype _nonNegativeInt; - private XmlSchemaDatatype _builtInType; - private XmlTypeCode _builtInEnum; - - private bool _firstPattern; - private StringBuilder _regStr; - private XmlSchemaPatternFacet _pattern_facet; - - public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction) - { - _firstPattern = true; - _regStr = null; - _pattern_facet = null; - _datatype = baseDatatype; - _derivedRestriction = restriction; - _baseFlags = _datatype.Restriction != null ? _datatype.Restriction.Flags : 0; - _baseFixedFlags = _datatype.Restriction != null ? _datatype.Restriction.FixedFlags : 0; - _validRestrictionFlags = _datatype.ValidRestrictionFlags; - _nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype; - _builtInEnum = !(_datatype is Datatype_union || _datatype is Datatype_List) ? _datatype.TypeCode : 0; - _builtInType = (int)_builtInEnum > 0 ? DatatypeImplementation.GetSimpleTypeFromTypeCode(_builtInEnum).Datatype : _datatype; - } - - internal void CompileLengthFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.Length, ResXml.Sch_LengthFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.Length, ResXml.Sch_DupLengthFacet); - _derivedRestriction.Length = XmlBaseConverter.DecimalToInt32((decimal)ParseFacetValue(_nonNegativeInt, facet, ResXml.Sch_LengthFacetInvalid, null, null)); - - if ((_baseFixedFlags & RestrictionFlags.Length) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.Length, _derivedRestriction.Length)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - if ((_baseFlags & RestrictionFlags.Length) != 0) - { - if (_datatype.Restriction.Length < _derivedRestriction.Length) - { - throw new XmlSchemaException(ResXml.Sch_LengthGtBaseLength, facet); - } - } - // If the base has the MinLength facet, check that our derived length is not violating it - if ((_baseFlags & RestrictionFlags.MinLength) != 0) - { - if (_datatype.Restriction.MinLength > _derivedRestriction.Length) - { - throw new XmlSchemaException(ResXml.Sch_MaxMinLengthBaseLength, facet); - } - } - // If the base has the MaxLength facet, check that our derived length is not violating it - if ((_baseFlags & RestrictionFlags.MaxLength) != 0) - { - if (_datatype.Restriction.MaxLength < _derivedRestriction.Length) - { - throw new XmlSchemaException(ResXml.Sch_MaxMinLengthBaseLength, facet); - } - } - SetFlag(facet, RestrictionFlags.Length); - } - - internal void CompileMinLengthFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MinLength, ResXml.Sch_MinLengthFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MinLength, ResXml.Sch_DupMinLengthFacet); - _derivedRestriction.MinLength = XmlBaseConverter.DecimalToInt32((decimal)ParseFacetValue(_nonNegativeInt, facet, ResXml.Sch_MinLengthFacetInvalid, null, null)); - - if ((_baseFixedFlags & RestrictionFlags.MinLength) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MinLength, _derivedRestriction.MinLength)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - if ((_baseFlags & RestrictionFlags.MinLength) != 0) - { - if (_datatype.Restriction.MinLength > _derivedRestriction.MinLength) - { - throw new XmlSchemaException(ResXml.Sch_MinLengthGtBaseMinLength, facet); - } - } - if ((_baseFlags & RestrictionFlags.Length) != 0) - { - if (_datatype.Restriction.Length < _derivedRestriction.MinLength) - { - throw new XmlSchemaException(ResXml.Sch_MaxMinLengthBaseLength, facet); - } - } - SetFlag(facet, RestrictionFlags.MinLength); - } - - internal void CompileMaxLengthFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MaxLength, ResXml.Sch_MaxLengthFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MaxLength, ResXml.Sch_DupMaxLengthFacet); - _derivedRestriction.MaxLength = XmlBaseConverter.DecimalToInt32((decimal)ParseFacetValue(_nonNegativeInt, facet, ResXml.Sch_MaxLengthFacetInvalid, null, null)); - - if ((_baseFixedFlags & RestrictionFlags.MaxLength) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MaxLength, _derivedRestriction.MaxLength)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - if ((_baseFlags & RestrictionFlags.MaxLength) != 0) - { - if (_datatype.Restriction.MaxLength < _derivedRestriction.MaxLength) - { - throw new XmlSchemaException(ResXml.Sch_MaxLengthGtBaseMaxLength, facet); - } - } - if ((_baseFlags & RestrictionFlags.Length) != 0) - { - if (_datatype.Restriction.Length > _derivedRestriction.MaxLength) - { - throw new XmlSchemaException(ResXml.Sch_MaxMinLengthBaseLength, facet); - } - } - SetFlag(facet, RestrictionFlags.MaxLength); - } - - internal void CompilePatternFacet(XmlSchemaPatternFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.Pattern, ResXml.Sch_PatternFacetProhibited); - if (_firstPattern == true) - { - _regStr = new StringBuilder(); - _regStr.Append("("); - _regStr.Append(facet.Value); - _pattern_facet = facet; - _firstPattern = false; - } - else - { - _regStr.Append(")|("); - _regStr.Append(facet.Value); - } - SetFlag(facet, RestrictionFlags.Pattern); - } - - internal void CompileEnumerationFacet(XmlSchemaFacet facet, IXmlNamespaceResolver nsmgr, XmlNameTable nameTable) - { - CheckProhibitedFlag(facet, RestrictionFlags.Enumeration, ResXml.Sch_EnumerationFacetProhibited); - if (_derivedRestriction.Enumeration == null) - { - _derivedRestriction.Enumeration = new ArrayList(); - } - _derivedRestriction.Enumeration.Add(ParseFacetValue(_datatype, facet, ResXml.Sch_EnumerationFacetInvalid, nsmgr, nameTable)); - SetFlag(facet, RestrictionFlags.Enumeration); - } - - internal void CompileWhitespaceFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.WhiteSpace, ResXml.Sch_WhiteSpaceFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.WhiteSpace, ResXml.Sch_DupWhiteSpaceFacet); - if (facet.Value == "preserve") - { - _derivedRestriction.WhiteSpace = XmlSchemaWhiteSpace.Preserve; - } - else if (facet.Value == "replace") - { - _derivedRestriction.WhiteSpace = XmlSchemaWhiteSpace.Replace; - } - else if (facet.Value == "collapse") - { - _derivedRestriction.WhiteSpace = XmlSchemaWhiteSpace.Collapse; - } - else - { - throw new XmlSchemaException(ResXml.Sch_InvalidWhiteSpace, facet.Value, facet); - } - if ((_baseFixedFlags & RestrictionFlags.WhiteSpace) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.WhiteSpace, _derivedRestriction.WhiteSpace)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - //Check base and derived whitespace facets - XmlSchemaWhiteSpace baseWhitespace; - if ((_baseFlags & RestrictionFlags.WhiteSpace) != 0) - { - baseWhitespace = _datatype.Restriction.WhiteSpace; - } - else - { - baseWhitespace = _datatype.BuiltInWhitespaceFacet; - } - if (baseWhitespace == XmlSchemaWhiteSpace.Collapse && - (_derivedRestriction.WhiteSpace == XmlSchemaWhiteSpace.Replace || _derivedRestriction.WhiteSpace == XmlSchemaWhiteSpace.Preserve) - ) - { - throw new XmlSchemaException(ResXml.Sch_WhiteSpaceRestriction1, facet); - } - if (baseWhitespace == XmlSchemaWhiteSpace.Replace && - _derivedRestriction.WhiteSpace == XmlSchemaWhiteSpace.Preserve - ) - { - throw new XmlSchemaException(ResXml.Sch_WhiteSpaceRestriction2, facet); - } - SetFlag(facet, RestrictionFlags.WhiteSpace); - } - - internal void CompileMaxInclusiveFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MaxInclusive, ResXml.Sch_MaxInclusiveFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MaxInclusive, ResXml.Sch_DupMaxInclusiveFacet); - _derivedRestriction.MaxInclusive = ParseFacetValue(_builtInType, facet, ResXml.Sch_MaxInclusiveFacetInvalid, null, null); - - if ((_baseFixedFlags & RestrictionFlags.MaxInclusive) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MaxInclusive, _derivedRestriction.MaxInclusive)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - CheckValue(_derivedRestriction.MaxInclusive, facet); - SetFlag(facet, RestrictionFlags.MaxInclusive); - } - - internal void CompileMaxExclusiveFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MaxExclusive, ResXml.Sch_MaxExclusiveFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MaxExclusive, ResXml.Sch_DupMaxExclusiveFacet); - _derivedRestriction.MaxExclusive = ParseFacetValue(_builtInType, facet, ResXml.Sch_MaxExclusiveFacetInvalid, null, null); - - if ((_baseFixedFlags & RestrictionFlags.MaxExclusive) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MaxExclusive, _derivedRestriction.MaxExclusive)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - CheckValue(_derivedRestriction.MaxExclusive, facet); - SetFlag(facet, RestrictionFlags.MaxExclusive); - } - - internal void CompileMinInclusiveFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MinInclusive, ResXml.Sch_MinInclusiveFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MinInclusive, ResXml.Sch_DupMinInclusiveFacet); - _derivedRestriction.MinInclusive = ParseFacetValue(_builtInType, facet, ResXml.Sch_MinInclusiveFacetInvalid, null, null); - - if ((_baseFixedFlags & RestrictionFlags.MinInclusive) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MinInclusive, _derivedRestriction.MinInclusive)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - CheckValue(_derivedRestriction.MinInclusive, facet); - SetFlag(facet, RestrictionFlags.MinInclusive); - } - - internal void CompileMinExclusiveFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.MinExclusive, ResXml.Sch_MinExclusiveFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.MinExclusive, ResXml.Sch_DupMinExclusiveFacet); - _derivedRestriction.MinExclusive = ParseFacetValue(_builtInType, facet, ResXml.Sch_MinExclusiveFacetInvalid, null, null); - - if ((_baseFixedFlags & RestrictionFlags.MinExclusive) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.MinExclusive, _derivedRestriction.MinExclusive)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - CheckValue(_derivedRestriction.MinExclusive, facet); - SetFlag(facet, RestrictionFlags.MinExclusive); - } - - internal void CompileTotalDigitsFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.TotalDigits, ResXml.Sch_TotalDigitsFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.TotalDigits, ResXml.Sch_DupTotalDigitsFacet); - XmlSchemaDatatype positiveInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.PositiveInteger).Datatype; - _derivedRestriction.TotalDigits = XmlBaseConverter.DecimalToInt32((decimal)ParseFacetValue(positiveInt, facet, ResXml.Sch_TotalDigitsFacetInvalid, null, null)); - - if ((_baseFixedFlags & RestrictionFlags.TotalDigits) != 0) - { - if (!_datatype.IsEqual(_datatype.Restriction.TotalDigits, _derivedRestriction.TotalDigits)) - { - throw new XmlSchemaException(ResXml.Sch_FacetBaseFixed, facet); - } - } - if ((_baseFlags & RestrictionFlags.TotalDigits) != 0) - { - if (_derivedRestriction.TotalDigits > _datatype.Restriction.TotalDigits) - { - throw new XmlSchemaException(ResXml.Sch_TotalDigitsMismatch, string.Empty); - } - } - SetFlag(facet, RestrictionFlags.TotalDigits); - } - - internal void CompileFractionDigitsFacet(XmlSchemaFacet facet) - { - CheckProhibitedFlag(facet, RestrictionFlags.FractionDigits, ResXml.Sch_FractionDigitsFacetProhibited); - CheckDupFlag(facet, RestrictionFlags.FractionDigits, ResXml.Sch_DupFractionDigitsFacet); - _derivedRestriction.FractionDigits = XmlBaseConverter.DecimalToInt32((decimal)ParseFacetValue(_nonNegativeInt, facet, ResXml.Sch_FractionDigitsFacetInvalid, null, null)); - - if ((_derivedRestriction.FractionDigits != 0) && (_datatype.TypeCode != XmlTypeCode.Decimal)) - { - throw new XmlSchemaException(ResXml.Sch_FractionDigitsFacetInvalid, ResXml.Sch_FractionDigitsNotOnDecimal, facet); - } - if ((_baseFlags & RestrictionFlags.FractionDigits) != 0) - { - if (_derivedRestriction.FractionDigits > _datatype.Restriction.FractionDigits) - { - throw new XmlSchemaException(ResXml.Sch_TotalDigitsMismatch, string.Empty); - } - } - SetFlag(facet, RestrictionFlags.FractionDigits); - } - - internal void FinishFacetCompile() - { - //Additional check for pattern facet - //If facet is XMLSchemaPattern, then the String built inside the loop - //needs to be converted to a RegEx - if (_firstPattern == false) - { - if (_derivedRestriction.Patterns == null) - { - _derivedRestriction.Patterns = new ArrayList(); - } - try - { - _regStr.Append(")"); - string tempStr = _regStr.ToString(); - if (tempStr.IndexOf('|') != -1) - { // ordinal compare - _regStr.Insert(0, "("); - _regStr.Append(")"); - } - _derivedRestriction.Patterns.Add(new Regex(Preprocess(_regStr.ToString()), RegexOptions.None)); - } - catch (Exception e) - { - throw new XmlSchemaException(ResXml.Sch_PatternFacetInvalid, new string[] { e.Message }, e, _pattern_facet.SourceUri, _pattern_facet.LineNumber, _pattern_facet.LinePosition, _pattern_facet); - } - } - } - - private void CheckValue(object value, XmlSchemaFacet facet) - { - RestrictionFacets restriction = _datatype.Restriction; - switch (facet.FacetType) - { - case FacetType.MaxInclusive: - if ((_baseFlags & RestrictionFlags.MaxInclusive) != 0) - { //Base facet has maxInclusive - if (_datatype.Compare(value, restriction.MaxInclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MaxInclusiveMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MaxExclusive) != 0) - { //Base facet has maxExclusive - if (_datatype.Compare(value, restriction.MaxExclusive) >= 0) - { - throw new XmlSchemaException(ResXml.Sch_MaxIncExlMismatch, string.Empty); - } - } - break; - - case FacetType.MaxExclusive: - if ((_baseFlags & RestrictionFlags.MaxExclusive) != 0) - { //Base facet has maxExclusive - if (_datatype.Compare(value, restriction.MaxExclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MaxExclusiveMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MaxInclusive) != 0) - { //Base facet has maxInclusive - if (_datatype.Compare(value, restriction.MaxInclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MaxExlIncMismatch, string.Empty); - } - } - break; - - case FacetType.MinInclusive: - if ((_baseFlags & RestrictionFlags.MinInclusive) != 0) - { //Base facet has minInclusive - if (_datatype.Compare(value, restriction.MinInclusive) < 0) - { - throw new XmlSchemaException(ResXml.Sch_MinInclusiveMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MinExclusive) != 0) - { //Base facet has minExclusive - if (_datatype.Compare(value, restriction.MinExclusive) < 0) - { - throw new XmlSchemaException(ResXml.Sch_MinIncExlMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MaxExclusive) != 0) - { //Base facet has maxExclusive - if (_datatype.Compare(value, restriction.MaxExclusive) >= 0) - { - throw new XmlSchemaException(ResXml.Sch_MinIncMaxExlMismatch, string.Empty); - } - } - break; - - case FacetType.MinExclusive: - if ((_baseFlags & RestrictionFlags.MinExclusive) != 0) - { //Base facet has minExclusive - if (_datatype.Compare(value, restriction.MinExclusive) < 0) - { - throw new XmlSchemaException(ResXml.Sch_MinExclusiveMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MinInclusive) != 0) - { //Base facet has minInclusive - if (_datatype.Compare(value, restriction.MinInclusive) < 0) - { - throw new XmlSchemaException(ResXml.Sch_MinExlIncMismatch, string.Empty); - } - } - if ((_baseFlags & RestrictionFlags.MaxExclusive) != 0) - { //Base facet has maxExclusive - if (_datatype.Compare(value, restriction.MaxExclusive) >= 0) - { - throw new XmlSchemaException(ResXml.Sch_MinExlMaxExlMismatch, string.Empty); - } - } - break; - - default: - Debug.Assert(false); - break; - } - } - - internal void CompileFacetCombinations() - { - RestrictionFacets baseRestriction = _datatype.Restriction; - //They are not allowed on the same type but allowed on derived types. - if ( - (_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxExclusive) != 0 - ) - { - throw new XmlSchemaException(ResXml.Sch_MaxInclusiveExclusive, string.Empty); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinInclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MinExclusive) != 0 - ) - { - throw new XmlSchemaException(ResXml.Sch_MinInclusiveExclusive, string.Empty); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.Length) != 0 && - (_derivedRestriction.Flags & (RestrictionFlags.MinLength | RestrictionFlags.MaxLength)) != 0 - ) - { - throw new XmlSchemaException(ResXml.Sch_LengthAndMinMax, string.Empty); - } - - CopyFacetsFromBaseType(); - - // Check combinations - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinLength) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxLength) != 0 - ) - { - if (_derivedRestriction.MinLength > _derivedRestriction.MaxLength) - { - throw new XmlSchemaException(ResXml.Sch_MinLengthGtMaxLength, string.Empty); - } - } - - //TODO MinInc /MinExc /MaxInc / MaxExc checked in derived types - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinInclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) != 0 - ) - { - if (_datatype.Compare(_derivedRestriction.MinInclusive, _derivedRestriction.MaxInclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MinInclusiveGtMaxInclusive, string.Empty); - } - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinInclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxExclusive) != 0 - ) - { - if (_datatype.Compare(_derivedRestriction.MinInclusive, _derivedRestriction.MaxExclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MinInclusiveGtMaxExclusive, string.Empty); - } - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinExclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxExclusive) != 0 - ) - { - if (_datatype.Compare(_derivedRestriction.MinExclusive, _derivedRestriction.MaxExclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MinExclusiveGtMaxExclusive, string.Empty); - } - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinExclusive) != 0 && - (_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) != 0 - ) - { - if (_datatype.Compare(_derivedRestriction.MinExclusive, _derivedRestriction.MaxInclusive) > 0) - { - throw new XmlSchemaException(ResXml.Sch_MinExclusiveGtMaxInclusive, string.Empty); - } - } - if ((_derivedRestriction.Flags & (RestrictionFlags.TotalDigits | RestrictionFlags.FractionDigits)) == (RestrictionFlags.TotalDigits | RestrictionFlags.FractionDigits)) - { - if (_derivedRestriction.FractionDigits > _derivedRestriction.TotalDigits) - { - throw new XmlSchemaException(ResXml.Sch_FractionDigitsGtTotalDigits, string.Empty); - } - } - } - - private void CopyFacetsFromBaseType() - { - RestrictionFacets baseRestriction = _datatype.Restriction; - // Copy additional facets from the base type - if ( - (_derivedRestriction.Flags & RestrictionFlags.Length) == 0 && - (_baseFlags & RestrictionFlags.Length) != 0 - ) - { - _derivedRestriction.Length = baseRestriction.Length; - SetFlag(RestrictionFlags.Length); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinLength) == 0 && - (_baseFlags & RestrictionFlags.MinLength) != 0 - ) - { - _derivedRestriction.MinLength = baseRestriction.MinLength; - SetFlag(RestrictionFlags.MinLength); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MaxLength) == 0 && - (_baseFlags & RestrictionFlags.MaxLength) != 0 - ) - { - _derivedRestriction.MaxLength = baseRestriction.MaxLength; - SetFlag(RestrictionFlags.MaxLength); - } - if ((_baseFlags & RestrictionFlags.Pattern) != 0) - { - if (_derivedRestriction.Patterns == null) - { - _derivedRestriction.Patterns = baseRestriction.Patterns; - } - else - { - _derivedRestriction.Patterns.AddRange(baseRestriction.Patterns); - } - SetFlag(RestrictionFlags.Pattern); - } - - if ((_baseFlags & RestrictionFlags.Enumeration) != 0) - { - if (_derivedRestriction.Enumeration == null) - { - _derivedRestriction.Enumeration = baseRestriction.Enumeration; - } - SetFlag(RestrictionFlags.Enumeration); - } - - if ( - (_derivedRestriction.Flags & RestrictionFlags.WhiteSpace) == 0 && - (_baseFlags & RestrictionFlags.WhiteSpace) != 0 - ) - { - _derivedRestriction.WhiteSpace = baseRestriction.WhiteSpace; - SetFlag(RestrictionFlags.WhiteSpace); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) == 0 && - (_baseFlags & RestrictionFlags.MaxInclusive) != 0 - ) - { - _derivedRestriction.MaxInclusive = baseRestriction.MaxInclusive; - SetFlag(RestrictionFlags.MaxInclusive); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MaxExclusive) == 0 && - (_baseFlags & RestrictionFlags.MaxExclusive) != 0 - ) - { - _derivedRestriction.MaxExclusive = baseRestriction.MaxExclusive; - SetFlag(RestrictionFlags.MaxExclusive); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinInclusive) == 0 && - (_baseFlags & RestrictionFlags.MinInclusive) != 0 - ) - { - _derivedRestriction.MinInclusive = baseRestriction.MinInclusive; - SetFlag(RestrictionFlags.MinInclusive); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.MinExclusive) == 0 && - (_baseFlags & RestrictionFlags.MinExclusive) != 0 - ) - { - _derivedRestriction.MinExclusive = baseRestriction.MinExclusive; - SetFlag(RestrictionFlags.MinExclusive); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.TotalDigits) == 0 && - (_baseFlags & RestrictionFlags.TotalDigits) != 0 - ) - { - _derivedRestriction.TotalDigits = baseRestriction.TotalDigits; - SetFlag(RestrictionFlags.TotalDigits); - } - if ( - (_derivedRestriction.Flags & RestrictionFlags.FractionDigits) == 0 && - (_baseFlags & RestrictionFlags.FractionDigits) != 0 - ) - { - _derivedRestriction.FractionDigits = baseRestriction.FractionDigits; - SetFlag(RestrictionFlags.FractionDigits); - } - } - - private object ParseFacetValue(XmlSchemaDatatype datatype, XmlSchemaFacet facet, string code, IXmlNamespaceResolver nsmgr, XmlNameTable nameTable) - { - object typedValue; - Exception ex = datatype.TryParseValue(facet.Value, nameTable, nsmgr, out typedValue); - if (ex == null) - { - return typedValue; - } - else - { - throw new XmlSchemaException(code, new string[] { ex.Message }, ex, facet.SourceUri, facet.LineNumber, facet.LinePosition, facet); - } - } - - private struct Map - { - internal Map(char m, string r) - { - match = m; - replacement = r; - } - internal char match; - internal string replacement; - }; - - private static readonly Map[] s_map = { - new Map('c', "\\p{_xmlC}"), - new Map('C', "\\P{_xmlC}"), - new Map('d', "\\p{_xmlD}"), - new Map('D', "\\P{_xmlD}"), - new Map('i', "\\p{_xmlI}"), - new Map('I', "\\P{_xmlI}"), - new Map('w', "\\p{_xmlW}"), - new Map('W', "\\P{_xmlW}"), - }; - private static string Preprocess(string pattern) - { - StringBuilder bufBld = new StringBuilder(); - bufBld.Append("^"); - - char[] source = pattern.ToCharArray(); - int length = pattern.Length; - int copyPosition = 0; - for (int position = 0; position < length - 2; position++) - { - if (source[position] == '\\') - { - if (source[position + 1] == '\\') - { - position++; // skip it - } - else - { - char ch = source[position + 1]; - for (int i = 0; i < s_map.Length; i++) - { - if (s_map[i].match == ch) - { - if (copyPosition < position) - { - bufBld.Append(source, copyPosition, position - copyPosition); - } - bufBld.Append(s_map[i].replacement); - position++; - copyPosition = position + 1; - break; - } - } - } - } - } - if (copyPosition < length) - { - bufBld.Append(source, copyPosition, length - copyPosition); - } - - bufBld.Append("$"); - return bufBld.ToString(); - } - - private void CheckProhibitedFlag(XmlSchemaFacet facet, RestrictionFlags flag, string errorCode) - { - if ((_validRestrictionFlags & flag) == 0) - { - throw new XmlSchemaException(errorCode, _datatype.TypeCodeString, facet); - } - } - - private void CheckDupFlag(XmlSchemaFacet facet, RestrictionFlags flag, string errorCode) - { - if ((_derivedRestriction.Flags & flag) != 0) - { - throw new XmlSchemaException(errorCode, facet); - } - } - - private void SetFlag(XmlSchemaFacet facet, RestrictionFlags flag) - { - _derivedRestriction.Flags |= flag; - if (facet.IsFixed) - { - _derivedRestriction.FixedFlags |= flag; - } - } - - private void SetFlag(RestrictionFlags flag) - { - _derivedRestriction.Flags |= flag; - if ((_baseFixedFlags & flag) != 0) - { - _derivedRestriction.FixedFlags |= flag; - } - } - } - - internal virtual Exception CheckLexicalFacets(ref string parseString, XmlSchemaDatatype datatype) - { - CheckWhitespaceFacets(ref parseString, datatype); - return CheckPatternFacets(datatype.Restriction, parseString); - } - internal virtual Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(decimal value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(Int64 value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(Int32 value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(Int16 value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(byte value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(DateTime value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(double value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(float value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(string value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(byte[] value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(TimeSpan value, XmlSchemaDatatype datatype) - { - return null; - } - internal virtual Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype) - { - return null; - } - - internal void CheckWhitespaceFacets(ref string s, XmlSchemaDatatype datatype) - { - // before parsing, check whitespace facet - RestrictionFacets restriction = datatype.Restriction; - - switch (datatype.Variety) - { - case XmlSchemaDatatypeVariety.List: - s = s.Trim(); - break; - - case XmlSchemaDatatypeVariety.Atomic: - if (datatype.BuiltInWhitespaceFacet == XmlSchemaWhiteSpace.Collapse) - { - s = XmlComplianceUtil.NonCDataNormalize(s); - } - else if (datatype.BuiltInWhitespaceFacet == XmlSchemaWhiteSpace.Replace) - { - s = XmlComplianceUtil.CDataNormalize(s); - } - else if (restriction != null && (restriction.Flags & RestrictionFlags.WhiteSpace) != 0) - { //Restriction has whitespace facet specified - if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Replace) - { - s = XmlComplianceUtil.CDataNormalize(s); - } - else if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Collapse) - { - s = XmlComplianceUtil.NonCDataNormalize(s); - } - } - break; - - default: - break; - } - } - internal Exception CheckPatternFacets(RestrictionFacets restriction, string value) - { - if (restriction != null && (restriction.Flags & RestrictionFlags.Pattern) != 0) - { - for (int i = 0; i < restriction.Patterns.Count; ++i) - { - Regex regex = (Regex)restriction.Patterns[i]; - if (!regex.IsMatch(value)) - { - return new XmlSchemaException(ResXml.Sch_PatternConstraintFailed, string.Empty); - } - } - } - return null; - } - - internal virtual bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return false; - } - - //Compile-time Facet Checking - internal virtual RestrictionFacets ConstructRestriction(DatatypeImplementation datatype, XmlSchemaObjectCollection facets, XmlNameTable nameTable) - { - //Datatype is the type on which this method is called - RestrictionFacets derivedRestriction = new RestrictionFacets(); - FacetsCompiler facetCompiler = new FacetsCompiler(datatype, derivedRestriction); - - for (int i = 0; i < facets.Count; ++i) - { - XmlSchemaFacet facet = (XmlSchemaFacet)facets[i]; - if (facet.Value == null) - { - throw new XmlSchemaException(ResXml.Sch_InvalidFacet, facet); - } - IXmlNamespaceResolver nsmgr = new SchemaNamespaceManager(facet); - switch (facet.FacetType) - { - case FacetType.Length: - facetCompiler.CompileLengthFacet(facet); - break; - - case FacetType.MinLength: - facetCompiler.CompileMinLengthFacet(facet); - break; - - case FacetType.MaxLength: - facetCompiler.CompileMaxLengthFacet(facet); - break; - - case FacetType.Pattern: - facetCompiler.CompilePatternFacet(facet as XmlSchemaPatternFacet); - break; - - case FacetType.Enumeration: - facetCompiler.CompileEnumerationFacet(facet, nsmgr, nameTable); - break; - - case FacetType.Whitespace: - facetCompiler.CompileWhitespaceFacet(facet); - break; - - case FacetType.MinInclusive: - facetCompiler.CompileMinInclusiveFacet(facet); - break; - - case FacetType.MinExclusive: - facetCompiler.CompileMinExclusiveFacet(facet); - break; - - case FacetType.MaxInclusive: - facetCompiler.CompileMaxInclusiveFacet(facet); - break; - - case FacetType.MaxExclusive: - facetCompiler.CompileMaxExclusiveFacet(facet); - break; - - case FacetType.TotalDigits: - facetCompiler.CompileTotalDigitsFacet(facet); - break; - - case FacetType.FractionDigits: - facetCompiler.CompileFractionDigitsFacet(facet); - break; - - default: - throw new XmlSchemaException(ResXml.Sch_UnknownFacet, facet); - } - } - facetCompiler.FinishFacetCompile(); - facetCompiler.CompileFacetCombinations(); - return derivedRestriction; - } - - - - - - internal static decimal Power(int x, int y) - { - //Returns X raised to the power Y - decimal returnValue = 1m; - decimal decimalValue = (decimal)x; - if (y > 28) - { //CLR decimal cannot handle more than 29 digits (10 power 28.) - return decimal.MaxValue; - } - for (int i = 0; i < y; i++) - { - returnValue = returnValue * decimalValue; - } - return returnValue; - } - } - - - internal class Numeric10FacetsChecker : FacetsChecker - { - private static readonly char[] s_signs = new char[] { '+', '-' }; - private decimal _maxValue; - private decimal _minValue; - - internal Numeric10FacetsChecker(decimal minVal, decimal maxVal) - { - _minValue = minVal; - _maxValue = maxVal; - } - - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - decimal decimalValue = datatype.ValueConverter.ToDecimal(value); - return CheckValueFacets(decimalValue, datatype); - } - - internal override Exception CheckValueFacets(decimal value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - XmlValueConverter valueConverter = datatype.ValueConverter; - - //Check built-in facets - if (value > _maxValue || value < _minValue) - { - return new OverflowException(string.Format(ResXml.XmlConvert_Overflow, value.ToString(), datatype.TypeCodeString)); - } - //Check user-defined facets - if (flags != 0) - { - if ((flags & RestrictionFlags.MaxInclusive) != 0) - { - if (value > valueConverter.ToDecimal(restriction.MaxInclusive)) - { - return new XmlSchemaException(ResXml.Sch_MaxInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MaxExclusive) != 0) - { - if (value >= valueConverter.ToDecimal(restriction.MaxExclusive)) - { - return new XmlSchemaException(ResXml.Sch_MaxExclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinInclusive) != 0) - { - if (value < valueConverter.ToDecimal(restriction.MinInclusive)) - { - return new XmlSchemaException(ResXml.Sch_MinInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinExclusive) != 0) - { - if (value <= valueConverter.ToDecimal(restriction.MinExclusive)) - { - return new XmlSchemaException(ResXml.Sch_MinExclusiveConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, valueConverter)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return CheckTotalAndFractionDigits(value, restriction.TotalDigits, restriction.FractionDigits, ((flags & RestrictionFlags.TotalDigits) != 0), ((flags & RestrictionFlags.FractionDigits) != 0)); - } - return null; - } - - internal override Exception CheckValueFacets(Int64 value, XmlSchemaDatatype datatype) - { - decimal decimalValue = (decimal)value; - return CheckValueFacets(decimalValue, datatype); - } - - internal override Exception CheckValueFacets(Int32 value, XmlSchemaDatatype datatype) - { - decimal decimalValue = (decimal)value; - return CheckValueFacets(decimalValue, datatype); - } - internal override Exception CheckValueFacets(Int16 value, XmlSchemaDatatype datatype) - { - decimal decimalValue = (decimal)value; - return CheckValueFacets(decimalValue, datatype); - } - internal override Exception CheckValueFacets(byte value, XmlSchemaDatatype datatype) - { - decimal decimalValue = (decimal)value; - return CheckValueFacets(decimalValue, datatype); - } - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration(datatype.ValueConverter.ToDecimal(value), enumeration, datatype.ValueConverter); - } - - internal bool MatchEnumeration(decimal value, ArrayList enumeration, XmlValueConverter valueConverter) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (value == valueConverter.ToDecimal(enumeration[i])) - { - return true; - } - } - return false; - } - internal Exception CheckTotalAndFractionDigits(decimal value, int totalDigits, int fractionDigits, bool checkTotal, bool checkFraction) - { - decimal maxValue = FacetsChecker.Power(10, totalDigits) - 1; //(decimal)Math.Pow(10, totalDigits) - 1 ; - int powerCnt = 0; - if (value < 0) - { - value = Decimal.Negate(value); //Need to compare maxValue allowed against the absolute value - } - while (Decimal.Truncate(value) != value) - { //Till it has a fraction - value = value * 10; - powerCnt++; - } - - if (checkTotal && (value > maxValue || powerCnt > totalDigits)) - { - return new XmlSchemaException(ResXml.Sch_TotalDigitsConstraintFailed, string.Empty); - } - if (checkFraction && powerCnt > fractionDigits) - { - return new XmlSchemaException(ResXml.Sch_FractionDigitsConstraintFailed, string.Empty); - } - return null; - } - } - - - internal class Numeric2FacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - double doubleValue = datatype.ValueConverter.ToDouble(value); - return CheckValueFacets(doubleValue, datatype); - } - - internal override Exception CheckValueFacets(double value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - XmlValueConverter valueConverter = datatype.ValueConverter; - - if ((flags & RestrictionFlags.MaxInclusive) != 0) - { - if (value > valueConverter.ToDouble(restriction.MaxInclusive)) - { - return new XmlSchemaException(ResXml.Sch_MaxInclusiveConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MaxExclusive) != 0) - { - if (value >= valueConverter.ToDouble(restriction.MaxExclusive)) - { - return new XmlSchemaException(ResXml.Sch_MaxExclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinInclusive) != 0) - { - if (value < (valueConverter.ToDouble(restriction.MinInclusive))) - { - return new XmlSchemaException(ResXml.Sch_MinInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinExclusive) != 0) - { - if (value <= valueConverter.ToDouble(restriction.MinExclusive)) - { - return new XmlSchemaException(ResXml.Sch_MinExclusiveConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, valueConverter)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return null; - } - - internal override Exception CheckValueFacets(float value, XmlSchemaDatatype datatype) - { - double doubleValue = (double)value; - return CheckValueFacets(doubleValue, datatype); - } - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration(datatype.ValueConverter.ToDouble(value), enumeration, datatype.ValueConverter); - } - private bool MatchEnumeration(double value, ArrayList enumeration, XmlValueConverter valueConverter) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (value == valueConverter.ToDouble(enumeration[i])) - { - return true; - } - } - return false; - } - } - - internal class DurationFacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - TimeSpan timeSpanValue = (TimeSpan)datatype.ValueConverter.ChangeType(value, typeof(TimeSpan)); - return CheckValueFacets(timeSpanValue, datatype); - } - - internal override Exception CheckValueFacets(TimeSpan value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - - if ((flags & RestrictionFlags.MaxInclusive) != 0) - { - if (TimeSpan.Compare(value, (TimeSpan)restriction.MaxInclusive) > 0) - { - return new XmlSchemaException(ResXml.Sch_MaxInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MaxExclusive) != 0) - { - if (TimeSpan.Compare(value, (TimeSpan)restriction.MaxExclusive) >= 0) - { - return new XmlSchemaException(ResXml.Sch_MaxExclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinInclusive) != 0) - { - if (TimeSpan.Compare(value, (TimeSpan)restriction.MinInclusive) < 0) - { - return new XmlSchemaException(ResXml.Sch_MinInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinExclusive) != 0) - { - if (TimeSpan.Compare(value, (TimeSpan)restriction.MinExclusive) <= 0) - { - return new XmlSchemaException(ResXml.Sch_MinExclusiveConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return null; - } - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration((TimeSpan)value, enumeration); - } - - private bool MatchEnumeration(TimeSpan value, ArrayList enumeration) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (TimeSpan.Compare(value, (TimeSpan)enumeration[i]) == 0) - { - return true; - } - } - return false; - } - } - - internal class DateTimeFacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - DateTime dateTimeValue = datatype.ValueConverter.ToDateTime(value); - return CheckValueFacets(dateTimeValue, datatype); - } - - internal override Exception CheckValueFacets(DateTime value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - - if ((flags & RestrictionFlags.MaxInclusive) != 0) - { - if (datatype.Compare(value, (DateTime)restriction.MaxInclusive) > 0) - { - return new XmlSchemaException(ResXml.Sch_MaxInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MaxExclusive) != 0) - { - if (datatype.Compare(value, (DateTime)restriction.MaxExclusive) >= 0) - { - return new XmlSchemaException(ResXml.Sch_MaxExclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinInclusive) != 0) - { - if (datatype.Compare(value, (DateTime)restriction.MinInclusive) < 0) - { - return new XmlSchemaException(ResXml.Sch_MinInclusiveConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinExclusive) != 0) - { - if (datatype.Compare(value, (DateTime)restriction.MinExclusive) <= 0) - { - return new XmlSchemaException(ResXml.Sch_MinExclusiveConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, datatype)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return null; - } - - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration(datatype.ValueConverter.ToDateTime(value), enumeration, datatype); - } - - private bool MatchEnumeration(DateTime value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (datatype.Compare(value, (DateTime)enumeration[i]) == 0) - { - return true; - } - } - return false; - } - } - - internal class StringFacetsChecker : FacetsChecker - { //All types derived from string & anyURI - private static Regex s_languagePattern; - - private static Regex LanguagePattern - { - get - { - if (s_languagePattern == null) - { - Regex langRegex = new Regex("^([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*$", RegexOptions.None); - Interlocked.CompareExchange(ref s_languagePattern, langRegex, null); - } - return s_languagePattern; - } - } - - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - string stringValue = datatype.ValueConverter.ToString(value); - return CheckValueFacets(stringValue, datatype, true); - } - - internal override Exception CheckValueFacets(string value, XmlSchemaDatatype datatype) - { - return CheckValueFacets(value, datatype, true); - } - - internal Exception CheckValueFacets(string value, XmlSchemaDatatype datatype, bool verifyUri) - { - //Length, MinLength, MaxLength - int length = value.Length; - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - Exception exception; - - exception = CheckBuiltInFacets(value, datatype.TypeCode, verifyUri); - if (exception != null) return exception; - - if (flags != 0) - { - if ((flags & RestrictionFlags.Length) != 0) - { - if (restriction.Length != length) - { - return new XmlSchemaException(ResXml.Sch_LengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MinLength) != 0) - { - if (length < restriction.MinLength) - { - return new XmlSchemaException(ResXml.Sch_MinLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MaxLength) != 0) - { - if (restriction.MaxLength < length) - { - return new XmlSchemaException(ResXml.Sch_MaxLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, datatype)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - } - return null; - } - - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration(datatype.ValueConverter.ToString(value), enumeration, datatype); - } - - private bool MatchEnumeration(string value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - if (datatype.TypeCode == XmlTypeCode.AnyUri) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (value.Equals(((Uri)enumeration[i]).OriginalString)) - { - return true; - } - } - } - else - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (value.Equals((string)enumeration[i])) - { - return true; - } - } - } - return false; - } - - private Exception CheckBuiltInFacets(string s, XmlTypeCode typeCode, bool verifyUri) - { - Exception exception = null; - - switch (typeCode) - { - case XmlTypeCode.AnyUri: - if (verifyUri) - { - Uri uri; - exception = XmlConvert.TryToUri(s, out uri); - } - break; - - case XmlTypeCode.NormalizedString: - exception = XmlConvert.TryVerifyNormalizedString(s); - break; - - case XmlTypeCode.Token: - exception = XmlConvert.TryVerifyTOKEN(s); - break; - - case XmlTypeCode.Language: - if (s == null || s.Length == 0) - { - return new XmlSchemaException(ResXml.Sch_EmptyAttributeValue, string.Empty); - } - if (!LanguagePattern.IsMatch(s)) - { - return new XmlSchemaException(ResXml.Sch_InvalidLanguageId, string.Empty); - } - break; - - case XmlTypeCode.NmToken: - exception = XmlConvert.TryVerifyNMTOKEN(s); - break; - - case XmlTypeCode.Name: - exception = XmlConvert.TryVerifyName(s); - break; - - case XmlTypeCode.NCName: - case XmlTypeCode.Id: - case XmlTypeCode.Idref: - case XmlTypeCode.Entity: - exception = XmlConvert.TryVerifyNCName(s); - break; - default: - break; - } - return exception; - } - } - - internal class QNameFacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - XmlQualifiedName qualifiedNameValue = (XmlQualifiedName)datatype.ValueConverter.ChangeType(value, typeof(XmlQualifiedName)); - return CheckValueFacets(qualifiedNameValue, datatype); - } - - internal override Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - if (flags != 0) - { //If there are facets defined - string strValue = value.ToString(); - int length = strValue.Length; - if ((flags & RestrictionFlags.Length) != 0) - { - if (restriction.Length != length) - { - return new XmlSchemaException(ResXml.Sch_LengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MinLength) != 0) - { - if (length < restriction.MinLength) - { - return new XmlSchemaException(ResXml.Sch_MinLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MaxLength) != 0) - { - if (restriction.MaxLength < length) - { - return new XmlSchemaException(ResXml.Sch_MaxLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - } - return null; - } - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration((XmlQualifiedName)datatype.ValueConverter.ChangeType(value, typeof(XmlQualifiedName)), enumeration); - } - - private bool MatchEnumeration(XmlQualifiedName value, ArrayList enumeration) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (value.Equals((XmlQualifiedName)enumeration[i])) - { - return true; - } - } - return false; - } - } - - internal class MiscFacetsChecker : FacetsChecker - { //For bool, anySimpleType - } - - internal class BinaryFacetsChecker : FacetsChecker - { //hexBinary & Base64Binary - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - byte[] byteArrayValue = (byte[])value; - return CheckValueFacets(byteArrayValue, datatype); - } - - internal override Exception CheckValueFacets(byte[] value, XmlSchemaDatatype datatype) - { - //Length, MinLength, MaxLength - RestrictionFacets restriction = datatype.Restriction; - int length = value.Length; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - if (flags != 0) - { //if it has facets defined - if ((flags & RestrictionFlags.Length) != 0) - { - if (restriction.Length != length) - { - return new XmlSchemaException(ResXml.Sch_LengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MinLength) != 0) - { - if (length < restriction.MinLength) - { - return new XmlSchemaException(ResXml.Sch_MinLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.MaxLength) != 0) - { - if (restriction.MaxLength < length) - { - return new XmlSchemaException(ResXml.Sch_MaxLengthConstraintFailed, string.Empty); - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, datatype)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - } - return null; - } - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - return MatchEnumeration((byte[])value, enumeration, datatype); - } - - private bool MatchEnumeration(byte[] value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (datatype.Compare(value, (byte[])enumeration[i]) == 0) - { - return true; - } - } - return false; - } - } - - internal class ListFacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - //Check for facets allowed on lists - Length, MinLength, MaxLength - Array values = value as Array; - Debug.Assert(values != null); - - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - - if ((flags & (RestrictionFlags.Length | RestrictionFlags.MinLength | RestrictionFlags.MaxLength)) != 0) - { - int length = values.Length; - if ((flags & RestrictionFlags.Length) != 0) - { - if (restriction.Length != length) - { - return new XmlSchemaException(ResXml.Sch_LengthConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MinLength) != 0) - { - if (length < restriction.MinLength) - { - return new XmlSchemaException(ResXml.Sch_MinLengthConstraintFailed, string.Empty); - } - } - - if ((flags & RestrictionFlags.MaxLength) != 0) - { - if (restriction.MaxLength < length) - { - return new XmlSchemaException(ResXml.Sch_MaxLengthConstraintFailed, string.Empty); - } - } - } - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, datatype)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return null; - } - - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (datatype.Compare(value, enumeration[i]) == 0) - { - return true; - } - } - return false; - } - } - - internal class UnionFacetsChecker : FacetsChecker - { - internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) - { - RestrictionFacets restriction = datatype.Restriction; - RestrictionFlags flags = restriction != null ? restriction.Flags : 0; - - if ((flags & RestrictionFlags.Enumeration) != 0) - { - if (!MatchEnumeration(value, restriction.Enumeration, datatype)) - { - return new XmlSchemaException(ResXml.Sch_EnumerationConstraintFailed, string.Empty); - } - } - return null; - } - - internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) - { - for (int i = 0; i < enumeration.Count; ++i) - { - if (datatype.Compare(value, enumeration[i]) == 0) - { //Compare on Datatype_union will compare two XsdSimpleValue - return true; - } - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/GenerateConverter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/GenerateConverter.cs deleted file mode 100644 index f6ece10a862..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/GenerateConverter.cs +++ /dev/null @@ -1,1118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace MS.Internal.ValueConverter -{ - using System; - using System.Text.RegularExpressions; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.XPath; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using Microsoft.CodeDom.Compiler; // for IndentedTextWriter - using System.Reflection; - - public class Generator - { - private IndentedTextWriter _w; - - public static Type[] InterfaceTypes = { typeof(Boolean), typeof(DateTime), typeof(Decimal), typeof(Double), typeof(Int32), typeof(Int64), typeof(Single), typeof(String), typeof(Object) }; - - // xs:decimal and derived types - public static ConversionRuleGroup Numeric10RuleGroup = - new ConversionRuleGroup("XmlNumeric10Converter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "Decimal", "Decimal", "((decimal) value)"}, - new string[] {"*", "Int32", "Decimal", "((decimal) (int) value)"}, - new string[] {"*", "Int64", "Decimal", "((decimal) (long) value)"}, - new string[] {"*", "String", "Decimal", "XmlConvert.ToInteger((string) value)"}, - new string[] {"xs:decimal", "String", "Decimal", "XmlConvert.ToDecimal((string) value)"}, - new string[] {"*", "XmlAtomicValue", "Decimal", "((decimal) ((XmlAtomicValue) value).ValueAs(DecimalType))"}, - - new string[] {"*", "Decimal", "Int32", "DecimalToInt32((decimal) value)"}, - new string[] {"*", "Int32", "Int32", "((int) value)"}, - new string[] {"*", "Int64", "Int32", "Int64ToInt32((long) value)"}, - new string[] {"*", "String", "Int32", "XmlConvert.ToInt32((string) value)"}, - new string[] {"xs:decimal", "String", "Int32", "DecimalToInt32(XmlConvert.ToDecimal((string) value))"}, - new string[] {"*", "XmlAtomicValue", "Int32", "((XmlAtomicValue) value).ValueAsInt"}, - - new string[] {"*", "Decimal", "Int64", "DecimalToInt64((decimal) value)"}, - new string[] {"*", "Int32", "Int64", "((long) (int) value)"}, - new string[] {"*", "Int64", "Int64", "((long) value)"}, - new string[] {"*", "String", "Int64", "XmlConvert.ToInt64((string) value)"}, - new string[] {"xs:decimal", "String", "Int64", "DecimalToInt64(XmlConvert.ToDecimal((string) value))"}, - new string[] {"*", "XmlAtomicValue", "Int64", "((XmlAtomicValue) value).ValueAsLong"}, - - new string[] {"*", "Decimal", "String", "XmlConvert.ToString(decimal.Truncate((decimal) value))"}, - new string[] {"xs:decimal", "Decimal", "String", "XmlConvert.ToString((decimal) value)"}, - new string[] {"*", "Int32", "String", "XmlConvert.ToString((int) value)"}, - new string[] {"*", "Int64", "String", "XmlConvert.ToString((long) value)"}, - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((XmlAtomicValue) value).Value"}, - - new string[] {"*", "Decimal", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "Int32", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (int) value))"}, - new string[] {"*", "Int64", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (long) value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "Decimal", "XPathItem", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "Int32", "XPathItem", "(new XmlAtomicValue(SchemaType, (int) value))"}, - new string[] {"*", "Int64", "XPathItem", "(new XmlAtomicValue(SchemaType, (long) value))"}, - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - - new string[] {"*", "*", "Byte", "Int32ToByte(this.ToInt32(value))"}, - new string[] {"*", "*", "Int16", "Int32ToInt16(this.ToInt32(value))"}, - new string[] {"*", "*", "SByte", "Int32ToSByte(this.ToInt32(value))"}, - new string[] {"*", "*", "UInt16", "Int32ToUInt16(this.ToInt32(value))"}, - new string[] {"*", "*", "UInt32", "Int64ToUInt32(this.ToInt64(value))"}, - new string[] {"*", "*", "UInt64", "DecimalToUInt64(this.ToDecimal(value))"}, - - new string[] {"*", "Byte", "*", "this.ChangeType((int) (byte) value, destinationType)"}, - new string[] {"*", "Int16", "*", "this.ChangeType((int) (short) value, destinationType)"}, - new string[] {"*", "SByte", "*", "this.ChangeType((int) (sbyte) value, destinationType)"}, - new string[] {"*", "UInt16", "*", "this.ChangeType((int) (ushort) value, destinationType)"}, - new string[] {"*", "UInt32", "*", "this.ChangeType((long) (uint) value, destinationType)"}, - new string[] {"*", "UInt64", "*", "this.ChangeType((decimal) (ulong) value, destinationType)"}, - }); - - // xs:double, xs:float, and derived types - public static ConversionRuleGroup Numeric2RuleGroup = - new ConversionRuleGroup("XmlNumeric2Converter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "Double", "Double", "((double) value)"}, - new string[] {"*", "Single", "Double", "((double) (float) value)"}, - new string[] {"*", "String", "Double", "XmlConvert.ToDouble((string) value)"}, - new string[] {"xs:float", "String", "Double", "((double) XmlConvert.ToSingle((string) value))"}, - new string[] {"*", "XmlAtomicValue", "Double", "((XmlAtomicValue) value).ValueAsDouble"}, - - new string[] {"*", "Double", "Single", "((float) (double) value)"}, - new string[] {"*", "Single", "Single", "((float) value)"}, - new string[] {"*", "String", "Single", "((float) XmlConvert.ToDouble((string) value))"}, - new string[] {"xs:float", "String", "Single", "XmlConvert.ToSingle((string) value)"}, - new string[] {"*", "XmlAtomicValue", "Single", "((float) ((XmlAtomicValue) value).ValueAs(SingleType))"}, - - new string[] {"*", "Double", "String", "XmlConvert.ToString((double) value)"}, - new string[] {"xs:float", "Double", "String", "XmlConvert.ToString(ToSingle((double) value))"}, - new string[] {"*", "Single", "String", "XmlConvert.ToString((double) (float) value)"}, - new string[] {"xs:float", "Single", "String", "XmlConvert.ToString((float) value)"}, - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((XmlAtomicValue) value).Value"}, - - new string[] {"*", "Double", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (double) value))"}, - new string[] {"*", "Single", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "Double", "XPathItem", "(new XmlAtomicValue(SchemaType, (double) value))"}, - new string[] {"*", "Single", "XPathItem", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - }); - - // xs:dateTime, xs:date, xs:time, xs:gDay, xs:gMonth, xs:gMOnthDay, xs:gYear, xs:gYearMonth, and derived types - public static ConversionRuleGroup DateTimeRuleGroup = - new ConversionRuleGroup("XmlDateTimeConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "DateTime", "DateTime", "((DateTime) value)"}, - new string[] {"*", "String", "DateTime", "StringToDateTime((string) value)"}, - new string[] {"xs:date", "String", "DateTime", "StringToDate((string) value)"}, - new string[] {"xs:time", "String", "DateTime", "StringToTime((string) value)"}, - new string[] {"xs:gDay", "String", "DateTime", "StringToGDay((string) value)"}, - new string[] {"xs:gMonth", "String", "DateTime", "StringToGMonth((string) value)"}, - new string[] {"xs:gMonthDay", "String", "DateTime", "StringToGMonthDay((string) value)"}, - new string[] {"xs:gYear", "String", "DateTime", "StringToGYear((string) value)"}, - new string[] {"xs:gYearMonth", "String", "DateTime", "StringToGYearMonth((string) value)"}, - new string[] {"*", "XmlAtomicValue", "DateTime", "((XmlAtomicValue) value).ValueAsDateTime"}, - - new string[] {"*", "DateTime", "String", "DateTimeToString((DateTime) value)"}, - new string[] {"xs:date", "DateTime", "String", "DateToString((DateTime) value)"}, - new string[] {"xs:time", "DateTime", "String", "TimeToString((DateTime) value)"}, - new string[] {"xs:gDay", "DateTime", "String", "GDayToString((DateTime) value)"}, - new string[] {"xs:gMonth", "DateTime", "String", "GMonthToString((DateTime) value)"}, - new string[] {"xs:gMonthDay", "DateTime", "String", "GMonthDayToString((DateTime) value)"}, - new string[] {"xs:gYear", "DateTime", "String", "GYearToString((DateTime) value)"}, - new string[] {"xs:gYearMonth", "DateTime", "String", "GYearMonthToString((DateTime) value)"}, - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((XmlAtomicValue) value).Value"}, - - new string[] {"*", "DateTime", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (DateTime) value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "DateTime", "XPathItem", "(new XmlAtomicValue(SchemaType, (DateTime) value))"}, - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - }); - - // xs:boolean and derived types - public static ConversionRuleGroup BooleanRuleGroup = - new ConversionRuleGroup("XmlBooleanConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "Boolean", "Boolean", "((bool) value)"}, - new string[] {"*", "String", "Boolean", "XmlConvert.ToBoolean((string) value)"}, - new string[] {"*", "XmlAtomicValue", "Boolean", "((XmlAtomicValue) value).ValueAsBoolean"}, - - new string[] {"*", "Boolean", "String", "XmlConvert.ToString((bool) value)"}, - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((XmlAtomicValue) value).Value"}, - - new string[] {"*", "Boolean", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (bool) value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "Boolean", "XPathItem", "(new XmlAtomicValue(SchemaType, (bool) value))"}, - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - }); - - // xs:base64Binary, xs:hexBinary, xs:NOTATION, xs:QName, xs:anyUri, xs:duration, and derived types - public static ConversionRuleGroup MiscRuleGroup = - new ConversionRuleGroup("XmlMiscConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"xs:base64Binary", "ByteArray", "ByteArray", "((byte[]) value)"}, - new string[] {"xs:hexBinary", "ByteArray", "ByteArray", "((byte[]) value)"}, - new string[] {"xs:base64Binary", "String", "ByteArray", "StringToBase64Binary((string) value)"}, - new string[] {"xs:hexBinary", "String", "ByteArray", "StringToHexBinary((string) value)"}, - - new string[] {"xs:NOTATION", "String", "XmlQualifiedName", "StringToQName((string) value, nsResolver)"}, - new string[] {"xs:QName", "String", "XmlQualifiedName", "StringToQName((string) value, nsResolver)"}, - new string[] {"xs:NOTATION", "XmlQualifiedName", "XmlQualifiedName", "((XmlQualifiedName) value)"}, - new string[] {"xs:QName", "XmlQualifiedName", "XmlQualifiedName", "((XmlQualifiedName) value)"}, - - new string[] {"xs:base64Binary", "ByteArray", "String", "Base64BinaryToString((byte[]) value)"}, - new string[] {"xs:hexBinary", "ByteArray", "String", "XmlConvert.ToBinHexString((byte[]) value)"}, - new string[] {"*", "String", "String", "(string) value"}, - new string[] {"xs:anyURI", "Uri", "String", "AnyUriToString((Uri) value)"}, - new string[] {"xs:dayTimeDuration", "TimeSpan", "String", "DayTimeDurationToString((TimeSpan) value)"}, - new string[] {"xs:duration", "TimeSpan", "String", "DurationToString((TimeSpan) value)"}, - new string[] {"xs:yearMonthDuration", "TimeSpan", "String", "YearMonthDurationToString((TimeSpan) value)"}, - new string[] {"xs:NOTATION", "XmlQualifiedName", "String", "QNameToString((XmlQualifiedName) value, nsResolver)"}, - new string[] {"xs:QName", "XmlQualifiedName", "String", "QNameToString((XmlQualifiedName) value, nsResolver)"}, - - new string[] {"xs:dayTimeDuration", "String", "TimeSpan", "StringToDayTimeDuration((string) value)"}, - new string[] {"xs:duration", "String", "TimeSpan", "StringToDuration((string) value)"}, - new string[] {"xs:yearMonthDuration", "String", "TimeSpan", "StringToYearMonthDuration((string) value)"}, - new string[] {"xs:dayTimeDuration", "TimeSpan", "TimeSpan", "((TimeSpan) value)"}, - new string[] {"xs:duration", "TimeSpan", "TimeSpan", "((TimeSpan) value)"}, - new string[] {"xs:yearMonthDuration", "TimeSpan", "TimeSpan", "((TimeSpan) value)"}, - - new string[] {"xs:anyURI", "String", "Uri", "XmlConvert.ToUri((string) value)"}, - new string[] {"xs:anyURI", "Uri", "Uri", "((Uri) value)"}, - - new string[] {"xs:base64Binary", "ByteArray", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"xs:hexBinary", "ByteArray", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string)value, nsResolver))"}, - new string[] {"xs:dayTimeDuration", "TimeSpan", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"xs:duration", "TimeSpan", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"xs:yearMonthDuration", "TimeSpan", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"xs:anyURI", "Uri", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - new string[] {"xs:NOTATION", "XmlQualifiedName", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value, nsResolver))"}, - new string[] {"xs:QName", "XmlQualifiedName", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, value, nsResolver))"}, - - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - - new string[] {"*", "*", "XPathItem", "((XPathItem) this.ChangeType(value, XmlAtomicValueType, nsResolver))"}, - - new string[] {"*", "XmlAtomicValue", "*", "((XmlAtomicValue) value).ValueAs(destinationType, nsResolver)"}, - }); - - // xs:string and derived types - public static ConversionRuleGroup StringRuleGroup = - new ConversionRuleGroup("XmlStringConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((XmlAtomicValue) value).Value"}, - - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - }); - - // xs:untypedAtomic - public static ConversionRuleGroup UntypedRuleGroup = - new ConversionRuleGroup("XmlUntypedConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "String", "Boolean", "XmlConvert.ToBoolean((string) value)"}, - new string[] {"*", "String", "Byte", "Int32ToByte(XmlConvert.ToInt32((string) value))"}, - new string[] {"*", "String", "ByteArray", "StringToBase64Binary((string) value)"}, - new string[] {"*", "String", "DateTime", "UntypedAtomicToDateTime((string) value)"}, - new string[] {"*", "String", "Decimal", "XmlConvert.ToDecimal((string) value)"}, - new string[] {"*", "String", "Double", "XmlConvert.ToDouble((string) value)"}, - new string[] {"*", "String", "Int16", "Int32ToInt16(XmlConvert.ToInt32((string) value))"}, - new string[] {"*", "String", "Int32", "XmlConvert.ToInt32((string) value)"}, - new string[] {"*", "String", "Int64", "XmlConvert.ToInt64((string) value)"}, - new string[] {"*", "String", "SByte", "Int32ToSByte(XmlConvert.ToInt32((string) value))"}, - new string[] {"*", "String", "Single", "XmlConvert.ToSingle((string) value)"}, - new string[] {"*", "String", "TimeSpan", "StringToDuration((string) value)"}, - new string[] {"*", "String", "UInt16", "Int32ToUInt16(XmlConvert.ToInt32((string) value))"}, - new string[] {"*", "String", "UInt32", "Int64ToUInt32(XmlConvert.ToInt64((string) value))"}, - new string[] {"*", "String", "UInt64", "DecimalToUInt64(XmlConvert.ToDecimal((string) value))"}, - new string[] {"*", "String", "Uri", "XmlConvert.ToUri((string) value)"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, (string) value))"}, - new string[] {"*", "String", "XmlQualifiedName", "StringToQName((string) value, nsResolver)"}, - new string[] {"*", "String", "XPathItem", "(new XmlAtomicValue(SchemaType, (string) value))"}, - - new string[] {"*", "Boolean", "String", "XmlConvert.ToString((bool) value)"}, - new string[] {"*", "Byte", "String", "XmlConvert.ToString((byte) value)"}, - new string[] {"*", "ByteArray", "String", "Base64BinaryToString((byte[]) value)"}, - new string[] {"*", "DateTime", "String", "DateTimeToString((DateTime) value)"}, - new string[] {"*", "Decimal", "String", "XmlConvert.ToString((decimal) value)"}, - new string[] {"*", "Double", "String", "XmlConvert.ToString((double) value)"}, - new string[] {"*", "Int16", "String", "XmlConvert.ToString((short) value)"}, - new string[] {"*", "Int32", "String", "XmlConvert.ToString((int) value)"}, - new string[] {"*", "Int64", "String", "XmlConvert.ToString((long) value)"}, - new string[] {"*", "SByte", "String", "XmlConvert.ToString((sbyte) value)"}, - new string[] {"*", "Single", "String", "XmlConvert.ToString((float) value)"}, - new string[] {"*", "String", "String", "((string) value)"}, - new string[] {"*", "TimeSpan", "String", "DurationToString((TimeSpan) value)"}, - new string[] {"*", "UInt16", "String", "XmlConvert.ToString((ushort) value)"}, - new string[] {"*", "UInt32", "String", "XmlConvert.ToString((uint) value)"}, - new string[] {"*", "UInt64", "String", "XmlConvert.ToString((ulong) value)"}, - new string[] {"*", "Uri", "String", "AnyUriToString((Uri) value)"}, - new string[] {"*", "XmlAtomicValue", "String", "((string) ((XmlAtomicValue) value).ValueAs(StringType, nsResolver))"}, - new string[] {"*", "XmlQualifiedName", "String", "QNameToString((XmlQualifiedName) value, nsResolver)"}, - - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - - new string[] {"*", "*", "XmlAtomicValue", "(new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver)))"}, - new string[] {"*", "*", "XPathItem", "(new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver)))"}, - new string[] {"*", "XmlAtomicValue", "*", "((XmlAtomicValue) value).ValueAs(destinationType, nsResolver)"}, - }); - - // node - public static ConversionRuleGroup NodeRuleGroup = - new ConversionRuleGroup("XmlNodeConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "XPathNavigator", "XPathNavigator", "((XPathNavigator) value)"}, - - new string[] {"*", "XPathNavigator", "XPathItem", "((XPathItem) value)"}, - }); - - // item, xs:anyAtomicType - public static ConversionRuleGroup AnyRuleGroup = - new ConversionRuleGroup("XmlAnyConverter", new string[][] - { - // Xml Type Source Clr Type Destination Clr Type Conversion Logic - // ===================================================================================================== - new string[] {"*", "XmlAtomicValue", "Boolean", "((XmlAtomicValue) value).ValueAsBoolean"}, - new string[] {"*", "XmlAtomicValue", "DateTime", "((XmlAtomicValue) value).ValueAsDateTime"}, - new string[] {"*", "XmlAtomicValue", "Decimal", "((decimal) ((XmlAtomicValue) value).ValueAs(DecimalType))"}, - new string[] {"*", "XmlAtomicValue", "Double", "((XmlAtomicValue) value).ValueAsDouble"}, - new string[] {"*", "XmlAtomicValue", "Int32", "((XmlAtomicValue) value).ValueAsInt"}, - new string[] {"*", "XmlAtomicValue", "Int64", "((XmlAtomicValue) value).ValueAsLong"}, - new string[] {"*", "XmlAtomicValue", "Single", "((float) ((XmlAtomicValue) value).ValueAs(SingleType))"}, - new string[] {"*", "XmlAtomicValue", "XmlAtomicValue", "((XmlAtomicValue) value)"}, - - new string[] {"*", "Boolean", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean), (bool) value))"}, - new string[] {"*", "Byte", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedByte), value))"}, - new string[] {"*", "ByteArray", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Base64Binary), value))"}, - new string[] {"*", "DateTime", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTime) value))"}, - new string[] {"*", "Decimal", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Decimal), value))"}, - new string[] {"*", "Double", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Double), (double) value))"}, - new string[] {"*", "Int16", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Short), value))"}, - new string[] {"*", "Int32", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int), (int) value))"}, - new string[] {"*", "Int64", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Long), (long) value))"}, - new string[] {"*", "SByte", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Byte), value))"}, - new string[] {"*", "Single", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Float), value))"}, - new string[] {"*", "String", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String), (string) value))"}, - new string[] {"*", "TimeSpan", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Duration), value))"}, - new string[] {"*", "UInt16", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedShort), value))"}, - new string[] {"*", "UInt32", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedInt), value))"}, - new string[] {"*", "UInt64", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedLong), value))"}, - new string[] {"*", "Uri", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyUri), value))"}, - new string[] {"*", "XmlQualifiedName", "XmlAtomicValue", "(new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName), value, nsResolver))"}, - - new string[] {"*", "XmlAtomicValue", "XPathItem", "((XmlAtomicValue) value)"}, - new string[] {"*", "XPathNavigator", "XPathItem", "((XPathNavigator) value)"}, - - new string[] {"*", "XPathNavigator", "XPathNavigator", "ToNavigator((XPathNavigator) value)"}, - - new string[] {"*", "XmlAtomicValue", "*", "((XmlAtomicValue) value).ValueAs(destinationType, nsResolver)"}, - new string[] {"*", "*", "XPathItem", "((XPathItem) this.ChangeType(value, XmlAtomicValueType, nsResolver))"}, - }); - - public static ConversionRuleGroup[] ConversionsRules = { - Numeric10RuleGroup, - Numeric2RuleGroup, - DateTimeRuleGroup, - BooleanRuleGroup, - MiscRuleGroup, - StringRuleGroup, - UntypedRuleGroup, - NodeRuleGroup, - AnyRuleGroup, - }; - - public void Generate() - { - AutoGenWriter autoGenWriter; - - //----------------------------------------------- - // XmlBaseConverter - //----------------------------------------------- - - // Output list of all CLR types used by the generated code - autoGenWriter = new AutoGenWriter("XmlValueConverter.cs", "AUTOGENERATED_XMLBASECONVERTER"); - _w = autoGenWriter.OpenIndented(); - - List uniqueTypes = new List(); - foreach (ConversionRuleGroup group in ConversionsRules) - { - foreach (Type tSrc in group.FindUniqueSourceTypes(null)) - if (!uniqueTypes.Contains(tSrc)) uniqueTypes.Add(tSrc); - - foreach (Type tDst in group.FindUniqueDestinationTypes(null)) - if (!uniqueTypes.Contains(tDst)) uniqueTypes.Add(tDst); - } - - foreach (Type t in uniqueTypes) - _w.WriteLine("protected static readonly Type " + ClrTypeName(t) + "Type = typeof(" + ClrTypeToCSharpName(t) + ");"); - - _w.WriteLine(); - - // Output default methods which call ChangeType - foreach (Type tDst in InterfaceTypes) - { - foreach (Type tSrc in InterfaceTypes) - { - if (tDst == typeof(object) && tSrc == typeof(object)) - continue; - - StartMethodSignature(tSrc, tDst); - _w.Write("return (" + ClrTypeToCSharpName(tDst) + ") ChangeType((object) value, "); - - if (tDst == typeof(object)) - _w.Write("destinationType"); - else - _w.Write(ClrTypeName(tDst) + "Type"); - - _w.WriteLine(", " + (MethodHasResolver(tSrc, tDst) ? "nsResolver" : "null") + "); }"); - } - - if (tDst == typeof(string)) - { - _w.WriteLine("public override string ToString(string value) {return this.ToString(value, null); }"); - _w.WriteLine("public override string ToString(object value) {return this.ToString(value, null); }"); - } - - if (tDst == typeof(object)) - { - _w.WriteLine("public override object ChangeType(string value, Type destinationType) {return this.ChangeType(value, destinationType, null); }"); - _w.WriteLine("public override object ChangeType(object value, Type destinationType) {return this.ChangeType(value, destinationType, null); }"); - } - - _w.WriteLine(); - } - - autoGenWriter.Close(); - - - //----------------------------------------------- - // Other Converters - //----------------------------------------------- - - foreach (ConversionRuleGroup group in ConversionsRules) - { - IList uniqueSourceTypes, uniqueDestTypes; - - autoGenWriter = new AutoGenWriter("XmlValueConverter.cs", "AUTOGENERATED_" + group.Name.ToUpper()); - _w = autoGenWriter.OpenIndented(); - - foreach (Type tDst in InterfaceTypes) - { - // Handle ChangeType methods later - if (tDst == typeof(object)) - continue; - - _w.WriteLine(); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine("// To" + ClrTypeName(tDst)); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine(); - - // Create strongly-typed ToXXX methods - foreach (Type tSrc in InterfaceTypes) - { - // Handle ToXXX(object value) method later - if (tSrc == typeof(object)) - continue; - - IList rules = group.Find(XmlTypeCode.None, tSrc, tDst); - if (rules.Count > 0) - { - ConversionRule defaultRule = FindDefaultRule(rules); - if (defaultRule == null) - throw new Exception("If conversion from " + tSrc.Name + " to " + tDst.Name + " exists, a default conversion should also be defined."); - - // ToXXX(T value) - StartMethod(tSrc, tDst); - GenerateConversions(defaultRule, rules); - EndMethod(); - } - } - - // Gather all unique source types which have destination type "tDst" - uniqueSourceTypes = group.FindUniqueSourceTypes(tDst); - if (uniqueSourceTypes.Count > 0) - { - // ToXXX(object value); - StartMethod(typeof(object), tDst); - - _w.WriteLine("Type sourceType = value.GetType();"); - _w.WriteLine(); - - foreach (Type tSrc in uniqueSourceTypes) - GenerateConversionsTo(group.Find(XmlTypeCode.None, tSrc, tDst)); - - // If wildcard destination conversions exist, then delegate to ChangeTypeWildcardDestination method to handle them - _w.WriteLine(); - _w.Write("return (" + ClrTypeToCSharpName(tDst) + ") "); - _w.Write(group.FindUniqueSourceTypes(typeof(object)).Count > 0 ? "ChangeTypeWildcardDestination" : "ChangeListType"); - _w.WriteLine("(value, " + ClrTypeName(tDst) + "Type, " + (MethodHasResolver(typeof(object), tDst) ? "nsResolver);" : "null);")); - - EndMethod(); - } - else - { - _w.WriteLine("// This converter does not support conversions to " + ClrTypeName(tDst) + "."); - } - - _w.WriteLine(); - } - - _w.WriteLine(); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine("// ChangeType"); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine(); - - foreach (Type tSrc in InterfaceTypes) - { - // Handle ChangeType(object) later - if (tSrc == typeof(object)) - continue; - - // Gather all unique destination types which have source type "tSrc" - uniqueDestTypes = group.FindUniqueDestinationTypes(tSrc); - if (uniqueDestTypes.Count > 0) - { - // ChangeType(T value, Type destinationType); - StartMethod(tSrc, typeof(object)); - - _w.WriteLine("if (destinationType == ObjectType) destinationType = DefaultClrType;"); - - foreach (Type tDst in uniqueDestTypes) - GenerateConversionsFrom(group.Find(XmlTypeCode.None, tSrc, tDst)); - - // If wildcard source conversions exist, then delegate to ChangeTypeWildcardSource method to handle them - _w.WriteLine(); - if (group.FindUniqueDestinationTypes(typeof(object)).Count > 0) - _w.Write("return ChangeTypeWildcardSource(value, destinationType, "); - else - _w.Write("return ChangeListType(value, destinationType, "); - - _w.WriteLine(MethodHasResolver(typeof(object), tSrc) ? "nsResolver);" : "null);"); - - EndMethod(); - - _w.WriteLine(); - } - } - - // object ChangeType(object value, Type destinationType, IXmlNamespaceResolver resolver); - StartMethod(typeof(object), typeof(object)); - - _w.WriteLine("Type sourceType = value.GetType();"); - _w.WriteLine(); - - // Generate conversions to destinationType - _w.WriteLine("if (destinationType == ObjectType) destinationType = DefaultClrType;"); - - // Strongly-typed destinations - foreach (Type tDst in group.FindUniqueDestinationTypes(null)) - { - // Only output conversions if the destination is not a wildcard - if (tDst == typeof(object)) - continue; - - // Get source types that can be converted to the destination type - uniqueSourceTypes = group.FindUniqueSourceTypes(tDst); - - // Remove wildcard source rules, as they are handled later - int i = 0; - while (i < uniqueSourceTypes.Count) - { - if (uniqueSourceTypes[i] == typeof(object)) - uniqueSourceTypes.RemoveAt(i); - else - i++; - } - - if (uniqueSourceTypes.Count != 0) - { - if (IsInterfaceMethod(tDst) && uniqueSourceTypes.Count > 1) - { - _w.Write("if (destinationType == " + ClrTypeName(tDst) + "Type) "); - _w.WriteLine("return this.To" + ClrTypeName(tDst) + "(value" + (MethodHasResolver(tDst, tDst) ? ", nsResolver);" : ");")); - } - else - { - _w.WriteLine("if (destinationType == " + ClrTypeName(tDst) + "Type) {"); - _w.Indent++; - - foreach (Type tSrc in uniqueSourceTypes) - { - GenerateConversionsTo(group.Find(XmlTypeCode.None, tSrc, tDst)); - } - - _w.Indent--; - _w.WriteLine("}"); - } - } - } - - // Generate conversions from wildcard source types - foreach (Type tDst in group.FindUniqueDestinationTypes(typeof(object))) - GenerateConversionsFrom(group.Find(XmlTypeCode.None, typeof(object), tDst)); - - // Generate conversions to wildcard destination types - foreach (Type tSrc in group.FindUniqueSourceTypes(typeof(object))) - GenerateConversionsTo(group.Find(XmlTypeCode.None, tSrc, typeof(object))); - - _w.WriteLine(); - _w.WriteLine("return ChangeListType(value, destinationType, nsResolver);"); - - EndMethod(); - - uniqueSourceTypes = group.FindUniqueSourceTypes(typeof(object)); - uniqueDestTypes = group.FindUniqueDestinationTypes(typeof(object)); - - if (uniqueSourceTypes.Count != 0 || uniqueDestTypes.Count != 0) - { - _w.WriteLine(); - _w.WriteLine(); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine("// Helpers"); - _w.WriteLine("//-----------------------------------------------"); - _w.WriteLine(); - - // Generate ChangeTypeWildcardDestination method, which performs conversions that are the same no matter what the destination type is - if (uniqueSourceTypes.Count != 0) - { - _w.WriteLine("private object ChangeTypeWildcardDestination(object value, Type destinationType, IXmlNamespaceResolver nsResolver) {"); - _w.Indent++; - - _w.WriteLine("Type sourceType = value.GetType();"); - _w.WriteLine(); - - foreach (Type tSrc in uniqueSourceTypes) - GenerateConversionsTo(group.Find(XmlTypeCode.None, tSrc, typeof(object))); - - _w.WriteLine(); - _w.WriteLine("return ChangeListType(value, destinationType, nsResolver);"); - - _w.Indent--; - _w.WriteLine("}"); - } - - // Generate ChangeTypeWildcardSource method, which performs conversions that are the same no matter what the source type is - if (uniqueDestTypes.Count != 0) - { - _w.WriteLine("private object ChangeTypeWildcardSource(object value, Type destinationType, IXmlNamespaceResolver nsResolver) {"); - _w.Indent++; - - foreach (Type tDst in uniqueDestTypes) - GenerateConversionsFrom(group.Find(XmlTypeCode.None, typeof(object), tDst)); - - _w.WriteLine(); - _w.WriteLine("return ChangeListType(value, destinationType, nsResolver);"); - - _w.Indent--; - _w.WriteLine("}"); - } - } - - autoGenWriter.Close(); - } - } - - private void StartMethod(Type typeSrc, Type typeDst) - { - StartMethodSignature(typeSrc, typeDst); - - _w.WriteLine(); - _w.Indent++; - - if (!typeSrc.GetTypeInfo().IsValueType) - { - _w.WriteLine("if (value == null) throw new ArgumentNullException(\"value\");"); - - if (typeDst != typeof(object)) - _w.WriteLine(); - } - - if (typeDst == typeof(object)) - { - _w.WriteLine("if (destinationType == null) throw new ArgumentNullException(\"destinationType\");"); - _w.WriteLine(); - } - } - - private void StartMethodSignature(Type typeSrc, Type typeDst) - { - string methName, methSig; - - methSig = ClrTypeToCSharpName(typeSrc) + " value"; - - if (typeDst == typeof(object)) - { - methName = "ChangeType"; - methSig += ", Type destinationType"; - } - else - { - methName = "To" + ClrTypeName(typeDst); - } - - if (MethodHasResolver(typeSrc, typeDst)) - methSig += ", IXmlNamespaceResolver nsResolver"; - - _w.Write("public override " + ClrTypeToCSharpName(typeDst) + " " + methName + "(" + methSig + ") {"); - } - - private void EndMethod() - { - _w.Indent--; - _w.WriteLine("}"); - } - - private bool MethodHasResolver(Type typeSrc, Type typeDst) - { - if (typeSrc == typeof(object) || typeSrc == typeof(string)) - { - if (typeDst == typeof(object) || typeDst == typeof(string)) - return true; - } - return false; - } - - private ConversionRule FindDefaultRule(IList rules) - { - foreach (ConversionRule rule in rules) - { - if (rule.XmlType == XmlTypeCode.Item) - return rule; - } - return null; - } - - private void GenerateConversions(ConversionRule defaultRule, IList rulesSwitch) - { - int cnt = rulesSwitch.Count; - - // Don't need to test TypeCode for default rule - if (defaultRule != null) - cnt--; - - if (cnt > 0) - { - if (cnt > 1) - { - _w.WriteLine("switch (TypeCode) {"); - } - - foreach (ConversionRule ruleSwitch in rulesSwitch) - { - if (ruleSwitch != defaultRule) - { - if (cnt > 1) - { - _w.Indent++; - _w.WriteLine("case XmlTypeCode." + ruleSwitch.XmlType + ": return " + ruleSwitch.ConversionExpression + ";"); - _w.Indent--; - } - else - { - _w.WriteLine("if (TypeCode == XmlTypeCode." + ruleSwitch.XmlType + ") return " + ruleSwitch.ConversionExpression + ";"); - } - } - } - - if (cnt > 1) - { - _w.WriteLine("}"); - } - } - - if (defaultRule != null) - _w.WriteLine("return " + defaultRule.ConversionExpression + ";"); - } - - private void GenerateConversionsTo(IList rules) - { - GenerateConversionsToFrom(rules, false); - } - - private void GenerateConversionsFrom(IList rules) - { - GenerateConversionsToFrom(rules, true); - } - - private void GenerateConversionsToFrom(IList rules, bool isFrom) - { - ConversionRule defaultRule = FindDefaultRule(rules); - Type tSrc, tDst; - - // If no conversions exist, then don't generate anything - if (rules.Count == 0) - return; - - tSrc = rules[0].SourceType; - tDst = rules[0].DestinationType; - - if (isFrom) - _w.Write("if (destinationType == " + ClrTypeName(tDst) + "Type) "); - else - _w.Write("if (" + GenerateSourceTypeMatch(tSrc) + ") "); - - if (rules.Count > 1 && IsInterfaceMethod(tSrc) && IsInterfaceMethod(tDst)) - { - // There exists an interface method already which performs switch, so call it - _w.Write("return this.To" + ClrTypeName(tDst) + "((" + ClrTypeToCSharpName(tSrc) + ") value"); - _w.WriteLine(MethodHasResolver(tSrc, tDst) ? ", nsResolver);" : ");"); - } - else - { - // Inline the conversion - if (rules.Count == 1) - { - GenerateConversions(defaultRule, rules); - } - else - { - _w.WriteLine("{"); - _w.Indent++; - - GenerateConversions(defaultRule, rules); - - _w.Indent--; - _w.WriteLine("}"); - } - } - } - - private string GenerateSourceTypeMatch(Type type) - { - TypeInfo info = type.GetTypeInfo(); - if (info.IsValueType || info.IsSealed) - return "sourceType == " + ClrTypeName(type) + "Type"; - - if (info.IsInterface) - return ClrTypeName(type) + "Type.IsAssignableFrom(sourceType)"; - - return "IsDerivedFrom(sourceType, " + ClrTypeName(type) + "Type)"; - } - - private static string ClrTypeName(Type type) - { - if (type.IsArray) - return type.GetElementType().Name + "Array"; - - return type.Name; - } - - private static string ClrTypeToCSharpName(Type type) - { - if (type == typeof(String)) return "string"; - if (type == typeof(SByte)) return "sbyte"; - if (type == typeof(Int16)) return "short"; - if (type == typeof(Int32)) return "int"; - if (type == typeof(Int64)) return "long"; - if (type == typeof(Byte)) return "byte"; - if (type == typeof(UInt16)) return "ushort"; - if (type == typeof(UInt32)) return "uint"; - if (type == typeof(UInt64)) return "ulong"; - if (type == typeof(Double)) return "double"; - if (type == typeof(Single)) return "float"; - if (type == typeof(Decimal)) return "decimal"; - if (type == typeof(Object)) return "object"; - if (type == typeof(Boolean)) return "bool"; - - return type.Name; - } - - private static bool IsInterfaceMethod(Type type) - { - return ((IList)InterfaceTypes).Contains(type); - } - } - - public class ConversionRuleGroup - { - private string _groupName; - private List _rules; - - public ConversionRuleGroup(string groupName, string[][] rules) - { - _groupName = groupName; - _rules = new List(); - - foreach (string[] rule in rules) - { - XmlTypeCode xmlType = XmlTypeNameToTypeCode(rule[0]); - Type clrTypeSrc = ClrTypeNameToType(rule[1]); - Type clrTypeDst = ClrTypeNameToType(rule[2]); - string convExpr = rule[3]; - - AddRule(new ConversionRule(xmlType, clrTypeSrc, clrTypeDst, convExpr)); - } - } - - public string Name - { - get { return _groupName; } - } - - public IList FindUniqueSourceTypes(Type tDst) - { - List types = new List(); - - foreach (ConversionRule rule in Find(XmlTypeCode.None, null, tDst)) - { - if (!types.Contains(rule.SourceType)) - types.Add(rule.SourceType); - } - - return types; - } - - public IList FindUniqueDestinationTypes(Type tSrc) - { - List types = new List(); - - foreach (ConversionRule rule in Find(XmlTypeCode.None, tSrc, null)) - { - if (!types.Contains(rule.DestinationType)) - types.Add(rule.DestinationType); - } - - return types; - } - - public IList Find(XmlTypeCode code, Type tSrc, Type tDst) - { - List subset = new List(); - - foreach (ConversionRule rule in _rules) - { - if (code == XmlTypeCode.None || code == rule.XmlType) - { - if (tSrc == null || tSrc == rule.SourceType) - { - if (tDst == null || tDst == rule.DestinationType) - { - subset.Add(rule); - } - } - } - } - - return subset; - } - - private void AddRule(ConversionRule ruleAdd) - { - for (int i = 0; i < _rules.Count; i++) - { - ConversionRule rule = _rules[i]; - - if (rule.XmlType == ruleAdd.XmlType) - { - if (rule.SourceType == ruleAdd.SourceType) - { - if (rule.DestinationType == ruleAdd.DestinationType) - { - // Override previous rule with new rule - _rules[i] = ruleAdd; - return; - } - } - } - } - - _rules.Add(ruleAdd); - } - - private static XmlTypeCode XmlTypeNameToTypeCode(string name) - { - int idx; - - if (name == "*") - return XmlTypeCode.Item; - - idx = name.IndexOf(':'); - if (idx != -1) - name = name.Substring(idx + 1); - - return (XmlTypeCode)Enum.Parse(typeof(XmlTypeCode), name, true); - } - - private static Type ClrTypeNameToType(string name) - { - Type type = Type.GetType("System." + name); - if (type != null) return type; - - type = Type.GetType("System.IO." + name); - if (type != null) return type; - - if (name == "*") return typeof(object); - if (name == "ByteArray") return typeof(byte[]); - if (name == "XmlQualifiedName") return typeof(XmlQualifiedName); - if (name == "XmlAtomicValue") return typeof(XmlAtomicValue); - if (name == "XPathNavigator") return typeof(XPathNavigator); - if (name == "XPathItem") return typeof(XPathItem); - if (name == "Uri") return typeof(Uri); - if (name == "IEnumerable") return typeof(IEnumerable); - - throw new Exception("Unknown type " + name); - } - } - - public class ConversionRule - { - private XmlTypeCode _xmlType; - private Type _clrTypeSrc,_clrTypeDst; - private string _convExpr; - - public ConversionRule(XmlTypeCode xmlType, Type clrTypeSrc, Type clrTypeDst, string convExpr) - { - _xmlType = xmlType; - _clrTypeSrc = clrTypeSrc; - _clrTypeDst = clrTypeDst; - _convExpr = convExpr; - } - - public XmlTypeCode XmlType - { - get { return _xmlType; } - } - - public Type SourceType - { - get { return _clrTypeSrc; } - } - - public Type DestinationType - { - get { return _clrTypeDst; } - } - - public string ConversionExpression - { - get { return _convExpr; } - } - } - - public class AutoGenWriter - { - private static char[] s_whitespace = { ' ' }; - private FileStream _fs; - private StreamReader _r; - private StringWriter _sw; - private string _regionName; - private int _indent; - - public AutoGenWriter(string fileName, string regionName) : this(File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite), regionName) - { - } - - public AutoGenWriter(FileStream fs, string regionName) - { - if (!fs.CanSeek || !fs.CanRead || !fs.CanWrite) - throw new Exception("Internal error: Unable to seek/read/write this filestream"); - _fs = fs; - _r = new StreamReader(fs); - _sw = new StringWriter(); - _regionName = regionName; - } - - public int Indent { get { return _indent; } } - - public TextWriter Open() - { - // Seek to the autogenerated region within the file - for (string s = _r.ReadLine(); s != null; s = _r.ReadLine()) - { - _sw.WriteLine(s); - if (s.Trim(s_whitespace).StartsWith("#region " + _regionName)) - { - if (s[0] != '#') - _indent = s.IndexOf('#') / 4; - break; - } - } - return _sw; - } - - internal IndentedTextWriter OpenIndented() - { - TextWriter w = Open(); - IndentedTextWriter iw = new IndentedTextWriter(w); - iw.Indent = _indent; - for (int i = 0; i < _indent; i++) - w.Write(" "); - return iw; - } - - internal void Close() - { - // End the autogenerated region - for (string s = _r.ReadLine(); s != null; s = _r.ReadLine()) - { - string ss = s.Trim(s_whitespace); - if (ss.StartsWith("#endregion")) - { - _sw.WriteLine(s); - break; - } - } - - for (string s = _r.ReadLine(); s != null; s = _r.ReadLine()) - { - _sw.WriteLine(s); - } - - _fs.SetLength(0); - _fs.Seek(0, SeekOrigin.Begin); - StreamWriter w = new StreamWriter(_fs); - w.Write(_sw.ToString()); - w.Dispose(); - _sw.Dispose(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/IXmlSchemaInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/IXmlSchemaInfo.cs deleted file mode 100644 index ee0f9271cc1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/IXmlSchemaInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xml; -using System.Collections; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - public interface IXmlSchemaInfo - { - /// - XmlSchemaValidity Validity { get; } - - /// - bool IsDefault { get; } - - /// - bool IsNil { get; } - - /// - XmlSchemaSimpleType MemberType { get; } - - /// - XmlSchemaType SchemaType { get; } - - /// - XmlSchemaElement SchemaElement { get; } - - /// - XmlSchemaAttribute SchemaAttribute { get; } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/XmlSchemaInferenceException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/XmlSchemaInferenceException.cs deleted file mode 100644 index 69696376597..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/XmlSchemaInferenceException.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.IO; - using System.Resources; - using System.Text; - using System.Diagnostics; - // using System.Security.Permissions; - using System.Globalization; - - // [Serializable], - public class XmlSchemaInferenceException : XmlSchemaException - { - public XmlSchemaInferenceException() : base(null) - { - } - - - public XmlSchemaInferenceException(String message) : base(message, ((Exception)null), 0, 0) - { - } - - public XmlSchemaInferenceException(String message, Exception innerException) : base(message, innerException, 0, 0) - { - } - - /// - public XmlSchemaInferenceException(String message, Exception innerException, int lineNumber, int linePosition) : - base(message, innerException, lineNumber, linePosition) - { - } - - internal XmlSchemaInferenceException(string res, string[] args) : base(res, args, null, null, 0, 0, null) - { - } - - internal XmlSchemaInferenceException(string res, string arg) : base(res, new string[] { arg }, null, null, 0, 0, null) - { - } - internal XmlSchemaInferenceException(string res, string arg, string sourceUri, int lineNumber, int linePosition) : - base(res, new string[] { arg }, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaInferenceException(string res, string sourceUri, int lineNumber, int linePosition) : - base(res, (string[])null, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaInferenceException(string res, string[] args, string sourceUri, int lineNumber, int linePosition) : - base(res, args, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaInferenceException(string res, int lineNumber, int linePosition) : - base(res, null, null, null, lineNumber, linePosition, null) - { - } - } -} // namespace Microsoft.Xml.Schema - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/infer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/infer.cs deleted file mode 100644 index b2fa2c683ef..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Inference/infer.cs +++ /dev/null @@ -1,2544 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -// using System.Security.Permissions; - - - - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - /// - /// - /// Infer class serves for infering XML Schema from given XML instance document. - /// - public sealed class XmlSchemaInference - { - internal static XmlQualifiedName ST_boolean = new XmlQualifiedName("boolean", XmlSchema.Namespace); - internal static XmlQualifiedName ST_byte = new XmlQualifiedName("byte", XmlSchema.Namespace); - internal static XmlQualifiedName ST_unsignedByte = new XmlQualifiedName("unsignedByte", XmlSchema.Namespace); - internal static XmlQualifiedName ST_short = new XmlQualifiedName("short", XmlSchema.Namespace); - internal static XmlQualifiedName ST_unsignedShort = new XmlQualifiedName("unsignedShort", XmlSchema.Namespace); - internal static XmlQualifiedName ST_int = new XmlQualifiedName("int", XmlSchema.Namespace); - internal static XmlQualifiedName ST_unsignedInt = new XmlQualifiedName("unsignedInt", XmlSchema.Namespace); - internal static XmlQualifiedName ST_long = new XmlQualifiedName("long", XmlSchema.Namespace); - internal static XmlQualifiedName ST_unsignedLong = new XmlQualifiedName("unsignedLong", XmlSchema.Namespace); - internal static XmlQualifiedName ST_integer = new XmlQualifiedName("integer", XmlSchema.Namespace); - internal static XmlQualifiedName ST_decimal = new XmlQualifiedName("decimal", XmlSchema.Namespace); - internal static XmlQualifiedName ST_float = new XmlQualifiedName("float", XmlSchema.Namespace); - internal static XmlQualifiedName ST_double = new XmlQualifiedName("double", XmlSchema.Namespace); - internal static XmlQualifiedName ST_duration = new XmlQualifiedName("duration", XmlSchema.Namespace); - internal static XmlQualifiedName ST_dateTime = new XmlQualifiedName("dateTime", XmlSchema.Namespace); - internal static XmlQualifiedName ST_time = new XmlQualifiedName("time", XmlSchema.Namespace); - internal static XmlQualifiedName ST_date = new XmlQualifiedName("date", XmlSchema.Namespace); - internal static XmlQualifiedName ST_gYearMonth = new XmlQualifiedName("gYearMonth", XmlSchema.Namespace); - internal static XmlQualifiedName ST_string = new XmlQualifiedName("string", XmlSchema.Namespace); - internal static XmlQualifiedName ST_anySimpleType = new XmlQualifiedName("anySimpleType", XmlSchema.Namespace); - - internal static XmlQualifiedName[] SimpleTypes = - { - ST_boolean, - ST_byte, - ST_unsignedByte, - ST_short, - ST_unsignedShort, - ST_int, - ST_unsignedInt, - ST_long, - ST_unsignedLong, - ST_integer, - ST_decimal, - ST_float, - ST_double, - ST_duration, - ST_dateTime, - ST_time, - ST_date, - ST_gYearMonth, - ST_string - }; - - internal const short HC_ST_boolean = 0; - internal const short HC_ST_byte = 1; - internal const short HC_ST_unsignedByte = 2; - internal const short HC_ST_short = 3; - internal const short HC_ST_unsignedShort = 4; - internal const short HC_ST_int = 5; - internal const short HC_ST_unsignedInt = 6; - internal const short HC_ST_long = 7; - internal const short HC_ST_unsignedLong = 8; - internal const short HC_ST_integer = 9; - internal const short HC_ST_decimal = 10; - internal const short HC_ST_float = 11; - internal const short HC_ST_double = 12; - internal const short HC_ST_duration = 13; - internal const short HC_ST_dateTime = 14; - internal const short HC_ST_time = 15; - internal const short HC_ST_date = 16; - internal const short HC_ST_gYearMonth = 17; - internal const short HC_ST_string = 18; - internal const short HC_ST_Count = HC_ST_string + 1; - - - internal const int TF_boolean = 1 << HC_ST_boolean; - internal const int TF_byte = 1 << HC_ST_byte; - internal const int TF_unsignedByte = 1 << HC_ST_unsignedByte; - internal const int TF_short = 1 << HC_ST_short; - internal const int TF_unsignedShort = 1 << HC_ST_unsignedShort; - internal const int TF_int = 1 << HC_ST_int; - internal const int TF_unsignedInt = 1 << HC_ST_unsignedInt; - internal const int TF_long = 1 << HC_ST_long; - internal const int TF_unsignedLong = 1 << HC_ST_unsignedLong; - internal const int TF_integer = 1 << HC_ST_integer; - internal const int TF_decimal = 1 << HC_ST_decimal; - internal const int TF_float = 1 << HC_ST_float; - internal const int TF_double = 1 << HC_ST_double; - internal const int TF_duration = 1 << HC_ST_duration; - internal const int TF_dateTime = 1 << HC_ST_dateTime; - internal const int TF_time = 1 << HC_ST_time; - internal const int TF_date = 1 << HC_ST_date; - internal const int TF_gYearMonth = 1 << HC_ST_gYearMonth; - internal const int TF_string = 1 << HC_ST_string; - - private XmlSchema _rootSchema = null; //(XmlSchema) xsc[TargetNamespace]; - private XmlSchemaSet _schemaSet; - private XmlReader _xtr; - private NameTable _nametable; - private string _targetNamespace; - private XmlNamespaceManager _namespaceManager; - //private Hashtable schemas; //contains collection of schemas before they get added to the XmlSchemaSet xsc - //private bool bRefine = false; //indicates if we are going to infer or refine schema when InferSchema is called - private ArrayList _schemaList; - private InferenceOption _occurrence = InferenceOption.Restricted; - private InferenceOption _typeInference = InferenceOption.Restricted; - - /* internal struct ReplaceList - { - internal XmlSchemaObjectCollection col; - internal int position; - - internal ReplaceList(XmlSchemaObjectCollection col, int position) - { - this.col = col; - this.position = position; - } - }*/ - - /// - public enum InferenceOption - { - /// - Restricted, - /// - Relaxed - }; - - /// - public InferenceOption Occurrence - { - set - { - _occurrence = value; - } - get - { - return _occurrence; - } - } - - /// - public InferenceOption TypeInference - { - set - { - _typeInference = value; - } - get - { - return _typeInference; - } - } - - /// - public XmlSchemaInference() - { - _nametable = new NameTable(); - _namespaceManager = new XmlNamespaceManager(_nametable); - _namespaceManager.AddNamespace("xs", XmlSchema.Namespace); - _schemaList = new ArrayList(); - } - - /// - public XmlSchemaSet InferSchema(XmlReader instanceDocument) - { - return InferSchema1(instanceDocument, new XmlSchemaSet(_nametable)); - } - - /// - public XmlSchemaSet InferSchema(XmlReader instanceDocument, XmlSchemaSet schemas) - { - if (schemas == null) - { - schemas = new XmlSchemaSet(_nametable); - } - return InferSchema1(instanceDocument, schemas); - } - internal XmlSchemaSet InferSchema1(XmlReader instanceDocument, XmlSchemaSet schemas) - { - if (instanceDocument == null) - { - throw new ArgumentNullException("instanceDocument"); - } - _rootSchema = null; - _xtr = instanceDocument; - schemas.Compile(); - _schemaSet = schemas; - //schemas = new Hashtable(); - //while(xtr.Read()) - - while (_xtr.NodeType != XmlNodeType.Element && _xtr.Read()) ; - - - if (_xtr.NodeType == XmlNodeType.Element) - { - //Create and process the root element - _targetNamespace = _xtr.NamespaceURI; - if (_xtr.NamespaceURI == XmlSchema.Namespace) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_schema, 0, 0); - } - XmlSchemaElement xse = null; - foreach (XmlSchemaElement elem in schemas.GlobalElements.Values) - { - if (elem.Name == _xtr.LocalName && elem.QualifiedName.Namespace == _xtr.NamespaceURI) - { - _rootSchema = elem.Parent as XmlSchema; - xse = elem; - break; - } - } - - if (_rootSchema == null) - { - //rootSchema = CreateXmlSchema(xtr.NamespaceURI); - xse = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, null, null, -1); - } - else - { - //bRefine = true; - InferElement(xse, false, _rootSchema); - } - - /* foreach (ReplaceList listItem in schemaList) - { - if (listItem.position < listItem.col.Count) - { - XmlSchemaElement particle = listItem.col[listItem.position] as XmlSchemaElement; - if (particle != null && (particle.RefName.Namespace == XmlSchema.Namespace)) - { - XmlSchemaAny any = new XmlSchemaAny(); - if (particle.MaxOccurs != 1) - { - any.MaxOccurs = particle.MaxOccurs; - } - if (particle.MinOccurs != 1) - { - any.MinOccurs = particle.MinOccurs; - } - any.ProcessContents = XmlSchemaContentProcessing.Skip; - any.MinOccurs = decimal.Zero; - any.Namespace = particle.RefName.Namespace; - listItem.col[listItem.position] = any; - } - } - }*/ - foreach (String prefix in _namespaceManager) - { - if (!prefix.Equals("xml") && !prefix.Equals("xmlns")) - { - String ns = _namespaceManager.LookupNamespace(_nametable.Get(prefix)); - if (ns.Length != 0) - { //Do not add xmlns="" - _rootSchema.Namespaces.Add(prefix, ns); - } - } - } - Debug.Assert(_rootSchema != null, "rootSchema is null"); - schemas.Reprocess(_rootSchema); - schemas.Compile(); - //break; - } - else - { - throw new XmlSchemaInferenceException(ResXml.SchInf_NoElement, 0, 0); - } - return schemas; - } - - private XmlSchemaAttribute AddAttribute(string localName, string prefix, string childURI, string attrValue, bool bCreatingNewType, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, XmlSchemaObjectTable compiledAttributes) - { - if (childURI == XmlSchema.Namespace) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_schema, 0, 0); - } - - XmlSchemaAttribute xsa = null; - int AttributeType = -1; - XmlSchemaAttribute returnedAttribute = null; //this value will change to attributeReference if childURI!= parentURI - XmlSchema xs = null; - bool add = true; - - Debug.Assert(compiledAttributes != null); //AttributeUses is never null - // First we need to look into the already compiled attributes - // (they come from the schemaset which we got on input) - // If there are none or we don't find it there, then we must search the list of attributes - // where we are going to add a new one (if it doesn't exist). - // This is necessary to avoid adding duplicate attribute declarations. - ICollection searchCollectionPrimary, searchCollectionSecondary; - if (compiledAttributes.Count > 0) - { - searchCollectionPrimary = compiledAttributes.Values; - searchCollectionSecondary = addLocation; - } - else - { - searchCollectionPrimary = addLocation; - searchCollectionSecondary = null; - } - if (childURI == XmlReservedNs.NsXml) - { - XmlSchemaAttribute attributeReference = null; - //see if the reference exists - attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI); - if (attributeReference == null && searchCollectionSecondary != null) - { - attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI); - } - if (attributeReference == null) - { - attributeReference = new XmlSchemaAttribute(); - attributeReference.RefName = new XmlQualifiedName(localName, childURI); - if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) - { - attributeReference.Use = XmlSchemaUse.Required; - } - else - { - attributeReference.Use = XmlSchemaUse.Optional; - } - - addLocation.Add(attributeReference); - } - returnedAttribute = attributeReference; - } - else - { - if (childURI.Length == 0) - { - xs = parentSchema; - add = false; - } - else if (childURI != null && !_schemaSet.Contains(childURI)) - { - /*if (parentSchema.AttributeFormDefault = XmlSchemaForm.Unqualified && childURI.Length == 0) - { - xs = parentSchema; - add = false; - break; - }*/ - xs = new XmlSchema(); - xs.AttributeFormDefault = XmlSchemaForm.Unqualified; - xs.ElementFormDefault = XmlSchemaForm.Qualified; - if (childURI.Length != 0) - xs.TargetNamespace = childURI; - //schemas.Add(childURI, xs); - _schemaSet.Add(xs); - if (prefix.Length != 0 && String.Compare(prefix, "xml", StringComparison.OrdinalIgnoreCase) != 0) - _namespaceManager.AddNamespace(prefix, childURI); - } - else - { - ArrayList col = _schemaSet.Schemas(childURI) as ArrayList; - if (col != null && col.Count > 0) - { - xs = col[0] as XmlSchema; - } - } - if (childURI.Length != 0) //BUGBUG It need not be an attribute reference if there is a namespace, it can be attribute with attributeFormDefault = qualified - { - XmlSchemaAttribute attributeReference = null; - //see if the reference exists - attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI); - if (attributeReference == null & searchCollectionSecondary != null) - { - attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI); - } - if (attributeReference == null) - { - attributeReference = new XmlSchemaAttribute(); - attributeReference.RefName = new XmlQualifiedName(localName, childURI); - if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) - { - attributeReference.Use = XmlSchemaUse.Required; - } - else - { - attributeReference.Use = XmlSchemaUse.Optional; - } - - addLocation.Add(attributeReference); - } - returnedAttribute = attributeReference; - - //see if the attribute exists on the global level - xsa = FindAttribute(xs.Items, localName); - if (xsa == null) - { - xsa = new XmlSchemaAttribute(); - xsa.Name = localName; - xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); - xsa.LineNumber = AttributeType; //we use LineNumber to store flags of valid types - xs.Items.Add(xsa); - } - else - { - if (xsa.Parent == null) - { - AttributeType = xsa.LineNumber; // we use LineNumber to store flags of valid types - } - else - { - AttributeType = GetSchemaType(xsa.SchemaTypeName); - xsa.Parent = null; - } - xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); - xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types - } - } - else - { - xsa = FindAttribute(searchCollectionPrimary, localName); - if (xsa == null && searchCollectionSecondary != null) - { - xsa = FindAttribute(searchCollectionSecondary, localName); - } - if (xsa == null) - { - xsa = new XmlSchemaAttribute(); - xsa.Name = localName; - xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); - xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types - if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted) - xsa.Use = XmlSchemaUse.Required; - else - xsa.Use = XmlSchemaUse.Optional; - addLocation.Add(xsa); - if (xs.AttributeFormDefault != XmlSchemaForm.Unqualified) - { - xsa.Form = XmlSchemaForm.Unqualified; - } - } - else - { - if (xsa.Parent == null) - { - AttributeType = xsa.LineNumber; // we use LineNumber to store flags of valid types - } - else - { - AttributeType = GetSchemaType(xsa.SchemaTypeName); - xsa.Parent = null; - } - xsa.SchemaTypeName = RefineSimpleType(attrValue, ref AttributeType); - xsa.LineNumber = AttributeType; // we use LineNumber to store flags of valid types - } - returnedAttribute = xsa; - } - } - string nullString = null; - if (add && childURI != parentSchema.TargetNamespace) - { - for (int i = 0; i < parentSchema.Includes.Count; ++i) - { - XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport; - if (import == null) - { - continue; - } - if (import.Namespace == childURI) - { - add = false; - } - } - if (add) - { - XmlSchemaImport import = new XmlSchemaImport(); - import.Schema = xs; - if (childURI.Length != 0) - { - nullString = childURI; - } - import.Namespace = nullString; - parentSchema.Includes.Add(import); - } - } - - - return returnedAttribute; - } - - private XmlSchema CreateXmlSchema(string targetNS) - { - Debug.Assert(targetNS == null || targetNS.Length > 0, "targetns for schema is empty"); - XmlSchema xs = new XmlSchema(); - xs.AttributeFormDefault = XmlSchemaForm.Unqualified; - xs.ElementFormDefault = XmlSchemaForm.Qualified; - xs.TargetNamespace = targetNS; - _schemaSet.Add(xs); - return xs; - } - - private XmlSchemaElement AddElement(string localName, string prefix, string childURI, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, int positionWithinCollection) - { - if (childURI == XmlSchema.Namespace) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_schema, 0, 0); - } - - XmlSchemaElement xse = null; - XmlSchemaElement returnedElement = xse; //this value will change to elementReference if childURI!= parentURI - XmlSchema xs = null; - bool bCreatingNewType = true; - if (childURI == String.Empty) - { - childURI = null; - } - // The new element belongs to the same ns as parent and addlocation is not null - if (parentSchema != null && childURI == parentSchema.TargetNamespace) - { - xse = new XmlSchemaElement(); - xse.Name = localName; - xs = parentSchema; - if (xs.ElementFormDefault != XmlSchemaForm.Qualified && addLocation != null) - { - xse.Form = XmlSchemaForm.Qualified; - } - } - else if (_schemaSet.Contains(childURI)) - { - xse = this.FindGlobalElement(childURI, localName, out xs); - if (xse == null) - { - ArrayList col = _schemaSet.Schemas(childURI) as ArrayList; - if (col != null && col.Count > 0) - { - xs = col[0] as XmlSchema; - } - xse = new XmlSchemaElement(); - xse.Name = localName; - xs.Items.Add(xse); - } - else - bCreatingNewType = false; - } - else - { - xs = CreateXmlSchema(childURI); - if (prefix.Length != 0) - _namespaceManager.AddNamespace(prefix, childURI); - xse = new XmlSchemaElement(); - xse.Name = localName; - xs.Items.Add(xse); //add global element declaration only when creating new schema - } - if (parentSchema == null) - { - parentSchema = xs; - _rootSchema = parentSchema; - } - - if (childURI != parentSchema.TargetNamespace) - { - bool add = true; - - for (int i = 0; i < parentSchema.Includes.Count; ++i) - { - XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport; - if (import == null) - { - continue; - } - //Debug.WriteLine(import.Schema.TargetNamespace); - - if (import.Namespace == childURI) - { - add = false; - } - } - if (add) - { - XmlSchemaImport import = new XmlSchemaImport(); - import.Schema = xs; - import.Namespace = childURI; - parentSchema.Includes.Add(import); - } - } - returnedElement = xse; - if (addLocation != null) - { - if (childURI == parentSchema.TargetNamespace) - { - if (this.Occurrence == InferenceOption.Relaxed /*&& parentSchema.Items != addLocation*/) - { - xse.MinOccurs = 0; - } - if (positionWithinCollection == -1) - { - positionWithinCollection = addLocation.Add(xse); - } - else - { - addLocation.Insert(positionWithinCollection, xse); - } - } - else - { - XmlSchemaElement elementReference = new XmlSchemaElement(); - elementReference.RefName = new XmlQualifiedName(localName, childURI); - if (this.Occurrence == InferenceOption.Relaxed) - { - elementReference.MinOccurs = 0; - } - if (positionWithinCollection == -1) - { - positionWithinCollection = addLocation.Add(elementReference); - } - else - { - addLocation.Insert(positionWithinCollection, elementReference); - } - returnedElement = elementReference; - /* if (childURI == XmlSchema.Namespace) - { - schemaList.Add(new ReplaceList(addLocation, positionWithinCollection)); - }*/ - } - } - - - InferElement(xse, bCreatingNewType, xs); - - return returnedElement; - } - - /// - /// Sets type of the xse based on the currently read element. - /// If the type is already set, verifies that it matches the instance and if not, updates the type to validate the instance. - /// - /// XmlSchemaElement corresponding to the element just read by the xtr XmlTextReader - /// true if the type is newly created, false if the type already existed and matches the current element name - /// namespaceURI of the parent element. Used to distinguish if ref= should be used when parent is in different ns than child. - internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchema parentSchema) - { - bool bEmptyElement = _xtr.IsEmptyElement; - int lastUsedSeqItem = -1; - - Hashtable table = new Hashtable(); - XmlSchemaType schemaType = GetEffectiveSchemaType(xse, bCreatingNewType); - XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType; - - //infer type based on content of the current element - if (_xtr.MoveToFirstAttribute()) - { - ProcessAttributes(ref xse, schemaType, bCreatingNewType, parentSchema); - } - else - { - if (!bCreatingNewType && ct != null) - { //if type already exists and can potentially have attributes - MakeExistingAttributesOptional(ct, null); - } - } - if (ct == null || ct == XmlSchemaComplexType.AnyType) - { //It was null or simple type, after processing attributes, this might have been set - ct = xse.SchemaType as XmlSchemaComplexType; - } - //xse's type is set either to complex type if attributes exist or null - if (bEmptyElement) // - { - if (!bCreatingNewType) - { - if (null != ct) - { - if (null != ct.Particle) - - { - ct.Particle.MinOccurs = 0; - } - else if (null != ct.ContentModel) - { - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - } - else if (!xse.SchemaTypeName.IsEmpty) - { - xse.LineNumber = TF_string; - xse.SchemaTypeName = ST_string; - } - } - else - { - xse.LineNumber = TF_string; - //xse.SchemaTypeName = ST_string; //My change - } - return; //We are done processing this element - all attributes are already added - } - bool bWhiteSpace = false; - do - { - _xtr.Read(); - if (_xtr.NodeType == XmlNodeType.Whitespace) - { - bWhiteSpace = true; - } - if (_xtr.NodeType == XmlNodeType.EntityReference) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_entity, 0, 0); - } - } while ((!_xtr.EOF) && (_xtr.NodeType != XmlNodeType.EndElement) && (_xtr.NodeType != XmlNodeType.CDATA) && (_xtr.NodeType != XmlNodeType.Element) && (_xtr.NodeType != XmlNodeType.Text)); - - if (_xtr.NodeType == XmlNodeType.EndElement) - { - if (bWhiteSpace) - { - if (ct != null) - { - if (null != ct.ContentModel) - { - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - else if (bCreatingNewType) - { - //attributes exist, but both Particle and ContentModel == null - this must be complex type with simpleContent extension - XmlSchemaSimpleContent sc = new XmlSchemaSimpleContent(); - ct.ContentModel = sc; - XmlSchemaSimpleContentExtension sce = new XmlSchemaSimpleContentExtension(); - sc.Content = sce; - - MoveAttributes(ct, sce, bCreatingNewType); - - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - else - ct.IsMixed = true; - } - else - { - xse.SchemaTypeName = ST_string; - xse.LineNumber = TF_string; - } - } - if (bCreatingNewType) - { - xse.LineNumber = TF_string; - //xse.SchemaTypeName = ST_string; //my change - } - else - { - if (null != ct) - { - if (null != ct.Particle) - { - ct.Particle.MinOccurs = 0; - } - else if (null != ct.ContentModel) - { - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - } - else if (!xse.SchemaTypeName.IsEmpty) - { - xse.LineNumber = TF_string; - xse.SchemaTypeName = ST_string; - } - } - - return; // - } - int iChildNumber = 0; - bool bCreatingNewSequence = false; - while (!_xtr.EOF && (_xtr.NodeType != XmlNodeType.EndElement)) - { - bool bNextNodeAlreadyRead = false; //In some cases we have to look ahead one node. If true means that we did look ahead. - iChildNumber++; - if ((_xtr.NodeType == XmlNodeType.Text) || (_xtr.NodeType == XmlNodeType.CDATA)) //node can be simple type, complex with simple content or complex with mixed content - { - if (null != ct) - { - if (null != ct.Particle) - { - ct.IsMixed = true; - if (iChildNumber == 1) - { - //if this is the only child and other elements do not follow, we must set particle minOccurs="0" - do { _xtr.Read(); } while ((!_xtr.EOF) && ((_xtr.NodeType == XmlNodeType.CDATA) || (_xtr.NodeType == XmlNodeType.Text) || (_xtr.NodeType == XmlNodeType.Comment) || (_xtr.NodeType == XmlNodeType.ProcessingInstruction) || (_xtr.NodeType == XmlNodeType.Whitespace) || (_xtr.NodeType == XmlNodeType.SignificantWhitespace) || (_xtr.NodeType == XmlNodeType.XmlDeclaration))); - bNextNodeAlreadyRead = true; - if (_xtr.NodeType == XmlNodeType.EndElement) - ct.Particle.MinOccurs = decimal.Zero; - } - } - else if (null != ct.ContentModel) - { //complexType with simpleContent - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - if ((_xtr.NodeType == XmlNodeType.Text) && (iChildNumber == 1)) - { - int SimpleType = -1; - if (xse.Parent == null) - { - SimpleType = sce.LineNumber; // we use LineNumber to represent valid type flags - } - else - { - SimpleType = GetSchemaType(sce.BaseTypeName); - xse.Parent = null; - } - sce.BaseTypeName = RefineSimpleType(_xtr.Value, ref SimpleType); - sce.LineNumber = SimpleType; // we use LineNumber to represent valid type flags - } - else - { - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - } - else - { - //attributes exist, but both Particle and ContentModel == null - this must be complex type with simpleContent extension - XmlSchemaSimpleContent sc = new XmlSchemaSimpleContent(); - ct.ContentModel = sc; - XmlSchemaSimpleContentExtension sce = new XmlSchemaSimpleContentExtension(); - sc.Content = sce; - - MoveAttributes(ct, sce, bCreatingNewType); - - if (_xtr.NodeType == XmlNodeType.Text) - { - int TypeFlags; - if (!bCreatingNewType) - //previously this was empty element - TypeFlags = TF_string; - else - TypeFlags = -1; - sce.BaseTypeName = RefineSimpleType(_xtr.Value, ref TypeFlags); - sce.LineNumber = TypeFlags; // we use LineNumber to store flags of valid types - } - else - { - sce.BaseTypeName = ST_string; - sce.LineNumber = TF_string; - } - } - } - else - { //node is currently empty or with SimpleType - //node will become simple type - if (iChildNumber > 1) - { - //more than one consecutive text nodes probably with PI in between - xse.SchemaTypeName = ST_string; - xse.LineNumber = TF_string;// we use LineNumber to store flags of valid types - } - else - { - int TypeFlags = -1; - if (bCreatingNewType) - if (_xtr.NodeType == XmlNodeType.Text) - { - xse.SchemaTypeName = RefineSimpleType(_xtr.Value, ref TypeFlags); - xse.LineNumber = TypeFlags; // we use LineNumber to store flags of valid types - } - else - { - xse.SchemaTypeName = ST_string; - xse.LineNumber = TF_string;// we use LineNumber to store flags of valid types - } - else if (_xtr.NodeType == XmlNodeType.Text) - { - if (xse.Parent == null) - { - TypeFlags = xse.LineNumber; - } - else - { - TypeFlags = GetSchemaType(xse.SchemaTypeName); - if (TypeFlags == -1 && xse.LineNumber == TF_string) - { //Since schemaTypeName is not set for empty elements () - TypeFlags = TF_string; - } - xse.Parent = null; - } - xse.SchemaTypeName = RefineSimpleType(_xtr.Value, ref TypeFlags); //simple type - xse.LineNumber = TypeFlags; // we use LineNumber to store flags of valid types - } - else - { - xse.SchemaTypeName = ST_string; - xse.LineNumber = TF_string;// we use LineNumber to store flags of valid types - } - } - } - } - else if (_xtr.NodeType == XmlNodeType.Element) - { - XmlQualifiedName qname = new XmlQualifiedName(_xtr.LocalName, _xtr.NamespaceURI); - bool Maxoccursflag = false; - if (table.Contains(qname)) - { - Maxoccursflag = true; - } - else - { - table.Add(qname, null); - } - if (ct == null) - { //untill now the element was empty or SimpleType - it now becomes complex type - ct = new XmlSchemaComplexType(); - xse.SchemaType = ct; - if (!xse.SchemaTypeName.IsEmpty) //BUGBUG, This assumption is wrong - { - ct.IsMixed = true; - xse.SchemaTypeName = XmlQualifiedName.Empty; - } - } - if (ct.ContentModel != null) - { //type was previously identified as simple content extension - we need to convert it to sequence - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - MoveAttributes(sce, ct); - ct.ContentModel = null; - ct.IsMixed = true; - if (ct.Particle != null) - throw new XmlSchemaInferenceException(ResXml.SchInf_particle, 0, 0); - ct.Particle = new XmlSchemaSequence(); - bCreatingNewSequence = true; - XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1); - lastUsedSeqItem = 0; - if (!bCreatingNewType) - ct.Particle.MinOccurs = 0; //previously this was simple type so subelements did not exist - } - else if (ct.Particle == null) - { - ct.Particle = new XmlSchemaSequence(); - bCreatingNewSequence = true; - XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1); - if (!bCreatingNewType) - { - ((XmlSchemaSequence)ct.Particle).MinOccurs = decimal.Zero; - // subelement.MinOccurs = decimal.Zero; - } - - lastUsedSeqItem = 0; - } - else - { - bool bParticleChanged = false; - XmlSchemaElement subelement = FindMatchingElement(bCreatingNewType || bCreatingNewSequence, _xtr, ct, ref lastUsedSeqItem, ref bParticleChanged, parentSchema, Maxoccursflag); - } - } - else if (_xtr.NodeType == XmlNodeType.Text) - { - if (ct == null) - throw new XmlSchemaInferenceException(ResXml.SchInf_ct, 0, 0); - ct.IsMixed = true; - } - do - { - if (_xtr.NodeType == XmlNodeType.EntityReference) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_entity, 0, 0); - } - if (!bNextNodeAlreadyRead) - { - _xtr.Read(); - } - else - { - bNextNodeAlreadyRead = false; - } - } while ((!_xtr.EOF) && (_xtr.NodeType != XmlNodeType.EndElement) && (_xtr.NodeType != XmlNodeType.CDATA) && (_xtr.NodeType != XmlNodeType.Element) && (_xtr.NodeType != XmlNodeType.Text)); - } - if (lastUsedSeqItem != -1) - { - //Verify if all elements in a sequence exist, if not set MinOccurs=0 - while (++lastUsedSeqItem < ((XmlSchemaSequence)ct.Particle).Items.Count) - { - if (((XmlSchemaSequence)ct.Particle).Items[lastUsedSeqItem].GetType() != typeof(XmlSchemaElement)) - throw new XmlSchemaInferenceException(ResXml.SchInf_seq, 0, 0); - XmlSchemaElement subElement = (XmlSchemaElement)((XmlSchemaSequence)ct.Particle).Items[lastUsedSeqItem]; - subElement.MinOccurs = 0; - } - } - } - - private XmlSchemaSimpleContentExtension CheckSimpleContentExtension(XmlSchemaComplexType ct) - { - XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent; - if (sc == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_simplecontent, 0, 0); - } - XmlSchemaSimpleContentExtension sce = sc.Content as XmlSchemaSimpleContentExtension; - if (sce == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_extension, 0, 0); - } - return sce; - } - - private XmlSchemaType GetEffectiveSchemaType(XmlSchemaElement elem, bool bCreatingNewType) - { - XmlSchemaType effectiveSchemaType = null; - if (!bCreatingNewType && elem.ElementSchemaType != null) - { - effectiveSchemaType = elem.ElementSchemaType; - } - else - { //creating new type, hence look up pre-compiled info - Debug.Assert(elem.ElementDecl == null); - if (elem.SchemaType != null) - { - effectiveSchemaType = elem.SchemaType; - } - else if (elem.SchemaTypeName != XmlQualifiedName.Empty) - { - effectiveSchemaType = _schemaSet.GlobalTypes[elem.SchemaTypeName] as XmlSchemaType; - if (effectiveSchemaType == null) - { - effectiveSchemaType = XmlSchemaType.GetBuiltInSimpleType(elem.SchemaTypeName); - } - if (effectiveSchemaType == null) - { - effectiveSchemaType = XmlSchemaType.GetBuiltInComplexType(elem.SchemaTypeName); - } - } - } - return effectiveSchemaType; - } - /// - /// Verifies that the current element has its corresponding element in the sequence and order is the same. - /// If the order is not the same, it changes the particle from Sequence to Sequence with Choice. - /// If there is more elements of the same kind in the sequence, sets maxOccurs to unbounded - /// - /// True if this is a new type. This is important for setting minOccurs=0 for elements that did not exist in a particle. - /// text reader positioned to the current element - /// complex type with Sequence or Choice Particle - /// ordinal number in the sequence to indicate current sequence position - /// hashtable of elements with minOccurs changed to 0 in order to satisfy sequence requirements. These elements will be rolled back if Sequence becomes Sequence of Choice. - /// This indicates to the caller if Sequence was changed to Choice - internal XmlSchemaElement FindMatchingElement(bool bCreatingNewType, XmlReader xtr, XmlSchemaComplexType ct, ref int lastUsedSeqItem, ref bool bParticleChanged, XmlSchema parentSchema, bool setMaxoccurs) - { - if (xtr.NamespaceURI == XmlSchema.Namespace) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_schema, 0, 0); - } - - bool bItemNotUsedYet = ((lastUsedSeqItem == -1) ? true : false); - XmlSchemaObjectCollection minOccursCandidates = new XmlSchemaObjectCollection(); //elements that are skipped in the sequence and need minOccurs modified. - if (ct.Particle.GetType() == typeof(XmlSchemaSequence)) - { - string childURI = xtr.NamespaceURI; - if (childURI.Length == 0) - { - childURI = null; - } - XmlSchemaSequence xss = (XmlSchemaSequence)ct.Particle; - if (xss.Items.Count < 1 && !bCreatingNewType) - { - lastUsedSeqItem = 0; - XmlSchemaElement e = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xss.Items, -1); - e.MinOccurs = 0; - return e; - } - if (xss.Items[0].GetType() == typeof(XmlSchemaChoice)) - { // ... - XmlSchemaChoice xsch = (XmlSchemaChoice)xss.Items[0]; - for (int i = 0; i < xsch.Items.Count; ++i) - { - XmlSchemaElement el = xsch.Items[i] as XmlSchemaElement; - if (el == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_UnknownParticle, 0, 0); - } - if ((el.Name == xtr.LocalName) && (parentSchema.TargetNamespace == childURI)) - { // element is in the same namespace - InferElement(el, false, parentSchema); - SetMinMaxOccurs(el, setMaxoccurs); - return el; - } - else if ((el.RefName.Name == xtr.LocalName) && (el.RefName.Namespace == xtr.NamespaceURI)) - { - XmlSchemaElement referencedElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema); - InferElement(referencedElement, false, parentSchema); - SetMinMaxOccurs(el, setMaxoccurs); - return referencedElement; - } - } - XmlSchemaElement subElement = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xsch.Items, -1); - return subElement; - } - else - { //this should be sequence of elements - int iSeqItem = 0; //iterator through schema sequence items - if (lastUsedSeqItem >= 0) - iSeqItem = lastUsedSeqItem; - XmlSchemaParticle particle = xss.Items[iSeqItem] as XmlSchemaParticle; - XmlSchemaElement el = particle as XmlSchemaElement; - if (el == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_UnknownParticle, 0, 0); - } - if (el.Name == xtr.LocalName && parentSchema.TargetNamespace == childURI) - { - if (!bItemNotUsedYet) //read: if item was already used one or more times - el.MaxOccurs = decimal.MaxValue; //set it to unbounded - lastUsedSeqItem = iSeqItem; - InferElement(el, false, parentSchema); - SetMinMaxOccurs(el, false); - return el; - } - else if (el.RefName.Name == xtr.LocalName && el.RefName.Namespace == xtr.NamespaceURI) - { - if (!bItemNotUsedYet) //read: if item was already used one or more times - el.MaxOccurs = decimal.MaxValue; //set it to unbounded - lastUsedSeqItem = iSeqItem; - XmlSchemaElement referencedElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema); - InferElement(referencedElement, false, parentSchema); - SetMinMaxOccurs(el, false); - return el; - } - if (bItemNotUsedYet && el.MinOccurs != decimal.Zero) - minOccursCandidates.Add(el); - iSeqItem++; - while (iSeqItem < xss.Items.Count) - { - particle = xss.Items[iSeqItem] as XmlSchemaParticle; - el = particle as XmlSchemaElement; - if (el == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_UnknownParticle, 0, 0); - } - if (el.Name == xtr.LocalName && parentSchema.TargetNamespace == childURI) - { - lastUsedSeqItem = iSeqItem; - for (int i = 0; i < minOccursCandidates.Count; ++i) - { - ((XmlSchemaElement)minOccursCandidates[i]).MinOccurs = decimal.Zero; - } - InferElement(el, false, parentSchema); - SetMinMaxOccurs(el, setMaxoccurs); - return el; - } - else if (el.RefName.Name == xtr.LocalName && el.RefName.Namespace == xtr.NamespaceURI) - { - lastUsedSeqItem = iSeqItem; - for (int i = 0; i < minOccursCandidates.Count; ++i) - { - ((XmlSchemaElement)minOccursCandidates[i]).MinOccurs = decimal.Zero; - } - XmlSchemaElement referencedElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema); - InferElement(referencedElement, false, parentSchema); - SetMinMaxOccurs(el, setMaxoccurs); - return referencedElement; - } - - - minOccursCandidates.Add(el); - iSeqItem++; - } - - //element not found in the sequence order, if it is found out of order change Sequence of elements to Sequence of Choices otherwise insert into sequence as optional - XmlSchemaElement subElement = null; - XmlSchemaElement actualElement = null; - //BUGBUG - is this logic correct - if there is a sequence of elements should they be int he parent's namespace. - - if (parentSchema.TargetNamespace == childURI) - { - subElement = FindElement(xss.Items, xtr.LocalName); - actualElement = subElement; - } - else - { - subElement = FindElementRef(xss.Items, xtr.LocalName, xtr.NamespaceURI); - if (subElement != null) - { - actualElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema); - } - } - if (null != subElement) - { - XmlSchemaChoice xsc = new XmlSchemaChoice(); - xsc.MaxOccurs = decimal.MaxValue; - SetMinMaxOccurs(subElement, setMaxoccurs); - InferElement(actualElement, false, parentSchema); - for (int i = 0; i < xss.Items.Count; ++i) - { - xsc.Items.Add(CreateNewElementforChoice((XmlSchemaElement)xss.Items[i])); - } - xss.Items.Clear(); - xss.Items.Add(xsc); - return subElement; - } - else - { - subElement = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xss.Items, ++lastUsedSeqItem); - if (!bCreatingNewType) - subElement.MinOccurs = decimal.Zero; - return subElement; - } - } - } - else - { - throw new XmlSchemaInferenceException(ResXml.SchInf_noseq, 0, 0); - } - } - internal void ProcessAttributes(ref XmlSchemaElement xse, XmlSchemaType effectiveSchemaType, bool bCreatingNewType, XmlSchema parentSchema) - { - XmlSchemaObjectCollection attributesSeen = new XmlSchemaObjectCollection(); - XmlSchemaComplexType ct = effectiveSchemaType as XmlSchemaComplexType; - - Debug.Assert(_xtr.NodeType == XmlNodeType.Attribute); - do - { - if (_xtr.NamespaceURI == XmlSchema.Namespace) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_schema, 0, 0); - } - - if (_xtr.NamespaceURI == XmlReservedNs.NsXmlNs) - { - if (_xtr.Prefix == "xmlns") - _namespaceManager.AddNamespace(_xtr.LocalName, _xtr.Value); - } - else if (_xtr.NamespaceURI == XmlReservedNs.NsXsi) - { - string localName = _xtr.LocalName; - if (localName == "nil") - { - xse.IsNillable = true; - } - else if (localName != "type" && localName != "schemaLocation" && localName != "noNamespaceSchemaLocation") - { - throw new XmlSchemaInferenceException(ResXml.Sch_NotXsiAttribute, localName); - } - } - else - { - if (ct == null || ct == XmlSchemaComplexType.AnyType) - { - ct = new XmlSchemaComplexType(); - xse.SchemaType = ct; - } - - XmlSchemaAttribute xsa = null; - //The earlier assumption of checking just schemaTypeName !Empty is not correct for schemas that are not generated by us, schemaTypeName can point to any complex type as well - //Check that it is a simple type by checking typeCode - //Switch to complex type simple content extension - if (effectiveSchemaType != null && effectiveSchemaType.Datatype != null && !xse.SchemaTypeName.IsEmpty) - { - //type was previously simple type, now it will become complex with simple type extension - Debug.Assert(ct != null); - XmlSchemaSimpleContent sc = new XmlSchemaSimpleContent(); - ct.ContentModel = sc; - XmlSchemaSimpleContentExtension sce = new XmlSchemaSimpleContentExtension(); - sc.Content = sce; - sce.BaseTypeName = xse.SchemaTypeName; - sce.LineNumber = xse.LineNumber; - xse.LineNumber = 0; - xse.SchemaTypeName = XmlQualifiedName.Empty; //re-set the name - } - - Debug.Assert(ct != null); //either the user-defined type itself is a complex type or we switched from a simple type to a complex type - if (ct.ContentModel != null) - { - XmlSchemaSimpleContentExtension sce = CheckSimpleContentExtension(ct); - Debug.Assert(sce != null); - xsa = AddAttribute(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, _xtr.Value, bCreatingNewType, parentSchema, sce.Attributes, ct.AttributeUses); - } - else //add atributes directly to complex type - { - xsa = AddAttribute(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, _xtr.Value, bCreatingNewType, parentSchema, ct.Attributes, ct.AttributeUses); - } - if (xsa != null) - { - attributesSeen.Add(xsa); - } - } - } while (_xtr.MoveToNextAttribute()); - if (!bCreatingNewType) - { - //make attributes that did not appear this time optional - if (ct != null) - { - MakeExistingAttributesOptional(ct, attributesSeen); - } - } - } - - private void MoveAttributes(XmlSchemaSimpleContentExtension scExtension, XmlSchemaComplexType ct) - { - //copy all attributes from the simple content to the complex type - //This is ok since when we move from complex type to simple content extension we copy from AttributeUses property - for (int i = 0; i < scExtension.Attributes.Count; ++i) //since simpleContent is being cleared - { - ct.Attributes.Add(scExtension.Attributes[i]); - } - } - - private void MoveAttributes(XmlSchemaComplexType ct, XmlSchemaSimpleContentExtension simpleContentExtension, bool bCreatingNewType) - { - //copy all attributes from the complex type to the simple content - - ICollection sourceCollection; - if (!bCreatingNewType && ct.AttributeUses.Count > 0) - { - sourceCollection = ct.AttributeUses.Values; - } - else - { - sourceCollection = ct.Attributes; - } - - foreach (XmlSchemaAttribute attr in sourceCollection) - { - simpleContentExtension.Attributes.Add(attr); - } - ct.Attributes.Clear(); //Clear from pre-compiled property, post compiled will be cleared on Re-process and Compile() - } - - internal XmlSchemaAttribute FindAttribute(ICollection attributes, string attrName) - { - foreach (XmlSchemaObject xsa in attributes) - { - XmlSchemaAttribute schemaAttribute = xsa as XmlSchemaAttribute; - if (schemaAttribute != null) - { - if (schemaAttribute.Name == attrName) - { - return schemaAttribute; - } - } - } - return null; - } - - internal XmlSchemaElement FindGlobalElement(string namespaceURI, string localName, out XmlSchema parentSchema) - { - ICollection col = _schemaSet.Schemas(namespaceURI); - XmlSchemaElement xse = null; - parentSchema = null; - foreach (XmlSchema schema in col) - { - xse = FindElement(schema.Items, localName); - if (xse != null) - { - parentSchema = schema; - return xse; - } - } - return null; - } - - - internal XmlSchemaElement FindElement(XmlSchemaObjectCollection elements, string elementName) - { - for (int i = 0; i < elements.Count; ++i) - { - XmlSchemaElement xse = elements[i] as XmlSchemaElement; - if (xse != null && xse.RefName != null) - { - if (xse.Name == elementName) - { - return xse; - } - } - } - return null; - } - - internal XmlSchemaAttribute FindAttributeRef(ICollection attributes, string attributeName, string nsURI) - { - foreach (XmlSchemaObject xsa in attributes) - { - XmlSchemaAttribute schemaAttribute = xsa as XmlSchemaAttribute; - if (schemaAttribute != null) - { - if (schemaAttribute.RefName.Name == attributeName && schemaAttribute.RefName.Namespace == nsURI) - { - return schemaAttribute; - } - } - } - return null; - } - - internal XmlSchemaElement FindElementRef(XmlSchemaObjectCollection elements, string elementName, string nsURI) - { - for (int i = 0; i < elements.Count; ++i) - { - XmlSchemaElement xse = elements[i] as XmlSchemaElement; - if (xse != null && xse.RefName != null) - { - if (xse.RefName.Name == elementName && xse.RefName.Namespace == nsURI) - { - return xse; - } - } - } - return null; - } - - internal void MakeExistingAttributesOptional(XmlSchemaComplexType ct, XmlSchemaObjectCollection attributesInInstance) - { - if (ct == null) - { - throw new XmlSchemaInferenceException(ResXml.SchInf_noct, 0, 0); - } - if (ct.ContentModel != null) - { - XmlSchemaSimpleContentExtension xssce = CheckSimpleContentExtension(ct); - SwitchUseToOptional(xssce.Attributes, attributesInInstance); - } - else - { //either as child of xs:complexType or the attributes are within the content model - SwitchUseToOptional(ct.Attributes, attributesInInstance); - } - } - - private void SwitchUseToOptional(XmlSchemaObjectCollection attributes, XmlSchemaObjectCollection attributesInInstance) - { - for (int i = 0; i < attributes.Count; ++i) - { - XmlSchemaAttribute attr = attributes[i] as XmlSchemaAttribute; - if (attr != null) - { - if (attributesInInstance != null) - { - if (attr.RefName.Name.Length == 0) - { //If the attribute is not present in this instance, make it optional - if (null == FindAttribute(attributesInInstance, attr.Name)) - { - attr.Use = XmlSchemaUse.Optional; - } - } - else - { - if (null == FindAttributeRef(attributesInInstance, attr.RefName.Name, attr.RefName.Namespace)) - { - attr.Use = XmlSchemaUse.Optional; - } - } - } - else - { - attr.Use = XmlSchemaUse.Optional; - } - } - } - } - - internal XmlQualifiedName RefineSimpleType(string s, ref int iTypeFlags) - { - bool bNeedsRangeCheck = false; - s = s.Trim(); - if (iTypeFlags == TF_string || _typeInference == InferenceOption.Relaxed) - return ST_string; - iTypeFlags &= InferSimpleType(s, ref bNeedsRangeCheck); - if (iTypeFlags == TF_string) - return ST_string; - if (bNeedsRangeCheck) - { - if ((iTypeFlags & TF_byte) != 0) - { - try - { - XmlConvert.ToSByte(s); - //sbyte.Parse(s); - if ((iTypeFlags & TF_unsignedByte) != 0) - return ST_unsignedByte; //number is positive and fits byte -> it also fits unsignedByte - else - return ST_byte; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_byte); - } - if ((iTypeFlags & TF_unsignedByte) != 0) - { - try - { - XmlConvert.ToByte(s); - //byte.Parse(s); - return ST_unsignedByte; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_unsignedByte); - } - if ((iTypeFlags & TF_short) != 0) - { - try - { - XmlConvert.ToInt16(s); - //short.Parse(s); - if ((iTypeFlags & TF_unsignedShort) != 0) - return ST_unsignedShort; //number is positive and fits short -> it also fits unsignedShort - else - return ST_short; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_short); - } - if ((iTypeFlags & TF_unsignedShort) != 0) - { - try - { - XmlConvert.ToUInt16(s); - //ushort.Parse(s); - return ST_unsignedShort; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_unsignedShort); - } - if ((iTypeFlags & TF_int) != 0) - { - try - { - XmlConvert.ToInt32(s); - //int.Parse(s); - if ((iTypeFlags & TF_unsignedInt) != 0) - return ST_unsignedInt; //number is positive and fits int -> it also fits unsignedInt - else - return ST_int; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_int); - } - if ((iTypeFlags & TF_unsignedInt) != 0) - { - try - { - XmlConvert.ToUInt32(s); - //uint.Parse(s); - return ST_unsignedInt; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_unsignedInt); - } - if ((iTypeFlags & TF_long) != 0) - { - try - { - XmlConvert.ToInt64(s); - //long.Parse(s); - if ((iTypeFlags & TF_unsignedLong) != 0) - return ST_unsignedLong; //number is positive and fits long -> it also fits unsignedLong - else - return ST_long; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_long); - } - if ((iTypeFlags & TF_unsignedLong) != 0) - { - try - { - XmlConvert.ToUInt64(s); - //ulong.Parse(s); - return ST_unsignedLong; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_unsignedLong); - } - if ((iTypeFlags & TF_double) != 0) - { - try - { - double dbValue = XmlConvert.ToDouble(s); - if ((iTypeFlags & TF_integer) != 0) - return ST_integer; - else if ((iTypeFlags & TF_decimal) != 0) - return ST_decimal; - else - { - // The value fits into double, but it could be float as well - if ((iTypeFlags & TF_float) != 0) - { - // We used to default to float in this case, so try to fit it into float first - try - { - float flValue = XmlConvert.ToSingle(s); - // Compare the float and double values. We can't do simple value comparison - // as conversion from float to double introduces imprecissions which cause problems. - // Instead we will convert both back to string and compare the strings. - if (string.Compare(XmlConvert.ToString(flValue), XmlConvert.ToString(dbValue), - StringComparison.OrdinalIgnoreCase) == 0) - { - // If we can convert the original string to the exact same value - // and it still fits into float then we treat it as float - return ST_float; - } - } - catch (FormatException) - { } - catch (OverflowException) - { } - } - iTypeFlags &= (~TF_float); - return ST_double; - } - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags &= (~TF_double); - } - if ((iTypeFlags & TF_float) != 0) - { - try - { - XmlConvert.ToSingle(s); - if ((iTypeFlags & TF_integer) != 0) - return ST_integer; - else if ((iTypeFlags & TF_decimal) != 0) - return ST_decimal; - else - return ST_float; - } - catch (FormatException) { } - catch (OverflowException) { } - iTypeFlags &= (~TF_float); - } - if ((iTypeFlags & TF_integer) != 0) - return ST_integer; - else if ((iTypeFlags & TF_decimal) != 0) - return ST_decimal; - else if (iTypeFlags == (TF_gYearMonth | TF_string)) - { - try - { - XmlConvert.ToDateTime(s, XmlDateTimeSerializationMode.RoundtripKind); - return ST_gYearMonth; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags = TF_string; - return ST_string; - } - else if (iTypeFlags == (TF_duration | TF_string)) - { - try - { - XmlConvert.ToTimeSpan(s); - return ST_duration; - } - catch (FormatException) - { } - catch (OverflowException) - { } - iTypeFlags = TF_string; - return ST_string; - } - else if (iTypeFlags == (TF_boolean | TF_string)) - { - return ST_boolean; - } - } - - switch (iTypeFlags) - { - case TF_string: - return ST_string; - case TF_boolean: - return ST_boolean; - case TF_byte: - return ST_byte; - case TF_unsignedByte: - return ST_unsignedByte; - case TF_short: - return ST_short; - case TF_unsignedShort: - return ST_unsignedShort; - case TF_int: - return ST_int; - case TF_unsignedInt: - return ST_unsignedInt; - case TF_long: - return ST_long; - case TF_unsignedLong: - return ST_unsignedLong; - case TF_integer: - return ST_integer; - case TF_decimal: - return ST_decimal; - case TF_float: - return ST_float; - case TF_double: - return ST_double; - case TF_duration: - return ST_duration; - case TF_dateTime: - return ST_dateTime; - case TF_time: - return ST_time; - case TF_date: - return ST_date; - case TF_gYearMonth: - return ST_gYearMonth; - - case TF_boolean | TF_string: - return ST_boolean; - case TF_dateTime | TF_string: - return ST_dateTime; - case TF_date | TF_string: - return ST_date; - case TF_time | TF_string: - return ST_time; - case TF_float | TF_double | TF_string: - return ST_float; - case TF_double | TF_string: - return ST_double; - - default: - Debug.Assert(false, "Expected type not matched"); - return ST_string; - } - /* if (currentType == null) - return SimpleTypes[newType]; - else - return SimpleTypes[ST_Map[newType,(short) ST_Codes[currentType]]]; - */ - } - - internal static int InferSimpleType(string s, ref bool bNeedsRangeCheck) - { - bool bNegative = false; - bool bPositive = false; - bool bDate = false; - bool bTime = false; - bool bMissingDay = false; - - if (s.Length == 0) return TF_string; - int i = 0; - switch (s[i]) - { - case 't': - case 'f': - if (s == "true") - return TF_boolean | TF_string; - else if (s == "false") - return TF_boolean | TF_string; - else - return TF_string; - case 'N': //try to match "NaN" - if (s == "NaN") - return TF_float | TF_double | TF_string; - else - return TF_string; - //else - case 'I': //try to match "INF" - INF: - if (s.Substring(i) == "INF") - return TF_float | TF_double | TF_string; - else return TF_string; - case '.': //try to match ".9999" decimal/float/double - FRACTION: - bNeedsRangeCheck = true; - i++; - if (i == s.Length) - { - if ((i == 1) || (i == 2 && (bPositive || bNegative))) //"." "-." "+." - return TF_string; - else - return TF_decimal | TF_float | TF_double | TF_string; - } - switch (s[i]) - { - case 'e': - case 'E': - goto EXPONENT; - default: - if (s[i] >= '0' && s[i] <= '9') - goto DEC_PART; - else - return TF_string; - } - DEC_PART: - i++; if (i == s.Length) return TF_decimal | TF_float | TF_double | TF_string; //"9999.9" was matched - switch (s[i]) - { - case 'e': - case 'E': - goto EXPONENT; - default: - if (s[i] >= '0' && s[i] <= '9') - goto DEC_PART; - else - return TF_string; - } - EXPONENT: - i++; if (i == s.Length) return TF_string; - switch (s[i]) - { - case '+': - case '-': - goto E1; - default: - if (s[i] >= '0' && s[i] <= '9') - goto EXP_PART; - else - return TF_string; - } - E1: - i++; if (i == s.Length) return TF_string; //".9999e+" was matched - if (s[i] >= '0' && s[i] <= '9') - goto EXP_PART; - else - return TF_string; //".999e+X was matched - EXP_PART: - i++; if (i == s.Length) return TF_float | TF_double | TF_string; //".9999e+99" was matched - if (s[i] >= '0' && s[i] <= '9') //".9999e+9 - goto EXP_PART; - else - return TF_string; //".9999e+999X" was matched - case '-': - bNegative = true; - i++; if (i == s.Length) return TF_string; - switch (s[i]) - { - case 'I': //try to match "-INF" - goto INF; - case '.': //try to match "-.9999" - goto FRACTION; - case 'P': - goto DURATION; - default: - if (s[i] >= '0' && s[i] <= '9') //-9 - goto NUMBER; - else return TF_string; - } - case '+': - bPositive = true; - i++; if (i == s.Length) return TF_string; - switch (s[i]) - { - case '.': //try to match "+.9999" - goto FRACTION; - case 'P': - goto DURATION; - default: - if (s[i] >= '0' && s[i] <= '9') //"+9 - goto NUMBER; - else return TF_string; - } - case 'P': //try to match duration - DURATION: - i++; if (i == s.Length) return TF_string; - switch (s[i]) - { - case 'T': - goto D7; - default: - if (s[i] >= '0' && s[i] <= '9') //"P9" - goto D1; - else return TF_string; - } - D1: - i++; if (i == s.Length) return TF_string; //"P999" was matched - switch (s[i]) - { - case 'Y': - goto D2; - case 'M': - goto D4; - case 'D': - goto D6; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D1; - else - return TF_string; - } - D2: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"P999Y" was matched - } - switch (s[i]) - { - case 'T': - goto D7; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D3; - else - return TF_string; - } - D3: - i++; if (i == s.Length) return TF_string; //"P999Y9" was matched - switch (s[i]) - { - case 'M': - goto D4; - case 'D': - goto D6; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D3; - else - return TF_string; - } - D4: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"P999Y999M" was matched - } - switch (s[i]) - { - case 'T': - goto D7; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D5; - else - return TF_string; - } - D5: - i++; if (i == s.Length) return TF_string; //"P999Y999M9" was matched - switch (s[i]) - { - case 'D': - goto D6; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D5; - else - return TF_string; - } - D6: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"P999Y999M999D" was matched - } - switch (s[i]) - { - case 'T': - goto D7; - default: - return TF_string; - } - D7: - i++; if (i == s.Length) return TF_string; //"P999Y999M9999DT" was matched - if (s[i] >= '0' && s[i] <= '9') - goto D8; - else - return TF_string; - D8: - i++; if (i == s.Length) return TF_string; //"___T9" was matched - switch (s[i]) - { - case 'H': - goto D9; - case 'M': - goto D11; - case '.': - goto D13; - case 'S': - goto D15; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D8; - else - return TF_string; - } - D9: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"___T999H" was matched - } - if (s[i] >= '0' && s[i] <= '9') - goto D10; - else - return TF_string; - D10: - i++; if (i == s.Length) return TF_string; //"___T999H9" was matched - switch (s[i]) - { - case 'M': - goto D11; - case '.': - goto D13; - case 'S': - goto D15; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D10; - else - return TF_string; - } - D11: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"___T999H999M" was matched - } - if (s[i] >= '0' && s[i] <= '9') - goto D12; - else - return TF_string; - D12: - i++; if (i == s.Length) return TF_string; //"___T999H999M9" was matched - switch (s[i]) - { - case '.': - goto D13; - case 'S': - goto D15; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D12; - else - return TF_string; - } - D13: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"___T999H999M999." was matched - } - if (s[i] >= '0' && s[i] <= '9') - goto D14; - else - return TF_string; - D14: - i++; if (i == s.Length) return TF_string; //"___T999H999M999.9" was matched - switch (s[i]) - { - case 'S': - goto D15; - default: - if (s[i] >= '0' && s[i] <= '9') - goto D14; - else - return TF_string; - } - D15: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_duration | TF_string; //"___T999H999M999.999S" was matched - } - else return TF_string; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - NUMBER: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - if (bNegative || bPositive) - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; //"-9" - else - { - if (s == "0" || s == "1") - return TF_boolean | TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - else - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - } - switch (s[i]) - { - case '.': - goto FRACTION; - case 'e': - case 'E': - bNeedsRangeCheck = true; - return TF_float | TF_double | TF_string; - default: - if (s[i] >= '0' && s[i] <= '9') - goto N2; - else - return TF_string; - } - N2: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - if (bNegative || bPositive) - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; //"-9" - else - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - switch (s[i]) - { - case '.': - goto FRACTION; - case ':': - bTime = true; - goto MINUTE; - case 'e': - case 'E': - bNeedsRangeCheck = true; - return TF_float | TF_double | TF_string; - default: - if (s[i] >= '0' && s[i] <= '9') - goto N3; - else - return TF_string; - } - - N3: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; //three digits may not fit byte and unsignedByte - if (bNegative || bPositive) - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; //"-9" - else - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - switch (s[i]) - { - case '.': - goto FRACTION; - case 'e': - case 'E': - bNeedsRangeCheck = true; - return TF_float | TF_double | TF_string; - default: - if (s[i] >= '0' && s[i] <= '9') - goto N4; - else - return TF_string; - } - N4: - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - if (bNegative || bPositive) - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; //"-9" - else - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - - switch (s[i]) - { - case '-': - bDate = true; - goto DATE; - case '.': - goto FRACTION; - case 'e': - case 'E': - bNeedsRangeCheck = true; - return TF_float | TF_double | TF_string; - default: - if (s[i] >= '0' && s[i] <= '9') - goto N4; - else - return TF_string; - } - DATE: - i++; if (i == s.Length) return TF_string; //"9999-" - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; //"9999-9" - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; - if (i == s.Length) - { - bNeedsRangeCheck = true; - return TF_gYearMonth | TF_string; //"9999-99" - } - switch (s[i]) - { - case '-': - goto DAY; - case 'Z': - case 'z': - bMissingDay = true; - goto ZULU; - case '+': - bMissingDay = true; - goto ZONE_SHIFT; - default: - return TF_string; - } - DAY: - i++; if (i == s.Length) return TF_string; //"9999-99-" - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; //"9999-99-9" - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return DateTime(s, bDate, bTime); //"9999-99-99" - switch (s[i]) - { - case 'Z': - case 'z': - goto ZULU; - case '+': - case '-': - goto ZONE_SHIFT; - case 'T': - bTime = true; - goto TIME; - case ':': - bMissingDay = true; - goto ZONE_SHIFT_MINUTE; - default: - return TF_string; - } - ZULU: - i++; - if (i == s.Length) - { - if (bMissingDay) - { - bNeedsRangeCheck = true; - return TF_gYearMonth | TF_string; - } - else - { - return DateTime(s, bDate, bTime); - } - } - else - return TF_string; - ZONE_SHIFT: - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] != ':') - return TF_string; - ZONE_SHIFT_MINUTE: - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; - if (i == s.Length) - { - if (bMissingDay) - { - bNeedsRangeCheck = true; - return TF_gYearMonth | TF_string; - } - else - { - return DateTime(s, bDate, bTime); - } - } - else return TF_string; - TIME: - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] != ':') - return TF_string; - MINUTE: - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] != ':') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - i++; if (i == s.Length) return DateTime(s, bDate, bTime); - switch (s[i]) - { - case 'Z': - case 'z': - goto ZULU; - case '+': - case '-': - goto ZONE_SHIFT; - case '.': - goto SECOND_FRACTION; - default: - return TF_string; - } - SECOND_FRACTION: - i++; if (i == s.Length) return TF_string; - if (s[i] < '0' || s[i] > '9') - return TF_string; - FRACT_DIGITS: - i++; if (i == s.Length) return DateTime(s, bDate, bTime); - switch (s[i]) - { - case 'Z': - case 'z': - goto ZULU; - case '+': - case '-': - goto ZONE_SHIFT; - default: - if (s[i] >= '0' && s[i] <= '9') - goto FRACT_DIGITS; - else - return TF_string; - } - default: - return TF_string; - } - } - - internal static int DateTime(string s, bool bDate, bool bTime) - { - try - { - XmlConvert.ToDateTime(s, XmlDateTimeSerializationMode.RoundtripKind); - } - catch (FormatException) - { - return TF_string; - } - if (bDate && bTime) - return TF_dateTime | TF_string; - else if (bDate) - return TF_date | TF_string; - else if (bTime) - return TF_time | TF_string; - else - { - Debug.Assert(false, "Expected date, time or dateTime"); - return TF_string; - } - } - private XmlSchemaElement CreateNewElementforChoice(XmlSchemaElement copyElement) - { - XmlSchemaElement newElement = new XmlSchemaElement(); - newElement.Annotation = copyElement.Annotation; - newElement.Block = copyElement.Block; - newElement.DefaultValue = copyElement.DefaultValue; - newElement.Final = copyElement.Final; - newElement.FixedValue = copyElement.FixedValue; - newElement.Form = copyElement.Form; - newElement.Id = copyElement.Id; - // newElement.IsAbstract = copyElement.IsAbstract; - if (copyElement.IsNillable) - { - newElement.IsNillable = copyElement.IsNillable; - } - newElement.LineNumber = copyElement.LineNumber; - newElement.LinePosition = copyElement.LinePosition; - newElement.Name = copyElement.Name; - newElement.Namespaces = copyElement.Namespaces; - newElement.RefName = copyElement.RefName; - newElement.SchemaType = copyElement.SchemaType; - newElement.SchemaTypeName = copyElement.SchemaTypeName; - newElement.SourceUri = copyElement.SourceUri; - newElement.SubstitutionGroup = copyElement.SubstitutionGroup; - newElement.UnhandledAttributes = copyElement.UnhandledAttributes; - if (copyElement.MinOccurs != Decimal.One && this.Occurrence == InferenceOption.Relaxed) - { - newElement.MinOccurs = copyElement.MinOccurs; - } - if (copyElement.MaxOccurs != Decimal.One) - { - newElement.MaxOccurs = copyElement.MaxOccurs; - } - return newElement; - } - - private static int GetSchemaType(XmlQualifiedName qname) - { - if (qname == SimpleTypes[HC_ST_boolean]) - { - return TF_boolean | TF_string; - } - if (qname == SimpleTypes[HC_ST_byte]) - { - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_unsignedByte]) - { - return TF_byte | TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedByte | TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - if (qname == SimpleTypes[HC_ST_short]) - { - return TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_unsignedShort]) - { - return TF_short | TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedShort | TF_unsignedInt | TF_unsignedLong | TF_string; - } - if (qname == SimpleTypes[HC_ST_int]) - { - return TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_unsignedInt]) - { - return TF_int | TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedInt | TF_unsignedLong | TF_string; - } - if (qname == SimpleTypes[HC_ST_long]) - { - return TF_long | TF_integer | TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_unsignedLong]) - { - return TF_long | TF_integer | TF_decimal | TF_float | TF_double | - TF_unsignedLong | TF_string; - } - if (qname == SimpleTypes[HC_ST_integer]) - { - return TF_integer | TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_decimal]) - { - return TF_decimal | TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_float]) - { - return TF_float | TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_double]) - { - return TF_double | TF_string; - } - if (qname == SimpleTypes[HC_ST_duration]) - { - return TF_duration | TF_string; - } - if (qname == SimpleTypes[HC_ST_dateTime]) - { - return TF_dateTime | TF_string; - } - if (qname == SimpleTypes[HC_ST_time]) - { - return TF_time | TF_string; - } - if (qname == SimpleTypes[HC_ST_date]) - { - return TF_date; - } - if (qname == SimpleTypes[HC_ST_gYearMonth]) - { - return TF_gYearMonth; - } - if (qname == SimpleTypes[HC_ST_string]) - { - return TF_string; - } - if (qname == null || qname.IsEmpty) - { - return -1; - } - throw new XmlSchemaInferenceException(ResXml.SchInf_schematype, 0, 0); - } - - internal void SetMinMaxOccurs(XmlSchemaElement el, bool setMaxOccurs) - { - if (this.Occurrence == InferenceOption.Relaxed) - { - if (setMaxOccurs || el.MaxOccurs > 1) - { - el.MaxOccurs = decimal.MaxValue; //set it to unbounded - } - el.MinOccurs = 0; - } - else if (el.MinOccurs > 1) - { - el.MinOccurs = 1; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/NamespaceList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/NamespaceList.cs deleted file mode 100644 index b12dd136d6f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/NamespaceList.cs +++ /dev/null @@ -1,414 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - using System.Collections; - using System.Text; - using System.Diagnostics; - - internal class NamespaceList - { - public enum ListType - { - Any, - Other, - Set - }; - - private ListType _type = ListType.Any; - private Hashtable _set = null; - private string _targetNamespace; - - public NamespaceList() - { - } - - public NamespaceList(string namespaces, string targetNamespace) - { - Debug.Assert(targetNamespace != null); - _targetNamespace = targetNamespace; - namespaces = namespaces.Trim(); - if (namespaces == "##any" || namespaces.Length == 0) - { - _type = ListType.Any; - } - else if (namespaces == "##other") - { - _type = ListType.Other; - } - else - { - _type = ListType.Set; - _set = new Hashtable(); - string[] splitString = XmlConvert.SplitString(namespaces); - for (int i = 0; i < splitString.Length; ++i) - { - if (splitString[i] == "##local") - { - _set[string.Empty] = string.Empty; - } - else if (splitString[i] == "##targetNamespace") - { - _set[targetNamespace] = targetNamespace; - } - else - { - XmlConvert.ToUri(splitString[i]); // can throw - _set[splitString[i]] = splitString[i]; - } - } - } - } - - public NamespaceList Clone() - { - NamespaceList nsl = (NamespaceList)MemberwiseClone(); - if (_type == ListType.Set) - { - Debug.Assert(_set != null); - nsl._set = (Hashtable)(_set.Clone()); - } - return nsl; - } - - public ListType Type - { - get { return _type; } - } - - public string Excluded - { - get { return _targetNamespace; } - } - - public ICollection Enumerate - { - get - { - switch (_type) - { - case ListType.Set: - return _set.Keys; - case ListType.Other: - case ListType.Any: - default: - throw new InvalidOperationException(); - } - } - } - - public virtual bool Allows(string ns) - { - switch (_type) - { - case ListType.Any: - return true; - case ListType.Other: - return ns != _targetNamespace && ns.Length != 0; - case ListType.Set: - return _set[ns] != null; - } - Debug.Assert(false); - return false; - } - - public bool Allows(XmlQualifiedName qname) - { - return Allows(qname.Namespace); - } - - public override string ToString() - { - switch (_type) - { - case ListType.Any: - return "##any"; - case ListType.Other: - return "##other"; - case ListType.Set: - StringBuilder sb = new StringBuilder(); - bool first = true; - foreach (string s in _set.Keys) - { - if (first) - { - first = false; - } - else - { - sb.Append(" "); - } - if (s == _targetNamespace) - { - sb.Append("##targetNamespace"); - } - else if (s.Length == 0) - { - sb.Append("##local"); - } - else - { - sb.Append(s); - } - } - return sb.ToString(); - } - Debug.Assert(false); - return string.Empty; - } - - public static bool IsSubset(NamespaceList sub, NamespaceList super) - { - if (super._type == ListType.Any) - { - return true; - } - else if (sub._type == ListType.Other && super._type == ListType.Other) - { - return super._targetNamespace == sub._targetNamespace; - } - else if (sub._type == ListType.Set) - { - if (super._type == ListType.Other) - { - return !sub._set.Contains(super._targetNamespace); - } - else - { - Debug.Assert(super._type == ListType.Set); - foreach (string ns in sub._set.Keys) - { - if (!super._set.Contains(ns)) - { - return false; - } - } - return true; - } - } - return false; - } - - - public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat) - { - NamespaceList nslist = null; - Debug.Assert(o1 != o2); - if (o1._type == ListType.Any) - { //clause 2 - o1 is Any - nslist = new NamespaceList(); - } - else if (o2._type == ListType.Any) - { //clause 2 - o2 is Any - nslist = new NamespaceList(); - } - else if (o1._type == ListType.Set && o2._type == ListType.Set) - { //clause 3 , both are sets - nslist = o1.Clone(); - foreach (string ns in o2._set.Keys) - { - nslist._set[ns] = ns; - } - } - else if (o1._type == ListType.Other && o2._type == ListType.Other) - { //clause 4, both are negations - if (o1._targetNamespace == o2._targetNamespace) - { //negation of same value - nslist = o1.Clone(); - } - else - { //Not a breaking change, going from not expressible to not(absent) - nslist = new NamespaceList("##other", string.Empty); //clause 4, negations of different values, result is not(absent) - } - } - else if (o1._type == ListType.Set && o2._type == ListType.Other) - { - if (v1Compat) - { - if (o1._set.Contains(o2._targetNamespace)) - { - nslist = new NamespaceList(); - } - else - { //This was not there originally in V1, added for consistency since its not breaking - nslist = o2.Clone(); - } - } - else - { - if (o2._targetNamespace != string.Empty) - { //clause 5, o1 is set S, o2 is not(tns) - nslist = o1.CompareSetToOther(o2); - } - else if (o1._set.Contains(string.Empty)) - { //clause 6.1 - set S includes absent, o2 is not(absent) - nslist = new NamespaceList(); - } - else - { //clause 6.2 - set S does not include absent, result is not(absent) - nslist = new NamespaceList("##other", string.Empty); - } - } - } - else if (o2._type == ListType.Set && o1._type == ListType.Other) - { - if (v1Compat) - { - if (o2._set.Contains(o2._targetNamespace)) - { - nslist = new NamespaceList(); - } - else - { - nslist = o1.Clone(); - } - } - else - { //New rules - if (o1._targetNamespace != string.Empty) - { //clause 5, o1 is set S, o2 is not(tns) - nslist = o2.CompareSetToOther(o1); - } - else if (o2._set.Contains(string.Empty)) - { //clause 6.1 - set S includes absent, o2 is not(absent) - nslist = new NamespaceList(); - } - else - { //clause 6.2 - set S does not include absent, result is not(absent) - nslist = new NamespaceList("##other", string.Empty); - } - } - } - return nslist; - } - - private NamespaceList CompareSetToOther(NamespaceList other) - { - //clause 5.1 - NamespaceList nslist = null; - if (_set.Contains(other._targetNamespace)) - { //S contains negated ns - if (_set.Contains(string.Empty)) - { // AND S contains absent - nslist = new NamespaceList(); //any is the result - } - else - { //clause 5.2 - nslist = new NamespaceList("##other", string.Empty); - } - } - else if (_set.Contains(string.Empty)) - { //clause 5.3 - Not expressible - nslist = null; - } - else - { //clause 5.4 - Set S does not contain negated ns or absent - nslist = other.Clone(); - } - return nslist; - } - - public static NamespaceList Intersection(NamespaceList o1, NamespaceList o2, bool v1Compat) - { - NamespaceList nslist = null; - Debug.Assert(o1 != o2); //clause 1 - if (o1._type == ListType.Any) - { //clause 2 - o1 is any - nslist = o2.Clone(); - } - else if (o2._type == ListType.Any) - { //clause 2 - o2 is any - nslist = o1.Clone(); - } - else if (o1._type == ListType.Set && o2._type == ListType.Other) - { //Clause 3 o2 is other - nslist = o1.Clone(); - nslist.RemoveNamespace(o2._targetNamespace); - if (!v1Compat) - { - nslist.RemoveNamespace(string.Empty); //remove ##local - } - } - else if (o1._type == ListType.Other && o2._type == ListType.Set) - { //Clause 3 o1 is other - nslist = o2.Clone(); - nslist.RemoveNamespace(o1._targetNamespace); - if (!v1Compat) - { - nslist.RemoveNamespace(string.Empty); //remove ##local - } - } - else if (o1._type == ListType.Set && o2._type == ListType.Set) - { //clause 4 - nslist = o1.Clone(); - nslist = new NamespaceList(); - nslist._type = ListType.Set; - nslist._set = new Hashtable(); - foreach (string ns in o1._set.Keys) - { - if (o2._set.Contains(ns)) - { - nslist._set.Add(ns, ns); - } - } - } - else if (o1._type == ListType.Other && o2._type == ListType.Other) - { - if (o1._targetNamespace == o2._targetNamespace) - { //negation of same namespace name - nslist = o1.Clone(); - return nslist; - } - if (!v1Compat) - { - if (o1._targetNamespace == string.Empty) - { // clause 6 - o1 is negation of absent - nslist = o2.Clone(); - } - else if (o2._targetNamespace == string.Empty) - { //clause 6 - o1 is negation of absent - nslist = o1.Clone(); - } - } - //if it comes here, its not expressible //clause 5 - } - return nslist; - } - - private void RemoveNamespace(string tns) - { - if (_set[tns] != null) - { - _set.Remove(tns); - } - } - - public bool IsEmpty() - { - return ((_type == ListType.Set) && ((_set == null) || _set.Count == 0)); - } - }; - - internal class NamespaceListV1Compat : NamespaceList - { - public NamespaceListV1Compat(string namespaces, string targetNamespace) : base(namespaces, targetNamespace) { } - - public override bool Allows(string ns) - { - if (this.Type == ListType.Other) - { - return ns != Excluded; - } - else - { - return base.Allows(ns); - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Parser.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Parser.cs deleted file mode 100644 index ec43a91ba9d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Parser.cs +++ /dev/null @@ -1,480 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Globalization; - using System.Text; - using System.IO; - using System.Diagnostics; - - internal sealed partial class Parser - { - private SchemaType _schemaType; - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private ValidationEventHandler _eventHandler; - private XmlNamespaceManager _namespaceManager; - private XmlReader _reader; - private PositionInfo _positionInfo; - private bool _isProcessNamespaces; - private int _schemaXmlDepth = 0; - private int _markupDepth; - private SchemaBuilder _builder; - private XmlSchema _schema; - private SchemaInfo _xdrSchema; - private XmlResolver _xmlResolver = null; //to be used only by XDRBuilder - - //xs:Annotation perf fix - private XmlDocument _dummyDocument; - private bool _processMarkup; - private XmlNode _parentNode; - private XmlNamespaceManager _annotationNSManager; - private string _xmlns; - - //Whitespace check for text nodes - private XmlCharType _xmlCharType = XmlCharType.Instance; - - public Parser(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) - { - _schemaType = schemaType; - _nameTable = nameTable; - _schemaNames = schemaNames; - _eventHandler = eventHandler; - _xmlResolver = Microsoft.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(); - _processMarkup = true; - _dummyDocument = new XmlDocument(); - } - - public SchemaType Parse(XmlReader reader, string targetNamespace) - { - StartParsing(reader, targetNamespace); - while (ParseReaderNode() && reader.Read()) { } - return FinishParsing(); - } - - public void StartParsing(XmlReader reader, string targetNamespace) - { - _reader = reader; - _positionInfo = PositionInfo.GetPositionInfo(reader); - _namespaceManager = reader.NamespaceManager; - if (_namespaceManager == null) - { - _namespaceManager = new XmlNamespaceManager(_nameTable); - _isProcessNamespaces = true; - } - else - { - _isProcessNamespaces = false; - } - while (reader.NodeType != XmlNodeType.Element && reader.Read()) { } - - _markupDepth = int.MaxValue; - _schemaXmlDepth = reader.Depth; - SchemaType rootType = _schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI); - - string code; - if (!CheckSchemaRoot(rootType, out code)) - { - throw new XmlSchemaException(code, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition); - } - - if (_schemaType == SchemaType.XSD) - { - _schema = new XmlSchema(); - _schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute); - _builder = new XsdBuilder(reader, _namespaceManager, _schema, _nameTable, _schemaNames, _eventHandler); - } - else - { - Debug.Assert(_schemaType == SchemaType.XDR); - _xdrSchema = new SchemaInfo(); - _xdrSchema.SchemaType = SchemaType.XDR; - _builder = new XdrBuilder(reader, _namespaceManager, _xdrSchema, targetNamespace, _nameTable, _schemaNames, _eventHandler); - ((XdrBuilder)_builder).XmlResolver = _xmlResolver; - } - } - - private bool CheckSchemaRoot(SchemaType rootType, out string code) - { - code = null; - if (_schemaType == SchemaType.None) - { - _schemaType = rootType; - } - switch (rootType) - { - case SchemaType.XSD: - if (_schemaType != SchemaType.XSD) - { - code = ResXml.Sch_MixSchemaTypes; - return false; - } - break; - - case SchemaType.XDR: - if (_schemaType == SchemaType.XSD) - { - code = ResXml.Sch_XSDSchemaOnly; - return false; - } - else if (_schemaType != SchemaType.XDR) - { - code = ResXml.Sch_MixSchemaTypes; - return false; - } - break; - - case SchemaType.DTD: //Did not detect schema type that can be parsed by this parser - case SchemaType.None: - code = ResXml.Sch_SchemaRootExpected; - if (_schemaType == SchemaType.XSD) - { - code = ResXml.Sch_XSDSchemaRootExpected; - } - return false; - - default: - Debug.Assert(false); - break; - } - return true; - } - - public SchemaType FinishParsing() - { - return _schemaType; - } - - public XmlSchema XmlSchema - { - get { return _schema; } - } - - internal XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - } - } - - public SchemaInfo XdrSchema - { - get { return _xdrSchema; } - } - - public bool ParseReaderNode() - { - if (_reader.Depth > _markupDepth) - { - if (_processMarkup) - { - ProcessAppInfoDocMarkup(false); - } - return true; - } - else if (_reader.NodeType == XmlNodeType.Element) - { - if (_builder.ProcessElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI)) - { - _namespaceManager.PushScope(); - if (_reader.MoveToFirstAttribute()) - { - do - { - _builder.ProcessAttribute(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _reader.Value); - if (Ref.Equal(_reader.NamespaceURI, _schemaNames.NsXmlNs) && _isProcessNamespaces) - { - _namespaceManager.AddNamespace(_reader.Prefix.Length == 0 ? string.Empty : _reader.LocalName, _reader.Value); - } - } - while (_reader.MoveToNextAttribute()); - _reader.MoveToElement(); // get back to the element - } - _builder.StartChildren(); - if (_reader.IsEmptyElement) - { - _namespaceManager.PopScope(); - _builder.EndChildren(); - if (_reader.Depth == _schemaXmlDepth) - { - return false; // done - } - } - else if (!_builder.IsContentParsed()) - { //AppInfo and Documentation - _markupDepth = _reader.Depth; - _processMarkup = true; - if (_annotationNSManager == null) - { - _annotationNSManager = new XmlNamespaceManager(_nameTable); - _xmlns = _nameTable.Add("xmlns"); - } - ProcessAppInfoDocMarkup(true); - } - } - else if (!_reader.IsEmptyElement) - { //UnsupportedElement in that context - _markupDepth = _reader.Depth; - _processMarkup = false; //Hack to not process unsupported elements - } - } - else if (_reader.NodeType == XmlNodeType.Text) - { //Check for whitespace - if (!_xmlCharType.IsOnlyWhitespace(_reader.Value)) - { - _builder.ProcessCData(_reader.Value); - } - } - else if (_reader.NodeType == XmlNodeType.EntityReference || - _reader.NodeType == XmlNodeType.SignificantWhitespace || - _reader.NodeType == XmlNodeType.CDATA) - { - _builder.ProcessCData(_reader.Value); - } - else if (_reader.NodeType == XmlNodeType.EndElement) - { - if (_reader.Depth == _markupDepth) - { - if (_processMarkup) - { - Debug.Assert(_parentNode != null); - XmlNodeList list = _parentNode.ChildNodes; - XmlNode[] markup = new XmlNode[list.Count]; - for (int i = 0; i < list.Count; i++) - { - markup[i] = list[i]; - } - _builder.ProcessMarkup(markup); - _namespaceManager.PopScope(); - _builder.EndChildren(); - } - _markupDepth = int.MaxValue; - } - else - { - _namespaceManager.PopScope(); - _builder.EndChildren(); - } - if (_reader.Depth == _schemaXmlDepth) - { - return false; // done - } - } - return true; - } - - private void ProcessAppInfoDocMarkup(bool root) - { - //First time reader is positioned on AppInfo or Documentation element - XmlNode currentNode = null; - - switch (_reader.NodeType) - { - case XmlNodeType.Element: - _annotationNSManager.PushScope(); - currentNode = LoadElementNode(root); - // Dev10 (TFS) #479761: The following code was to address the issue of where an in-scope namespace delaration attribute - // was not added when an element follows an empty element. This fix will result in persisting schema in a consistent form - // although it does not change the semantic meaning of the schema. - // Since it is as a breaking change and Dev10 needs to maintain the backward compatibility, this fix is being reverted. - // if (reader.IsEmptyElement) { - // annotationNSManager.PopScope(); - // } - break; - - case XmlNodeType.Text: - currentNode = _dummyDocument.CreateTextNode(_reader.Value); - goto default; - - case XmlNodeType.SignificantWhitespace: - currentNode = _dummyDocument.CreateSignificantWhitespace(_reader.Value); - goto default; - - case XmlNodeType.CDATA: - currentNode = _dummyDocument.CreateCDataSection(_reader.Value); - goto default; - - case XmlNodeType.EntityReference: - currentNode = _dummyDocument.CreateEntityReference(_reader.Name); - goto default; - - case XmlNodeType.Comment: - currentNode = _dummyDocument.CreateComment(_reader.Value); - goto default; - - case XmlNodeType.ProcessingInstruction: - currentNode = _dummyDocument.CreateProcessingInstruction(_reader.Name, _reader.Value); - goto default; - - case XmlNodeType.EndEntity: - break; - - case XmlNodeType.Whitespace: - break; - - case XmlNodeType.EndElement: - _annotationNSManager.PopScope(); - _parentNode = _parentNode.ParentNode; - break; - - default: //other possible node types: Document/DocType/DocumentFrag/Entity/Notation/Xmldecl cannot appear as children of xs:appInfo or xs:doc - Debug.Assert(currentNode != null); - Debug.Assert(_parentNode != null); - _parentNode.AppendChild(currentNode); - break; - } - } - - private XmlElement LoadElementNode(bool root) - { - Debug.Assert(_reader.NodeType == XmlNodeType.Element); - - XmlReader r = _reader; - bool fEmptyElement = r.IsEmptyElement; - - XmlElement element = _dummyDocument.CreateElement(r.Prefix, r.LocalName, r.NamespaceURI); - element.IsEmpty = fEmptyElement; - - if (root) - { - _parentNode = element; - } - else - { - XmlAttributeCollection attributes = element.Attributes; - if (r.MoveToFirstAttribute()) - { - do - { - if (Ref.Equal(r.NamespaceURI, _schemaNames.NsXmlNs)) - { //Namespace Attribute - _annotationNSManager.AddNamespace(r.Prefix.Length == 0 ? string.Empty : _reader.LocalName, _reader.Value); - } - XmlAttribute attr = LoadAttributeNode(); - attributes.Append(attr); - } while (r.MoveToNextAttribute()); - } - r.MoveToElement(); - string ns = _annotationNSManager.LookupNamespace(r.Prefix); - if (ns == null) - { - XmlAttribute attr = CreateXmlNsAttribute(r.Prefix, _namespaceManager.LookupNamespace(r.Prefix)); - attributes.Append(attr); - } - else if (ns.Length == 0) - { //string.Empty prefix is mapped to string.Empty NS by default - string elemNS = _namespaceManager.LookupNamespace(r.Prefix); - if (elemNS != string.Empty) - { - XmlAttribute attr = CreateXmlNsAttribute(r.Prefix, elemNS); - attributes.Append(attr); - } - } - - while (r.MoveToNextAttribute()) - { - if (r.Prefix.Length != 0) - { - string attNS = _annotationNSManager.LookupNamespace(r.Prefix); - if (attNS == null) - { - XmlAttribute attr = CreateXmlNsAttribute(r.Prefix, _namespaceManager.LookupNamespace(r.Prefix)); - attributes.Append(attr); - } - } - } - r.MoveToElement(); - - _parentNode.AppendChild(element); - if (!r.IsEmptyElement) - { - _parentNode = element; - } - } - return element; - } - - private XmlAttribute CreateXmlNsAttribute(string prefix, string value) - { - XmlAttribute attr; - if (prefix.Length == 0) - { - attr = _dummyDocument.CreateAttribute(string.Empty, _xmlns, XmlReservedNs.NsXmlNs); - } - else - { - attr = _dummyDocument.CreateAttribute(_xmlns, prefix, XmlReservedNs.NsXmlNs); - } - attr.AppendChild(_dummyDocument.CreateTextNode(value)); - _annotationNSManager.AddNamespace(prefix, value); - return attr; - } - - private XmlAttribute LoadAttributeNode() - { - Debug.Assert(_reader.NodeType == XmlNodeType.Attribute); - - XmlReader r = _reader; - - XmlAttribute attr = _dummyDocument.CreateAttribute(r.Prefix, r.LocalName, r.NamespaceURI); - - while (r.ReadAttributeValue()) - { - switch (r.NodeType) - { - case XmlNodeType.Text: - attr.AppendChild(_dummyDocument.CreateTextNode(r.Value)); - continue; - case XmlNodeType.EntityReference: - attr.AppendChild(LoadEntityReferenceInAttribute()); - continue; - default: - throw XmlLoader.UnexpectedNodeType(r.NodeType); - } - } - - return attr; - } - - private XmlEntityReference LoadEntityReferenceInAttribute() - { - Debug.Assert(_reader.NodeType == XmlNodeType.EntityReference); - - XmlEntityReference eref = _dummyDocument.CreateEntityReference(_reader.LocalName); - if (!_reader.CanResolveEntity) - { - return eref; - } - _reader.ResolveEntity(); - - while (_reader.ReadAttributeValue()) - { - switch (_reader.NodeType) - { - case XmlNodeType.Text: - eref.AppendChild(_dummyDocument.CreateTextNode(_reader.Value)); - continue; - case XmlNodeType.EndEntity: - if (eref.ChildNodes.Count == 0) - { - eref.AppendChild(_dummyDocument.CreateTextNode(String.Empty)); - } - return eref; - case XmlNodeType.EntityReference: - eref.AppendChild(LoadEntityReferenceInAttribute()); - break; - default: - throw XmlLoader.UnexpectedNodeType(_reader.NodeType); - } - } - - return eref; - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ParserAsync.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ParserAsync.cs deleted file mode 100644 index 12078215c96..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ParserAsync.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Globalization; - using System.Text; - using System.IO; - using System.Diagnostics; - - using System.Threading.Tasks; - - internal sealed partial class Parser - { - public async Task ParseAsync(XmlReader reader, string targetNamespace) - { - await StartParsingAsync(reader, targetNamespace).ConfigureAwait(false); - while (ParseReaderNode() && await reader.ReadAsync().ConfigureAwait(false)) { } - return FinishParsing(); - } - - public async Task StartParsingAsync(XmlReader reader, string targetNamespace) - { - _reader = reader; - _positionInfo = PositionInfo.GetPositionInfo(reader); - _namespaceManager = reader.NamespaceManager; - if (_namespaceManager == null) - { - _namespaceManager = new XmlNamespaceManager(_nameTable); - _isProcessNamespaces = true; - } - else - { - _isProcessNamespaces = false; - } - while (reader.NodeType != XmlNodeType.Element && await reader.ReadAsync().ConfigureAwait(false)) { } - - _markupDepth = int.MaxValue; - _schemaXmlDepth = reader.Depth; - SchemaType rootType = _schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI); - - string code; - if (!CheckSchemaRoot(rootType, out code)) - { - throw new XmlSchemaException(code, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition); - } - - if (_schemaType == SchemaType.XSD) - { - _schema = new XmlSchema(); - _schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute); - _builder = new XsdBuilder(reader, _namespaceManager, _schema, _nameTable, _schemaNames, _eventHandler); - } - else - { - Debug.Assert(_schemaType == SchemaType.XDR); - _xdrSchema = new SchemaInfo(); - _xdrSchema.SchemaType = SchemaType.XDR; - _builder = new XdrBuilder(reader, _namespaceManager, _xdrSchema, targetNamespace, _nameTable, _schemaNames, _eventHandler); - ((XdrBuilder)_builder).XmlResolver = _xmlResolver; - } - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Preprocessor.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Preprocessor.cs deleted file mode 100644 index 6b71e306e32..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/Preprocessor.cs +++ /dev/null @@ -1,2215 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.IO; - using System.Threading; - using System.Diagnostics; - using System.Collections.Generic; - using System.Runtime.Versioning; - using System.Reflection; - - internal enum Compositor - { - Root, - Include, - Import, - Redefine - }; - - internal class RedefineEntry - { - internal XmlSchemaRedefine redefine; - internal XmlSchema schemaToUpdate; - - public RedefineEntry(XmlSchemaRedefine external, XmlSchema schema) - { - redefine = external; - schemaToUpdate = schema; - } - } - - internal sealed class Preprocessor : BaseProcessor - { - private string _xmlns; - private string _nsXsi; - private string _targetNamespace; - - private XmlSchema _rootSchema; - private XmlSchema _currentSchema; - - private XmlSchemaForm _elementFormDefault; - private XmlSchemaForm _attributeFormDefault; - private XmlSchemaDerivationMethod _blockDefault; - private XmlSchemaDerivationMethod _finalDefault; - - /*Dictionary schemaLocations; - Dictionary chameleonSchemas;*/ - private Hashtable _schemaLocations; - private Hashtable _chameleonSchemas; - - private Hashtable _referenceNamespaces; - private Hashtable _processedExternals; - private SortedList _lockList; - - private XmlReaderSettings _readerSettings; - - //For redefines - private XmlSchema _rootSchemaForRedefine = null; - private ArrayList _redefinedList; - - private static XmlSchema s_builtInSchemaForXmlNS; - - private const XmlSchemaDerivationMethod schemaBlockDefaultAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Substitution; - private const XmlSchemaDerivationMethod schemaFinalDefaultAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union; - private const XmlSchemaDerivationMethod elementBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Substitution; - private const XmlSchemaDerivationMethod elementFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private const XmlSchemaDerivationMethod simpleTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union; - private const XmlSchemaDerivationMethod complexTypeBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private const XmlSchemaDerivationMethod complexTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - - private XmlResolver _xmlResolver = null; - - public Preprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) - : this(nameTable, schemaNames, eventHandler, new XmlSchemaCompilationSettings()) { } - - public Preprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings) - : base(nameTable, schemaNames, eventHandler, compilationSettings) - { - _referenceNamespaces = new Hashtable(); - _processedExternals = new Hashtable(); - _lockList = new SortedList(); - } - - - public bool Execute(XmlSchema schema, string targetNamespace, bool loadExternals) - { - _rootSchema = schema; //Need to lock main schema here - _xmlns = NameTable.Add("xmlns"); - _nsXsi = NameTable.Add(XmlReservedNs.NsXsi); - - _rootSchema.ImportedSchemas.Clear(); - _rootSchema.ImportedNamespaces.Clear(); - - //Add root schema to the schemaLocations table - if (_rootSchema.BaseUri != null) - { - if (_schemaLocations[_rootSchema.BaseUri] == null) - { - _schemaLocations.Add(_rootSchema.BaseUri, _rootSchema); - } - } - //Check targetNamespace for rootSchema - if (_rootSchema.TargetNamespace != null) - { - if (targetNamespace == null) - { - targetNamespace = _rootSchema.TargetNamespace; - } - else if (targetNamespace != _rootSchema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceEx, targetNamespace, _rootSchema.TargetNamespace, _rootSchema); - } - } - else if (targetNamespace != null && targetNamespace.Length != 0) - { //if schema.TargetNamespace == null & targetNamespace != null, we will force the schema components into targetNamespace - _rootSchema = GetChameleonSchema(targetNamespace, _rootSchema); //Chameleon include at top-level - } - if (loadExternals && _xmlResolver != null) - { - LoadExternals(_rootSchema); - } - BuildSchemaList(_rootSchema); - int schemaIndex = 0; - XmlSchema listSchema; - try - { - //Accquire locks on all schema objects; Need to lock only on pre-created schemas and not parsed schemas - for (schemaIndex = 0; schemaIndex < _lockList.Count; schemaIndex++) - { - listSchema = (XmlSchema)_lockList.GetByIndex(schemaIndex); -#pragma warning disable 0618 - //@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- ericeil - Monitor.Enter(listSchema); -#pragma warning restore 0618 - listSchema.IsProcessing = false; //Reset processing flag from LoadExternals - } - //Preprocess - _rootSchemaForRedefine = _rootSchema; - Preprocess(_rootSchema, targetNamespace, _rootSchema.ImportedSchemas); - if (_redefinedList != null) - { //If there were redefines - for (int i = 0; i < _redefinedList.Count; ++i) - { - PreprocessRedefine((RedefineEntry)_redefinedList[i]); - } - } - } - finally - { //Releasing locks in finally block - if (schemaIndex == _lockList.Count) - { - schemaIndex--; - } - - for (int i = schemaIndex; schemaIndex >= 0; schemaIndex--) - { - listSchema = (XmlSchema)_lockList.GetByIndex(schemaIndex); - listSchema.IsProcessing = false; //Reset processing flag from Preprocess - if (listSchema == Preprocessor.GetBuildInSchema()) - { //dont re-set compiled flags for xml namespace schema - Monitor.Exit(listSchema); - continue; - } - listSchema.IsCompiledBySet = false; - listSchema.IsPreprocessed = !HasErrors; - Monitor.Exit(listSchema); //Release locks on all schema objects - } - } - _rootSchema.IsPreprocessed = !HasErrors; //For chameleon at top-level - return !HasErrors; - } - - private void Cleanup(XmlSchema schema) - { - if (schema == Preprocessor.GetBuildInSchema()) - { - return; - } - schema.Attributes.Clear(); - schema.AttributeGroups.Clear(); - schema.SchemaTypes.Clear(); - schema.Elements.Clear(); - schema.Groups.Clear(); - schema.Notations.Clear(); - schema.Ids.Clear(); - schema.IdentityConstraints.Clear(); - schema.IsRedefined = false; - schema.IsCompiledBySet = false; - } - - private void CleanupRedefine(XmlSchemaExternal include) - { - XmlSchemaRedefine rdef = include as XmlSchemaRedefine; - rdef.AttributeGroups.Clear(); - rdef.Groups.Clear(); - rdef.SchemaTypes.Clear(); - } - - internal XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - } - } - - internal XmlReaderSettings ReaderSettings - { - get - { - if (_readerSettings == null) - { - _readerSettings = new XmlReaderSettings(); - _readerSettings.DtdProcessing = DtdProcessing.Prohibit; - } - return _readerSettings; - } - set - { - _readerSettings = value; - } - } - - //internal Dictionary SchemaLocations { - internal Hashtable SchemaLocations - { - set - { - _schemaLocations = value; - } - } - - - //internal Dictionary ChameleonSchemas { - internal Hashtable ChameleonSchemas - { - set - { - _chameleonSchemas = value; - } - } - - internal XmlSchema RootSchema - { - get - { - return _rootSchema; //This is required to get back a cloned chameleon - } - } - - private void BuildSchemaList(XmlSchema schema) - { - if (_lockList.Contains(schema.SchemaId)) - { - return; - } - _lockList.Add(schema.SchemaId, schema); - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal ext = (XmlSchemaExternal)schema.Includes[i]; - if (ext.Schema != null) - { - BuildSchemaList(ext.Schema); - } - } - } - - // SxS: This method uses resource names read from source document and does not expose any resources to the caller. - // It's OK to disable the SxS warning. - - - private void LoadExternals(XmlSchema schema) - { - if (schema.IsProcessing) - { - return; - } - schema.IsProcessing = true; - for (int i = 0; i < schema.Includes.Count; ++i) - { - Uri includeLocation = null; - //CASE 1: If the Schema object of the include has been set - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - XmlSchema includedSchema = include.Schema; - if (includedSchema != null) - { - // already loaded - includeLocation = includedSchema.BaseUri; - if (includeLocation != null && _schemaLocations[includeLocation] == null) - { - _schemaLocations.Add(includeLocation, includedSchema); - } - LoadExternals(includedSchema); - continue; - } - - //CASE 2: Try & Parse schema from the provided location - string schemaLocation = include.SchemaLocation; - Uri ruri = null; - Exception innerException = null; - if (schemaLocation != null) - { - try - { - ruri = ResolveSchemaLocationUri(schema, schemaLocation); - } - catch (Exception e) - { - ruri = null; - innerException = e; - } - } - - if (include.Compositor == Compositor.Import) - { - XmlSchemaImport import = include as XmlSchemaImport; - Debug.Assert(import != null); - string importNS = import.Namespace != null ? import.Namespace : string.Empty; - if (!schema.ImportedNamespaces.Contains(importNS)) - { - schema.ImportedNamespaces.Add(importNS); - } - //CASE 2.1: If the imported namespace is the XML namespace, - // If the parent schemaSet already has schema for XML ns loaded, use that - // Else if the location is null use the built-in one - // else go through regular processing of parsing from location - if (importNS == XmlReservedNs.NsXml) - { - if (ruri == null) - { //Resolved location is null, hence get the built-in one - include.Schema = Preprocessor.GetBuildInSchema(); - continue; - } - } - } - - //CASE 3: Parse schema from the provided location - if (ruri == null) - { - if (schemaLocation != null) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_InvalidIncludeLocation, null, innerException, include.SourceUri, include.LineNumber, include.LinePosition, include), XmlSeverityType.Warning); - } - continue; - } - - if (_schemaLocations[ruri] == null) - { // Only if location already not processed - object obj = null; - try - { - obj = GetSchemaEntity(ruri); - } - catch (Exception eInner) - { - innerException = eInner; - obj = null; - } - - if (obj != null) - { - include.BaseUri = ruri; - Type returnType = obj.GetType(); - TypeInfo returnTypeInfo = returnType.GetTypeInfo(); - if (typeof(XmlSchema).IsAssignableFrom(returnType)) - { //To handle XmlSchema and all its derived types - include.Schema = (XmlSchema)obj; - _schemaLocations.Add(ruri, include.Schema); - LoadExternals(include.Schema); - } - else - { - XmlReader reader = null; - if (returnTypeInfo.IsSubclassOf(typeof(Stream))) - { - _readerSettings.CloseInput = true; - _readerSettings.XmlResolver = _xmlResolver; - reader = XmlReader.Create((Stream)obj, _readerSettings, ruri.ToString()); - } - else if (returnTypeInfo.IsSubclassOf(typeof(XmlReader))) - { - reader = (XmlReader)obj; - } - else if (returnTypeInfo.IsSubclassOf(typeof(TextReader))) - { - _readerSettings.CloseInput = true; - _readerSettings.XmlResolver = _xmlResolver; - reader = XmlReader.Create((TextReader)obj, _readerSettings, ruri.ToString()); - } - if (reader == null) - { - SendValidationEvent(ResXml.Sch_InvalidIncludeLocation, include, XmlSeverityType.Warning); - continue; - } - try - { - Parser parser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); - parser.Parse(reader, null); - while (reader.Read()) ;// wellformness check - includedSchema = parser.XmlSchema; - include.Schema = includedSchema; - _schemaLocations.Add(ruri, includedSchema); - LoadExternals(includedSchema); - } - catch (XmlSchemaException e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchemaLocation, schemaLocation, e.Message, e.SourceUri, e.LineNumber, e.LinePosition); - } - catch (Exception eInner) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_InvalidIncludeLocation, null, eInner, include.SourceUri, include.LineNumber, include.LinePosition, include), XmlSeverityType.Warning); - } - finally - { - reader.Close(); - } - } - } - else - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_InvalidIncludeLocation, null, innerException, include.SourceUri, include.LineNumber, include.LinePosition, include), XmlSeverityType.Warning); - } - } - else - { //Location already in table and now seeing duplicate import / include - include.Schema = (XmlSchema)_schemaLocations[ruri]; //Set schema object even for duplicates - } - } - } - - - internal static XmlSchema GetBuildInSchema() - { - if (s_builtInSchemaForXmlNS == null) - { - XmlSchema tempSchema = new XmlSchema(); - tempSchema.TargetNamespace = XmlReservedNs.NsXml; - tempSchema.Namespaces.Add("xml", XmlReservedNs.NsXml); - - XmlSchemaAttribute lang = new XmlSchemaAttribute(); - lang.Name = "lang"; - lang.SchemaTypeName = new XmlQualifiedName("language", XmlReservedNs.NsXs); - tempSchema.Items.Add(lang); - - XmlSchemaAttribute xmlbase = new XmlSchemaAttribute(); - xmlbase.Name = "base"; - xmlbase.SchemaTypeName = new XmlQualifiedName("anyURI", XmlReservedNs.NsXs); - tempSchema.Items.Add(xmlbase); - - XmlSchemaAttribute space = new XmlSchemaAttribute(); - space.Name = "space"; - XmlSchemaSimpleType type = new XmlSchemaSimpleType(); - XmlSchemaSimpleTypeRestriction r = new XmlSchemaSimpleTypeRestriction(); - r.BaseTypeName = new XmlQualifiedName("NCName", XmlReservedNs.NsXs); - XmlSchemaEnumerationFacet space_default = new XmlSchemaEnumerationFacet(); - space_default.Value = "default"; - r.Facets.Add(space_default); - XmlSchemaEnumerationFacet space_preserve = new XmlSchemaEnumerationFacet(); - space_preserve.Value = "preserve"; - r.Facets.Add(space_preserve); - type.Content = r; - space.SchemaType = type; - space.DefaultValue = "preserve"; - tempSchema.Items.Add(space); - - XmlSchemaAttributeGroup attributeGroup = new XmlSchemaAttributeGroup(); - attributeGroup.Name = "specialAttrs"; - XmlSchemaAttribute langRef = new XmlSchemaAttribute(); - langRef.RefName = new XmlQualifiedName("lang", XmlReservedNs.NsXml); - attributeGroup.Attributes.Add(langRef); - XmlSchemaAttribute spaceRef = new XmlSchemaAttribute(); - spaceRef.RefName = new XmlQualifiedName("space", XmlReservedNs.NsXml); - attributeGroup.Attributes.Add(spaceRef); - XmlSchemaAttribute baseRef = new XmlSchemaAttribute(); - baseRef.RefName = new XmlQualifiedName("base", XmlReservedNs.NsXml); - attributeGroup.Attributes.Add(baseRef); - tempSchema.Items.Add(attributeGroup); - tempSchema.IsPreprocessed = true; - tempSchema.CompileSchemaInSet(new NameTable(), null, null); //compile built-in schema - - Interlocked.CompareExchange(ref s_builtInSchemaForXmlNS, tempSchema, null); - } - return s_builtInSchemaForXmlNS; - } - - private void BuildRefNamespaces(XmlSchema schema) - { - _referenceNamespaces.Clear(); - XmlSchemaImport import; - string ns; - - //Add XSD namespace - _referenceNamespaces.Add(XmlReservedNs.NsXs, XmlReservedNs.NsXs); - - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - if (include is XmlSchemaImport) - { - import = include as XmlSchemaImport; - ns = import.Namespace; - if (ns == null) - { - ns = string.Empty; - } - if (_referenceNamespaces[ns] == null) - _referenceNamespaces.Add(ns, ns); - } - } - - //Add the schema's targetnamespace - string tns = schema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - if (_referenceNamespaces[tns] == null) - { - _referenceNamespaces.Add(tns, tns); - } - } - - private void ParseUri(string uri, string code, XmlSchemaObject sourceSchemaObject) - { - try - { - XmlConvert.ToUri(uri); // can throw - } - catch (FormatException eInner) - { - SendValidationEvent(code, new string[] { uri }, eInner, sourceSchemaObject); - } - } - - private void Preprocess(XmlSchema schema, string targetNamespace, ArrayList imports) - { - XmlSchema prevRootSchemaForRedefine = null; - if (schema.IsProcessing) - { - return; - } - schema.IsProcessing = true; - - string tns = schema.TargetNamespace; - if (tns != null) - { - schema.TargetNamespace = tns = NameTable.Add(tns); - if (tns.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidTargetNamespaceAttribute, schema); - } - else - { - ParseUri(tns, ResXml.Sch_InvalidNamespace, schema); - } - } - if (schema.Version != null) - { - XmlSchemaDatatype tokenDt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.Token).Datatype; - object version; - Exception exception = tokenDt.TryParseValue(schema.Version, null, null, out version); - if (exception != null) - { - SendValidationEvent(ResXml.Sch_AttributeValueDataTypeDetailed, new string[] { "version", schema.Version, tokenDt.TypeCodeString, exception.Message }, exception, schema); - } - else - { - schema.Version = (string)version; - } - } - - //Begin processing the schema after checking targetNamespace and verifying chameleon - Cleanup(schema); - - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - XmlSchema externalSchema = include.Schema; - SetParent(include, schema); - PreprocessAnnotation(include); - string loc = include.SchemaLocation; - if (loc != null) - { - ParseUri(loc, ResXml.Sch_InvalidSchemaLocation, include); - } - else if ((include.Compositor == Compositor.Include || include.Compositor == Compositor.Redefine) && externalSchema == null) - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "schemaLocation", include); - } - - switch (include.Compositor) - { - case Compositor.Import: - XmlSchemaImport import = include as XmlSchemaImport; - string importNS = import.Namespace; - if (importNS == schema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_ImportTargetNamespace, include); - } - if (externalSchema != null) - { - if (importNS != externalSchema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceImport, importNS, externalSchema.TargetNamespace, import); - } - //SetParent(externalSchema, import); - prevRootSchemaForRedefine = _rootSchemaForRedefine; - _rootSchemaForRedefine = externalSchema; //Make the imported schema the root schema for redefines - Preprocess(externalSchema, importNS, imports); - _rootSchemaForRedefine = prevRootSchemaForRedefine; //Reset the root schema for redefines - } - else - { - if (importNS != null) - { - if (importNS.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidNamespaceAttribute, importNS, include); - } - else - { - ParseUri(importNS, ResXml.Sch_InvalidNamespace, include); - } - } - } - break; - case Compositor.Include: - XmlSchema includedSchema = include.Schema; - if (includedSchema != null) - { - //SetParent(includedSchema, include); - goto default; - } - break; - - case Compositor.Redefine: - if (externalSchema != null) - { - //SetParent(externalSchema, include); - CleanupRedefine(include); - goto default; - } - break; - - default: //For include, redefine common case - if (externalSchema.TargetNamespace != null) - { - if (schema.TargetNamespace != externalSchema.TargetNamespace) - { //namespaces for includes should be the same - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceInclude, externalSchema.TargetNamespace, schema.TargetNamespace, include); - } - } - else if (targetNamespace != null && targetNamespace.Length != 0) - { //Chameleon redefine - externalSchema = GetChameleonSchema(targetNamespace, externalSchema); - include.Schema = externalSchema; //Reset the schema property to the cloned schema - } - Preprocess(externalSchema, schema.TargetNamespace, imports); - break; - } - } - - //Begin processing the current schema passed to preprocess - //Build the namespaces that can be referenced in the current schema - _currentSchema = schema; - BuildRefNamespaces(schema); - ValidateIdAttribute(schema); - - _targetNamespace = targetNamespace == null ? string.Empty : targetNamespace; - - SetSchemaDefaults(schema); - - _processedExternals.Clear(); - XmlSchemaExternal external; - for (int i = 0; i < schema.Includes.Count; i++) - { - external = (XmlSchemaExternal)schema.Includes[i]; - XmlSchema includedSchema = external.Schema; - if (includedSchema != null) - { - switch (external.Compositor) - { - case Compositor.Include: - if (_processedExternals[includedSchema] != null) - { - continue; //Already processed this included schema; TODO Need to look at other option than using HashTable - } - _processedExternals.Add(includedSchema, external); - CopyIncludedComponents(includedSchema, schema); - break; - - case Compositor.Redefine: - if (_redefinedList == null) - { - _redefinedList = new ArrayList(); - } - _redefinedList.Add(new RedefineEntry(external as XmlSchemaRedefine, _rootSchemaForRedefine)); - if (_processedExternals[includedSchema] != null) - { - continue; //Already processed this included schema; TODO Need to look at other option than using HashTable - } - _processedExternals.Add(includedSchema, external); - CopyIncludedComponents(includedSchema, schema); - break; - - case Compositor.Import: - if (includedSchema != _rootSchema) - { - XmlSchemaImport import = external as XmlSchemaImport; - string importNS = import.Namespace != null ? import.Namespace : string.Empty; - if (!imports.Contains(includedSchema)) - { //TODO Change ImportedSchemas to Hashtable - imports.Add(includedSchema); - } - if (!_rootSchema.ImportedNamespaces.Contains(importNS)) - { - _rootSchema.ImportedNamespaces.Add(importNS); - } - } - break; - - default: - Debug.Assert(false); - break; - } - } - else if (external.Compositor == Compositor.Redefine) - { - XmlSchemaRedefine redefine = external as XmlSchemaRedefine; - if (redefine.BaseUri == null) - { - for (int j = 0; j < redefine.Items.Count; ++j) - { - if (!(redefine.Items[j] is XmlSchemaAnnotation)) - { - SendValidationEvent(ResXml.Sch_RedefineNoSchema, redefine); - break; - } - } - } - } - - ValidateIdAttribute(external); - } - - List removeItemsList = new List(); - XmlSchemaObjectCollection schemaItems = schema.Items; - for (int i = 0; i < schemaItems.Count; ++i) - { - SetParent(schemaItems[i], schema); - XmlSchemaAttribute attribute = schemaItems[i] as XmlSchemaAttribute; - if (attribute != null) - { - PreprocessAttribute(attribute); - AddToTable(schema.Attributes, attribute.QualifiedName, attribute); - } - else if (schemaItems[i] is XmlSchemaAttributeGroup) - { - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)schemaItems[i]; - PreprocessAttributeGroup(attributeGroup); - AddToTable(schema.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - } - else if (schemaItems[i] is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaItems[i]; - PreprocessComplexType(complexType, false); - AddToTable(schema.SchemaTypes, complexType.QualifiedName, complexType); - } - else if (schemaItems[i] is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)schemaItems[i]; - PreprocessSimpleType(simpleType, false); - AddToTable(schema.SchemaTypes, simpleType.QualifiedName, simpleType); - } - else if (schemaItems[i] is XmlSchemaElement) - { - XmlSchemaElement element = (XmlSchemaElement)schemaItems[i]; - PreprocessElement(element); - AddToTable(schema.Elements, element.QualifiedName, element); - } - else if (schemaItems[i] is XmlSchemaGroup) - { - XmlSchemaGroup group = (XmlSchemaGroup)schemaItems[i]; - PreprocessGroup(group); - AddToTable(schema.Groups, group.QualifiedName, group); - } - else if (schemaItems[i] is XmlSchemaNotation) - { - XmlSchemaNotation notation = (XmlSchemaNotation)schemaItems[i]; - PreprocessNotation(notation); - AddToTable(schema.Notations, notation.QualifiedName, notation); - } - else if (schemaItems[i] is XmlSchemaAnnotation) - { - PreprocessAnnotation(schemaItems[i] as XmlSchemaAnnotation); - } - else - { - SendValidationEvent(ResXml.Sch_InvalidCollection, (XmlSchemaObject)schemaItems[i]); - removeItemsList.Add(schemaItems[i]); - } - } - - for (int i = 0; i < removeItemsList.Count; ++i) - { - schema.Items.Remove(removeItemsList[i]); - } - } - - private void CopyIncludedComponents(XmlSchema includedSchema, XmlSchema schema) - { - foreach (XmlSchemaElement element in includedSchema.Elements.Values) - { - AddToTable(schema.Elements, element.QualifiedName, element); - } - - foreach (XmlSchemaAttribute attribute in includedSchema.Attributes.Values) - { - AddToTable(schema.Attributes, attribute.QualifiedName, attribute); - } - - foreach (XmlSchemaGroup group in includedSchema.Groups.Values) - { - AddToTable(schema.Groups, group.QualifiedName, group); - } - - foreach (XmlSchemaAttributeGroup attributeGroup in includedSchema.AttributeGroups.Values) - { - AddToTable(schema.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - } - - foreach (XmlSchemaType type in includedSchema.SchemaTypes.Values) - { - AddToTable(schema.SchemaTypes, type.QualifiedName, type); - } - - foreach (XmlSchemaNotation notation in includedSchema.Notations.Values) - { - AddToTable(schema.Notations, notation.QualifiedName, notation); - } - } - - private void PreprocessRedefine(RedefineEntry redefineEntry) - { - XmlSchemaRedefine redefine = redefineEntry.redefine; - XmlSchema originalSchema = redefine.Schema; - - _currentSchema = GetParentSchema(redefine); //Set this for correct schema context in ValidateIdAttribute & ValidateQNameAttribute for redefines - Debug.Assert(_currentSchema != null); - SetSchemaDefaults(_currentSchema); - - if (originalSchema.IsRedefined) - { - SendValidationEvent(ResXml.Sch_MultipleRedefine, redefine, XmlSeverityType.Warning); - return; - } - originalSchema.IsRedefined = true; - - XmlSchema schemaToUpdate = redefineEntry.schemaToUpdate; - ArrayList includesOfRedefine = new ArrayList(); - GetIncludedSet(originalSchema, includesOfRedefine); - string targetNS = schemaToUpdate.TargetNamespace == null ? string.Empty : schemaToUpdate.TargetNamespace; - - XmlSchemaObjectCollection items = redefine.Items; - for (int i = 0; i < items.Count; ++i) - { - SetParent(items[i], redefine); - XmlSchemaGroup group = items[i] as XmlSchemaGroup; - if (group != null) - { - PreprocessGroup(group); - group.QualifiedName.SetNamespace(targetNS); //Since PreprocessGroup will use this.targetNamespace and that will be that of the root schema's - if (redefine.Groups[group.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_GroupDoubleRedefine, group); - } - else - { - AddToTable(redefine.Groups, group.QualifiedName, group); - XmlSchemaGroup originalGroup = (XmlSchemaGroup)schemaToUpdate.Groups[group.QualifiedName]; - XmlSchema parentSchema = GetParentSchema(originalGroup); - if (originalGroup == null || (parentSchema != originalSchema && !includesOfRedefine.Contains(parentSchema))) - { - SendValidationEvent(ResXml.Sch_ComponentRedefineNotFound, "", group.QualifiedName.ToString(), group); - } - else - { - group.Redefined = originalGroup; - schemaToUpdate.Groups.Insert(group.QualifiedName, group); - CheckRefinedGroup(group); - } - } - } - else if (items[i] is XmlSchemaAttributeGroup) - { - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)items[i]; - PreprocessAttributeGroup(attributeGroup); - attributeGroup.QualifiedName.SetNamespace(targetNS); //Since PreprocessAttributeGroup will use this.targetNamespace and that will be that of the root schema's - if (redefine.AttributeGroups[attributeGroup.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_AttrGroupDoubleRedefine, attributeGroup); - } - else - { - AddToTable(redefine.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - XmlSchemaAttributeGroup originalAttrGroup = (XmlSchemaAttributeGroup)schemaToUpdate.AttributeGroups[attributeGroup.QualifiedName]; - XmlSchema parentSchema = GetParentSchema(originalAttrGroup); - if (originalAttrGroup == null || (parentSchema != originalSchema && !includesOfRedefine.Contains(parentSchema))) - { - SendValidationEvent(ResXml.Sch_ComponentRedefineNotFound, "", attributeGroup.QualifiedName.ToString(), attributeGroup); - } - else - { - attributeGroup.Redefined = originalAttrGroup; - schemaToUpdate.AttributeGroups.Insert(attributeGroup.QualifiedName, attributeGroup); - CheckRefinedAttributeGroup(attributeGroup); - } - } - } - else if (items[i] is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)items[i]; - PreprocessComplexType(complexType, false); - complexType.QualifiedName.SetNamespace(targetNS); //Since PreprocessComplexType will use this.targetNamespace and that will be that of the root schema's - if (redefine.SchemaTypes[complexType.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_ComplexTypeDoubleRedefine, complexType); - } - else - { - AddToTable(redefine.SchemaTypes, complexType.QualifiedName, complexType); - XmlSchemaType originalType = (XmlSchemaType)schemaToUpdate.SchemaTypes[complexType.QualifiedName]; - XmlSchema parentSchema = GetParentSchema(originalType); - if (originalType == null || (parentSchema != originalSchema && !includesOfRedefine.Contains(parentSchema))) - { - SendValidationEvent(ResXml.Sch_ComponentRedefineNotFound, "", complexType.QualifiedName.ToString(), complexType); - } - else if (originalType is XmlSchemaComplexType) - { - complexType.Redefined = originalType; - schemaToUpdate.SchemaTypes.Insert(complexType.QualifiedName, complexType); - CheckRefinedComplexType(complexType); - } - else - { - SendValidationEvent(ResXml.Sch_SimpleToComplexTypeRedefine, complexType); - } - } - } - else if (items[i] is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)items[i]; - PreprocessSimpleType(simpleType, false); - simpleType.QualifiedName.SetNamespace(targetNS); //Since PreprocessSimpleType will use this.targetNamespace and that will be that of the root schema's - if (redefine.SchemaTypes[simpleType.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_SimpleTypeDoubleRedefine, simpleType); - } - else - { - AddToTable(redefine.SchemaTypes, simpleType.QualifiedName, simpleType); - XmlSchemaType originalType = (XmlSchemaType)schemaToUpdate.SchemaTypes[simpleType.QualifiedName]; - XmlSchema parentSchema = GetParentSchema(originalType); - if (originalType == null || (parentSchema != originalSchema && !includesOfRedefine.Contains(parentSchema))) - { - SendValidationEvent(ResXml.Sch_ComponentRedefineNotFound, "", simpleType.QualifiedName.ToString(), simpleType); - } - else if (originalType is XmlSchemaSimpleType) - { - simpleType.Redefined = originalType; - schemaToUpdate.SchemaTypes.Insert(simpleType.QualifiedName, simpleType); - CheckRefinedSimpleType(simpleType); - } - else - { - SendValidationEvent(ResXml.Sch_ComplexToSimpleTypeRedefine, simpleType); - } - } - } - } - } - - private void GetIncludedSet(XmlSchema schema, ArrayList includesList) - { - if (includesList.Contains(schema)) - { - return; - } - includesList.Add(schema); - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal external = (XmlSchemaExternal)schema.Includes[i]; - if (external.Compositor == Compositor.Include || external.Compositor == Compositor.Redefine) - { - if (external.Schema != null) - { - GetIncludedSet(external.Schema, includesList); - } - } - } - } - - internal static XmlSchema GetParentSchema(XmlSchemaObject currentSchemaObject) - { - XmlSchema parentSchema = null; - Debug.Assert((currentSchemaObject as XmlSchema) == null); //The current object should not be schema - while (parentSchema == null && currentSchemaObject != null) - { - currentSchemaObject = currentSchemaObject.Parent; - parentSchema = currentSchemaObject as XmlSchema; - } - return parentSchema; - } - - private void SetSchemaDefaults(XmlSchema schema) - { - if (schema.BlockDefault == XmlSchemaDerivationMethod.All) - { - _blockDefault = XmlSchemaDerivationMethod.All; - } - else if (schema.BlockDefault == XmlSchemaDerivationMethod.None) - { - _blockDefault = XmlSchemaDerivationMethod.Empty; - } - else - { - if ((schema.BlockDefault & ~schemaBlockDefaultAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidBlockDefaultValue, schema); - } - _blockDefault = schema.BlockDefault & schemaBlockDefaultAllowed; - } - if (schema.FinalDefault == XmlSchemaDerivationMethod.All) - { - _finalDefault = XmlSchemaDerivationMethod.All; - } - else if (schema.FinalDefault == XmlSchemaDerivationMethod.None) - { - _finalDefault = XmlSchemaDerivationMethod.Empty; - } - else - { - if ((schema.FinalDefault & ~schemaFinalDefaultAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidFinalDefaultValue, schema); - } - _finalDefault = schema.FinalDefault & schemaFinalDefaultAllowed; - } - _elementFormDefault = schema.ElementFormDefault; - if (_elementFormDefault == XmlSchemaForm.None) - { - _elementFormDefault = XmlSchemaForm.Unqualified; - } - _attributeFormDefault = schema.AttributeFormDefault; - if (_attributeFormDefault == XmlSchemaForm.None) - { - _attributeFormDefault = XmlSchemaForm.Unqualified; - } - } - - private int CountGroupSelfReference(XmlSchemaObjectCollection items, XmlQualifiedName name, XmlSchemaGroup redefined) - { - int count = 0; - for (int i = 0; i < items.Count; ++i) - { - XmlSchemaGroupRef groupRef = items[i] as XmlSchemaGroupRef; - if (groupRef != null) - { - if (groupRef.RefName == name) - { - groupRef.Redefined = redefined; - if (groupRef.MinOccurs != decimal.One || groupRef.MaxOccurs != decimal.One) - { - SendValidationEvent(ResXml.Sch_MinMaxGroupRedefine, groupRef); - } - count++; - } - } - else if (items[i] is XmlSchemaGroupBase) - { - count += CountGroupSelfReference(((XmlSchemaGroupBase)items[i]).Items, name, redefined); - } - if (count > 1) - { - break; - } - } - return count; - } - - private void CheckRefinedGroup(XmlSchemaGroup group) - { - int count = 0; - if (group.Particle != null) - { - count = CountGroupSelfReference(group.Particle.Items, group.QualifiedName, group.Redefined); - } - if (count > 1) - { - SendValidationEvent(ResXml.Sch_MultipleGroupSelfRef, group); - } - group.SelfReferenceCount = count; - } - - private void CheckRefinedAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - int count = 0; - for (int i = 0; i < attributeGroup.Attributes.Count; ++i) - { - XmlSchemaAttributeGroupRef attrGroupRef = attributeGroup.Attributes[i] as XmlSchemaAttributeGroupRef; - if (attrGroupRef != null && attrGroupRef.RefName == attributeGroup.QualifiedName) - { - count++; - } - } - if (count > 1) - { - SendValidationEvent(ResXml.Sch_MultipleAttrGroupSelfRef, attributeGroup); - } - attributeGroup.SelfReferenceCount = count; - } - - private void CheckRefinedSimpleType(XmlSchemaSimpleType stype) - { - if (stype.Content != null && stype.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)stype.Content; - if (restriction.BaseTypeName == stype.QualifiedName) - { - return; - } - } - SendValidationEvent(ResXml.Sch_InvalidTypeRedefine, stype); - } - - private void CheckRefinedComplexType(XmlSchemaComplexType ctype) - { - if (ctype.ContentModel != null) - { - XmlQualifiedName baseName; - if (ctype.ContentModel is XmlSchemaComplexContent) - { - XmlSchemaComplexContent content = (XmlSchemaComplexContent)ctype.ContentModel; - if (content.Content is XmlSchemaComplexContentRestriction) - { - baseName = ((XmlSchemaComplexContentRestriction)content.Content).BaseTypeName; - } - else - { - baseName = ((XmlSchemaComplexContentExtension)content.Content).BaseTypeName; - } - } - else - { - XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)ctype.ContentModel; - if (content.Content is XmlSchemaSimpleContentRestriction) - { - baseName = ((XmlSchemaSimpleContentRestriction)content.Content).BaseTypeName; - } - else - { - baseName = ((XmlSchemaSimpleContentExtension)content.Content).BaseTypeName; - } - } - if (baseName == ctype.QualifiedName) - { - return; - } - } - SendValidationEvent(ResXml.Sch_InvalidTypeRedefine, ctype); - } - - private void PreprocessAttribute(XmlSchemaAttribute attribute) - { - if (attribute.Name != null) - { - ValidateNameAttribute(attribute); - attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", attribute); - } - if (attribute.Use != XmlSchemaUse.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "use", attribute); - } - if (attribute.Form != XmlSchemaForm.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "form", attribute); - } - PreprocessAttributeContent(attribute); - ValidateIdAttribute(attribute); - } - - private void PreprocessLocalAttribute(XmlSchemaAttribute attribute) - { - if (attribute.Name != null) - { // name - ValidateNameAttribute(attribute); - PreprocessAttributeContent(attribute); - attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, (attribute.Form == XmlSchemaForm.Qualified || (attribute.Form == XmlSchemaForm.None && _attributeFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null)); - } - else - { // ref - PreprocessAnnotation(attribute); //set parent of annotation child of ref - if (attribute.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_AttributeNameRef, "???", attribute); - } - else - { - ValidateQNameAttribute(attribute, "ref", attribute.RefName); - } - if (!attribute.SchemaTypeName.IsEmpty || - attribute.SchemaType != null || - attribute.Form != XmlSchemaForm.None /*|| - attribute.DefaultValue != null || - attribute.FixedValue != null*/ - ) - { - SendValidationEvent(ResXml.Sch_InvalidAttributeRef, attribute); - } - attribute.SetQualifiedName(attribute.RefName); - } - ValidateIdAttribute(attribute); - } - - private void PreprocessAttributeContent(XmlSchemaAttribute attribute) - { - PreprocessAnnotation(attribute); - - if (Ref.Equal(_currentSchema.TargetNamespace, _nsXsi)) - { - SendValidationEvent(ResXml.Sch_TargetNamespaceXsi, attribute); - } - - if (!attribute.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "ref", attribute); - } - if (attribute.DefaultValue != null && attribute.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, attribute); - } - if (attribute.DefaultValue != null && attribute.Use != XmlSchemaUse.Optional && attribute.Use != XmlSchemaUse.None) - { - SendValidationEvent(ResXml.Sch_OptionalDefaultAttribute, attribute); - } - if (attribute.Name == _xmlns) - { - SendValidationEvent(ResXml.Sch_XmlNsAttribute, attribute); - } - if (attribute.SchemaType != null) - { - SetParent(attribute.SchemaType, attribute); - if (!attribute.SchemaTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_TypeMutualExclusive, attribute); - } - PreprocessSimpleType(attribute.SchemaType, true); - } - if (!attribute.SchemaTypeName.IsEmpty) - { - ValidateQNameAttribute(attribute, "type", attribute.SchemaTypeName); - } - } - - private void PreprocessAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - if (attributeGroup.Name != null) - { - ValidateNameAttribute(attributeGroup); - attributeGroup.SetQualifiedName(new XmlQualifiedName(attributeGroup.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", attributeGroup); - } - PreprocessAttributes(attributeGroup.Attributes, attributeGroup.AnyAttribute, attributeGroup); - PreprocessAnnotation(attributeGroup); - ValidateIdAttribute(attributeGroup); - } - - private void PreprocessElement(XmlSchemaElement element) - { - if (element.Name != null) - { - ValidateNameAttribute(element); - element.SetQualifiedName(new XmlQualifiedName(element.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", element); - } - PreprocessElementContent(element); - - if (element.Final == XmlSchemaDerivationMethod.All) - { - element.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (element.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - element.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - element.SetFinalResolved(_finalDefault & elementFinalAllowed); - } - } - else - { - if ((element.Final & ~elementFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidElementFinalValue, element); - } - element.SetFinalResolved(element.Final & elementFinalAllowed); - } - if (element.Form != XmlSchemaForm.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "form", element); - } - if (element.MinOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "minOccurs", element); - } - if (element.MaxOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "maxOccurs", element); - } - if (!element.SubstitutionGroup.IsEmpty) - { - ValidateQNameAttribute(element, "type", element.SubstitutionGroup); - } - ValidateIdAttribute(element); - } - - private void PreprocessLocalElement(XmlSchemaElement element) - { - if (element.Name != null) - { // name - ValidateNameAttribute(element); - PreprocessElementContent(element); - element.SetQualifiedName(new XmlQualifiedName(element.Name, (element.Form == XmlSchemaForm.Qualified || (element.Form == XmlSchemaForm.None && _elementFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null)); - } - else - { // ref - PreprocessAnnotation(element); //Check annotation child for ref and set parent - if (element.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ElementNameRef, element); - } - else - { - ValidateQNameAttribute(element, "ref", element.RefName); - } - if (!element.SchemaTypeName.IsEmpty || - element.HasAbstractAttribute || - element.Block != XmlSchemaDerivationMethod.None || - element.SchemaType != null || - element.HasConstraints || - element.DefaultValue != null || - element.Form != XmlSchemaForm.None || - element.FixedValue != null || - element.HasNillableAttribute) - { - SendValidationEvent(ResXml.Sch_InvalidElementRef, element); - } - if (element.DefaultValue != null && element.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, element); - } - element.SetQualifiedName(element.RefName); - } - if (element.MinOccurs > element.MaxOccurs) - { - element.MinOccurs = decimal.Zero; - SendValidationEvent(ResXml.Sch_MinGtMax, element); - } - if (element.HasAbstractAttribute) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "abstract", element); - } - if (element.Final != XmlSchemaDerivationMethod.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "final", element); - } - if (!element.SubstitutionGroup.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "substitutionGroup", element); - } - ValidateIdAttribute(element); - } - - private void PreprocessElementContent(XmlSchemaElement element) - { - PreprocessAnnotation(element); //Set parent for Annotation child of element - if (!element.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "ref", element); - } - if (element.Block == XmlSchemaDerivationMethod.All) - { - element.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else if (element.Block == XmlSchemaDerivationMethod.None) - { - if (_blockDefault == XmlSchemaDerivationMethod.All) - { - element.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else - { - element.SetBlockResolved(_blockDefault & elementBlockAllowed); - } - } - else - { - if ((element.Block & ~elementBlockAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidElementBlockValue, element); - } - element.SetBlockResolved(element.Block & elementBlockAllowed); - } - if (element.SchemaType != null) - { - SetParent(element.SchemaType, element); //Set parent for simple / complex type child of element - if (!element.SchemaTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_TypeMutualExclusive, element); - } - if (element.SchemaType is XmlSchemaComplexType) - { - PreprocessComplexType((XmlSchemaComplexType)element.SchemaType, true); - } - else - { - PreprocessSimpleType((XmlSchemaSimpleType)element.SchemaType, true); - } - } - if (!element.SchemaTypeName.IsEmpty) - { - ValidateQNameAttribute(element, "type", element.SchemaTypeName); - } - if (element.DefaultValue != null && element.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, element); - } - - for (int i = 0; i < element.Constraints.Count; ++i) - { - XmlSchemaIdentityConstraint identityConstraint = (XmlSchemaIdentityConstraint)element.Constraints[i]; - SetParent(identityConstraint, element); - PreprocessIdentityConstraint(identityConstraint); - } - } - - private void PreprocessIdentityConstraint(XmlSchemaIdentityConstraint constraint) - { - bool valid = true; - PreprocessAnnotation(constraint); //Set parent of annotation child of key/keyref/unique - if (constraint.Name != null) - { - ValidateNameAttribute(constraint); - constraint.SetQualifiedName(new XmlQualifiedName(constraint.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", constraint); - valid = false; - } - - if (_rootSchema.IdentityConstraints[constraint.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_DupIdentityConstraint, constraint.QualifiedName.ToString(), constraint); - valid = false; - } - else - { - _rootSchema.IdentityConstraints.Add(constraint.QualifiedName, constraint); - } - - if (constraint.Selector == null) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoSelector, constraint); - valid = false; - } - if (constraint.Fields.Count == 0) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoFields, constraint); - valid = false; - } - if (constraint is XmlSchemaKeyref) - { - XmlSchemaKeyref keyref = (XmlSchemaKeyref)constraint; - if (keyref.Refer.IsEmpty) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoRefer, constraint); - valid = false; - } - else - { - ValidateQNameAttribute(keyref, "refer", keyref.Refer); - } - } - if (valid) - { - ValidateIdAttribute(constraint); - ValidateIdAttribute(constraint.Selector); - SetParent(constraint.Selector, constraint); - for (int i = 0; i < constraint.Fields.Count; ++i) - { - SetParent(constraint.Fields[i], constraint); - ValidateIdAttribute(constraint.Fields[i]); - } - } - } - - private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local) - { - if (local) - { - if (simpleType.Name != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "name", simpleType); - } - } - else - { - if (simpleType.Name != null) - { - ValidateNameAttribute(simpleType); - simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", simpleType); - } - - if (simpleType.Final == XmlSchemaDerivationMethod.All) - { - simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (simpleType.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - simpleType.SetFinalResolved(_finalDefault & simpleTypeFinalAllowed); - } - } - else - { - if ((simpleType.Final & ~simpleTypeFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidSimpleTypeFinalValue, simpleType); - } - simpleType.SetFinalResolved(simpleType.Final & simpleTypeFinalAllowed); - } - } - - if (simpleType.Content == null) - { - SendValidationEvent(ResXml.Sch_NoSimpleTypeContent, simpleType); - } - else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; - //SetParent - SetParent(restriction, simpleType); - for (int i = 0; i < restriction.Facets.Count; ++i) - { - SetParent(restriction.Facets[i], restriction); - } - - if (restriction.BaseType != null) - { - if (!restriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeRestRefBase, restriction); - } - PreprocessSimpleType(restriction.BaseType, true); - } - else - { - if (restriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeRestRefBaseNone, restriction); - } - else - { - ValidateQNameAttribute(restriction, "base", restriction.BaseTypeName); - } - } - PreprocessAnnotation(restriction); //set parent of annotation child of simple type restriction - ValidateIdAttribute(restriction); - } - else if (simpleType.Content is XmlSchemaSimpleTypeList) - { - XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; - SetParent(list, simpleType); - - if (list.ItemType != null) - { - if (!list.ItemTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeListRefBase, list); - } - SetParent(list.ItemType, list); - PreprocessSimpleType(list.ItemType, true); - } - else - { - if (list.ItemTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeListRefBaseNone, list); - } - else - { - ValidateQNameAttribute(list, "itemType", list.ItemTypeName); - } - } - PreprocessAnnotation(list); //set parent of annotation child of simple type list - ValidateIdAttribute(list); - } - else - { // union - XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content; - SetParent(union1, simpleType); - - int baseTypeCount = union1.BaseTypes.Count; - if (union1.MemberTypes != null) - { - baseTypeCount += union1.MemberTypes.Length; - XmlQualifiedName[] qNames = union1.MemberTypes; - for (int i = 0; i < qNames.Length; ++i) - { - ValidateQNameAttribute(union1, "memberTypes", qNames[i]); - } - } - if (baseTypeCount == 0) - { - SendValidationEvent(ResXml.Sch_SimpleTypeUnionNoBase, union1); - } - for (int i = 0; i < union1.BaseTypes.Count; ++i) - { - XmlSchemaSimpleType type = (XmlSchemaSimpleType)union1.BaseTypes[i]; - SetParent(type, union1); - PreprocessSimpleType(type, true); - } - PreprocessAnnotation(union1); //set parent of annotation child of simple type union - ValidateIdAttribute(union1); - } - ValidateIdAttribute(simpleType); - } - - private void PreprocessComplexType(XmlSchemaComplexType complexType, bool local) - { - if (local) - { - if (complexType.Name != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "name", complexType); - } - } - else - { - if (complexType.Name != null) - { - ValidateNameAttribute(complexType); - complexType.SetQualifiedName(new XmlQualifiedName(complexType.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", complexType); - } - if (complexType.Block == XmlSchemaDerivationMethod.All) - { - complexType.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else if (complexType.Block == XmlSchemaDerivationMethod.None) - { - complexType.SetBlockResolved(_blockDefault & complexTypeBlockAllowed); - } - else - { - if ((complexType.Block & ~complexTypeBlockAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidComplexTypeBlockValue, complexType); - } - complexType.SetBlockResolved(complexType.Block & complexTypeBlockAllowed); - } - if (complexType.Final == XmlSchemaDerivationMethod.All) - { - complexType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (complexType.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - complexType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - complexType.SetFinalResolved(_finalDefault & complexTypeFinalAllowed); - } - } - else - { - if ((complexType.Final & ~complexTypeFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidComplexTypeFinalValue, complexType); - } - complexType.SetFinalResolved(complexType.Final & complexTypeFinalAllowed); - } - } - - if (complexType.ContentModel != null) - { - SetParent(complexType.ContentModel, complexType); //SimpleContent / complexCotent - PreprocessAnnotation(complexType.ContentModel); - - if (complexType.Particle != null || complexType.Attributes != null) - { - // this is illigal - } - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)complexType.ContentModel; - if (content.Content == null) - { - if (complexType.QualifiedName == XmlQualifiedName.Empty) - { - SendValidationEvent(ResXml.Sch_NoRestOrExt, complexType); - } - else - { - SendValidationEvent(ResXml.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType); - } - } - else - { - SetParent(content.Content, content); //simplecontent extension / restriction - PreprocessAnnotation(content.Content); //annotation child of simple extension / restriction - - if (content.Content is XmlSchemaSimpleContentExtension) - { - XmlSchemaSimpleContentExtension contentExtension = (XmlSchemaSimpleContentExtension)content.Content; - if (contentExtension.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentExtension); - } - else - { - ValidateQNameAttribute(contentExtension, "base", contentExtension.BaseTypeName); - } - PreprocessAttributes(contentExtension.Attributes, contentExtension.AnyAttribute, contentExtension); - ValidateIdAttribute(contentExtension); - } - else - { //XmlSchemaSimpleContentRestriction - XmlSchemaSimpleContentRestriction contentRestriction = (XmlSchemaSimpleContentRestriction)content.Content; - if (contentRestriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentRestriction); - } - else - { - ValidateQNameAttribute(contentRestriction, "base", contentRestriction.BaseTypeName); - } - if (contentRestriction.BaseType != null) - { - SetParent(contentRestriction.BaseType, contentRestriction); - PreprocessSimpleType(contentRestriction.BaseType, true); - } - PreprocessAttributes(contentRestriction.Attributes, contentRestriction.AnyAttribute, contentRestriction); - ValidateIdAttribute(contentRestriction); - } - } - ValidateIdAttribute(content); - } - else - { // XmlSchemaComplexContent - XmlSchemaComplexContent content = (XmlSchemaComplexContent)complexType.ContentModel; - if (content.Content == null) - { - if (complexType.QualifiedName == XmlQualifiedName.Empty) - { - SendValidationEvent(ResXml.Sch_NoRestOrExt, complexType); - } - else - { - SendValidationEvent(ResXml.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType); - } - } - else - { - if (!content.HasMixedAttribute && complexType.IsMixed) - { - content.IsMixed = true; // fixup - } - SetParent(content.Content, content); //complexcontent extension / restriction - PreprocessAnnotation(content.Content); //Annotation child of extension / restriction - - if (content.Content is XmlSchemaComplexContentExtension) - { - XmlSchemaComplexContentExtension contentExtension = (XmlSchemaComplexContentExtension)content.Content; - if (contentExtension.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentExtension); - } - else - { - ValidateQNameAttribute(contentExtension, "base", contentExtension.BaseTypeName); - } - if (contentExtension.Particle != null) - { - SetParent(contentExtension.Particle, contentExtension); //Group / all / choice / sequence - PreprocessParticle(contentExtension.Particle); - } - PreprocessAttributes(contentExtension.Attributes, contentExtension.AnyAttribute, contentExtension); - ValidateIdAttribute(contentExtension); - } - else - { // XmlSchemaComplexContentRestriction - XmlSchemaComplexContentRestriction contentRestriction = (XmlSchemaComplexContentRestriction)content.Content; - if (contentRestriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentRestriction); - } - else - { - ValidateQNameAttribute(contentRestriction, "base", contentRestriction.BaseTypeName); - } - if (contentRestriction.Particle != null) - { - SetParent(contentRestriction.Particle, contentRestriction); //Group / all / choice / sequence - PreprocessParticle(contentRestriction.Particle); - } - PreprocessAttributes(contentRestriction.Attributes, contentRestriction.AnyAttribute, contentRestriction); - ValidateIdAttribute(contentRestriction); - } - ValidateIdAttribute(content); - } - } - } - else - { - if (complexType.Particle != null) - { - SetParent(complexType.Particle, complexType); - PreprocessParticle(complexType.Particle); - } - PreprocessAttributes(complexType.Attributes, complexType.AnyAttribute, complexType); - } - ValidateIdAttribute(complexType); - } - - private void PreprocessGroup(XmlSchemaGroup group) - { - if (group.Name != null) - { - ValidateNameAttribute(group); - group.SetQualifiedName(new XmlQualifiedName(group.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", group); - } - if (group.Particle == null) - { - SendValidationEvent(ResXml.Sch_NoGroupParticle, group); - return; - } - if (group.Particle.MinOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "minOccurs", group.Particle); - } - if (group.Particle.MaxOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "maxOccurs", group.Particle); - } - - PreprocessParticle(group.Particle); - PreprocessAnnotation(group); //Set parent of annotation child of group - ValidateIdAttribute(group); - } - - private void PreprocessNotation(XmlSchemaNotation notation) - { - if (notation.Name != null) - { - ValidateNameAttribute(notation); - notation.QualifiedName = new XmlQualifiedName(notation.Name, _targetNamespace); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", notation); - } - if (notation.Public == null && notation.System == null) - { - SendValidationEvent(ResXml.Sch_MissingPublicSystemAttribute, notation); - } - else - { - if (notation.Public != null) - { - try - { - XmlConvert.VerifyTOKEN(notation.Public); // can throw - } - catch (XmlException eInner) - { - SendValidationEvent(ResXml.Sch_InvalidPublicAttribute, new string[] { notation.Public }, eInner, notation); - } - } - if (notation.System != null) - { - ParseUri(notation.System, ResXml.Sch_InvalidSystemAttribute, notation); - } - } - PreprocessAnnotation(notation); //Set parent of annotation child of notation - ValidateIdAttribute(notation); - } - - - private void PreprocessParticle(XmlSchemaParticle particle) - { - XmlSchemaObjectCollection items; - if (particle is XmlSchemaAll) - { - if (particle.MinOccurs != decimal.Zero && particle.MinOccurs != decimal.One) - { - particle.MinOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllMin, particle); - } - if (particle.MaxOccurs != decimal.One) - { - particle.MaxOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllMax, particle); - } - items = ((XmlSchemaAll)particle).Items; - for (int i = 0; i < items.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)items[i]; - if (element.MaxOccurs != decimal.Zero && element.MaxOccurs != decimal.One) - { - element.MaxOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllElementMax, element); - } - SetParent(element, particle); - PreprocessLocalElement(element); - } - } - else - { - if (particle.MinOccurs > particle.MaxOccurs) - { - particle.MinOccurs = particle.MaxOccurs; - SendValidationEvent(ResXml.Sch_MinGtMax, particle); - } - if (particle is XmlSchemaChoice) - { - items = ((XmlSchemaChoice)particle).Items; - for (int i = 0; i < items.Count; ++i) - { - SetParent(items[i], particle); - XmlSchemaElement element = items[i] as XmlSchemaElement; - if (element != null) - { - PreprocessLocalElement(element); - } - else - { - PreprocessParticle((XmlSchemaParticle)items[i]); - } - } - } - else if (particle is XmlSchemaSequence) - { - items = ((XmlSchemaSequence)particle).Items; - for (int i = 0; i < items.Count; ++i) - { - SetParent(items[i], particle); - XmlSchemaElement element = items[i] as XmlSchemaElement; - if (element != null) - { - PreprocessLocalElement(element); - } - else - { - PreprocessParticle((XmlSchemaParticle)items[i]); - } - } - } - else if (particle is XmlSchemaGroupRef) - { - XmlSchemaGroupRef groupRef = (XmlSchemaGroupRef)particle; - if (groupRef.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "ref", groupRef); - } - else - { - ValidateQNameAttribute(groupRef, "ref", groupRef.RefName); - } - } - else if (particle is XmlSchemaAny) - { - try - { - ((XmlSchemaAny)particle).BuildNamespaceList(_targetNamespace); - } - catch (FormatException fe) - { - SendValidationEvent(ResXml.Sch_InvalidAnyDetailed, new string[] { fe.Message }, fe, particle); - } - } - } - PreprocessAnnotation(particle); //set parent of annotation child of group / all/ choice / sequence - ValidateIdAttribute(particle); - } - - private void PreprocessAttributes(XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaObject parent) - { - for (int i = 0; i < attributes.Count; ++i) - { - SetParent(attributes[i], parent); - XmlSchemaAttribute attr = attributes[i] as XmlSchemaAttribute; - if (attr != null) - { - PreprocessLocalAttribute(attr); - } - else - { // XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributes[i]; - if (attributeGroupRef.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "ref", attributeGroupRef); - } - else - { - ValidateQNameAttribute(attributeGroupRef, "ref", attributeGroupRef.RefName); - } - PreprocessAnnotation(attributes[i]); //set parent of annotation child of attributeGroupRef - ValidateIdAttribute(attributes[i]); - } - } - if (anyAttribute != null) - { - try - { - SetParent(anyAttribute, parent); - PreprocessAnnotation(anyAttribute); //set parent of annotation child of any attribute - anyAttribute.BuildNamespaceList(_targetNamespace); - } - catch (FormatException fe) - { - SendValidationEvent(ResXml.Sch_InvalidAnyDetailed, new string[] { fe.Message }, fe, anyAttribute); - } - ValidateIdAttribute(anyAttribute); - } - } - - private void ValidateIdAttribute(XmlSchemaObject xso) - { - if (xso.IdAttribute != null) - { - try - { - xso.IdAttribute = NameTable.Add(XmlConvert.VerifyNCName(xso.IdAttribute)); - } - catch (XmlException ex) - { - SendValidationEvent(ResXml.Sch_InvalidIdAttribute, new string[] { ex.Message }, ex, xso); - return; - } - catch (ArgumentNullException) - { - SendValidationEvent(ResXml.Sch_InvalidIdAttribute, ResXml.Sch_NullValue, xso); - return; - } - try - { - _currentSchema.Ids.Add(xso.IdAttribute, xso); - } - catch (ArgumentException) - { - SendValidationEvent(ResXml.Sch_DupIdAttribute, xso); - } - } - } - - private void ValidateNameAttribute(XmlSchemaObject xso) - { - string name = xso.NameAttribute; - if (name == null || name.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidNameAttributeEx, null, ResXml.Sch_NullValue, xso); - } - //Normalize whitespace since NCName has whitespace facet="collapse" - name = XmlComplianceUtil.NonCDataNormalize(name); - int len = ValidateNames.ParseNCName(name, 0); - if (len != name.Length) - { // If the string is not a valid NCName, then throw or return false - string[] invCharArgs = XmlException.BuildCharExceptionArgs(name, len); - string innerStr = string.Format(ResXml.Xml_BadNameCharWithPos, invCharArgs[0], invCharArgs[1], len); - SendValidationEvent(ResXml.Sch_InvalidNameAttributeEx, name, innerStr, xso); - } - else - { - xso.NameAttribute = NameTable.Add(name); - } - } - - private void ValidateQNameAttribute(XmlSchemaObject xso, string attributeName, XmlQualifiedName value) - { - try - { - value.Verify(); - value.Atomize(NameTable); - if (_currentSchema.IsChameleon && value.Namespace.Length == 0) - { - value.SetNamespace(_currentSchema.TargetNamespace); //chameleon schemas are clones that have correct targetNamespace set - } - if (_referenceNamespaces[value.Namespace] == null) - { - SendValidationEvent(ResXml.Sch_UnrefNS, value.Namespace, xso, XmlSeverityType.Warning); - } - } - catch (FormatException fx) - { - SendValidationEvent(ResXml.Sch_InvalidAttribute, new string[] { attributeName, fx.Message }, fx, xso); - } - catch (XmlException ex) - { - SendValidationEvent(ResXml.Sch_InvalidAttribute, new string[] { attributeName, ex.Message }, ex, xso); - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private Uri ResolveSchemaLocationUri(XmlSchema enclosingSchema, string location) - { - if (location.Length == 0) - { - return null; - } - return _xmlResolver.ResolveUri(enclosingSchema.BaseUri, location); - } - - private object GetSchemaEntity(Uri ruri) - { - return _xmlResolver.GetEntity(ruri, null, null); - } - - private XmlSchema GetChameleonSchema(string targetNamespace, XmlSchema schema) - { - ChameleonKey cKey = new ChameleonKey(targetNamespace, schema); - XmlSchema chameleonSchema = (XmlSchema)_chameleonSchemas[cKey]; //Need not clone if a schema for that namespace already exists - if (chameleonSchema == null) - { - chameleonSchema = schema.DeepClone(); //It is ok that we dont lock the clone since no one else has access to it yet - chameleonSchema.IsChameleon = true; - chameleonSchema.TargetNamespace = targetNamespace; - _chameleonSchemas.Add(cKey, chameleonSchema); - chameleonSchema.SourceUri = schema.SourceUri; - //Handle the original schema that was added to lockList before cloning occurred - schema.IsProcessing = false; //Since we cloned it for the chameleon - } - return chameleonSchema; - } - - private void SetParent(XmlSchemaObject child, XmlSchemaObject parent) - { - child.Parent = parent; - } - - private void PreprocessAnnotation(XmlSchemaObject schemaObject) - { - XmlSchemaAnnotation annotation; - if (schemaObject is XmlSchemaAnnotated) - { - XmlSchemaAnnotated annotated = schemaObject as XmlSchemaAnnotated; - annotation = annotated.Annotation; - if (annotation != null) - { - PreprocessAnnotation(annotation); - annotation.Parent = schemaObject; - } - } - } - - private void PreprocessAnnotation(XmlSchemaAnnotation annotation) - { - ValidateIdAttribute(annotation); - for (int i = 0; i < annotation.Items.Count; ++i) - { - annotation.Items[i].Parent = annotation; //Can be documentation or appInfo - } - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaAttDef.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaAttDef.cs deleted file mode 100644 index 0f9167956a8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaAttDef.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Diagnostics; - using System.Collections.Generic; - - /* - * This class describes an attribute type and potential values. - * This encapsulates the information for one Attdef * in an - * Attlist in a DTD as described below: - */ - internal sealed class SchemaAttDef : SchemaDeclBase, IDtdDefaultAttributeInfo - { - internal enum Reserve - { - None, - XmlSpace, - XmlLang - }; - - private String _defExpanded; // default value in its expanded form - - private int _lineNum; - private int _linePos; - private int _valueLineNum; - private int _valueLinePos; - - private Reserve _reserved = Reserve.None; // indicate the attribute type, such as xml:lang or xml:space - - - private bool _defaultValueChecked = false; - private bool _hasEntityRef; // whether there is any entity reference in the default value - private XmlSchemaAttribute _schemaAttribute; - - public static readonly SchemaAttDef Empty = new SchemaAttDef(); - - // - // Constructors - // - public SchemaAttDef(XmlQualifiedName name, String prefix) - : base(name, prefix) - { - } - - public SchemaAttDef(XmlQualifiedName name) : base(name, null) - { - } - private SchemaAttDef() { } - - // - // IDtdAttributeInfo interface - // - #region IDtdAttributeInfo Members - string IDtdAttributeInfo.Prefix - { - get { return ((SchemaAttDef)this).Prefix; } - } - - string IDtdAttributeInfo.LocalName - { - get { return ((SchemaAttDef)this).Name.Name; } - } - - int IDtdAttributeInfo.LineNumber - { - get { return ((SchemaAttDef)this).LineNumber; } - } - - int IDtdAttributeInfo.LinePosition - { - get { return ((SchemaAttDef)this).LinePosition; } - } - - bool IDtdAttributeInfo.IsNonCDataType - { - get { return this.TokenizedType != XmlTokenizedType.CDATA; } - } - - bool IDtdAttributeInfo.IsDeclaredInExternal - { - get { return ((SchemaAttDef)this).IsDeclaredInExternal; } - } - - bool IDtdAttributeInfo.IsXmlAttribute - { - get { return this.Reserved != SchemaAttDef.Reserve.None; } - } - - #endregion - - // - // IDtdDefaultAttributeInfo interface - // - #region IDtdDefaultAttributeInfo Members - string IDtdDefaultAttributeInfo.DefaultValueExpanded - { - get { return ((SchemaAttDef)this).DefaultValueExpanded; } - } - - object IDtdDefaultAttributeInfo.DefaultValueTyped - { - get { return ((SchemaAttDef)this).DefaultValueTyped; } - } - - int IDtdDefaultAttributeInfo.ValueLineNumber - { - get { return ((SchemaAttDef)this).ValueLineNumber; } - } - - int IDtdDefaultAttributeInfo.ValueLinePosition - { - get { return ((SchemaAttDef)this).ValueLinePosition; } - } - #endregion - - // - // Internal properties - // - internal int LinePosition - { - get { return _linePos; } - set { _linePos = value; } - } - - internal int LineNumber - { - get { return _lineNum; } - set { _lineNum = value; } - } - - internal int ValueLinePosition - { - get { return _valueLinePos; } - set { _valueLinePos = value; } - } - - internal int ValueLineNumber - { - get { return _valueLineNum; } - set { _valueLineNum = value; } - } - - internal String DefaultValueExpanded - { - get { return (_defExpanded != null) ? _defExpanded : String.Empty; } - set { _defExpanded = value; } - } - - internal XmlTokenizedType TokenizedType - { - get - { - return Datatype.TokenizedType; - } - set - { - this.Datatype = XmlSchemaDatatype.FromXmlTokenizedType(value); - } - } - - internal Reserve Reserved - { - get { return _reserved; } - set { _reserved = value; } - } - - internal bool DefaultValueChecked - { - get - { - return _defaultValueChecked; - } - } - - internal bool HasEntityRef - { - get { return _hasEntityRef; } - set { _hasEntityRef = value; } - } - - internal XmlSchemaAttribute SchemaAttribute - { - get { return _schemaAttribute; } - set { _schemaAttribute = value; } - } - - internal void CheckXmlSpace(IValidationEventHandling validationEventHandling) - { - if (datatype.TokenizedType == XmlTokenizedType.ENUMERATION && - (values != null) && - (values.Count <= 2)) - { - String s1 = values[0].ToString(); - - if (values.Count == 2) - { - String s2 = values[1].ToString(); - - if ((s1 == "default" || s2 == "default") && - (s1 == "preserve" || s2 == "preserve")) - { - return; - } - } - else - { - if (s1 == "default" || s1 == "preserve") - { - return; - } - } - } - validationEventHandling.SendEvent(new XmlSchemaException(ResXml.Sch_XmlSpace, string.Empty), XmlSeverityType.Error); - } - - internal SchemaAttDef Clone() - { - return (SchemaAttDef)MemberwiseClone(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaBuilder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaBuilder.cs deleted file mode 100644 index 0c7da5b163e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaBuilder.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - internal abstract class SchemaBuilder - { - internal abstract bool ProcessElement(string prefix, string name, string ns); - internal abstract void ProcessAttribute(string prefix, string name, string ns, string value); - internal abstract bool IsContentParsed(); - internal abstract void ProcessMarkup(XmlNode[] markup); - internal abstract void ProcessCData(string value); - internal abstract void StartChildren(); - internal abstract void EndChildren(); - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionCompiler.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionCompiler.cs deleted file mode 100644 index 2d26e8fd919..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionCompiler.cs +++ /dev/null @@ -1,2769 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Globalization; - using System.Text; - using System.Diagnostics; - - internal sealed class SchemaCollectionCompiler : BaseProcessor - { - private bool _compileContentModel; - private XmlSchemaObjectTable _examplars = new XmlSchemaObjectTable(); - private Stack _complexTypeStack = new Stack(); - private XmlSchema _schema; - - public SchemaCollectionCompiler(XmlNameTable nameTable, ValidationEventHandler eventHandler) - : base(nameTable, null, eventHandler) - { - } - - public bool Execute(XmlSchema schema, SchemaInfo schemaInfo, bool compileContentModel) - { - _compileContentModel = compileContentModel; - _schema = schema; - Prepare(); - Cleanup(); - Compile(); - if (!HasErrors) - { - Output(schemaInfo); - } - return !HasErrors; - } - - private void Prepare() - { - foreach (XmlSchemaElement element in _schema.Elements.Values) - { - if (!element.SubstitutionGroup.IsEmpty) - { - XmlSchemaSubstitutionGroup substitutionGroup = (XmlSchemaSubstitutionGroup)_examplars[element.SubstitutionGroup]; - if (substitutionGroup == null) - { - substitutionGroup = new XmlSchemaSubstitutionGroupV1Compat(); - substitutionGroup.Examplar = element.SubstitutionGroup; - _examplars.Add(element.SubstitutionGroup, substitutionGroup); - } - ArrayList members = substitutionGroup.Members; - Debug.Assert(!members.Contains(element)); - members.Add(element); - } - } - } - - private void Cleanup() - { - foreach (XmlSchemaGroup group in _schema.Groups.Values) - { - CleanupGroup(group); - } - foreach (XmlSchemaAttributeGroup attributeGroup in _schema.AttributeGroups.Values) - { - CleanupAttributeGroup(attributeGroup); - } - foreach (XmlSchemaType type in _schema.SchemaTypes.Values) - { - if (type is XmlSchemaComplexType) - { - CleanupComplexType((XmlSchemaComplexType)type); - } - else - { - CleanupSimpleType((XmlSchemaSimpleType)type); - } - } - foreach (XmlSchemaElement element in _schema.Elements.Values) - { - CleanupElement(element); - } - foreach (XmlSchemaAttribute attribute in _schema.Attributes.Values) - { - CleanupAttribute(attribute); - } - } - - - internal static void Cleanup(XmlSchema schema) - { - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - if (include.Schema != null) - { - Cleanup(include.Schema); - } - XmlSchemaRedefine rdef = include as XmlSchemaRedefine; - if (rdef != null) - { - rdef.AttributeGroups.Clear(); - rdef.Groups.Clear(); - rdef.SchemaTypes.Clear(); - - for (int j = 0; j < rdef.Items.Count; ++j) - { - object item = rdef.Items[j]; - XmlSchemaAttribute attr; - XmlSchemaAttributeGroup attrgroup; - XmlSchemaComplexType complextype; - XmlSchemaSimpleType simpletype; - XmlSchemaElement element; - XmlSchemaGroup group; - - if ((attr = item as XmlSchemaAttribute) != null) - { - CleanupAttribute(attr); - } - else if ((attrgroup = item as XmlSchemaAttributeGroup) != null) - { - CleanupAttributeGroup(attrgroup); - } - else if ((complextype = item as XmlSchemaComplexType) != null) - { - CleanupComplexType(complextype); - } - else if ((simpletype = item as XmlSchemaSimpleType) != null) - { - CleanupSimpleType(simpletype); - } - else if ((element = item as XmlSchemaElement) != null) - { - CleanupElement(element); - } - else if ((group = item as XmlSchemaGroup) != null) - { - CleanupGroup(group); - } - } - } - } - - for (int i = 0; i < schema.Items.Count; ++i) - { - object item = schema.Items[i]; - XmlSchemaAttribute attr; - XmlSchemaAttributeGroup attrgroup; - XmlSchemaComplexType complextype; - XmlSchemaSimpleType simpletype; - XmlSchemaElement element; - XmlSchemaGroup group; - - if ((attr = item as XmlSchemaAttribute) != null) - { - CleanupAttribute(attr); - } - else if ((attrgroup = schema.Items[i] as XmlSchemaAttributeGroup) != null) - { - CleanupAttributeGroup(attrgroup); - } - else if ((complextype = schema.Items[i] as XmlSchemaComplexType) != null) - { - CleanupComplexType(complextype); - } - else if ((simpletype = schema.Items[i] as XmlSchemaSimpleType) != null) - { - CleanupSimpleType(simpletype); - } - else if ((element = schema.Items[i] as XmlSchemaElement) != null) - { - CleanupElement(element); - } - else if ((group = schema.Items[i] as XmlSchemaGroup) != null) - { - CleanupGroup(group); - } - } - schema.Attributes.Clear(); - schema.AttributeGroups.Clear(); - schema.SchemaTypes.Clear(); - schema.Elements.Clear(); - schema.Groups.Clear(); - schema.Notations.Clear(); - schema.Ids.Clear(); - schema.IdentityConstraints.Clear(); - } - - private void Compile() - { - _schema.SchemaTypes.Insert(DatatypeImplementation.QnAnyType, XmlSchemaComplexType.AnyType); - - foreach (XmlSchemaSubstitutionGroupV1Compat substitutionGroup in _examplars.Values) - { - CompileSubstitutionGroup(substitutionGroup); - } - foreach (XmlSchemaGroup group in _schema.Groups.Values) - { - CompileGroup(group); - } - foreach (XmlSchemaAttributeGroup attributeGroup in _schema.AttributeGroups.Values) - { - CompileAttributeGroup(attributeGroup); - } - foreach (XmlSchemaType type in _schema.SchemaTypes.Values) - { - if (type is XmlSchemaComplexType) - { - CompileComplexType((XmlSchemaComplexType)type); - } - else - { - CompileSimpleType((XmlSchemaSimpleType)type); - } - } - foreach (XmlSchemaElement element in _schema.Elements.Values) - { - if (element.ElementDecl == null) - { - CompileElement(element); - } - } - foreach (XmlSchemaAttribute attribute in _schema.Attributes.Values) - { - if (attribute.AttDef == null) - { - CompileAttribute(attribute); - } - } - foreach (XmlSchemaIdentityConstraint identityConstraint in _schema.IdentityConstraints.Values) - { - if (identityConstraint.CompiledConstraint == null) - { - CompileIdentityConstraint(identityConstraint); - } - } - while (_complexTypeStack.Count > 0) - { - XmlSchemaComplexType type = (XmlSchemaComplexType)_complexTypeStack.Pop(); - CompileCompexTypeElements(type); - } - foreach (XmlSchemaType type in _schema.SchemaTypes.Values) - { - if (type is XmlSchemaComplexType) - { - CheckParticleDerivation((XmlSchemaComplexType)type); - } - } - foreach (XmlSchemaElement element in _schema.Elements.Values) - { - if (element.ElementSchemaType is XmlSchemaComplexType && element.SchemaTypeName == XmlQualifiedName.Empty) - { // only local schemaTypes - CheckParticleDerivation((XmlSchemaComplexType)element.ElementSchemaType); - } - } - foreach (XmlSchemaSubstitutionGroup substitutionGroup in _examplars.Values) - { - CheckSubstitutionGroup(substitutionGroup); - } - - _schema.SchemaTypes.Remove(DatatypeImplementation.QnAnyType); //For backward compatibility - } - - private void Output(SchemaInfo schemaInfo) - { - foreach (XmlSchemaElement element in _schema.Elements.Values) - { - schemaInfo.TargetNamespaces[element.QualifiedName.Namespace] = true; - schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl); - } - foreach (XmlSchemaAttribute attribute in _schema.Attributes.Values) - { - schemaInfo.TargetNamespaces[attribute.QualifiedName.Namespace] = true; - schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef); - } - foreach (XmlSchemaType type in _schema.SchemaTypes.Values) - { - schemaInfo.TargetNamespaces[type.QualifiedName.Namespace] = true; - XmlSchemaComplexType complexType = type as XmlSchemaComplexType; - if (complexType == null || (!complexType.IsAbstract && type != XmlSchemaComplexType.AnyType)) - { - schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl); - } - } - foreach (XmlSchemaNotation notation in _schema.Notations.Values) - { - schemaInfo.TargetNamespaces[notation.QualifiedName.Namespace] = true; - SchemaNotation no = new SchemaNotation(notation.QualifiedName); - no.SystemLiteral = notation.System; - no.Pubid = notation.Public; - if (!schemaInfo.Notations.ContainsKey(no.Name.Name)) - { - schemaInfo.Notations.Add(no.Name.Name, no); - } - } - } - - private static void CleanupAttribute(XmlSchemaAttribute attribute) - { - if (attribute.SchemaType != null) - { - CleanupSimpleType((XmlSchemaSimpleType)attribute.SchemaType); - } - attribute.AttDef = null; - } - - private static void CleanupAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - CleanupAttributes(attributeGroup.Attributes); - attributeGroup.AttributeUses.Clear(); - attributeGroup.AttributeWildcard = null; - } - - private static void CleanupComplexType(XmlSchemaComplexType complexType) - { - if (complexType.ContentModel != null) - { //simpleContent or complexContent - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel; - if (simpleContent.Content is XmlSchemaSimpleContentExtension) - { - XmlSchemaSimpleContentExtension simpleExtension = (XmlSchemaSimpleContentExtension)simpleContent.Content; - CleanupAttributes(simpleExtension.Attributes); - } - else - { //simpleContent.Content is XmlSchemaSimpleContentRestriction - XmlSchemaSimpleContentRestriction simpleRestriction = (XmlSchemaSimpleContentRestriction)simpleContent.Content; - CleanupAttributes(simpleRestriction.Attributes); - } - } - else - { // complexType.ContentModel is XmlSchemaComplexContent - XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; - if (complexContent.Content is XmlSchemaComplexContentExtension) - { - XmlSchemaComplexContentExtension complexExtension = (XmlSchemaComplexContentExtension)complexContent.Content; - CleanupParticle(complexExtension.Particle); - CleanupAttributes(complexExtension.Attributes); - } - else - { //XmlSchemaComplexContentRestriction - XmlSchemaComplexContentRestriction complexRestriction = (XmlSchemaComplexContentRestriction)complexContent.Content; - CleanupParticle(complexRestriction.Particle); - CleanupAttributes(complexRestriction.Attributes); - } - } - } - else - { //equals XmlSchemaComplexContent with baseType is anyType - CleanupParticle(complexType.Particle); - CleanupAttributes(complexType.Attributes); - } - complexType.LocalElements.Clear(); - complexType.AttributeUses.Clear(); - complexType.SetAttributeWildcard(null); - complexType.SetContentTypeParticle(XmlSchemaParticle.Empty); - complexType.ElementDecl = null; - } - - private static void CleanupSimpleType(XmlSchemaSimpleType simpleType) - { - simpleType.ElementDecl = null; - } - - private static void CleanupElement(XmlSchemaElement element) - { - if (element.SchemaType != null) - { - XmlSchemaComplexType complexType = element.SchemaType as XmlSchemaComplexType; - if (complexType != null) - { - CleanupComplexType(complexType); - } - else - { - CleanupSimpleType((XmlSchemaSimpleType)element.SchemaType); - } - } - for (int i = 0; i < element.Constraints.Count; ++i) - { - ((XmlSchemaIdentityConstraint)element.Constraints[i]).CompiledConstraint = null; - } - element.ElementDecl = null; - } - - private static void CleanupAttributes(XmlSchemaObjectCollection attributes) - { - for (int i = 0; i < attributes.Count; ++i) - { - XmlSchemaAttribute attribute = attributes[i] as XmlSchemaAttribute; - if (attribute != null) - { - CleanupAttribute(attribute); - } - } - } - - private static void CleanupGroup(XmlSchemaGroup group) - { - CleanupParticle(group.Particle); - group.CanonicalParticle = null; - } - - private static void CleanupParticle(XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - CleanupElement((XmlSchemaElement)particle); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - for (int i = 0; i < particles.Count; ++i) - { - CleanupParticle((XmlSchemaParticle)particles[i]); - } - } - } - - private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroupV1Compat substitutionGroup) - { - if (substitutionGroup.IsProcessing && substitutionGroup.Members.Count > 0) - { - SendValidationEvent(ResXml.Sch_SubstitutionCircularRef, (XmlSchemaElement)substitutionGroup.Members[0]); - return; - } - XmlSchemaElement examplar = (XmlSchemaElement)_schema.Elements[substitutionGroup.Examplar]; - if (substitutionGroup.Members.Contains(examplar)) - {// already checked - return; - } - substitutionGroup.IsProcessing = true; - if (examplar != null) - { - if (examplar.FinalResolved == XmlSchemaDerivationMethod.All) - { - SendValidationEvent(ResXml.Sch_InvalidExamplar, examplar); - } - - for (int i = 0; i < substitutionGroup.Members.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)substitutionGroup.Members[i]; - //Chain to other head's that are members of this head's substGroup - XmlSchemaSubstitutionGroupV1Compat g = (XmlSchemaSubstitutionGroupV1Compat)_examplars[element.QualifiedName]; - if (g != null) - { - CompileSubstitutionGroup(g); - for (int j = 0; j < g.Choice.Items.Count; ++j) - { - substitutionGroup.Choice.Items.Add(g.Choice.Items[j]); - } - } - else - { - substitutionGroup.Choice.Items.Add(element); - } - } - substitutionGroup.Choice.Items.Add(examplar); - substitutionGroup.Members.Add(examplar); // Compiled mark - } - else if (substitutionGroup.Members.Count > 0) - { - SendValidationEvent(ResXml.Sch_NoExamplar, (XmlSchemaElement)substitutionGroup.Members[0]); - } - substitutionGroup.IsProcessing = false; - } - - private void CheckSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup) - { - XmlSchemaElement examplar = (XmlSchemaElement)_schema.Elements[substitutionGroup.Examplar]; - if (examplar != null) - { - for (int i = 0; i < substitutionGroup.Members.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)substitutionGroup.Members[i]; - - if (element != examplar) - { - if (!XmlSchemaType.IsDerivedFrom(element.ElementSchemaType, examplar.ElementSchemaType, examplar.FinalResolved)) - { - SendValidationEvent(ResXml.Sch_InvalidSubstitutionMember, (element.QualifiedName).ToString(), (examplar.QualifiedName).ToString(), element); - } - } - } - } - } - - private void CompileGroup(XmlSchemaGroup group) - { - if (group.IsProcessing) - { - SendValidationEvent(ResXml.Sch_GroupCircularRef, group); - group.CanonicalParticle = XmlSchemaParticle.Empty; - } - else - { - group.IsProcessing = true; - if (group.CanonicalParticle == null) - { - group.CanonicalParticle = CannonicalizeParticle(group.Particle, true, true); - } - Debug.Assert(group.CanonicalParticle != null); - group.IsProcessing = false; - } - } - - private void CompileSimpleType(XmlSchemaSimpleType simpleType) - { - if (simpleType.IsProcessing) - { - throw new XmlSchemaException(ResXml.Sch_TypeCircularRef, simpleType); - } - if (simpleType.ElementDecl != null) - { // already compiled - return; - } - simpleType.IsProcessing = true; - try - { - if (simpleType.Content is XmlSchemaSimpleTypeList) - { - XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; - XmlSchemaDatatype datatype; - simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); - if (list.ItemTypeName.IsEmpty) - { - CompileSimpleType(list.ItemType); - list.BaseItemType = list.ItemType; - datatype = list.ItemType.Datatype; - } - else - { - XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName); - if (type != null) - { - if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalList, simpleType); - } - list.BaseItemType = type; - datatype = type.Datatype; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), simpleType); - } - } - simpleType.SetDatatype(datatype.DeriveByList(simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List); - } - else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; - XmlSchemaDatatype datatype; - if (restriction.BaseTypeName.IsEmpty) - { - CompileSimpleType(restriction.BaseType); - simpleType.SetBaseSchemaType(restriction.BaseType); - datatype = restriction.BaseType.Datatype; - } - else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) - { - CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined); - simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType); - datatype = simpleType.Redefined.Datatype; - } - else - { - if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType)) - { - throw new XmlSchemaException(ResXml.Sch_InvalidSimpleTypeRestriction, restriction.BaseTypeName.ToString(), simpleType); - } - XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName); - if (type != null) - { - if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, simpleType); - } - simpleType.SetBaseSchemaType(type); - datatype = type.Datatype; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), simpleType); - } - } - simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, NameTable, simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - } - else - { //simpleType.Content is XmlSchemaSimpleTypeUnion - XmlSchemaSimpleType[] baseTypes = CompileBaseMemberTypes(simpleType); - simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); - simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(baseTypes, simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union); - } - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(simpleType); - } - SendValidationEvent(e); - simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); - } - finally - { - SchemaElementDecl decl = new SchemaElementDecl(); - decl.ContentValidator = ContentValidator.TextOnly; - decl.SchemaType = simpleType; - decl.Datatype = simpleType.Datatype; - simpleType.ElementDecl = decl; - simpleType.IsProcessing = false; - } - } - - private XmlSchemaSimpleType[] CompileBaseMemberTypes(XmlSchemaSimpleType simpleType) - { - XmlSchemaSimpleType unionMember; - ArrayList memberTypeDefinitions = new ArrayList(); - - XmlSchemaSimpleTypeUnion mainUnion = (XmlSchemaSimpleTypeUnion)simpleType.Content; - - XmlQualifiedName[] mainMemberTypes = mainUnion.MemberTypes; - if (mainMemberTypes != null) - { - for (int i = 0; i < mainMemberTypes.Length; ++i) - { - unionMember = GetSimpleType(mainMemberTypes[i]); - if (unionMember != null) - { - if (unionMember.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { //union of union - CheckUnionType(unionMember, memberTypeDefinitions, simpleType); - } - else - { //its list or atomic - memberTypeDefinitions.Add(unionMember); - } - //Check derivation method of the member that is referenced - if ((unionMember.FinalResolved & XmlSchemaDerivationMethod.Union) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalUnion, simpleType); - } - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, mainMemberTypes[i].ToString(), simpleType); - } - } - } - - //Now add the baseTypes that are defined inside the union itself - XmlSchemaObjectCollection mainBaseTypes = mainUnion.BaseTypes; //TODO check for null - if (mainBaseTypes != null) - { - for (int i = 0; i < mainBaseTypes.Count; ++i) - { - XmlSchemaSimpleType st = (XmlSchemaSimpleType)mainBaseTypes[i]; - CompileSimpleType(st); - if (st.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { //union of union - CheckUnionType(st, memberTypeDefinitions, simpleType); - } - else - { //its list or atomic - memberTypeDefinitions.Add(st); - } - } - } - //set all types - mainUnion.SetBaseMemberTypes(memberTypeDefinitions.ToArray(typeof(XmlSchemaSimpleType)) as XmlSchemaSimpleType[]); - return mainUnion.BaseMemberTypes; - } - - private void CheckUnionType(XmlSchemaSimpleType unionMember, ArrayList memberTypeDefinitions, XmlSchemaSimpleType parentType) - { - XmlSchemaDatatype unionDatatype = unionMember.Datatype; - if (unionMember.DerivedBy == XmlSchemaDerivationMethod.Restriction && (unionDatatype.HasLexicalFacets || unionDatatype.HasValueFacets)) - { - SendValidationEvent(ResXml.Sch_UnionFromUnion, parentType); - } - else - { - Datatype_union uniondt = unionMember.Datatype as Datatype_union; - memberTypeDefinitions.AddRange(uniondt.BaseMemberTypes); - } - } - - private void CompileComplexType(XmlSchemaComplexType complexType) - { - if (complexType.ElementDecl != null) - { //already compiled - return; - } - if (complexType.IsProcessing) - { - SendValidationEvent(ResXml.Sch_TypeCircularRef, complexType); - return; - } - complexType.IsProcessing = true; - if (complexType.ContentModel != null) - { //simpleContent or complexContent - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel; - complexType.SetContentType(XmlSchemaContentType.TextOnly); - if (simpleContent.Content is XmlSchemaSimpleContentExtension) - { - CompileSimpleContentExtension(complexType, (XmlSchemaSimpleContentExtension)simpleContent.Content); - } - else - { //simpleContent.Content is XmlSchemaSimpleContentRestriction - CompileSimpleContentRestriction(complexType, (XmlSchemaSimpleContentRestriction)simpleContent.Content); - } - } - else - { // complexType.ContentModel is XmlSchemaComplexContent - XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; - if (complexContent.Content is XmlSchemaComplexContentExtension) - { - CompileComplexContentExtension(complexType, complexContent, (XmlSchemaComplexContentExtension)complexContent.Content); - } - else - { // complexContent.Content is XmlSchemaComplexContentRestriction - CompileComplexContentRestriction(complexType, complexContent, (XmlSchemaComplexContentRestriction)complexContent.Content); - } - } - } - else - { //equals XmlSchemaComplexContent with baseType is anyType - complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType); - CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle, true)); - complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle)); - } - bool hasID = false; - foreach (XmlSchemaAttribute attribute in complexType.AttributeUses.Values) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - XmlSchemaDatatype datatype = attribute.Datatype; - if (datatype != null && datatype.TokenizedType == XmlTokenizedType.ID) - { - if (hasID) - { - SendValidationEvent(ResXml.Sch_TwoIdAttrUses, complexType); - } - else - { - hasID = true; - } - } - } - } - SchemaElementDecl decl = new SchemaElementDecl(); - decl.ContentValidator = CompileComplexContent(complexType); - decl.SchemaType = complexType; - decl.IsAbstract = complexType.IsAbstract; - decl.Datatype = complexType.Datatype; - decl.Block = complexType.BlockResolved; - decl.AnyAttribute = complexType.AttributeWildcard; - foreach (XmlSchemaAttribute attribute in complexType.AttributeUses.Values) - { - if (attribute.Use == XmlSchemaUse.Prohibited) - { - if (!decl.ProhibitedAttributes.ContainsKey(attribute.QualifiedName)) - { - decl.ProhibitedAttributes.Add(attribute.QualifiedName, attribute.QualifiedName); - } - } - else - { - if (!decl.AttDefs.ContainsKey(attribute.QualifiedName) && attribute.AttDef != null && attribute.AttDef.Name != XmlQualifiedName.Empty && attribute.AttDef != SchemaAttDef.Empty) - { - decl.AddAttDef(attribute.AttDef); - } - } - } - - complexType.ElementDecl = decl; - - complexType.IsProcessing = false; - } - - - private void CompileSimpleContentExtension(XmlSchemaComplexType complexType, XmlSchemaSimpleContentExtension simpleExtension) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && simpleExtension.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - complexType.SetBaseSchemaType(baseType); - complexType.SetDatatype(baseType.Datatype); - } - else - { - XmlSchemaType bto = GetAnySchemaType(simpleExtension.BaseTypeName); - if (bto == null) - { - SendValidationEvent(ResXml.Sch_UndeclaredType, simpleExtension.BaseTypeName.ToString(), complexType); - } - else - { - complexType.SetBaseSchemaType(bto); - complexType.SetDatatype(bto.Datatype); - } - baseType = bto as XmlSchemaComplexType; - } - if (baseType != null) - { - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalExtension, complexType); - } - if (baseType.ContentType != XmlSchemaContentType.TextOnly) - { - SendValidationEvent(ResXml.Sch_NotSimpleContent, complexType); - } - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension); - CompileLocalAttributes(baseType, complexType, simpleExtension.Attributes, simpleExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension); - } - - private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction) - { - XmlSchemaComplexType baseType = null; - XmlSchemaDatatype datatype = null; - if (complexType.Redefined != null && simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - datatype = baseType.Datatype; - } - else - { - baseType = GetComplexType(simpleRestriction.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseRestriction, simpleRestriction.BaseTypeName.ToString(), simpleRestriction); - return; - } - if (baseType.ContentType == XmlSchemaContentType.TextOnly) - { - if (simpleRestriction.BaseType == null) - { - datatype = baseType.Datatype; - //There is a bug here. Need to check if simpleRestriction has facets. - //If yes, Need tp apply these facets as well. - } - else - { - CompileSimpleType(simpleRestriction.BaseType); - if (!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, baseType.Datatype, XmlSchemaDerivationMethod.None)) - { - SendValidationEvent(ResXml.Sch_DerivedNotFromBase, simpleRestriction); - } - datatype = simpleRestriction.BaseType.Datatype; - } - } - else if (baseType.ContentType == XmlSchemaContentType.Mixed && baseType.ElementDecl.ContentValidator.IsEmptiable) - { - if (simpleRestriction.BaseType != null) - { - CompileSimpleType(simpleRestriction.BaseType); - complexType.SetBaseSchemaType(simpleRestriction.BaseType); - datatype = simpleRestriction.BaseType.Datatype; - } - else - { - SendValidationEvent(ResXml.Sch_NeedSimpleTypeChild, simpleRestriction); - } - } - else - { - SendValidationEvent(ResXml.Sch_NotSimpleContent, complexType); - } - } - if (baseType != null && baseType.ElementDecl != null) - { - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, complexType); - } - } - if (baseType != null) - { - complexType.SetBaseSchemaType(baseType); - } - if (datatype != null) - { - try - { - complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, NameTable, complexType)); - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(complexType); - } - SendValidationEvent(e); - complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); - } - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - CompileLocalAttributes(baseType, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - } - - private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - } - else - { - baseType = GetComplexType(complexExtension.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseExtension, complexExtension.BaseTypeName.ToString(), complexExtension); - return; - } - } - if (baseType != null && baseType.ElementDecl != null) - { - if (baseType.ContentType == XmlSchemaContentType.TextOnly) - { - SendValidationEvent(ResXml.Sch_NotComplexContent, complexType); - return; - } - } - complexType.SetBaseSchemaType(baseType); - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalExtension, complexType); - } - CompileLocalAttributes(baseType, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension); - - XmlSchemaParticle baseParticle = baseType.ContentTypeParticle; - XmlSchemaParticle extendedParticle = CannonicalizeParticle(complexExtension.Particle, true, true); - if (baseParticle != XmlSchemaParticle.Empty) - { - if (extendedParticle != XmlSchemaParticle.Empty) - { - XmlSchemaSequence compiledParticle = new XmlSchemaSequence(); - compiledParticle.Items.Add(baseParticle); - compiledParticle.Items.Add(extendedParticle); - complexType.SetContentTypeParticle(CompileContentTypeParticle(compiledParticle, false)); - } - else - { - complexType.SetContentTypeParticle(baseParticle); - } - XmlSchemaContentType contentType = GetSchemaContentType(complexType, complexContent, extendedParticle); - if (contentType == XmlSchemaContentType.Empty) - { //Derived content type is empty, Get ContentType from base - contentType = baseType.ContentType; - } - complexType.SetContentType(contentType); - if (complexType.ContentType != baseType.ContentType) - { - SendValidationEvent(ResXml.Sch_DifContentType, complexType); - } - } - else - { - complexType.SetContentTypeParticle(extendedParticle); - complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle)); - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension); - } - - private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - } - else - { - baseType = GetComplexType(complexRestriction.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction); - return; - } - } - if (baseType != null && baseType.ElementDecl != null) - { - if (baseType.ContentType == XmlSchemaContentType.TextOnly) - { - SendValidationEvent(ResXml.Sch_NotComplexContent, complexType); - return; - } - } - complexType.SetBaseSchemaType(baseType); - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, complexType); - } - CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - - complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle, true)); - complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle)); - if (complexType.ContentType == XmlSchemaContentType.Empty) - { - if (baseType.ElementDecl != null) - { - Debug.Assert(baseType.ElementDecl.ContentValidator != null); - } - if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) - { - SendValidationEvent(ResXml.Sch_InvalidContentRestriction, complexType); - } - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - } - - private void CheckParticleDerivation(XmlSchemaComplexType complexType) - { - XmlSchemaComplexType baseType = complexType.BaseXmlSchemaType as XmlSchemaComplexType; - if (baseType != null && baseType != XmlSchemaComplexType.AnyType && complexType.DerivedBy == XmlSchemaDerivationMethod.Restriction) - { - if (!IsValidRestriction(complexType.ContentTypeParticle, baseType.ContentTypeParticle)) - { -#if DEBUG - if (complexType.ContentTypeParticle != null && baseType.ContentTypeParticle != null) - { - string position = string.Empty; - if (complexType.SourceUri != null) - { - position = " in " + complexType.SourceUri + "(" + complexType.LineNumber + ", " + complexType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType content restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpContentModel(baseType.ContentTypeParticle)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpContentModel(complexType.ContentTypeParticle)); - } -#endif - SendValidationEvent(ResXml.Sch_InvalidParticleRestriction, complexType); - } - } - } - - private XmlSchemaParticle CompileContentTypeParticle(XmlSchemaParticle particle, bool substitution) - { - XmlSchemaParticle ctp = CannonicalizeParticle(particle, true, substitution); - XmlSchemaChoice choice = ctp as XmlSchemaChoice; - if (choice != null && choice.Items.Count == 0) - { - if (choice.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, choice, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - return ctp; - } - - private XmlSchemaParticle CannonicalizeParticle(XmlSchemaParticle particle, bool root, bool substitution) - { - if (particle == null || particle.IsEmpty) - { - return XmlSchemaParticle.Empty; - } - else if (particle is XmlSchemaElement) - { - return CannonicalizeElement((XmlSchemaElement)particle, substitution); - } - else if (particle is XmlSchemaGroupRef) - { - return CannonicalizeGroupRef((XmlSchemaGroupRef)particle, root, substitution); - } - else if (particle is XmlSchemaAll) - { - return CannonicalizeAll((XmlSchemaAll)particle, root, substitution); - } - else if (particle is XmlSchemaChoice) - { - return CannonicalizeChoice((XmlSchemaChoice)particle, root, substitution); - } - else if (particle is XmlSchemaSequence) - { - return CannonicalizeSequence((XmlSchemaSequence)particle, root, substitution); - } - else - { - return particle; - } - } - - private XmlSchemaParticle CannonicalizeElement(XmlSchemaElement element, bool substitution) - { - if (!element.RefName.IsEmpty && substitution && (element.BlockResolved & XmlSchemaDerivationMethod.Substitution) == 0) - { - XmlSchemaSubstitutionGroupV1Compat substitutionGroup = (XmlSchemaSubstitutionGroupV1Compat)_examplars[element.QualifiedName]; - if (substitutionGroup == null) - { - return element; - } - else - { - XmlSchemaChoice choice = (XmlSchemaChoice)substitutionGroup.Choice.Clone(); - choice.MinOccurs = element.MinOccurs; - choice.MaxOccurs = element.MaxOccurs; - return choice; - } - } - else - { - return element; - } - } - - private XmlSchemaParticle CannonicalizeGroupRef(XmlSchemaGroupRef groupRef, bool root, bool substitution) - { - XmlSchemaGroup group; - if (groupRef.Redefined != null) - { - group = groupRef.Redefined; - } - else - { - group = (XmlSchemaGroup)_schema.Groups[groupRef.RefName]; - } - if (group == null) - { - SendValidationEvent(ResXml.Sch_UndefGroupRef, groupRef.RefName.ToString(), groupRef); - return XmlSchemaParticle.Empty; - } - if (group.CanonicalParticle == null) - { - CompileGroup(group); - } - if (group.CanonicalParticle == XmlSchemaParticle.Empty) - { - return XmlSchemaParticle.Empty; - } - XmlSchemaGroupBase groupBase = (XmlSchemaGroupBase)group.CanonicalParticle; - if (groupBase is XmlSchemaAll) - { - if (!root) - { - SendValidationEvent(ResXml.Sch_AllRefNotRoot, "", groupRef); - return XmlSchemaParticle.Empty; - } - if (groupRef.MinOccurs != decimal.One || groupRef.MaxOccurs != decimal.One) - { - SendValidationEvent(ResXml.Sch_AllRefMinMax, groupRef); - return XmlSchemaParticle.Empty; - } - } - else if (groupBase is XmlSchemaChoice && groupBase.Items.Count == 0) - { - if (groupRef.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, groupRef, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - XmlSchemaGroupBase groupRefBase = ( - (groupBase is XmlSchemaSequence) ? (XmlSchemaGroupBase)new XmlSchemaSequence() : - (groupBase is XmlSchemaChoice) ? (XmlSchemaGroupBase)new XmlSchemaChoice() : - (XmlSchemaGroupBase)new XmlSchemaAll() - ); - groupRefBase.MinOccurs = groupRef.MinOccurs; - groupRefBase.MaxOccurs = groupRef.MaxOccurs; - for (int i = 0; i < groupBase.Items.Count; ++i) - { - groupRefBase.Items.Add((XmlSchemaParticle)groupBase.Items[i]); - } - groupRef.SetParticle(groupRefBase); - return groupRefBase; - } - - private XmlSchemaParticle CannonicalizeAll(XmlSchemaAll all, bool root, bool substitution) - { - if (all.Items.Count > 0) - { - XmlSchemaAll newAll = new XmlSchemaAll(); - newAll.MinOccurs = all.MinOccurs; - newAll.MaxOccurs = all.MaxOccurs; - newAll.SourceUri = all.SourceUri; // all is the only one that might need and error message - newAll.LineNumber = all.LineNumber; - newAll.LinePosition = all.LinePosition; - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaParticle p = CannonicalizeParticle((XmlSchemaElement)all.Items[i], false, substitution); - if (p != XmlSchemaParticle.Empty) - { - newAll.Items.Add(p); - } - } - all = newAll; - } - if (all.Items.Count == 0) - { - return XmlSchemaParticle.Empty; - } - else if (root && all.Items.Count == 1) - { - XmlSchemaSequence newSequence = new XmlSchemaSequence(); - newSequence.MinOccurs = all.MinOccurs; - newSequence.MaxOccurs = all.MaxOccurs; - newSequence.Items.Add((XmlSchemaParticle)all.Items[0]); - return newSequence; - } - else if (!root && all.Items.Count == 1 && all.MinOccurs == decimal.One && all.MaxOccurs == decimal.One) - { - return (XmlSchemaParticle)all.Items[0]; - } - else if (!root) - { - SendValidationEvent(ResXml.Sch_NotAllAlone, all); - return XmlSchemaParticle.Empty; - } - else - { - return all; - } - } - - private XmlSchemaParticle CannonicalizeChoice(XmlSchemaChoice choice, bool root, bool substitution) - { - XmlSchemaChoice oldChoice = choice; - if (choice.Items.Count > 0) - { - XmlSchemaChoice newChoice = new XmlSchemaChoice(); - newChoice.MinOccurs = choice.MinOccurs; - newChoice.MaxOccurs = choice.MaxOccurs; - for (int i = 0; i < choice.Items.Count; ++i) - { - XmlSchemaParticle p1 = CannonicalizeParticle((XmlSchemaParticle)choice.Items[i], false, substitution); - if (p1 != XmlSchemaParticle.Empty) - { - if (p1.MinOccurs == decimal.One && p1.MaxOccurs == decimal.One && p1 is XmlSchemaChoice) - { - XmlSchemaChoice particleChoice = (XmlSchemaChoice)p1; - for (int j = 0; j < particleChoice.Items.Count; ++j) - { - newChoice.Items.Add(particleChoice.Items[j]); - } - } - else - { - newChoice.Items.Add(p1); - } - } - } - choice = newChoice; - } - if (!root && choice.Items.Count == 0) - { - if (choice.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, oldChoice, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - else if (!root && choice.Items.Count == 1 && choice.MinOccurs == decimal.One && choice.MaxOccurs == decimal.One) - { - return (XmlSchemaParticle)choice.Items[0]; - } - else - { - return choice; - } - } - - private XmlSchemaParticle CannonicalizeSequence(XmlSchemaSequence sequence, bool root, bool substitution) - { - if (sequence.Items.Count > 0) - { - XmlSchemaSequence newSequence = new XmlSchemaSequence(); - newSequence.MinOccurs = sequence.MinOccurs; - newSequence.MaxOccurs = sequence.MaxOccurs; - for (int i = 0; i < sequence.Items.Count; ++i) - { - XmlSchemaParticle p1 = CannonicalizeParticle((XmlSchemaParticle)sequence.Items[i], false, substitution); - if (p1 != XmlSchemaParticle.Empty) - { - if (p1.MinOccurs == decimal.One && p1.MaxOccurs == decimal.One && p1 is XmlSchemaSequence) - { - XmlSchemaSequence particleSequence = (XmlSchemaSequence)p1; - for (int j = 0; j < particleSequence.Items.Count; ++j) - { - newSequence.Items.Add(particleSequence.Items[j]); - } - } - else - { - newSequence.Items.Add(p1); - } - } - } - sequence = newSequence; - } - if (sequence.Items.Count == 0) - { - return XmlSchemaParticle.Empty; - } - else if (!root && sequence.Items.Count == 1 && sequence.MinOccurs == decimal.One && sequence.MaxOccurs == decimal.One) - { - return (XmlSchemaParticle)sequence.Items[0]; - } - else - { - return sequence; - } - } - - private bool IsValidRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle) - { - if (derivedParticle == baseParticle) - { - return true; - } - else if (derivedParticle == null || derivedParticle == XmlSchemaParticle.Empty) - { - return IsParticleEmptiable(baseParticle); - } - else if (baseParticle == null || baseParticle == XmlSchemaParticle.Empty) - { - return false; - } - if (baseParticle is XmlSchemaElement) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromElement((XmlSchemaElement)derivedParticle, (XmlSchemaElement)baseParticle); - } - else - { - return false; - } - } - else if (baseParticle is XmlSchemaAny) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromAny((XmlSchemaElement)derivedParticle, (XmlSchemaAny)baseParticle); - } - else if (derivedParticle is XmlSchemaAny) - { - return IsAnyFromAny((XmlSchemaAny)derivedParticle, (XmlSchemaAny)baseParticle); - } - else - { - return IsGroupBaseFromAny((XmlSchemaGroupBase)derivedParticle, (XmlSchemaAny)baseParticle); - } - } - else if (baseParticle is XmlSchemaAll) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle, true); - } - else if (derivedParticle is XmlSchemaAll) - { - return IsGroupBaseFromGroupBase((XmlSchemaGroupBase)derivedParticle, (XmlSchemaGroupBase)baseParticle, true); - } - else if (derivedParticle is XmlSchemaSequence) - { - return IsSequenceFromAll((XmlSchemaSequence)derivedParticle, (XmlSchemaAll)baseParticle); - } - } - else if (baseParticle is XmlSchemaChoice) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle, false); - } - else if (derivedParticle is XmlSchemaChoice) - { - return IsGroupBaseFromGroupBase((XmlSchemaGroupBase)derivedParticle, (XmlSchemaGroupBase)baseParticle, false); - } - else if (derivedParticle is XmlSchemaSequence) - { - return IsSequenceFromChoice((XmlSchemaSequence)derivedParticle, (XmlSchemaChoice)baseParticle); - } - } - else if (baseParticle is XmlSchemaSequence) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle, true); - } - else if (derivedParticle is XmlSchemaSequence) - { - return IsGroupBaseFromGroupBase((XmlSchemaGroupBase)derivedParticle, (XmlSchemaGroupBase)baseParticle, true); - } - } - else - { - Debug.Assert(false); - } - - return false; - } - - private bool IsElementFromElement(XmlSchemaElement derivedElement, XmlSchemaElement baseElement) - { - return (derivedElement.QualifiedName == baseElement.QualifiedName) && - (derivedElement.IsNillable == baseElement.IsNillable) && - IsValidOccurrenceRangeRestriction(derivedElement, baseElement) && - (baseElement.FixedValue == null || baseElement.FixedValue == derivedElement.FixedValue) && - ((derivedElement.BlockResolved | baseElement.BlockResolved) == derivedElement.BlockResolved) && - (derivedElement.ElementSchemaType != null) && (baseElement.ElementSchemaType != null) && - XmlSchemaType.IsDerivedFrom(derivedElement.ElementSchemaType, baseElement.ElementSchemaType, ~XmlSchemaDerivationMethod.Restriction); - } - - private bool IsElementFromAny(XmlSchemaElement derivedElement, XmlSchemaAny baseAny) - { - return baseAny.Allows(derivedElement.QualifiedName) && - IsValidOccurrenceRangeRestriction(derivedElement, baseAny); - } - - private bool IsAnyFromAny(XmlSchemaAny derivedAny, XmlSchemaAny baseAny) - { - return IsValidOccurrenceRangeRestriction(derivedAny, baseAny) && - NamespaceList.IsSubset(derivedAny.NamespaceList, baseAny.NamespaceList); - } - - private bool IsGroupBaseFromAny(XmlSchemaGroupBase derivedGroupBase, XmlSchemaAny baseAny) - { - decimal minOccurs, maxOccurs; - CalculateEffectiveTotalRange(derivedGroupBase, out minOccurs, out maxOccurs); - if (!IsValidOccurrenceRangeRestriction(minOccurs, maxOccurs, baseAny.MinOccurs, baseAny.MaxOccurs)) - { - return false; - } - // eliminate occurrance range check - string minOccursAny = baseAny.MinOccursString; - baseAny.MinOccurs = decimal.Zero; - - for (int i = 0; i < derivedGroupBase.Items.Count; ++i) - { - if (!IsValidRestriction((XmlSchemaParticle)derivedGroupBase.Items[i], baseAny)) - { - baseAny.MinOccursString = minOccursAny; - return false; - } - } - baseAny.MinOccursString = minOccursAny; - return true; - } - - private bool IsElementFromGroupBase(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly) - { - bool isMatched = false; - for (int i = 0; i < baseGroupBase.Items.Count; ++i) - { - XmlSchemaParticle baseParticle = (XmlSchemaParticle)baseGroupBase.Items[i]; - if (!isMatched) - { - string minOccursElement = baseParticle.MinOccursString; - string maxOccursElement = baseParticle.MaxOccursString; - baseParticle.MinOccurs *= baseGroupBase.MinOccurs; - if (baseParticle.MaxOccurs != decimal.MaxValue) - { - if (baseGroupBase.MaxOccurs == decimal.MaxValue) - baseParticle.MaxOccurs = decimal.MaxValue; - else - baseParticle.MaxOccurs *= baseGroupBase.MaxOccurs; - } - isMatched = IsValidRestriction(derivedElement, baseParticle); - baseParticle.MinOccursString = minOccursElement; - baseParticle.MaxOccursString = maxOccursElement; - } - else if (skipEmptableOnly && !IsParticleEmptiable(baseParticle)) - { - return false; - } - } - return isMatched; - } - - private bool IsGroupBaseFromGroupBase(XmlSchemaGroupBase derivedGroupBase, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly) - { - if (!IsValidOccurrenceRangeRestriction(derivedGroupBase, baseGroupBase) || derivedGroupBase.Items.Count > baseGroupBase.Items.Count) - { - return false; - } - int count = 0; - for (int i = 0; i < baseGroupBase.Items.Count; ++i) - { - XmlSchemaParticle baseParticle = (XmlSchemaParticle)baseGroupBase.Items[i]; - if ((count < derivedGroupBase.Items.Count) && IsValidRestriction((XmlSchemaParticle)derivedGroupBase.Items[count], baseParticle)) - { - count++; - } - else if (skipEmptableOnly && !IsParticleEmptiable(baseParticle)) - { - return false; - } - } - if (count < derivedGroupBase.Items.Count) - { - return false; - } - return true; - } - - private bool IsSequenceFromAll(XmlSchemaSequence derivedSequence, XmlSchemaAll baseAll) - { - if (!IsValidOccurrenceRangeRestriction(derivedSequence, baseAll) || derivedSequence.Items.Count > baseAll.Items.Count) - { - return false; - } - BitSet map = new BitSet(baseAll.Items.Count); - for (int j = 0; j < derivedSequence.Items.Count; ++j) - { - int i = GetMappingParticle((XmlSchemaParticle)derivedSequence.Items[j], baseAll.Items); - if (i >= 0) - { - if (map[i]) - { - return false; - } - else - { - map.Set(i); - } - } - else - { - return false; - } - } - for (int i = 0; i < baseAll.Items.Count; i++) - { - if (!map[i] && !IsParticleEmptiable((XmlSchemaParticle)baseAll.Items[i])) - { - return false; - } - } - return true; - } - - private bool IsSequenceFromChoice(XmlSchemaSequence derivedSequence, XmlSchemaChoice baseChoice) - { - decimal minOccurs, maxOccurs; - CalculateSequenceRange(derivedSequence, out minOccurs, out maxOccurs); - if (!IsValidOccurrenceRangeRestriction(minOccurs, maxOccurs, baseChoice.MinOccurs, baseChoice.MaxOccurs) || derivedSequence.Items.Count > baseChoice.Items.Count) - { - return false; - } - for (int i = 0; i < derivedSequence.Items.Count; ++i) - { - if (GetMappingParticle((XmlSchemaParticle)derivedSequence.Items[i], baseChoice.Items) < 0) - return false; - } - return true; - } - - private void CalculateSequenceRange(XmlSchemaSequence sequence, out decimal minOccurs, out decimal maxOccurs) - { - minOccurs = decimal.Zero; maxOccurs = decimal.Zero; - for (int i = 0; i < sequence.Items.Count; ++i) - { - XmlSchemaParticle p = (XmlSchemaParticle)sequence.Items[i]; - - minOccurs += p.MinOccurs; - if (p.MaxOccurs == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else if (maxOccurs != decimal.MaxValue) - maxOccurs += p.MaxOccurs; - } - minOccurs *= sequence.MinOccurs; - if (sequence.MaxOccurs == decimal.MaxValue) - { - maxOccurs = decimal.MaxValue; - } - else if (maxOccurs != decimal.MaxValue) - { - maxOccurs *= sequence.MaxOccurs; - } - } - - private bool IsValidOccurrenceRangeRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle) - { - return IsValidOccurrenceRangeRestriction(derivedParticle.MinOccurs, derivedParticle.MaxOccurs, baseParticle.MinOccurs, baseParticle.MaxOccurs); - } - - private bool IsValidOccurrenceRangeRestriction(decimal minOccurs, decimal maxOccurs, decimal baseMinOccurs, decimal baseMaxOccurs) - { - return (baseMinOccurs <= minOccurs) && (maxOccurs <= baseMaxOccurs); - } - - private int GetMappingParticle(XmlSchemaParticle particle, XmlSchemaObjectCollection collection) - { - for (int i = 0; i < collection.Count; i++) - { - if (IsValidRestriction(particle, (XmlSchemaParticle)collection[i])) - return i; - } - return -1; - } - - private bool IsParticleEmptiable(XmlSchemaParticle particle) - { - decimal minOccurs, maxOccurs; - CalculateEffectiveTotalRange(particle, out minOccurs, out maxOccurs); - return minOccurs == decimal.Zero; - } - - private void CalculateEffectiveTotalRange(XmlSchemaParticle particle, out decimal minOccurs, out decimal maxOccurs) - { - if (particle is XmlSchemaElement || particle is XmlSchemaAny) - { - minOccurs = particle.MinOccurs; - maxOccurs = particle.MaxOccurs; - } - else if (particle is XmlSchemaChoice) - { - if (((XmlSchemaChoice)particle).Items.Count == 0) - { - minOccurs = maxOccurs = decimal.Zero; - } - else - { - minOccurs = decimal.MaxValue; - maxOccurs = decimal.Zero; - XmlSchemaChoice choice = (XmlSchemaChoice)particle; - for (int i = 0; i < choice.Items.Count; ++i) - { - decimal min, max; - CalculateEffectiveTotalRange((XmlSchemaParticle)choice.Items[i], out min, out max); - if (min < minOccurs) - { - minOccurs = min; - } - if (max > maxOccurs) - { - maxOccurs = max; - } - } - minOccurs *= particle.MinOccurs; - if (maxOccurs != decimal.MaxValue) - { - if (particle.MaxOccurs == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs *= particle.MaxOccurs; - } - } - } - else - { - XmlSchemaObjectCollection collection = ((XmlSchemaGroupBase)particle).Items; - if (collection.Count == 0) - { - minOccurs = maxOccurs = decimal.Zero; - } - else - { - minOccurs = 0; - maxOccurs = 0; - for (int i = 0; i < collection.Count; ++i) - { - decimal min, max; - CalculateEffectiveTotalRange((XmlSchemaParticle)collection[i], out min, out max); - minOccurs += min; - if (maxOccurs != decimal.MaxValue) - { - if (max == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs += max; - } - } - minOccurs *= particle.MinOccurs; - if (maxOccurs != decimal.MaxValue) - { - if (particle.MaxOccurs == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs *= particle.MaxOccurs; - } - } - } - } - - private void PushComplexType(XmlSchemaComplexType complexType) - { - _complexTypeStack.Push(complexType); - } - - private XmlSchemaContentType GetSchemaContentType(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaParticle particle) - { - if ((complexContent != null && complexContent.IsMixed) || - (complexContent == null && complexType.IsMixed)) - { - return XmlSchemaContentType.Mixed; - } - else if (particle != null && !particle.IsEmpty) - { - return XmlSchemaContentType.ElementOnly; - } - else - { - return XmlSchemaContentType.Empty; - } - } - - private void CompileAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - if (attributeGroup.IsProcessing) - { - SendValidationEvent(ResXml.Sch_AttributeGroupCircularRef, attributeGroup); - return; - } - if (attributeGroup.AttributeUses.Count > 0) - {// already checked - return; - } - attributeGroup.IsProcessing = true; - XmlSchemaAnyAttribute anyAttribute = attributeGroup.AnyAttribute; - for (int i = 0; i < attributeGroup.Attributes.Count; ++i) - { - XmlSchemaAttribute attribute = attributeGroup.Attributes[i] as XmlSchemaAttribute; - if (attribute != null) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - CompileAttribute(attribute); - } - if (attributeGroup.AttributeUses[attribute.QualifiedName] == null) - { - attributeGroup.AttributeUses.Add(attribute.QualifiedName, attribute); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attribute); - } - } - else - { // XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributeGroup.Attributes[i]; - XmlSchemaAttributeGroup attributeGroupResolved; - if (attributeGroup.Redefined != null && attributeGroupRef.RefName == attributeGroup.Redefined.QualifiedName) - { - attributeGroupResolved = (XmlSchemaAttributeGroup)attributeGroup.Redefined; - } - else - { - attributeGroupResolved = (XmlSchemaAttributeGroup)_schema.AttributeGroups[attributeGroupRef.RefName]; - } - if (attributeGroupResolved != null) - { - CompileAttributeGroup(attributeGroupResolved); - foreach (XmlSchemaAttribute attributeValue in attributeGroupResolved.AttributeUses.Values) - { - if (attributeGroup.AttributeUses[attributeValue.QualifiedName] == null) - { - attributeGroup.AttributeUses.Add(attributeValue.QualifiedName, attributeValue); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attributeValue.QualifiedName.ToString(), attributeValue); - } - } - anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroupResolved.AttributeWildcard); - } - else - { - SendValidationEvent(ResXml.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef); - } - } - } - attributeGroup.AttributeWildcard = anyAttribute; - attributeGroup.IsProcessing = false; - } - - private void CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy) - { - XmlSchemaAnyAttribute baseAttributeWildcard = baseType != null ? baseType.AttributeWildcard : null; - for (int i = 0; i < attributes.Count; ++i) - { - XmlSchemaAttribute attribute = attributes[i] as XmlSchemaAttribute; - if (attribute != null) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - CompileAttribute(attribute); - } - if (attribute.Use != XmlSchemaUse.Prohibited || - (attribute.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) - { - if (derivedType.AttributeUses[attribute.QualifiedName] == null) - { - derivedType.AttributeUses.Add(attribute.QualifiedName, attribute); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attribute); - } - } - else - { - SendValidationEvent(ResXml.Sch_AttributeIgnored, attribute.QualifiedName.ToString(), attribute, XmlSeverityType.Warning); - } - } - else - { // is XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributes[i]; - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)_schema.AttributeGroups[attributeGroupRef.RefName]; - if (attributeGroup != null) - { - CompileAttributeGroup(attributeGroup); - foreach (XmlSchemaAttribute attributeValue in attributeGroup.AttributeUses.Values) - { - if (attributeValue.Use != XmlSchemaUse.Prohibited || - (attributeValue.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) - { - if (derivedType.AttributeUses[attributeValue.QualifiedName] == null) - { - derivedType.AttributeUses.Add(attributeValue.QualifiedName, attributeValue); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attributeValue.QualifiedName.ToString(), attributeGroupRef); - } - } - else - { - SendValidationEvent(ResXml.Sch_AttributeIgnored, attributeValue.QualifiedName.ToString(), attributeValue, XmlSeverityType.Warning); - } - } - anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroup.AttributeWildcard); - } - else - { - SendValidationEvent(ResXml.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef); - } - } - } - - // check derivation rules - if (baseType != null) - { - if (derivedBy == XmlSchemaDerivationMethod.Extension) - { - derivedType.SetAttributeWildcard(CompileAnyAttributeUnion(anyAttribute, baseAttributeWildcard)); - foreach (XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) - { - XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName]; - if (attribute != null) - { - Debug.Assert(attribute.Use != XmlSchemaUse.Prohibited); - if (attribute.AttributeSchemaType != attributeBase.AttributeSchemaType || attributeBase.Use == XmlSchemaUse.Prohibited) - { - SendValidationEvent(ResXml.Sch_InvalidAttributeExtension, attribute); - } - } - else - { - derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase); - } - } - } - else - { // derivedBy == XmlSchemaDerivationMethod.Restriction - // Schema Component Constraint: Derivation Valid (Restriction, Complex) - if ((anyAttribute != null) && (baseAttributeWildcard == null || !XmlSchemaAnyAttribute.IsSubset(anyAttribute, baseAttributeWildcard))) - { - SendValidationEvent(ResXml.Sch_InvalidAnyAttributeRestriction, derivedType); - } - else - { - derivedType.SetAttributeWildcard(anyAttribute); //complete wildcard - } - - // Add form the base - foreach (XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) - { - XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName]; - if (attribute == null) - { - derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase); - } - else - { - if (attributeBase.Use == XmlSchemaUse.Prohibited && attribute.Use != XmlSchemaUse.Prohibited) - { -#if DEBUG - string position = string.Empty; - if (derivedType.SourceUri != null) - { - position = " in " + derivedType.SourceUri + "(" + derivedType.LineNumber + ", " + derivedType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType attributes restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpAttributes(baseType.AttributeUses, baseType.AttributeWildcard)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpAttributes(derivedType.AttributeUses, derivedType.AttributeWildcard)); -#endif - SendValidationEvent(ResXml.Sch_AttributeRestrictionProhibited, attribute); - } - else if (attribute.Use == XmlSchemaUse.Prohibited) - { - continue; - } - else if (attributeBase.AttributeSchemaType == null || attribute.AttributeSchemaType == null || !XmlSchemaType.IsDerivedFrom(attribute.AttributeSchemaType, attributeBase.AttributeSchemaType, XmlSchemaDerivationMethod.Empty)) - { - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalid, attribute); - } - } - } - - // Check additional ones are valid restriction of base's wildcard - foreach (XmlSchemaAttribute attribute in derivedType.AttributeUses.Values) - { - XmlSchemaAttribute attributeBase = (XmlSchemaAttribute)baseType.AttributeUses[attribute.QualifiedName]; - if (attributeBase != null) - { - continue; - } - if (baseAttributeWildcard == null || !baseAttributeWildcard.Allows(attribute.QualifiedName)) - { -#if DEBUG - string position = string.Empty; - if (derivedType.SourceUri != null) - { - position = " in " + derivedType.SourceUri + "(" + derivedType.LineNumber + ", " + derivedType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType attributes restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpAttributes(baseType.AttributeUses, baseType.AttributeWildcard)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpAttributes(derivedType.AttributeUses, derivedType.AttributeWildcard)); -#endif - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalidFromWildcard, attribute); - } - } - } - } - else - { - derivedType.SetAttributeWildcard(anyAttribute); - } - } - - -#if DEBUG - private string DumpAttributes(XmlSchemaObjectTable attributeUses, XmlSchemaAnyAttribute attributeWildcard) - { - StringBuilder sb = new StringBuilder(); - sb.Append("["); - bool first = true; - foreach (XmlSchemaAttribute attribute in attributeUses.Values) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - if (first) - { - first = false; - } - else - { - sb.Append(" "); - } - sb.Append(attribute.QualifiedName.Name); - if (attribute.Use == XmlSchemaUse.Optional) - { - sb.Append("?"); - } - } - } - if (attributeWildcard != null) - { - if (attributeUses.Count != 0) - { - sb.Append(" "); - } - sb.Append("<"); - sb.Append(attributeWildcard.NamespaceList.ToString()); - sb.Append(">"); - } - sb.Append("] - ["); - first = true; - foreach (XmlSchemaAttribute attribute in attributeUses.Values) - { - if (attribute.Use == XmlSchemaUse.Prohibited) - { - if (first) - { - first = false; - } - else - { - sb.Append(" "); - } - sb.Append(attribute.QualifiedName.Name); - } - } - sb.Append("]"); - return sb.ToString(); - } -#endif - - private XmlSchemaAnyAttribute CompileAnyAttributeUnion(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b) - { - if (a == null) - { - return b; - } - else if (b == null) - { - return a; - } - else - { - XmlSchemaAnyAttribute attribute = XmlSchemaAnyAttribute.Union(a, b, true); //true for v1Compat - if (attribute == null) - { - SendValidationEvent(ResXml.Sch_UnexpressibleAnyAttribute, a); - } - return attribute; - } - } - - private XmlSchemaAnyAttribute CompileAnyAttributeIntersection(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b) - { - if (a == null) - { - return b; - } - else if (b == null) - { - return a; - } - else - { - XmlSchemaAnyAttribute attribute = XmlSchemaAnyAttribute.Intersection(a, b, true); //true for v1Compat - if (attribute == null) - { - SendValidationEvent(ResXml.Sch_UnexpressibleAnyAttribute, a); - } - return attribute; - } - } - - private void CompileAttribute(XmlSchemaAttribute xa) - { - if (xa.IsProcessing) - { - SendValidationEvent(ResXml.Sch_AttributeCircularRef, xa); - return; - } - if (xa.AttDef != null) - { //already compiled? - return; - } - xa.IsProcessing = true; - SchemaAttDef decl = null; - try - { - if (!xa.RefName.IsEmpty) - { - XmlSchemaAttribute a = (XmlSchemaAttribute)_schema.Attributes[xa.RefName]; - if (a == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa); - } - CompileAttribute(a); - if (a.AttDef == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa); - } - decl = a.AttDef.Clone(); - if (decl.Datatype != null) - { - if (a.FixedValue != null) - { - if (xa.DefaultValue != null) - { - throw new XmlSchemaException(ResXml.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa); - } - else if (xa.FixedValue != null) - { - if (xa.FixedValue != a.FixedValue) - { - throw new XmlSchemaException(ResXml.Sch_FixedInRef, xa.RefName.ToString(), xa); - } - } - else - { - decl.Presence = SchemaDeclBase.Use.Fixed; - decl.DefaultValueRaw = decl.DefaultValueExpanded = a.FixedValue; - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true); - } - } - else if (a.DefaultValue != null) - { - if (xa.DefaultValue == null && xa.FixedValue == null) - { - decl.Presence = SchemaDeclBase.Use.Default; - decl.DefaultValueRaw = decl.DefaultValueExpanded = a.DefaultValue; - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true); - } - } - } - xa.SetAttributeType(a.AttributeSchemaType); - } - else - { - decl = new SchemaAttDef(xa.QualifiedName); - if (xa.SchemaType != null) - { - CompileSimpleType(xa.SchemaType); - xa.SetAttributeType(xa.SchemaType); - decl.SchemaType = xa.SchemaType; - decl.Datatype = xa.SchemaType.Datatype; - } - else if (!xa.SchemaTypeName.IsEmpty) - { - XmlSchemaSimpleType simpleType = GetSimpleType(xa.SchemaTypeName); - if (simpleType != null) - { - xa.SetAttributeType(simpleType); - decl.Datatype = simpleType.Datatype; - decl.SchemaType = simpleType; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa); - } - } - else - { - decl.SchemaType = DatatypeImplementation.AnySimpleType; - decl.Datatype = DatatypeImplementation.AnySimpleType.Datatype; - xa.SetAttributeType(DatatypeImplementation.AnySimpleType); - } - } - if (decl.Datatype != null) - { - decl.Datatype.VerifySchemaValid(_schema.Notations, xa); - } - if (xa.DefaultValue != null || xa.FixedValue != null) - { - if (xa.DefaultValue != null) - { - decl.Presence = SchemaDeclBase.Use.Default; - decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.DefaultValue; - } - else - { - decl.Presence = SchemaDeclBase.Use.Fixed; - decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.FixedValue; - } - if (decl.Datatype != null) - { - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true); - } - } - else - { - switch (xa.Use) - { - case XmlSchemaUse.None: - case XmlSchemaUse.Optional: - decl.Presence = SchemaDeclBase.Use.Implied; - break; - case XmlSchemaUse.Required: - decl.Presence = SchemaDeclBase.Use.Required; - break; - case XmlSchemaUse.Prohibited: - break; - } - } - decl.SchemaAttribute = xa; //So this is available for PSVI - xa.AttDef = decl; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xa); - } - SendValidationEvent(e); - xa.AttDef = SchemaAttDef.Empty; - } - finally - { - xa.IsProcessing = false; - } - } - - private void CompileIdentityConstraint(XmlSchemaIdentityConstraint xi) - { - if (xi.IsProcessing) - { - xi.CompiledConstraint = CompiledIdentityConstraint.Empty; - SendValidationEvent(ResXml.Sch_IdentityConstraintCircularRef, xi); - return; - } - - if (xi.CompiledConstraint != null) - { - return; - } - - xi.IsProcessing = true; - CompiledIdentityConstraint compic = null; - try - { - SchemaNamespaceManager xnmgr = new SchemaNamespaceManager(xi); - compic = new CompiledIdentityConstraint(xi, xnmgr); - if (xi is XmlSchemaKeyref) - { - XmlSchemaIdentityConstraint ic = (XmlSchemaIdentityConstraint)_schema.IdentityConstraints[((XmlSchemaKeyref)xi).Refer]; - if (ic == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredIdentityConstraint, ((XmlSchemaKeyref)xi).Refer.ToString(), xi); - } - CompileIdentityConstraint(ic); - if (ic.CompiledConstraint == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidIdentityConstraint, ((XmlSchemaKeyref)xi).Refer.ToString(), xi); - } - // keyref has the different cardinality with the key it referred - if (ic.Fields.Count != xi.Fields.Count) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidCardin, xi.QualifiedName.ToString(), xi); - } - // keyref can only refer to key/unique - if (ic.CompiledConstraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - { - throw new XmlSchemaException(ResXml.Sch_ReftoKeyref, xi.QualifiedName.ToString(), xi); - } - } - xi.CompiledConstraint = compic; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xi); - } - SendValidationEvent(e); - xi.CompiledConstraint = CompiledIdentityConstraint.Empty; - // empty is better than null here, stop quickly when circle referencing - } - finally - { - xi.IsProcessing = false; - } - } - - private void CompileElement(XmlSchemaElement xe) - { - if (xe.IsProcessing) - { - SendValidationEvent(ResXml.Sch_ElementCircularRef, xe); - return; - } - if (xe.ElementDecl != null) - { - return; - } - xe.IsProcessing = true; - SchemaElementDecl decl = null; - try - { - if (!xe.RefName.IsEmpty) - { - XmlSchemaElement e = (XmlSchemaElement)_schema.Elements[xe.RefName]; - if (e == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredElement, xe.RefName.ToString(), xe); - } - CompileElement(e); - if (e.ElementDecl == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidElement, xe.RefName.ToString(), xe); - } - xe.SetElementType(e.ElementSchemaType); - decl = e.ElementDecl.Clone(); - } - else - { - if (xe.SchemaType != null) - { - xe.SetElementType(xe.SchemaType); - } - else if (!xe.SchemaTypeName.IsEmpty) - { - xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName)); - if (xe.ElementSchemaType == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe); - } - } - else if (!xe.SubstitutionGroup.IsEmpty) - { - XmlSchemaElement examplar = (XmlSchemaElement)_schema.Elements[xe.SubstitutionGroup]; - if (examplar == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name.ToString(), xe); - } - if (examplar.IsProcessing) - { //Circular subst group; already detected by now - return; - } - CompileElement(examplar); - if (examplar.ElementDecl == null) - { //If head is invalid, fall back to AnyType - xe.SetElementType(XmlSchemaComplexType.AnyType); - decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone(); - } - else - { - xe.SetElementType(examplar.ElementSchemaType); - decl = examplar.ElementDecl.Clone(); - } - } - else - { - xe.SetElementType(XmlSchemaComplexType.AnyType); - decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone(); - } - - if (decl == null) - { - Debug.Assert(xe.ElementSchemaType != null); - if (xe.ElementSchemaType is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)xe.ElementSchemaType; - CompileComplexType(complexType); - if (complexType.ElementDecl != null) - { - decl = complexType.ElementDecl.Clone(); - // decl.LocalElements = complexType.LocalElementDecls; - } - } - else if (xe.ElementSchemaType is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)xe.ElementSchemaType; - CompileSimpleType(simpleType); - if (simpleType.ElementDecl != null) - { - decl = simpleType.ElementDecl.Clone(); - } - } - } - decl.Name = xe.QualifiedName; - decl.IsAbstract = xe.IsAbstract; - XmlSchemaComplexType ct = xe.ElementSchemaType as XmlSchemaComplexType; - if (ct != null) - { - decl.IsAbstract |= ct.IsAbstract; - } - decl.IsNillable = xe.IsNillable; - decl.Block |= xe.BlockResolved; - } - if (decl.Datatype != null) - { - decl.Datatype.VerifySchemaValid(_schema.Notations, xe); - } - - if (xe.DefaultValue != null || xe.FixedValue != null) - { - if (decl.ContentValidator != null) - { - if (decl.ContentValidator.ContentType == XmlSchemaContentType.TextOnly) - { - if (xe.DefaultValue != null) - { - decl.Presence = SchemaDeclBase.Use.Default; - decl.DefaultValueRaw = xe.DefaultValue; - } - else - { - decl.Presence = SchemaDeclBase.Use.Fixed; - decl.DefaultValueRaw = xe.FixedValue; - } - if (decl.Datatype != null) - { - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xe), true); - } - } - else if (decl.ContentValidator.ContentType != XmlSchemaContentType.Mixed || !decl.ContentValidator.IsEmptiable) - { - throw new XmlSchemaException(ResXml.Sch_ElementCannotHaveValue, xe); - } - } - } - if (xe.HasConstraints) - { - XmlSchemaObjectCollection constraints = xe.Constraints; - CompiledIdentityConstraint[] compiledConstraints = new CompiledIdentityConstraint[constraints.Count]; - int idx = 0; - for (int i = 0; i < constraints.Count; ++i) - { - XmlSchemaIdentityConstraint constraint = (XmlSchemaIdentityConstraint)constraints[i]; - CompileIdentityConstraint(constraint); - compiledConstraints[idx++] = constraint.CompiledConstraint; - } - decl.Constraints = compiledConstraints; - } - decl.SchemaElement = xe; //So this is available for PSVI - xe.ElementDecl = decl; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xe); - } - SendValidationEvent(e); - xe.ElementDecl = SchemaElementDecl.Empty; - } - finally - { - xe.IsProcessing = false; - } - } - - private ContentValidator CompileComplexContent(XmlSchemaComplexType complexType) - { - if (complexType.ContentType == XmlSchemaContentType.Empty) - { - return ContentValidator.Empty; - } - else if (complexType.ContentType == XmlSchemaContentType.TextOnly) - { - return ContentValidator.TextOnly; - } - XmlSchemaParticle particle = complexType.ContentTypeParticle; - if (particle == null || particle == XmlSchemaParticle.Empty) - { - if (complexType.ContentType == XmlSchemaContentType.ElementOnly) - { - return ContentValidator.Empty; - } - else - { - return ContentValidator.Mixed; - } - } - PushComplexType(complexType); - if (particle is XmlSchemaAll) - { - XmlSchemaAll all = (XmlSchemaAll)particle; - AllElementsContentValidator contentValidator = new AllElementsContentValidator(complexType.ContentType, all.Items.Count, all.MinOccurs == decimal.Zero); - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i]; - if (!contentValidator.AddElement(localElement.QualifiedName, localElement, localElement.MinOccurs == decimal.Zero)) - { - SendValidationEvent(ResXml.Sch_DupElement, localElement.QualifiedName.ToString(), localElement); - } - } - return contentValidator; - } - else - { - ParticleContentValidator contentValidator = new ParticleContentValidator(complexType.ContentType); -#if DEBUG - string name = complexType.Name != null ? complexType.Name : string.Empty; - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceVerbose, "CompileComplexContent: "+ name + DumpContentModel(particle)); -#endif - try - { - contentValidator.Start(); - BuildParticleContentModel(contentValidator, particle); - return contentValidator.Finish(_compileContentModel); - } - catch (UpaException e) - { - if (e.Particle1 is XmlSchemaElement) - { - if (e.Particle2 is XmlSchemaElement) - { - SendValidationEvent(ResXml.Sch_NonDeterministic, ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaElement)e.Particle2); - } - else - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle2).NamespaceList.ToString(), ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaAny)e.Particle2); - } - } - else - { - if (e.Particle2 is XmlSchemaElement) - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle1).NamespaceList.ToString(), ((XmlSchemaElement)e.Particle2).QualifiedName.ToString(), (XmlSchemaAny)e.Particle1); - } - else - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyAny, ((XmlSchemaAny)e.Particle1).NamespaceList.ToString(), ((XmlSchemaAny)e.Particle2).NamespaceList.ToString(), (XmlSchemaAny)e.Particle1); - } - } - return XmlSchemaComplexType.AnyTypeContentValidator; - } - catch (NotSupportedException) - { - SendValidationEvent(ResXml.Sch_ComplexContentModel, complexType, XmlSeverityType.Warning); - return XmlSchemaComplexType.AnyTypeContentValidator; - } - } - } - -#if DEBUG - private string DumpContentModel(XmlSchemaParticle particle) - { - StringBuilder sb = new StringBuilder(); - DumpContentModelTo(sb, particle); - return sb.ToString(); - } - - private void DumpContentModelTo(StringBuilder sb, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - sb.Append(((XmlSchemaElement)particle).QualifiedName); - } - else if (particle is XmlSchemaAny) - { - sb.Append("<"); - sb.Append(((XmlSchemaAny)particle).NamespaceList.ToString()); - sb.Append(">"); - } - else if (particle is XmlSchemaAll) - { - XmlSchemaAll all = (XmlSchemaAll)particle; - sb.Append("["); - bool first = true; - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i]; - if (first) - { - first = false; - } - else - { - sb.Append(", "); - } - sb.Append(localElement.QualifiedName.Name); - if (localElement.MinOccurs == decimal.Zero) - { - sb.Append("?"); - } - } - sb.Append("]"); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaGroupBase gb = (XmlSchemaGroupBase)particle; - sb.Append("("); - string delimeter = (particle is XmlSchemaChoice) ? " | " : ", "; - bool first = true; - for (int i = 0; i < gb.Items.Count; ++i) - { - if (first) - { - first = false; - } - else - { - sb.Append(delimeter); - } - DumpContentModelTo(sb, (XmlSchemaParticle)gb.Items[i]); - } - sb.Append(")"); - } - else - { - Debug.Assert(particle == XmlSchemaParticle.Empty); - sb.Append("<>"); - } - if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One) - { - // nothing - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One) - { - sb.Append("?"); - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append("*"); - } - else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append("+"); - } - else - { - sb.Append("{" + particle.MinOccurs.ToString(NumberFormatInfo.InvariantInfo) + ", " + particle.MaxOccurs.ToString(NumberFormatInfo.InvariantInfo) + "}"); - } - } -#endif - - private void BuildParticleContentModel(ParticleContentValidator contentValidator, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - XmlSchemaElement element = (XmlSchemaElement)particle; - contentValidator.AddName(element.QualifiedName, element); - } - else if (particle is XmlSchemaAny) - { - XmlSchemaAny any = (XmlSchemaAny)particle; - contentValidator.AddNamespaceList(any.NamespaceList, any); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - bool isChoice = particle is XmlSchemaChoice; - contentValidator.OpenGroup(); - bool first = true; - for (int i = 0; i < particles.Count; ++i) - { - XmlSchemaParticle p = (XmlSchemaParticle)particles[i]; - Debug.Assert(!p.IsEmpty); - if (first) - { - first = false; - } - else if (isChoice) - { - contentValidator.AddChoice(); - } - else - { - contentValidator.AddSequence(); - } - BuildParticleContentModel(contentValidator, p); - } - contentValidator.CloseGroup(); - } - else - { - Debug.Assert(false); - } - if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One) - { - // nothing - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One) - { - contentValidator.AddQMark(); - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue) - { - contentValidator.AddStar(); - } - else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue) - { - contentValidator.AddPlus(); - } - else - { - contentValidator.AddLeafRange(particle.MinOccurs, particle.MaxOccurs); - } - } - - private void CompileParticleElements(XmlSchemaComplexType complexType, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - XmlSchemaElement localElement = (XmlSchemaElement)particle; - CompileElement(localElement); - if (complexType.LocalElements[localElement.QualifiedName] == null) - { - complexType.LocalElements.Add(localElement.QualifiedName, localElement); - } - else - { - XmlSchemaElement element = (XmlSchemaElement)complexType.LocalElements[localElement.QualifiedName]; - if (element.ElementSchemaType != localElement.ElementSchemaType) - { - SendValidationEvent(ResXml.Sch_ElementTypeCollision, particle); - } - } - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - for (int i = 0; i < particles.Count; ++i) - { - CompileParticleElements(complexType, (XmlSchemaParticle)particles[i]); - } - } - } - - private void CompileCompexTypeElements(XmlSchemaComplexType complexType) - { - if (complexType.IsProcessing) - { - SendValidationEvent(ResXml.Sch_TypeCircularRef, complexType); - return; - } - complexType.IsProcessing = true; - if (complexType.ContentTypeParticle != XmlSchemaParticle.Empty) - { - CompileParticleElements(complexType, complexType.ContentTypeParticle); - } - complexType.IsProcessing = false; - } - - private XmlSchemaSimpleType GetSimpleType(XmlQualifiedName name) - { - XmlSchemaSimpleType type = _schema.SchemaTypes[name] as XmlSchemaSimpleType; - if (type != null) - { - CompileSimpleType(type); - } - else - { - type = DatatypeImplementation.GetSimpleTypeFromXsdType(name); - //Re-assign datatype impl for V1Compat - if (type != null) - { - if (type.TypeCode == XmlTypeCode.NormalizedString) - { - type = DatatypeImplementation.GetNormalizedStringTypeV1Compat(); - } - else if (type.TypeCode == XmlTypeCode.Token) - { - type = DatatypeImplementation.GetTokenTypeV1Compat(); - } - } - } - return type; - } - - private XmlSchemaComplexType GetComplexType(XmlQualifiedName name) - { - XmlSchemaComplexType type = _schema.SchemaTypes[name] as XmlSchemaComplexType; - if (type != null) - { - CompileComplexType(type); - } - return type; - } - - private XmlSchemaType GetAnySchemaType(XmlQualifiedName name) - { - XmlSchemaType type = (XmlSchemaType)_schema.SchemaTypes[name]; - if (type != null) - { - if (type is XmlSchemaComplexType) - { - CompileComplexType((XmlSchemaComplexType)type); - } - else - { - CompileSimpleType((XmlSchemaSimpleType)type); - } - return type; - } - else - { //Its is a built-in simpleType - XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(name); - return simpleType; - } - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionPreprocessor.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionPreprocessor.cs deleted file mode 100644 index 64abdfff552..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaCollectionPreprocessor.cs +++ /dev/null @@ -1,1834 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Diagnostics; - using System.Runtime.Versioning; - -#pragma warning disable 618 - internal sealed class SchemaCollectionPreprocessor : BaseProcessor - { - private enum Compositor - { - Root, - Include, - Import - }; - - private XmlSchema _schema; - private string _targetNamespace; - private bool _buildinIncluded = false; - private XmlSchemaForm _elementFormDefault; - private XmlSchemaForm _attributeFormDefault; - private XmlSchemaDerivationMethod _blockDefault; - private XmlSchemaDerivationMethod _finalDefault; - //Dictionary schemaLocations; - private Hashtable _schemaLocations; - private Hashtable _referenceNamespaces; - - private string _xmlns; - private const XmlSchemaDerivationMethod schemaBlockDefaultAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Substitution; - private const XmlSchemaDerivationMethod schemaFinalDefaultAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union; - private const XmlSchemaDerivationMethod elementBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Substitution; - private const XmlSchemaDerivationMethod elementFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private const XmlSchemaDerivationMethod simpleTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union; - private const XmlSchemaDerivationMethod complexTypeBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private const XmlSchemaDerivationMethod complexTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - - private XmlResolver _xmlResolver = null; - - public SchemaCollectionPreprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler) - : base(nameTable, schemaNames, eventHandler) - { - } - - public bool Execute(XmlSchema schema, string targetNamespace, bool loadExternals, XmlSchemaCollection xsc) - { - _schema = schema; - _xmlns = NameTable.Add("xmlns"); - - Cleanup(schema); - if (loadExternals && _xmlResolver != null) - { - _schemaLocations = new Hashtable(); //new Dictionary(); - if (schema.BaseUri != null) - { - _schemaLocations.Add(schema.BaseUri, schema.BaseUri); - } - LoadExternals(schema, xsc); - } - ValidateIdAttribute(schema); - Preprocess(schema, targetNamespace, Compositor.Root); - if (!HasErrors) - { - schema.IsPreprocessed = true; - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - if (include.Schema != null) - { - include.Schema.IsPreprocessed = true; - } - } - } - return !HasErrors; - } - - private void Cleanup(XmlSchema schema) - { - if (schema.IsProcessing) - { - return; - } - schema.IsProcessing = true; - - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - - if (include.Schema != null) - { - Cleanup(include.Schema); - } - - if (include is XmlSchemaRedefine) - { - XmlSchemaRedefine rdef = include as XmlSchemaRedefine; - rdef.AttributeGroups.Clear(); - rdef.Groups.Clear(); - rdef.SchemaTypes.Clear(); - } - } - - schema.Attributes.Clear(); - schema.AttributeGroups.Clear(); - schema.SchemaTypes.Clear(); - schema.Elements.Clear(); - schema.Groups.Clear(); - schema.Notations.Clear(); - schema.Ids.Clear(); - schema.IdentityConstraints.Clear(); - - schema.IsProcessing = false; - } - - internal XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - } - } - - // SxS: This method reads resource names from the source documents and does not return any resources to the caller - // It's fine to disable the SxS warning - - - private void LoadExternals(XmlSchema schema, XmlSchemaCollection xsc) - { - if (schema.IsProcessing) - { - return; - } - schema.IsProcessing = true; - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - Uri includeLocation = null; - //CASE 1: If the Schema object of the include has been set - if (include.Schema != null) - { - // already loaded - if (include is XmlSchemaImport && ((XmlSchemaImport)include).Namespace == XmlReservedNs.NsXml) - { - _buildinIncluded = true; - } - else - { - includeLocation = include.BaseUri; - if (includeLocation != null && _schemaLocations[includeLocation] == null) - { - _schemaLocations.Add(includeLocation, includeLocation); - } - LoadExternals(include.Schema, xsc); - } - continue; - } - - //CASE 2: If the include has been already added to the schema collection directly - if (xsc != null && include is XmlSchemaImport) - { //Added for SchemaCollection compatibility - XmlSchemaImport import = (XmlSchemaImport)include; - string importNS = import.Namespace != null ? import.Namespace : string.Empty; - include.Schema = xsc[importNS]; //Fetch it from the collection - if (include.Schema != null) - { - include.Schema = include.Schema.Clone(); - if (include.Schema.BaseUri != null && _schemaLocations[include.Schema.BaseUri] == null) - { - _schemaLocations.Add(include.Schema.BaseUri, include.Schema.BaseUri); - } - //To avoid re-including components that were already included through a different path - Uri subUri = null; - for (int j = 0; j < include.Schema.Includes.Count; ++j) - { - XmlSchemaExternal subInc = (XmlSchemaExternal)include.Schema.Includes[j]; - if (subInc is XmlSchemaImport) - { - XmlSchemaImport subImp = (XmlSchemaImport)subInc; - subUri = subImp.BaseUri != null ? subImp.BaseUri : (subImp.Schema != null && subImp.Schema.BaseUri != null ? subImp.Schema.BaseUri : null); - if (subUri != null) - { - if (_schemaLocations[subUri] != null) - { - subImp.Schema = null; //So that the components are not included again - } - else - { //if its not there already, add it - _schemaLocations.Add(subUri, subUri); //The schema for that location is available - } - } - } - } - continue; - } - } - - //CASE 3: If the imported namespace is the XML namespace, load built-in schema - if (include is XmlSchemaImport && ((XmlSchemaImport)include).Namespace == XmlReservedNs.NsXml) - { - if (!_buildinIncluded) - { - _buildinIncluded = true; - include.Schema = Preprocessor.GetBuildInSchema(); - } - continue; - } - - //CASE4: Parse schema from the provided location - string schemaLocation = include.SchemaLocation; - if (schemaLocation == null) - { - continue; - } - - Uri ruri = ResolveSchemaLocationUri(schema, schemaLocation); - - if (ruri != null && _schemaLocations[ruri] == null) - { - Stream stream = GetSchemaEntity(ruri); - if (stream != null) - { - include.BaseUri = ruri; - _schemaLocations.Add(ruri, ruri); - XmlTextReader reader = new XmlTextReader(ruri.ToString(), stream, NameTable); - reader.XmlResolver = _xmlResolver; - try - { - Parser parser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); - parser.Parse(reader, null); - while (reader.Read()) ;// wellformness check - include.Schema = parser.XmlSchema; - LoadExternals(include.Schema, xsc); - } - catch (XmlSchemaException e) - { - SendValidationEventNoThrow(new XmlSchemaException(ResXml.Sch_CannotLoadSchema, new string[] { schemaLocation, e.Message }, e.SourceUri, e.LineNumber, e.LinePosition), XmlSeverityType.Error); - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_InvalidIncludeLocation, include, XmlSeverityType.Warning); - } - finally - { - reader.Close(); - } - } - else - { - SendValidationEvent(ResXml.Sch_InvalidIncludeLocation, include, XmlSeverityType.Warning); - } - } - } - schema.IsProcessing = false; - } - - - private void BuildRefNamespaces(XmlSchema schema) - { - _referenceNamespaces = new Hashtable(); - XmlSchemaImport import; - string ns; - - //Add XSD namespace - _referenceNamespaces.Add(XmlReservedNs.NsXs, XmlReservedNs.NsXs); - _referenceNamespaces.Add(string.Empty, string.Empty); - - for (int i = 0; i < schema.Includes.Count; ++i) - { - import = schema.Includes[i] as XmlSchemaImport; - if (import != null) - { - ns = import.Namespace; - if (ns != null && _referenceNamespaces[ns] == null) - _referenceNamespaces.Add(ns, ns); - } - } - - //Add the schema's targetnamespace - if (schema.TargetNamespace != null && _referenceNamespaces[schema.TargetNamespace] == null) - _referenceNamespaces.Add(schema.TargetNamespace, schema.TargetNamespace); - } - - private void Preprocess(XmlSchema schema, string targetNamespace, Compositor compositor) - { - if (schema.IsProcessing) - { - return; - } - schema.IsProcessing = true; - string tns = schema.TargetNamespace; - if (tns != null) - { - schema.TargetNamespace = tns = NameTable.Add(tns); - if (tns.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidTargetNamespaceAttribute, schema); - } - else - { - try - { - XmlConvert.ToUri(tns); // can throw - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidNamespace, schema.TargetNamespace, schema); - } - } - } - - if (schema.Version != null) - { - try - { - XmlConvert.VerifyTOKEN(schema.Version); // can throw - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_AttributeValueDataType, "version", schema); - } - } - switch (compositor) - { - case Compositor.Root: - if (targetNamespace == null && schema.TargetNamespace != null) - { // not specified - targetNamespace = schema.TargetNamespace; - } - else if (schema.TargetNamespace == null && targetNamespace != null && targetNamespace.Length == 0) - { // no namespace schema - targetNamespace = null; - } - if (targetNamespace != schema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceEx, targetNamespace, schema.TargetNamespace, schema); - } - break; - case Compositor.Import: - if (targetNamespace != schema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceImport, targetNamespace, schema.TargetNamespace, schema); - } - break; - case Compositor.Include: - if (schema.TargetNamespace != null) - { - if (targetNamespace != schema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_MismatchTargetNamespaceInclude, targetNamespace, schema.TargetNamespace, schema); - } - } - break; - } - - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - SetParent(include, schema); - PreprocessAnnotation(include); - - string loc = include.SchemaLocation; - if (loc != null) - { - try - { - XmlConvert.ToUri(loc); // can throw - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidSchemaLocation, loc, include); - } - } - else if ((include is XmlSchemaRedefine || include is XmlSchemaInclude) && include.Schema == null) - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "schemaLocation", include); - } - if (include.Schema != null) - { - if (include is XmlSchemaRedefine) - { - Preprocess(include.Schema, schema.TargetNamespace, Compositor.Include); - } - else if (include is XmlSchemaImport) - { - if (((XmlSchemaImport)include).Namespace == null && schema.TargetNamespace == null) - { - SendValidationEvent(ResXml.Sch_ImportTargetNamespaceNull, include); - } - else if (((XmlSchemaImport)include).Namespace == schema.TargetNamespace) - { - SendValidationEvent(ResXml.Sch_ImportTargetNamespace, include); - } - Preprocess(include.Schema, ((XmlSchemaImport)include).Namespace, Compositor.Import); - } - else - { - Preprocess(include.Schema, schema.TargetNamespace, Compositor.Include); - } - } - else if (include is XmlSchemaImport) - { - string ns = ((XmlSchemaImport)include).Namespace; - if (ns != null) - { - if (ns.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidNamespaceAttribute, ns, include); - } - else - { - try - { - XmlConvert.ToUri(ns); //can throw - } - catch (FormatException) - { - SendValidationEvent(ResXml.Sch_InvalidNamespace, ns, include); - } - } - } - } - } - - //Begin processing the current schema passed to preprocess - //Build the namespaces that can be referenced in the current schema - BuildRefNamespaces(schema); - - _targetNamespace = targetNamespace == null ? string.Empty : targetNamespace; - - if (schema.BlockDefault == XmlSchemaDerivationMethod.All) - { - _blockDefault = XmlSchemaDerivationMethod.All; - } - else if (schema.BlockDefault == XmlSchemaDerivationMethod.None) - { - _blockDefault = XmlSchemaDerivationMethod.Empty; - } - else - { - if ((schema.BlockDefault & ~schemaBlockDefaultAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidBlockDefaultValue, schema); - } - _blockDefault = schema.BlockDefault & schemaBlockDefaultAllowed; - } - if (schema.FinalDefault == XmlSchemaDerivationMethod.All) - { - _finalDefault = XmlSchemaDerivationMethod.All; - } - else if (schema.FinalDefault == XmlSchemaDerivationMethod.None) - { - _finalDefault = XmlSchemaDerivationMethod.Empty; - } - else - { - if ((schema.FinalDefault & ~schemaFinalDefaultAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidFinalDefaultValue, schema); - } - _finalDefault = schema.FinalDefault & schemaFinalDefaultAllowed; - } - _elementFormDefault = schema.ElementFormDefault; - if (_elementFormDefault == XmlSchemaForm.None) - { - _elementFormDefault = XmlSchemaForm.Unqualified; - } - _attributeFormDefault = schema.AttributeFormDefault; - if (_attributeFormDefault == XmlSchemaForm.None) - { - _attributeFormDefault = XmlSchemaForm.Unqualified; - } - - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal include = (XmlSchemaExternal)schema.Includes[i]; - if (include is XmlSchemaRedefine) - { - XmlSchemaRedefine redefine = (XmlSchemaRedefine)include; - if (include.Schema != null) - { - PreprocessRedefine(redefine); - } - else - { - for (int j = 0; j < redefine.Items.Count; ++j) - { - if (!(redefine.Items[j] is XmlSchemaAnnotation)) - { - SendValidationEvent(ResXml.Sch_RedefineNoSchema, redefine); - break; - } - } - } - } - XmlSchema includedSchema = include.Schema; - if (includedSchema != null) - { - foreach (XmlSchemaElement element in includedSchema.Elements.Values) - { - AddToTable(schema.Elements, element.QualifiedName, element); - } - foreach (XmlSchemaAttribute attribute in includedSchema.Attributes.Values) - { - AddToTable(schema.Attributes, attribute.QualifiedName, attribute); - } - foreach (XmlSchemaGroup group in includedSchema.Groups.Values) - { - AddToTable(schema.Groups, group.QualifiedName, group); - } - foreach (XmlSchemaAttributeGroup attributeGroup in includedSchema.AttributeGroups.Values) - { - AddToTable(schema.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - } - foreach (XmlSchemaType type in includedSchema.SchemaTypes.Values) - { - AddToTable(schema.SchemaTypes, type.QualifiedName, type); - } - foreach (XmlSchemaNotation notation in includedSchema.Notations.Values) - { - AddToTable(schema.Notations, notation.QualifiedName, notation); - } - } - ValidateIdAttribute(include); - } - - List removeItemsList = new List(); - for (int i = 0; i < schema.Items.Count; ++i) - { - SetParent(schema.Items[i], schema); - XmlSchemaAttribute attribute = schema.Items[i] as XmlSchemaAttribute; - if (attribute != null) - { - PreprocessAttribute(attribute); - AddToTable(schema.Attributes, attribute.QualifiedName, attribute); - } - else if (schema.Items[i] is XmlSchemaAttributeGroup) - { - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)schema.Items[i]; - PreprocessAttributeGroup(attributeGroup); - AddToTable(schema.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - } - else if (schema.Items[i] is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)schema.Items[i]; - PreprocessComplexType(complexType, false); - AddToTable(schema.SchemaTypes, complexType.QualifiedName, complexType); - } - else if (schema.Items[i] is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)schema.Items[i]; - PreprocessSimpleType(simpleType, false); - AddToTable(schema.SchemaTypes, simpleType.QualifiedName, simpleType); - } - else if (schema.Items[i] is XmlSchemaElement) - { - XmlSchemaElement element = (XmlSchemaElement)schema.Items[i]; - PreprocessElement(element); - AddToTable(schema.Elements, element.QualifiedName, element); - } - else if (schema.Items[i] is XmlSchemaGroup) - { - XmlSchemaGroup group = (XmlSchemaGroup)schema.Items[i]; - PreprocessGroup(group); - AddToTable(schema.Groups, group.QualifiedName, group); - } - else if (schema.Items[i] is XmlSchemaNotation) - { - XmlSchemaNotation notation = (XmlSchemaNotation)schema.Items[i]; - PreprocessNotation(notation); - AddToTable(schema.Notations, notation.QualifiedName, notation); - } - else if (!(schema.Items[i] is XmlSchemaAnnotation)) - { - SendValidationEvent(ResXml.Sch_InvalidCollection, schema.Items[i]); - removeItemsList.Add(schema.Items[i]); - } - } - for (int i = 0; i < removeItemsList.Count; ++i) - { - schema.Items.Remove(removeItemsList[i]); - } - - schema.IsProcessing = false; - } - - private void PreprocessRedefine(XmlSchemaRedefine redefine) - { - for (int i = 0; i < redefine.Items.Count; ++i) - { - SetParent(redefine.Items[i], redefine); - XmlSchemaGroup group = redefine.Items[i] as XmlSchemaGroup; - if (group != null) - { - PreprocessGroup(group); - if (redefine.Groups[group.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_GroupDoubleRedefine, group); - } - else - { - AddToTable(redefine.Groups, group.QualifiedName, group); - group.Redefined = (XmlSchemaGroup)redefine.Schema.Groups[group.QualifiedName]; - if (group.Redefined != null) - { - CheckRefinedGroup(group); - } - else - { - SendValidationEvent(ResXml.Sch_GroupRedefineNotFound, group); - } - } - } - else if (redefine.Items[i] is XmlSchemaAttributeGroup) - { - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)redefine.Items[i]; - PreprocessAttributeGroup(attributeGroup); - if (redefine.AttributeGroups[attributeGroup.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_AttrGroupDoubleRedefine, attributeGroup); - } - else - { - AddToTable(redefine.AttributeGroups, attributeGroup.QualifiedName, attributeGroup); - attributeGroup.Redefined = (XmlSchemaAttributeGroup)redefine.Schema.AttributeGroups[attributeGroup.QualifiedName]; - if (attributeGroup.Redefined != null) - { - CheckRefinedAttributeGroup(attributeGroup); - } - else - { - SendValidationEvent(ResXml.Sch_AttrGroupRedefineNotFound, attributeGroup); - } - } - } - else if (redefine.Items[i] is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)redefine.Items[i]; - PreprocessComplexType(complexType, false); - if (redefine.SchemaTypes[complexType.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_ComplexTypeDoubleRedefine, complexType); - } - else - { - AddToTable(redefine.SchemaTypes, complexType.QualifiedName, complexType); - XmlSchemaType type = (XmlSchemaType)redefine.Schema.SchemaTypes[complexType.QualifiedName]; - if (type != null) - { - if (type is XmlSchemaComplexType) - { - complexType.Redefined = type; - CheckRefinedComplexType(complexType); - } - else - { - SendValidationEvent(ResXml.Sch_SimpleToComplexTypeRedefine, complexType); - } - } - else - { - SendValidationEvent(ResXml.Sch_ComplexTypeRedefineNotFound, complexType); - } - } - } - else if (redefine.Items[i] is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)redefine.Items[i]; - PreprocessSimpleType(simpleType, false); - if (redefine.SchemaTypes[simpleType.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_SimpleTypeDoubleRedefine, simpleType); - } - else - { - AddToTable(redefine.SchemaTypes, simpleType.QualifiedName, simpleType); - XmlSchemaType type = (XmlSchemaType)redefine.Schema.SchemaTypes[simpleType.QualifiedName]; - if (type != null) - { - if (type is XmlSchemaSimpleType) - { - simpleType.Redefined = type; - CheckRefinedSimpleType(simpleType); - } - else - { - SendValidationEvent(ResXml.Sch_ComplexToSimpleTypeRedefine, simpleType); - } - } - else - { - SendValidationEvent(ResXml.Sch_SimpleTypeRedefineNotFound, simpleType); - } - } - } - } - - foreach (DictionaryEntry entry in redefine.Groups) - { - redefine.Schema.Groups.Insert((XmlQualifiedName)entry.Key, (XmlSchemaObject)entry.Value); - } - foreach (DictionaryEntry entry in redefine.AttributeGroups) - { - redefine.Schema.AttributeGroups.Insert((XmlQualifiedName)entry.Key, (XmlSchemaObject)entry.Value); - } - foreach (DictionaryEntry entry in redefine.SchemaTypes) - { - redefine.Schema.SchemaTypes.Insert((XmlQualifiedName)entry.Key, (XmlSchemaObject)entry.Value); - } - } - - private int CountGroupSelfReference(XmlSchemaObjectCollection items, XmlQualifiedName name) - { - int count = 0; - for (int i = 0; i < items.Count; ++i) - { - XmlSchemaGroupRef groupRef = items[i] as XmlSchemaGroupRef; - if (groupRef != null) - { - if (groupRef.RefName == name) - { - if (groupRef.MinOccurs != decimal.One || groupRef.MaxOccurs != decimal.One) - { - SendValidationEvent(ResXml.Sch_MinMaxGroupRedefine, groupRef); - } - count++; - } - } - else if (items[i] is XmlSchemaGroupBase) - { - count += CountGroupSelfReference(((XmlSchemaGroupBase)items[i]).Items, name); - } - if (count > 1) - { - break; - } - } - return count; - } - - private void CheckRefinedGroup(XmlSchemaGroup group) - { - int count = 0; - if (group.Particle != null) - { - count = CountGroupSelfReference(group.Particle.Items, group.QualifiedName); - } - if (count > 1) - { - SendValidationEvent(ResXml.Sch_MultipleGroupSelfRef, group); - } - } - - private void CheckRefinedAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - int count = 0; - for (int i = 0; i < attributeGroup.Attributes.Count; ++i) - { - XmlSchemaAttributeGroupRef groupRef = attributeGroup.Attributes[i] as XmlSchemaAttributeGroupRef; - if (groupRef != null && groupRef.RefName == attributeGroup.QualifiedName) - { - count++; - } - } - if (count > 1) - { - SendValidationEvent(ResXml.Sch_MultipleAttrGroupSelfRef, attributeGroup); - } - } - - private void CheckRefinedSimpleType(XmlSchemaSimpleType stype) - { - if (stype.Content != null && stype.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)stype.Content; - if (restriction.BaseTypeName == stype.QualifiedName) - { - return; - } - } - SendValidationEvent(ResXml.Sch_InvalidTypeRedefine, stype); - } - - private void CheckRefinedComplexType(XmlSchemaComplexType ctype) - { - if (ctype.ContentModel != null) - { - XmlQualifiedName baseName; - if (ctype.ContentModel is XmlSchemaComplexContent) - { - XmlSchemaComplexContent content = (XmlSchemaComplexContent)ctype.ContentModel; - if (content.Content is XmlSchemaComplexContentRestriction) - { - baseName = ((XmlSchemaComplexContentRestriction)content.Content).BaseTypeName; - } - else - { - baseName = ((XmlSchemaComplexContentExtension)content.Content).BaseTypeName; - } - } - else - { - XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)ctype.ContentModel; - if (content.Content is XmlSchemaSimpleContentRestriction) - { - baseName = ((XmlSchemaSimpleContentRestriction)content.Content).BaseTypeName; - } - else - { - baseName = ((XmlSchemaSimpleContentExtension)content.Content).BaseTypeName; - } - } - if (baseName == ctype.QualifiedName) - { - return; - } - } - SendValidationEvent(ResXml.Sch_InvalidTypeRedefine, ctype); - } - - private void PreprocessAttribute(XmlSchemaAttribute attribute) - { - if (attribute.Name != null) - { - ValidateNameAttribute(attribute); - attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", attribute); - } - if (attribute.Use != XmlSchemaUse.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "use", attribute); - } - if (attribute.Form != XmlSchemaForm.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "form", attribute); - } - PreprocessAttributeContent(attribute); - ValidateIdAttribute(attribute); - } - - private void PreprocessLocalAttribute(XmlSchemaAttribute attribute) - { - if (attribute.Name != null) - { // name - ValidateNameAttribute(attribute); - PreprocessAttributeContent(attribute); - attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, (attribute.Form == XmlSchemaForm.Qualified || (attribute.Form == XmlSchemaForm.None && _attributeFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null)); - } - else - { // ref - PreprocessAnnotation(attribute); //set parent of annotation child of ref - if (attribute.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_AttributeNameRef, "???", attribute); - } - else - { - ValidateQNameAttribute(attribute, "ref", attribute.RefName); - } - if (!attribute.SchemaTypeName.IsEmpty || - attribute.SchemaType != null || - attribute.Form != XmlSchemaForm.None /*|| - attribute.DefaultValue != null || - attribute.FixedValue != null*/ - ) - { - SendValidationEvent(ResXml.Sch_InvalidAttributeRef, attribute); - } - attribute.SetQualifiedName(attribute.RefName); - } - ValidateIdAttribute(attribute); - } - - private void PreprocessAttributeContent(XmlSchemaAttribute attribute) - { - PreprocessAnnotation(attribute); - if (_schema.TargetNamespace == XmlReservedNs.NsXsi) - { - SendValidationEvent(ResXml.Sch_TargetNamespaceXsi, attribute); - } - if (!attribute.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "ref", attribute); - } - if (attribute.DefaultValue != null && attribute.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, attribute); - } - if (attribute.DefaultValue != null && attribute.Use != XmlSchemaUse.Optional && attribute.Use != XmlSchemaUse.None) - { - SendValidationEvent(ResXml.Sch_OptionalDefaultAttribute, attribute); - } - if (attribute.Name == _xmlns) - { - SendValidationEvent(ResXml.Sch_XmlNsAttribute, attribute); - } - if (attribute.SchemaType != null) - { - SetParent(attribute.SchemaType, attribute); - if (!attribute.SchemaTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_TypeMutualExclusive, attribute); - } - PreprocessSimpleType(attribute.SchemaType, true); - } - if (!attribute.SchemaTypeName.IsEmpty) - { - ValidateQNameAttribute(attribute, "type", attribute.SchemaTypeName); - } - } - - private void PreprocessAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - if (attributeGroup.Name != null) - { - ValidateNameAttribute(attributeGroup); - attributeGroup.SetQualifiedName(new XmlQualifiedName(attributeGroup.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", attributeGroup); - } - PreprocessAttributes(attributeGroup.Attributes, attributeGroup.AnyAttribute, attributeGroup); - PreprocessAnnotation(attributeGroup); - ValidateIdAttribute(attributeGroup); - } - - private void PreprocessElement(XmlSchemaElement element) - { - if (element.Name != null) - { - ValidateNameAttribute(element); - element.SetQualifiedName(new XmlQualifiedName(element.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", element); - } - PreprocessElementContent(element); - - if (element.Final == XmlSchemaDerivationMethod.All) - { - element.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (element.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - element.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - element.SetFinalResolved(_finalDefault & elementFinalAllowed); - } - } - else - { - if ((element.Final & ~elementFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidElementFinalValue, element); - } - element.SetFinalResolved(element.Final & elementFinalAllowed); - } - if (element.Form != XmlSchemaForm.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "form", element); - } - if (element.MinOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "minOccurs", element); - } - if (element.MaxOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "maxOccurs", element); - } - if (!element.SubstitutionGroup.IsEmpty) - { - ValidateQNameAttribute(element, "type", element.SubstitutionGroup); - } - ValidateIdAttribute(element); - } - - private void PreprocessLocalElement(XmlSchemaElement element) - { - if (element.Name != null) - { // name - ValidateNameAttribute(element); - PreprocessElementContent(element); - element.SetQualifiedName(new XmlQualifiedName(element.Name, (element.Form == XmlSchemaForm.Qualified || (element.Form == XmlSchemaForm.None && _elementFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null)); - } - else - { // ref - PreprocessAnnotation(element); //Check annotation child for ref and set parent - if (element.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ElementNameRef, element); - } - else - { - ValidateQNameAttribute(element, "ref", element.RefName); - } - if (!element.SchemaTypeName.IsEmpty || - element.IsAbstract || - element.Block != XmlSchemaDerivationMethod.None || - element.SchemaType != null || - element.HasConstraints || - element.DefaultValue != null || - element.Form != XmlSchemaForm.None || - element.FixedValue != null || - element.HasNillableAttribute) - { - SendValidationEvent(ResXml.Sch_InvalidElementRef, element); - } - if (element.DefaultValue != null && element.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, element); - } - element.SetQualifiedName(element.RefName); - } - if (element.MinOccurs > element.MaxOccurs) - { - element.MinOccurs = decimal.Zero; - SendValidationEvent(ResXml.Sch_MinGtMax, element); - } - if (element.IsAbstract) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "abstract", element); - } - if (element.Final != XmlSchemaDerivationMethod.None) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "final", element); - } - if (!element.SubstitutionGroup.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "substitutionGroup", element); - } - ValidateIdAttribute(element); - } - - private void PreprocessElementContent(XmlSchemaElement element) - { - PreprocessAnnotation(element); //Set parent for Annotation child of element - if (!element.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "ref", element); - } - if (element.Block == XmlSchemaDerivationMethod.All) - { - element.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else if (element.Block == XmlSchemaDerivationMethod.None) - { - if (_blockDefault == XmlSchemaDerivationMethod.All) - { - element.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else - { - element.SetBlockResolved(_blockDefault & elementBlockAllowed); - } - } - else - { - if ((element.Block & ~elementBlockAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidElementBlockValue, element); - } - element.SetBlockResolved(element.Block & elementBlockAllowed); - } - if (element.SchemaType != null) - { - SetParent(element.SchemaType, element); //Set parent for simple / complex type child of element - if (!element.SchemaTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_TypeMutualExclusive, element); - } - if (element.SchemaType is XmlSchemaComplexType) - { - PreprocessComplexType((XmlSchemaComplexType)element.SchemaType, true); - } - else - { - PreprocessSimpleType((XmlSchemaSimpleType)element.SchemaType, true); - } - } - if (!element.SchemaTypeName.IsEmpty) - { - ValidateQNameAttribute(element, "type", element.SchemaTypeName); - } - if (element.DefaultValue != null && element.FixedValue != null) - { - SendValidationEvent(ResXml.Sch_DefaultFixedAttributes, element); - } - for (int i = 0; i < element.Constraints.Count; ++i) - { - SetParent(element.Constraints[i], element); - PreprocessIdentityConstraint((XmlSchemaIdentityConstraint)element.Constraints[i]); - } - } - - private void PreprocessIdentityConstraint(XmlSchemaIdentityConstraint constraint) - { - bool valid = true; - PreprocessAnnotation(constraint); //Set parent of annotation child of key/keyref/unique - if (constraint.Name != null) - { - ValidateNameAttribute(constraint); - constraint.SetQualifiedName(new XmlQualifiedName(constraint.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", constraint); - valid = false; - } - - if (_schema.IdentityConstraints[constraint.QualifiedName] != null) - { - SendValidationEvent(ResXml.Sch_DupIdentityConstraint, constraint.QualifiedName.ToString(), constraint); - valid = false; - } - else - { - _schema.IdentityConstraints.Add(constraint.QualifiedName, constraint); - } - - if (constraint.Selector == null) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoSelector, constraint); - valid = false; - } - if (constraint.Fields.Count == 0) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoFields, constraint); - valid = false; - } - if (constraint is XmlSchemaKeyref) - { - XmlSchemaKeyref keyref = (XmlSchemaKeyref)constraint; - if (keyref.Refer.IsEmpty) - { - SendValidationEvent(ResXml.Sch_IdConstraintNoRefer, constraint); - valid = false; - } - else - { - ValidateQNameAttribute(keyref, "refer", keyref.Refer); - } - } - if (valid) - { - ValidateIdAttribute(constraint); - ValidateIdAttribute(constraint.Selector); - SetParent(constraint.Selector, constraint); - for (int i = 0; i < constraint.Fields.Count; ++i) - { - SetParent(constraint.Fields[i], constraint); - ValidateIdAttribute(constraint.Fields[i]); - } - } - } - - private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local) - { - if (local) - { - if (simpleType.Name != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "name", simpleType); - } - } - else - { - if (simpleType.Name != null) - { - ValidateNameAttribute(simpleType); - simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", simpleType); - } - - if (simpleType.Final == XmlSchemaDerivationMethod.All) - { - simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (simpleType.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - simpleType.SetFinalResolved(_finalDefault & simpleTypeFinalAllowed); - } - } - else - { - if ((simpleType.Final & ~simpleTypeFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidSimpleTypeFinalValue, simpleType); - } - simpleType.SetFinalResolved(simpleType.Final & simpleTypeFinalAllowed); - } - } - - if (simpleType.Content == null) - { - SendValidationEvent(ResXml.Sch_NoSimpleTypeContent, simpleType); - } - else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; - //SetParent - SetParent(restriction, simpleType); - for (int i = 0; i < restriction.Facets.Count; ++i) - { - SetParent(restriction.Facets[i], restriction); - } - - if (restriction.BaseType != null) - { - if (!restriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeRestRefBase, restriction); - } - PreprocessSimpleType(restriction.BaseType, true); - } - else - { - if (restriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeRestRefBaseNone, restriction); - } - else - { - ValidateQNameAttribute(restriction, "base", restriction.BaseTypeName); - } - } - PreprocessAnnotation(restriction); //set parent of annotation child of simple type restriction - ValidateIdAttribute(restriction); - } - else if (simpleType.Content is XmlSchemaSimpleTypeList) - { - XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; - SetParent(list, simpleType); - - if (list.ItemType != null) - { - if (!list.ItemTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeListRefBase, list); - } - SetParent(list.ItemType, list); - PreprocessSimpleType(list.ItemType, true); - } - else - { - if (list.ItemTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_SimpleTypeListRefBaseNone, list); - } - else - { - ValidateQNameAttribute(list, "itemType", list.ItemTypeName); - } - } - PreprocessAnnotation(list); //set parent of annotation child of simple type list - ValidateIdAttribute(list); - } - else - { // union - XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content; - SetParent(union1, simpleType); - - int baseTypeCount = union1.BaseTypes.Count; - if (union1.MemberTypes != null) - { - baseTypeCount += union1.MemberTypes.Length; - for (int i = 0; i < union1.MemberTypes.Length; ++i) - { - ValidateQNameAttribute(union1, "memberTypes", union1.MemberTypes[i]); - } - } - if (baseTypeCount == 0) - { - SendValidationEvent(ResXml.Sch_SimpleTypeUnionNoBase, union1); - } - for (int i = 0; i < union1.BaseTypes.Count; ++i) - { - SetParent(union1.BaseTypes[i], union1); - PreprocessSimpleType((XmlSchemaSimpleType)union1.BaseTypes[i], true); - } - PreprocessAnnotation(union1); //set parent of annotation child of simple type union - ValidateIdAttribute(union1); - } - ValidateIdAttribute(simpleType); - } - - private void PreprocessComplexType(XmlSchemaComplexType complexType, bool local) - { - if (local) - { - if (complexType.Name != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "name", complexType); - } - } - else - { - if (complexType.Name != null) - { - ValidateNameAttribute(complexType); - complexType.SetQualifiedName(new XmlQualifiedName(complexType.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", complexType); - } - if (complexType.Block == XmlSchemaDerivationMethod.All) - { - complexType.SetBlockResolved(XmlSchemaDerivationMethod.All); - } - else if (complexType.Block == XmlSchemaDerivationMethod.None) - { - complexType.SetBlockResolved(_blockDefault & complexTypeBlockAllowed); - } - else - { - if ((complexType.Block & ~complexTypeBlockAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidComplexTypeBlockValue, complexType); - } - complexType.SetBlockResolved(complexType.Block & complexTypeBlockAllowed); - } - if (complexType.Final == XmlSchemaDerivationMethod.All) - { - complexType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else if (complexType.Final == XmlSchemaDerivationMethod.None) - { - if (_finalDefault == XmlSchemaDerivationMethod.All) - { - complexType.SetFinalResolved(XmlSchemaDerivationMethod.All); - } - else - { - complexType.SetFinalResolved(_finalDefault & complexTypeFinalAllowed); - } - } - else - { - if ((complexType.Final & ~complexTypeFinalAllowed) != 0) - { - SendValidationEvent(ResXml.Sch_InvalidComplexTypeFinalValue, complexType); - } - complexType.SetFinalResolved(complexType.Final & complexTypeFinalAllowed); - } - } - - if (complexType.ContentModel != null) - { - SetParent(complexType.ContentModel, complexType); //SimpleContent / complexCotent - PreprocessAnnotation(complexType.ContentModel); - - if (complexType.Particle != null || complexType.Attributes != null) - { - // this is illigal - } - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)complexType.ContentModel; - if (content.Content == null) - { - if (complexType.QualifiedName == XmlQualifiedName.Empty) - { - SendValidationEvent(ResXml.Sch_NoRestOrExt, complexType); - } - else - { - SendValidationEvent(ResXml.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType); - } - } - else - { - SetParent(content.Content, content); //simplecontent extension / restriction - PreprocessAnnotation(content.Content); //annotation child of simple extension / restriction - - if (content.Content is XmlSchemaSimpleContentExtension) - { - XmlSchemaSimpleContentExtension contentExtension = (XmlSchemaSimpleContentExtension)content.Content; - if (contentExtension.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentExtension); - } - else - { - ValidateQNameAttribute(contentExtension, "base", contentExtension.BaseTypeName); - } - PreprocessAttributes(contentExtension.Attributes, contentExtension.AnyAttribute, contentExtension); - ValidateIdAttribute(contentExtension); - } - else - { //XmlSchemaSimpleContentRestriction - XmlSchemaSimpleContentRestriction contentRestriction = (XmlSchemaSimpleContentRestriction)content.Content; - if (contentRestriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentRestriction); - } - else - { - ValidateQNameAttribute(contentRestriction, "base", contentRestriction.BaseTypeName); - } - if (contentRestriction.BaseType != null) - { - SetParent(contentRestriction.BaseType, contentRestriction); - PreprocessSimpleType(contentRestriction.BaseType, true); - } - PreprocessAttributes(contentRestriction.Attributes, contentRestriction.AnyAttribute, contentRestriction); - ValidateIdAttribute(contentRestriction); - } - } - ValidateIdAttribute(content); - } - else - { // XmlSchemaComplexContent - XmlSchemaComplexContent content = (XmlSchemaComplexContent)complexType.ContentModel; - if (content.Content == null) - { - if (complexType.QualifiedName == XmlQualifiedName.Empty) - { - SendValidationEvent(ResXml.Sch_NoRestOrExt, complexType); - } - else - { - SendValidationEvent(ResXml.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType); - } - } - else - { - if (!content.HasMixedAttribute && complexType.IsMixed) - { - content.IsMixed = true; // fixup - } - SetParent(content.Content, content); //complexcontent extension / restriction - PreprocessAnnotation(content.Content); //Annotation child of extension / restriction - - if (content.Content is XmlSchemaComplexContentExtension) - { - XmlSchemaComplexContentExtension contentExtension = (XmlSchemaComplexContentExtension)content.Content; - if (contentExtension.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentExtension); - } - else - { - ValidateQNameAttribute(contentExtension, "base", contentExtension.BaseTypeName); - } - if (contentExtension.Particle != null) - { - SetParent(contentExtension.Particle, contentExtension); //Group / all / choice / sequence - PreprocessParticle(contentExtension.Particle); - } - PreprocessAttributes(contentExtension.Attributes, contentExtension.AnyAttribute, contentExtension); - ValidateIdAttribute(contentExtension); - } - else - { // XmlSchemaComplexContentRestriction - XmlSchemaComplexContentRestriction contentRestriction = (XmlSchemaComplexContentRestriction)content.Content; - if (contentRestriction.BaseTypeName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "base", contentRestriction); - } - else - { - ValidateQNameAttribute(contentRestriction, "base", contentRestriction.BaseTypeName); - } - if (contentRestriction.Particle != null) - { - SetParent(contentRestriction.Particle, contentRestriction); //Group / all / choice / sequence - PreprocessParticle(contentRestriction.Particle); - } - PreprocessAttributes(contentRestriction.Attributes, contentRestriction.AnyAttribute, contentRestriction); - ValidateIdAttribute(contentRestriction); - } - ValidateIdAttribute(content); - } - } - } - else - { - if (complexType.Particle != null) - { - SetParent(complexType.Particle, complexType); - PreprocessParticle(complexType.Particle); - } - PreprocessAttributes(complexType.Attributes, complexType.AnyAttribute, complexType); - } - ValidateIdAttribute(complexType); - } - - private void PreprocessGroup(XmlSchemaGroup group) - { - if (group.Name != null) - { - ValidateNameAttribute(group); - group.SetQualifiedName(new XmlQualifiedName(group.Name, _targetNamespace)); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", group); - } - if (group.Particle == null) - { - SendValidationEvent(ResXml.Sch_NoGroupParticle, group); - return; - } - if (group.Particle.MinOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "minOccurs", group.Particle); - } - if (group.Particle.MaxOccursString != null) - { - SendValidationEvent(ResXml.Sch_ForbiddenAttribute, "maxOccurs", group.Particle); - } - - PreprocessParticle(group.Particle); - PreprocessAnnotation(group); //Set parent of annotation child of group - ValidateIdAttribute(group); - } - - private void PreprocessNotation(XmlSchemaNotation notation) - { - if (notation.Name != null) - { - ValidateNameAttribute(notation); - notation.QualifiedName = new XmlQualifiedName(notation.Name, _targetNamespace); - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "name", notation); - } - if (notation.Public != null) - { - try - { - XmlConvert.ToUri(notation.Public); // can throw - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidPublicAttribute, notation.Public, notation); - } - } - else - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, "public", notation); - } - if (notation.System != null) - { - try - { - XmlConvert.ToUri(notation.System); // can throw - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidSystemAttribute, notation.System, notation); - } - } - PreprocessAnnotation(notation); //Set parent of annotation child of notation - ValidateIdAttribute(notation); - } - - - private void PreprocessParticle(XmlSchemaParticle particle) - { - XmlSchemaAll schemaAll = particle as XmlSchemaAll; - if (schemaAll != null) - { - if (particle.MinOccurs != decimal.Zero && particle.MinOccurs != decimal.One) - { - particle.MinOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllMin, particle); - } - if (particle.MaxOccurs != decimal.One) - { - particle.MaxOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllMax, particle); - } - for (int i = 0; i < schemaAll.Items.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)schemaAll.Items[i]; - if (element.MaxOccurs != decimal.Zero && element.MaxOccurs != decimal.One) - { - element.MaxOccurs = decimal.One; - SendValidationEvent(ResXml.Sch_InvalidAllElementMax, element); - } - SetParent(element, particle); - PreprocessLocalElement(element); - } - } - else - { - if (particle.MinOccurs > particle.MaxOccurs) - { - particle.MinOccurs = particle.MaxOccurs; - SendValidationEvent(ResXml.Sch_MinGtMax, particle); - } - XmlSchemaChoice choice = particle as XmlSchemaChoice; - if (choice != null) - { - XmlSchemaObjectCollection choices = choice.Items; - for (int i = 0; i < choices.Count; ++i) - { - SetParent(choices[i], particle); - XmlSchemaElement element = choices[i] as XmlSchemaElement; - if (element != null) - { - PreprocessLocalElement(element); - } - else - { - PreprocessParticle((XmlSchemaParticle)choices[i]); - } - } - } - else if (particle is XmlSchemaSequence) - { - XmlSchemaObjectCollection sequences = ((XmlSchemaSequence)particle).Items; - for (int i = 0; i < sequences.Count; ++i) - { - SetParent(sequences[i], particle); - XmlSchemaElement element = sequences[i] as XmlSchemaElement; - if (element != null) - { - PreprocessLocalElement(element); - } - else - { - PreprocessParticle((XmlSchemaParticle)sequences[i]); - } - } - } - else if (particle is XmlSchemaGroupRef) - { - XmlSchemaGroupRef groupRef = (XmlSchemaGroupRef)particle; - if (groupRef.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "ref", groupRef); - } - else - { - ValidateQNameAttribute(groupRef, "ref", groupRef.RefName); - } - } - else if (particle is XmlSchemaAny) - { - try - { - ((XmlSchemaAny)particle).BuildNamespaceListV1Compat(_targetNamespace); - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidAny, particle); - } - } - } - PreprocessAnnotation(particle); //set parent of annotation child of group / all/ choice / sequence - ValidateIdAttribute(particle); - } - - private void PreprocessAttributes(XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaObject parent) - { - for (int i = 0; i < attributes.Count; ++i) - { - SetParent(attributes[i], parent); - XmlSchemaAttribute attribute = attributes[i] as XmlSchemaAttribute; - if (attribute != null) - { - PreprocessLocalAttribute(attribute); - } - else - { // XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributes[i]; - if (attributeGroupRef.RefName.IsEmpty) - { - SendValidationEvent(ResXml.Sch_MissAttribute, "ref", attributeGroupRef); - } - else - { - ValidateQNameAttribute(attributeGroupRef, "ref", attributeGroupRef.RefName); - } - PreprocessAnnotation(attributes[i]); //set parent of annotation child of attributeGroupRef - ValidateIdAttribute(attributes[i]); - } - } - if (anyAttribute != null) - { - try - { - SetParent(anyAttribute, parent); - PreprocessAnnotation(anyAttribute); //set parent of annotation child of any attribute - anyAttribute.BuildNamespaceListV1Compat(_targetNamespace); - } - catch - { - SendValidationEvent(ResXml.Sch_InvalidAnyAttribute, anyAttribute); - } - ValidateIdAttribute(anyAttribute); - } - } - - private void ValidateIdAttribute(XmlSchemaObject xso) - { - if (xso.IdAttribute != null) - { - try - { - xso.IdAttribute = NameTable.Add(XmlConvert.VerifyNCName(xso.IdAttribute)); - if (_schema.Ids[xso.IdAttribute] != null) - { - SendValidationEvent(ResXml.Sch_DupIdAttribute, xso); - } - else - { - _schema.Ids.Add(xso.IdAttribute, xso); - } - } - catch (Exception ex) - { - SendValidationEvent(ResXml.Sch_InvalidIdAttribute, ex.Message, xso); - } - } - } - - private void ValidateNameAttribute(XmlSchemaObject xso) - { - string name = xso.NameAttribute; - if (name == null || name.Length == 0) - { - SendValidationEvent(ResXml.Sch_InvalidNameAttributeEx, null, ResXml.Sch_NullValue, xso); - } - //Normalize whitespace since NCName has whitespace facet="collapse" - name = XmlComplianceUtil.NonCDataNormalize(name); - int len = ValidateNames.ParseNCName(name, 0); - if (len != name.Length) - { // If the string is not a valid NCName, then throw or return false - string[] invCharArgs = XmlException.BuildCharExceptionArgs(name, len); - string innerStr = string.Format(ResXml.Xml_BadNameCharWithPos, invCharArgs[0], invCharArgs[1], len); - SendValidationEvent(ResXml.Sch_InvalidNameAttributeEx, name, innerStr, xso); - } - else - { - xso.NameAttribute = NameTable.Add(name); - } - } - - private void ValidateQNameAttribute(XmlSchemaObject xso, string attributeName, XmlQualifiedName value) - { - try - { - value.Verify(); - value.Atomize(NameTable); - if (_referenceNamespaces[value.Namespace] == null) - { - SendValidationEvent(ResXml.Sch_UnrefNS, value.Namespace, xso, XmlSeverityType.Warning); - } - } - catch (Exception ex) - { - SendValidationEvent(ResXml.Sch_InvalidAttribute, attributeName, ex.Message, xso); - } - } - - private void SetParent(XmlSchemaObject child, XmlSchemaObject parent) - { - child.Parent = parent; - } - - private void PreprocessAnnotation(XmlSchemaObject schemaObject) - { - XmlSchemaAnnotated annotated = schemaObject as XmlSchemaAnnotated; - if (annotated != null) - { - if (annotated.Annotation != null) - { - annotated.Annotation.Parent = schemaObject; - for (int i = 0; i < annotated.Annotation.Items.Count; ++i) - { - annotated.Annotation.Items[i].Parent = annotated.Annotation; //Can be documentation or appInfo - } - } - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private Uri ResolveSchemaLocationUri(XmlSchema enclosingSchema, string location) - { - try - { - return _xmlResolver.ResolveUri(enclosingSchema.BaseUri, location); - } - catch - { - return null; - } - } - - private Stream GetSchemaEntity(Uri ruri) - { - try - { - return (Stream)_xmlResolver.GetEntity(ruri, null, null); - } - catch - { - return null; - } - } - }; -#pragma warning restore 618 -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaDeclBase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaDeclBase.cs deleted file mode 100644 index 2d6aaee4d8b..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaDeclBase.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections.Generic; - using System.Diagnostics; - - internal abstract class SchemaDeclBase - { - internal enum Use - { - Default, - Required, - Implied, - Fixed, - RequiredFixed - }; - - protected XmlQualifiedName name = XmlQualifiedName.Empty; - protected string prefix; - protected bool isDeclaredInExternal = false; - protected Use presence; // the presence, such as fixed, implied, etc - - protected XmlSchemaType schemaType; - protected XmlSchemaDatatype datatype; - - protected string defaultValueRaw; // default value in its original form - protected object defaultValueTyped; - - protected long maxLength; // dt:maxLength - protected long minLength; // dt:minLength - - protected List values; // array of values for enumerated and notation types - - protected SchemaDeclBase(XmlQualifiedName name, string prefix) - { - this.name = name; - this.prefix = prefix; - maxLength = -1; - minLength = -1; - } - - protected SchemaDeclBase() - { - } - - internal XmlQualifiedName Name - { - get { return name; } - set { name = value; } - } - - internal string Prefix - { - get { return (prefix == null) ? string.Empty : prefix; } - set { prefix = value; } - } - - internal bool IsDeclaredInExternal - { - get { return isDeclaredInExternal; } - set { isDeclaredInExternal = value; } - } - - internal Use Presence - { - get { return presence; } - set { presence = value; } - } - - internal long MaxLength - { - get { return maxLength; } - set { maxLength = value; } - } - - internal long MinLength - { - get { return minLength; } - set { minLength = value; } - } - - internal XmlSchemaType SchemaType - { - get { return schemaType; } - set { schemaType = value; } - } - - internal XmlSchemaDatatype Datatype - { - get { return datatype; } - set { datatype = value; } - } - - internal void AddValue(string value) - { - if (values == null) - { - values = new List(); - } - values.Add(value); - } - - internal List Values - { - get { return values; } - set { values = value; } - } - - internal string DefaultValueRaw - { - get { return (defaultValueRaw != null) ? defaultValueRaw : string.Empty; } - set { defaultValueRaw = value; } - } - - internal object DefaultValueTyped - { - get { return defaultValueTyped; } - set { defaultValueTyped = value; } - } - - internal bool CheckEnumeration(object pVal) - { - return (datatype.TokenizedType != XmlTokenizedType.NOTATION && datatype.TokenizedType != XmlTokenizedType.ENUMERATION) || values.Contains(pVal.ToString()); - } - - internal bool CheckValue(Object pVal) - { - return (presence != Use.Fixed && presence != Use.RequiredFixed) || (defaultValueTyped != null && datatype.IsEqual(pVal, defaultValueTyped)); - } - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaElementDecl.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaElementDecl.cs deleted file mode 100644 index 340ee68f915..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaElementDecl.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Diagnostics; - using System.Collections.Generic; - - internal sealed class SchemaElementDecl : SchemaDeclBase, IDtdAttributeListInfo - { - private Dictionary _attdefs = new Dictionary(); - private List _defaultAttdefs; - private bool _isIdDeclared; - private bool _hasNonCDataAttribute = false; - - private bool _isAbstract = false; - private bool _isNillable = false; - private bool _hasRequiredAttribute = false; - private bool _isNotationDeclared; - private Dictionary _prohibitedAttributes = new Dictionary(); - private ContentValidator _contentValidator; - private XmlSchemaAnyAttribute _anyAttribute; - private XmlSchemaDerivationMethod _block; - private CompiledIdentityConstraint[] _constraints; - private XmlSchemaElement _schemaElement; - - internal static readonly SchemaElementDecl Empty = new SchemaElementDecl(); - - // - // Constructor - // - internal SchemaElementDecl() - { - } - - internal SchemaElementDecl(XmlSchemaDatatype dtype) - { - Datatype = dtype; - _contentValidator = ContentValidator.TextOnly; - } - - internal SchemaElementDecl(XmlQualifiedName name, String prefix) - : base(name, prefix) - { - } - - // - // Static methods - // - internal static SchemaElementDecl CreateAnyTypeElementDecl() - { - SchemaElementDecl anyTypeElementDecl = new SchemaElementDecl(); - anyTypeElementDecl.Datatype = DatatypeImplementation.AnySimpleType.Datatype; - return anyTypeElementDecl; - } - - // - // IDtdAttributeListInfo interface - // - #region IDtdAttributeListInfo Members - - string IDtdAttributeListInfo.Prefix - { - get { return ((SchemaElementDecl)this).Prefix; } - } - - string IDtdAttributeListInfo.LocalName - { - get { return ((SchemaElementDecl)this).Name.Name; } - } - - bool IDtdAttributeListInfo.HasNonCDataAttributes - { - get { return _hasNonCDataAttribute; } - } - - IDtdAttributeInfo IDtdAttributeListInfo.LookupAttribute(string prefix, string localName) - { - XmlQualifiedName qname = new XmlQualifiedName(localName, prefix); - SchemaAttDef attDef; - if (_attdefs.TryGetValue(qname, out attDef)) - { - return attDef; - } - return null; - } - - IEnumerable IDtdAttributeListInfo.LookupDefaultAttributes() - { - return _defaultAttdefs; - } - - IDtdAttributeInfo IDtdAttributeListInfo.LookupIdAttribute() - { - foreach (SchemaAttDef attDef in _attdefs.Values) - { - if (attDef.TokenizedType == XmlTokenizedType.ID) - { - return (IDtdAttributeInfo)attDef; - } - } - return null; - } - #endregion - - // - // SchemaElementDecl properties - // - internal bool IsIdDeclared - { - get { return _isIdDeclared; } - set { _isIdDeclared = value; } - } - - internal bool HasNonCDataAttribute - { - get { return _hasNonCDataAttribute; } - set { _hasNonCDataAttribute = value; } - } - - internal SchemaElementDecl Clone() - { - return (SchemaElementDecl)MemberwiseClone(); - } - - internal bool IsAbstract - { - get { return _isAbstract; } - set { _isAbstract = value; } - } - - internal bool IsNillable - { - get { return _isNillable; } - set { _isNillable = value; } - } - - internal XmlSchemaDerivationMethod Block - { - get { return _block; } - set { _block = value; } - } - - internal bool IsNotationDeclared - { - get { return _isNotationDeclared; } - set { _isNotationDeclared = value; } - } - - internal bool HasDefaultAttribute - { - get { return _defaultAttdefs != null; } - } - - internal bool HasRequiredAttribute - { - get { return _hasRequiredAttribute; } - set { _hasRequiredAttribute = value; } - } - - internal ContentValidator ContentValidator - { - get { return _contentValidator; } - set { _contentValidator = value; } - } - - internal XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - internal CompiledIdentityConstraint[] Constraints - { - get { return _constraints; } - set { _constraints = value; } - } - - internal XmlSchemaElement SchemaElement - { - get { return _schemaElement; } - set { _schemaElement = value; } - } - // add a new SchemaAttDef to the SchemaElementDecl - internal void AddAttDef(SchemaAttDef attdef) - { - _attdefs.Add(attdef.Name, attdef); - if (attdef.Presence == SchemaDeclBase.Use.Required || attdef.Presence == SchemaDeclBase.Use.RequiredFixed) - { - _hasRequiredAttribute = true; - } - if (attdef.Presence == SchemaDeclBase.Use.Default || attdef.Presence == SchemaDeclBase.Use.Fixed) - { //Not adding RequiredFixed here - if (_defaultAttdefs == null) - { - _defaultAttdefs = new List(); - } - _defaultAttdefs.Add(attdef); - } - } - - /* - * Retrieves the attribute definition of the named attribute. - * @param name The name of the attribute. - * @return an attribute definition object; returns null if it is not found. - */ - internal SchemaAttDef GetAttDef(XmlQualifiedName qname) - { - SchemaAttDef attDef; - if (_attdefs.TryGetValue(qname, out attDef)) - { - return attDef; - } - return null; - } - - internal IList DefaultAttDefs - { - get { return _defaultAttdefs; } - } - - internal Dictionary AttDefs - { - get { return _attdefs; } - } - - internal Dictionary ProhibitedAttributes - { - get { return _prohibitedAttributes; } - } - - internal void CheckAttributes(Hashtable presence, bool standalone) - { - foreach (SchemaAttDef attdef in _attdefs.Values) - { - if (presence[attdef.Name] == null) - { - if (attdef.Presence == SchemaDeclBase.Use.Required) - { - throw new XmlSchemaException(ResXml.Sch_MissRequiredAttribute, attdef.Name.ToString()); - } - else if (standalone && attdef.IsDeclaredInExternal && (attdef.Presence == SchemaDeclBase.Use.Default || attdef.Presence == SchemaDeclBase.Use.Fixed)) - { - throw new XmlSchemaException(ResXml.Sch_StandAlone, string.Empty); - } - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaEntity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaEntity.cs deleted file mode 100644 index 41db588a3f7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaEntity.cs +++ /dev/null @@ -1,185 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Diagnostics; - - internal sealed class SchemaEntity : IDtdEntityInfo - { - private XmlQualifiedName _qname; // Name of entity - private String _url; // Url for external entity (system id) - private String _pubid; // Pubid for external entity - private String _text; // Text for internal entity - private XmlQualifiedName _ndata = XmlQualifiedName.Empty; // NDATA identifier - private int _lineNumber; // line number - private int _linePosition; // character postion - private bool _isParameter; // parameter entity flag - private bool _isExternal; // external entity flag - private bool _parsingInProgress; // whether entity is being parsed (DtdParser infinite recursion check) - private bool _isDeclaredInExternal; // declared in external markup or not - private string _baseURI; - private string _declaredURI; - - // - // Constructor - // - internal SchemaEntity(XmlQualifiedName qname, bool isParameter) - { - _qname = qname; - _isParameter = isParameter; - } - - // - // IDtdEntityInfo interface - // - #region IDtdEntityInfo Members - - string IDtdEntityInfo.Name - { - get { return this.Name.Name; } - } - - bool IDtdEntityInfo.IsExternal - { - get { return ((SchemaEntity)this).IsExternal; } - } - - bool IDtdEntityInfo.IsDeclaredInExternal - { - get { return this.DeclaredInExternal; } - } - - bool IDtdEntityInfo.IsUnparsedEntity - { - get { return !this.NData.IsEmpty; } - } - - bool IDtdEntityInfo.IsParameterEntity - { - get { return _isParameter; } - } - - string IDtdEntityInfo.BaseUriString - { - get { return this.BaseURI; } - } - - string IDtdEntityInfo.DeclaredUriString - { - get { return this.DeclaredURI; } - } - - string IDtdEntityInfo.SystemId - { - get { return this.Url; } - } - - string IDtdEntityInfo.PublicId - { - get { return this.Pubid; } - } - - string IDtdEntityInfo.Text - { - get { return ((SchemaEntity)this).Text; } - } - - int IDtdEntityInfo.LineNumber - { - get { return this.Line; } - } - - int IDtdEntityInfo.LinePosition - { - get { return this.Pos; } - } - - #endregion - - // - // Internal methods and properties - // - internal static bool IsPredefinedEntity(String n) - { - return (n == "lt" || - n == "gt" || - n == "amp" || - n == "apos" || - n == "quot"); - } - - internal XmlQualifiedName Name - { - get { return _qname; } - } - - internal String Url - { - get { return _url; } - set { _url = value; _isExternal = true; } - } - - internal String Pubid - { - get { return _pubid; } - set { _pubid = value; } - } - - internal bool IsExternal - { - get { return _isExternal; } - set { _isExternal = value; } - } - - internal bool DeclaredInExternal - { - get { return _isDeclaredInExternal; } - set { _isDeclaredInExternal = value; } - } - - internal XmlQualifiedName NData - { - get { return _ndata; } - set { _ndata = value; } - } - - internal String Text - { - get { return _text; } - set { _text = value; _isExternal = false; } - } - - internal int Line - { - get { return _lineNumber; } - set { _lineNumber = value; } - } - - internal int Pos - { - get { return _linePosition; } - set { _linePosition = value; } - } - - internal String BaseURI - { - get { return (_baseURI == null) ? String.Empty : _baseURI; } - set { _baseURI = value; } - } - - internal bool ParsingInProgress - { - get { return _parsingInProgress; } - set { _parsingInProgress = value; } - } - - internal String DeclaredURI - { - get { return (_declaredURI == null) ? String.Empty : _declaredURI; } - set { _declaredURI = value; } - } - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaInfo.cs deleted file mode 100644 index 727a0e5e52a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaInfo.cs +++ /dev/null @@ -1,474 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections.Generic; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - internal enum AttributeMatchState - { - AttributeFound, - AnyIdAttributeFound, - UndeclaredElementAndAttribute, - UndeclaredAttribute, - AnyAttributeLax, - AnyAttributeSkip, - ProhibitedAnyAttribute, - ProhibitedAttribute, - AttributeNameMismatch, - ValidateAttributeInvalidCall, - } - - internal class SchemaInfo : IDtdInfo - { - private Dictionary _elementDecls = new Dictionary(); - private Dictionary _undeclaredElementDecls = new Dictionary(); - - private Dictionary _generalEntities; - private Dictionary _parameterEntities; - - private XmlQualifiedName _docTypeName = XmlQualifiedName.Empty; - private string _internalDtdSubset = string.Empty; - private bool _hasNonCDataAttributes = false; - private bool _hasDefaultAttributes = false; - - private Dictionary _targetNamespaces = new Dictionary(); - private Dictionary _attributeDecls = new Dictionary(); - private int _errorCount; - private SchemaType _schemaType; - private Dictionary _elementDeclsByType = new Dictionary(); - private Dictionary _notations; - - - internal SchemaInfo() - { - _schemaType = SchemaType.None; - } - - public XmlQualifiedName DocTypeName - { - get { return _docTypeName; } - set { _docTypeName = value; } - } - - internal string InternalDtdSubset - { - get { return _internalDtdSubset; } - set { _internalDtdSubset = value; } - } - - internal Dictionary ElementDecls - { - get { return _elementDecls; } - } - - internal Dictionary UndeclaredElementDecls - { - get { return _undeclaredElementDecls; } - } - - internal Dictionary GeneralEntities - { - get - { - if (_generalEntities == null) - { - _generalEntities = new Dictionary(); - } - return _generalEntities; - } - } - - internal Dictionary ParameterEntities - { - get - { - if (_parameterEntities == null) - { - _parameterEntities = new Dictionary(); - } - return _parameterEntities; - } - } - - internal SchemaType SchemaType - { - get { return _schemaType; } - set { _schemaType = value; } - } - - internal Dictionary TargetNamespaces - { - get { return _targetNamespaces; } - } - - internal Dictionary ElementDeclsByType - { - get { return _elementDeclsByType; } - } - - internal Dictionary AttributeDecls - { - get { return _attributeDecls; } - } - - internal Dictionary Notations - { - get - { - if (_notations == null) - { - _notations = new Dictionary(); - } - return _notations; - } - } - - internal int ErrorCount - { - get { return _errorCount; } - set { _errorCount = value; } - } - - internal SchemaElementDecl GetElementDecl(XmlQualifiedName qname) - { - SchemaElementDecl elemDecl; - if (_elementDecls.TryGetValue(qname, out elemDecl)) - { - return elemDecl; - } - return null; - } - - internal SchemaElementDecl GetTypeDecl(XmlQualifiedName qname) - { - SchemaElementDecl elemDecl; - if (_elementDeclsByType.TryGetValue(qname, out elemDecl)) - { - return elemDecl; - } - return null; - } - - - internal XmlSchemaElement GetElement(XmlQualifiedName qname) - { - SchemaElementDecl ed = GetElementDecl(qname); - if (ed != null) - { - return ed.SchemaElement; - } - return null; - } - - internal XmlSchemaAttribute GetAttribute(XmlQualifiedName qname) - { - SchemaAttDef attdef = (SchemaAttDef)_attributeDecls[qname]; - if (attdef != null) - { - return attdef.SchemaAttribute; - } - return null; - } - - internal XmlSchemaElement GetType(XmlQualifiedName qname) - { - SchemaElementDecl ed = GetElementDecl(qname); - if (ed != null) - { - return ed.SchemaElement; - } - return null; - } - - internal bool HasSchema(string ns) - { - return _targetNamespaces.ContainsKey(ns); - } - - internal bool Contains(string ns) - { - return _targetNamespaces.ContainsKey(ns); - } - - internal SchemaAttDef GetAttributeXdr(SchemaElementDecl ed, XmlQualifiedName qname) - { - SchemaAttDef attdef = null; - if (ed != null) - { - attdef = ed.GetAttDef(qname); ; - if (attdef == null) - { - if (!ed.ContentValidator.IsOpen || qname.Namespace.Length == 0) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredAttribute, qname.ToString()); - } - if (!_attributeDecls.TryGetValue(qname, out attdef) && _targetNamespaces.ContainsKey(qname.Namespace)) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredAttribute, qname.ToString()); - } - } - } - return attdef; - } - - - internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState) - { - SchemaAttDef attdef = null; - attributeMatchState = AttributeMatchState.UndeclaredAttribute; - if (ed != null) - { - attdef = ed.GetAttDef(qname); - if (attdef != null) - { - attributeMatchState = AttributeMatchState.AttributeFound; - return attdef; - } - XmlSchemaAnyAttribute any = ed.AnyAttribute; - if (any != null) - { - if (!any.NamespaceList.Allows(qname)) - { - attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute; - } - else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) - { - if (_attributeDecls.TryGetValue(qname, out attdef)) - { - if (attdef.Datatype.TypeCode == XmlTypeCode.Id) - { //anyAttribute match whose type is ID - attributeMatchState = AttributeMatchState.AnyIdAttributeFound; - } - else - { - attributeMatchState = AttributeMatchState.AttributeFound; - } - } - else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax) - { - attributeMatchState = AttributeMatchState.AnyAttributeLax; - } - } - else - { - attributeMatchState = AttributeMatchState.AnyAttributeSkip; - } - } - else if (ed.ProhibitedAttributes.ContainsKey(qname)) - { - attributeMatchState = AttributeMatchState.ProhibitedAttribute; - } - } - else if (partialValidationType != null) - { - XmlSchemaAttribute attr = partialValidationType as XmlSchemaAttribute; - if (attr != null) - { - if (qname.Equals(attr.QualifiedName)) - { - attdef = attr.AttDef; - attributeMatchState = AttributeMatchState.AttributeFound; - } - else - { - attributeMatchState = AttributeMatchState.AttributeNameMismatch; - } - } - else - { - attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall; - } - } - else - { - if (_attributeDecls.TryGetValue(qname, out attdef)) - { - attributeMatchState = AttributeMatchState.AttributeFound; - } - else - { - attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute; - } - } - return attdef; - } - - internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip) - { - AttributeMatchState attributeMatchState; - - SchemaAttDef attDef = GetAttributeXsd(ed, qname, null, out attributeMatchState); - switch (attributeMatchState) - { - case AttributeMatchState.UndeclaredAttribute: - throw new XmlSchemaException(ResXml.Sch_UndeclaredAttribute, qname.ToString()); - - case AttributeMatchState.ProhibitedAnyAttribute: - case AttributeMatchState.ProhibitedAttribute: - throw new XmlSchemaException(ResXml.Sch_ProhibitedAttribute, qname.ToString()); - - case AttributeMatchState.AttributeFound: - case AttributeMatchState.AnyIdAttributeFound: - case AttributeMatchState.AnyAttributeLax: - case AttributeMatchState.UndeclaredElementAndAttribute: - break; - - case AttributeMatchState.AnyAttributeSkip: - skip = true; - break; - - default: - Debug.Assert(false); - break; - } - return attDef; - } - - internal void Add(SchemaInfo sinfo, ValidationEventHandler eventhandler) - { - if (_schemaType == SchemaType.None) - { - _schemaType = sinfo.SchemaType; - } - else if (_schemaType != sinfo.SchemaType) - { - if (eventhandler != null) - { - eventhandler(this, new ValidationEventArgs(new XmlSchemaException(ResXml.Sch_MixSchemaTypes, string.Empty))); - } - return; - } - - foreach (string tns in sinfo.TargetNamespaces.Keys) - { - if (!_targetNamespaces.ContainsKey(tns)) - { - _targetNamespaces.Add(tns, true); - } - } - - foreach (KeyValuePair entry in sinfo._elementDecls) - { - if (!_elementDecls.ContainsKey(entry.Key)) - { - _elementDecls.Add(entry.Key, entry.Value); - } - } - foreach (KeyValuePair entry in sinfo._elementDeclsByType) - { - if (!_elementDeclsByType.ContainsKey(entry.Key)) - { - _elementDeclsByType.Add(entry.Key, entry.Value); - } - } - foreach (SchemaAttDef attdef in sinfo.AttributeDecls.Values) - { - if (!_attributeDecls.ContainsKey(attdef.Name)) - { - _attributeDecls.Add(attdef.Name, attdef); - } - } - foreach (SchemaNotation notation in sinfo.Notations.Values) - { - if (!Notations.ContainsKey(notation.Name.Name)) - { - Notations.Add(notation.Name.Name, notation); - } - } - } - - internal void Finish() - { - Dictionary elements = _elementDecls; - for (int i = 0; i < 2; i++) - { - foreach (SchemaElementDecl e in elements.Values) - { - if (e.HasNonCDataAttribute) - { - _hasNonCDataAttributes = true; - } - if (e.DefaultAttDefs != null) - { - _hasDefaultAttributes = true; - } - } - elements = _undeclaredElementDecls; - } - } - // - // IDtdInfo interface - // - #region IDtdInfo Members - bool IDtdInfo.HasDefaultAttributes - { - get - { - return _hasDefaultAttributes; - } - } - - bool IDtdInfo.HasNonCDataAttributes - { - get - { - return _hasNonCDataAttributes; - } - } - - IDtdAttributeListInfo IDtdInfo.LookupAttributeList(string prefix, string localName) - { - XmlQualifiedName qname = new XmlQualifiedName(prefix, localName); - SchemaElementDecl elementDecl; - if (!_elementDecls.TryGetValue(qname, out elementDecl)) - { - _undeclaredElementDecls.TryGetValue(qname, out elementDecl); - } - return elementDecl; - } - - IEnumerable IDtdInfo.GetAttributeLists() - { - foreach (SchemaElementDecl elemDecl in _elementDecls.Values) - { - IDtdAttributeListInfo eleDeclAsAttList = (IDtdAttributeListInfo)elemDecl; - yield return eleDeclAsAttList; - } - } - - IDtdEntityInfo IDtdInfo.LookupEntity(string name) - { - if (_generalEntities == null) - { - return null; - } - XmlQualifiedName qname = new XmlQualifiedName(name); - SchemaEntity entity; - if (_generalEntities.TryGetValue(qname, out entity)) - { - return entity; - } - return null; - } - - XmlQualifiedName IDtdInfo.Name - { - get { return _docTypeName; } - } - - string IDtdInfo.InternalDtdSubset - { - get { return _internalDtdSubset; } - } - #endregion - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNames.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNames.cs deleted file mode 100644 index ef89aeb06db..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNames.cs +++ /dev/null @@ -1,614 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.Diagnostics; - - internal sealed class SchemaNames - { - private XmlNameTable _nameTable; - - public XmlNameTable NameTable - { - get { return _nameTable; } - } - - public string NsDataType; - public string NsDataTypeAlias; - public string NsDataTypeOld; - public string NsXml; - public string NsXmlNs; - public string NsXdr; - public string NsXdrAlias; - public string NsXs; - public string NsXsi; - public string XsiType; - public string XsiNil; - public string XsiSchemaLocation; - public string XsiNoNamespaceSchemaLocation; - public string XsdSchema; - public string XdrSchema; - - public XmlQualifiedName QnPCData; - public XmlQualifiedName QnXml; - public XmlQualifiedName QnXmlNs; - public XmlQualifiedName QnDtDt; - public XmlQualifiedName QnXmlLang; - - public XmlQualifiedName QnName; - public XmlQualifiedName QnType; - public XmlQualifiedName QnMaxOccurs; - public XmlQualifiedName QnMinOccurs; - public XmlQualifiedName QnInfinite; - public XmlQualifiedName QnModel; - public XmlQualifiedName QnOpen; - public XmlQualifiedName QnClosed; - public XmlQualifiedName QnContent; - public XmlQualifiedName QnMixed; - public XmlQualifiedName QnEmpty; - public XmlQualifiedName QnEltOnly; - public XmlQualifiedName QnTextOnly; - public XmlQualifiedName QnOrder; - public XmlQualifiedName QnSeq; - public XmlQualifiedName QnOne; - public XmlQualifiedName QnMany; - public XmlQualifiedName QnRequired; - public XmlQualifiedName QnYes; - public XmlQualifiedName QnNo; - public XmlQualifiedName QnString; - public XmlQualifiedName QnID; - public XmlQualifiedName QnIDRef; - public XmlQualifiedName QnIDRefs; - public XmlQualifiedName QnEntity; - public XmlQualifiedName QnEntities; - public XmlQualifiedName QnNmToken; - public XmlQualifiedName QnNmTokens; - public XmlQualifiedName QnEnumeration; - public XmlQualifiedName QnDefault; - public XmlQualifiedName QnXdrSchema; - public XmlQualifiedName QnXdrElementType; - public XmlQualifiedName QnXdrElement; - public XmlQualifiedName QnXdrGroup; - public XmlQualifiedName QnXdrAttributeType; - public XmlQualifiedName QnXdrAttribute; - public XmlQualifiedName QnXdrDataType; - public XmlQualifiedName QnXdrDescription; - public XmlQualifiedName QnXdrExtends; - public XmlQualifiedName QnXdrAliasSchema; - public XmlQualifiedName QnDtType; - public XmlQualifiedName QnDtValues; - public XmlQualifiedName QnDtMaxLength; - public XmlQualifiedName QnDtMinLength; - public XmlQualifiedName QnDtMax; - public XmlQualifiedName QnDtMin; - public XmlQualifiedName QnDtMinExclusive; - public XmlQualifiedName QnDtMaxExclusive; - // For XSD Schema - public XmlQualifiedName QnTargetNamespace; - public XmlQualifiedName QnVersion; - public XmlQualifiedName QnFinalDefault; - public XmlQualifiedName QnBlockDefault; - public XmlQualifiedName QnFixed; - public XmlQualifiedName QnAbstract; - public XmlQualifiedName QnBlock; - public XmlQualifiedName QnSubstitutionGroup; - public XmlQualifiedName QnFinal; - public XmlQualifiedName QnNillable; - public XmlQualifiedName QnRef; - public XmlQualifiedName QnBase; - public XmlQualifiedName QnDerivedBy; - public XmlQualifiedName QnNamespace; - public XmlQualifiedName QnProcessContents; - public XmlQualifiedName QnRefer; - public XmlQualifiedName QnPublic; - public XmlQualifiedName QnSystem; - public XmlQualifiedName QnSchemaLocation; - public XmlQualifiedName QnValue; - public XmlQualifiedName QnUse; - public XmlQualifiedName QnForm; - public XmlQualifiedName QnElementFormDefault; - public XmlQualifiedName QnAttributeFormDefault; - public XmlQualifiedName QnItemType; - public XmlQualifiedName QnMemberTypes; - public XmlQualifiedName QnXPath; - public XmlQualifiedName QnXsdSchema; - public XmlQualifiedName QnXsdAnnotation; - public XmlQualifiedName QnXsdInclude; - public XmlQualifiedName QnXsdImport; - public XmlQualifiedName QnXsdElement; - public XmlQualifiedName QnXsdAttribute; - public XmlQualifiedName QnXsdAttributeGroup; - public XmlQualifiedName QnXsdAnyAttribute; - public XmlQualifiedName QnXsdGroup; - public XmlQualifiedName QnXsdAll; - public XmlQualifiedName QnXsdChoice; - public XmlQualifiedName QnXsdSequence; - public XmlQualifiedName QnXsdAny; - public XmlQualifiedName QnXsdNotation; - public XmlQualifiedName QnXsdSimpleType; - public XmlQualifiedName QnXsdComplexType; - public XmlQualifiedName QnXsdUnique; - public XmlQualifiedName QnXsdKey; - public XmlQualifiedName QnXsdKeyRef; - public XmlQualifiedName QnXsdSelector; - public XmlQualifiedName QnXsdField; - public XmlQualifiedName QnXsdMinExclusive; - public XmlQualifiedName QnXsdMinInclusive; - public XmlQualifiedName QnXsdMaxInclusive; - public XmlQualifiedName QnXsdMaxExclusive; - public XmlQualifiedName QnXsdTotalDigits; - public XmlQualifiedName QnXsdFractionDigits; - public XmlQualifiedName QnXsdLength; - public XmlQualifiedName QnXsdMinLength; - public XmlQualifiedName QnXsdMaxLength; - public XmlQualifiedName QnXsdEnumeration; - public XmlQualifiedName QnXsdPattern; - public XmlQualifiedName QnXsdDocumentation; - public XmlQualifiedName QnXsdAppinfo; - public XmlQualifiedName QnSource; - public XmlQualifiedName QnXsdComplexContent; - public XmlQualifiedName QnXsdSimpleContent; - public XmlQualifiedName QnXsdRestriction; - public XmlQualifiedName QnXsdExtension; - public XmlQualifiedName QnXsdUnion; - public XmlQualifiedName QnXsdList; - public XmlQualifiedName QnXsdWhiteSpace; - public XmlQualifiedName QnXsdRedefine; - public XmlQualifiedName QnXsdAnyType; - - internal XmlQualifiedName[] TokenToQName = new XmlQualifiedName[(int)Token.XmlLang + 1]; - - public SchemaNames(XmlNameTable nameTable) - { - _nameTable = nameTable; - NsDataType = nameTable.Add(XmlReservedNs.NsDataType); - NsDataTypeAlias = nameTable.Add(XmlReservedNs.NsDataTypeAlias); - NsDataTypeOld = nameTable.Add(XmlReservedNs.NsDataTypeOld); - NsXml = nameTable.Add(XmlReservedNs.NsXml); - NsXmlNs = nameTable.Add(XmlReservedNs.NsXmlNs); - NsXdr = nameTable.Add(XmlReservedNs.NsXdr); - NsXdrAlias = nameTable.Add(XmlReservedNs.NsXdrAlias); - NsXs = nameTable.Add(XmlReservedNs.NsXs); - NsXsi = nameTable.Add(XmlReservedNs.NsXsi); - XsiType = nameTable.Add("type"); - XsiNil = nameTable.Add("nil"); - XsiSchemaLocation = nameTable.Add("schemaLocation"); - XsiNoNamespaceSchemaLocation = nameTable.Add("noNamespaceSchemaLocation"); - XsdSchema = nameTable.Add("schema"); - XdrSchema = nameTable.Add("Schema"); - - - QnPCData = new XmlQualifiedName(nameTable.Add("#PCDATA")); - QnXml = new XmlQualifiedName(nameTable.Add("xml")); - QnXmlNs = new XmlQualifiedName(nameTable.Add("xmlns"), NsXmlNs); - QnDtDt = new XmlQualifiedName(nameTable.Add("dt"), NsDataType); - QnXmlLang = new XmlQualifiedName(nameTable.Add("lang"), NsXml); - - // Empty namespace - QnName = new XmlQualifiedName(nameTable.Add("name")); - QnType = new XmlQualifiedName(nameTable.Add("type")); - QnMaxOccurs = new XmlQualifiedName(nameTable.Add("maxOccurs")); - QnMinOccurs = new XmlQualifiedName(nameTable.Add("minOccurs")); - QnInfinite = new XmlQualifiedName(nameTable.Add("*")); - QnModel = new XmlQualifiedName(nameTable.Add("model")); - QnOpen = new XmlQualifiedName(nameTable.Add("open")); - QnClosed = new XmlQualifiedName(nameTable.Add("closed")); - QnContent = new XmlQualifiedName(nameTable.Add("content")); - QnMixed = new XmlQualifiedName(nameTable.Add("mixed")); - QnEmpty = new XmlQualifiedName(nameTable.Add("empty")); - QnEltOnly = new XmlQualifiedName(nameTable.Add("eltOnly")); - QnTextOnly = new XmlQualifiedName(nameTable.Add("textOnly")); - QnOrder = new XmlQualifiedName(nameTable.Add("order")); - QnSeq = new XmlQualifiedName(nameTable.Add("seq")); - QnOne = new XmlQualifiedName(nameTable.Add("one")); - QnMany = new XmlQualifiedName(nameTable.Add("many")); - QnRequired = new XmlQualifiedName(nameTable.Add("required")); - QnYes = new XmlQualifiedName(nameTable.Add("yes")); - QnNo = new XmlQualifiedName(nameTable.Add("no")); - QnString = new XmlQualifiedName(nameTable.Add("string")); - QnID = new XmlQualifiedName(nameTable.Add("id")); - QnIDRef = new XmlQualifiedName(nameTable.Add("idref")); - QnIDRefs = new XmlQualifiedName(nameTable.Add("idrefs")); - QnEntity = new XmlQualifiedName(nameTable.Add("entity")); - QnEntities = new XmlQualifiedName(nameTable.Add("entities")); - QnNmToken = new XmlQualifiedName(nameTable.Add("nmtoken")); - QnNmTokens = new XmlQualifiedName(nameTable.Add("nmtokens")); - QnEnumeration = new XmlQualifiedName(nameTable.Add("enumeration")); - QnDefault = new XmlQualifiedName(nameTable.Add("default")); - - //For XSD Schema - QnTargetNamespace = new XmlQualifiedName(nameTable.Add("targetNamespace")); - QnVersion = new XmlQualifiedName(nameTable.Add("version")); - QnFinalDefault = new XmlQualifiedName(nameTable.Add("finalDefault")); - QnBlockDefault = new XmlQualifiedName(nameTable.Add("blockDefault")); - QnFixed = new XmlQualifiedName(nameTable.Add("fixed")); - QnAbstract = new XmlQualifiedName(nameTable.Add("abstract")); - QnBlock = new XmlQualifiedName(nameTable.Add("block")); - QnSubstitutionGroup = new XmlQualifiedName(nameTable.Add("substitutionGroup")); - QnFinal = new XmlQualifiedName(nameTable.Add("final")); - QnNillable = new XmlQualifiedName(nameTable.Add("nillable")); - QnRef = new XmlQualifiedName(nameTable.Add("ref")); - QnBase = new XmlQualifiedName(nameTable.Add("base")); - QnDerivedBy = new XmlQualifiedName(nameTable.Add("derivedBy")); - QnNamespace = new XmlQualifiedName(nameTable.Add("namespace")); - QnProcessContents = new XmlQualifiedName(nameTable.Add("processContents")); - QnRefer = new XmlQualifiedName(nameTable.Add("refer")); - QnPublic = new XmlQualifiedName(nameTable.Add("public")); - QnSystem = new XmlQualifiedName(nameTable.Add("system")); - QnSchemaLocation = new XmlQualifiedName(nameTable.Add("schemaLocation")); - QnValue = new XmlQualifiedName(nameTable.Add("value")); - QnUse = new XmlQualifiedName(nameTable.Add("use")); - QnForm = new XmlQualifiedName(nameTable.Add("form")); - QnAttributeFormDefault = new XmlQualifiedName(nameTable.Add("attributeFormDefault")); - QnElementFormDefault = new XmlQualifiedName(nameTable.Add("elementFormDefault")); - QnSource = new XmlQualifiedName(nameTable.Add("source")); - QnMemberTypes = new XmlQualifiedName(nameTable.Add("memberTypes")); - QnItemType = new XmlQualifiedName(nameTable.Add("itemType")); - QnXPath = new XmlQualifiedName(nameTable.Add("xpath")); - - // XDR namespace - QnXdrSchema = new XmlQualifiedName(XdrSchema, NsXdr); - QnXdrElementType = new XmlQualifiedName(nameTable.Add("ElementType"), NsXdr); - QnXdrElement = new XmlQualifiedName(nameTable.Add("element"), NsXdr); - QnXdrGroup = new XmlQualifiedName(nameTable.Add("group"), NsXdr); - QnXdrAttributeType = new XmlQualifiedName(nameTable.Add("AttributeType"), NsXdr); - QnXdrAttribute = new XmlQualifiedName(nameTable.Add("attribute"), NsXdr); - QnXdrDataType = new XmlQualifiedName(nameTable.Add("datatype"), NsXdr); - QnXdrDescription = new XmlQualifiedName(nameTable.Add("description"), NsXdr); - QnXdrExtends = new XmlQualifiedName(nameTable.Add("extends"), NsXdr); - - // XDR alias namespace - QnXdrAliasSchema = new XmlQualifiedName(nameTable.Add("Schema"), NsDataTypeAlias); - - // DataType namespace - QnDtType = new XmlQualifiedName(nameTable.Add("type"), NsDataType); - QnDtValues = new XmlQualifiedName(nameTable.Add("values"), NsDataType); - QnDtMaxLength = new XmlQualifiedName(nameTable.Add("maxLength"), NsDataType); - QnDtMinLength = new XmlQualifiedName(nameTable.Add("minLength"), NsDataType); - QnDtMax = new XmlQualifiedName(nameTable.Add("max"), NsDataType); - QnDtMin = new XmlQualifiedName(nameTable.Add("min"), NsDataType); - QnDtMinExclusive = new XmlQualifiedName(nameTable.Add("minExclusive"), NsDataType); - QnDtMaxExclusive = new XmlQualifiedName(nameTable.Add("maxExclusive"), NsDataType); - - // XSD namespace - QnXsdSchema = new XmlQualifiedName(XsdSchema, NsXs); - QnXsdAnnotation = new XmlQualifiedName(nameTable.Add("annotation"), NsXs); - QnXsdInclude = new XmlQualifiedName(nameTable.Add("include"), NsXs); - QnXsdImport = new XmlQualifiedName(nameTable.Add("import"), NsXs); - QnXsdElement = new XmlQualifiedName(nameTable.Add("element"), NsXs); - QnXsdAttribute = new XmlQualifiedName(nameTable.Add("attribute"), NsXs); - QnXsdAttributeGroup = new XmlQualifiedName(nameTable.Add("attributeGroup"), NsXs); - QnXsdAnyAttribute = new XmlQualifiedName(nameTable.Add("anyAttribute"), NsXs); - QnXsdGroup = new XmlQualifiedName(nameTable.Add("group"), NsXs); - QnXsdAll = new XmlQualifiedName(nameTable.Add("all"), NsXs); - QnXsdChoice = new XmlQualifiedName(nameTable.Add("choice"), NsXs); - QnXsdSequence = new XmlQualifiedName(nameTable.Add("sequence"), NsXs); - QnXsdAny = new XmlQualifiedName(nameTable.Add("any"), NsXs); - QnXsdNotation = new XmlQualifiedName(nameTable.Add("notation"), NsXs); - QnXsdSimpleType = new XmlQualifiedName(nameTable.Add("simpleType"), NsXs); - QnXsdComplexType = new XmlQualifiedName(nameTable.Add("complexType"), NsXs); - QnXsdUnique = new XmlQualifiedName(nameTable.Add("unique"), NsXs); - QnXsdKey = new XmlQualifiedName(nameTable.Add("key"), NsXs); - QnXsdKeyRef = new XmlQualifiedName(nameTable.Add("keyref"), NsXs); - QnXsdSelector = new XmlQualifiedName(nameTable.Add("selector"), NsXs); - QnXsdField = new XmlQualifiedName(nameTable.Add("field"), NsXs); - QnXsdMinExclusive = new XmlQualifiedName(nameTable.Add("minExclusive"), NsXs); - QnXsdMinInclusive = new XmlQualifiedName(nameTable.Add("minInclusive"), NsXs); - QnXsdMaxInclusive = new XmlQualifiedName(nameTable.Add("maxInclusive"), NsXs); - QnXsdMaxExclusive = new XmlQualifiedName(nameTable.Add("maxExclusive"), NsXs); - QnXsdTotalDigits = new XmlQualifiedName(nameTable.Add("totalDigits"), NsXs); - QnXsdFractionDigits = new XmlQualifiedName(nameTable.Add("fractionDigits"), NsXs); - QnXsdLength = new XmlQualifiedName(nameTable.Add("length"), NsXs); - QnXsdMinLength = new XmlQualifiedName(nameTable.Add("minLength"), NsXs); - QnXsdMaxLength = new XmlQualifiedName(nameTable.Add("maxLength"), NsXs); - QnXsdEnumeration = new XmlQualifiedName(nameTable.Add("enumeration"), NsXs); - QnXsdPattern = new XmlQualifiedName(nameTable.Add("pattern"), NsXs); - QnXsdDocumentation = new XmlQualifiedName(nameTable.Add("documentation"), NsXs); - QnXsdAppinfo = new XmlQualifiedName(nameTable.Add("appinfo"), NsXs); - QnXsdComplexContent = new XmlQualifiedName(nameTable.Add("complexContent"), NsXs); - QnXsdSimpleContent = new XmlQualifiedName(nameTable.Add("simpleContent"), NsXs); - QnXsdRestriction = new XmlQualifiedName(nameTable.Add("restriction"), NsXs); - QnXsdExtension = new XmlQualifiedName(nameTable.Add("extension"), NsXs); - QnXsdUnion = new XmlQualifiedName(nameTable.Add("union"), NsXs); - QnXsdList = new XmlQualifiedName(nameTable.Add("list"), NsXs); - QnXsdWhiteSpace = new XmlQualifiedName(nameTable.Add("whiteSpace"), NsXs); - QnXsdRedefine = new XmlQualifiedName(nameTable.Add("redefine"), NsXs); - QnXsdAnyType = new XmlQualifiedName(nameTable.Add("anyType"), NsXs); - - //Create token to Qname table - CreateTokenToQNameTable(); - } - - public void CreateTokenToQNameTable() - { - TokenToQName[(int)Token.SchemaName] = QnName; - TokenToQName[(int)Token.SchemaType] = QnType; - TokenToQName[(int)Token.SchemaMaxOccurs] = QnMaxOccurs; - TokenToQName[(int)Token.SchemaMinOccurs] = QnMinOccurs; - TokenToQName[(int)Token.SchemaInfinite] = QnInfinite; - TokenToQName[(int)Token.SchemaModel] = QnModel; - TokenToQName[(int)Token.SchemaOpen] = QnOpen; - TokenToQName[(int)Token.SchemaClosed] = QnClosed; - TokenToQName[(int)Token.SchemaContent] = QnContent; - TokenToQName[(int)Token.SchemaMixed] = QnMixed; - TokenToQName[(int)Token.SchemaEmpty] = QnEmpty; - TokenToQName[(int)Token.SchemaElementOnly] = QnEltOnly; - TokenToQName[(int)Token.SchemaTextOnly] = QnTextOnly; - TokenToQName[(int)Token.SchemaOrder] = QnOrder; - TokenToQName[(int)Token.SchemaSeq] = QnSeq; - TokenToQName[(int)Token.SchemaOne] = QnOne; - TokenToQName[(int)Token.SchemaMany] = QnMany; - TokenToQName[(int)Token.SchemaRequired] = QnRequired; - TokenToQName[(int)Token.SchemaYes] = QnYes; - TokenToQName[(int)Token.SchemaNo] = QnNo; - TokenToQName[(int)Token.SchemaString] = QnString; - TokenToQName[(int)Token.SchemaId] = QnID; - TokenToQName[(int)Token.SchemaIdref] = QnIDRef; - TokenToQName[(int)Token.SchemaIdrefs] = QnIDRefs; - TokenToQName[(int)Token.SchemaEntity] = QnEntity; - TokenToQName[(int)Token.SchemaEntities] = QnEntities; - TokenToQName[(int)Token.SchemaNmtoken] = QnNmToken; - TokenToQName[(int)Token.SchemaNmtokens] = QnNmTokens; - TokenToQName[(int)Token.SchemaEnumeration] = QnEnumeration; - TokenToQName[(int)Token.SchemaDefault] = QnDefault; - TokenToQName[(int)Token.XdrRoot] = QnXdrSchema; - TokenToQName[(int)Token.XdrElementType] = QnXdrElementType; - TokenToQName[(int)Token.XdrElement] = QnXdrElement; - TokenToQName[(int)Token.XdrGroup] = QnXdrGroup; - TokenToQName[(int)Token.XdrAttributeType] = QnXdrAttributeType; - TokenToQName[(int)Token.XdrAttribute] = QnXdrAttribute; - TokenToQName[(int)Token.XdrDatatype] = QnXdrDataType; - TokenToQName[(int)Token.XdrDescription] = QnXdrDescription; - TokenToQName[(int)Token.XdrExtends] = QnXdrExtends; - TokenToQName[(int)Token.SchemaXdrRootAlias] = QnXdrAliasSchema; - TokenToQName[(int)Token.SchemaDtType] = QnDtType; - TokenToQName[(int)Token.SchemaDtValues] = QnDtValues; - TokenToQName[(int)Token.SchemaDtMaxLength] = QnDtMaxLength; - TokenToQName[(int)Token.SchemaDtMinLength] = QnDtMinLength; - TokenToQName[(int)Token.SchemaDtMax] = QnDtMax; - TokenToQName[(int)Token.SchemaDtMin] = QnDtMin; - TokenToQName[(int)Token.SchemaDtMinExclusive] = QnDtMinExclusive; - TokenToQName[(int)Token.SchemaDtMaxExclusive] = QnDtMaxExclusive; - TokenToQName[(int)Token.SchemaTargetNamespace] = QnTargetNamespace; - TokenToQName[(int)Token.SchemaVersion] = QnVersion; - TokenToQName[(int)Token.SchemaFinalDefault] = QnFinalDefault; - TokenToQName[(int)Token.SchemaBlockDefault] = QnBlockDefault; - TokenToQName[(int)Token.SchemaFixed] = QnFixed; - TokenToQName[(int)Token.SchemaAbstract] = QnAbstract; - TokenToQName[(int)Token.SchemaBlock] = QnBlock; - TokenToQName[(int)Token.SchemaSubstitutionGroup] = QnSubstitutionGroup; - TokenToQName[(int)Token.SchemaFinal] = QnFinal; - TokenToQName[(int)Token.SchemaNillable] = QnNillable; - TokenToQName[(int)Token.SchemaRef] = QnRef; - TokenToQName[(int)Token.SchemaBase] = QnBase; - TokenToQName[(int)Token.SchemaDerivedBy] = QnDerivedBy; - TokenToQName[(int)Token.SchemaNamespace] = QnNamespace; - TokenToQName[(int)Token.SchemaProcessContents] = QnProcessContents; - TokenToQName[(int)Token.SchemaRefer] = QnRefer; - TokenToQName[(int)Token.SchemaPublic] = QnPublic; - TokenToQName[(int)Token.SchemaSystem] = QnSystem; - TokenToQName[(int)Token.SchemaSchemaLocation] = QnSchemaLocation; - TokenToQName[(int)Token.SchemaValue] = QnValue; - TokenToQName[(int)Token.SchemaItemType] = QnItemType; - TokenToQName[(int)Token.SchemaMemberTypes] = QnMemberTypes; - TokenToQName[(int)Token.SchemaXPath] = QnXPath; - TokenToQName[(int)Token.XsdSchema] = QnXsdSchema; - TokenToQName[(int)Token.XsdAnnotation] = QnXsdAnnotation; - TokenToQName[(int)Token.XsdInclude] = QnXsdInclude; - TokenToQName[(int)Token.XsdImport] = QnXsdImport; - TokenToQName[(int)Token.XsdElement] = QnXsdElement; - TokenToQName[(int)Token.XsdAttribute] = QnXsdAttribute; - TokenToQName[(int)Token.xsdAttributeGroup] = QnXsdAttributeGroup; - TokenToQName[(int)Token.XsdAnyAttribute] = QnXsdAnyAttribute; - TokenToQName[(int)Token.XsdGroup] = QnXsdGroup; - TokenToQName[(int)Token.XsdAll] = QnXsdAll; - TokenToQName[(int)Token.XsdChoice] = QnXsdChoice; - TokenToQName[(int)Token.XsdSequence] = QnXsdSequence; - TokenToQName[(int)Token.XsdAny] = QnXsdAny; - TokenToQName[(int)Token.XsdNotation] = QnXsdNotation; - TokenToQName[(int)Token.XsdSimpleType] = QnXsdSimpleType; - TokenToQName[(int)Token.XsdComplexType] = QnXsdComplexType; - TokenToQName[(int)Token.XsdUnique] = QnXsdUnique; - TokenToQName[(int)Token.XsdKey] = QnXsdKey; - TokenToQName[(int)Token.XsdKeyref] = QnXsdKeyRef; - TokenToQName[(int)Token.XsdSelector] = QnXsdSelector; - TokenToQName[(int)Token.XsdField] = QnXsdField; - TokenToQName[(int)Token.XsdMinExclusive] = QnXsdMinExclusive; - TokenToQName[(int)Token.XsdMinInclusive] = QnXsdMinInclusive; - TokenToQName[(int)Token.XsdMaxExclusive] = QnXsdMaxExclusive; - TokenToQName[(int)Token.XsdMaxInclusive] = QnXsdMaxInclusive; - TokenToQName[(int)Token.XsdTotalDigits] = QnXsdTotalDigits; - TokenToQName[(int)Token.XsdFractionDigits] = QnXsdFractionDigits; - TokenToQName[(int)Token.XsdLength] = QnXsdLength; - TokenToQName[(int)Token.XsdMinLength] = QnXsdMinLength; - TokenToQName[(int)Token.XsdMaxLength] = QnXsdMaxLength; - TokenToQName[(int)Token.XsdEnumeration] = QnXsdEnumeration; - TokenToQName[(int)Token.XsdPattern] = QnXsdPattern; - TokenToQName[(int)Token.XsdWhitespace] = QnXsdWhiteSpace; - TokenToQName[(int)Token.XsdDocumentation] = QnXsdDocumentation; - TokenToQName[(int)Token.XsdAppInfo] = QnXsdAppinfo; - TokenToQName[(int)Token.XsdComplexContent] = QnXsdComplexContent; - TokenToQName[(int)Token.XsdComplexContentRestriction] = QnXsdRestriction; - TokenToQName[(int)Token.XsdSimpleContentRestriction] = QnXsdRestriction; - TokenToQName[(int)Token.XsdSimpleTypeRestriction] = QnXsdRestriction; - TokenToQName[(int)Token.XsdComplexContentExtension] = QnXsdExtension; - TokenToQName[(int)Token.XsdSimpleContentExtension] = QnXsdExtension; - TokenToQName[(int)Token.XsdSimpleContent] = QnXsdSimpleContent; - TokenToQName[(int)Token.XsdSimpleTypeUnion] = QnXsdUnion; - TokenToQName[(int)Token.XsdSimpleTypeList] = QnXsdList; - TokenToQName[(int)Token.XsdRedefine] = QnXsdRedefine; - TokenToQName[(int)Token.SchemaSource] = QnSource; - TokenToQName[(int)Token.SchemaUse] = QnUse; - TokenToQName[(int)Token.SchemaForm] = QnForm; - TokenToQName[(int)Token.SchemaElementFormDefault] = QnElementFormDefault; - TokenToQName[(int)Token.SchemaAttributeFormDefault] = QnAttributeFormDefault; - TokenToQName[(int)Token.XmlLang] = QnXmlLang; - TokenToQName[(int)Token.Empty] = XmlQualifiedName.Empty; - } - - public SchemaType SchemaTypeFromRoot(string localName, string ns) - { - if (IsXSDRoot(localName, ns)) - { - return SchemaType.XSD; - } - else if (IsXDRRoot(localName, XmlSchemaDatatype.XdrCanonizeUri(ns, _nameTable, this))) - { - return SchemaType.XDR; - } - else - { - return SchemaType.None; - } - } - - public bool IsXSDRoot(string localName, string ns) - { - return Ref.Equal(ns, NsXs) && Ref.Equal(localName, XsdSchema); - } - - public bool IsXDRRoot(string localName, string ns) - { - return Ref.Equal(ns, NsXdr) && Ref.Equal(localName, XdrSchema); - } - - public XmlQualifiedName GetName(SchemaNames.Token token) - { - return TokenToQName[(int)token]; - } - - public enum Token - { - Empty, - SchemaName, - SchemaType, - SchemaMaxOccurs, - SchemaMinOccurs, - SchemaInfinite, - SchemaModel, - SchemaOpen, - SchemaClosed, - SchemaContent, - SchemaMixed, - SchemaEmpty, - SchemaElementOnly, - SchemaTextOnly, - SchemaOrder, - SchemaSeq, - SchemaOne, - SchemaMany, - SchemaRequired, - SchemaYes, - SchemaNo, - SchemaString, - SchemaId, - SchemaIdref, - SchemaIdrefs, - SchemaEntity, - SchemaEntities, - SchemaNmtoken, - SchemaNmtokens, - SchemaEnumeration, - SchemaDefault, - XdrRoot, - XdrElementType, - XdrElement, - XdrGroup, - XdrAttributeType, - XdrAttribute, - XdrDatatype, - XdrDescription, - XdrExtends, - SchemaXdrRootAlias, - SchemaDtType, - SchemaDtValues, - SchemaDtMaxLength, - SchemaDtMinLength, - SchemaDtMax, - SchemaDtMin, - SchemaDtMinExclusive, - SchemaDtMaxExclusive, - SchemaTargetNamespace, - SchemaVersion, - SchemaFinalDefault, - SchemaBlockDefault, - SchemaFixed, - SchemaAbstract, - SchemaBlock, - SchemaSubstitutionGroup, - SchemaFinal, - SchemaNillable, - SchemaRef, - SchemaBase, - SchemaDerivedBy, - SchemaNamespace, - SchemaProcessContents, - SchemaRefer, - SchemaPublic, - SchemaSystem, - SchemaSchemaLocation, - SchemaValue, - SchemaSource, - SchemaAttributeFormDefault, - SchemaElementFormDefault, - SchemaUse, - SchemaForm, - XsdSchema, - XsdAnnotation, - XsdInclude, - XsdImport, - XsdElement, - XsdAttribute, - xsdAttributeGroup, - XsdAnyAttribute, - XsdGroup, - XsdAll, - XsdChoice, - XsdSequence, - XsdAny, - XsdNotation, - XsdSimpleType, - XsdComplexType, - XsdUnique, - XsdKey, - XsdKeyref, - XsdSelector, - XsdField, - XsdMinExclusive, - XsdMinInclusive, - XsdMaxExclusive, - XsdMaxInclusive, - XsdTotalDigits, - XsdFractionDigits, - XsdLength, - XsdMinLength, - XsdMaxLength, - XsdEnumeration, - XsdPattern, - XsdDocumentation, - XsdAppInfo, - XsdComplexContent, - XsdComplexContentExtension, - XsdComplexContentRestriction, - XsdSimpleContent, - XsdSimpleContentExtension, - XsdSimpleContentRestriction, - XsdSimpleTypeList, - XsdSimpleTypeRestriction, - XsdSimpleTypeUnion, - XsdWhitespace, - XsdRedefine, - SchemaItemType, - SchemaMemberTypes, - SchemaXPath, - XmlLang - }; - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNamespaceManager.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNamespaceManager.cs deleted file mode 100644 index f2a5e0331d8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNamespaceManager.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Diagnostics; - using System.Collections; - - internal class SchemaNamespaceManager : XmlNamespaceManager - { - private XmlSchemaObject _node; - - public SchemaNamespaceManager(XmlSchemaObject node) - { - _node = node; - } - - public override string LookupNamespace(string prefix) - { - if (prefix == "xml") - { //Special case for the XML namespace - return XmlReservedNs.NsXml; - } - Hashtable namespaces; - for (XmlSchemaObject current = _node; current != null; current = current.Parent) - { - namespaces = current.Namespaces.Namespaces; - if (namespaces != null && namespaces.Count > 0) - { - object uri = namespaces[prefix]; - if (uri != null) - return (string)uri; - } - } - return prefix.Length == 0 ? string.Empty : null; - } - - public override string LookupPrefix(string ns) - { - if (ns == XmlReservedNs.NsXml) - { //Special case for the XML namespace - return "xml"; - } - Hashtable namespaces; - for (XmlSchemaObject current = _node; current != null; current = current.Parent) - { - namespaces = current.Namespaces.Namespaces; - if (namespaces != null && namespaces.Count > 0) - { - foreach (DictionaryEntry entry in namespaces) - { - if (entry.Value.Equals(ns)) - { - return (string)entry.Key; - } - } - } - } - return null; - } - }; //SchemaNamespaceManager -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNotation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNotation.cs deleted file mode 100644 index b10a4ba0e04..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaNotation.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Diagnostics; - - internal sealed class SchemaNotation - { - internal const int SYSTEM = 0; - internal const int PUBLIC = 1; - - private XmlQualifiedName _name; - private String _systemLiteral; // System literal - private String _pubid; // pubid literal - - internal SchemaNotation(XmlQualifiedName name) - { - _name = name; - } - - internal XmlQualifiedName Name - { - get { return _name; } - } - - internal String SystemLiteral - { - get { return _systemLiteral; } - set { _systemLiteral = value; } - } - - internal String Pubid - { - get { return _pubid; } - set { _pubid = value; } - } - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaSetCompiler.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaSetCompiler.cs deleted file mode 100644 index 3acb29f7358..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaSetCompiler.cs +++ /dev/null @@ -1,3281 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Globalization; - using System.Text; - using System.Diagnostics; - using System.Reflection; - using Microsoft.Xml; - - internal sealed class Compiler : BaseProcessor - { - private string _restrictionErrorMsg; - private XmlSchemaObjectTable _attributes = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _attributeGroups = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _elements = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _schemaTypes = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _groups = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _notations = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _examplars = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _identityConstraints = new XmlSchemaObjectTable(); - private Stack _complexTypeStack = new Stack(); - private Hashtable _schemasToCompile = new Hashtable(); - private Hashtable _importedSchemas = new Hashtable(); - - private XmlSchema _schemaForSchema; - - public Compiler(XmlNameTable nameTable, ValidationEventHandler eventHandler, XmlSchema schemaForSchema, XmlSchemaCompilationSettings compilationSettings) : base(nameTable, null, eventHandler, compilationSettings) - { - _schemaForSchema = schemaForSchema; - } - - public bool Execute(XmlSchemaSet schemaSet, SchemaInfo schemaCompiledInfo) - { - Compile(); - if (!HasErrors) - { - Output(schemaCompiledInfo); - schemaSet.elements = _elements; - schemaSet.attributes = _attributes; - schemaSet.schemaTypes = _schemaTypes; - schemaSet.substitutionGroups = _examplars; - } - return !HasErrors; - } - - internal void Prepare(XmlSchema schema, bool cleanup) - { - if (_schemasToCompile[schema] != null) - { - return; - } - _schemasToCompile.Add(schema, schema); - foreach (XmlSchemaElement element in schema.Elements.Values) - { - if (cleanup) - { - CleanupElement(element); - } - AddToTable(_elements, element.QualifiedName, element); - } - foreach (XmlSchemaAttribute attribute in schema.Attributes.Values) - { - if (cleanup) - { - CleanupAttribute(attribute); - } - AddToTable(_attributes, attribute.QualifiedName, attribute); - } - foreach (XmlSchemaGroup group in schema.Groups.Values) - { - if (cleanup) - { - CleanupGroup(group); - } - AddToTable(_groups, group.QualifiedName, group); - } - foreach (XmlSchemaAttributeGroup attributeGroup in schema.AttributeGroups.Values) - { - if (cleanup) - { - CleanupAttributeGroup(attributeGroup); - } - AddToTable(_attributeGroups, attributeGroup.QualifiedName, attributeGroup); - } - foreach (XmlSchemaType type in schema.SchemaTypes.Values) - { - if (cleanup) - { - XmlSchemaComplexType ct = type as XmlSchemaComplexType; - if (ct != null) - { - CleanupComplexType(ct); - } - else - { - CleanupSimpleType(type as XmlSchemaSimpleType); - } - } - AddToTable(_schemaTypes, type.QualifiedName, type); - } - foreach (XmlSchemaNotation notation in schema.Notations.Values) - { - AddToTable(_notations, notation.QualifiedName, notation); - } - foreach (XmlSchemaIdentityConstraint ic in schema.IdentityConstraints.Values) - { - AddToTable(_identityConstraints, ic.QualifiedName, ic); - } - } - - private void UpdateSForSSimpleTypes() - { - Debug.Assert(_schemaForSchema != null); - XmlSchemaSimpleType[] schemaSimpleTypes = DatatypeImplementation.GetBuiltInTypes(); - XmlSchemaSimpleType builtInType; - //Using enumToTypeCode array; indexed by XmlTypeCode; Start indexing from 12 since schema types start there and iterate till Length - 2 as the last 2 are xquery types - int numberOfSchemaTypes = schemaSimpleTypes.Length - 3; //skip last 2 xquery types - for (int i = 12; i < numberOfSchemaTypes; i++) - { - builtInType = schemaSimpleTypes[i]; - _schemaForSchema.SchemaTypes.Replace(builtInType.QualifiedName, builtInType); - _schemaTypes.Replace(builtInType.QualifiedName, builtInType); - } - } - - private void Output(SchemaInfo schemaInfo) - { - string tns; - foreach (XmlSchema schema in _schemasToCompile.Values) - { - tns = schema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - schemaInfo.TargetNamespaces[tns] = true; - } - foreach (XmlSchemaElement element in _elements.Values) - { - schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl); - } - foreach (XmlSchemaAttribute attribute in _attributes.Values) - { - schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef); - } - foreach (XmlSchemaType type in _schemaTypes.Values) - { - schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl); - } - foreach (XmlSchemaNotation notation in _notations.Values) - { - SchemaNotation no = new SchemaNotation(notation.QualifiedName); - no.SystemLiteral = notation.System; - no.Pubid = notation.Public; - if (!schemaInfo.Notations.ContainsKey(no.Name.Name)) - { - schemaInfo.Notations.Add(no.Name.Name, no); - } - } - } - - internal void ImportAllCompiledSchemas(XmlSchemaSet schemaSet) - { - XmlSchema currentSchema; - int schemaIndex; - SortedList schemas = schemaSet.SortedSchemas; - for (schemaIndex = 0; schemaIndex < schemas.Count; schemaIndex++) - { - currentSchema = (XmlSchema)schemas.GetByIndex(schemaIndex); - if (currentSchema.IsCompiledBySet) - { //Import already compiled schemas - Prepare(currentSchema, false); - } - } - } - - internal bool Compile() - { - _schemaTypes.Insert(DatatypeImplementation.QnAnyType, XmlSchemaComplexType.AnyType); - if (_schemaForSchema != null) - { //Get our built-in types - _schemaForSchema.SchemaTypes.Replace(DatatypeImplementation.QnAnyType, XmlSchemaComplexType.AnyType); - UpdateSForSSimpleTypes(); - } - - foreach (XmlSchemaGroup group in _groups.Values) - { - CompileGroup(group); - } - foreach (XmlSchemaAttributeGroup attributeGroup in _attributeGroups.Values) - { - CompileAttributeGroup(attributeGroup); - } - foreach (XmlSchemaType type in _schemaTypes.Values) - { - XmlSchemaComplexType ct = type as XmlSchemaComplexType; - if (ct != null) - { - CompileComplexType(ct); - } - else - { - CompileSimpleType((XmlSchemaSimpleType)type); - } - } - foreach (XmlSchemaElement element in _elements.Values) - { - if (element.ElementDecl == null) - { - CompileElement(element); - } - } - foreach (XmlSchemaAttribute attribute in _attributes.Values) - { - if (attribute.AttDef == null) - { - CompileAttribute(attribute); - } - } - foreach (XmlSchemaIdentityConstraint identityConstraint in _identityConstraints.Values) - { - if (identityConstraint.CompiledConstraint == null) - { - CompileIdentityConstraint(identityConstraint); - } - } - while (_complexTypeStack.Count > 0) - { - XmlSchemaComplexType type = (XmlSchemaComplexType)_complexTypeStack.Pop(); - CompileComplexTypeElements(type); - } - - ProcessSubstitutionGroups(); - - foreach (XmlSchemaType type in _schemaTypes.Values) - { - XmlSchemaComplexType localType = type as XmlSchemaComplexType; - if (localType != null) - { - CheckParticleDerivation(localType); - } - } - - foreach (XmlSchemaElement element in _elements.Values) - { - XmlSchemaComplexType localComplexType = element.ElementSchemaType as XmlSchemaComplexType; - if (localComplexType != null && element.SchemaTypeName == XmlQualifiedName.Empty) - { // only local schemaTypes - CheckParticleDerivation(localComplexType); - } - } - foreach (XmlSchemaGroup group in _groups.Values) - { //Check particle derivation for redefined groups - XmlSchemaGroup baseGroup = group.Redefined; - if (baseGroup != null) - { - RecursivelyCheckRedefinedGroups(group, baseGroup); - } - } - - foreach (XmlSchemaAttributeGroup attributeGroup in _attributeGroups.Values) - { - XmlSchemaAttributeGroup baseAttributeGroup = attributeGroup.Redefined; - if (baseAttributeGroup != null) - { - RecursivelyCheckRedefinedAttributeGroups(attributeGroup, baseAttributeGroup); - } - } - return !HasErrors; - } - - private void CleanupAttribute(XmlSchemaAttribute attribute) - { - if (attribute.SchemaType != null) - { - CleanupSimpleType((XmlSchemaSimpleType)attribute.SchemaType); - } - attribute.AttDef = null; - } - - private void CleanupAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - CleanupAttributes(attributeGroup.Attributes); - attributeGroup.AttributeUses.Clear(); - attributeGroup.AttributeWildcard = null; - if (attributeGroup.Redefined != null) - { - CleanupAttributeGroup(attributeGroup.Redefined); - } - } - - private void CleanupComplexType(XmlSchemaComplexType complexType) - { - if (complexType.QualifiedName == DatatypeImplementation.QnAnyType) - { //if it is built-in anyType dont clean it. - return; - } - if (complexType.ContentModel != null) - { //simpleContent or complexContent - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel; - if (simpleContent.Content is XmlSchemaSimpleContentExtension) - { - XmlSchemaSimpleContentExtension simpleExtension = (XmlSchemaSimpleContentExtension)simpleContent.Content; - CleanupAttributes(simpleExtension.Attributes); - } - else - { //simpleContent.Content is XmlSchemaSimpleContentRestriction - XmlSchemaSimpleContentRestriction simpleRestriction = (XmlSchemaSimpleContentRestriction)simpleContent.Content; - CleanupAttributes(simpleRestriction.Attributes); - } - } - else - { // complexType.ContentModel is XmlSchemaComplexContent - XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; - if (complexContent.Content is XmlSchemaComplexContentExtension) - { - XmlSchemaComplexContentExtension complexExtension = (XmlSchemaComplexContentExtension)complexContent.Content; - CleanupParticle(complexExtension.Particle); - CleanupAttributes(complexExtension.Attributes); - } - else - { //XmlSchemaComplexContentRestriction - XmlSchemaComplexContentRestriction complexRestriction = (XmlSchemaComplexContentRestriction)complexContent.Content; - CleanupParticle(complexRestriction.Particle); - CleanupAttributes(complexRestriction.Attributes); - } - } - } - else - { //equals XmlSchemaComplexContent with baseType is anyType - CleanupParticle(complexType.Particle); - CleanupAttributes(complexType.Attributes); - } - complexType.LocalElements.Clear(); - complexType.AttributeUses.Clear(); - complexType.SetAttributeWildcard(null); - complexType.SetContentTypeParticle(XmlSchemaParticle.Empty); - complexType.ElementDecl = null; - complexType.HasWildCard = false; - - //Clean up the original type if this is a redefined type - if (complexType.Redefined != null) - { - CleanupComplexType(complexType.Redefined as XmlSchemaComplexType); - } - } - - private void CleanupSimpleType(XmlSchemaSimpleType simpleType) - { - if (simpleType == XmlSchemaType.GetBuiltInSimpleType(simpleType.TypeCode)) - { //If it is a built-in simple type dont clean up - return; - } - simpleType.ElementDecl = null; - //Clean up the original group if this is a redefined group - if (simpleType.Redefined != null) - { - CleanupSimpleType(simpleType.Redefined as XmlSchemaSimpleType); - } - } - - private void CleanupElement(XmlSchemaElement element) - { - if (element.SchemaType != null) - { - XmlSchemaComplexType complexType = element.SchemaType as XmlSchemaComplexType; - if (complexType != null) - { - CleanupComplexType(complexType); - } - else - { - CleanupSimpleType((XmlSchemaSimpleType)element.SchemaType); - } - } - for (int i = 0; i < element.Constraints.Count; ++i) - { - ((XmlSchemaIdentityConstraint)element.Constraints[i]).CompiledConstraint = null; - } - element.ElementDecl = null; - element.IsLocalTypeDerivationChecked = false; //clear Local element type derivation check - } - - private void CleanupAttributes(XmlSchemaObjectCollection attributes) - { - for (int i = 0; i < attributes.Count; ++i) - { - XmlSchemaAttribute attribute = attributes[i] as XmlSchemaAttribute; - if (attribute != null) - { - CleanupAttribute(attribute); - } - } - } - - private void CleanupGroup(XmlSchemaGroup group) - { - CleanupParticle(group.Particle); - group.CanonicalParticle = null; - //Clean up the original group if this is a redefined group - if (group.Redefined != null) - { - CleanupGroup(group.Redefined); - } - } - - private void CleanupParticle(XmlSchemaParticle particle) - { - XmlSchemaElement element = particle as XmlSchemaElement; - if (element != null) - { - CleanupElement(element); - return; - } - - XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; - if (groupBase != null) - { - for (int i = 0; i < groupBase.Items.Count; ++i) - { - CleanupParticle((XmlSchemaParticle)groupBase.Items[i]); - } - } - } - - private void ProcessSubstitutionGroups() - { - foreach (XmlSchemaElement element in _elements.Values) - { - if (!element.SubstitutionGroup.IsEmpty) - { - XmlSchemaElement headElement = _elements[element.SubstitutionGroup] as XmlSchemaElement; - if (headElement == null) - { - SendValidationEvent(ResXml.Sch_NoExamplar, element); - continue; - } - //Check derivation of member's type against head's type - if (!XmlSchemaType.IsDerivedFrom(element.ElementSchemaType, headElement.ElementSchemaType, headElement.FinalResolved)) - { - SendValidationEvent(ResXml.Sch_InvalidSubstitutionMember, (element.QualifiedName).ToString(), (headElement.QualifiedName).ToString(), element); - } - - //Create substitutionGroup - XmlSchemaSubstitutionGroup substitutionGroup = (XmlSchemaSubstitutionGroup)_examplars[element.SubstitutionGroup]; - if (substitutionGroup == null) - { - substitutionGroup = new XmlSchemaSubstitutionGroup(); - substitutionGroup.Examplar = element.SubstitutionGroup; - _examplars.Add(element.SubstitutionGroup, substitutionGroup); - } - ArrayList members = substitutionGroup.Members; - if (!members.Contains(element)) - { //Members might contain element if the same schema is included and imported through different paths. Imp, hence will be added to set directly - members.Add(element); - } - } - } - - //Check the subst groups that we just built - foreach (XmlSchemaSubstitutionGroup substitutionGroup in _examplars.Values) - { - CompileSubstitutionGroup(substitutionGroup); - } - } - - private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup) - { - if (substitutionGroup.IsProcessing && substitutionGroup.Members.Count > 0) - { - SendValidationEvent(ResXml.Sch_SubstitutionCircularRef, (XmlSchemaElement)substitutionGroup.Members[0]); - return; - } - XmlSchemaElement examplar = (XmlSchemaElement)_elements[substitutionGroup.Examplar]; - Debug.Assert(examplar != null); //Headelement presence is checked while building subst groups - if (substitutionGroup.Members.Contains(examplar)) - {// already checked - return; - } - substitutionGroup.IsProcessing = true; - try - { - if (examplar.FinalResolved == XmlSchemaDerivationMethod.All) - { - SendValidationEvent(ResXml.Sch_InvalidExamplar, examplar); - } - //Build transitive members - ArrayList newMembers = null; - for (int i = 0; i < substitutionGroup.Members.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)substitutionGroup.Members[i]; - //Chain to other head's that are members of this head's substGroup - if ((element.ElementDecl.Block & XmlSchemaDerivationMethod.Substitution) == 0) - { //Chain only if substitution is not blocked - XmlSchemaSubstitutionGroup g = (XmlSchemaSubstitutionGroup)_examplars[element.QualifiedName]; - if (g != null) - { - CompileSubstitutionGroup(g); - for (int j = 0; j < g.Members.Count; ++j) - { - if (g.Members[j] != element) - { //Exclude the head - if (newMembers == null) - { - newMembers = new ArrayList(); - } - newMembers.Add(g.Members[j]); - } - } - } - } - } - if (newMembers != null) - { - for (int i = 0; i < newMembers.Count; ++i) - { - substitutionGroup.Members.Add(newMembers[i]); - } - } - substitutionGroup.Members.Add(examplar); // Compiled mark - } - finally - { - substitutionGroup.IsProcessing = false; - } - } - - private void RecursivelyCheckRedefinedGroups(XmlSchemaGroup redefinedGroup, XmlSchemaGroup baseGroup) - { - if (baseGroup.Redefined != null) - { - RecursivelyCheckRedefinedGroups(baseGroup, baseGroup.Redefined); - } - if (redefinedGroup.SelfReferenceCount == 0) - { - if (baseGroup.CanonicalParticle == null) - { - baseGroup.CanonicalParticle = CannonicalizeParticle(baseGroup.Particle, true); - } - if (redefinedGroup.CanonicalParticle == null) - { - redefinedGroup.CanonicalParticle = CannonicalizeParticle(redefinedGroup.Particle, true); - } - CompileParticleElements(redefinedGroup.CanonicalParticle); - CompileParticleElements(baseGroup.CanonicalParticle); - CheckParticleDerivation(redefinedGroup.CanonicalParticle, baseGroup.CanonicalParticle); - } - } - - private void RecursivelyCheckRedefinedAttributeGroups(XmlSchemaAttributeGroup attributeGroup, XmlSchemaAttributeGroup baseAttributeGroup) - { - if (baseAttributeGroup.Redefined != null) - { - RecursivelyCheckRedefinedAttributeGroups(baseAttributeGroup, baseAttributeGroup.Redefined); - } - if (attributeGroup.SelfReferenceCount == 0) - { - CompileAttributeGroup(baseAttributeGroup); - CompileAttributeGroup(attributeGroup); - CheckAtrributeGroupRestriction(baseAttributeGroup, attributeGroup); - } - } - - private void CompileGroup(XmlSchemaGroup group) - { - if (group.IsProcessing) - { - SendValidationEvent(ResXml.Sch_GroupCircularRef, group); - group.CanonicalParticle = XmlSchemaParticle.Empty; - } - else - { - group.IsProcessing = true; - if (group.CanonicalParticle == null) - { - group.CanonicalParticle = CannonicalizeParticle(group.Particle, true); - } - Debug.Assert(group.CanonicalParticle != null); - group.IsProcessing = false; //Not enclosung in try -finally as cannonicalizeParticle will not throw exception - } - } - - private void CompileSimpleType(XmlSchemaSimpleType simpleType) - { - if (simpleType.IsProcessing) - { - throw new XmlSchemaException(ResXml.Sch_TypeCircularRef, simpleType); - } - if (simpleType.ElementDecl != null) - { // already compiled - return; - } - simpleType.IsProcessing = true; - try - { - if (simpleType.Content is XmlSchemaSimpleTypeList) - { - XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; - XmlSchemaDatatype datatype; - simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); - if (list.ItemTypeName.IsEmpty) - { - CompileSimpleType(list.ItemType); - list.BaseItemType = list.ItemType; - datatype = list.ItemType.Datatype; - } - else - { - XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName); - if (type != null) - { - if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalList, simpleType); - } - list.BaseItemType = type; - datatype = type.Datatype; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), list); - } - } - simpleType.SetDatatype(datatype.DeriveByList(simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List); - } - else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) - { - XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; - XmlSchemaDatatype datatype; - if (restriction.BaseTypeName.IsEmpty) - { - CompileSimpleType(restriction.BaseType); - simpleType.SetBaseSchemaType(restriction.BaseType); - datatype = restriction.BaseType.Datatype; - } - else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) - { - CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined); - simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType); - datatype = simpleType.Redefined.Datatype; - } - else - { - if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType)) - { - XmlSchema parentSchema = Preprocessor.GetParentSchema(simpleType); - if (parentSchema.TargetNamespace != XmlSchema.Namespace) - { //If it is not SForS, then error - throw new XmlSchemaException(ResXml.Sch_InvalidSimpleTypeRestriction, restriction.BaseTypeName.ToString(), simpleType); - } - } - XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName); - if (type != null) - { - if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, simpleType); - } - simpleType.SetBaseSchemaType(type); - datatype = type.Datatype; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), restriction); - } - } - simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, NameTable, simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - } - else - { //simpleType.Content is XmlSchemaSimpleTypeUnion - XmlSchemaSimpleType[] baseTypes = CompileBaseMemberTypes(simpleType); - simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); - simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(baseTypes, simpleType)); - simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union); - } - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(simpleType); - } - SendValidationEvent(e); - simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); - } - finally - { - SchemaElementDecl decl = new SchemaElementDecl(); - decl.ContentValidator = ContentValidator.TextOnly; - decl.SchemaType = simpleType; - decl.Datatype = simpleType.Datatype; - simpleType.ElementDecl = decl; - simpleType.IsProcessing = false; - } - } - - private XmlSchemaSimpleType[] CompileBaseMemberTypes(XmlSchemaSimpleType simpleType) - { - XmlSchemaSimpleType unionMember; - ArrayList memberTypeDefinitions = new ArrayList(); - - XmlSchemaSimpleTypeUnion mainUnion = (XmlSchemaSimpleTypeUnion)simpleType.Content; - - XmlQualifiedName[] mainMemberTypes = mainUnion.MemberTypes; - if (mainMemberTypes != null) - { - for (int i = 0; i < mainMemberTypes.Length; ++i) - { - unionMember = GetSimpleType(mainMemberTypes[i]); - if (unionMember != null) - { - if (unionMember.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { //union of union - CheckUnionType(unionMember, memberTypeDefinitions, simpleType); - } - else - { //its list or atomic - memberTypeDefinitions.Add(unionMember); - } - //Check derivation method of the member that is referenced - if ((unionMember.FinalResolved & XmlSchemaDerivationMethod.Union) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalUnion, simpleType); - } - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, mainMemberTypes[i].ToString(), mainUnion); - } - } - } - - //Now add the baseTypes that are defined inside the union itself - XmlSchemaObjectCollection mainBaseTypes = mainUnion.BaseTypes; //TODO check for null - if (mainBaseTypes != null) - { - for (int i = 0; i < mainBaseTypes.Count; ++i) - { - XmlSchemaSimpleType st = (XmlSchemaSimpleType)mainBaseTypes[i]; - CompileSimpleType(st); - if (st.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { //union of union - CheckUnionType(st, memberTypeDefinitions, simpleType); - } - else - { //its list or atomic - memberTypeDefinitions.Add(st); - } - } - } - //set all types - mainUnion.SetBaseMemberTypes(memberTypeDefinitions.ToArray(typeof(XmlSchemaSimpleType)) as XmlSchemaSimpleType[]); - return mainUnion.BaseMemberTypes; - } - - private void CheckUnionType(XmlSchemaSimpleType unionMember, ArrayList memberTypeDefinitions, XmlSchemaSimpleType parentType) - { - XmlSchemaDatatype unionDatatype = unionMember.Datatype; - if (unionMember.DerivedBy == XmlSchemaDerivationMethod.Restriction && (unionDatatype.HasLexicalFacets || unionDatatype.HasValueFacets)) - { - SendValidationEvent(ResXml.Sch_UnionFromUnion, parentType); - } - else - { - Datatype_union uniondt = unionMember.Datatype as Datatype_union; - memberTypeDefinitions.AddRange(uniondt.BaseMemberTypes); - } - } - - private void CompileComplexType(XmlSchemaComplexType complexType) - { - if (complexType.ElementDecl != null) - { //already compiled - return; - } - if (complexType.IsProcessing) - { - SendValidationEvent(ResXml.Sch_TypeCircularRef, complexType); - return; - } - complexType.IsProcessing = true; - try - { - if (complexType.ContentModel != null) - { //simpleContent or complexContent - if (complexType.ContentModel is XmlSchemaSimpleContent) - { - XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel; - complexType.SetContentType(XmlSchemaContentType.TextOnly); - if (simpleContent.Content is XmlSchemaSimpleContentExtension) - { - CompileSimpleContentExtension(complexType, (XmlSchemaSimpleContentExtension)simpleContent.Content); - } - else - { //simpleContent.Content is XmlSchemaSimpleContentRestriction - CompileSimpleContentRestriction(complexType, (XmlSchemaSimpleContentRestriction)simpleContent.Content); - } - } - else - { // complexType.ContentModel is XmlSchemaComplexContent - XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; - if (complexContent.Content is XmlSchemaComplexContentExtension) - { - CompileComplexContentExtension(complexType, complexContent, (XmlSchemaComplexContentExtension)complexContent.Content); - } - else - { // complexContent.Content is XmlSchemaComplexContentRestriction - CompileComplexContentRestriction(complexType, complexContent, (XmlSchemaComplexContentRestriction)complexContent.Content); - } - } - } - else - { //equals XmlSchemaComplexContent with baseType is anyType - complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType); - CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle)); - complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle)); - } - if (complexType.ContainsIdAttribute(true)) - { - SendValidationEvent(ResXml.Sch_TwoIdAttrUses, complexType); - } - SchemaElementDecl decl = new SchemaElementDecl(); - decl.ContentValidator = CompileComplexContent(complexType); - decl.SchemaType = complexType; - decl.IsAbstract = complexType.IsAbstract; - decl.Datatype = complexType.Datatype; - decl.Block = complexType.BlockResolved; - decl.AnyAttribute = complexType.AttributeWildcard; - foreach (XmlSchemaAttribute attribute in complexType.AttributeUses.Values) - { - if (attribute.Use == XmlSchemaUse.Prohibited) - { - if (!decl.ProhibitedAttributes.ContainsKey(attribute.QualifiedName)) - { - decl.ProhibitedAttributes.Add(attribute.QualifiedName, attribute.QualifiedName); - } - } - else - { - if (!decl.AttDefs.ContainsKey(attribute.QualifiedName) && attribute.AttDef != null && attribute.AttDef.Name != XmlQualifiedName.Empty && attribute.AttDef != SchemaAttDef.Empty) - { - decl.AddAttDef(attribute.AttDef); - } - } - } - complexType.ElementDecl = decl; - } - finally - { - complexType.IsProcessing = false; - } - } - - internal static string GetTempAssemblyName(AssemblyName assemblyName, string defaultNamespace) - { - throw new NotImplementedException(); - } - - private void CompileSimpleContentExtension(XmlSchemaComplexType complexType, XmlSchemaSimpleContentExtension simpleExtension) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && simpleExtension.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - complexType.SetBaseSchemaType(baseType); - complexType.SetDatatype(baseType.Datatype); - } - else - { - XmlSchemaType bto = GetAnySchemaType(simpleExtension.BaseTypeName); - if (bto == null) - { - SendValidationEvent(ResXml.Sch_UndeclaredType, simpleExtension.BaseTypeName.ToString(), simpleExtension); - } - else - { - complexType.SetBaseSchemaType(bto); - complexType.SetDatatype(bto.Datatype); - } - baseType = bto as XmlSchemaComplexType; - } - if (baseType != null) - { - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalExtension, complexType); - } - if (baseType.ContentType != XmlSchemaContentType.TextOnly) - { - SendValidationEvent(ResXml.Sch_NotSimpleContent, complexType); - } - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension); - CompileLocalAttributes(baseType, complexType, simpleExtension.Attributes, simpleExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension); - } - - private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction) - { - XmlSchemaComplexType baseType = null; - XmlSchemaDatatype datatype = null; - if (complexType.Redefined != null && simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - datatype = baseType.Datatype; - } - else - { - baseType = GetComplexType(simpleRestriction.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseRestriction, simpleRestriction.BaseTypeName.ToString(), simpleRestriction); - return; - } - if (baseType.ContentType == XmlSchemaContentType.TextOnly) - { - if (simpleRestriction.BaseType == null) - { - datatype = baseType.Datatype; - //There is a bug here. Need to check if simpleRestriction has facets. - //If yes, Need tp apply these facets as well. - } - else - { - CompileSimpleType(simpleRestriction.BaseType); - if (!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, baseType.Datatype, XmlSchemaDerivationMethod.None)) - { - SendValidationEvent(ResXml.Sch_DerivedNotFromBase, simpleRestriction); - } - datatype = simpleRestriction.BaseType.Datatype; - } - } - else if (baseType.ContentType == XmlSchemaContentType.Mixed && baseType.ElementDecl.ContentValidator.IsEmptiable) - { - if (simpleRestriction.BaseType != null) - { - CompileSimpleType(simpleRestriction.BaseType); - complexType.SetBaseSchemaType(simpleRestriction.BaseType); - datatype = simpleRestriction.BaseType.Datatype; - } - else - { - SendValidationEvent(ResXml.Sch_NeedSimpleTypeChild, simpleRestriction); - } - } - else - { - SendValidationEvent(ResXml.Sch_NotSimpleContent, complexType); - } - } - if (baseType != null && baseType.ElementDecl != null) - { - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, complexType); - } - } - if (baseType != null) - { - complexType.SetBaseSchemaType(baseType); - } - if (datatype != null) - { - try - { - complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, NameTable, complexType)); - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(complexType); - } - SendValidationEvent(e); - complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); - } - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - CompileLocalAttributes(baseType, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - } - - private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - } - else - { - baseType = GetComplexType(complexExtension.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseExtension, complexExtension.BaseTypeName.ToString(), complexExtension); - return; - } - } - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalExtension, complexType); - } - CompileLocalAttributes(baseType, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension); - - XmlSchemaParticle baseParticle = baseType.ContentTypeParticle; - XmlSchemaParticle extendedParticle = CannonicalizeParticle(complexExtension.Particle, true); - if (baseParticle != XmlSchemaParticle.Empty) - { - if (extendedParticle != XmlSchemaParticle.Empty) - { - XmlSchemaSequence compiledParticle = new XmlSchemaSequence(); - compiledParticle.Items.Add(baseParticle); - compiledParticle.Items.Add(extendedParticle); - complexType.SetContentTypeParticle(CompileContentTypeParticle(compiledParticle)); - } - else - { - complexType.SetContentTypeParticle(baseParticle); - } - } - else - { - complexType.SetContentTypeParticle(extendedParticle); - } - XmlSchemaContentType contentType = GetSchemaContentType(complexType, complexContent, extendedParticle); - if (contentType == XmlSchemaContentType.Empty) - { //Derived content type is empty, Get ContentType from base - contentType = baseType.ContentType; - // In case of a simple base type (content type is TextOnly) the derived type - // will be the same as the base type. So set the same content type and then also - // set the same data type. - if (contentType == XmlSchemaContentType.TextOnly) - { - complexType.SetDatatype(baseType.Datatype); - } - } - complexType.SetContentType(contentType); - - if (baseType.ContentType != XmlSchemaContentType.Empty && complexType.ContentType != baseType.ContentType) - { //If base is empty, do not check - SendValidationEvent(ResXml.Sch_DifContentType, complexType); - return; - } - complexType.SetBaseSchemaType(baseType); - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension); - } - - private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) - { - XmlSchemaComplexType baseType = null; - if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) - { - baseType = (XmlSchemaComplexType)complexType.Redefined; - CompileComplexType(baseType); - } - else - { - baseType = GetComplexType(complexRestriction.BaseTypeName); - if (baseType == null) - { - SendValidationEvent(ResXml.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction); - return; - } - } - complexType.SetBaseSchemaType(baseType); - if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) - { - SendValidationEvent(ResXml.Sch_BaseFinalRestriction, complexType); - } - CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); - - complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle)); - XmlSchemaContentType derivedContentType = GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle); - complexType.SetContentType(derivedContentType); - switch (derivedContentType) - { - case XmlSchemaContentType.Empty: - if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) - { //base is either TextOnly or its ElementOnly/Mixed and not emptiable - SendValidationEvent(ResXml.Sch_InvalidContentRestrictionDetailed, ResXml.Sch_InvalidBaseToEmpty, complexType); - } - break; - - case XmlSchemaContentType.Mixed: - if (baseType.ContentType != XmlSchemaContentType.Mixed) - { - SendValidationEvent(ResXml.Sch_InvalidContentRestrictionDetailed, ResXml.Sch_InvalidBaseToMixed, complexType); - } - break; - } - complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); - } - - private void CheckParticleDerivation(XmlSchemaComplexType complexType) - { - XmlSchemaComplexType baseType = complexType.BaseXmlSchemaType as XmlSchemaComplexType; - _restrictionErrorMsg = null; - if (baseType != null && baseType != XmlSchemaComplexType.AnyType && complexType.DerivedBy == XmlSchemaDerivationMethod.Restriction) - { - XmlSchemaParticle derivedParticle = CannonicalizePointlessRoot(complexType.ContentTypeParticle); - XmlSchemaParticle baseParticle = CannonicalizePointlessRoot(baseType.ContentTypeParticle); - if (!IsValidRestriction(derivedParticle, baseParticle)) - { -#if DEBUG - if (complexType.ContentTypeParticle != null && baseType.ContentTypeParticle != null) - { - string position = string.Empty; - if (complexType.SourceUri != null) - { - position = " in " + complexType.SourceUri + "(" + complexType.LineNumber + ", " + complexType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType content restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpContentModel(baseType.ContentTypeParticle)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpContentModel(complexType.ContentTypeParticle)); - } -#endif - if (_restrictionErrorMsg != null) - { - SendValidationEvent(ResXml.Sch_InvalidParticleRestrictionDetailed, _restrictionErrorMsg, complexType); - } - else - { - SendValidationEvent(ResXml.Sch_InvalidParticleRestriction, complexType); - } - } - } - else if (baseType == XmlSchemaComplexType.AnyType) - { //The complex type itself is not explicitly derived by restriction but it could have local elements which have anonymous types that are derived by restriction - foreach (XmlSchemaElement localElement in complexType.LocalElements.Values) - { - if (localElement.IsLocalTypeDerivationChecked) - { //Element already checked - continue; - } - XmlSchemaComplexType localComplexType = localElement.ElementSchemaType as XmlSchemaComplexType; - if (localComplexType != null && localElement.SchemaTypeName == XmlQualifiedName.Empty && localElement.RefName == XmlQualifiedName.Empty) - { //Only local elements - localElement.IsLocalTypeDerivationChecked = true; //Not clearing this flag after recursion to make sure this check is not repeated for multiple references of the same local element (through group refs) - CheckParticleDerivation(localComplexType); - } - } - } - } - - private void CheckParticleDerivation(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle) - { - _restrictionErrorMsg = null; - derivedParticle = CannonicalizePointlessRoot(derivedParticle); - baseParticle = CannonicalizePointlessRoot(baseParticle); - if (!IsValidRestriction(derivedParticle, baseParticle)) - { - if (_restrictionErrorMsg != null) - { - SendValidationEvent(ResXml.Sch_InvalidParticleRestrictionDetailed, _restrictionErrorMsg, derivedParticle); - } - else - { - SendValidationEvent(ResXml.Sch_InvalidParticleRestriction, derivedParticle); - } - } - } - - private XmlSchemaParticle CompileContentTypeParticle(XmlSchemaParticle particle) - { - XmlSchemaParticle ctp = CannonicalizeParticle(particle, true); - XmlSchemaChoice choice = ctp as XmlSchemaChoice; - if (choice != null && choice.Items.Count == 0) - { - if (choice.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, choice, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - return ctp; - } - - private XmlSchemaParticle CannonicalizeParticle(XmlSchemaParticle particle, bool root) - { - if (particle == null || particle.IsEmpty) - { - return XmlSchemaParticle.Empty; - } - else if (particle is XmlSchemaElement) - { - //return CannonicalizeElement((XmlSchemaElement)particle, substitution); - return particle; - } - else if (particle is XmlSchemaGroupRef) - { - return CannonicalizeGroupRef((XmlSchemaGroupRef)particle, root); - } - else if (particle is XmlSchemaAll) - { - return CannonicalizeAll((XmlSchemaAll)particle, root); - } - else if (particle is XmlSchemaChoice) - { - return CannonicalizeChoice((XmlSchemaChoice)particle, root); - } - else if (particle is XmlSchemaSequence) - { - return CannonicalizeSequence((XmlSchemaSequence)particle, root); - } - else - { - return particle; - } - } - - private XmlSchemaParticle CannonicalizeElement(XmlSchemaElement element) - { - if (!element.RefName.IsEmpty && (element.ElementDecl.Block & XmlSchemaDerivationMethod.Substitution) == 0) - { - XmlSchemaSubstitutionGroup substitutionGroup = (XmlSchemaSubstitutionGroup)_examplars[element.QualifiedName]; - if (substitutionGroup == null) - { - return element; - } - else - { - XmlSchemaChoice choice = new XmlSchemaChoice(); - for (int i = 0; i < substitutionGroup.Members.Count; ++i) - { - choice.Items.Add((XmlSchemaElement)substitutionGroup.Members[i]); - } - choice.MinOccurs = element.MinOccurs; - choice.MaxOccurs = element.MaxOccurs; - CopyPosition(choice, element, false); - return choice; - } - } - else - { - return element; - } - } - - private XmlSchemaParticle CannonicalizeGroupRef(XmlSchemaGroupRef groupRef, bool root) - { - XmlSchemaGroup group; - if (groupRef.Redefined != null) - { - group = groupRef.Redefined; - } - else - { - group = (XmlSchemaGroup)_groups[groupRef.RefName]; - } - if (group == null) - { - SendValidationEvent(ResXml.Sch_UndefGroupRef, groupRef.RefName.ToString(), groupRef); - return XmlSchemaParticle.Empty; - } - if (group.CanonicalParticle == null) - { - CompileGroup(group); - } - if (group.CanonicalParticle == XmlSchemaParticle.Empty) - { - return XmlSchemaParticle.Empty; - } - XmlSchemaGroupBase groupBase = (XmlSchemaGroupBase)group.CanonicalParticle; - if (groupBase is XmlSchemaAll) - { - if (!root) - { - SendValidationEvent(ResXml.Sch_AllRefNotRoot, "", groupRef); - return XmlSchemaParticle.Empty; - } - if (groupRef.MinOccurs > decimal.One || groupRef.MaxOccurs != decimal.One) - { - SendValidationEvent(ResXml.Sch_AllRefMinMax, groupRef); - return XmlSchemaParticle.Empty; - } - } - else if (groupBase is XmlSchemaChoice && groupBase.Items.Count == 0) - { - if (groupRef.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, groupRef, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - XmlSchemaGroupBase groupRefBase = ( - (groupBase is XmlSchemaSequence) ? (XmlSchemaGroupBase)new XmlSchemaSequence() : - (groupBase is XmlSchemaChoice) ? (XmlSchemaGroupBase)new XmlSchemaChoice() : - (XmlSchemaGroupBase)new XmlSchemaAll() - ); - groupRefBase.MinOccurs = groupRef.MinOccurs; - groupRefBase.MaxOccurs = groupRef.MaxOccurs; - CopyPosition(groupRefBase, groupRef, true); - - for (int i = 0; i < groupBase.Items.Count; ++i) - { - groupRefBase.Items.Add(groupBase.Items[i]); - } - groupRef.SetParticle(groupRefBase); - return groupRefBase; - } - - private XmlSchemaParticle CannonicalizeAll(XmlSchemaAll all, bool root) - { - if (all.Items.Count > 0) - { - XmlSchemaAll newAll = new XmlSchemaAll(); - newAll.MinOccurs = all.MinOccurs; - newAll.MaxOccurs = all.MaxOccurs; - CopyPosition(newAll, all, true); - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaParticle p = CannonicalizeParticle((XmlSchemaElement)all.Items[i], false); - if (p != XmlSchemaParticle.Empty) - { - newAll.Items.Add(p); - } - } - all = newAll; - } - if (all.Items.Count == 0) - { - return XmlSchemaParticle.Empty; - } - else if (!root) - { - SendValidationEvent(ResXml.Sch_NotAllAlone, all); - return XmlSchemaParticle.Empty; - } - else - { - return all; - } - } - - private XmlSchemaParticle CannonicalizeChoice(XmlSchemaChoice choice, bool root) - { - XmlSchemaChoice oldChoice = choice; - if (choice.Items.Count > 0) - { - XmlSchemaChoice newChoice = new XmlSchemaChoice(); - newChoice.MinOccurs = choice.MinOccurs; - newChoice.MaxOccurs = choice.MaxOccurs; - CopyPosition(newChoice, choice, true); - for (int i = 0; i < choice.Items.Count; ++i) - { - XmlSchemaParticle p1 = CannonicalizeParticle((XmlSchemaParticle)choice.Items[i], false); - if (p1 != XmlSchemaParticle.Empty) - { - if (p1.MinOccurs == decimal.One && p1.MaxOccurs == decimal.One && p1 is XmlSchemaChoice) - { - XmlSchemaChoice p1Choice = p1 as XmlSchemaChoice; - for (int j = 0; j < p1Choice.Items.Count; ++j) - { - newChoice.Items.Add(p1Choice.Items[j]); - } - } - else - { - newChoice.Items.Add(p1); - } - } - } - choice = newChoice; - } - if (!root && choice.Items.Count == 0) - { - if (choice.MinOccurs != decimal.Zero) - { - SendValidationEvent(ResXml.Sch_EmptyChoice, oldChoice, XmlSeverityType.Warning); - } - return XmlSchemaParticle.Empty; - } - else if (!root && choice.Items.Count == 1 && choice.MinOccurs == decimal.One && choice.MaxOccurs == decimal.One) - { - return (XmlSchemaParticle)choice.Items[0]; - } - else - { - return choice; - } - } - - private XmlSchemaParticle CannonicalizeSequence(XmlSchemaSequence sequence, bool root) - { - if (sequence.Items.Count > 0) - { - XmlSchemaSequence newSequence = new XmlSchemaSequence(); - newSequence.MinOccurs = sequence.MinOccurs; - newSequence.MaxOccurs = sequence.MaxOccurs; - CopyPosition(newSequence, sequence, true); - for (int i = 0; i < sequence.Items.Count; ++i) - { - XmlSchemaParticle p1 = CannonicalizeParticle((XmlSchemaParticle)sequence.Items[i], false); - if (p1 != XmlSchemaParticle.Empty) - { - XmlSchemaSequence p1Sequence = p1 as XmlSchemaSequence; - if (p1.MinOccurs == decimal.One && p1.MaxOccurs == decimal.One && p1Sequence != null) - { - for (int j = 0; j < p1Sequence.Items.Count; ++j) - { - newSequence.Items.Add(p1Sequence.Items[j]); - } - } - else - { - newSequence.Items.Add(p1); - } - } - } - sequence = newSequence; - } - if (sequence.Items.Count == 0) - { - return XmlSchemaParticle.Empty; - } - else if (!root && sequence.Items.Count == 1 && sequence.MinOccurs == decimal.One && sequence.MaxOccurs == decimal.One) - { - return (XmlSchemaParticle)sequence.Items[0]; - } - else - { - return sequence; - } - } - - private XmlSchemaParticle CannonicalizePointlessRoot(XmlSchemaParticle particle) - { - if (particle == null) - { - return null; - } - XmlSchemaSequence xss; - XmlSchemaChoice xsc; - XmlSchemaAll xsa; - decimal one = decimal.One; - - if ((xss = (particle as XmlSchemaSequence)) != null) - { - XmlSchemaObjectCollection items = xss.Items; - int count = items.Count; - if (count == 1) - { - if (xss.MinOccurs == one && xss.MaxOccurs == one) - { - return (XmlSchemaParticle)items[0]; - } - } - } - else if ((xsc = (particle as XmlSchemaChoice)) != null) - { - XmlSchemaObjectCollection items = xsc.Items; - int count = items.Count; - - if (count == 1) - { - if (xsc.MinOccurs == one && xsc.MaxOccurs == one) - { - return (XmlSchemaParticle)items[0]; - } - } - else if (count == 0) - { - return XmlSchemaParticle.Empty; - } - } - else if ((xsa = (particle as XmlSchemaAll)) != null) - { - XmlSchemaObjectCollection items = xsa.Items; - int count = items.Count; - - if (count == 1) - { - if (xsa.MinOccurs == one && xsa.MaxOccurs == one) - { - return (XmlSchemaParticle)items[0]; - } - } - } - - return particle; - } - - private bool IsValidRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle) - { - if (derivedParticle == baseParticle) - { - return true; - } - else if (derivedParticle == null || derivedParticle == XmlSchemaParticle.Empty) - { - return IsParticleEmptiable(baseParticle); - } - else if (baseParticle == null || baseParticle == XmlSchemaParticle.Empty) - { - return false; - } - if (derivedParticle is XmlSchemaElement) - { //check for derived element being head of substitutionGroup - XmlSchemaElement derivedElem = (XmlSchemaElement)derivedParticle; - derivedParticle = CannonicalizeElement(derivedElem); - } - if (baseParticle is XmlSchemaElement) - { - XmlSchemaElement baseElem = (XmlSchemaElement)baseParticle; - XmlSchemaParticle newBaseParticle; - newBaseParticle = CannonicalizeElement(baseElem); - if (newBaseParticle is XmlSchemaChoice) - { //Base Element is subs grp head. - return IsValidRestriction(derivedParticle, newBaseParticle); - } - else if (derivedParticle is XmlSchemaElement) - { - return IsElementFromElement((XmlSchemaElement)derivedParticle, baseElem); - } - else - { - _restrictionErrorMsg = ResXml.Sch_ForbiddenDerivedParticleForElem; - return false; - } - } - else if (baseParticle is XmlSchemaAny) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromAny((XmlSchemaElement)derivedParticle, (XmlSchemaAny)baseParticle); - } - else if (derivedParticle is XmlSchemaAny) - { - return IsAnyFromAny((XmlSchemaAny)derivedParticle, (XmlSchemaAny)baseParticle); - } - else - { - return IsGroupBaseFromAny((XmlSchemaGroupBase)derivedParticle, (XmlSchemaAny)baseParticle); - } - } - else if (baseParticle is XmlSchemaAll) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle); - } - else if (derivedParticle is XmlSchemaAll) - { - if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)derivedParticle, (XmlSchemaGroupBase)baseParticle, true)) - { - return true; - } - } - else if (derivedParticle is XmlSchemaSequence) - { - if (IsSequenceFromAll((XmlSchemaSequence)derivedParticle, (XmlSchemaAll)baseParticle)) - { - return true; - } - _restrictionErrorMsg = string.Format(ResXml.Sch_SeqFromAll, derivedParticle.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedParticle.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseParticle.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseParticle.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - } - else if (derivedParticle is XmlSchemaChoice || derivedParticle is XmlSchemaAny) - { - _restrictionErrorMsg = ResXml.Sch_ForbiddenDerivedParticleForAll; - } - return false; - } - else if (baseParticle is XmlSchemaChoice) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle); - } - else if (derivedParticle is XmlSchemaChoice) - { - XmlSchemaChoice baseChoice = baseParticle as XmlSchemaChoice; - XmlSchemaChoice derivedChoice = derivedParticle as XmlSchemaChoice; - - if (baseChoice.Parent == null || derivedChoice.Parent == null) - { //using parent property to indicate this choice was created on the fly for substitutionGroup - return IsChoiceFromChoiceSubstGroup(derivedChoice, baseChoice); - } - if (IsGroupBaseFromGroupBase(derivedChoice, baseChoice, false)) - { - return true; - } - } - else if (derivedParticle is XmlSchemaSequence) - { - if (IsSequenceFromChoice((XmlSchemaSequence)derivedParticle, (XmlSchemaChoice)baseParticle)) - { - return true; - } - _restrictionErrorMsg = string.Format(ResXml.Sch_SeqFromChoice, derivedParticle.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedParticle.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseParticle.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseParticle.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - } - else - { - _restrictionErrorMsg = ResXml.Sch_ForbiddenDerivedParticleForChoice; - } - return false; - } - else if (baseParticle is XmlSchemaSequence) - { - if (derivedParticle is XmlSchemaElement) - { - return IsElementFromGroupBase((XmlSchemaElement)derivedParticle, (XmlSchemaGroupBase)baseParticle); - } - else if (derivedParticle is XmlSchemaSequence || (derivedParticle is XmlSchemaAll && ((XmlSchemaGroupBase)derivedParticle).Items.Count == 1)) - { - if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)derivedParticle, (XmlSchemaGroupBase)baseParticle, true)) - { - return true; - } - } - else - { - _restrictionErrorMsg = ResXml.Sch_ForbiddenDerivedParticleForSeq; - } - return false; - } - else - { - Debug.Assert(false); - } - - return false; - } - - private bool IsElementFromElement(XmlSchemaElement derivedElement, XmlSchemaElement baseElement) - { - // In case of elements the block value '#all' is 100% equivalent to the value of 'substitution restriction extension'. - // Since below we perform a logical operation on the bit fields we need to convert the #all (0xFF) - // to the equivalent set of substitution, restriction and extension, so that the operation works as expected. - // (The goal of the (derived | base) == derived is to fail if the derived is not a bitwise superset of base) - XmlSchemaDerivationMethod baseEffectiveBlock = - baseElement.ElementDecl.Block == XmlSchemaDerivationMethod.All ? - XmlSchemaDerivationMethod.Substitution | XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension : - baseElement.ElementDecl.Block; - XmlSchemaDerivationMethod derivedEffectiveBlock = - derivedElement.ElementDecl.Block == XmlSchemaDerivationMethod.All ? - XmlSchemaDerivationMethod.Substitution | XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension : - derivedElement.ElementDecl.Block; - - if (!((derivedElement.QualifiedName == baseElement.QualifiedName) && - (baseElement.IsNillable || !derivedElement.IsNillable) && - IsValidOccurrenceRangeRestriction(derivedElement, baseElement) && - (baseElement.FixedValue == null || IsFixedEqual(baseElement.ElementDecl, derivedElement.ElementDecl)) && - ((derivedEffectiveBlock | baseEffectiveBlock) == derivedEffectiveBlock) && - (derivedElement.ElementSchemaType != null) && (baseElement.ElementSchemaType != null) && - XmlSchemaType.IsDerivedFrom(derivedElement.ElementSchemaType, baseElement.ElementSchemaType, ~(XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union)))) - { - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromElement, derivedElement.QualifiedName, baseElement.QualifiedName); - return false; - } - return true; - } - - private bool IsElementFromAny(XmlSchemaElement derivedElement, XmlSchemaAny baseAny) - { - if (!baseAny.Allows(derivedElement.QualifiedName)) - { - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromAnyRule1, derivedElement.QualifiedName.ToString()); - return false; - } - if (!IsValidOccurrenceRangeRestriction(derivedElement, baseAny)) - { - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromAnyRule2, derivedElement.QualifiedName.ToString()); - return false; - } - return true; - } - - private bool IsAnyFromAny(XmlSchemaAny derivedAny, XmlSchemaAny baseAny) - { - if (!IsValidOccurrenceRangeRestriction(derivedAny, baseAny)) - { - _restrictionErrorMsg = ResXml.Sch_AnyFromAnyRule1; - return false; - } - if (!NamespaceList.IsSubset(derivedAny.NamespaceList, baseAny.NamespaceList)) - { - _restrictionErrorMsg = ResXml.Sch_AnyFromAnyRule2; - return false; - } - if ((int)derivedAny.ProcessContentsCorrect < (int)baseAny.ProcessContentsCorrect) - { - _restrictionErrorMsg = ResXml.Sch_AnyFromAnyRule3; - return false; - } - return true; - } - - private bool IsGroupBaseFromAny(XmlSchemaGroupBase derivedGroupBase, XmlSchemaAny baseAny) - { - decimal minOccurs, maxOccurs; - CalculateEffectiveTotalRange(derivedGroupBase, out minOccurs, out maxOccurs); - if (!IsValidOccurrenceRangeRestriction(minOccurs, maxOccurs, baseAny.MinOccurs, baseAny.MaxOccurs)) - { - _restrictionErrorMsg = string.Format(ResXml.Sch_GroupBaseFromAny2, derivedGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseAny.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseAny.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - return false; - } - // eliminate occurrance range check - string minOccursAny = baseAny.MinOccursString; - baseAny.MinOccurs = decimal.Zero; - for (int i = 0; i < derivedGroupBase.Items.Count; ++i) - { - if (!IsValidRestriction((XmlSchemaParticle)derivedGroupBase.Items[i], baseAny)) - { - _restrictionErrorMsg = ResXml.Sch_GroupBaseFromAny1; - baseAny.MinOccursString = minOccursAny; - return false; - } - } - baseAny.MinOccursString = minOccursAny; - return true; - } - -#if PRIYAL - private bool IsElementFromGroupBase(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly) { - if (!IsRangeSimple(baseGroupBase.MinOccurs, baseGroupBase.MaxOccurs) || !IsRangeSimple(derivedElement.MinOccurs, derivedElement.MaxOccurs)) { - return IsElementFromGroupBase(derivedElement, baseGroupBase); //SPEC COMPLIANT - } - else { - //Base partilce's and Derived Element's range is simple - //If all particles in baseParticle also have simple ranges, then can use our algorithm - //So that we dont break common cases that we used to accept earlier - //Example Choice -> Element - if (IsElementFromGroupBaseHack(derivedElement, baseGroupBase, skipEmptableOnly)) { - return true; - } - else { //Fall back to regular checking - return IsElementFromGroupBase(derivedElement, baseGroupBase); - } - } - } - - private bool IsElementFromGroupBaseHack(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly) { - bool isMatched = false; - - foreach(XmlSchemaParticle baseParticle in baseGroupBase.Items) { - if (!isMatched && IsRangeSimple(baseParticle.MinOccurs, baseParticle.MaxOccurs)) { - string minOccursElement = baseParticle.MinOccursString; - string maxOccursElement = baseParticle.MaxOccursString; - baseParticle.MinOccurs *= baseGroupBase.MinOccurs; - if ( baseParticle.MaxOccurs != decimal.MaxValue) { - if (baseGroupBase.MaxOccurs == decimal.MaxValue) - baseParticle.MaxOccurs = decimal.MaxValue; - else - baseParticle.MaxOccurs *= baseGroupBase.MaxOccurs; - } - isMatched = IsValidRestriction(derivedElement, baseParticle); - baseParticle.MinOccursString = minOccursElement; - baseParticle.MaxOccursString = maxOccursElement; - } - if (!isMatched && skipEmptableOnly && !IsParticleEmptiable(baseParticle)) { - return false; - } - } - return isMatched; - } -#endif - private bool IsElementFromGroupBase(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase) - { - if (baseGroupBase is XmlSchemaSequence) - { - XmlSchemaSequence virtualSeq = new XmlSchemaSequence(); - virtualSeq.MinOccurs = 1; - virtualSeq.MaxOccurs = 1; - virtualSeq.Items.Add(derivedElement); - if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualSeq, baseGroupBase, true)) - { - return true; - } - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromGroupBase1, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - } - else if (baseGroupBase is XmlSchemaChoice) - { - XmlSchemaChoice virtualChoice = new XmlSchemaChoice(); - virtualChoice.MinOccurs = 1; - virtualChoice.MaxOccurs = 1; - virtualChoice.Items.Add(derivedElement); - if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualChoice, baseGroupBase, false)) - { - return true; - } - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromGroupBase2, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - } - else if (baseGroupBase is XmlSchemaAll) - { - XmlSchemaAll virtualAll = new XmlSchemaAll(); - virtualAll.MinOccurs = 1; - virtualAll.MaxOccurs = 1; - virtualAll.Items.Add(derivedElement); - if (IsGroupBaseFromGroupBase((XmlSchemaGroupBase)virtualAll, baseGroupBase, true)) - { - return true; - } - _restrictionErrorMsg = string.Format(ResXml.Sch_ElementFromGroupBase3, derivedElement.QualifiedName.ToString(), derivedElement.LineNumber.ToString(NumberFormatInfo.InvariantInfo), derivedElement.LinePosition.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LineNumber.ToString(NumberFormatInfo.InvariantInfo), baseGroupBase.LinePosition.ToString(NumberFormatInfo.InvariantInfo)); - } - return false; - } - - private bool IsChoiceFromChoiceSubstGroup(XmlSchemaChoice derivedChoice, XmlSchemaChoice baseChoice) - { - if (!IsValidOccurrenceRangeRestriction(derivedChoice, baseChoice)) - { - _restrictionErrorMsg = ResXml.Sch_GroupBaseRestRangeInvalid; - return false; - } - for (int i = 0; i < derivedChoice.Items.Count; ++i) - { - if (GetMappingParticle((XmlSchemaParticle)derivedChoice.Items[i], baseChoice.Items) < 0) - { - return false; - } - } - return true; - } - - private bool IsGroupBaseFromGroupBase(XmlSchemaGroupBase derivedGroupBase, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly) - { - if (!IsValidOccurrenceRangeRestriction(derivedGroupBase, baseGroupBase)) - { - _restrictionErrorMsg = ResXml.Sch_GroupBaseRestRangeInvalid; - return false; - } - if (derivedGroupBase.Items.Count > baseGroupBase.Items.Count) - { - _restrictionErrorMsg = ResXml.Sch_GroupBaseRestNoMap; - return false; - } - int count = 0; - for (int i = 0; i < baseGroupBase.Items.Count; ++i) - { - XmlSchemaParticle baseParticle = (XmlSchemaParticle)baseGroupBase.Items[i]; - if ((count < derivedGroupBase.Items.Count) - && IsValidRestriction((XmlSchemaParticle)derivedGroupBase.Items[count], baseParticle)) - { - count++; - } - else if (skipEmptableOnly && !IsParticleEmptiable(baseParticle)) - { - if (_restrictionErrorMsg == null) - { //If restriction failed on previous check, do not overwrite error - _restrictionErrorMsg = ResXml.Sch_GroupBaseRestNotEmptiable; - } - return false; - } - } - if (count < derivedGroupBase.Items.Count) - { - return false; - } - return true; - } - - private bool IsSequenceFromAll(XmlSchemaSequence derivedSequence, XmlSchemaAll baseAll) - { - if (!IsValidOccurrenceRangeRestriction(derivedSequence, baseAll) || derivedSequence.Items.Count > baseAll.Items.Count) - { - return false; - } - BitSet map = new BitSet(baseAll.Items.Count); - for (int j = 0; j < derivedSequence.Items.Count; ++j) - { - int i = GetMappingParticle((XmlSchemaParticle)derivedSequence.Items[j], baseAll.Items); - if (i >= 0) - { - if (map[i]) - { - return false; - } - else - { - map.Set(i); - } - } - else - { - return false; - } - } - for (int i = 0; i < baseAll.Items.Count; i++) - { - if (!map[i] && !IsParticleEmptiable((XmlSchemaParticle)baseAll.Items[i])) - { - return false; - } - } - return true; - } - - private bool IsSequenceFromChoice(XmlSchemaSequence derivedSequence, XmlSchemaChoice baseChoice) - { - decimal minOccurs, maxOccurs; - minOccurs = derivedSequence.MinOccurs * derivedSequence.Items.Count; - if (derivedSequence.MaxOccurs == decimal.MaxValue) - { - maxOccurs = decimal.MaxValue; - } - else - { - maxOccurs = derivedSequence.MaxOccurs * derivedSequence.Items.Count; - } - if (!IsValidOccurrenceRangeRestriction(minOccurs, maxOccurs, baseChoice.MinOccurs, baseChoice.MaxOccurs) || derivedSequence.Items.Count > baseChoice.Items.Count) - { - return false; - } - for (int i = 0; i < derivedSequence.Items.Count; ++i) - { - if (GetMappingParticle((XmlSchemaParticle)derivedSequence.Items[i], baseChoice.Items) < 0) - return false; - } - return true; - } - - private bool IsValidOccurrenceRangeRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle) - { - return IsValidOccurrenceRangeRestriction(derivedParticle.MinOccurs, derivedParticle.MaxOccurs, baseParticle.MinOccurs, baseParticle.MaxOccurs); - } - - private bool IsValidOccurrenceRangeRestriction(decimal minOccurs, decimal maxOccurs, decimal baseMinOccurs, decimal baseMaxOccurs) - { - return (baseMinOccurs <= minOccurs) && (maxOccurs <= baseMaxOccurs); - } - - private int GetMappingParticle(XmlSchemaParticle particle, XmlSchemaObjectCollection collection) - { - for (int i = 0; i < collection.Count; i++) - { - if (IsValidRestriction(particle, (XmlSchemaParticle)collection[i])) - return i; - } - return -1; - } - - private bool IsParticleEmptiable(XmlSchemaParticle particle) - { - decimal minOccurs, maxOccurs; - CalculateEffectiveTotalRange(particle, out minOccurs, out maxOccurs); - return minOccurs == decimal.Zero; - } - - private void CalculateEffectiveTotalRange(XmlSchemaParticle particle, out decimal minOccurs, out decimal maxOccurs) - { - XmlSchemaChoice choice = particle as XmlSchemaChoice; - - if (particle is XmlSchemaElement || particle is XmlSchemaAny) - { - minOccurs = particle.MinOccurs; - maxOccurs = particle.MaxOccurs; - } - else if (choice != null) - { - if (choice.Items.Count == 0) - { - minOccurs = maxOccurs = decimal.Zero; - } - else - { - minOccurs = decimal.MaxValue; - maxOccurs = decimal.Zero; - for (int i = 0; i < choice.Items.Count; ++i) - { - decimal min, max; - CalculateEffectiveTotalRange((XmlSchemaParticle)choice.Items[i], out min, out max); - if (min < minOccurs) - { - minOccurs = min; - } - if (max > maxOccurs) - { - maxOccurs = max; - } - } - minOccurs *= particle.MinOccurs; - if (maxOccurs != decimal.MaxValue) - { - if (particle.MaxOccurs == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs *= particle.MaxOccurs; - } - } - } - else - { - XmlSchemaObjectCollection collection = ((XmlSchemaGroupBase)particle).Items; - if (collection.Count == 0) - { - minOccurs = maxOccurs = decimal.Zero; - } - else - { - minOccurs = 0; - maxOccurs = 0; - for (int i = 0; i < collection.Count; ++i) - { - decimal min, max; - CalculateEffectiveTotalRange((XmlSchemaParticle)collection[i], out min, out max); - minOccurs += min; - if (maxOccurs != decimal.MaxValue) - { - if (max == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs += max; - } - } - minOccurs *= particle.MinOccurs; - if (maxOccurs != decimal.MaxValue) - { - if (particle.MaxOccurs == decimal.MaxValue) - maxOccurs = decimal.MaxValue; - else - maxOccurs *= particle.MaxOccurs; - } - } - } - } - - private void PushComplexType(XmlSchemaComplexType complexType) - { - _complexTypeStack.Push(complexType); - } - - private XmlSchemaContentType GetSchemaContentType(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaParticle particle) - { - if ((complexContent != null && complexContent.IsMixed) || - (complexContent == null && complexType.IsMixed)) - { - return XmlSchemaContentType.Mixed; - } - else if (particle != null && !particle.IsEmpty) - { - return XmlSchemaContentType.ElementOnly; - } - else - { - return XmlSchemaContentType.Empty; - } - } - - private void CompileAttributeGroup(XmlSchemaAttributeGroup attributeGroup) - { - if (attributeGroup.IsProcessing) - { - SendValidationEvent(ResXml.Sch_AttributeGroupCircularRef, attributeGroup); - return; - } - if (attributeGroup.AttributeUses.Count > 0) - {// already checked - return; - } - attributeGroup.IsProcessing = true; - XmlSchemaAnyAttribute anyAttribute = attributeGroup.AnyAttribute; - - try - { - for (int i = 0; i < attributeGroup.Attributes.Count; ++i) - { - XmlSchemaAttribute attr = attributeGroup.Attributes[i] as XmlSchemaAttribute; - if (attr != null) - { - if (attr.Use == XmlSchemaUse.Prohibited) - { - continue; - } - CompileAttribute(attr); - if (attributeGroup.AttributeUses[attr.QualifiedName] == null) - { - attributeGroup.AttributeUses.Add(attr.QualifiedName, attr); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attr.QualifiedName.ToString(), attr); - } - } - else - { // XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributeGroup.Attributes[i]; - XmlSchemaAttributeGroup attributeGroupResolved; - if (attributeGroup.Redefined != null && attributeGroupRef.RefName == attributeGroup.Redefined.QualifiedName) - { - attributeGroupResolved = (XmlSchemaAttributeGroup)attributeGroup.Redefined; - } - else - { - attributeGroupResolved = (XmlSchemaAttributeGroup)_attributeGroups[attributeGroupRef.RefName]; - } - if (attributeGroupResolved != null) - { - CompileAttributeGroup(attributeGroupResolved); - foreach (XmlSchemaAttribute attribute in attributeGroupResolved.AttributeUses.Values) - { - if (attributeGroup.AttributeUses[attribute.QualifiedName] == null) - { - attributeGroup.AttributeUses.Add(attribute.QualifiedName, attribute); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attribute); - } - } - anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroupResolved.AttributeWildcard); - } - else - { - SendValidationEvent(ResXml.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef); - } - } - } - attributeGroup.AttributeWildcard = anyAttribute; - } - finally - { - attributeGroup.IsProcessing = false; - } - } - - private void CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy) - { - XmlSchemaAnyAttribute baseAttributeWildcard = baseType != null ? baseType.AttributeWildcard : null; - for (int i = 0; i < attributes.Count; ++i) - { - XmlSchemaAttribute attr = attributes[i] as XmlSchemaAttribute; - if (attr != null) - { - if (attr.Use != XmlSchemaUse.Prohibited) - { - CompileAttribute(attr); - } - if (attr.Use != XmlSchemaUse.Prohibited || - (attr.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) - { - if (derivedType.AttributeUses[attr.QualifiedName] == null) - { - derivedType.AttributeUses.Add(attr.QualifiedName, attr); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attr.QualifiedName.ToString(), attr); - } - } - else - { - SendValidationEvent(ResXml.Sch_AttributeIgnored, attr.QualifiedName.ToString(), attr, XmlSeverityType.Warning); - } - } - else - { // is XmlSchemaAttributeGroupRef - XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)attributes[i]; - XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)_attributeGroups[attributeGroupRef.RefName]; - if (attributeGroup != null) - { - CompileAttributeGroup(attributeGroup); - foreach (XmlSchemaAttribute attribute in attributeGroup.AttributeUses.Values) - { - if (attribute.Use != XmlSchemaUse.Prohibited || - (attribute.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) - { - if (derivedType.AttributeUses[attribute.QualifiedName] == null) - { - derivedType.AttributeUses.Add(attribute.QualifiedName, attribute); - } - else - { - SendValidationEvent(ResXml.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attributeGroupRef); - } - } - else - { - SendValidationEvent(ResXml.Sch_AttributeIgnored, attribute.QualifiedName.ToString(), attribute, XmlSeverityType.Warning); - } - } - anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroup.AttributeWildcard); - } - else - { - SendValidationEvent(ResXml.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef); - } - } - } - - // check derivation rules - if (baseType != null) - { - if (derivedBy == XmlSchemaDerivationMethod.Extension) - { - derivedType.SetAttributeWildcard(CompileAnyAttributeUnion(anyAttribute, baseAttributeWildcard)); - foreach (XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) - { - XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName]; - if (attribute == null) - { - derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase); - } - else - { - Debug.Assert(attribute.Use != XmlSchemaUse.Prohibited); - if (attributeBase.Use != XmlSchemaUse.Prohibited && attribute.AttributeSchemaType != attributeBase.AttributeSchemaType) - { //Extension allows previously prohibited attributes to be re-added, - SendValidationEvent(ResXml.Sch_InvalidAttributeExtension, attribute); - } - } - } - } - else - { // derivedBy == XmlSchemaDerivationMethod.Restriction - // Schema Component Constraint: Derivation Valid (Restriction, Complex) - if ((anyAttribute != null) && (baseAttributeWildcard == null || !XmlSchemaAnyAttribute.IsSubset(anyAttribute, baseAttributeWildcard) || !IsProcessContentsRestricted(baseType, anyAttribute, baseAttributeWildcard))) - { - SendValidationEvent(ResXml.Sch_InvalidAnyAttributeRestriction, derivedType); - } - else - { - derivedType.SetAttributeWildcard(anyAttribute); //complete wildcard - } - - // Add form the base - foreach (XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) - { - XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName]; - if (attribute == null) - { - derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase); - } - else - { - if (attributeBase.Use == XmlSchemaUse.Prohibited && attribute.Use != XmlSchemaUse.Prohibited) - { -#if DEBUG - string position = string.Empty; - if (derivedType.SourceUri != null) - { - position = " in " + derivedType.SourceUri + "(" + derivedType.LineNumber + ", " + derivedType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType attributes restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpAttributes(baseType.AttributeUses, baseType.AttributeWildcard)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpAttributes(derivedType.AttributeUses, derivedType.AttributeWildcard)); -#endif - SendValidationEvent(ResXml.Sch_AttributeRestrictionProhibited, attribute); - } - else if (attributeBase.Use == XmlSchemaUse.Required && (attribute.Use != XmlSchemaUse.Required)) - { //If base is required, derived should also be required - SendValidationEvent(ResXml.Sch_AttributeUseInvalid, attribute); - } - else if (attribute.Use == XmlSchemaUse.Prohibited) - { - continue; - } - else if (attributeBase.AttributeSchemaType == null || attribute.AttributeSchemaType == null || !XmlSchemaType.IsDerivedFrom(attribute.AttributeSchemaType, attributeBase.AttributeSchemaType, XmlSchemaDerivationMethod.Empty)) - { - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalid, attribute); - } - else if (!IsFixedEqual(attributeBase.AttDef, attribute.AttDef)) - { - SendValidationEvent(ResXml.Sch_AttributeFixedInvalid, attribute); - } - } - } - - // Check additional ones are valid restriction of base's wildcard - foreach (XmlSchemaAttribute attribute in derivedType.AttributeUses.Values) - { - XmlSchemaAttribute attributeBase = (XmlSchemaAttribute)baseType.AttributeUses[attribute.QualifiedName]; - if (attributeBase != null) - { - continue; - } - if (baseAttributeWildcard == null || !baseAttributeWildcard.Allows(attribute.QualifiedName)) - { -#if DEBUG - string position = string.Empty; - if (derivedType.SourceUri != null) - { - position = " in " + derivedType.SourceUri + "(" + derivedType.LineNumber + ", " + derivedType.LinePosition + ")"; - } - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType attributes restriction" + position); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpAttributes(baseType.AttributeUses, baseType.AttributeWildcard)); - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpAttributes(derivedType.AttributeUses, derivedType.AttributeWildcard)); -#endif - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalidFromWildcard, attribute); - } - } - } - } - else - { - derivedType.SetAttributeWildcard(anyAttribute); - } - } - - private void CheckAtrributeGroupRestriction(XmlSchemaAttributeGroup baseAttributeGroup, XmlSchemaAttributeGroup derivedAttributeGroup) - { - XmlSchemaAnyAttribute baseAnyAtt = baseAttributeGroup.AttributeWildcard; - XmlSchemaAnyAttribute derivedAnyAtt = derivedAttributeGroup.AttributeWildcard; - - if ((derivedAnyAtt != null) && (baseAnyAtt == null || !XmlSchemaAnyAttribute.IsSubset(derivedAnyAtt, baseAnyAtt) || !IsProcessContentsRestricted(null, derivedAnyAtt, baseAnyAtt))) - { - SendValidationEvent(ResXml.Sch_InvalidAnyAttributeRestriction, derivedAttributeGroup); - } - foreach (XmlSchemaAttribute attributeBase in baseAttributeGroup.AttributeUses.Values) - { - XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedAttributeGroup.AttributeUses[attributeBase.QualifiedName]; - if (attribute != null) - { - if (attributeBase.Use == XmlSchemaUse.Prohibited && attribute.Use != XmlSchemaUse.Prohibited) - { - SendValidationEvent(ResXml.Sch_AttributeRestrictionProhibited, attribute); - } - else if (attributeBase.Use == XmlSchemaUse.Required && attribute.Use != XmlSchemaUse.Required) - { - SendValidationEvent(ResXml.Sch_AttributeUseInvalid, attribute); - } - else if (attribute.Use == XmlSchemaUse.Prohibited) - { //If derived att is prohibited, continue - continue; - } - else if (attributeBase.AttributeSchemaType == null || attribute.AttributeSchemaType == null || !XmlSchemaType.IsDerivedFrom(attribute.AttributeSchemaType, attributeBase.AttributeSchemaType, XmlSchemaDerivationMethod.Empty)) - { - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalid, attribute); - } - else if (!IsFixedEqual(attributeBase.AttDef, attribute.AttDef)) - { - SendValidationEvent(ResXml.Sch_AttributeFixedInvalid, attribute); - } - } - else if (attributeBase.Use == XmlSchemaUse.Required) - { - SendValidationEvent(ResXml.Sch_NoDerivedAttribute, attributeBase.QualifiedName.ToString(), baseAttributeGroup.QualifiedName.ToString(), derivedAttributeGroup); - } - } - // Check additional ones are valid restriction of base's wildcard - foreach (XmlSchemaAttribute attribute in derivedAttributeGroup.AttributeUses.Values) - { - XmlSchemaAttribute attributeBase = (XmlSchemaAttribute)baseAttributeGroup.AttributeUses[attribute.QualifiedName]; - if (attributeBase != null) - { - continue; - } - if (baseAnyAtt == null || !baseAnyAtt.Allows(attribute.QualifiedName)) - { - SendValidationEvent(ResXml.Sch_AttributeRestrictionInvalidFromWildcard, attribute); - } - } - } - -#if DEBUG - private string DumpAttributes(XmlSchemaObjectTable attributeUses, XmlSchemaAnyAttribute attributeWildcard) - { - StringBuilder sb = new StringBuilder(); - sb.Append("["); - bool first = true; - foreach (XmlSchemaAttribute attribute in attributeUses.Values) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - if (first) - { - first = false; - } - else - { - sb.Append(" "); - } - sb.Append(attribute.QualifiedName.Name); - if (attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) - { - sb.Append("?"); - } - } - } - if (attributeWildcard != null) - { - if (attributeUses.Count != 0) - { - sb.Append(" "); - } - sb.Append("<"); - sb.Append(attributeWildcard.NamespaceList.ToString()); - sb.Append(">"); - } - sb.Append("] - ["); - first = true; - foreach (XmlSchemaAttribute attribute in attributeUses.Values) - { - if (attribute.Use == XmlSchemaUse.Prohibited) - { - if (first) - { - first = false; - } - else - { - sb.Append(" "); - } - sb.Append(attribute.QualifiedName.Name); - } - } - sb.Append("]"); - return sb.ToString(); - } -#endif - - private bool IsProcessContentsRestricted(XmlSchemaComplexType baseType, XmlSchemaAnyAttribute derivedAttributeWildcard, XmlSchemaAnyAttribute baseAttributeWildcard) - { - if (baseType == XmlSchemaComplexType.AnyType) - { - return true; - } - if ((int)derivedAttributeWildcard.ProcessContentsCorrect >= (int)baseAttributeWildcard.ProcessContentsCorrect) - { - return true; - } - return false; - } - - private XmlSchemaAnyAttribute CompileAnyAttributeUnion(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b) - { - if (a == null) - { - return b; - } - else if (b == null) - { - return a; - } - else - { - XmlSchemaAnyAttribute attribute = XmlSchemaAnyAttribute.Union(a, b, false); //false is for v1Compatd - if (attribute == null) - { - SendValidationEvent(ResXml.Sch_UnexpressibleAnyAttribute, a); - } - return attribute; - } - } - - private XmlSchemaAnyAttribute CompileAnyAttributeIntersection(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b) - { - if (a == null) - { - return b; - } - else if (b == null) - { - return a; - } - else - { - XmlSchemaAnyAttribute attribute = XmlSchemaAnyAttribute.Intersection(a, b, false); //false is for v1Compat - if (attribute == null) - { - SendValidationEvent(ResXml.Sch_UnexpressibleAnyAttribute, a); - } - return attribute; - } - } - - private void CompileAttribute(XmlSchemaAttribute xa) - { - if (xa.IsProcessing) - { - SendValidationEvent(ResXml.Sch_AttributeCircularRef, xa); - return; - } - if (xa.AttDef != null) - { //already compiled? - return; - } - xa.IsProcessing = true; - SchemaAttDef decl = null; - try - { - if (!xa.RefName.IsEmpty) - { - XmlSchemaAttribute a = (XmlSchemaAttribute)_attributes[xa.RefName]; - if (a == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa); - } - CompileAttribute(a); - if (a.AttDef == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa); - } - decl = a.AttDef.Clone(); - XmlSchemaDatatype datatype = decl.Datatype; - - if (datatype != null) - { - if (a.FixedValue == null && a.DefaultValue == null) - { - SetDefaultFixed(xa, decl); - } - else if (a.FixedValue != null) - { - if (xa.DefaultValue != null) - { - throw new XmlSchemaException(ResXml.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa); - } - else if (xa.FixedValue != null) - { - object refFixedValue = datatype.ParseValue(xa.FixedValue, NameTable, new SchemaNamespaceManager(xa), true); - if (!datatype.IsEqual(decl.DefaultValueTyped, refFixedValue)) - { - throw new XmlSchemaException(ResXml.Sch_FixedInRef, xa.RefName.ToString(), xa); - } - } - } - } - xa.SetAttributeType(a.AttributeSchemaType); - } - else - { - decl = new SchemaAttDef(xa.QualifiedName); - if (xa.SchemaType != null) - { - CompileSimpleType(xa.SchemaType); - xa.SetAttributeType(xa.SchemaType); - decl.SchemaType = xa.SchemaType; - decl.Datatype = xa.SchemaType.Datatype; - } - else if (!xa.SchemaTypeName.IsEmpty) - { - XmlSchemaSimpleType simpleType = GetSimpleType(xa.SchemaTypeName); - if (simpleType != null) - { - xa.SetAttributeType(simpleType); - decl.Datatype = simpleType.Datatype; - decl.SchemaType = simpleType; - } - else - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa); - } - } - else - { - decl.SchemaType = DatatypeImplementation.AnySimpleType; - decl.Datatype = DatatypeImplementation.AnySimpleType.Datatype; - xa.SetAttributeType(DatatypeImplementation.AnySimpleType); - } - //} //Removed this here since the following should be done only if RefName is Empty - if (decl.Datatype != null) - { - decl.Datatype.VerifySchemaValid(_notations, xa); - } - SetDefaultFixed(xa, decl); - } //End of Else for !RefName.IsEmpty - - decl.SchemaAttribute = xa; //So this is available for PSVI - xa.AttDef = decl; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xa); - } - SendValidationEvent(e); - xa.AttDef = SchemaAttDef.Empty; - } - finally - { - xa.IsProcessing = false; - } - } - - private void SetDefaultFixed(XmlSchemaAttribute xa, SchemaAttDef decl) - { - if (xa.DefaultValue != null || xa.FixedValue != null) - { - if (xa.DefaultValue != null) - { - decl.Presence = SchemaDeclBase.Use.Default; - decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.DefaultValue; - } - else - { - if (xa.Use == XmlSchemaUse.Required) - { - decl.Presence = SchemaDeclBase.Use.RequiredFixed; - } - else - { - decl.Presence = SchemaDeclBase.Use.Fixed; - } - decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.FixedValue; - } - if (decl.Datatype != null) - { - if (decl.Datatype.TypeCode == XmlTypeCode.Id) - { - SendValidationEvent(ResXml.Sch_DefaultIdValue, xa); - } - else - { - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true); - } - } - } - else - { - switch (xa.Use) - { - case XmlSchemaUse.None: - case XmlSchemaUse.Optional: - decl.Presence = SchemaDeclBase.Use.Implied; - break; - case XmlSchemaUse.Required: - decl.Presence = SchemaDeclBase.Use.Required; - break; - case XmlSchemaUse.Prohibited: - break; - } - } - } - - private void CompileIdentityConstraint(XmlSchemaIdentityConstraint xi) - { - if (xi.IsProcessing) - { - xi.CompiledConstraint = CompiledIdentityConstraint.Empty; - SendValidationEvent(ResXml.Sch_IdentityConstraintCircularRef, xi); - return; - } - - if (xi.CompiledConstraint != null) - { - return; - } - - xi.IsProcessing = true; - CompiledIdentityConstraint compic = null; - try - { - SchemaNamespaceManager xnmgr = new SchemaNamespaceManager(xi); - compic = new CompiledIdentityConstraint(xi, xnmgr); - if (xi is XmlSchemaKeyref) - { - XmlSchemaIdentityConstraint ic = (XmlSchemaIdentityConstraint)_identityConstraints[((XmlSchemaKeyref)xi).Refer]; - if (ic == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredIdentityConstraint, ((XmlSchemaKeyref)xi).Refer.ToString(), xi); - } - CompileIdentityConstraint(ic); - if (ic.CompiledConstraint == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidIdentityConstraint, ((XmlSchemaKeyref)xi).Refer.ToString(), xi); - } - // keyref has the different cardinality with the key it referred - if (ic.Fields.Count != xi.Fields.Count) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidCardin, xi.QualifiedName.ToString(), xi); - } - // keyref can only refer to key/unique - if (ic.CompiledConstraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - { - throw new XmlSchemaException(ResXml.Sch_ReftoKeyref, xi.QualifiedName.ToString(), xi); - } - } - xi.CompiledConstraint = compic; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xi); - } - SendValidationEvent(e); - xi.CompiledConstraint = CompiledIdentityConstraint.Empty; - // empty is better than null here, stop quickly when circle referencing - } - finally - { - xi.IsProcessing = false; - } - } - - private void CompileElement(XmlSchemaElement xe) - { - if (xe.IsProcessing) - { - SendValidationEvent(ResXml.Sch_ElementCircularRef, xe); - return; - } - if (xe.ElementDecl != null) - { - return; - } - xe.IsProcessing = true; - SchemaElementDecl decl = null; - try - { - if (!xe.RefName.IsEmpty) - { - XmlSchemaElement e = (XmlSchemaElement)_elements[xe.RefName]; - if (e == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredElement, xe.RefName.ToString(), xe); - } - CompileElement(e); - if (e.ElementDecl == null) - { - throw new XmlSchemaException(ResXml.Sch_RefInvalidElement, xe.RefName.ToString(), xe); - } - xe.SetElementType(e.ElementSchemaType); - decl = e.ElementDecl.Clone(); - } - else - { - if (xe.SchemaType != null) - { - xe.SetElementType(xe.SchemaType); - } - else if (!xe.SchemaTypeName.IsEmpty) - { - xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName)); - if (xe.ElementSchemaType == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe); - } - } - else if (!xe.SubstitutionGroup.IsEmpty) - { - XmlSchemaElement examplar = (XmlSchemaElement)_elements[xe.SubstitutionGroup]; - if (examplar == null) - { - throw new XmlSchemaException(ResXml.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name.ToString(), xe); - } - if (examplar.IsProcessing) - { //Circular subst group; already detected by now - return; - } - CompileElement(examplar); - if (examplar.ElementDecl == null) - { //If head is invalid, fall back to AnyType - xe.SetElementType(XmlSchemaComplexType.AnyType); - decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone(); - } - else - { - xe.SetElementType(examplar.ElementSchemaType); - decl = examplar.ElementDecl.Clone(); - } - } - else - { - xe.SetElementType(XmlSchemaComplexType.AnyType); - decl = XmlSchemaComplexType.AnyType.ElementDecl.Clone(); - } - - if (decl == null) - { - Debug.Assert(xe.ElementSchemaType != null); - if (xe.ElementSchemaType is XmlSchemaComplexType) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)xe.ElementSchemaType; - CompileComplexType(complexType); - if (complexType.ElementDecl != null) - { - decl = complexType.ElementDecl.Clone(); - // decl.LocalElements = complexType.LocalElementDecls; - } - } - else if (xe.ElementSchemaType is XmlSchemaSimpleType) - { - XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)xe.ElementSchemaType; - CompileSimpleType(simpleType); - if (simpleType.ElementDecl != null) - { - decl = simpleType.ElementDecl.Clone(); - } - } - } - Debug.Assert(decl != null); - decl.Name = xe.QualifiedName; - decl.IsAbstract = xe.IsAbstract; - XmlSchemaComplexType ct = xe.ElementSchemaType as XmlSchemaComplexType; - if (ct != null) - { - decl.IsAbstract |= ct.IsAbstract; - } - decl.IsNillable = xe.IsNillable; - decl.Block |= xe.BlockResolved; - } - if (decl.Datatype != null) - { - decl.Datatype.VerifySchemaValid(_notations, xe); - } - - if (xe.DefaultValue != null || xe.FixedValue != null) - { - if (decl.ContentValidator != null) - { - if (decl.ContentValidator.ContentType == XmlSchemaContentType.TextOnly || (decl.ContentValidator.ContentType == XmlSchemaContentType.Mixed && decl.ContentValidator.IsEmptiable)) - { - if (xe.DefaultValue != null) - { - decl.Presence = SchemaDeclBase.Use.Default; - decl.DefaultValueRaw = xe.DefaultValue; - } - else - { - decl.Presence = SchemaDeclBase.Use.Fixed; - decl.DefaultValueRaw = xe.FixedValue; - } - if (decl.Datatype != null) - { - if (decl.Datatype.TypeCode == XmlTypeCode.Id) - { - SendValidationEvent(ResXml.Sch_DefaultIdValue, xe); - } - else - { - decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xe), true); - } - } - else - { //Mixed with emptiable particle - decl.DefaultValueTyped = DatatypeImplementation.AnySimpleType.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xe)); - } - } - else - { - throw new XmlSchemaException(ResXml.Sch_ElementCannotHaveValue, xe); - } - } - } - if (xe.HasConstraints) - { - XmlSchemaObjectCollection constraints = xe.Constraints; - CompiledIdentityConstraint[] compiledConstraints = new CompiledIdentityConstraint[constraints.Count]; - int idx = 0; - for (int i = 0; i < constraints.Count; ++i) - { - XmlSchemaIdentityConstraint constraint = (XmlSchemaIdentityConstraint)constraints[i]; - CompileIdentityConstraint(constraint); - compiledConstraints[idx++] = constraint.CompiledConstraint; - } - decl.Constraints = compiledConstraints; - } - decl.SchemaElement = xe; //So this is available for PSVI - xe.ElementDecl = decl; - } - catch (XmlSchemaException e) - { - if (e.SourceSchemaObject == null) - { - e.SetSource(xe); - } - SendValidationEvent(e); - xe.ElementDecl = SchemaElementDecl.Empty; - } - finally - { - xe.IsProcessing = false; - } - } - - private ContentValidator CompileComplexContent(XmlSchemaComplexType complexType) - { - if (complexType.ContentType == XmlSchemaContentType.Empty) - { - return ContentValidator.Empty; - } - else if (complexType.ContentType == XmlSchemaContentType.TextOnly) - { - return ContentValidator.TextOnly; - } - XmlSchemaParticle particle = complexType.ContentTypeParticle; - if (particle == null || particle == XmlSchemaParticle.Empty) - { - if (complexType.ContentType == XmlSchemaContentType.ElementOnly) - { - return ContentValidator.Empty; - } - else - { - return ContentValidator.Mixed; - } - } - PushComplexType(complexType); - if (particle is XmlSchemaAll) - { - XmlSchemaAll all = (XmlSchemaAll)particle; - AllElementsContentValidator contentValidator = new AllElementsContentValidator(complexType.ContentType, all.Items.Count, all.MinOccurs == decimal.Zero); - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i]; - if (!contentValidator.AddElement(localElement.QualifiedName, localElement, localElement.MinOccurs == decimal.Zero)) - { - SendValidationEvent(ResXml.Sch_DupElement, localElement.QualifiedName.ToString(), localElement); - } - } - return contentValidator; - } - else - { - ParticleContentValidator contentValidator = new ParticleContentValidator(complexType.ContentType, CompilationSettings.EnableUpaCheck); -#if DEBUG - string name = complexType.Name != null ? complexType.Name : string.Empty; - // Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceVerbose, "CompileComplexContent: "+ name + DumpContentModel(particle)); -#endif - try - { - contentValidator.Start(); - complexType.HasWildCard = BuildParticleContentModel(contentValidator, particle); - return contentValidator.Finish(true); - } - catch (UpaException e) - { - if (e.Particle1 is XmlSchemaElement) - { - if (e.Particle2 is XmlSchemaElement) - { - SendValidationEvent(ResXml.Sch_NonDeterministic, ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaElement)e.Particle2); - } - else - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle2).ResolvedNamespace, ((XmlSchemaElement)e.Particle1).QualifiedName.ToString(), (XmlSchemaAny)e.Particle2); - } - } - else - { - if (e.Particle2 is XmlSchemaElement) - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)e.Particle1).ResolvedNamespace, ((XmlSchemaElement)e.Particle2).QualifiedName.ToString(), (XmlSchemaElement)e.Particle2); - } - else - { - SendValidationEvent(ResXml.Sch_NonDeterministicAnyAny, ((XmlSchemaAny)e.Particle1).ResolvedNamespace, ((XmlSchemaAny)e.Particle2).ResolvedNamespace, (XmlSchemaAny)e.Particle2); - } - } - return XmlSchemaComplexType.AnyTypeContentValidator; - } - catch (NotSupportedException) - { - SendValidationEvent(ResXml.Sch_ComplexContentModel, complexType, XmlSeverityType.Warning); - return XmlSchemaComplexType.AnyTypeContentValidator; - } - } - } - -#if DEBUG - private string DumpContentModel(XmlSchemaParticle particle) - { - StringBuilder sb = new StringBuilder(); - DumpContentModelTo(sb, particle); - return sb.ToString(); - } - - private void DumpContentModelTo(StringBuilder sb, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - sb.Append(((XmlSchemaElement)particle).QualifiedName); - } - else if (particle is XmlSchemaAny) - { - sb.Append("<"); - sb.Append(((XmlSchemaAny)particle).NamespaceList.ToString()); - sb.Append(">"); - } - else if (particle is XmlSchemaAll) - { - XmlSchemaAll all = (XmlSchemaAll)particle; - sb.Append("["); - bool first = true; - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i]; - if (first) - { - first = false; - } - else - { - sb.Append(", "); - } - sb.Append(localElement.QualifiedName.Name); - if (localElement.MinOccurs == decimal.Zero) - { - sb.Append("?"); - } - } - sb.Append("]"); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaGroupBase gb = (XmlSchemaGroupBase)particle; - sb.Append("("); - string delimeter = (particle is XmlSchemaChoice) ? " | " : ", "; - bool first = true; - for (int i = 0; i < gb.Items.Count; ++i) - { - if (first) - { - first = false; - } - else - { - sb.Append(delimeter); - } - DumpContentModelTo(sb, (XmlSchemaParticle)gb.Items[i]); - } - sb.Append(")"); - } - else - { - Debug.Assert(particle == XmlSchemaParticle.Empty); - sb.Append("<>"); - } - if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One) - { - // nothing - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One) - { - sb.Append("?"); - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append("*"); - } - else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append("+"); - } - else - { - sb.Append("{" + particle.MinOccurs.ToString(NumberFormatInfo.InvariantInfo) + ", " + particle.MaxOccurs.ToString(NumberFormatInfo.InvariantInfo) + "}"); - } - } -#endif - - private bool BuildParticleContentModel(ParticleContentValidator contentValidator, XmlSchemaParticle particle) - { - bool hasWildCard = false; - if (particle is XmlSchemaElement) - { - XmlSchemaElement element = (XmlSchemaElement)particle; - contentValidator.AddName(element.QualifiedName, element); - } - else if (particle is XmlSchemaAny) - { - hasWildCard = true; - XmlSchemaAny any = (XmlSchemaAny)particle; - contentValidator.AddNamespaceList(any.NamespaceList, any); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - bool isChoice = particle is XmlSchemaChoice; - contentValidator.OpenGroup(); - bool first = true; - for (int i = 0; i < particles.Count; ++i) - { - Debug.Assert(!((XmlSchemaParticle)particles[i]).IsEmpty); - if (first) - { - first = false; - } - else if (isChoice) - { - contentValidator.AddChoice(); - } - else - { - contentValidator.AddSequence(); - } - hasWildCard = BuildParticleContentModel(contentValidator, (XmlSchemaParticle)particles[i]); - } - contentValidator.CloseGroup(); - } - else - { - Debug.Assert(false); - } - if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One) - { - // nothing - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One) - { - contentValidator.AddQMark(); - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue) - { - contentValidator.AddStar(); - } - else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue) - { - contentValidator.AddPlus(); - } - else - { - contentValidator.AddLeafRange(particle.MinOccurs, particle.MaxOccurs); - } - return hasWildCard; - } - - private void CompileParticleElements(XmlSchemaComplexType complexType, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - XmlSchemaElement localElement = (XmlSchemaElement)particle; - CompileElement(localElement); - if (complexType.LocalElements[localElement.QualifiedName] == null) - { - complexType.LocalElements.Add(localElement.QualifiedName, localElement); - } - else - { - XmlSchemaElement element = (XmlSchemaElement)complexType.LocalElements[localElement.QualifiedName]; - if (element.ElementSchemaType != localElement.ElementSchemaType) - { - SendValidationEvent(ResXml.Sch_ElementTypeCollision, particle); - } - } - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - for (int i = 0; i < particles.Count; ++i) - { - CompileParticleElements(complexType, (XmlSchemaParticle)particles[i]); - } - } - } - - private void CompileParticleElements(XmlSchemaParticle particle) - { //For checking redefined group particle derivation - if (particle is XmlSchemaElement) - { - XmlSchemaElement localElement = (XmlSchemaElement)particle; - CompileElement(localElement); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaObjectCollection particles = ((XmlSchemaGroupBase)particle).Items; - for (int i = 0; i < particles.Count; ++i) - { - CompileParticleElements((XmlSchemaParticle)particles[i]); - } - } - } - - private void CompileComplexTypeElements(XmlSchemaComplexType complexType) - { - if (complexType.IsProcessing) - { - SendValidationEvent(ResXml.Sch_TypeCircularRef, complexType); - return; - } - complexType.IsProcessing = true; - try - { - if (complexType.ContentTypeParticle != XmlSchemaParticle.Empty) - { - CompileParticleElements(complexType, complexType.ContentTypeParticle); - } - } - finally - { - complexType.IsProcessing = false; - } - } - - private XmlSchemaSimpleType GetSimpleType(XmlQualifiedName name) - { - XmlSchemaSimpleType type = _schemaTypes[name] as XmlSchemaSimpleType; - if (type != null) - { - CompileSimpleType(type); - } - else - { - type = DatatypeImplementation.GetSimpleTypeFromXsdType(name); - } - return type; - } - - private XmlSchemaComplexType GetComplexType(XmlQualifiedName name) - { - XmlSchemaComplexType type = _schemaTypes[name] as XmlSchemaComplexType; - if (type != null) - { - CompileComplexType(type); - } - return type; - } - - private XmlSchemaType GetAnySchemaType(XmlQualifiedName name) - { - XmlSchemaType type = (XmlSchemaType)_schemaTypes[name]; - if (type != null) - { - if (type is XmlSchemaComplexType) - { - CompileComplexType((XmlSchemaComplexType)type); - } - else - { - CompileSimpleType((XmlSchemaSimpleType)type); - } - return type; - } - else - { //Its is a built-in simpleType - XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(name); - return simpleType; - } - } - - private void CopyPosition(XmlSchemaAnnotated to, XmlSchemaAnnotated from, bool copyParent) - { - to.SourceUri = from.SourceUri; - to.LinePosition = from.LinePosition; - to.LineNumber = from.LineNumber; - to.SetUnhandledAttributes(from.UnhandledAttributes); - if (copyParent) - { - to.Parent = from.Parent; - } - } - - private bool IsFixedEqual(SchemaDeclBase baseDecl, SchemaDeclBase derivedDecl) - { - if (baseDecl.Presence == SchemaDeclBase.Use.Fixed || baseDecl.Presence == SchemaDeclBase.Use.RequiredFixed) - { - object baseFixedValue = baseDecl.DefaultValueTyped; - object derivedFixedValue = derivedDecl.DefaultValueTyped; - - Debug.Assert(baseFixedValue != null); - if (derivedDecl.Presence != SchemaDeclBase.Use.Fixed && derivedDecl.Presence != SchemaDeclBase.Use.RequiredFixed) - { - return false; - } - Debug.Assert(derivedFixedValue != null); - XmlSchemaDatatype baseDatatype = baseDecl.Datatype; - XmlSchemaDatatype derivedDatatype = derivedDecl.Datatype; - - if (baseDatatype.Variety == XmlSchemaDatatypeVariety.Union) - { - if (derivedDatatype.Variety == XmlSchemaDatatypeVariety.Union) - { - if (!derivedDatatype.IsEqual(baseFixedValue, derivedFixedValue)) - { - return false; - } - } - else - { //Base is union and derived is member of union - XsdSimpleValue simpleFixedValue = baseDecl.DefaultValueTyped as XsdSimpleValue; - Debug.Assert(simpleFixedValue != null); - XmlSchemaDatatype memberType = simpleFixedValue.XmlType.Datatype; - if (!memberType.IsComparable(derivedDatatype) || !derivedDatatype.IsEqual(simpleFixedValue.TypedValue, derivedFixedValue)) - { //base type {Union of long & string}, derived type {int} - return false; - } - } - } - else if (!derivedDatatype.IsEqual(baseFixedValue, derivedFixedValue)) - { - return false; - } - } - return true; - } - }; -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaType.cs deleted file mode 100644 index a02e088cb12..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/SchemaType.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - internal enum SchemaType - { - None, - DTD, - XDR, - XSD - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventArgs.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventArgs.cs deleted file mode 100644 index 4c41289fb33..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventArgs.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - /// - /// - /// Returns detailed information relating to - /// the ValidationEventhandler. - /// - public class ValidationEventArgs : EventArgs - { - private XmlSchemaException _ex; - private XmlSeverityType _severity; - - internal ValidationEventArgs(XmlSchemaException ex) : base() - { - _ex = ex; - _severity = XmlSeverityType.Error; - } - - internal ValidationEventArgs(XmlSchemaException ex, XmlSeverityType severity) : base() - { - _ex = ex; - _severity = severity; - } - - /// - public XmlSeverityType Severity - { - get { return _severity; } - } - - /// - public XmlSchemaException Exception - { - get { return _ex; } - } - - /// - /// - /// Gets the text description corresponding to the - /// validation error. - /// - public String Message - { - get { return _ex.Message; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventHandler.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventHandler.cs deleted file mode 100644 index 76ab7674c37..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/ValidationEventHandler.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - /// - /// - /// - public delegate void ValidationEventHandler(object sender, ValidationEventArgs e); -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XdrBuilder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XdrBuilder.cs deleted file mode 100644 index 0eef1ff27f8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XdrBuilder.cs +++ /dev/null @@ -1,1833 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.IO; - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics; - using System.ComponentModel; - using System.Globalization; - using System.Runtime.Versioning; - - /* - * The XdrBuilder class parses the XDR Schema and - * builds internal validation information - */ - internal sealed class XdrBuilder : SchemaBuilder - { - private const int XdrSchema = 1; - private const int XdrElementType = 2; - private const int XdrAttributeType = 3; - private const int XdrElement = 4; - private const int XdrAttribute = 5; - private const int XdrGroup = 6; - private const int XdrElementDatatype = 7; - private const int XdrAttributeDatatype = 8; - - private const int SchemaFlagsNs = 0x0100; - - private const int StackIncrement = 10; - - - private const int SchemaOrderNone = 0; - private const int SchemaOrderMany = 1; - private const int SchemaOrderSequence = 2; - private const int SchemaOrderChoice = 3; - private const int SchemaOrderAll = 4; - - private const int SchemaContentNone = 0; - private const int SchemaContentEmpty = 1; - private const int SchemaContentText = 2; - private const int SchemaContentMixed = 3; - private const int SchemaContentElement = 4; - - - private sealed class DeclBaseInfo - { - // used for e1 has to have a () - internal bool _ExistTerminal; // when there exist a terminal, we need to addOrder before - - // we can add another terminal - internal bool _AllowDataType; // must have textOnly if we have datatype - internal bool _HasDataType; // got data type - - // for = x_schema.Length && - 0 == string.Compare(uri, 0, x_schema, 0, x_schema.Length, StringComparison.Ordinal) && - !uri.StartsWith("x-schema:#", StringComparison.Ordinal); - } - - internal override bool IsContentParsed() - { - return true; - } - - internal override void ProcessMarkup(XmlNode[] markup) - { - throw new InvalidOperationException(ResXml.Xml_InvalidOperation); // should never be called - } - - internal override void ProcessCData(string value) - { - if (_CurState._AllowText) - { - _Text = value; - } - else - { - SendValidationEvent(ResXml.Sch_TextNotAllowed, value); - } - } - - internal override void StartChildren() - { - if (_CurState._BeginChildFunc != null) - { - (this._CurState._BeginChildFunc)(this); - } - } - - internal override void EndChildren() - { - if (_CurState._EndChildFunc != null) - { - (this._CurState._EndChildFunc)(this); - } - - Pop(); - } - - // - // State stack push & pop - // - private void Push() - { - _StateHistory.Push(); - _StateHistory[_StateHistory.Length - 1] = _CurState; - _CurState = _NextState; - } - - private void Pop() - { - _CurState = (XdrEntry)_StateHistory.Pop(); - } - - - // - // Group stack push & pop - // - private void PushGroupInfo() - { - _GroupStack.Push(); - _GroupStack[_GroupStack.Length - 1] = GroupContent.Copy(_GroupDef); - } - - private void PopGroupInfo() - { - _GroupDef = (GroupContent)_GroupStack.Pop(); - Debug.Assert(_GroupDef != null); - } - - // - // XDR Schema - // - private static void XDR_InitRoot(XdrBuilder builder, object obj) - { - builder._SchemaInfo.SchemaType = SchemaType.XDR; - builder._ElementDef._ElementDecl = null; - builder._ElementDef._AttDefList = null; - builder._AttributeDef._AttDef = null; - } - - private static void XDR_BuildRoot_Name(XdrBuilder builder, object obj, string prefix) - { - builder._XdrName = (string)obj; - builder._XdrPrefix = prefix; - } - - private static void XDR_BuildRoot_ID(XdrBuilder builder, object obj, string prefix) - { - } - - private static void XDR_BeginRoot(XdrBuilder builder) - { - if (builder._TargetNamespace == null) - { // inline xdr schema - if (builder._XdrName != null) - { - builder._TargetNamespace = builder._NameTable.Add("x-schema:#" + builder._XdrName); - } - else - { - builder._TargetNamespace = String.Empty; - } - } - builder._SchemaInfo.TargetNamespaces.Add(builder._TargetNamespace, true); - } - - private static void XDR_EndRoot(XdrBuilder builder) - { - // - // check undefined attribute types - // We already checked local attribute types, so only need to check global attribute types here - // - while (builder._UndefinedAttributeTypes != null) - { - XmlQualifiedName gname = builder._UndefinedAttributeTypes._TypeName; - - // if there is no URN in this name then the name is local to the - // schema, but the global attribute was still URN qualified, so - // we need to qualify this name now. - if (gname.Namespace.Length == 0) - { - gname = new XmlQualifiedName(gname.Name, builder._TargetNamespace); - } - SchemaAttDef ad; - if (builder._SchemaInfo.AttributeDecls.TryGetValue(gname, out ad)) - { - builder._UndefinedAttributeTypes._Attdef = (SchemaAttDef)ad.Clone(); - builder._UndefinedAttributeTypes._Attdef.Name = gname; - builder.XDR_CheckAttributeDefault(builder._UndefinedAttributeTypes, builder._UndefinedAttributeTypes._Attdef); - } - else - { - builder.SendValidationEvent(ResXml.Sch_UndeclaredAttribute, gname.Name); - } - builder._UndefinedAttributeTypes = builder._UndefinedAttributeTypes._Next; - } - - foreach (SchemaElementDecl ed in builder._UndeclaredElements.Values) - { - builder.SendValidationEvent(ResXml.Sch_UndeclaredElement, XmlQualifiedName.ToString(ed.Name.Name, ed.Prefix)); - } - } - - - // - // XDR ElementType - // - - private static void XDR_InitElementType(XdrBuilder builder, object obj) - { - builder._ElementDef._ElementDecl = new SchemaElementDecl(); - builder._contentValidator = new ParticleContentValidator(XmlSchemaContentType.Mixed); - builder._contentValidator.IsOpen = true; - - builder._ElementDef._ContentAttr = SchemaContentNone; - builder._ElementDef._OrderAttr = SchemaOrderNone; - builder._ElementDef._MasterGroupRequired = false; - builder._ElementDef._ExistTerminal = false; - builder._ElementDef._AllowDataType = true; - builder._ElementDef._HasDataType = false; - builder._ElementDef._EnumerationRequired = false; - builder._ElementDef._AttDefList = new Hashtable(); - builder._ElementDef._MaxLength = uint.MaxValue; - builder._ElementDef._MinLength = uint.MaxValue; - - // builder._AttributeDef._HasDataType = false; - // builder._AttributeDef._Default = null; - } - - private static void XDR_BuildElementType_Name(XdrBuilder builder, object obj, string prefix) - { - XmlQualifiedName qname = (XmlQualifiedName)obj; - - if (builder._SchemaInfo.ElementDecls.ContainsKey(qname)) - { - builder.SendValidationEvent(ResXml.Sch_DupElementDecl, XmlQualifiedName.ToString(qname.Name, prefix)); - } - builder._ElementDef._ElementDecl.Name = qname; - builder._ElementDef._ElementDecl.Prefix = prefix; - builder._SchemaInfo.ElementDecls.Add(qname, builder._ElementDef._ElementDecl); - if (builder._UndeclaredElements[qname] != null) - { - builder._UndeclaredElements.Remove(qname); - } - } - - private static void XDR_BuildElementType_Content(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._ContentAttr = builder.GetContent((XmlQualifiedName)obj); - } - - private static void XDR_BuildElementType_Model(XdrBuilder builder, object obj, string prefix) - { - builder._contentValidator.IsOpen = builder.GetModel((XmlQualifiedName)obj); - } - - private static void XDR_BuildElementType_Order(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._OrderAttr = builder._GroupDef._Order = builder.GetOrder((XmlQualifiedName)obj); - } - - private static void XDR_BuildElementType_DtType(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._HasDataType = true; - string s = ((string)obj).Trim(); - if (s.Length == 0) - { - builder.SendValidationEvent(ResXml.Sch_MissDtvalue); - } - else - { - XmlSchemaDatatype dtype = XmlSchemaDatatype.FromXdrName(s); - if (dtype == null) - { - builder.SendValidationEvent(ResXml.Sch_UnknownDtType, s); - } - builder._ElementDef._ElementDecl.Datatype = dtype; - } - } - - private static void XDR_BuildElementType_DtValues(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._EnumerationRequired = true; - builder._ElementDef._ElementDecl.Values = new List((string[])obj); - } - - private static void XDR_BuildElementType_DtMaxLength(XdrBuilder builder, object obj, string prefix) - { - ParseDtMaxLength(ref builder._ElementDef._MaxLength, obj, builder); - } - - private static void XDR_BuildElementType_DtMinLength(XdrBuilder builder, object obj, string prefix) - { - ParseDtMinLength(ref builder._ElementDef._MinLength, obj, builder); - } - - private static void XDR_BeginElementType(XdrBuilder builder) - { - string code = null; - string msg = null; - - // - // check name attribute - // - if (builder._ElementDef._ElementDecl.Name.IsEmpty) - { - code = ResXml.Sch_MissAttribute; - msg = "name"; - goto cleanup; - } - - // - // check dt:type attribute - // - if (builder._ElementDef._HasDataType) - { - if (!builder._ElementDef._AllowDataType) - { - code = ResXml.Sch_DataTypeTextOnly; - goto cleanup; - } - else - { - builder._ElementDef._ContentAttr = SchemaContentText; - } - } - else if (builder._ElementDef._ContentAttr == SchemaContentNone) - { - switch (builder._ElementDef._OrderAttr) - { - case SchemaOrderNone: - builder._ElementDef._ContentAttr = SchemaContentMixed; - builder._ElementDef._OrderAttr = SchemaOrderMany; - break; - case SchemaOrderSequence: - builder._ElementDef._ContentAttr = SchemaContentElement; - break; - case SchemaOrderChoice: - builder._ElementDef._ContentAttr = SchemaContentElement; - break; - case SchemaOrderMany: - builder._ElementDef._ContentAttr = SchemaContentMixed; - break; - } - } - - - //save the model value from the base - bool tempOpen = builder._contentValidator.IsOpen; - ElementContent def = builder._ElementDef; - switch (builder._ElementDef._ContentAttr) - { - case SchemaContentText: - builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.TextOnly; - builder._GroupDef._Order = SchemaOrderMany; - builder._contentValidator = null; - break; - case SchemaContentElement: - builder._contentValidator = new ParticleContentValidator(XmlSchemaContentType.ElementOnly); - if (def._OrderAttr == SchemaOrderNone) - { - builder._GroupDef._Order = SchemaOrderSequence; - } - def._MasterGroupRequired = true; - builder._contentValidator.IsOpen = tempOpen; - break; - - case SchemaContentEmpty: - builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.Empty; - builder._contentValidator = null; - break; - - case SchemaContentMixed: - if (def._OrderAttr == SchemaOrderNone || def._OrderAttr == SchemaOrderMany) - { - builder._GroupDef._Order = SchemaOrderMany; - } - else - { - code = ResXml.Sch_MixedMany; - goto cleanup; - } - def._MasterGroupRequired = true; - builder._contentValidator.IsOpen = tempOpen; - break; - } - - - if (def._ContentAttr == SchemaContentMixed || def._ContentAttr == SchemaContentElement) - { - builder._contentValidator.Start(); - builder._contentValidator.OpenGroup(); - } - cleanup: - if (code != null) - { - builder.SendValidationEvent(code, msg); - } - } - - private static void XDR_EndElementType(XdrBuilder builder) - { - SchemaElementDecl ed = builder._ElementDef._ElementDecl; - - // check undefined attribute types first - if (builder._UndefinedAttributeTypes != null && builder._ElementDef._AttDefList != null) - { - DeclBaseInfo patt = builder._UndefinedAttributeTypes; - DeclBaseInfo p1 = patt; - - while (patt != null) - { - SchemaAttDef pAttdef = null; - - if (patt._ElementDecl == ed) - { - XmlQualifiedName pName = patt._TypeName; - pAttdef = (SchemaAttDef)builder._ElementDef._AttDefList[pName]; - if (pAttdef != null) - { - patt._Attdef = (SchemaAttDef)pAttdef.Clone(); - patt._Attdef.Name = pName; - builder.XDR_CheckAttributeDefault(patt, pAttdef); - - // remove it from _pUndefinedAttributeTypes - if (patt == builder._UndefinedAttributeTypes) - { - patt = builder._UndefinedAttributeTypes = patt._Next; - p1 = patt; - } - else - { - p1._Next = patt._Next; - patt = p1._Next; - } - } - } - - if (pAttdef == null) - { - if (patt != builder._UndefinedAttributeTypes) - p1 = p1._Next; - patt = patt._Next; - } - } - } - - if (builder._ElementDef._MasterGroupRequired) - { - // if the content is mixed, there is a group that need to be closed - builder._contentValidator.CloseGroup(); - - if (!builder._ElementDef._ExistTerminal) - { - if (builder._contentValidator.IsOpen) - { - builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.Any; - builder._contentValidator = null; - } - else - { - if (builder._ElementDef._ContentAttr != SchemaContentMixed) - builder.SendValidationEvent(ResXml.Sch_ElementMissing); - } - } - else - { - if (builder._GroupDef._Order == SchemaOrderMany) - { - builder._contentValidator.AddStar(); - } - } - } - if (ed.Datatype != null) - { - XmlTokenizedType ttype = ed.Datatype.TokenizedType; - if (ttype == XmlTokenizedType.ENUMERATION && - !builder._ElementDef._EnumerationRequired) - { - builder.SendValidationEvent(ResXml.Sch_MissDtvaluesAttribute); - } - - if (ttype != XmlTokenizedType.ENUMERATION && - builder._ElementDef._EnumerationRequired) - { - builder.SendValidationEvent(ResXml.Sch_RequireEnumeration); - } - } - CompareMinMaxLength(builder._ElementDef._MinLength, builder._ElementDef._MaxLength, builder); - ed.MaxLength = (long)builder._ElementDef._MaxLength; - ed.MinLength = (long)builder._ElementDef._MinLength; - - if (builder._contentValidator != null) - { - builder._ElementDef._ElementDecl.ContentValidator = builder._contentValidator.Finish(true); - builder._contentValidator = null; - } - - builder._ElementDef._ElementDecl = null; - builder._ElementDef._AttDefList = null; - } - - - // - // XDR AttributeType - // - - private static void XDR_InitAttributeType(XdrBuilder builder, object obj) - { - AttributeContent ad = builder._AttributeDef; - ad._AttDef = new SchemaAttDef(XmlQualifiedName.Empty, null); - - ad._Required = false; - ad._Prefix = null; - - ad._Default = null; - ad._MinVal = 0; // optional by default. - ad._MaxVal = 1; - - // used for datatype - ad._EnumerationRequired = false; - ad._HasDataType = false; - ad._Global = (builder._StateHistory.Length == 2); - - ad._MaxLength = uint.MaxValue; - ad._MinLength = uint.MaxValue; - } - - private static void XDR_BuildAttributeType_Name(XdrBuilder builder, object obj, string prefix) - { - XmlQualifiedName qname = (XmlQualifiedName)obj; - - builder._AttributeDef._Name = qname; - builder._AttributeDef._Prefix = prefix; - builder._AttributeDef._AttDef.Name = qname; - - if (builder._ElementDef._ElementDecl != null) - { // Local AttributeType - if (builder._ElementDef._AttDefList[qname] == null) - { - builder._ElementDef._AttDefList.Add(qname, builder._AttributeDef._AttDef); - } - else - { - builder.SendValidationEvent(ResXml.Sch_DupAttribute, XmlQualifiedName.ToString(qname.Name, prefix)); - } - } - else - { // Global AttributeType - // Global AttributeTypes are URN qualified so that we can look them up across schemas. - qname = new XmlQualifiedName(qname.Name, builder._TargetNamespace); - builder._AttributeDef._AttDef.Name = qname; - if (!builder._SchemaInfo.AttributeDecls.ContainsKey(qname)) - { - builder._SchemaInfo.AttributeDecls.Add(qname, builder._AttributeDef._AttDef); - } - else - { - builder.SendValidationEvent(ResXml.Sch_DupAttribute, XmlQualifiedName.ToString(qname.Name, prefix)); - } - } - } - - private static void XDR_BuildAttributeType_Required(XdrBuilder builder, object obj, string prefix) - { - builder._AttributeDef._Required = IsYes(obj, builder); - } - - private static void XDR_BuildAttributeType_Default(XdrBuilder builder, object obj, string prefix) - { - builder._AttributeDef._Default = obj; - } - - private static void XDR_BuildAttributeType_DtType(XdrBuilder builder, object obj, string prefix) - { - XmlQualifiedName qname = (XmlQualifiedName)obj; - builder._AttributeDef._HasDataType = true; - builder._AttributeDef._AttDef.Datatype = builder.CheckDatatype(qname.Name); - } - - private static void XDR_BuildAttributeType_DtValues(XdrBuilder builder, object obj, string prefix) - { - builder._AttributeDef._EnumerationRequired = true; - builder._AttributeDef._AttDef.Values = new List((string[])obj); - } - - private static void XDR_BuildAttributeType_DtMaxLength(XdrBuilder builder, object obj, string prefix) - { - ParseDtMaxLength(ref builder._AttributeDef._MaxLength, obj, builder); - } - - private static void XDR_BuildAttributeType_DtMinLength(XdrBuilder builder, object obj, string prefix) - { - ParseDtMinLength(ref builder._AttributeDef._MinLength, obj, builder); - } - - private static void XDR_BeginAttributeType(XdrBuilder builder) - { - if (builder._AttributeDef._Name.IsEmpty) - { - builder.SendValidationEvent(ResXml.Sch_MissAttribute); - } - } - - private static void XDR_EndAttributeType(XdrBuilder builder) - { - string code = null; - if (builder._AttributeDef._HasDataType && builder._AttributeDef._AttDef.Datatype != null) - { - XmlTokenizedType ttype = builder._AttributeDef._AttDef.Datatype.TokenizedType; - - if (ttype == XmlTokenizedType.ENUMERATION && !builder._AttributeDef._EnumerationRequired) - { - code = ResXml.Sch_MissDtvaluesAttribute; - goto cleanup; - } - - if (ttype != XmlTokenizedType.ENUMERATION && builder._AttributeDef._EnumerationRequired) - { - code = ResXml.Sch_RequireEnumeration; - goto cleanup; - } - - // a attributes of type id is not supposed to have a default value - if (builder._AttributeDef._Default != null && ttype == XmlTokenizedType.ID) - { - code = ResXml.Sch_DefaultIdValue; - goto cleanup; - } - } - else - { - builder._AttributeDef._AttDef.Datatype = XmlSchemaDatatype.FromXmlTokenizedType(XmlTokenizedType.CDATA); - } - - // - // constraints - // - CompareMinMaxLength(builder._AttributeDef._MinLength, builder._AttributeDef._MaxLength, builder); - builder._AttributeDef._AttDef.MaxLength = builder._AttributeDef._MaxLength; - builder._AttributeDef._AttDef.MinLength = builder._AttributeDef._MinLength; - - // - // checkAttributeType - // - if (builder._AttributeDef._Default != null) - { - builder._AttributeDef._AttDef.DefaultValueRaw = builder._AttributeDef._AttDef.DefaultValueExpanded = (string)builder._AttributeDef._Default; - builder.CheckDefaultAttValue(builder._AttributeDef._AttDef); - } - - builder.SetAttributePresence(builder._AttributeDef._AttDef, builder._AttributeDef._Required); - - cleanup: - if (code != null) - { - builder.SendValidationEvent(code); - } - } - - - // - // XDR Element - // - - private static void XDR_InitElement(XdrBuilder builder, object obj) - { - if (builder._ElementDef._HasDataType || - (builder._ElementDef._ContentAttr == SchemaContentEmpty) || - (builder._ElementDef._ContentAttr == SchemaContentText)) - { - builder.SendValidationEvent(ResXml.Sch_ElementNotAllowed); - } - - builder._ElementDef._AllowDataType = false; - - builder._ElementDef._HasType = false; - builder._ElementDef._MinVal = 1; - builder._ElementDef._MaxVal = 1; - } - - private static void XDR_BuildElement_Type(XdrBuilder builder, object obj, string prefix) - { - XmlQualifiedName qname = (XmlQualifiedName)obj; - - if (!builder._SchemaInfo.ElementDecls.ContainsKey(qname)) - { - SchemaElementDecl ed = (SchemaElementDecl)builder._UndeclaredElements[qname]; - if (ed == null) - { - ed = new SchemaElementDecl(qname, prefix); - builder._UndeclaredElements.Add(qname, ed); - } - } - - builder._ElementDef._HasType = true; - if (builder._ElementDef._ExistTerminal) - builder.AddOrder(); - else - builder._ElementDef._ExistTerminal = true; - - builder._contentValidator.AddName(qname, null); - } - - private static void XDR_BuildElement_MinOccurs(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._MinVal = ParseMinOccurs(obj, builder); - } - - private static void XDR_BuildElement_MaxOccurs(XdrBuilder builder, object obj, string prefix) - { - builder._ElementDef._MaxVal = ParseMaxOccurs(obj, builder); - } - - - // private static void XDR_BeginElement(XdrBuilder builder) - // { - // - // } - - - private static void XDR_EndElement(XdrBuilder builder) - { - if (builder._ElementDef._HasType) - { - HandleMinMax(builder._contentValidator, - builder._ElementDef._MinVal, - builder._ElementDef._MaxVal); - } - else - { - builder.SendValidationEvent(ResXml.Sch_MissAttribute); - } - } - - - // - // XDR Attribute - // - - private static void XDR_InitAttribute(XdrBuilder builder, object obj) - { - if (builder._BaseDecl == null) - builder._BaseDecl = new DeclBaseInfo(); - builder._BaseDecl._MinOccurs = 0; - } - - private static void XDR_BuildAttribute_Type(XdrBuilder builder, object obj, string prefix) - { - builder._BaseDecl._TypeName = (XmlQualifiedName)obj; - builder._BaseDecl._Prefix = prefix; - } - - private static void XDR_BuildAttribute_Required(XdrBuilder builder, object obj, string prefix) - { - if (IsYes(obj, builder)) - { - builder._BaseDecl._MinOccurs = 1; - } - } - - private static void XDR_BuildAttribute_Default(XdrBuilder builder, object obj, string prefix) - { - builder._BaseDecl._Default = obj; - } - - private static void XDR_BeginAttribute(XdrBuilder builder) - { - if (builder._BaseDecl._TypeName.IsEmpty) - { - builder.SendValidationEvent(ResXml.Sch_MissAttribute); - } - - SchemaAttDef attdef = null; - XmlQualifiedName qname = builder._BaseDecl._TypeName; - string prefix = builder._BaseDecl._Prefix; - - // local? - if (builder._ElementDef._AttDefList != null) - { - attdef = (SchemaAttDef)builder._ElementDef._AttDefList[qname]; - } - - // global? - if (attdef == null) - { - // if there is no URN in this name then the name is local to the - // schema, but the global attribute was still URN qualified, so - // we need to qualify this name now. - XmlQualifiedName gname = qname; - if (prefix.Length == 0) - gname = new XmlQualifiedName(qname.Name, builder._TargetNamespace); - SchemaAttDef ad; - if (builder._SchemaInfo.AttributeDecls.TryGetValue(gname, out ad)) - { - attdef = (SchemaAttDef)ad.Clone(); - attdef.Name = qname; - } - else if (prefix.Length != 0) - { - builder.SendValidationEvent(ResXml.Sch_UndeclaredAttribute, XmlQualifiedName.ToString(qname.Name, prefix)); - } - } - - if (attdef != null) - { - builder.XDR_CheckAttributeDefault(builder._BaseDecl, attdef); - } - else - { - // will process undeclared types later - attdef = new SchemaAttDef(qname, prefix); - DeclBaseInfo decl = new DeclBaseInfo(); - decl._Checking = true; - decl._Attdef = attdef; - decl._TypeName = builder._BaseDecl._TypeName; - decl._ElementDecl = builder._ElementDef._ElementDecl; - decl._MinOccurs = builder._BaseDecl._MinOccurs; - decl._Default = builder._BaseDecl._Default; - - // add undefined attribute types - decl._Next = builder._UndefinedAttributeTypes; - builder._UndefinedAttributeTypes = decl; - } - - builder._ElementDef._ElementDecl.AddAttDef(attdef); - } - - private static void XDR_EndAttribute(XdrBuilder builder) - { - builder._BaseDecl.Reset(); - } - - - // - // XDR Group - // - - private static void XDR_InitGroup(XdrBuilder builder, object obj) - { - if (builder._ElementDef._ContentAttr == SchemaContentEmpty || - builder._ElementDef._ContentAttr == SchemaContentText) - { - builder.SendValidationEvent(ResXml.Sch_GroupDisabled); - } - - builder.PushGroupInfo(); - - builder._GroupDef._MinVal = 1; - builder._GroupDef._MaxVal = 1; - builder._GroupDef._HasMaxAttr = false; - builder._GroupDef._HasMinAttr = false; - - if (builder._ElementDef._ExistTerminal) - builder.AddOrder(); - - // now we are in a group so we reset fExistTerminal - builder._ElementDef._ExistTerminal = false; - - builder._contentValidator.OpenGroup(); - } - - private static void XDR_BuildGroup_Order(XdrBuilder builder, object obj, string prefix) - { - builder._GroupDef._Order = builder.GetOrder((XmlQualifiedName)obj); - if (builder._ElementDef._ContentAttr == SchemaContentMixed && builder._GroupDef._Order != SchemaOrderMany) - { - builder.SendValidationEvent(ResXml.Sch_MixedMany); - } - } - - private static void XDR_BuildGroup_MinOccurs(XdrBuilder builder, object obj, string prefix) - { - builder._GroupDef._MinVal = ParseMinOccurs(obj, builder); - builder._GroupDef._HasMinAttr = true; - } - - private static void XDR_BuildGroup_MaxOccurs(XdrBuilder builder, object obj, string prefix) - { - builder._GroupDef._MaxVal = ParseMaxOccurs(obj, builder); - builder._GroupDef._HasMaxAttr = true; - } - - - // private static void XDR_BeginGroup(XdrBuilder builder) - // { - // - // } - - - private static void XDR_EndGroup(XdrBuilder builder) - { - if (!builder._ElementDef._ExistTerminal) - { - builder.SendValidationEvent(ResXml.Sch_ElementMissing); - } - - builder._contentValidator.CloseGroup(); - - if (builder._GroupDef._Order == SchemaOrderMany) - { - builder._contentValidator.AddStar(); - } - - if (SchemaOrderMany == builder._GroupDef._Order && - builder._GroupDef._HasMaxAttr && - builder._GroupDef._MaxVal != uint.MaxValue) - { - builder.SendValidationEvent(ResXml.Sch_ManyMaxOccurs); - } - - HandleMinMax(builder._contentValidator, - builder._GroupDef._MinVal, - builder._GroupDef._MaxVal); - - builder.PopGroupInfo(); - } - - - // - // DataType - // - - private static void XDR_InitElementDtType(XdrBuilder builder, object obj) - { - if (builder._ElementDef._HasDataType) - { - builder.SendValidationEvent(ResXml.Sch_DupDtType); - } - - if (!builder._ElementDef._AllowDataType) - { - builder.SendValidationEvent(ResXml.Sch_DataTypeTextOnly); - } - } - - private static void XDR_EndElementDtType(XdrBuilder builder) - { - if (!builder._ElementDef._HasDataType) - { - builder.SendValidationEvent(ResXml.Sch_MissAttribute); - } - builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.TextOnly; - builder._ElementDef._ContentAttr = SchemaContentText; - builder._ElementDef._MasterGroupRequired = false; - builder._contentValidator = null; - } - - private static void XDR_InitAttributeDtType(XdrBuilder builder, object obj) - { - if (builder._AttributeDef._HasDataType) - { - builder.SendValidationEvent(ResXml.Sch_DupDtType); - } - } - - private static void XDR_EndAttributeDtType(XdrBuilder builder) - { - string code = null; - - if (!builder._AttributeDef._HasDataType) - { - code = ResXml.Sch_MissAttribute; - } - else - { - if (builder._AttributeDef._AttDef.Datatype != null) - { - XmlTokenizedType ttype = builder._AttributeDef._AttDef.Datatype.TokenizedType; - - if (ttype == XmlTokenizedType.ENUMERATION && !builder._AttributeDef._EnumerationRequired) - { - code = ResXml.Sch_MissDtvaluesAttribute; - } - else if (ttype != XmlTokenizedType.ENUMERATION && builder._AttributeDef._EnumerationRequired) - { - code = ResXml.Sch_RequireEnumeration; - } - } - } - if (code != null) - { - builder.SendValidationEvent(code); - } - } - - // - // private utility methods - // - - private bool GetNextState(XmlQualifiedName qname) - { - if (_CurState._NextStates != null) - { - for (int i = 0; i < _CurState._NextStates.Length; i++) - { - if (_SchemaNames.TokenToQName[(int)s_schemaEntries[_CurState._NextStates[i]]._Name].Equals(qname)) - { - _NextState = s_schemaEntries[_CurState._NextStates[i]]; - return true; - } - } - } - - return false; - } - - private bool IsSkipableElement(XmlQualifiedName qname) - { - string ns = qname.Namespace; - if (ns != null && !Ref.Equal(ns, _SchemaNames.NsXdr)) - return true; - - // skip description && extends - if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.XdrDescription].Equals(qname) || - _SchemaNames.TokenToQName[(int)SchemaNames.Token.XdrExtends].Equals(qname)) - return true; - - return false; - } - - private bool IsSkipableAttribute(XmlQualifiedName qname) - { - string ns = qname.Namespace; - if ( - ns.Length != 0 && - !Ref.Equal(ns, _SchemaNames.NsXdr) && - !Ref.Equal(ns, _SchemaNames.NsDataType) - ) - { - return true; - } - - if (Ref.Equal(ns, _SchemaNames.NsDataType) && - _CurState._Name == SchemaNames.Token.XdrDatatype && - (_SchemaNames.QnDtMax.Equals(qname) || - _SchemaNames.QnDtMin.Equals(qname) || - _SchemaNames.QnDtMaxExclusive.Equals(qname) || - _SchemaNames.QnDtMinExclusive.Equals(qname))) - { - return true; - } - - return false; - } - - private int GetOrder(XmlQualifiedName qname) - { - int order = 0; - if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaSeq].Equals(qname)) - { - order = SchemaOrderSequence; - } - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaOne].Equals(qname)) - { - order = SchemaOrderChoice; - } - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaMany].Equals(qname)) - { - order = SchemaOrderMany; - } - else - { - SendValidationEvent(ResXml.Sch_UnknownOrder, qname.Name); - } - - return order; - } - - private void AddOrder() - { - // additional order can be add on by changing the setOrder and addOrder - switch (_GroupDef._Order) - { - case SchemaOrderSequence: - _contentValidator.AddSequence(); - break; - case SchemaOrderChoice: - case SchemaOrderMany: - _contentValidator.AddChoice(); - break; - default: - case SchemaOrderAll: - throw new XmlException(ResXml.Xml_UnexpectedToken, "NAME"); - } - } - - private static bool IsYes(object obj, XdrBuilder builder) - { - XmlQualifiedName qname = (XmlQualifiedName)obj; - bool fYes = false; - - if (qname.Name == "yes") - { - fYes = true; - } - else if (qname.Name != "no") - { - builder.SendValidationEvent(ResXml.Sch_UnknownRequired); - } - - return fYes; - } - - private static uint ParseMinOccurs(object obj, XdrBuilder builder) - { - uint cVal = 1; - - if (!ParseInteger((string)obj, ref cVal) || (cVal != 0 && cVal != 1)) - { - builder.SendValidationEvent(ResXml.Sch_MinOccursInvalid); - } - return cVal; - } - - private static uint ParseMaxOccurs(object obj, XdrBuilder builder) - { - uint cVal = uint.MaxValue; - string s = (string)obj; - - if (!s.Equals("*") && - (!ParseInteger(s, ref cVal) || (cVal != uint.MaxValue && cVal != 1))) - { - builder.SendValidationEvent(ResXml.Sch_MaxOccursInvalid); - } - return cVal; - } - - private static void HandleMinMax(ParticleContentValidator pContent, uint cMin, uint cMax) - { - if (pContent != null) - { - if (cMax == uint.MaxValue) - { - if (cMin == 0) - pContent.AddStar(); // minOccurs="0" and maxOccurs="infinite" - else - pContent.AddPlus(); // minOccurs="1" and maxOccurs="infinite" - } - else if (cMin == 0) - { // minOccurs="0" and maxOccurs="1") - pContent.AddQMark(); - } - } - } - - private static void ParseDtMaxLength(ref uint cVal, object obj, XdrBuilder builder) - { - if (uint.MaxValue != cVal) - { - builder.SendValidationEvent(ResXml.Sch_DupDtMaxLength); - } - - if (!ParseInteger((string)obj, ref cVal) || cVal < 0) - { - builder.SendValidationEvent(ResXml.Sch_DtMaxLengthInvalid, obj.ToString()); - } - } - - private static void ParseDtMinLength(ref uint cVal, object obj, XdrBuilder builder) - { - if (uint.MaxValue != cVal) - { - builder.SendValidationEvent(ResXml.Sch_DupDtMinLength); - } - - if (!ParseInteger((string)obj, ref cVal) || cVal < 0) - { - builder.SendValidationEvent(ResXml.Sch_DtMinLengthInvalid, obj.ToString()); - } - } - - private static void CompareMinMaxLength(uint cMin, uint cMax, XdrBuilder builder) - { - if (cMin != uint.MaxValue && cMax != uint.MaxValue && cMin > cMax) - { - builder.SendValidationEvent(ResXml.Sch_DtMinMaxLength); - } - } - - private static bool ParseInteger(string str, ref uint n) - { - return UInt32.TryParse(str, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out n); - } - - private void XDR_CheckAttributeDefault(DeclBaseInfo decl, SchemaAttDef pAttdef) - { - if (decl._Default != null || pAttdef.DefaultValueTyped != null) - { - if (decl._Default != null) - { - pAttdef.DefaultValueRaw = pAttdef.DefaultValueExpanded = (string)decl._Default; - CheckDefaultAttValue(pAttdef); - } - } - - SetAttributePresence(pAttdef, 1 == decl._MinOccurs); - } - - private void SetAttributePresence(SchemaAttDef pAttdef, bool fRequired) - { - if (SchemaDeclBase.Use.Fixed != pAttdef.Presence) - { - if (fRequired || SchemaDeclBase.Use.Required == pAttdef.Presence) - { - // If it is required and it has a default value then it is a FIXED attribute. - if (pAttdef.DefaultValueTyped != null) - pAttdef.Presence = SchemaDeclBase.Use.Fixed; - else - pAttdef.Presence = SchemaDeclBase.Use.Required; - } - else if (pAttdef.DefaultValueTyped != null) - { - pAttdef.Presence = SchemaDeclBase.Use.Default; - } - else - { - pAttdef.Presence = SchemaDeclBase.Use.Implied; - } - } - } - - private int GetContent(XmlQualifiedName qname) - { - int content = 0; - if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaEmpty].Equals(qname)) - { - content = SchemaContentEmpty; - _ElementDef._AllowDataType = false; - } - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaElementOnly].Equals(qname)) - { - content = SchemaContentElement; - _ElementDef._AllowDataType = false; - } - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaMixed].Equals(qname)) - { - content = SchemaContentMixed; - _ElementDef._AllowDataType = false; - } - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaTextOnly].Equals(qname)) - { - content = SchemaContentText; - } - else - { - SendValidationEvent(ResXml.Sch_UnknownContent, qname.Name); - } - return content; - } - - private bool GetModel(XmlQualifiedName qname) - { - bool fOpen = false; - if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaOpen].Equals(qname)) - fOpen = true; - else if (_SchemaNames.TokenToQName[(int)SchemaNames.Token.SchemaClosed].Equals(qname)) - fOpen = false; - else - SendValidationEvent(ResXml.Sch_UnknownModel, qname.Name); - return fOpen; - } - - private XmlSchemaDatatype CheckDatatype(string str) - { - XmlSchemaDatatype dtype = XmlSchemaDatatype.FromXdrName(str); - if (dtype == null) - { - SendValidationEvent(ResXml.Sch_UnknownDtType, str); - } - else if (dtype.TokenizedType == XmlTokenizedType.ID) - { - if (!_AttributeDef._Global) - { - if (_ElementDef._ElementDecl.IsIdDeclared) - { - SendValidationEvent(ResXml.Sch_IdAttrDeclared, - XmlQualifiedName.ToString(_ElementDef._ElementDecl.Name.Name, _ElementDef._ElementDecl.Prefix)); - } - _ElementDef._ElementDecl.IsIdDeclared = true; - } - } - - return dtype; - } - - private void CheckDefaultAttValue(SchemaAttDef attDef) - { - string str = (attDef.DefaultValueRaw).Trim(); - XdrValidator.CheckDefaultValue(str, attDef, _SchemaInfo, _CurNsMgr, _NameTable, null, _validationEventHandler, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition); - } - - private bool IsGlobal(int flags) - { - return flags == SchemaFlagsNs; - } - - private void SendValidationEvent(string code, string[] args, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, args, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - - private void SendValidationEvent(string code) - { - SendValidationEvent(code, string.Empty); - } - - private void SendValidationEvent(string code, string msg) - { - SendValidationEvent(new XmlSchemaException(code, msg, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition), XmlSeverityType.Error); - } - - private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) - { - _SchemaInfo.ErrorCount++; - if (_validationEventHandler != null) - { - _validationEventHandler(this, new ValidationEventArgs(e, severity)); - } - else if (severity == XmlSeverityType.Error) - { - throw e; - } - } - }; // class XdrBuilder -} // namespace Microsoft.Xml diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlAtomicValue.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlAtomicValue.cs deleted file mode 100644 index 21e71781c94..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlAtomicValue.cs +++ /dev/null @@ -1,414 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.Xml.XPath; -using System.Diagnostics; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - /// This class contains a (CLR Object, XmlType) pair that represents an instance of an Xml atomic value. - /// It is optimized to avoid boxing. - /// - public sealed class XmlAtomicValue : XPathItem, ICloneable - { - private XmlSchemaType _xmlType; - private object _objVal; - private TypeCode _clrType; - private Union _unionVal; - private NamespacePrefixForQName _nsPrefix; - - [StructLayout(LayoutKind.Explicit, Size = 8)] - private struct Union - { - [FieldOffset(0)] public bool boolVal; - [FieldOffset(0)] public double dblVal; - [FieldOffset(0)] public long i64Val; - [FieldOffset(0)] public int i32Val; - [FieldOffset(0)] public DateTime dtVal; - } - - private class NamespacePrefixForQName : IXmlNamespaceResolver - { - public string prefix; - public string ns; - - public NamespacePrefixForQName(string prefix, string ns) - { - this.ns = ns; - this.prefix = prefix; - } - public string LookupNamespace(string prefix) - { - if (prefix == this.prefix) - { - return ns; - } - return null; - } - - public string LookupPrefix(string namespaceName) - { - if (ns == namespaceName) - { - return prefix; - } - return null; - } - - public IDictionary GetNamespacesInScope(XmlNamespaceScope scope) - { - Dictionary dict = new Dictionary(1); - dict[prefix] = ns; - return dict; - } - } - - //----------------------------------------------- - // XmlAtomicValue constructors and methods - //----------------------------------------------- - - internal XmlAtomicValue(XmlSchemaType xmlType, bool value) - { - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _clrType = TypeCode.Boolean; - _unionVal.boolVal = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, DateTime value) - { - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _clrType = TypeCode.DateTime; - _unionVal.dtVal = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, double value) - { - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _clrType = TypeCode.Double; - _unionVal.dblVal = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, int value) - { - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _clrType = TypeCode.Int32; - _unionVal.i32Val = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, long value) - { - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _clrType = TypeCode.Int64; - _unionVal.i64Val = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, string value) - { - if (value == null) throw new ArgumentNullException("value"); - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _objVal = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _objVal = value; - if (nsResolver != null && (_xmlType.TypeCode == XmlTypeCode.QName || _xmlType.TypeCode == XmlTypeCode.Notation)) - { - string prefix = GetPrefixFromQName(value); - _nsPrefix = new NamespacePrefixForQName(prefix, nsResolver.LookupNamespace(prefix)); - } - } - - internal XmlAtomicValue(XmlSchemaType xmlType, object value) - { - if (value == null) throw new ArgumentNullException("value"); - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _objVal = value; - } - - internal XmlAtomicValue(XmlSchemaType xmlType, object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (xmlType == null) throw new ArgumentNullException("xmlType"); - _xmlType = xmlType; - _objVal = value; - - if (nsResolver != null && (_xmlType.TypeCode == XmlTypeCode.QName || _xmlType.TypeCode == XmlTypeCode.Notation)) - { //Its a qualifiedName - XmlQualifiedName qname = _objVal as XmlQualifiedName; - Debug.Assert(qname != null); //string representation is handled in a different overload - string ns = qname.Namespace; - _nsPrefix = new NamespacePrefixForQName(nsResolver.LookupPrefix(ns), ns); - } - } - - /// - /// Since XmlAtomicValue is immutable, clone simply returns this. - /// - public XmlAtomicValue Clone() - { - return this; - } - - - //----------------------------------------------- - // ICloneable methods - //----------------------------------------------- - - /// - /// Since XmlAtomicValue is immutable, clone simply returns this. - /// - object ICloneable.Clone() - { - return this; - } - - - //----------------------------------------------- - // XPathItem methods - //----------------------------------------------- - - public override bool IsNode - { - get { return false; } - } - - public override XmlSchemaType XmlType - { - get { return _xmlType; } - } - - public override Type ValueType - { - get { return _xmlType.Datatype.ValueType; } - } - - public override object TypedValue - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ChangeType(_unionVal.boolVal, ValueType); - case TypeCode.Int32: return valueConverter.ChangeType(_unionVal.i32Val, ValueType); - case TypeCode.Int64: return valueConverter.ChangeType(_unionVal.i64Val, ValueType); - case TypeCode.Double: return valueConverter.ChangeType(_unionVal.dblVal, ValueType); - case TypeCode.DateTime: return valueConverter.ChangeType(_unionVal.dtVal, ValueType); - default: Debug.Assert(false, "Should never get here"); break; - } - } - return valueConverter.ChangeType(_objVal, ValueType, _nsPrefix); - } - } - - public override bool ValueAsBoolean - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return _unionVal.boolVal; - case TypeCode.Int32: return valueConverter.ToBoolean(_unionVal.i32Val); - case TypeCode.Int64: return valueConverter.ToBoolean(_unionVal.i64Val); - case TypeCode.Double: return valueConverter.ToBoolean(_unionVal.dblVal); - case TypeCode.DateTime: return valueConverter.ToBoolean(_unionVal.dtVal); - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ToBoolean(_objVal); - } - } - - public override DateTime ValueAsDateTime - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ToDateTime(_unionVal.boolVal); - case TypeCode.Int32: return valueConverter.ToDateTime(_unionVal.i32Val); - case TypeCode.Int64: return valueConverter.ToDateTime(_unionVal.i64Val); - case TypeCode.Double: return valueConverter.ToDateTime(_unionVal.dblVal); - case TypeCode.DateTime: return _unionVal.dtVal; - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ToDateTime(_objVal); - } - } - - - public override double ValueAsDouble - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ToDouble(_unionVal.boolVal); - case TypeCode.Int32: return valueConverter.ToDouble(_unionVal.i32Val); - case TypeCode.Int64: return valueConverter.ToDouble(_unionVal.i64Val); - case TypeCode.Double: return _unionVal.dblVal; - case TypeCode.DateTime: return valueConverter.ToDouble(_unionVal.dtVal); - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ToDouble(_objVal); - } - } - - public override int ValueAsInt - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ToInt32(_unionVal.boolVal); - case TypeCode.Int32: return _unionVal.i32Val; - case TypeCode.Int64: return valueConverter.ToInt32(_unionVal.i64Val); - case TypeCode.Double: return valueConverter.ToInt32(_unionVal.dblVal); - case TypeCode.DateTime: return valueConverter.ToInt32(_unionVal.dtVal); - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ToInt32(_objVal); - } - } - - public override long ValueAsLong - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ToInt64(_unionVal.boolVal); - case TypeCode.Int32: return valueConverter.ToInt64(_unionVal.i32Val); - case TypeCode.Int64: return _unionVal.i64Val; - case TypeCode.Double: return valueConverter.ToInt64(_unionVal.dblVal); - case TypeCode.DateTime: return valueConverter.ToInt64(_unionVal.dtVal); - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ToInt64(_objVal); - } - } - - public override object ValueAs(Type type, IXmlNamespaceResolver nsResolver) - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (type == typeof(XPathItem) || type == typeof(XmlAtomicValue)) - return this; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ChangeType(_unionVal.boolVal, type); - case TypeCode.Int32: return valueConverter.ChangeType(_unionVal.i32Val, type); - case TypeCode.Int64: return valueConverter.ChangeType(_unionVal.i64Val, type); - case TypeCode.Double: return valueConverter.ChangeType(_unionVal.dblVal, type); - case TypeCode.DateTime: return valueConverter.ChangeType(_unionVal.dtVal, type); - default: Debug.Assert(false, "Should never get here"); break; - } - } - - return valueConverter.ChangeType(_objVal, type, nsResolver); - } - - public override string Value - { - get - { - XmlValueConverter valueConverter = _xmlType.ValueConverter; - - if (_objVal == null) - { - switch (_clrType) - { - case TypeCode.Boolean: return valueConverter.ToString(_unionVal.boolVal); - case TypeCode.Int32: return valueConverter.ToString(_unionVal.i32Val); - case TypeCode.Int64: return valueConverter.ToString(_unionVal.i64Val); - case TypeCode.Double: return valueConverter.ToString(_unionVal.dblVal); - case TypeCode.DateTime: return valueConverter.ToString(_unionVal.dtVal); - default: Debug.Assert(false, "Should never get here"); break; - } - } - return valueConverter.ToString(_objVal, _nsPrefix); - } - } - - public override string ToString() - { - return Value; - } - - private string GetPrefixFromQName(string value) - { - int colonOffset; - int len = ValidateNames.ParseQName(value, 0, out colonOffset); - - if (len == 0 || len != value.Length) - { - return null; - } - if (colonOffset != 0) - { - return value.Substring(0, colonOffset); - } - else - { - return string.Empty; - } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchema.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchema.cs deleted file mode 100644 index 0d05a0200c3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchema.cs +++ /dev/null @@ -1,756 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - using System.IO; - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - using System.Threading; - using System.Diagnostics; - - /// - /// - /// [To be supplied.] - /// - [XmlRoot("schema", Namespace = XmlSchema.Namespace)] - public class XmlSchema : XmlSchemaObject - { - /// - /// - /// [To be supplied.] - /// - public const string Namespace = XmlReservedNs.NsXs; - /// - /// - /// [To be supplied.] - /// - public const string InstanceNamespace = XmlReservedNs.NsXsi; - - private XmlSchemaForm _attributeFormDefault = XmlSchemaForm.None; - private XmlSchemaForm _elementFormDefault = XmlSchemaForm.None; - private XmlSchemaDerivationMethod _blockDefault = XmlSchemaDerivationMethod.None; - private XmlSchemaDerivationMethod _finalDefault = XmlSchemaDerivationMethod.None; - private string _targetNs; - private string _version; - private XmlSchemaObjectCollection _includes = new XmlSchemaObjectCollection(); - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - private string _id; - private XmlAttribute[] _moreAttributes; - - // compiled info - private bool _isCompiled = false; - private bool _isCompiledBySet = false; - private bool _isPreprocessed = false; - private bool _isRedefined = false; - private int _errorCount = 0; - private XmlSchemaObjectTable _attributes; - private XmlSchemaObjectTable _attributeGroups = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _elements = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _types = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _groups = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _notations = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _identityConstraints = new XmlSchemaObjectTable(); - - private static int s_globalIdCounter = -1; - private ArrayList _importedSchemas; - private ArrayList _importedNamespaces; - - private int _schemaId = -1; //Not added to a set - private Uri _baseUri; - private bool _isChameleon; - private Hashtable _ids = new Hashtable(); - private XmlDocument _document; - private XmlNameTable _nameTable; - - /// - /// - /// [To be supplied.] - /// - public XmlSchema() { } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler) - { - return Read(new XmlTextReader(reader), validationEventHandler); - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Read(Stream stream, ValidationEventHandler validationEventHandler) - { - return Read(new XmlTextReader(stream), validationEventHandler); - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Read(XmlReader reader, ValidationEventHandler validationEventHandler) - { - XmlNameTable nameTable = reader.NameTable; - Parser parser = new Parser(SchemaType.XSD, nameTable, new SchemaNames(nameTable), validationEventHandler); - try - { - parser.Parse(reader, null); - } - catch (XmlSchemaException e) - { - if (validationEventHandler != null) - { - validationEventHandler(null, new ValidationEventArgs(e)); - } - else - { - throw e; - } - return null; - } - return parser.XmlSchema; - } - - /// - /// - /// [To be supplied.] - /// - public void Write(Stream stream) - { - Write(stream, null); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(Stream stream, XmlNamespaceManager namespaceManager) - { - XmlTextWriter xmlWriter = new XmlTextWriter(stream, null); - xmlWriter.Formatting = Formatting.Indented; - Write(xmlWriter, namespaceManager); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(TextWriter writer) - { - Write(writer, null); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(TextWriter writer, XmlNamespaceManager namespaceManager) - { - XmlTextWriter xmlWriter = new XmlTextWriter(writer); - xmlWriter.Formatting = Formatting.Indented; - Write(xmlWriter, namespaceManager); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(XmlWriter writer) - { - Write(writer, null); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(XmlWriter writer, XmlNamespaceManager namespaceManager) - { - XmlSerializer serializer = new XmlSerializer(typeof(XmlSchema)); - XmlSerializerNamespaces ns; - - if (namespaceManager != null) - { - ns = new XmlSerializerNamespaces(); - bool ignoreXS = false; - if (this.Namespaces != null) - { //User may have set both nsManager and Namespaces property on the XmlSchema object - ignoreXS = this.Namespaces.Namespaces["xs"] != null || this.Namespaces.Namespaces.ContainsValue(XmlReservedNs.NsXs); - } - if (!ignoreXS && namespaceManager.LookupPrefix(XmlReservedNs.NsXs) == null && - namespaceManager.LookupNamespace("xs") == null) - { - ns.Add("xs", XmlReservedNs.NsXs); - } - foreach (string prefix in namespaceManager) - { - if (prefix != "xml" && prefix != "xmlns") - { - ns.Add(prefix, namespaceManager.LookupNamespace(prefix)); - } - } - } - else if (this.Namespaces != null && this.Namespaces.Count > 0) - { - Hashtable serializerNS = this.Namespaces.Namespaces; - if (serializerNS["xs"] == null && !serializerNS.ContainsValue(XmlReservedNs.NsXs)) - { //Prefix xs not defined AND schema namespace not already mapped to a prefix - serializerNS.Add("xs", XmlReservedNs.NsXs); - } - ns = this.Namespaces; - } - else - { - ns = new XmlSerializerNamespaces(); - ns.Add("xs", XmlSchema.Namespace); - if (_targetNs != null && _targetNs.Length != 0) - { - ns.Add("tns", _targetNs); - } - } - serializer.Serialize(writer, this, ns); - } - - /// - /// - /// [To be supplied.] - /// - [Obsolete("Use Microsoft.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")] - public void Compile(ValidationEventHandler validationEventHandler) - { - SchemaInfo sInfo = new SchemaInfo(); - sInfo.SchemaType = SchemaType.XSD; - CompileSchema(null, Microsoft.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(), sInfo, null, validationEventHandler, NameTable, false); - } - - /// - /// - /// [To be supplied.] - /// - [Obsolete("Use Microsoft.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")] - public void Compile(ValidationEventHandler validationEventHandler, XmlResolver resolver) - { - SchemaInfo sInfo = new SchemaInfo(); - sInfo.SchemaType = SchemaType.XSD; - CompileSchema(null, resolver, sInfo, null, validationEventHandler, NameTable, false); - } - -#pragma warning disable 618 - internal bool CompileSchema(XmlSchemaCollection xsc, XmlResolver resolver, SchemaInfo schemaInfo, string ns, ValidationEventHandler validationEventHandler, XmlNameTable nameTable, bool CompileContentModel) - { - //Need to lock here to prevent multi-threading problems when same schema is added to set and compiled - lock (this) - { - //Preprocessing - SchemaCollectionPreprocessor prep = new SchemaCollectionPreprocessor(nameTable, null, validationEventHandler); - prep.XmlResolver = resolver; - if (!prep.Execute(this, ns, true, xsc)) - { - return false; - } - - //Compilation - SchemaCollectionCompiler compiler = new SchemaCollectionCompiler(nameTable, validationEventHandler); - _isCompiled = compiler.Execute(this, schemaInfo, CompileContentModel); - this.SetIsCompiled(_isCompiled); - //TODO includes isCompiled flag - return _isCompiled; - } - } -#pragma warning restore 618 - - internal void CompileSchemaInSet(XmlNameTable nameTable, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings) - { - Debug.Assert(_isPreprocessed); - Compiler setCompiler = new Compiler(nameTable, eventHandler, null, compilationSettings); - setCompiler.Prepare(this, true); - _isCompiledBySet = setCompiler.Compile(); - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("attributeFormDefault"), DefaultValue(XmlSchemaForm.None)] - public XmlSchemaForm AttributeFormDefault - { - get { return _attributeFormDefault; } - set { _attributeFormDefault = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("blockDefault"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod BlockDefault - { - get { return _blockDefault; } - set { _blockDefault = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("finalDefault"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod FinalDefault - { - get { return _finalDefault; } - set { _finalDefault = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("elementFormDefault"), DefaultValue(XmlSchemaForm.None)] - public XmlSchemaForm ElementFormDefault - { - get { return _elementFormDefault; } - set { _elementFormDefault = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("targetNamespace", DataType = "anyURI")] - public string TargetNamespace - { - get { return _targetNs; } - set { _targetNs = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("version", DataType = "token")] - public string Version - { - get { return _version; } - set { _version = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("include", typeof(XmlSchemaInclude)), - XmlElement("import", typeof(XmlSchemaImport)), - XmlElement("redefine", typeof(XmlSchemaRedefine))] - public XmlSchemaObjectCollection Includes - { - get { return _includes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("annotation", typeof(XmlSchemaAnnotation)), - XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroup)), - XmlElement("complexType", typeof(XmlSchemaComplexType)), - XmlElement("simpleType", typeof(XmlSchemaSimpleType)), - XmlElement("element", typeof(XmlSchemaElement)), - XmlElement("group", typeof(XmlSchemaGroup)), - XmlElement("notation", typeof(XmlSchemaNotation))] - public XmlSchemaObjectCollection Items - { - get { return _items; } - } - - // Compiled info - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public bool IsCompiled - { - get - { - return _isCompiled || _isCompiledBySet; - } - } - - [XmlIgnore] - internal bool IsCompiledBySet - { - get { return _isCompiledBySet; } - set { _isCompiledBySet = value; } - } - - [XmlIgnore] - internal bool IsPreprocessed - { - get { return _isPreprocessed; } - set { _isPreprocessed = value; } - } - - [XmlIgnore] - internal bool IsRedefined - { - get { return _isRedefined; } - set { _isRedefined = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable Attributes - { - get - { - if (_attributes == null) - { - _attributes = new XmlSchemaObjectTable(); - } - return _attributes; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable AttributeGroups - { - get - { - if (_attributeGroups == null) - { - _attributeGroups = new XmlSchemaObjectTable(); - } - return _attributeGroups; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable SchemaTypes - { - get - { - if (_types == null) - { - _types = new XmlSchemaObjectTable(); - } - return _types; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable Elements - { - get - { - if (_elements == null) - { - _elements = new XmlSchemaObjectTable(); - } - return _elements; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("id", DataType = "ID")] - public string Id - { - get { return _id; } - set { _id = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAnyAttribute] - public XmlAttribute[] UnhandledAttributes - { - get { return _moreAttributes; } - set { _moreAttributes = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable Groups - { - get { return _groups; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable Notations - { - get { return _notations; } - } - - [XmlIgnore] - internal XmlSchemaObjectTable IdentityConstraints - { - get { return _identityConstraints; } - } - - [XmlIgnore] - internal Uri BaseUri - { - get { return _baseUri; } - set - { - _baseUri = value; - } - } - - [XmlIgnore] - // Please be careful with this property. Since it lazy initialized and its value depends on a global state - // if it gets called on multiple schemas in a different order the schemas will end up with different IDs - // Unfortunately the IDs are used to sort the schemas in the schema set and thus changing the IDs might change - // the order which would be a breaking change!! - // Simply put if you are planning to add or remove a call to this getter you need to be extra carefull - // or better don't do it at all. - internal int SchemaId - { - get - { - if (_schemaId == -1) - { - _schemaId = Interlocked.Increment(ref s_globalIdCounter); - } - return _schemaId; - } - } - - [XmlIgnore] - internal bool IsChameleon - { - get { return _isChameleon; } - set { _isChameleon = value; } - } - - [XmlIgnore] - internal Hashtable Ids - { - get { return _ids; } - } - - [XmlIgnore] - internal XmlDocument Document - { - get { if (_document == null) _document = new XmlDocument(); return _document; } - } - - [XmlIgnore] - internal int ErrorCount - { - get { return _errorCount; } - set { _errorCount = value; } - } - - internal new XmlSchema Clone() - { - XmlSchema that = new XmlSchema(); - that._attributeFormDefault = _attributeFormDefault; - that._elementFormDefault = _elementFormDefault; - that._blockDefault = _blockDefault; - that._finalDefault = _finalDefault; - that._targetNs = _targetNs; - that._version = _version; - that._includes = _includes; - - that.Namespaces = this.Namespaces; - that._items = _items; - that.BaseUri = this.BaseUri; - - SchemaCollectionCompiler.Cleanup(that); - return that; - } - - internal XmlSchema DeepClone() - { - XmlSchema that = new XmlSchema(); - that._attributeFormDefault = _attributeFormDefault; - that._elementFormDefault = _elementFormDefault; - that._blockDefault = _blockDefault; - that._finalDefault = _finalDefault; - that._targetNs = _targetNs; - that._version = _version; - that._isPreprocessed = _isPreprocessed; - //that.IsProcessing = this.IsProcessing; //Not sure if this is needed - - //Clone its Items - for (int i = 0; i < _items.Count; ++i) - { - XmlSchemaObject newItem; - - XmlSchemaComplexType complexType; - XmlSchemaElement element; - XmlSchemaGroup group; - - if ((complexType = _items[i] as XmlSchemaComplexType) != null) - { - newItem = complexType.Clone(this); - } - else if ((element = _items[i] as XmlSchemaElement) != null) - { - newItem = element.Clone(this); - } - else if ((group = _items[i] as XmlSchemaGroup) != null) - { - newItem = group.Clone(this); - } - else - { - newItem = _items[i].Clone(); - } - that.Items.Add(newItem); - } - - //Clone Includes - for (int i = 0; i < _includes.Count; ++i) - { - XmlSchemaExternal newInclude = (XmlSchemaExternal)_includes[i].Clone(); - that.Includes.Add(newInclude); - } - that.Namespaces = this.Namespaces; - //that.includes = this.includes; //Need to verify this is OK for redefines - that.BaseUri = this.BaseUri; - return that; - } - - [XmlIgnore] - internal override string IdAttribute - { - get { return Id; } - set { Id = value; } - } - - internal void SetIsCompiled(bool isCompiled) - { - _isCompiled = isCompiled; - } - - internal override void SetUnhandledAttributes(XmlAttribute[] moreAttributes) - { - _moreAttributes = moreAttributes; - } - internal override void AddAnnotation(XmlSchemaAnnotation annotation) - { - _items.Add(annotation); - } - - internal XmlNameTable NameTable - { - get { if (_nameTable == null) _nameTable = new Microsoft.Xml.NameTable(); return _nameTable; } - } - - internal ArrayList ImportedSchemas - { - get - { - if (_importedSchemas == null) - { - _importedSchemas = new ArrayList(); - } - return _importedSchemas; - } - } - - internal ArrayList ImportedNamespaces - { - get - { - if (_importedNamespaces == null) - { - _importedNamespaces = new ArrayList(); - } - return _importedNamespaces; - } - } - - internal void GetExternalSchemasList(IList extList, XmlSchema schema) - { - Debug.Assert(extList != null && schema != null); - if (extList.Contains(schema)) - { - return; - } - extList.Add(schema); - for (int i = 0; i < schema.Includes.Count; ++i) - { - XmlSchemaExternal ext = (XmlSchemaExternal)schema.Includes[i]; - if (ext.Schema != null) - { - GetExternalSchemasList(extList, ext.Schema); - } - } - } - -#if TRUST_COMPILE_STATE - internal void AddCompiledInfo(SchemaInfo schemaInfo) { - XmlQualifiedName itemName; - foreach (XmlSchemaElement element in elements.Values) { - itemName = element.QualifiedName; - schemaInfo.TargetNamespaces[itemName.Namespace] = true; - if (schemaInfo.ElementDecls[itemName] == null) { - schemaInfo.ElementDecls.Add(itemName, element.ElementDecl); - } - } - foreach (XmlSchemaAttribute attribute in attributes.Values) { - itemName = attribute.QualifiedName; - schemaInfo.TargetNamespaces[itemName.Namespace] = true; - if (schemaInfo.ElementDecls[itemName] == null) { - schemaInfo.AttributeDecls.Add(itemName, attribute.AttDef); - } - } - foreach (XmlSchemaType type in types.Values) { - itemName = type.QualifiedName; - schemaInfo.TargetNamespaces[itemName.Namespace] = true; - XmlSchemaComplexType complexType = type as XmlSchemaComplexType; - if ((complexType == null || type != XmlSchemaComplexType.AnyType) && schemaInfo.ElementDeclsByType[itemName] == null) { - schemaInfo.ElementDeclsByType.Add(itemName, type.ElementDecl); - } - } - foreach (XmlSchemaNotation notation in notations.Values) { - itemName = notation.QualifiedName; - schemaInfo.TargetNamespaces[itemName.Namespace] = true; - SchemaNotation no = new SchemaNotation(itemName); - no.SystemLiteral = notation.System; - no.Pubid = notation.Public; - if (schemaInfo.Notations[itemName.Name] == null) { - schemaInfo.Notations.Add(itemName.Name, no); - } - } - } - #endif//TRUST_COMPILE_STATE - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAll.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAll.cs deleted file mode 100644 index c64c3677053..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAll.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAll : XmlSchemaGroupBase - { - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - - /// - /// - /// [To be supplied.] - /// - [XmlElement("element", typeof(XmlSchemaElement))] - public override XmlSchemaObjectCollection Items - { - get { return _items; } - } - - internal override bool IsEmpty - { - get { return base.IsEmpty || _items.Count == 0; } - } - - internal override void SetItems(XmlSchemaObjectCollection newItems) - { - _items = newItems; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotated.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotated.cs deleted file mode 100644 index 49185069ce0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotated.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAnnotated : XmlSchemaObject - { - private string _id; - private XmlSchemaAnnotation _annotation; - private XmlAttribute[] _moreAttributes; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("id", DataType = "ID")] - public string Id - { - get { return _id; } - set { _id = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("annotation", typeof(XmlSchemaAnnotation))] - public XmlSchemaAnnotation Annotation - { - get { return _annotation; } - set { _annotation = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAnyAttribute] - public XmlAttribute[] UnhandledAttributes - { - get { return _moreAttributes; } - set { _moreAttributes = value; } - } - - [XmlIgnore] - internal override string IdAttribute - { - get { return Id; } - set { Id = value; } - } - - internal override void SetUnhandledAttributes(XmlAttribute[] moreAttributes) - { - _moreAttributes = moreAttributes; - } - internal override void AddAnnotation(XmlSchemaAnnotation annotation) - { - _annotation = annotation; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotation.cs deleted file mode 100644 index c3aab1693d6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnnotation.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAnnotation : XmlSchemaObject - { - private string _id; - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - private XmlAttribute[] _moreAttributes; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("id", DataType = "ID")] - public string Id - { - get { return _id; } - set { _id = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("documentation", typeof(XmlSchemaDocumentation)), - XmlElement("appinfo", typeof(XmlSchemaAppInfo))] - public XmlSchemaObjectCollection Items - { - get { return _items; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAnyAttribute] - public XmlAttribute[] UnhandledAttributes - { - get { return _moreAttributes; } - set { _moreAttributes = value; } - } - - [XmlIgnore] - internal override string IdAttribute - { - get { return Id; } - set { Id = value; } - } - - internal override void SetUnhandledAttributes(XmlAttribute[] moreAttributes) - { - _moreAttributes = moreAttributes; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAny.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAny.cs deleted file mode 100644 index 6e26e708eec..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAny.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.ComponentModel; - using Microsoft.Xml.Serialization; - using System.Text; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAny : XmlSchemaParticle - { - private string _ns; - private XmlSchemaContentProcessing _processContents = XmlSchemaContentProcessing.None; - private NamespaceList _namespaceList; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("namespace")] - public string Namespace - { - get { return _ns; } - set { _ns = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("processContents"), DefaultValue(XmlSchemaContentProcessing.None)] - public XmlSchemaContentProcessing ProcessContents - { - get { return _processContents; } - set { _processContents = value; } - } - - [XmlIgnore] - internal NamespaceList NamespaceList - { - get { return _namespaceList; } - } - - [XmlIgnore] - internal string ResolvedNamespace - { - get - { - if (_ns == null || _ns.Length == 0) - { - return "##any"; - } - return _ns; - } - } - - [XmlIgnore] - internal XmlSchemaContentProcessing ProcessContentsCorrect - { - get { return _processContents == XmlSchemaContentProcessing.None ? XmlSchemaContentProcessing.Strict : _processContents; } - } - - internal override string NameString - { - get - { - switch (_namespaceList.Type) - { - case NamespaceList.ListType.Any: - return "##any:*"; - - case NamespaceList.ListType.Other: - return "##other:*"; - - case NamespaceList.ListType.Set: - StringBuilder sb = new StringBuilder(); - int i = 1; - foreach (string wildcardNS in _namespaceList.Enumerate) - { - sb.Append(wildcardNS + ":*"); - if (i < _namespaceList.Enumerate.Count) - { - sb.Append(" "); - } - i++; - } - return sb.ToString(); - - default: - return string.Empty; - } - } - } - - internal void BuildNamespaceList(string targetNamespace) - { - if (_ns != null) - { //If namespace="" default to namespace="##any" - _namespaceList = new NamespaceList(_ns, targetNamespace); - } - else - { - _namespaceList = new NamespaceList(); - } - } - - internal void BuildNamespaceListV1Compat(string targetNamespace) - { - if (_ns != null) - { - _namespaceList = new NamespaceListV1Compat(_ns, targetNamespace); - } - else - { - _namespaceList = new NamespaceList(); //This is only ##any, hence base class is sufficient - } - } - - internal bool Allows(XmlQualifiedName qname) - { - return _namespaceList.Allows(qname.Namespace); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnyAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnyAttribute.cs deleted file mode 100644 index 8864228fc6d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAnyAttribute.cs +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAnyAttribute : XmlSchemaAnnotated - { - private string _ns; - private XmlSchemaContentProcessing _processContents = XmlSchemaContentProcessing.None; - private NamespaceList _namespaceList; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("namespace")] - public string Namespace - { - get { return _ns; } - set { _ns = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("processContents"), DefaultValue(XmlSchemaContentProcessing.None)] - public XmlSchemaContentProcessing ProcessContents - { - get { return _processContents; } - set { _processContents = value; } - } - - - [XmlIgnore] - internal NamespaceList NamespaceList - { - get { return _namespaceList; } - } - - [XmlIgnore] - internal XmlSchemaContentProcessing ProcessContentsCorrect - { - get { return _processContents == XmlSchemaContentProcessing.None ? XmlSchemaContentProcessing.Strict : _processContents; } - } - - internal void BuildNamespaceList(string targetNamespace) - { - if (_ns != null) - { - _namespaceList = new NamespaceList(_ns, targetNamespace); - } - else - { - _namespaceList = new NamespaceList(); - } - } - - internal void BuildNamespaceListV1Compat(string targetNamespace) - { - if (_ns != null) - { - _namespaceList = new NamespaceListV1Compat(_ns, targetNamespace); - } - else - { - _namespaceList = new NamespaceList(); //This is only ##any, hence base class is sufficient - } - } - - internal bool Allows(XmlQualifiedName qname) - { - return _namespaceList.Allows(qname.Namespace); - } - - internal static bool IsSubset(XmlSchemaAnyAttribute sub, XmlSchemaAnyAttribute super) - { - return NamespaceList.IsSubset(sub.NamespaceList, super.NamespaceList); - } - - internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat) - { - NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList, v1Compat); - if (nsl != null) - { - XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute(); - anyAttribute._namespaceList = nsl; - anyAttribute.ProcessContents = o1.ProcessContents; - anyAttribute.Annotation = o1.Annotation; - return anyAttribute; - } - else - { - // not expressible - return null; - } - } - - internal static XmlSchemaAnyAttribute Union(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat) - { - NamespaceList nsl = NamespaceList.Union(o1.NamespaceList, o2.NamespaceList, v1Compat); - if (nsl != null) - { - XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute(); - anyAttribute._namespaceList = nsl; - anyAttribute._processContents = o1._processContents; - anyAttribute.Annotation = o1.Annotation; - return anyAttribute; - } - else - { - // not expressible - return null; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAppInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAppInfo.cs deleted file mode 100644 index 29e51099a46..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAppInfo.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAppInfo : XmlSchemaObject - { - private string _source; - private XmlNode[] _markup; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("source", DataType = "anyURI")] - public string Source - { - get { return _source; } - set { _source = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlText(), XmlAnyElement] - public XmlNode[] Markup - { - get { return _markup; } - set { _markup = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttribute.cs deleted file mode 100644 index b88fda31f80..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttribute.cs +++ /dev/null @@ -1,233 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.ComponentModel; -using Microsoft.Xml.Serialization; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAttribute : XmlSchemaAnnotated - { - private string _defaultValue; - private string _fixedValue; - private string _name; - - private XmlSchemaForm _form = XmlSchemaForm.None; - private XmlSchemaUse _use = XmlSchemaUse.None; - - private XmlQualifiedName _refName = XmlQualifiedName.Empty; - private XmlQualifiedName _typeName = XmlQualifiedName.Empty; - private XmlQualifiedName _qualifiedName = XmlQualifiedName.Empty; - - private XmlSchemaSimpleType _type; - private XmlSchemaSimpleType _attributeType; - - private SchemaAttDef _attDef; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("default")] - [DefaultValue(null)] - public string DefaultValue - { - get { return _defaultValue; } - set { _defaultValue = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("fixed")] - [DefaultValue(null)] - public string FixedValue - { - get { return _fixedValue; } - set { _fixedValue = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("form"), DefaultValue(XmlSchemaForm.None)] - public XmlSchemaForm Form - { - get { return _form; } - set { _form = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("ref")] - public XmlQualifiedName RefName - { - get { return _refName; } - set { _refName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("type")] - public XmlQualifiedName SchemaTypeName - { - get { return _typeName; } - set { _typeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleType")] - public XmlSchemaSimpleType SchemaType - { - get { return _type; } - set { _type = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("use"), DefaultValue(XmlSchemaUse.None)] - public XmlSchemaUse Use - { - get { return _use; } - set { _use = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qualifiedName; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - [Obsolete("This property has been deprecated. Please use AttributeSchemaType property that returns a strongly typed attribute type. http://go.microsoft.com/fwlink/?linkid=14202")] - public object AttributeType - { - get - { - if (_attributeType == null) - return null; - - if (_attributeType.QualifiedName.Namespace == XmlReservedNs.NsXs) - { - return _attributeType.Datatype; - } - return _attributeType; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaSimpleType AttributeSchemaType - { - get { return _attributeType; } - } - - internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler) - { - if (schemaSet != null) - { - XmlReaderSettings readerSettings = new XmlReaderSettings(); - readerSettings.ValidationType = ValidationType.Schema; - readerSettings.Schemas = schemaSet; - readerSettings.ValidationEventHandler += valEventHandler; - return new XsdValidatingReader(reader, resolver, readerSettings, this); - } - return null; - } - - [XmlIgnore] - internal XmlSchemaDatatype Datatype - { - get - { - if (_attributeType != null) - { - return _attributeType.Datatype; - } - return null; - } - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qualifiedName = value; - } - - internal void SetAttributeType(XmlSchemaSimpleType value) - { - _attributeType = value; - } - - internal SchemaAttDef AttDef - { - get { return _attDef; } - set { _attDef = value; } - } - - internal bool HasDefault - { - get { return _defaultValue != null; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - - internal override XmlSchemaObject Clone() - { - XmlSchemaAttribute newAtt = (XmlSchemaAttribute)MemberwiseClone(); - - //Deep clone the QNames as these will be updated on chameleon includes - newAtt._refName = _refName.Clone(); - newAtt._typeName = _typeName.Clone(); - newAtt._qualifiedName = _qualifiedName.Clone(); - return newAtt; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroup.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroup.cs deleted file mode 100644 index a2c91af932d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroup.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAttributeGroup : XmlSchemaAnnotated - { - private string _name; - private XmlSchemaObjectCollection _attributes = new XmlSchemaObjectCollection(); - private XmlSchemaAnyAttribute _anyAttribute; - private XmlQualifiedName _qname = XmlQualifiedName.Empty; - private XmlSchemaAttributeGroup _redefined; - private XmlSchemaObjectTable _attributeUses; - private XmlSchemaAnyAttribute _attributeWildcard; - private int _selfReferenceCount; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get { return _attributes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qname; } - } - - [XmlIgnore] - internal XmlSchemaObjectTable AttributeUses - { - get - { - if (_attributeUses == null) - { - _attributeUses = new XmlSchemaObjectTable(); - } - return _attributeUses; - } - } - - [XmlIgnore] - internal XmlSchemaAnyAttribute AttributeWildcard - { - get { return _attributeWildcard; } - set { _attributeWildcard = value; } - } - - /// - [XmlIgnore] - public XmlSchemaAttributeGroup RedefinedAttributeGroup - { - get { return _redefined; } - } - - [XmlIgnore] - internal XmlSchemaAttributeGroup Redefined - { - get { return _redefined; } - set { _redefined = value; } - } - - [XmlIgnore] - internal int SelfReferenceCount - { - get { return _selfReferenceCount; } - set { _selfReferenceCount = value; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qname = value; - } - - internal override XmlSchemaObject Clone() - { - XmlSchemaAttributeGroup newGroup = (XmlSchemaAttributeGroup)MemberwiseClone(); - if (XmlSchemaComplexType.HasAttributeQNameRef(_attributes)) - { //If a ref/type name is present - newGroup._attributes = XmlSchemaComplexType.CloneAttributes(_attributes); - - //Clear compiled tables - newGroup._attributeUses = null; - } - return newGroup; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroupRef.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroupRef.cs deleted file mode 100644 index ab151cab1d5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaAttributeGroupRef.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated - { - private XmlQualifiedName _refName = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("ref")] - public XmlQualifiedName RefName - { - get { return _refName; } - set { _refName = (value == null ? XmlQualifiedName.Empty : value); } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaChoice.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaChoice.cs deleted file mode 100644 index 01fd4856125..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaChoice.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaChoice : XmlSchemaGroupBase - { - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - - /// - /// - /// [To be supplied.] - /// - [XmlElement("element", typeof(XmlSchemaElement)), - XmlElement("group", typeof(XmlSchemaGroupRef)), - XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("sequence", typeof(XmlSchemaSequence)), - XmlElement("any", typeof(XmlSchemaAny))] - public override XmlSchemaObjectCollection Items - { - get { return _items; } - } - - internal override bool IsEmpty - { - get { return base.IsEmpty /*|| items.Count == 0*/; } - } - - internal override void SetItems(XmlSchemaObjectCollection newItems) - { - _items = newItems; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCollection.cs deleted file mode 100644 index e1fab99bc09..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCollection.cs +++ /dev/null @@ -1,519 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Threading; - using System.Collections; - using Microsoft.Xml.Schema; - using System.Runtime.Versioning; - - - /// - /// - /// The XmlSchemaCollection contains a set of namespace URI's. - /// Each namespace also have an associated private data cache - /// corresponding to the XML-Data Schema or W3C XML Schema. - /// The XmlSchemaCollection will able to load XSD and XDR schemas, - /// and compile them into an internal "cooked schema representation". - /// The Validate method then uses this internal representation for - /// efficient runtime validation of any given subtree. - /// - [Obsolete("Use Microsoft.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")] - public sealed class XmlSchemaCollection : ICollection - { - private Hashtable _collection; - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private ReaderWriterLockSlim _wLock; - private int _timeout = Timeout.Infinite; - private bool _isThreadSafe = true; - private ValidationEventHandler _validationEventHandler = null; - private XmlResolver _xmlResolver = null; - - - /// - /// - /// Construct a new empty schema collection. - /// - public XmlSchemaCollection() : this(new NameTable()) - { - } - - /// - /// - /// Construct a new empty schema collection with associated XmlNameTable. - /// The XmlNameTable is used when loading schemas - /// - public XmlSchemaCollection(XmlNameTable nametable) - { - if (nametable == null) - { - throw new ArgumentNullException("nametable"); - } - _nameTable = nametable; - _collection = Hashtable.Synchronized(new Hashtable()); - _xmlResolver = Microsoft.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(); - _isThreadSafe = true; - if (_isThreadSafe) - { - _wLock = new ReaderWriterLockSlim(); - } - } - - /// - /// - /// Returns the number of namespaces defined in this collection - /// (whether or not there is an actual schema associated with those namespaces or not). - /// - public int Count - { - get { return _collection.Count; } - } - - /// - /// - /// The default XmlNameTable used by the XmlSchemaCollection when loading new schemas. - /// - public XmlNameTable NameTable - { - get { return _nameTable; } - } - - /// - public event ValidationEventHandler ValidationEventHandler - { - add { _validationEventHandler += value; } - remove { _validationEventHandler -= value; } - } - - internal XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - } - } - - - /// - /// - /// Add the schema located by the given URL into the schema collection. - /// If the given schema references other namespaces, the schemas for those other - /// namespaces are NOT automatically loaded. - /// - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlSchema Add(string ns, string uri) - { - if (uri == null || uri.Length == 0) - throw new ArgumentNullException("uri"); - XmlTextReader reader = new XmlTextReader(uri, _nameTable); - reader.XmlResolver = _xmlResolver; - - XmlSchema schema = null; - try - { - schema = Add(ns, reader, _xmlResolver); - while (reader.Read()) ;// wellformness check - } - finally - { - reader.Close(); - } - return schema; - } - - /// - public XmlSchema Add(String ns, XmlReader reader) - { - return Add(ns, reader, _xmlResolver); - } - - /// - /// - /// Add the given schema into the schema collection. - /// If the given schema references other namespaces, the schemas for those - /// other namespaces are NOT automatically loaded. - /// - public XmlSchema Add(String ns, XmlReader reader, XmlResolver resolver) - { - if (reader == null) - throw new ArgumentNullException("reader"); - XmlNameTable readerNameTable = reader.NameTable; - SchemaInfo schemaInfo = new SchemaInfo(); - - Parser parser = new Parser(SchemaType.None, readerNameTable, GetSchemaNames(readerNameTable), _validationEventHandler); - parser.XmlResolver = resolver; - SchemaType schemaType; - try - { - schemaType = parser.Parse(reader, ns); - } - catch (XmlSchemaException e) - { - SendValidationEvent(e); - return null; - } - - if (schemaType == SchemaType.XSD) - { - schemaInfo.SchemaType = SchemaType.XSD; - return Add(ns, schemaInfo, parser.XmlSchema, true, resolver); - } - else - { - SchemaInfo xdrSchema = parser.XdrSchema; - return Add(ns, parser.XdrSchema, null, true, resolver); - } - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchema Add(XmlSchema schema) - { - return Add(schema, _xmlResolver); - } - - /// - public XmlSchema Add(XmlSchema schema, XmlResolver resolver) - { - if (schema == null) - throw new ArgumentNullException("schema"); - - SchemaInfo schemaInfo = new SchemaInfo(); - schemaInfo.SchemaType = SchemaType.XSD; - return Add(schema.TargetNamespace, schemaInfo, schema, true, resolver); - } - - /// - /// - /// Adds all the namespaces defined in the given collection - /// (including their associated schemas) to this collection. - /// - public void Add(XmlSchemaCollection schema) - { - if (schema == null) - throw new ArgumentNullException("schema"); - if (this == schema) - return; - IDictionaryEnumerator enumerator = schema._collection.GetEnumerator(); - while (enumerator.MoveNext()) - { - XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value; - Add(node.NamespaceURI, node); - } - } - - - /// - /// - /// Looks up the schema by it's associated namespace URI - /// - public XmlSchema this[string ns] - { - get - { - XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty]; - return (node != null) ? node.Schema : null; - } - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(XmlSchema schema) - { - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - return this[schema.TargetNamespace] != null; - } - - /// - public bool Contains(string ns) - { - return _collection[(ns != null) ? ns : string.Empty] != null; - } - - /// - /// - /// - /// Get a IEnumerator of the XmlSchemaCollection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return new XmlSchemaCollectionEnumerator(_collection); - } - - /// - public XmlSchemaCollectionEnumerator GetEnumerator() - { - return new XmlSchemaCollectionEnumerator(_collection); - } - - /// - /// - void ICollection.CopyTo(Array array, int index) - { - if (array == null) - throw new ArgumentNullException("array"); - if (index < 0) - throw new ArgumentOutOfRangeException("index"); - for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) - { - array.SetValue(e.Current, index++); - } - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(XmlSchema[] array, int index) - { - if (array == null) - throw new ArgumentNullException("array"); - if (index < 0) - throw new ArgumentOutOfRangeException("index"); - for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) - { - XmlSchema schema = e.Current; - if (schema != null) - { - if (index == array.Length) - { - throw new ArgumentOutOfRangeException("index"); - } - array[index++] = e.Current; - } - } - } - - /// - /// - bool ICollection.IsSynchronized - { - get { return true; } - } - - /// - /// - object ICollection.SyncRoot - { - get { return this; } - } - - /// - /// - int ICollection.Count - { - get { return _collection.Count; } - } - - internal SchemaInfo GetSchemaInfo(string ns) - { - XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty]; - return (node != null) ? node.SchemaInfo : null; - } - - internal SchemaNames GetSchemaNames(XmlNameTable nt) - { - if (_nameTable != nt) - { - return new SchemaNames(nt); - } - else - { - if (_schemaNames == null) - { - _schemaNames = new SchemaNames(_nameTable); - } - return _schemaNames; - } - } - - internal XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile) - { - return Add(ns, schemaInfo, schema, compile, _xmlResolver); - } - - private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver) - { - int errorCount = 0; - if (schema != null) - { - if (schema.ErrorCount == 0 && compile) - { - if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, true)) - { - errorCount = 1; - } - ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; - } - errorCount += schema.ErrorCount; - } - else - { - errorCount += schemaInfo.ErrorCount; - //ns = ns == null? string.Empty : NameTable.Add(ns); - ns = NameTable.Add(ns); //Added without checking for ns == null, since XDR cannot have null namespace - } - if (errorCount == 0) - { - XmlSchemaCollectionNode node = new XmlSchemaCollectionNode(); - node.NamespaceURI = ns; - node.SchemaInfo = schemaInfo; - node.Schema = schema; - Add(ns, node); - return schema; - } - return null; - } - - private void Add(string ns, XmlSchemaCollectionNode node) - { - if (_isThreadSafe) - _wLock.TryEnterWriteLock(_timeout); - //wLock.AcquireWriterLock(timeout); - try - { - if (_collection[ns] != null) - _collection.Remove(ns); - _collection.Add(ns, node); - } - finally - { - if (_isThreadSafe) - _wLock.ExitWriteLock(); - //wLock.ReleaseWriterLock(); - } - } - - private void SendValidationEvent(XmlSchemaException e) - { - if (_validationEventHandler != null) - { - _validationEventHandler(this, new ValidationEventArgs(e)); - } - else - { - throw e; - } - } - - internal ValidationEventHandler EventHandler - { - get - { - return _validationEventHandler; - } - set - { - _validationEventHandler = value; - } - } - }; - - - internal sealed class XmlSchemaCollectionNode - { - private String _namespaceUri; - private SchemaInfo _schemaInfo; - private XmlSchema _schema; - - internal String NamespaceURI - { - get { return _namespaceUri; } - set { _namespaceUri = value; } - } - - internal SchemaInfo SchemaInfo - { - get { return _schemaInfo; } - set { _schemaInfo = value; } - } - - internal XmlSchema Schema - { - get { return _schema; } - set { _schema = value; } - } - } - - - /// - /// - /// [To be supplied.] - /// - public sealed class XmlSchemaCollectionEnumerator : IEnumerator - { - private IDictionaryEnumerator _enumerator; - - internal XmlSchemaCollectionEnumerator(Hashtable collection) - { - _enumerator = collection.GetEnumerator(); - } - - /// - /// - void IEnumerator.Reset() - { - _enumerator.Reset(); - } - - /// - /// - bool IEnumerator.MoveNext() - { - return _enumerator.MoveNext(); - } - - /// - /// - /// [To be supplied.] - /// - public bool MoveNext() - { - return _enumerator.MoveNext(); - } - - /// - /// - object IEnumerator.Current - { - get { return this.Current; } - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchema Current - { - get - { - XmlSchemaCollectionNode n = (XmlSchemaCollectionNode)_enumerator.Value; - if (n != null) - return n.Schema; - else - return null; - } - } - - internal XmlSchemaCollectionNode CurrentNode - { - get - { - XmlSchemaCollectionNode n = (XmlSchemaCollectionNode)_enumerator.Value; - return n; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCompilationSettings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCompilationSettings.cs deleted file mode 100644 index 7c320a406cd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaCompilationSettings.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - public sealed class XmlSchemaCompilationSettings - { - private bool _enableUpaCheck; - - public XmlSchemaCompilationSettings() - { - _enableUpaCheck = true; - } - - public bool EnableUpaCheck - { - get - { - return _enableUpaCheck; - } - set - { - _enableUpaCheck = value; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContent.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContent.cs deleted file mode 100644 index a2739ad3ba3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContent.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaComplexContent : XmlSchemaContentModel - { - private XmlSchemaContent _content; - private bool _isMixed; - private bool _hasMixedAttribute; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("mixed")] - public bool IsMixed - { - get { return _isMixed; } - set { _isMixed = value; _hasMixedAttribute = true; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("restriction", typeof(XmlSchemaComplexContentRestriction)), - XmlElement("extension", typeof(XmlSchemaComplexContentExtension))] - public override XmlSchemaContent Content - { - get { return _content; } - set { _content = value; } - } - - [XmlIgnore] - internal bool HasMixedAttribute - { - get { return _hasMixedAttribute; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentExtension.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentExtension.cs deleted file mode 100644 index 1e6a3fc5887..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentExtension.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaComplexContentExtension : XmlSchemaContent - { - private XmlSchemaParticle _particle; - private XmlSchemaObjectCollection _attributes = new XmlSchemaObjectCollection(); - private XmlSchemaAnyAttribute _anyAttribute; - private XmlQualifiedName _baseTypeName = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("base")] - public XmlQualifiedName BaseTypeName - { - get { return _baseTypeName; } - set { _baseTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("group", typeof(XmlSchemaGroupRef)), - XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("all", typeof(XmlSchemaAll)), - XmlElement("sequence", typeof(XmlSchemaSequence))] - public XmlSchemaParticle Particle - { - get { return _particle; } - set { _particle = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get { return _attributes; } - } - - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - internal void SetAttributes(XmlSchemaObjectCollection newAttributes) - { - _attributes = newAttributes; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentRestriction.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentRestriction.cs deleted file mode 100644 index 25ee6bd7250..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexContentRestriction.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaComplexContentRestriction : XmlSchemaContent - { - private XmlSchemaParticle _particle; - private XmlSchemaObjectCollection _attributes = new XmlSchemaObjectCollection(); - private XmlSchemaAnyAttribute _anyAttribute; - private XmlQualifiedName _baseTypeName = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("base")] - public XmlQualifiedName BaseTypeName - { - get { return _baseTypeName; } - set { _baseTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("group", typeof(XmlSchemaGroupRef)), - XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("all", typeof(XmlSchemaAll)), - XmlElement("sequence", typeof(XmlSchemaSequence))] - public XmlSchemaParticle Particle - { - get { return _particle; } - set { _particle = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get { return _attributes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - internal void SetAttributes(XmlSchemaObjectCollection newAttributes) - { - _attributes = newAttributes; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexType.cs deleted file mode 100644 index 82da56c5035..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaComplexType.cs +++ /dev/null @@ -1,658 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaComplexType : XmlSchemaType - { - private XmlSchemaDerivationMethod _block = XmlSchemaDerivationMethod.None; - - private XmlSchemaContentModel _contentModel; - private XmlSchemaParticle _particle; - private XmlSchemaObjectCollection _attributes; - private XmlSchemaAnyAttribute _anyAttribute; - - private XmlSchemaParticle _contentTypeParticle = XmlSchemaParticle.Empty; - private XmlSchemaDerivationMethod _blockResolved; - private XmlSchemaObjectTable _localElements; - private XmlSchemaObjectTable _attributeUses; - private XmlSchemaAnyAttribute _attributeWildcard; - - private static XmlSchemaComplexType s_anyTypeLax; - private static XmlSchemaComplexType s_anyTypeSkip; - private static XmlSchemaComplexType s_untypedAnyType; - - //additional info for Partial validation - private byte _pvFlags; - private const byte wildCardMask = 0x01; - private const byte isMixedMask = 0x02; - private const byte isAbstractMask = 0x04; - //const byte dupDeclMask = 0x08; - - static XmlSchemaComplexType() - { - s_anyTypeLax = CreateAnyType(XmlSchemaContentProcessing.Lax); - s_anyTypeSkip = CreateAnyType(XmlSchemaContentProcessing.Skip); - - // Create xdt:untypedAny - s_untypedAnyType = new XmlSchemaComplexType(); - s_untypedAnyType.SetQualifiedName(new XmlQualifiedName("untypedAny", XmlReservedNs.NsXQueryDataType)); - s_untypedAnyType.IsMixed = true; - s_untypedAnyType.SetContentTypeParticle(s_anyTypeLax.ContentTypeParticle); - s_untypedAnyType.SetContentType(XmlSchemaContentType.Mixed); - - s_untypedAnyType.ElementDecl = SchemaElementDecl.CreateAnyTypeElementDecl(); - s_untypedAnyType.ElementDecl.SchemaType = s_untypedAnyType; - s_untypedAnyType.ElementDecl.ContentValidator = AnyTypeContentValidator; - } - - private static XmlSchemaComplexType CreateAnyType(XmlSchemaContentProcessing processContents) - { - XmlSchemaComplexType localAnyType = new XmlSchemaComplexType(); - localAnyType.SetQualifiedName(DatatypeImplementation.QnAnyType); - - XmlSchemaAny anyElement = new XmlSchemaAny(); - anyElement.MinOccurs = decimal.Zero; - anyElement.MaxOccurs = decimal.MaxValue; - - anyElement.ProcessContents = processContents; - anyElement.BuildNamespaceList(null); - XmlSchemaSequence seq = new XmlSchemaSequence(); - seq.Items.Add(anyElement); - - localAnyType.SetContentTypeParticle(seq); - localAnyType.SetContentType(XmlSchemaContentType.Mixed); - - localAnyType.ElementDecl = SchemaElementDecl.CreateAnyTypeElementDecl(); - localAnyType.ElementDecl.SchemaType = localAnyType; - - //Create contentValidator for Any - ParticleContentValidator contentValidator = new ParticleContentValidator(XmlSchemaContentType.Mixed); - contentValidator.Start(); - contentValidator.OpenGroup(); - contentValidator.AddNamespaceList(anyElement.NamespaceList, anyElement); - contentValidator.AddStar(); - contentValidator.CloseGroup(); - ContentValidator anyContentValidator = contentValidator.Finish(true); - localAnyType.ElementDecl.ContentValidator = anyContentValidator; - - XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute(); - anyAttribute.ProcessContents = processContents; - anyAttribute.BuildNamespaceList(null); - localAnyType.SetAttributeWildcard(anyAttribute); - localAnyType.ElementDecl.AnyAttribute = anyAttribute; - return localAnyType; - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchemaComplexType() - { - } - - - [XmlIgnore] - internal static XmlSchemaComplexType AnyType - { - get { return s_anyTypeLax; } - } - - [XmlIgnore] - internal static XmlSchemaComplexType UntypedAnyType - { - get { return s_untypedAnyType; } - } - - [XmlIgnore] - internal static XmlSchemaComplexType AnyTypeSkip - { - get { return s_anyTypeSkip; } - } - - internal static ContentValidator AnyTypeContentValidator - { - get - { - return s_anyTypeLax.ElementDecl.ContentValidator; - } - } - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("abstract"), DefaultValue(false)] - public bool IsAbstract - { - get - { - return (_pvFlags & isAbstractMask) != 0; - } - set - { - if (value) - { - _pvFlags = (byte)(_pvFlags | isAbstractMask); - } - else - { - _pvFlags = (byte)(_pvFlags & ~isAbstractMask); - } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("block"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod Block - { - get { return _block; } - set { _block = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("mixed"), DefaultValue(false)] - public override bool IsMixed - { - get - { - return (_pvFlags & isMixedMask) != 0; - } - set - { - if (value) - { - _pvFlags = (byte)(_pvFlags | isMixedMask); - } - else - { - _pvFlags = (byte)(_pvFlags & ~isMixedMask); - } - } - } - - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleContent", typeof(XmlSchemaSimpleContent)), - XmlElement("complexContent", typeof(XmlSchemaComplexContent))] - public XmlSchemaContentModel ContentModel - { - get { return _contentModel; } - set { _contentModel = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("group", typeof(XmlSchemaGroupRef)), - XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("all", typeof(XmlSchemaAll)), - XmlElement("sequence", typeof(XmlSchemaSequence))] - public XmlSchemaParticle Particle - { - get { return _particle; } - set { _particle = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get - { - if (_attributes == null) - { - _attributes = new XmlSchemaObjectCollection(); - } - return _attributes; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaContentType ContentType - { - get { return SchemaContentType; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaParticle ContentTypeParticle - { - get { return _contentTypeParticle; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDerivationMethod BlockResolved - { - get { return _blockResolved; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable AttributeUses - { - get - { - if (_attributeUses == null) - { - _attributeUses = new XmlSchemaObjectTable(); - } - return _attributeUses; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaAnyAttribute AttributeWildcard - { - get { return _attributeWildcard; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - internal XmlSchemaObjectTable LocalElements - { - get - { - if (_localElements == null) - { - _localElements = new XmlSchemaObjectTable(); - } - return _localElements; - } - } - - internal void SetContentTypeParticle(XmlSchemaParticle value) - { - _contentTypeParticle = value; - } - - internal void SetBlockResolved(XmlSchemaDerivationMethod value) - { - _blockResolved = value; - } - - internal void SetAttributeWildcard(XmlSchemaAnyAttribute value) - { - _attributeWildcard = value; - } - - internal bool HasWildCard - { - get - { - return (_pvFlags & wildCardMask) != 0; - } - set - { - if (value) - { - _pvFlags = (byte)(_pvFlags | wildCardMask); - } - else - { - _pvFlags = (byte)(_pvFlags & ~wildCardMask); - } - } - } - - internal override XmlQualifiedName DerivedFrom - { - get - { - if (_contentModel == null) - { - // type derived from anyType - return XmlQualifiedName.Empty; - } - if (_contentModel.Content is XmlSchemaComplexContentRestriction) - return ((XmlSchemaComplexContentRestriction)_contentModel.Content).BaseTypeName; - else if (_contentModel.Content is XmlSchemaComplexContentExtension) - return ((XmlSchemaComplexContentExtension)_contentModel.Content).BaseTypeName; - else if (_contentModel.Content is XmlSchemaSimpleContentRestriction) - return ((XmlSchemaSimpleContentRestriction)_contentModel.Content).BaseTypeName; - else if (_contentModel.Content is XmlSchemaSimpleContentExtension) - return ((XmlSchemaSimpleContentExtension)_contentModel.Content).BaseTypeName; - else - return XmlQualifiedName.Empty; - } - } - - internal void SetAttributes(XmlSchemaObjectCollection newAttributes) - { - _attributes = newAttributes; - } - - internal bool ContainsIdAttribute(bool findAll) - { - int idCount = 0; - foreach (XmlSchemaAttribute attribute in this.AttributeUses.Values) - { - if (attribute.Use != XmlSchemaUse.Prohibited) - { - XmlSchemaDatatype datatype = attribute.Datatype; - if (datatype != null && datatype.TypeCode == XmlTypeCode.Id) - { - idCount++; - if (idCount > 1) - { //two or more attributes is error - break; - } - } - } - } - return findAll ? (idCount > 1) : (idCount > 0); - } - - internal override XmlSchemaObject Clone() - { - System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaComplexType. Call Clone(XmlSchema) instead."); - return Clone(null); - } - - internal XmlSchemaObject Clone(XmlSchema parentSchema) - { - XmlSchemaComplexType complexType = (XmlSchemaComplexType)MemberwiseClone(); - - //Deep clone the QNames as these will be updated on chameleon includes - if (complexType.ContentModel != null) - { //simpleContent or complexContent - XmlSchemaSimpleContent simpleContent = complexType.ContentModel as XmlSchemaSimpleContent; - if (simpleContent != null) - { - XmlSchemaSimpleContent newSimpleContent = (XmlSchemaSimpleContent)simpleContent.Clone(); - - XmlSchemaSimpleContentExtension simpleExt = simpleContent.Content as XmlSchemaSimpleContentExtension; - if (simpleExt != null) - { - XmlSchemaSimpleContentExtension newSimpleExt = (XmlSchemaSimpleContentExtension)simpleExt.Clone(); - newSimpleExt.BaseTypeName = simpleExt.BaseTypeName.Clone(); - newSimpleExt.SetAttributes(CloneAttributes(simpleExt.Attributes)); - newSimpleContent.Content = newSimpleExt; - } - else - { //simpleContent.Content is XmlSchemaSimpleContentRestriction - XmlSchemaSimpleContentRestriction simpleRest = (XmlSchemaSimpleContentRestriction)simpleContent.Content; - XmlSchemaSimpleContentRestriction newSimpleRest = (XmlSchemaSimpleContentRestriction)simpleRest.Clone(); - newSimpleRest.BaseTypeName = simpleRest.BaseTypeName.Clone(); - newSimpleRest.SetAttributes(CloneAttributes(simpleRest.Attributes)); - newSimpleContent.Content = newSimpleRest; - } - - complexType.ContentModel = newSimpleContent; - } - else - { // complexType.ContentModel is XmlSchemaComplexContent - XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; - XmlSchemaComplexContent newComplexContent = (XmlSchemaComplexContent)complexContent.Clone(); - - XmlSchemaComplexContentExtension complexExt = complexContent.Content as XmlSchemaComplexContentExtension; - if (complexExt != null) - { - XmlSchemaComplexContentExtension newComplexExt = (XmlSchemaComplexContentExtension)complexExt.Clone(); - newComplexExt.BaseTypeName = complexExt.BaseTypeName.Clone(); - newComplexExt.SetAttributes(CloneAttributes(complexExt.Attributes)); - if (HasParticleRef(complexExt.Particle, parentSchema)) - { - newComplexExt.Particle = CloneParticle(complexExt.Particle, parentSchema); - } - newComplexContent.Content = newComplexExt; - } - else - { // complexContent.Content is XmlSchemaComplexContentRestriction - XmlSchemaComplexContentRestriction complexRest = complexContent.Content as XmlSchemaComplexContentRestriction; - XmlSchemaComplexContentRestriction newComplexRest = (XmlSchemaComplexContentRestriction)complexRest.Clone(); - newComplexRest.BaseTypeName = complexRest.BaseTypeName.Clone(); - newComplexRest.SetAttributes(CloneAttributes(complexRest.Attributes)); - if (HasParticleRef(newComplexRest.Particle, parentSchema)) - { - newComplexRest.Particle = CloneParticle(newComplexRest.Particle, parentSchema); - } - newComplexContent.Content = newComplexRest; - } - complexType.ContentModel = newComplexContent; - } - } - else - { //equals XmlSchemaComplexContent with baseType is anyType - if (HasParticleRef(complexType.Particle, parentSchema)) - { - complexType.Particle = CloneParticle(complexType.Particle, parentSchema); - } - complexType.SetAttributes(CloneAttributes(complexType.Attributes)); - } - complexType.ClearCompiledState(); - return complexType; - } - - private void ClearCompiledState() - { - //Re-set post-compiled state for cloned object - _attributeUses = null; - _localElements = null; - _attributeWildcard = null; - _contentTypeParticle = XmlSchemaParticle.Empty; - _blockResolved = XmlSchemaDerivationMethod.None; - } - - internal static XmlSchemaObjectCollection CloneAttributes(XmlSchemaObjectCollection attributes) - { - if (HasAttributeQNameRef(attributes)) - { - XmlSchemaObjectCollection newAttributes = attributes.Clone(); - XmlSchemaAttributeGroupRef attributeGroupRef; - XmlSchemaAttributeGroupRef newAttGroupRef; - XmlSchemaObject xso; - XmlSchemaAttribute att; - - for (int i = 0; i < attributes.Count; i++) - { - xso = attributes[i]; - attributeGroupRef = xso as XmlSchemaAttributeGroupRef; - if (attributeGroupRef != null) - { - newAttGroupRef = (XmlSchemaAttributeGroupRef)attributeGroupRef.Clone(); - newAttGroupRef.RefName = attributeGroupRef.RefName.Clone(); - newAttributes[i] = newAttGroupRef; - } - else - { //Its XmlSchemaAttribute - att = xso as XmlSchemaAttribute; - if (!att.RefName.IsEmpty || !att.SchemaTypeName.IsEmpty) - { - newAttributes[i] = att.Clone(); - } - } - } - return newAttributes; - } - return attributes; - } - - private static XmlSchemaObjectCollection CloneGroupBaseParticles(XmlSchemaObjectCollection groupBaseParticles, XmlSchema parentSchema) - { - XmlSchemaObjectCollection newParticles = groupBaseParticles.Clone(); - - for (int i = 0; i < groupBaseParticles.Count; i++) - { - XmlSchemaParticle p = (XmlSchemaParticle)groupBaseParticles[i]; - newParticles[i] = CloneParticle(p, parentSchema); - } - return newParticles; - } - - internal static XmlSchemaParticle CloneParticle(XmlSchemaParticle particle, XmlSchema parentSchema) - { - XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; - if (groupBase != null) - { //Choice or sequence - XmlSchemaGroupBase newGroupBase = groupBase; - - XmlSchemaObjectCollection newGroupbaseParticles = CloneGroupBaseParticles(groupBase.Items, parentSchema); - newGroupBase = (XmlSchemaGroupBase)groupBase.Clone(); - newGroupBase.SetItems(newGroupbaseParticles); - return newGroupBase; - } - else if (particle is XmlSchemaGroupRef) - { // group ref - XmlSchemaGroupRef newGroupRef = (XmlSchemaGroupRef)particle.Clone(); - newGroupRef.RefName = newGroupRef.RefName.Clone(); - return newGroupRef; - } - else - { - XmlSchemaElement oldElem = particle as XmlSchemaElement; - // If the particle is an element and one of the following is true: - // - it references another element by name - // - it references its type by name - // - it's form (effective) is qualified (meaning it will inherint namespace from chameleon includes if that happens) - // then the element itself needs to be cloned. - if (oldElem != null && (!oldElem.RefName.IsEmpty || !oldElem.SchemaTypeName.IsEmpty || - GetResolvedElementForm(parentSchema, oldElem) == XmlSchemaForm.Qualified)) - { - XmlSchemaElement newElem = (XmlSchemaElement)oldElem.Clone(parentSchema); - return newElem; - } - } - return particle; - } - - // This method returns the effective value of the "element form" for the specified element in the specified - // parentSchema. Element form is either qualified, unqualified or none. If it's qualified it means that - // if the element doesn't declare its own namespace the targetNamespace of the schema is used instead. - // The element form can be either specified on the element itself via the "form" attribute or - // if that one is not present its inheritted from the value of the elementFormDefault attribute on the owning - // schema. - private static XmlSchemaForm GetResolvedElementForm(XmlSchema parentSchema, XmlSchemaElement element) - { - if (element.Form == XmlSchemaForm.None && parentSchema != null) - { - return parentSchema.ElementFormDefault; - } - else - { - return element.Form; - } - } - - internal static bool HasParticleRef(XmlSchemaParticle particle, XmlSchema parentSchema) - { - XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; - if (groupBase != null) - { - bool foundRef = false; - int i = 0; - while (i < groupBase.Items.Count && !foundRef) - { - XmlSchemaParticle p = (XmlSchemaParticle)groupBase.Items[i++]; - if (p is XmlSchemaGroupRef) - { - foundRef = true; - } - else - { - XmlSchemaElement elem = p as XmlSchemaElement; - // This is the same condition as in the CloneParticle method - // that's on purpose. This method is used to determine if we need to clone the whole particle. - // If we do, then the CloneParticle is called and it will try to clone only - // those elements which need cloning - and those are the ones matching this condition. - if (elem != null && (!elem.RefName.IsEmpty || !elem.SchemaTypeName.IsEmpty || - GetResolvedElementForm(parentSchema, elem) == XmlSchemaForm.Qualified)) - { - foundRef = true; - } - else - { - foundRef = HasParticleRef(p, parentSchema); - } - } - } - return foundRef; - } - else if (particle is XmlSchemaGroupRef) - { - return true; - } - return false; - } - - internal static bool HasAttributeQNameRef(XmlSchemaObjectCollection attributes) - { - for (int i = 0; i < attributes.Count; ++i) - { - if (attributes[i] is XmlSchemaAttributeGroupRef) - { - return true; - } - else - { - XmlSchemaAttribute attribute = attributes[i] as XmlSchemaAttribute; - if (!attribute.RefName.IsEmpty || !attribute.SchemaTypeName.IsEmpty) - { - return true; - } - } - } - return false; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContent.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContent.cs deleted file mode 100644 index b9ba5d50dfb..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContent.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaContent : XmlSchemaAnnotated - { - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentModel.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentModel.cs deleted file mode 100644 index 790e2d21dbd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaContentModel : XmlSchemaAnnotated - { - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public abstract XmlSchemaContent Content { get; set; } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentProcessing.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentProcessing.cs deleted file mode 100644 index 6bab74fb497..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentProcessing.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public enum XmlSchemaContentProcessing - { - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - None, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("skip")] - Skip, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("lax")] - Lax, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("strict")] - Strict - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentType.cs deleted file mode 100644 index 4ccca5b7b72..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaContentType.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - /// - public enum XmlSchemaContentType - { - /// - TextOnly, - /// - Empty, - /// - ElementOnly, - /// - Mixed - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDatatype.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDatatype.cs deleted file mode 100644 index 4f7d0b385e4..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDatatype.cs +++ /dev/null @@ -1,458 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.Diagnostics; -using System.ComponentModel; -using Microsoft.Xml; -using System.IO; -using System.Globalization; -using System.Text; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaDatatype - { - /// - /// - /// [To be supplied.] - /// - public abstract Type ValueType { get; } - - /// - /// - /// [To be supplied.] - /// - public abstract XmlTokenizedType TokenizedType { get; } - - /// - /// - /// [To be supplied.] - /// - public abstract object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr); - - /// - /// - /// [To be supplied.] - /// - public virtual XmlSchemaDatatypeVariety Variety { get { return XmlSchemaDatatypeVariety.Atomic; } } - - - /// - /// - /// [To be supplied.] - /// - public virtual object ChangeType(object value, Type targetType) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - if (targetType == null) - { - throw new ArgumentNullException("targetType"); - } - return ValueConverter.ChangeType(value, targetType); - } - - /// - /// - /// [To be supplied.] - /// - public virtual object ChangeType(object value, Type targetType, IXmlNamespaceResolver namespaceResolver) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - if (targetType == null) - { - throw new ArgumentNullException("targetType"); - } - if (namespaceResolver == null) - { - throw new ArgumentNullException("namespaceResolver"); - } - return ValueConverter.ChangeType(value, targetType, namespaceResolver); - } - - /// - /// - /// [To be supplied.] - /// - public virtual XmlTypeCode TypeCode { get { return XmlTypeCode.None; } } - - /// - /// - /// [To be supplied.] - /// - public virtual bool IsDerivedFrom(XmlSchemaDatatype datatype) - { - return false; - } - - internal abstract bool HasLexicalFacets { get; } - - internal abstract bool HasValueFacets { get; } - - internal abstract XmlValueConverter ValueConverter { get; } - - internal abstract RestrictionFacets Restriction { get; set; } - - internal abstract int Compare(object value1, object value2); - - internal abstract object ParseValue(string s, Type typDest, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr); - - internal abstract object ParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, bool createAtomicValue); - - internal abstract Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue); - - internal abstract Exception TryParseValue(object value, XmlNameTable nameTable, IXmlNamespaceResolver namespaceResolver, out object typedValue); - - internal abstract FacetsChecker FacetsChecker { get; } - - internal abstract XmlSchemaWhiteSpace BuiltInWhitespaceFacet { get; } - - internal abstract XmlSchemaDatatype DeriveByRestriction(XmlSchemaObjectCollection facets, XmlNameTable nameTable, XmlSchemaType schemaType); - - internal abstract XmlSchemaDatatype DeriveByList(XmlSchemaType schemaType); - - internal abstract void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller); - - internal abstract bool IsEqual(object o1, object o2); - - internal abstract bool IsComparable(XmlSchemaDatatype dtype); - - //Error message helper - internal string TypeCodeString - { - get - { - string typeCodeString = string.Empty; - XmlTypeCode typeCode = this.TypeCode; - switch (this.Variety) - { - case XmlSchemaDatatypeVariety.List: - if (typeCode == XmlTypeCode.AnyAtomicType) - { //List of union - typeCodeString = "List of Union"; - } - else - { - typeCodeString = "List of " + TypeCodeToString(typeCode); - } - break; - - case XmlSchemaDatatypeVariety.Union: - typeCodeString = "Union"; - break; - - case XmlSchemaDatatypeVariety.Atomic: - if (typeCode == XmlTypeCode.AnyAtomicType) - { - typeCodeString = "anySimpleType"; - } - else - { - typeCodeString = TypeCodeToString(typeCode); - } - break; - } - return typeCodeString; - } - } - - internal string TypeCodeToString(XmlTypeCode typeCode) - { - switch (typeCode) - { - case XmlTypeCode.None: - return "None"; - case XmlTypeCode.Item: - return "AnyType"; - case XmlTypeCode.AnyAtomicType: - return "AnyAtomicType"; - case XmlTypeCode.String: - return "String"; - case XmlTypeCode.Boolean: - return "Boolean"; - case XmlTypeCode.Decimal: - return "Decimal"; - case XmlTypeCode.Float: - return "Float"; - case XmlTypeCode.Double: - return "Double"; - case XmlTypeCode.Duration: - return "Duration"; - case XmlTypeCode.DateTime: - return "DateTime"; - case XmlTypeCode.Time: - return "Time"; - case XmlTypeCode.Date: - return "Date"; - case XmlTypeCode.GYearMonth: - return "GYearMonth"; - case XmlTypeCode.GYear: - return "GYear"; - case XmlTypeCode.GMonthDay: - return "GMonthDay"; - case XmlTypeCode.GDay: - return "GDay"; - case XmlTypeCode.GMonth: - return "GMonth"; - case XmlTypeCode.HexBinary: - return "HexBinary"; - case XmlTypeCode.Base64Binary: - return "Base64Binary"; - case XmlTypeCode.AnyUri: - return "AnyUri"; - case XmlTypeCode.QName: - return "QName"; - case XmlTypeCode.Notation: - return "Notation"; - case XmlTypeCode.NormalizedString: - return "NormalizedString"; - case XmlTypeCode.Token: - return "Token"; - case XmlTypeCode.Language: - return "Language"; - case XmlTypeCode.NmToken: - return "NmToken"; - case XmlTypeCode.Name: - return "Name"; - case XmlTypeCode.NCName: - return "NCName"; - case XmlTypeCode.Id: - return "Id"; - case XmlTypeCode.Idref: - return "Idref"; - case XmlTypeCode.Entity: - return "Entity"; - case XmlTypeCode.Integer: - return "Integer"; - case XmlTypeCode.NonPositiveInteger: - return "NonPositiveInteger"; - case XmlTypeCode.NegativeInteger: - return "NegativeInteger"; - case XmlTypeCode.Long: - return "Long"; - case XmlTypeCode.Int: - return "Int"; - case XmlTypeCode.Short: - return "Short"; - case XmlTypeCode.Byte: - return "Byte"; - case XmlTypeCode.NonNegativeInteger: - return "NonNegativeInteger"; - case XmlTypeCode.UnsignedLong: - return "UnsignedLong"; - case XmlTypeCode.UnsignedInt: - return "UnsignedInt"; - case XmlTypeCode.UnsignedShort: - return "UnsignedShort"; - case XmlTypeCode.UnsignedByte: - return "UnsignedByte"; - case XmlTypeCode.PositiveInteger: - return "PositiveInteger"; - - default: - return typeCode.ToString(); - } - } - - internal static string ConcatenatedToString(object value) - { - Type t = value.GetType(); - string stringValue = string.Empty; - if (t == typeof(IEnumerable) && t != typeof(System.String)) - { - StringBuilder bldr = new StringBuilder(); - IEnumerator enumerator = (value as IEnumerable).GetEnumerator(); - if (enumerator.MoveNext()) - { - bldr.Append("{"); - Object cur = enumerator.Current; - if (cur is IFormattable) - { - bldr.Append(((IFormattable)cur).ToString("", CultureInfo.InvariantCulture)); - } - else - { - bldr.Append(cur.ToString()); - } - while (enumerator.MoveNext()) - { - bldr.Append(" , "); - cur = enumerator.Current; - if (cur is IFormattable) - { - bldr.Append(((IFormattable)cur).ToString("", CultureInfo.InvariantCulture)); - } - else - { - bldr.Append(cur.ToString()); - } - } - bldr.Append("}"); - stringValue = bldr.ToString(); - } - } - else if (value is IFormattable) - { - stringValue = ((IFormattable)value).ToString("", CultureInfo.InvariantCulture); - } - else - { - stringValue = value.ToString(); - } - return stringValue; - } - - internal static XmlSchemaDatatype FromXmlTokenizedType(XmlTokenizedType token) - { - return DatatypeImplementation.FromXmlTokenizedType(token); - } - - internal static XmlSchemaDatatype FromXmlTokenizedTypeXsd(XmlTokenizedType token) - { - return DatatypeImplementation.FromXmlTokenizedTypeXsd(token); - } - - internal static XmlSchemaDatatype FromXdrName(string name) - { - return DatatypeImplementation.FromXdrName(name); - } - - internal static XmlSchemaDatatype DeriveByUnion(XmlSchemaSimpleType[] types, XmlSchemaType schemaType) - { - return DatatypeImplementation.DeriveByUnion(types, schemaType); - } - - internal static string XdrCanonizeUri(string uri, XmlNameTable nameTable, SchemaNames schemaNames) - { - string canonicalUri; - int offset = 5; - bool convert = false; - - if (uri.Length > 5 && uri.StartsWith("uuid:", StringComparison.Ordinal)) - { - convert = true; - } - else if (uri.Length > 9 && uri.StartsWith("urn:uuid:", StringComparison.Ordinal)) - { - convert = true; - offset = 9; - } - - if (convert) - { - canonicalUri = nameTable.Add(uri.Substring(0, offset) + uri.Substring(offset, uri.Length - offset).ToUpperInvariant()); - } - else - { - canonicalUri = uri; - } - - if ( - Ref.Equal(schemaNames.NsDataTypeAlias, canonicalUri) || - Ref.Equal(schemaNames.NsDataTypeOld, canonicalUri) - ) - { - canonicalUri = schemaNames.NsDataType; - } - else if (Ref.Equal(schemaNames.NsXdrAlias, canonicalUri)) - { - canonicalUri = schemaNames.NsXdr; - } - - return canonicalUri; - } - -#if PRIYAL - private bool CanConvert(object value, System.Type inputType, System.Type defaultType, out string resId) { - resId = null; - decimal decimalValue; - //TypeCode defaultTypeCode = Type.GetTypeCode(defaultType); - if (IsIntegralType(this.TypeCode)){ - switch (Type.GetTypeCode(inputType)) { - case System.TypeCode.Single: - case System.TypeCode.Double: - decimalValue = new Decimal((double)value); - goto case System.TypeCode.Decimal; - case System.TypeCode.Decimal: - decimalValue = (decimal)value; - if (decimal.Truncate(decimalValue) != decimalValue) { //HasFractionDigits - resId = Res.Sch_XmlTypeHasFraction; - return false; - } - break; - - default: - return true; - } - } - else if (this.TypeCode == XmlTypeCode.Boolean) { - if (IsNumericType(inputType)) { - decimalValue = (decimal)value; - if (decimalValue == 0 || decimalValue == 1) { - return true; - } - resId = Res.Sch_InvalidBoolean; - return false; - } - } - return true; - } - - private bool IsIntegralType(XmlTypeCode defaultTypeCode) { - switch (defaultTypeCode) { - case XmlTypeCode.Integer: - case XmlTypeCode.NegativeInteger: - case XmlTypeCode.NonNegativeInteger: - case XmlTypeCode.NonPositiveInteger: - case XmlTypeCode.PositiveInteger: - case XmlTypeCode.Long: - case XmlTypeCode.Int: - case XmlTypeCode.Short: - case XmlTypeCode.Byte: - case XmlTypeCode.UnsignedLong: - case XmlTypeCode.UnsignedInt: - case XmlTypeCode.UnsignedShort: - case XmlTypeCode.UnsignedByte: - return true; - default: - return false; - } - } - - private bool IsNumericType(System.Type inputType) { - switch (Type.GetTypeCode(inputType)) { - case System.TypeCode.Decimal: - case System.TypeCode.Double: - case System.TypeCode.Single: - case System.TypeCode.SByte: - case System.TypeCode.Byte: - case System.TypeCode.Int16: - case System.TypeCode.Int32: - case System.TypeCode.Int64: - case System.TypeCode.UInt16: - case System.TypeCode.UInt32: - case System.TypeCode.UInt64: - return true; - default: - return false; - } - } -#endif - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDerivationMethod.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDerivationMethod.cs deleted file mode 100644 index 9df5febb530..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDerivationMethod.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - [Flags] - public enum XmlSchemaDerivationMethod - { - /// - /// - /// [To be supplied.] - /// - [XmlEnum("")] - Empty = 0, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("substitution")] - Substitution = 0x0001, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("extension")] - Extension = 0x0002, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("restriction")] - Restriction = 0x0004, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("list")] - List = 0x0008, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("union")] - Union = 0x0010, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("#all")] - All = 0x00FF, - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - None = 0x0100 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDocumentation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDocumentation.cs deleted file mode 100644 index aeb24eed642..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaDocumentation.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaDocumentation : XmlSchemaObject - { - private string _source; - private string _language; - private XmlNode[] _markup; - private static XmlSchemaSimpleType s_languageType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName("language", XmlReservedNs.NsXs)); - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("source", DataType = "anyURI")] - public string Source - { - get { return _source; } - set { _source = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("xml:lang")] - public string Language - { - get { return _language; } - set { _language = (string)s_languageType.Datatype.ParseValue(value, (XmlNameTable)null, (IXmlNamespaceResolver)null); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlText(), XmlAnyElement] - public XmlNode[] Markup - { - get { return _markup; } - set { _markup = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaElement.cs deleted file mode 100644 index bb707fe0673..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaElement.cs +++ /dev/null @@ -1,386 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.ComponentModel; -using Microsoft.Xml.Serialization; -using System.Diagnostics; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaElement : XmlSchemaParticle - { - private bool _isAbstract; - private bool _hasAbstractAttribute; - private bool _isNillable; - private bool _hasNillableAttribute; - private bool _isLocalTypeDerivationChecked; - - private XmlSchemaDerivationMethod _block = XmlSchemaDerivationMethod.None; - private XmlSchemaDerivationMethod _final = XmlSchemaDerivationMethod.None; - private XmlSchemaForm _form = XmlSchemaForm.None; - private string _defaultValue; - private string _fixedValue; - private string _name; - - private XmlQualifiedName _refName = XmlQualifiedName.Empty; - private XmlQualifiedName _substitutionGroup = XmlQualifiedName.Empty; - private XmlQualifiedName _typeName = XmlQualifiedName.Empty; - private XmlSchemaType _type = null; - - private XmlQualifiedName _qualifiedName = XmlQualifiedName.Empty; - private XmlSchemaType _elementType; - private XmlSchemaDerivationMethod _blockResolved; - private XmlSchemaDerivationMethod _finalResolved; - private XmlSchemaObjectCollection _constraints; - private SchemaElementDecl _elementDecl; - - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("abstract"), DefaultValue(false)] - public bool IsAbstract - { - get { return _isAbstract; } - set - { - _isAbstract = value; - _hasAbstractAttribute = true; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("block"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod Block - { - get { return _block; } - set { _block = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("default")] - [DefaultValue(null)] - public string DefaultValue - { - get { return _defaultValue; } - set { _defaultValue = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("final"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod Final - { - get { return _final; } - set { _final = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("fixed")] - [DefaultValue(null)] - public string FixedValue - { - get { return _fixedValue; } - set { _fixedValue = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("form"), DefaultValue(XmlSchemaForm.None)] - public XmlSchemaForm Form - { - get { return _form; } - set { _form = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name"), DefaultValue("")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("nillable"), DefaultValue(false)] - public bool IsNillable - { - get { return _isNillable; } - set { _isNillable = value; _hasNillableAttribute = true; } - } - - [XmlIgnore] - internal bool HasNillableAttribute - { - get { return _hasNillableAttribute; } - } - - [XmlIgnore] - internal bool HasAbstractAttribute - { - get { return _hasAbstractAttribute; } - } - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("ref")] - public XmlQualifiedName RefName - { - get { return _refName; } - set { _refName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("substitutionGroup")] - public XmlQualifiedName SubstitutionGroup - { - get { return _substitutionGroup; } - set { _substitutionGroup = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("type")] - public XmlQualifiedName SchemaTypeName - { - get { return _typeName; } - set { _typeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("complexType", typeof(XmlSchemaComplexType)), - XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaType SchemaType - { - get { return _type; } - set { _type = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("key", typeof(XmlSchemaKey)), - XmlElement("keyref", typeof(XmlSchemaKeyref)), - XmlElement("unique", typeof(XmlSchemaUnique))] - public XmlSchemaObjectCollection Constraints - { - get - { - if (_constraints == null) - { - _constraints = new XmlSchemaObjectCollection(); - } - return _constraints; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qualifiedName; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - [Obsolete("This property has been deprecated. Please use ElementSchemaType property that returns a strongly typed element type. http://go.microsoft.com/fwlink/?linkid=14202")] - public object ElementType - { - get - { - if (_elementType == null) - return null; - - if (_elementType.QualifiedName.Namespace == XmlReservedNs.NsXs) - { - return _elementType.Datatype; //returns XmlSchemaDatatype; - } - return _elementType; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaType ElementSchemaType - { - get { return _elementType; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDerivationMethod BlockResolved - { - get { return _blockResolved; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDerivationMethod FinalResolved - { - get { return _finalResolved; } - } - - internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler) - { - if (schemaSet != null) - { - XmlReaderSettings readerSettings = new XmlReaderSettings(); - readerSettings.ValidationType = ValidationType.Schema; - readerSettings.Schemas = schemaSet; - readerSettings.ValidationEventHandler += valEventHandler; - return new XsdValidatingReader(reader, resolver, readerSettings, this); - } - return null; - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qualifiedName = value; - } - - internal void SetElementType(XmlSchemaType value) - { - _elementType = value; - } - - internal void SetBlockResolved(XmlSchemaDerivationMethod value) - { - _blockResolved = value; - } - - internal void SetFinalResolved(XmlSchemaDerivationMethod value) - { - _finalResolved = value; - } - - [XmlIgnore] - internal bool HasDefault - { - get { return _defaultValue != null && _defaultValue.Length > 0; } - } - - internal bool HasConstraints - { - get { return _constraints != null && _constraints.Count > 0; } - } - - internal bool IsLocalTypeDerivationChecked - { - get - { - return _isLocalTypeDerivationChecked; - } - set - { - _isLocalTypeDerivationChecked = value; - } - } - - internal SchemaElementDecl ElementDecl - { - get { return _elementDecl; } - set { _elementDecl = value; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - - [XmlIgnore] - internal override string NameString - { - get - { - return _qualifiedName.ToString(); - } - } - - internal override XmlSchemaObject Clone() - { - System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaElement. Call Clone(XmlSchema) instead."); - return Clone(null); - } - - internal XmlSchemaObject Clone(XmlSchema parentSchema) - { - XmlSchemaElement newElem = (XmlSchemaElement)MemberwiseClone(); - - //Deep clone the QNames as these will be updated on chameleon includes - newElem._refName = _refName.Clone(); - newElem._substitutionGroup = _substitutionGroup.Clone(); - newElem._typeName = _typeName.Clone(); - newElem._qualifiedName = _qualifiedName.Clone(); - // If this element has a complex type which is anonymous (declared in place with the element) - // it needs to be cloned as well, since it may contain named elements and such. And these names - // will need to be cloned since they may change their namespace on chameleon includes - XmlSchemaComplexType complexType = _type as XmlSchemaComplexType; - if (complexType != null && complexType.QualifiedName.IsEmpty) - { - newElem._type = (XmlSchemaType)complexType.Clone(parentSchema); - } - - //Clear compiled tables - newElem._constraints = null; - return newElem; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaException.cs deleted file mode 100644 index 83f6ffebab9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaException.cs +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.IO; - using System.Text; - using System.Resources; - using System.Globalization; - using System.Diagnostics; - // using System.Security.Permissions; - - /// - // [Serializable], - public class XmlSchemaException : System.Exception - { - private string _res; - private string[] _args; - private string _sourceUri; - private int _lineNumber; - private int _linePosition; - - [NonSerialized] - private XmlSchemaObject _sourceSchemaObject; - - // message != null for V1 exceptions deserialized in Whidbey - // message == null for V2 or higher exceptions; the exception message is stored on the base class (Exception._message) - private string _message = null; - - /// - public XmlSchemaException() : this(null) - { - } - - /// - public XmlSchemaException(String message) : this(message, ((Exception)null), 0, 0) - { -#if DEBUG - Debug.Assert(message == null || !message.StartsWith("Sch_", StringComparison.Ordinal), "Do not pass a resource here!"); -#endif - } - - /// - public XmlSchemaException(String message, Exception innerException) : this(message, innerException, 0, 0) - { - } - - /// - public XmlSchemaException(String message, Exception innerException, int lineNumber, int linePosition) : - this((message == null ? ResXml.Sch_DefaultException : ResXml.Xml_UserException), new string[] { message }, innerException, null, lineNumber, linePosition, null) - { - } - - internal XmlSchemaException(string res, string[] args) : - this(res, args, null, null, 0, 0, null) - { } - - internal XmlSchemaException(string res, string arg) : - this(res, new string[] { arg }, null, null, 0, 0, null) - { } - - internal XmlSchemaException(string res, string arg, string sourceUri, int lineNumber, int linePosition) : - this(res, new string[] { arg }, null, sourceUri, lineNumber, linePosition, null) - { } - - internal XmlSchemaException(string res, string sourceUri, int lineNumber, int linePosition) : - this(res, (string[])null, null, sourceUri, lineNumber, linePosition, null) - { } - - internal XmlSchemaException(string res, string[] args, string sourceUri, int lineNumber, int linePosition) : - this(res, args, null, sourceUri, lineNumber, linePosition, null) - { } - - internal XmlSchemaException(string res, XmlSchemaObject source) : - this(res, (string[])null, source) - { } - - internal XmlSchemaException(string res, string arg, XmlSchemaObject source) : - this(res, new string[] { arg }, source) - { } - - internal XmlSchemaException(string res, string[] args, XmlSchemaObject source) : - this(res, args, null, source.SourceUri, source.LineNumber, source.LinePosition, source) - { } - - internal XmlSchemaException(string res, string[] args, Exception innerException, string sourceUri, int lineNumber, int linePosition, XmlSchemaObject source) : - base(CreateMessage(res, args), innerException) - { - HResult = HResults.XmlSchema; - _res = res; - _args = args; - _sourceUri = sourceUri; - _lineNumber = lineNumber; - _linePosition = linePosition; - _sourceSchemaObject = source; - } - - internal static string CreateMessage(string res, string[] args) - { - if (args == null) - { - return res; - } - - try - { - return string.Format(res, args); - } - catch (MissingManifestResourceException) - { - return "UNKNOWN(" + res + ")"; - } - } - - internal string GetRes - { - get - { - return _res; - } - } - - internal string[] Args - { - get - { - return _args; - } - } - /// - public string SourceUri - { - get { return _sourceUri; } - } - - /// - public int LineNumber - { - get { return _lineNumber; } - } - - /// - public int LinePosition - { - get { return _linePosition; } - } - - /// - public XmlSchemaObject SourceSchemaObject - { - get { return _sourceSchemaObject; } - } - - /*internal static XmlSchemaException Create(string res) { //Since internal overload with res string will clash with public constructor that takes in a message - return new XmlSchemaException(res, (string[])null, null, null, 0, 0, null); - }*/ - - internal void SetSource(string sourceUri, int lineNumber, int linePosition) - { - _sourceUri = sourceUri; - _lineNumber = lineNumber; - _linePosition = linePosition; - } - - internal void SetSchemaObject(XmlSchemaObject source) - { - _sourceSchemaObject = source; - } - - internal void SetSource(XmlSchemaObject source) - { - _sourceSchemaObject = source; - _sourceUri = source.SourceUri; - _lineNumber = source.LineNumber; - _linePosition = source.LinePosition; - } - - internal void SetResourceId(string resourceId) - { - _res = resourceId; - } - - public override string Message - { - get - { - return (_message == null) ? base.Message : _message; - } - } - }; -} // namespace Microsoft.Xml.Schema - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaExternal.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaExternal.cs deleted file mode 100644 index 15463b1fc50..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaExternal.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - public abstract class XmlSchemaExternal : XmlSchemaObject - { - private string _location; - private Uri _baseUri; - private XmlSchema _schema; - private string _id; - private XmlAttribute[] _moreAttributes; - private Compositor _compositor; - - /// - [XmlAttribute("schemaLocation", DataType = "anyURI")] - public string SchemaLocation - { - get { return _location; } - set { _location = value; } - } - - /// - [XmlIgnore] - public XmlSchema Schema - { - get { return _schema; } - set { _schema = value; } - } - - /// - [XmlAttribute("id", DataType = "ID")] - public string Id - { - get { return _id; } - set { _id = value; } - } - - /// - [XmlAnyAttribute] - public XmlAttribute[] UnhandledAttributes - { - get { return _moreAttributes; } - set { _moreAttributes = value; } - } - - [XmlIgnore] - internal Uri BaseUri - { - get { return _baseUri; } - set { _baseUri = value; } - } - - [XmlIgnore] - internal override string IdAttribute - { - get { return Id; } - set { Id = value; } - } - - internal override void SetUnhandledAttributes(XmlAttribute[] moreAttributes) - { - _moreAttributes = moreAttributes; - } - - internal Compositor Compositor - { - get - { - return _compositor; - } - set - { - _compositor = value; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaFacet.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaFacet.cs deleted file mode 100644 index eb46fed019c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaFacet.cs +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - internal enum FacetType - { - None, - Length, - MinLength, - MaxLength, - Pattern, - Whitespace, - Enumeration, - MinExclusive, - MinInclusive, - MaxExclusive, - MaxInclusive, - TotalDigits, - FractionDigits, - } - - /// - public abstract class XmlSchemaFacet : XmlSchemaAnnotated - { - private string _value; - private bool _isFixed; - private FacetType _facetType; - - /// - [XmlAttribute("value")] - public string Value - { - get { return _value; } - set { _value = value; } - } - - /// - [XmlAttribute("fixed"), DefaultValue(false)] - public virtual bool IsFixed - { - get { return _isFixed; } - set - { - if (!(this is XmlSchemaEnumerationFacet) && !(this is XmlSchemaPatternFacet)) - { - _isFixed = value; - } - } - } - - internal FacetType FacetType - { - get - { - return _facetType; - } - set - { - _facetType = value; - } - } - } - - /// - public abstract class XmlSchemaNumericFacet : XmlSchemaFacet { } - - /// - public class XmlSchemaLengthFacet : XmlSchemaNumericFacet - { - public XmlSchemaLengthFacet() - { - FacetType = FacetType.Length; - } - } - - /// - public class XmlSchemaMinLengthFacet : XmlSchemaNumericFacet - { - public XmlSchemaMinLengthFacet() - { - FacetType = FacetType.MinLength; - } - } - - /// - public class XmlSchemaMaxLengthFacet : XmlSchemaNumericFacet - { - public XmlSchemaMaxLengthFacet() - { - FacetType = FacetType.MaxLength; - } - } - - /// - public class XmlSchemaPatternFacet : XmlSchemaFacet - { - public XmlSchemaPatternFacet() - { - FacetType = FacetType.Pattern; - } - } - - /// - public class XmlSchemaEnumerationFacet : XmlSchemaFacet - { - public XmlSchemaEnumerationFacet() - { - FacetType = FacetType.Enumeration; - } - } - - /// - public class XmlSchemaMinExclusiveFacet : XmlSchemaFacet - { - public XmlSchemaMinExclusiveFacet() - { - FacetType = FacetType.MinExclusive; - } - } - - /// - public class XmlSchemaMinInclusiveFacet : XmlSchemaFacet - { - public XmlSchemaMinInclusiveFacet() - { - FacetType = FacetType.MinInclusive; - } - } - - /// - public class XmlSchemaMaxExclusiveFacet : XmlSchemaFacet - { - public XmlSchemaMaxExclusiveFacet() - { - FacetType = FacetType.MaxExclusive; - } - } - - /// - public class XmlSchemaMaxInclusiveFacet : XmlSchemaFacet - { - public XmlSchemaMaxInclusiveFacet() - { - FacetType = FacetType.MaxInclusive; - } - } - - /// - public class XmlSchemaTotalDigitsFacet : XmlSchemaNumericFacet - { - public XmlSchemaTotalDigitsFacet() - { - FacetType = FacetType.TotalDigits; - } - } - - /// - public class XmlSchemaFractionDigitsFacet : XmlSchemaNumericFacet - { - public XmlSchemaFractionDigitsFacet() - { - FacetType = FacetType.FractionDigits; - } - } - - /// - public class XmlSchemaWhiteSpaceFacet : XmlSchemaFacet - { - public XmlSchemaWhiteSpaceFacet() - { - FacetType = FacetType.Whitespace; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaForm.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaForm.cs deleted file mode 100644 index 52df74b2c4d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaForm.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - // if change the enum, have to change xsdbuilder as well. - /// - /// - /// [To be supplied.] - /// - public enum XmlSchemaForm - { - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - None, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("qualified")] - Qualified, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("unqualified")] - Unqualified, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroup.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroup.cs deleted file mode 100644 index d4e90f03783..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroup.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaGroup : XmlSchemaAnnotated - { - private string _name; - private XmlSchemaGroupBase _particle; - private XmlSchemaParticle _canonicalParticle; - private XmlQualifiedName _qname = XmlQualifiedName.Empty; - private XmlSchemaGroup _redefined; - private int _selfReferenceCount; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("all", typeof(XmlSchemaAll)), - XmlElement("sequence", typeof(XmlSchemaSequence))] - public XmlSchemaGroupBase Particle - { - get { return _particle; } - set { _particle = value; } - } - - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qname; } - } - - [XmlIgnore] - internal XmlSchemaParticle CanonicalParticle - { - get { return _canonicalParticle; } - set { _canonicalParticle = value; } - } - - [XmlIgnore] - internal XmlSchemaGroup Redefined - { - get { return _redefined; } - set { _redefined = value; } - } - - [XmlIgnore] - internal int SelfReferenceCount - { - get { return _selfReferenceCount; } - set { _selfReferenceCount = value; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qname = value; - } - - internal override XmlSchemaObject Clone() - { - System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaGroup. Call Clone(XmlSchema) instead."); - return Clone(null); - } - - internal XmlSchemaObject Clone(XmlSchema parentSchema) - { - XmlSchemaGroup newGroup = (XmlSchemaGroup)MemberwiseClone(); - if (XmlSchemaComplexType.HasParticleRef(_particle, parentSchema)) - { - newGroup._particle = XmlSchemaComplexType.CloneParticle(_particle, parentSchema) as XmlSchemaGroupBase; - } - newGroup._canonicalParticle = XmlSchemaParticle.Empty; - return newGroup; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupRef.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupRef.cs deleted file mode 100644 index 0ade6f88d38..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupRef.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaGroupRef : XmlSchemaParticle - { - private XmlQualifiedName _refName = XmlQualifiedName.Empty; - private XmlSchemaGroupBase _particle; - private XmlSchemaGroup _refined; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("ref")] - public XmlQualifiedName RefName - { - get { return _refName; } - set { _refName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaGroupBase Particle - { - get { return _particle; } - } - - internal void SetParticle(XmlSchemaGroupBase value) - { - _particle = value; - } - - [XmlIgnore] - internal XmlSchemaGroup Redefined - { - get { return _refined; } - set { _refined = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupbase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupbase.cs deleted file mode 100644 index ec7042d81cd..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaGroupbase.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaGroupBase : XmlSchemaParticle - { - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public abstract XmlSchemaObjectCollection Items { get; } - - internal abstract void SetItems(XmlSchemaObjectCollection newItems); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaIdentityConstraint.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaIdentityConstraint.cs deleted file mode 100644 index a75b7273c8d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaIdentityConstraint.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaIdentityConstraint : XmlSchemaAnnotated - { - private string _name; - private XmlSchemaXPath _selector; - private XmlSchemaObjectCollection _fields = new XmlSchemaObjectCollection(); - private XmlQualifiedName _qualifiedName = XmlQualifiedName.Empty; - private CompiledIdentityConstraint _compiledConstraint = null; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("selector", typeof(XmlSchemaXPath))] - public XmlSchemaXPath Selector - { - get { return _selector; } - set { _selector = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("field", typeof(XmlSchemaXPath))] - public XmlSchemaObjectCollection Fields - { - get { return _fields; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qualifiedName; } - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qualifiedName = value; - } - - [XmlIgnore] - internal CompiledIdentityConstraint CompiledConstraint - { - get { return _compiledConstraint; } - set { _compiledConstraint = value; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaXPath : XmlSchemaAnnotated - { - private string _xpath; - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("xpath"), DefaultValue("")] - public string XPath - { - get { return _xpath; } - set { _xpath = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaUnique : XmlSchemaIdentityConstraint - { - } - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaKey : XmlSchemaIdentityConstraint - { - } - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaKeyref : XmlSchemaIdentityConstraint - { - private XmlQualifiedName _refer = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("refer")] - public XmlQualifiedName Refer - { - get { return _refer; } - set { _refer = (value == null ? XmlQualifiedName.Empty : value); } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaImport.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaImport.cs deleted file mode 100644 index 55261fc2998..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaImport.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaImport : XmlSchemaExternal - { - private string _ns; - private XmlSchemaAnnotation _annotation; - - /// - public XmlSchemaImport() - { - Compositor = Compositor.Import; - } - - /// - [XmlAttribute("namespace", DataType = "anyURI")] - public string Namespace - { - get { return _ns; } - set { _ns = value; } - } - - /// - [XmlElement("annotation", typeof(XmlSchemaAnnotation))] - public XmlSchemaAnnotation Annotation - { - get { return _annotation; } - set { _annotation = value; } - } - - internal override void AddAnnotation(XmlSchemaAnnotation annotation) - { - _annotation = annotation; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInclude.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInclude.cs deleted file mode 100644 index 1b4cfe99cec..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInclude.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaInclude : XmlSchemaExternal - { - private XmlSchemaAnnotation _annotation; - - /// - public XmlSchemaInclude() - { - Compositor = Compositor.Include; - } - /// - [XmlElement("annotation", typeof(XmlSchemaAnnotation))] - public XmlSchemaAnnotation Annotation - { - get { return _annotation; } - set { _annotation = value; } - } - - internal override void AddAnnotation(XmlSchemaAnnotation annotation) - { - _annotation = annotation; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInfo.cs deleted file mode 100644 index fa16595e9b5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaInfo.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xml; -using System.Collections; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - public class XmlSchemaInfo : IXmlSchemaInfo - { - private bool _isDefault; - private bool _isNil; - private XmlSchemaElement _schemaElement; - private XmlSchemaAttribute _schemaAttribute; - private XmlSchemaType _schemaType; - private XmlSchemaSimpleType _memberType; - private XmlSchemaValidity _validity; - private XmlSchemaContentType _contentType; - - public XmlSchemaInfo() - { - Clear(); - } - - internal XmlSchemaInfo(XmlSchemaValidity validity) : this() - { - _validity = validity; - } - - public XmlSchemaValidity Validity - { - get - { - return _validity; - } - set - { - _validity = value; - } - } - - public bool IsDefault - { - get - { - return _isDefault; - } - set - { - _isDefault = value; - } - } - - public bool IsNil - { - get - { - return _isNil; - } - set - { - _isNil = value; - } - } - - public XmlSchemaSimpleType MemberType - { - get - { - return _memberType; - } - set - { - _memberType = value; - } - } - - public XmlSchemaType SchemaType - { - get - { - return _schemaType; - } - set - { - _schemaType = value; - if (_schemaType != null) - { //Member type will not change its content type - _contentType = _schemaType.SchemaContentType; - } - else - { - _contentType = XmlSchemaContentType.Empty; - } - } - } - - public XmlSchemaElement SchemaElement - { - get - { - return _schemaElement; - } - set - { - _schemaElement = value; - if (value != null) - { //Setting non-null SchemaElement means SchemaAttribute should be null - _schemaAttribute = null; - } - } - } - - public XmlSchemaAttribute SchemaAttribute - { - get - { - return _schemaAttribute; - } - set - { - _schemaAttribute = value; - if (value != null) - { //Setting non-null SchemaAttribute means SchemaElement should be null - _schemaElement = null; - } - } - } - - public XmlSchemaContentType ContentType - { - get - { - return _contentType; - } - set - { - _contentType = value; - } - } - - internal XmlSchemaType XmlType - { - get - { - if (_memberType != null) - { - return _memberType; - } - return _schemaType; - } - } - - internal bool HasDefaultValue - { - get - { - return _schemaElement != null && _schemaElement.ElementDecl.DefaultValueTyped != null; - } - } - - internal bool IsUnionType - { - get - { - if (_schemaType == null || _schemaType.Datatype == null) - { - return false; - } - return _schemaType.Datatype.Variety == XmlSchemaDatatypeVariety.Union; - } - } - - internal void Clear() - { - _isNil = false; - _isDefault = false; - _schemaType = null; - _schemaElement = null; - _schemaAttribute = null; - _memberType = null; - _validity = XmlSchemaValidity.NotKnown; - _contentType = XmlSchemaContentType.Empty; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaNotation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaNotation.cs deleted file mode 100644 index 0630f76b2b6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaNotation.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaNotation : XmlSchemaAnnotated - { - private string _name; - private string _publicId; - private string _systemId; - private XmlQualifiedName _qname = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("public")] - public string Public - { - get { return _publicId; } - set { _publicId = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("system")] - public string System - { - get { return _systemId; } - set { _systemId = value; } - } - - [XmlIgnore] - internal XmlQualifiedName QualifiedName - { - get { return _qname; } - set { _qname = value; } - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObject.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObject.cs deleted file mode 100644 index d72bdd7f664..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObject.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - using System.Diagnostics; - using Microsoft.Xml.Serialization; - // using System.Security.Permissions; - - /// - /// - /// [To be supplied.] - /// - // [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")] - public abstract class XmlSchemaObject - { - private int _lineNum = 0; - private int _linePos = 0; - private string _sourceUri; - private XmlSerializerNamespaces _namespaces; - private XmlSchemaObject _parent; - - //internal - private bool _isProcessing; //Indicates whether this object is currently being processed - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public int LineNumber - { - get { return _lineNum; } - set { _lineNum = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public int LinePosition - { - get { return _linePos; } - set { _linePos = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public string SourceUri - { - get { return _sourceUri; } - set { _sourceUri = value; } - } - - /// - [XmlIgnore] - public XmlSchemaObject Parent - { - get { return _parent; } - set { _parent = value; } - } - - /// - [XmlNamespaceDeclarations] - public XmlSerializerNamespaces Namespaces - { - get - { - if (_namespaces == null) - _namespaces = new XmlSerializerNamespaces(); - return _namespaces; - } - set { _namespaces = value; } - } - - internal virtual void OnAdd(XmlSchemaObjectCollection container, object item) { } - internal virtual void OnRemove(XmlSchemaObjectCollection container, object item) { } - internal virtual void OnClear(XmlSchemaObjectCollection container) { } - - [XmlIgnore] - internal virtual string IdAttribute - { - get { Debug.Assert(false); return null; } - set { Debug.Assert(false); } - } - - internal virtual void SetUnhandledAttributes(XmlAttribute[] moreAttributes) { } - internal virtual void AddAnnotation(XmlSchemaAnnotation annotation) { } - - [XmlIgnore] - internal virtual string NameAttribute - { - get { Debug.Assert(false); return null; } - set { Debug.Assert(false); } - } - - [XmlIgnore] - internal bool IsProcessing - { - get - { - return _isProcessing; - } - set - { - _isProcessing = value; - } - } - - internal virtual XmlSchemaObject Clone() - { - return (XmlSchemaObject)MemberwiseClone(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectCollection.cs deleted file mode 100644 index d907859e852..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectCollection.cs +++ /dev/null @@ -1,236 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.ComponentModel; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaObjectCollection : CollectionBase - { - private XmlSchemaObject _parent; - - /// - /// - /// [To be supplied.] - /// - public XmlSchemaObjectCollection() - { - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchemaObjectCollection(XmlSchemaObject parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public virtual XmlSchemaObject this[int index] - { - get { return (XmlSchemaObject)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public new XmlSchemaObjectEnumerator GetEnumerator() - { - return new XmlSchemaObjectEnumerator(InnerList.GetEnumerator()); - } - - /// - /// - /// [To be supplied.] - /// - public int Add(XmlSchemaObject item) - { - return List.Add(item); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, XmlSchemaObject item) - { - List.Insert(index, item); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(XmlSchemaObject item) - { - return List.IndexOf(item); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(XmlSchemaObject item) - { - return List.Contains(item); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(XmlSchemaObject item) - { - List.Remove(item); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(XmlSchemaObject[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnInsert(int index, object item) - { - if (_parent != null) - { - _parent.OnAdd(this, item); - } - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnSet(int index, object oldValue, object newValue) - { - if (_parent != null) - { - _parent.OnRemove(this, oldValue); - _parent.OnAdd(this, newValue); - } - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnClear() - { - if (_parent != null) - { - _parent.OnClear(this); - } - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnRemove(int index, object item) - { - if (_parent != null) - { - _parent.OnRemove(this, item); - } - } - - internal XmlSchemaObjectCollection Clone() - { - XmlSchemaObjectCollection coll = new XmlSchemaObjectCollection(); - coll.Add(this); - return coll; - } - - private void Add(XmlSchemaObjectCollection collToAdd) - { - this.InnerList.InsertRange(0, collToAdd); - } - } - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaObjectEnumerator : IEnumerator - { - private IEnumerator _enumerator; - - internal XmlSchemaObjectEnumerator(IEnumerator enumerator) - { - _enumerator = enumerator; - } - - /// - /// - /// [To be supplied.] - /// - public void Reset() - { - _enumerator.Reset(); - } - - /// - /// - /// [To be supplied.] - /// - public bool MoveNext() - { - return _enumerator.MoveNext(); - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchemaObject Current - { - get { return (XmlSchemaObject)_enumerator.Current; } - } - - /// - /// - void IEnumerator.Reset() - { - _enumerator.Reset(); - } - - /// - /// - bool IEnumerator.MoveNext() - { - return _enumerator.MoveNext(); - } - - /// - /// - object IEnumerator.Current - { - get { return _enumerator.Current; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectTable.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectTable.cs deleted file mode 100644 index 29a3ff5916d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaObjectTable.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics; - - /// - public class XmlSchemaObjectTable - { - private Dictionary _table = new Dictionary(); - private List _entries = new List(); - - internal XmlSchemaObjectTable() - { - } - - internal void Add(XmlQualifiedName name, XmlSchemaObject value) - { - Debug.Assert(!_table.ContainsKey(name), "XmlSchemaObjectTable.Add: entry already exists"); - _table.Add(name, value); - _entries.Add(new XmlSchemaObjectEntry(name, value)); - } - - internal void Insert(XmlQualifiedName name, XmlSchemaObject value) - { - XmlSchemaObject oldValue = null; - if (_table.TryGetValue(name, out oldValue)) - { - _table[name] = value; //set new value - Debug.Assert(oldValue != null); - int matchedIndex = FindIndexByValue(oldValue); - Debug.Assert(matchedIndex >= 0); - //set new entry - Debug.Assert(_entries[matchedIndex].qname == name); - _entries[matchedIndex] = new XmlSchemaObjectEntry(name, value); - } - else - { - Add(name, value); - } - } - - internal void Replace(XmlQualifiedName name, XmlSchemaObject value) - { - XmlSchemaObject oldValue; - if (_table.TryGetValue(name, out oldValue)) - { - _table[name] = value; //set new value - Debug.Assert(oldValue != null); - int matchedIndex = FindIndexByValue(oldValue); - Debug.Assert(_entries[matchedIndex].qname == name); - _entries[matchedIndex] = new XmlSchemaObjectEntry(name, value); - } - } - - internal void Clear() - { - _table.Clear(); - _entries.Clear(); - } - - internal void Remove(XmlQualifiedName name) - { - XmlSchemaObject value; - if (_table.TryGetValue(name, out value)) - { - _table.Remove(name); - int matchedIndex = FindIndexByValue(value); - Debug.Assert(matchedIndex >= 0); - Debug.Assert(_entries[matchedIndex].qname == name); - _entries.RemoveAt(matchedIndex); - } - } - - private int FindIndexByValue(XmlSchemaObject xso) - { - int index; - for (index = 0; index < _entries.Count; index++) - { - if ((object)_entries[index].xso == (object)xso) - { - return index; - } - } - return -1; - } - /// - public int Count - { - get - { - Debug.Assert(_table.Count == _entries.Count); - return _table.Count; - } - } - - /// - public bool Contains(XmlQualifiedName name) - { - return _table.ContainsKey(name); - } - - /// - public XmlSchemaObject this[XmlQualifiedName name] - { - get - { - XmlSchemaObject value; - if (_table.TryGetValue(name, out value)) - { - return value; - } - return null; - } - } - - /// - public ICollection Names - { - get - { - return new NamesCollection(_entries, _table.Count); - } - } - - /// - public ICollection Values - { - get - { - return new ValuesCollection(_entries, _table.Count); - } - } - - /// - public IDictionaryEnumerator GetEnumerator() - { - return new XSODictionaryEnumerator(_entries, _table.Count, EnumeratorType.DictionaryEntry); - } - - internal enum EnumeratorType - { - Keys, - Values, - DictionaryEntry, - } - - internal struct XmlSchemaObjectEntry - { - internal XmlQualifiedName qname; - internal XmlSchemaObject xso; - - public XmlSchemaObjectEntry(XmlQualifiedName name, XmlSchemaObject value) - { - qname = name; - xso = value; - } - - public XmlSchemaObject IsMatch(string localName, string ns) - { - if (localName == qname.Name && ns == qname.Namespace) - { - return xso; - } - return null; - } - - public void Reset() - { - qname = null; - xso = null; - } - } - - internal class NamesCollection : ICollection - { - private List _entries; - private int _size; - - internal NamesCollection(List entries, int size) - { - _entries = entries; - _size = size; - } - - public int Count - { - get { return _size; } - } - - public Object SyncRoot - { - get - { - return ((ICollection)_entries).SyncRoot; - } - } - - public bool IsSynchronized - { - get - { - return ((ICollection)_entries).IsSynchronized; - } - } - - public void CopyTo(Array array, int arrayIndex) - { - if (array == null) - throw new ArgumentNullException("array"); - - if (arrayIndex < 0) - throw new ArgumentOutOfRangeException("arrayIndex"); - - Debug.Assert(array.Length >= _size, "array is not big enough to hold all the items in the ICollection"); - - for (int i = 0; i < _size; i++) - { - array.SetValue(_entries[i].qname, arrayIndex++); - } - } - - public IEnumerator GetEnumerator() - { - return new XSOEnumerator(_entries, _size, EnumeratorType.Keys); - } - } - - //ICollection for Values - internal class ValuesCollection : ICollection - { - private List _entries; - private int _size; - - internal ValuesCollection(List entries, int size) - { - _entries = entries; - _size = size; - } - - public int Count - { - get { return _size; } - } - - public Object SyncRoot - { - get - { - return ((ICollection)_entries).SyncRoot; - } - } - - public bool IsSynchronized - { - get - { - return ((ICollection)_entries).IsSynchronized; - } - } - - public void CopyTo(Array array, int arrayIndex) - { - if (array == null) - throw new ArgumentNullException("array"); - - if (arrayIndex < 0) - throw new ArgumentOutOfRangeException("arrayIndex"); - - Debug.Assert(array.Length >= _size, "array is not big enough to hold all the items in the ICollection"); - - for (int i = 0; i < _size; i++) - { - array.SetValue(_entries[i].xso, arrayIndex++); - } - } - - public IEnumerator GetEnumerator() - { - return new XSOEnumerator(_entries, _size, EnumeratorType.Values); - } - } - - internal class XSOEnumerator : IEnumerator - { - private List _entries; - private EnumeratorType _enumType; - - protected int currentIndex; - protected int size; - protected XmlQualifiedName currentKey; - protected XmlSchemaObject currentValue; - - - internal XSOEnumerator(List entries, int size, EnumeratorType enumType) - { - _entries = entries; - this.size = size; - _enumType = enumType; - currentIndex = -1; - } - - public Object Current - { - get - { - if (currentIndex == -1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - if (currentIndex >= size) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumFinished, string.Empty)); - } - switch (_enumType) - { - case EnumeratorType.Keys: - return currentKey; - - case EnumeratorType.Values: - return currentValue; - - case EnumeratorType.DictionaryEntry: - return new DictionaryEntry(currentKey, currentValue); - - default: - break; - } - return null; - } - } - - public bool MoveNext() - { - if (currentIndex >= size - 1) - { - currentValue = null; - currentKey = null; - return false; - } - currentIndex++; - currentValue = _entries[currentIndex].xso; - currentKey = _entries[currentIndex].qname; - return true; - } - - public void Reset() - { - currentIndex = -1; - currentValue = null; - currentKey = null; - } - } - - internal class XSODictionaryEnumerator : XSOEnumerator, IDictionaryEnumerator - { - internal XSODictionaryEnumerator(List entries, int size, EnumeratorType enumType) : base(entries, size, enumType) - { - } - - //IDictionaryEnumerator members - public DictionaryEntry Entry - { - get - { - if (currentIndex == -1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - if (currentIndex >= size) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumFinished, string.Empty)); - } - return new DictionaryEntry(currentKey, currentValue); - } - } - - public object Key - { - get - { - if (currentIndex == -1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - if (currentIndex >= size) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumFinished, string.Empty)); - } - return currentKey; - } - } - - public object Value - { - get - { - if (currentIndex == -1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumNotStarted, string.Empty)); - } - if (currentIndex >= size) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_EnumFinished, string.Empty)); - } - return currentValue; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaParticle.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaParticle.cs deleted file mode 100644 index 5804da8052e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaParticle.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaParticle : XmlSchemaAnnotated - { - [Flags] - private enum Occurs - { - None, - Min, - Max - }; - private decimal _minOccurs = decimal.One; - private decimal _maxOccurs = decimal.One; - private Occurs _flags = Occurs.None; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("minOccurs")] - public string MinOccursString - { - get - { - return (_flags & Occurs.Min) == 0 ? null : XmlConvert.ToString(_minOccurs); - } - set - { - if (value == null) - { - _minOccurs = decimal.One; - _flags &= ~Occurs.Min; - } - else - { - _minOccurs = XmlConvert.ToInteger(value); - if (_minOccurs < decimal.Zero) - { - throw new XmlSchemaException(ResXml.Sch_MinOccursInvalidXsd, string.Empty); - } - _flags |= Occurs.Min; - } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("maxOccurs")] - public string MaxOccursString - { - get - { - return (_flags & Occurs.Max) == 0 ? null : (_maxOccurs == decimal.MaxValue) ? "unbounded" : XmlConvert.ToString(_maxOccurs); - } - set - { - if (value == null) - { - _maxOccurs = decimal.One; - _flags &= ~Occurs.Max; - } - else - { - if (value == "unbounded") - { - _maxOccurs = decimal.MaxValue; - } - else - { - _maxOccurs = XmlConvert.ToInteger(value); - if (_maxOccurs < decimal.Zero) - { - throw new XmlSchemaException(ResXml.Sch_MaxOccursInvalidXsd, string.Empty); - } - else if (_maxOccurs == decimal.Zero && (_flags & Occurs.Min) == 0) - { - _minOccurs = decimal.Zero; - } - } - _flags |= Occurs.Max; - } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public decimal MinOccurs - { - get { return _minOccurs; } - set - { - if (value < decimal.Zero || value != decimal.Truncate(value)) - { - throw new XmlSchemaException(ResXml.Sch_MinOccursInvalidXsd, string.Empty); - } - _minOccurs = value; - _flags |= Occurs.Min; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public decimal MaxOccurs - { - get { return _maxOccurs; } - set - { - if (value < decimal.Zero || value != decimal.Truncate(value)) - { - throw new XmlSchemaException(ResXml.Sch_MaxOccursInvalidXsd, string.Empty); - } - _maxOccurs = value; - if (_maxOccurs == decimal.Zero && (_flags & Occurs.Min) == 0) - { - _minOccurs = decimal.Zero; - } - _flags |= Occurs.Max; - } - } - - internal virtual bool IsEmpty - { - get { return _maxOccurs == decimal.Zero; } - } - - internal bool IsMultipleOccurrence - { - get { return _maxOccurs > decimal.One; } - } - - internal virtual string NameString - { - get - { - return string.Empty; - } - } - - internal XmlQualifiedName GetQualifiedName() - { - XmlSchemaElement elem = this as XmlSchemaElement; - if (elem != null) - { - return elem.QualifiedName; - } - else - { - XmlSchemaAny any = this as XmlSchemaAny; - if (any != null) - { - string ns = any.Namespace; - if (ns != null) - { - ns = ns.Trim(); - } - else - { - ns = string.Empty; - } - return new XmlQualifiedName("*", ns.Length == 0 ? "##any" : ns); - } - } - return XmlQualifiedName.Empty; //If ever called on other particles - } - - private class EmptyParticle : XmlSchemaParticle - { - internal override bool IsEmpty - { - get { return true; } - } - } - - internal static readonly XmlSchemaParticle Empty = new EmptyParticle(); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaRedefine.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaRedefine.cs deleted file mode 100644 index 30098fcbda3..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaRedefine.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaRedefine : XmlSchemaExternal - { - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - private XmlSchemaObjectTable _attributeGroups = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _types = new XmlSchemaObjectTable(); - private XmlSchemaObjectTable _groups = new XmlSchemaObjectTable(); - - - /// - /// - /// [To be supplied.] - /// - public XmlSchemaRedefine() - { - Compositor = Compositor.Redefine; - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("annotation", typeof(XmlSchemaAnnotation)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroup)), - XmlElement("complexType", typeof(XmlSchemaComplexType)), - XmlElement("group", typeof(XmlSchemaGroup)), - XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaObjectCollection Items - { - get { return _items; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable AttributeGroups - { - get { return _attributeGroups; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable SchemaTypes - { - get { return _types; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaObjectTable Groups - { - get { return _groups; } - } - - internal override void AddAnnotation(XmlSchemaAnnotation annotation) - { - _items.Add(annotation); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSequence.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSequence.cs deleted file mode 100644 index b86571d738f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSequence.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSequence : XmlSchemaGroupBase - { - private XmlSchemaObjectCollection _items = new XmlSchemaObjectCollection(); - - /// - /// - /// [To be supplied.] - /// - [XmlElement("element", typeof(XmlSchemaElement)), - XmlElement("group", typeof(XmlSchemaGroupRef)), - XmlElement("choice", typeof(XmlSchemaChoice)), - XmlElement("sequence", typeof(XmlSchemaSequence)), - XmlElement("any", typeof(XmlSchemaAny))] - public override XmlSchemaObjectCollection Items - { - get { return _items; } - } - - internal override bool IsEmpty - { - get { return base.IsEmpty || _items.Count == 0; } - } - - internal override void SetItems(XmlSchemaObjectCollection newItems) - { - _items = newItems; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSet.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSet.cs deleted file mode 100644 index 467a9146393..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSet.cs +++ /dev/null @@ -1,1637 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Diagnostics; -using System.Collections; -using System.Threading; -using System.Collections.Generic; -using System.Runtime.Versioning; - - -namespace Microsoft.Xml.Schema -{ - /// - /// - /// The XmlSchemaSet contains a set of namespace URI's. - /// Each namespace also have an associated private data cache - /// corresponding to the XML-Data Schema or W3C XML Schema. - /// The XmlSchemaSet will able to load only XSD schemas, - /// and compile them into an internal "cooked schema representation". - /// The Validate method then uses this internal representation for - /// efficient runtime validation of any given subtree. - /// - public class XmlSchemaSet - { - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private SortedList _schemas; // List of source schemas - - //Event handling - private ValidationEventHandler _internalEventHandler; - private ValidationEventHandler _eventHandler; - - private bool _isCompiled = false; - - //Dictionary schemaLocations; - //Dictionary chameleonSchemas; - private Hashtable _schemaLocations; - private Hashtable _chameleonSchemas; - - private Hashtable _targetNamespaces; - private bool _compileAll; - - //Cached Compiled Info - private SchemaInfo _cachedCompiledInfo; - - //Reader settings to parse schema - private XmlReaderSettings _readerSettings; - private XmlSchema _schemaForSchema; //Only one schema for schema per set - - //Schema compilation settings - private XmlSchemaCompilationSettings _compilationSettings; - - internal XmlSchemaObjectTable elements; - internal XmlSchemaObjectTable attributes; - internal XmlSchemaObjectTable schemaTypes; - internal XmlSchemaObjectTable substitutionGroups; - private XmlSchemaObjectTable _typeExtensions; - - //Thread safety - private Object _internalSyncObject; - internal Object InternalSyncObject - { - get - { - if (_internalSyncObject == null) - { - Object o = new Object(); - Interlocked.CompareExchange(ref _internalSyncObject, o, null); - } - return _internalSyncObject; - } - } - - //Constructors - - /// - /// - /// Construct a new empty schema schemas. - /// - public XmlSchemaSet() : this(new NameTable()) - { - } - - /// - /// - /// Construct a new empty schema schemas with associated XmlNameTable. - /// The XmlNameTable is used when loading schemas - /// - public XmlSchemaSet(XmlNameTable nameTable) - { - if (nameTable == null) - { - throw new ArgumentNullException("nameTable"); - } - _nameTable = nameTable; - _schemas = new SortedList(); - - /*schemaLocations = new Dictionary(); - chameleonSchemas = new Dictionary();*/ - _schemaLocations = new Hashtable(); - _chameleonSchemas = new Hashtable(); - _targetNamespaces = new Hashtable(); - _internalEventHandler = new ValidationEventHandler(InternalValidationCallback); - _eventHandler = _internalEventHandler; - - _readerSettings = new XmlReaderSettings(); - - // we don't have to check XmlReaderSettings.EnableLegacyXmlSettings() here because the following - // code will return same result either we are running on v4.5 or later - if (_readerSettings.GetXmlResolver() == null) - { - // The created resolver will be used in the schema validation only - _readerSettings.XmlResolver = new XmlUrlResolver(); - _readerSettings.IsXmlResolverSet = false; - } - - _readerSettings.NameTable = nameTable; - _readerSettings.DtdProcessing = DtdProcessing.Prohibit; - - _compilationSettings = new XmlSchemaCompilationSettings(); - _cachedCompiledInfo = new SchemaInfo(); - _compileAll = true; - } - - - //Public Properties - /// - /// - /// The default XmlNameTable used by the XmlSchemaSet when loading new schemas. - /// - public XmlNameTable NameTable - { - get { return _nameTable; } - } - - /// - public event ValidationEventHandler ValidationEventHandler - { - add - { - _eventHandler -= _internalEventHandler; - _eventHandler += value; - if (_eventHandler == null) - { - _eventHandler = _internalEventHandler; - } - } - remove - { - _eventHandler -= value; - if (_eventHandler == null) - { - _eventHandler = _internalEventHandler; - } - } - } - - /// - /// - /// IsCompiled is true when the schema set is in compiled state - /// - public bool IsCompiled - { - get - { - return _isCompiled; - } - } - - /// - /// - /// - /// - public XmlResolver XmlResolver - { - set - { - _readerSettings.XmlResolver = value; - } - } - - /// - /// - /// - /// - public XmlSchemaCompilationSettings CompilationSettings - { - get - { - return _compilationSettings; - } - set - { - _compilationSettings = value; - } - } - - /// - /// - /// Returns the count of schemas in the set - /// - public int Count - { - get - { - return _schemas.Count; - } - } - /// - /// - /// - /// - public XmlSchemaObjectTable GlobalElements - { - get - { - if (elements == null) - { - elements = new XmlSchemaObjectTable(); - } - return elements; - } - } - - /// - /// - /// - /// - public XmlSchemaObjectTable GlobalAttributes - { - get - { - if (attributes == null) - { - attributes = new XmlSchemaObjectTable(); - } - return attributes; - } - } - - /// - /// - /// - /// - public XmlSchemaObjectTable GlobalTypes - { - get - { - if (schemaTypes == null) - { - schemaTypes = new XmlSchemaObjectTable(); - } - return schemaTypes; - } - } - - /// - /// - /// - /// - /// TODO: Need to make this public - internal XmlSchemaObjectTable SubstitutionGroups - { - get - { - if (substitutionGroups == null) - { - substitutionGroups = new XmlSchemaObjectTable(); - } - return substitutionGroups; - } - } - - /// - /// Table of all types extensions - /// - internal Hashtable SchemaLocations - { - get - { - return _schemaLocations; - } - } - - /// - /// Table of all types extensions - /// - internal XmlSchemaObjectTable TypeExtensions - { - get - { - if (_typeExtensions == null) - { - _typeExtensions = new XmlSchemaObjectTable(); - } - return _typeExtensions; - } - } - //Public Methods - - /// - /// - /// Add the schema located by the given URL into the schema schemas. - /// If the given schema references other namespaces, the schemas for those other - /// namespaces are NOT automatically loaded. - /// - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public XmlSchema Add(String targetNamespace, String schemaUri) - { - if (schemaUri == null || schemaUri.Length == 0) - { - throw new ArgumentNullException("schemaUri"); - } - if (targetNamespace != null) - { - targetNamespace = XmlComplianceUtil.CDataNormalize(targetNamespace); - } - XmlSchema schema = null; - lock (InternalSyncObject) - { - //Check if schema from url has already been added - XmlResolver tempResolver = _readerSettings.GetXmlResolver(); - if (tempResolver == null) - { - tempResolver = new XmlUrlResolver(); - } - Uri tempSchemaUri = tempResolver.ResolveUri(null, schemaUri); - if (IsSchemaLoaded(tempSchemaUri, targetNamespace, out schema)) - { - return schema; - } - else - { - //Url already not processed; Load SOM from url - XmlReader reader = XmlReader.Create(schemaUri, _readerSettings); - try - { - schema = Add(targetNamespace, ParseSchema(targetNamespace, reader)); //TODO can move parsing outside lock boundary - while (reader.Read()) ;// wellformness check; - } - finally - { - reader.Close(); - } - } - } - return schema; - } - - - /// - /// - /// Add the given schema into the schema schemas. - /// If the given schema references other namespaces, the schemas for those - /// other namespaces are NOT automatically loaded. - /// - public XmlSchema Add(String targetNamespace, XmlReader schemaDocument) - { - if (schemaDocument == null) - { - throw new ArgumentNullException("schemaDocument"); - } - if (targetNamespace != null) - { - targetNamespace = XmlComplianceUtil.CDataNormalize(targetNamespace); - } - lock (InternalSyncObject) - { - XmlSchema schema = null; - Uri schemaUri = new Uri(schemaDocument.BaseURI, UriKind.RelativeOrAbsolute); - if (IsSchemaLoaded(schemaUri, targetNamespace, out schema)) - { - return schema; - } - else - { - DtdProcessing dtdProcessing = _readerSettings.DtdProcessing; - SetDtdProcessing(schemaDocument); - schema = Add(targetNamespace, ParseSchema(targetNamespace, schemaDocument)); - _readerSettings.DtdProcessing = dtdProcessing; //reset dtdProcessing setting - return schema; - } - } - } - - - /// - /// - /// Adds all the namespaces defined in the given schemas - /// (including their associated schemas) to this schemas. - /// - public void Add(XmlSchemaSet schemas) - { - if (schemas == null) - { - throw new ArgumentNullException("schemas"); - } - if (this == schemas) - { - return; - } - bool thisLockObtained = false; - bool schemasLockObtained = false; - try - { - while (true) - { - Monitor.TryEnter(InternalSyncObject, ref thisLockObtained); - if (thisLockObtained) - { - Monitor.TryEnter(schemas.InternalSyncObject, ref schemasLockObtained); - if (schemasLockObtained) - { - break; - } - else - { - Monitor.Exit(InternalSyncObject); //Give up this lock and try both again - thisLockObtained = false; - Thread.Sleep(10); //Thread.Yield(); //Let the thread that holds the lock run - continue; - } - } - } - - XmlSchema currentSchema; - //TODO Need to copy chameleon Schemas and schemaLocations from other set - if (schemas.IsCompiled) - { - CopyFromCompiledSet(schemas); - } - else - { - bool remove = false; - string tns = null; - foreach (XmlSchema schema in schemas.SortedSchemas.Values) - { - tns = schema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - if (_schemas.ContainsKey(schema.SchemaId) || FindSchemaByNSAndUrl(schema.BaseUri, tns, null) != null) - { //Do not already existing url - continue; - } - currentSchema = Add(schema.TargetNamespace, schema); - if (currentSchema == null) - { - remove = true; - break; - } - } - //Remove all from the set if even one schema in the passed in set is not preprocessed. - if (remove) - { - foreach (XmlSchema schema in schemas.SortedSchemas.Values) - { //Remove all previously added schemas from the set - _schemas.Remove(schema.SchemaId); //Might remove schema that was already there and was not added thru this operation - _schemaLocations.Remove(schema.BaseUri); - } - } - } - } - finally - { //release locks on sets - if (thisLockObtained) - { - Monitor.Exit(InternalSyncObject); - } - if (schemasLockObtained) - { - Monitor.Exit(schemas.InternalSyncObject); - } - } - } - - /// - public XmlSchema Add(XmlSchema schema) - { - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - lock (InternalSyncObject) - { - if (_schemas.ContainsKey(schema.SchemaId)) - { - return schema; - } - return Add(schema.TargetNamespace, schema); - } - } - - /// - public XmlSchema Remove(XmlSchema schema) - { - return Remove(schema, true); - } - - /// - public bool RemoveRecursive(XmlSchema schemaToRemove) - { - if (schemaToRemove == null) - { - throw new ArgumentNullException("schemaToRemove"); - } - if (!_schemas.ContainsKey(schemaToRemove.SchemaId)) - { - return false; - } - - lock (InternalSyncObject) - { //Need to lock here so that remove cannot be called while the set is being compiled - if (_schemas.ContainsKey(schemaToRemove.SchemaId)) - { //Need to check again - //Build disallowedNamespaces list - Hashtable disallowedNamespaces = new Hashtable(); - disallowedNamespaces.Add(GetTargetNamespace(schemaToRemove), schemaToRemove); - string importedNS; - for (int i = 0; i < schemaToRemove.ImportedNamespaces.Count; i++) - { - importedNS = (string)schemaToRemove.ImportedNamespaces[i]; - if (disallowedNamespaces[importedNS] == null) - { - disallowedNamespaces.Add(importedNS, importedNS); - } - } - - //Removal list is all schemas imported by this schema directly or indirectly - //Need to check if other schemas in the set import schemaToRemove / any of its imports - ArrayList needToCheckSchemaList = new ArrayList(); - XmlSchema mainSchema; - for (int i = 0; i < _schemas.Count; i++) - { - mainSchema = (XmlSchema)_schemas.GetByIndex(i); - if (mainSchema == schemaToRemove || - schemaToRemove.ImportedSchemas.Contains(mainSchema)) - { - continue; - } - needToCheckSchemaList.Add(mainSchema); - } - - mainSchema = null; - for (int i = 0; i < needToCheckSchemaList.Count; i++) - { //Perf: Not using nested foreach here - mainSchema = (XmlSchema)needToCheckSchemaList[i]; - - if (mainSchema.ImportedNamespaces.Count > 0) - { - foreach (string tns in disallowedNamespaces.Keys) - { - if (mainSchema.ImportedNamespaces.Contains(tns)) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_SchemaNotRemoved, string.Empty), XmlSeverityType.Warning); - return false; - } - } - } - } - - Remove(schemaToRemove, true); - for (int i = 0; i < schemaToRemove.ImportedSchemas.Count; ++i) - { - XmlSchema impSchema = (XmlSchema)schemaToRemove.ImportedSchemas[i]; - Remove(impSchema, true); - } - return true; - } - } - return false; - } - - /// - public bool Contains(String targetNamespace) - { - if (targetNamespace == null) - { - targetNamespace = string.Empty; - } - return _targetNamespaces[targetNamespace] != null; - } - - /// - public bool Contains(XmlSchema schema) - { - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - return _schemas.ContainsValue(schema); - } - - /// - /// - /// [To be supplied.] - /// - public void Compile() - { - if (_isCompiled) - { - return; - } - if (_schemas.Count == 0) - { - ClearTables(); //Clear any previously present compiled state left by calling just Remove() on the set - _cachedCompiledInfo = new SchemaInfo(); - _isCompiled = true; - _compileAll = false; - return; - } - lock (InternalSyncObject) - { - if (!_isCompiled) - { //Locking before checking isCompiled to avoid problems with double locking - Compiler compiler = new Compiler(_nameTable, _eventHandler, _schemaForSchema, _compilationSettings); - SchemaInfo newCompiledInfo = new SchemaInfo(); - int schemaIndex = 0; - if (!_compileAll) - { //if we are not compiling everything again, Move the pre-compiled schemas to the compiler's tables - compiler.ImportAllCompiledSchemas(this); - } - try - { //First thing to do in the try block is to acquire locks since finally will try to release them. - //If we dont accuire the locks first, and an exception occurs in the code before the locking code, then Threading.SynchronizationLockException will be thrown - //when attempting to release it in the finally block - XmlSchema currentSchema; - XmlSchema xmlNSSchema = Preprocessor.GetBuildInSchema(); - for (schemaIndex = 0; schemaIndex < _schemas.Count; schemaIndex++) - { - currentSchema = (XmlSchema)_schemas.GetByIndex(schemaIndex); - - //Lock schema to be compiled -#pragma warning disable 0618 - //@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- ericeil - Monitor.Enter(currentSchema); -#pragma warning restore 0618 - if (!currentSchema.IsPreprocessed) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_SchemaNotPreprocessed, string.Empty), XmlSeverityType.Error); - _isCompiled = false; - return; - } - if (currentSchema.IsCompiledBySet) - { - if (!_compileAll) - { - continue; - } - else if ((object)currentSchema == (object)xmlNSSchema) - { // prepare for xml namespace schema without cleanup - compiler.Prepare(currentSchema, false); - continue; - } - } - compiler.Prepare(currentSchema, true); - } - - _isCompiled = compiler.Execute(this, newCompiledInfo); - if (_isCompiled) - { - if (!_compileAll) - { - newCompiledInfo.Add(_cachedCompiledInfo, _eventHandler); //Add all the items from the old to the new compiled object - } - _compileAll = false; - _cachedCompiledInfo = newCompiledInfo; //Replace the compiled info in the set after successful compilation - } - } - finally - { - //Release locks on all schemas - XmlSchema currentSchema; - if (schemaIndex == _schemas.Count) - { - schemaIndex--; - } - for (int i = schemaIndex; i >= 0; i--) - { - currentSchema = (XmlSchema)_schemas.GetByIndex(i); - if (currentSchema == Preprocessor.GetBuildInSchema()) - { //dont re-set compiled flags for xml namespace schema - Monitor.Exit(currentSchema); - continue; - } - currentSchema.IsCompiledBySet = _isCompiled; - Monitor.Exit(currentSchema); - } - } - } - } - return; - } - - /// - /// - /// [To be supplied.] - /// - public XmlSchema Reprocess(XmlSchema schema) - { - // Due to bug 644477 - this method is tightly coupled (THE CODE IS BASICALLY COPIED) to Remove, Add and AddSchemaToSet - // methods. If you change anything here *make sure* to update Remove/Add/AddSchemaToSet method(s) accordingly. - // The only difference is that we don't touch .schemas collection here to not break a code like this: - // foreach(XmlSchema s in schemaset.schemas) { schemaset.Reprocess(s); } - // This is by purpose. - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - if (!_schemas.ContainsKey(schema.SchemaId)) - { - throw new ArgumentException(ResXml.Sch_SchemaDoesNotExist, "schema"); - } - XmlSchema originalSchema = schema; - lock (InternalSyncObject) - { //Lock set so that set cannot be compiled in another thread - // This code is copied from method: - // Remove(XmlSchema schema, bool forceCompile) - // If you changed anything here go and change the same in Remove(XmlSchema schema, bool forceCompile) method - #region Copied from Remove(XmlSchema schema, bool forceCompile) - - RemoveSchemaFromGlobalTables(schema); - RemoveSchemaFromCaches(schema); - if (schema.BaseUri != null) - { - _schemaLocations.Remove(schema.BaseUri); - } - string tns = GetTargetNamespace(schema); - if (Schemas(tns).Count == 0) - { //This is the only schema for that namespace - _targetNamespaces.Remove(tns); - } - _isCompiled = false; - _compileAll = true; //Force compilation of the whole set; This is when the set is not completely thread-safe - - #endregion //Copied from Remove(XmlSchema schema, bool forceCompile) - - - // This code is copied from method: - // Add(string targetNamespace, XmlSchema schema) - // If you changed anything here go and change the same in Add(string targetNamespace, XmlSchema schema) method - #region Copied from Add(string targetNamespace, XmlSchema schema) - - if (schema.ErrorCount != 0) - { //Schema with parsing errors cannot be loaded - return originalSchema; - } - if (PreprocessSchema(ref schema, schema.TargetNamespace)) - { //No perf opt for already compiled schemas - // This code is copied from method: - // AddSchemaToSet(XmlSchema schema) - // If you changed anything here go and change the same in AddSchemaToSet(XmlSchema schema) method - #region Copied from AddSchemaToSet(XmlSchema schema) - - //Add to targetNamespaces table - if (_targetNamespaces[tns] == null) - { - _targetNamespaces.Add(tns, tns); - } - if (_schemaForSchema == null && tns == XmlReservedNs.NsXs && schema.SchemaTypes[DatatypeImplementation.QnAnyType] != null) - { //it has xs:anyType - _schemaForSchema = schema; - } - for (int i = 0; i < schema.ImportedSchemas.Count; ++i) - { //Once preprocessed external schemas property is set - XmlSchema s = (XmlSchema)schema.ImportedSchemas[i]; - if (!_schemas.ContainsKey(s.SchemaId)) - { - _schemas.Add(s.SchemaId, s); - } - tns = GetTargetNamespace(s); - if (_targetNamespaces[tns] == null) - { - _targetNamespaces.Add(tns, tns); - } - if (_schemaForSchema == null && tns == XmlReservedNs.NsXs && schema.SchemaTypes[DatatypeImplementation.QnAnyType] != null) - { //it has xs:anyType - _schemaForSchema = schema; - } - } - #endregion //Copied from AddSchemaToSet(XmlSchema schema) - return schema; - } - #endregion // Copied from Add(string targetNamespace, XmlSchema schema) - - return originalSchema; - } - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(XmlSchema[] schemas, int index) - { - if (schemas == null) - throw new ArgumentNullException("schemas"); - if (index < 0 || index > schemas.Length - 1) - throw new ArgumentOutOfRangeException("index"); - _schemas.Values.CopyTo(schemas, index); - } - - /// - /// - /// [To be supplied.] - /// - public ICollection Schemas() - { - return _schemas.Values; - } - - /// - /// - /// [To be supplied.] - /// - public ICollection Schemas(String targetNamespace) - { - ArrayList tnsSchemas = new ArrayList(); - XmlSchema currentSchema; - if (targetNamespace == null) - { - targetNamespace = string.Empty; - } - for (int i = 0; i < _schemas.Count; i++) - { - currentSchema = (XmlSchema)_schemas.GetByIndex(i); - if (GetTargetNamespace(currentSchema) == targetNamespace) - { - tnsSchemas.Add(currentSchema); - } - } - return tnsSchemas; - } - - //Internal Methods - - private XmlSchema Add(string targetNamespace, XmlSchema schema) - { - // Due to bug 644477 - this method is tightly coupled (THE CODE IS BASICALLY COPIED) to Reprocess - // method. If you change anything here *make sure* to update Reprocess method accordingly. - - if (schema == null || schema.ErrorCount != 0) - { //Schema with parsing errors cannot be loaded - return null; - } - - // This code is copied to method: - // Reprocess(XmlSchema schema) - // If you changed anything here go and change the same in Reprocess(XmlSchema schema) method - if (PreprocessSchema(ref schema, targetNamespace)) - { //No perf opt for already compiled schemas - AddSchemaToSet(schema); - _isCompiled = false; - return schema; - } - return null; - } - -#if TRUST_COMPILE_STATE - private void AddCompiledSchema(XmlSchema schema) { - if (schema.IsCompiledBySet ) { //trust compiled state always if it is not a chameleon schema - VerifyTables(); - SchemaInfo newCompiledInfo = new SchemaInfo(); - XmlSchemaObjectTable substitutionGroupsTable = null; - if (!AddToCompiledInfo(schema, newCompiledInfo, ref substitutionGroupsTable)) { //Error while adding main schema - return null; - } - foreach (XmlSchema impSchema in schema.ImportedSchemas) { - if (!AddToCompiledInfo(impSchema, newCompiledInfo, ref substitutionGroupsTable)) { //Error while adding imports - return null; - } - } - newCompiledInfo.Add(cachedCompiledInfo, eventHandler); //Add existing compiled info - cachedCompiledInfo = newCompiledInfo; - if (substitutionGroupsTable != null) { - ProcessNewSubstitutionGroups(substitutionGroupsTable, true); - } - if (schemas.Count == 0) { //If its the first compiled schema being added, then set doesnt need to be compiled - isCompiled = true; - compileAll = false; - } - AddSchemaToSet(schema); - return schema; - } - } - - private bool AddToCompiledInfo(XmlSchema schema, SchemaInfo newCompiledInfo, ref XmlSchemaObjectTable substTable) { - //Add schema's compiled tables to the set - if (schema.BaseUri != null && schemaLocations[schema.BaseUri] == null) { //Update schemaLocations table - schemaLocations.Add(schema.BaseUri, schema); - } - - foreach (XmlSchemaElement element in schema.Elements.Values) { - if(!AddToTable(elements, element.QualifiedName, element)) { - RemoveSchemaFromGlobalTables(schema); - return false; - } - XmlQualifiedName head = element.SubstitutionGroup; - if (!head.IsEmpty) { - if (substTable == null) { - substTable = new XmlSchemaObjectTable(); - } - XmlSchemaSubstitutionGroup substitutionGroup = (XmlSchemaSubstitutionGroup)substTable[head]; - if (substitutionGroup == null) { - substitutionGroup = new XmlSchemaSubstitutionGroup(); - substitutionGroup.Examplar = head; - substTable.Add(head, substitutionGroup); - } - ArrayList members = substitutionGroup.Members; - if (!members.Contains(element)) { //Members might contain element if the same schema is included and imported through different paths. Imp, hence will be added to set directly - members.Add(element); - } - } - } - foreach (XmlSchemaAttribute attribute in schema.Attributes.Values) { - if (!AddToTable(attributes, attribute.QualifiedName, attribute)) { - RemoveSchemaFromGlobalTables(schema); - return false; - } - } - foreach (XmlSchemaType schemaType in schema.SchemaTypes.Values) { - if (!AddToTable(schemaTypes, schemaType.QualifiedName, schemaType)) { - RemoveSchemaFromGlobalTables(schema); - return false; - } - } - schema.AddCompiledInfo(newCompiledInfo); - - return true; - } -#endif - - //For use by the validator when loading schemaLocations in the instance - internal void Add(String targetNamespace, XmlReader reader, Hashtable validatedNamespaces) - { - if (reader == null) - { - throw new ArgumentNullException("reader"); - } - if (targetNamespace == null) - { - targetNamespace = string.Empty; - } - if (validatedNamespaces[targetNamespace] != null) - { - if (FindSchemaByNSAndUrl(new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute), targetNamespace, null) != null) - { - return; - } - else - { - throw new XmlSchemaException(ResXml.Sch_ComponentAlreadySeenForNS, targetNamespace); - } - } - - //Not locking set as this will not be accessible outside the validator - XmlSchema schema; - if (IsSchemaLoaded(new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute), targetNamespace, out schema)) - { - return; - } - else - { //top-level schema not present for same url - schema = ParseSchema(targetNamespace, reader); - - //Store the previous locations - DictionaryEntry[] oldLocations = new DictionaryEntry[_schemaLocations.Count]; - _schemaLocations.CopyTo(oldLocations, 0); - - //Add to set - Add(targetNamespace, schema); - if (schema.ImportedSchemas.Count > 0) - { //Check imports - string tns; - for (int i = 0; i < schema.ImportedSchemas.Count; ++i) - { - XmlSchema impSchema = (XmlSchema)schema.ImportedSchemas[i]; - tns = impSchema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - if (validatedNamespaces[tns] != null && (FindSchemaByNSAndUrl(impSchema.BaseUri, tns, oldLocations) == null)) - { - RemoveRecursive(schema); - throw new XmlSchemaException(ResXml.Sch_ComponentAlreadySeenForNS, tns); - } - } - } - } - } - - internal XmlSchema FindSchemaByNSAndUrl(Uri schemaUri, string ns, DictionaryEntry[] locationsTable) - { - if (schemaUri == null || schemaUri.OriginalString.Length == 0) - { - return null; - } - XmlSchema schema = null; - if (locationsTable == null) - { - schema = (XmlSchema)_schemaLocations[schemaUri]; - } - else - { - for (int i = 0; i < locationsTable.Length; i++) - { - if (schemaUri.Equals(locationsTable[i].Key)) - { - schema = (XmlSchema)locationsTable[i].Value; - break; - } - } - } - if (schema != null) - { - Debug.Assert(ns != null); - string tns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; - if (tns == ns) - { - return schema; - } - else if (tns == string.Empty) - { //There could be a chameleon for same ns - // It is OK to pass in the schema we have found so far, since it must have the schemaUri we're looking for - // (we found it that way above) and it must be the original chameleon schema (the one without target ns) - // as we don't add the chameleon copies into the locations tables above. - Debug.Assert(schema.BaseUri.Equals(schemaUri)); - ChameleonKey cKey = new ChameleonKey(ns, schema); - schema = (XmlSchema)_chameleonSchemas[cKey]; //Need not clone if a schema for that namespace already exists - } - else - { - schema = null; - } - } - return schema; - } - - private void SetDtdProcessing(XmlReader reader) - { - if (reader.Settings != null) - { - _readerSettings.DtdProcessing = reader.Settings.DtdProcessing; - } - else - { - XmlTextReader v1Reader = reader as XmlTextReader; - if (v1Reader != null) - { - _readerSettings.DtdProcessing = v1Reader.DtdProcessing; - } - } - } - - private void AddSchemaToSet(XmlSchema schema) - { - // Due to bug 644477 - this method is tightly coupled (THE CODE IS BASICALLY COPIED) to Reprocess - // method. If you change anything here *make sure* to update Reprocess method accordingly. - - _schemas.Add(schema.SchemaId, schema); - //Add to targetNamespaces table - - // This code is copied to method: - // Reprocess(XmlSchema schema) - // If you changed anything here go and change the same in Reprocess(XmlSchema schema) method - #region This code is copied to Reprocess(XmlSchema schema) method - - string tns = GetTargetNamespace(schema); - if (_targetNamespaces[tns] == null) - { - _targetNamespaces.Add(tns, tns); - } - if (_schemaForSchema == null && tns == XmlReservedNs.NsXs && schema.SchemaTypes[DatatypeImplementation.QnAnyType] != null) - { //it has xs:anyType - _schemaForSchema = schema; - } - for (int i = 0; i < schema.ImportedSchemas.Count; ++i) - { //Once preprocessed external schemas property is set - XmlSchema s = (XmlSchema)schema.ImportedSchemas[i]; - if (!_schemas.ContainsKey(s.SchemaId)) - { - _schemas.Add(s.SchemaId, s); - } - tns = GetTargetNamespace(s); - if (_targetNamespaces[tns] == null) - { - _targetNamespaces.Add(tns, tns); - } - if (_schemaForSchema == null && tns == XmlReservedNs.NsXs && schema.SchemaTypes[DatatypeImplementation.QnAnyType] != null) - { //it has xs:anyType - _schemaForSchema = schema; - } - } - - #endregion // This code is copied to Reprocess(XmlSchema schema) method - } - - private void ProcessNewSubstitutionGroups(XmlSchemaObjectTable substitutionGroupsTable, bool resolve) - { - foreach (XmlSchemaSubstitutionGroup substGroup in substitutionGroupsTable.Values) - { - if (resolve) - { //Resolve substitutionGroups within this schema - ResolveSubstitutionGroup(substGroup, substitutionGroupsTable); - } - - //Add or Merge new substitutionGroups with those that already exist in the set - XmlQualifiedName head = substGroup.Examplar; - XmlSchemaSubstitutionGroup oldSubstGroup = (XmlSchemaSubstitutionGroup)substitutionGroups[head]; - if (oldSubstGroup != null) - { - for (int i = 0; i < substGroup.Members.Count; ++i) - { - if (!oldSubstGroup.Members.Contains(substGroup.Members[i])) - { - oldSubstGroup.Members.Add(substGroup.Members[i]); - } - } - } - else - { - AddToTable(substitutionGroups, head, substGroup); - } - } - } - - private void ResolveSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup, XmlSchemaObjectTable substTable) - { - List newMembers = null; - XmlSchemaElement headElement = (XmlSchemaElement)elements[substitutionGroup.Examplar]; - if (substitutionGroup.Members.Contains(headElement)) - {// already checked - return; - } - for (int i = 0; i < substitutionGroup.Members.Count; ++i) - { - XmlSchemaElement element = (XmlSchemaElement)substitutionGroup.Members[i]; - - //Chain to other head's that are members of this head's substGroup - XmlSchemaSubstitutionGroup g = (XmlSchemaSubstitutionGroup)substTable[element.QualifiedName]; - if (g != null) - { - ResolveSubstitutionGroup(g, substTable); - for (int j = 0; j < g.Members.Count; ++j) - { - XmlSchemaElement element1 = (XmlSchemaElement)g.Members[j]; - if (element1 != element) - { //Exclude the head - if (newMembers == null) - { - newMembers = new List(); - } - newMembers.Add(element1); - } - } - } - } - if (newMembers != null) - { - for (int i = 0; i < newMembers.Count; ++i) - { - substitutionGroup.Members.Add(newMembers[i]); - } - } - substitutionGroup.Members.Add(headElement); - } - - internal XmlSchema Remove(XmlSchema schema, bool forceCompile) - { - // Due to bug 644477 - this method is tightly coupled (THE CODE IS BASICALLY COPIED) to Reprocess - // method. If you change anything here *make sure* to update Reprocess method accordingly. - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - lock (InternalSyncObject) - { //Need to lock here so that remove cannot be called while the set is being compiled - if (_schemas.ContainsKey(schema.SchemaId)) - { - // This code is copied to method: - // Reprocess(XmlSchema schema) - // If you changed anything here go and change the same in Reprocess(XmlSchema schema) method - #region This code is copied to Reprocess(XmlSchema schema) method - - if (forceCompile) - { - RemoveSchemaFromGlobalTables(schema); - RemoveSchemaFromCaches(schema); - } - _schemas.Remove(schema.SchemaId); - if (schema.BaseUri != null) - { - _schemaLocations.Remove(schema.BaseUri); - } - string tns = GetTargetNamespace(schema); - if (Schemas(tns).Count == 0) - { //This is the only schema for that namespace - _targetNamespaces.Remove(tns); - } - if (forceCompile) - { - _isCompiled = false; - _compileAll = true; //Force compilation of the whole set; This is when the set is not completely thread-safe - } - return schema; - - #endregion // This code is copied to Reprocess(XmlSchema schema) method - } - } - return null; - } - - private void ClearTables() - { - GlobalElements.Clear(); - GlobalAttributes.Clear(); - GlobalTypes.Clear(); - SubstitutionGroups.Clear(); - TypeExtensions.Clear(); - } - - internal bool PreprocessSchema(ref XmlSchema schema, string targetNamespace) - { - Preprocessor prep = new Preprocessor(_nameTable, GetSchemaNames(_nameTable), _eventHandler, _compilationSettings); - prep.XmlResolver = _readerSettings.GetXmlResolver_CheckConfig(); - prep.ReaderSettings = _readerSettings; - prep.SchemaLocations = _schemaLocations; - prep.ChameleonSchemas = _chameleonSchemas; - bool hasErrors = prep.Execute(schema, targetNamespace, true); - schema = prep.RootSchema; //For any root level chameleon cloned - return hasErrors; - } - - internal XmlSchema ParseSchema(string targetNamespace, XmlReader reader) - { - XmlNameTable readerNameTable = reader.NameTable; - SchemaNames schemaNames = GetSchemaNames(readerNameTable); - Parser parser = new Parser(SchemaType.XSD, readerNameTable, schemaNames, _eventHandler); - parser.XmlResolver = _readerSettings.GetXmlResolver_CheckConfig(); - SchemaType schemaType; - try - { - schemaType = parser.Parse(reader, targetNamespace); - } - catch (XmlSchemaException e) - { - SendValidationEvent(e, XmlSeverityType.Error); - return null; - } - return parser.XmlSchema; - } - - internal void CopyFromCompiledSet(XmlSchemaSet otherSet) - { - XmlSchema currentSchema; - SortedList copyFromList = otherSet.SortedSchemas; - bool setIsCompiled = _schemas.Count == 0 ? true : false; - ArrayList existingSchemas = new ArrayList(); - - SchemaInfo newCompiledInfo = new SchemaInfo(); - Uri baseUri; - for (int i = 0; i < copyFromList.Count; i++) - { - currentSchema = (XmlSchema)copyFromList.GetByIndex(i); - baseUri = currentSchema.BaseUri; - if (_schemas.ContainsKey(currentSchema.SchemaId) || (baseUri != null && baseUri.OriginalString.Length != 0 && _schemaLocations[baseUri] != null)) - { - existingSchemas.Add(currentSchema); - continue; - } - _schemas.Add(currentSchema.SchemaId, currentSchema); - if (baseUri != null && baseUri.OriginalString.Length != 0) - { - _schemaLocations.Add(baseUri, currentSchema); - } - string tns = GetTargetNamespace(currentSchema); - if (_targetNamespaces[tns] == null) - { - _targetNamespaces.Add(tns, tns); - } - } - - VerifyTables(); - foreach (XmlSchemaElement element in otherSet.GlobalElements.Values) - { - if (!AddToTable(elements, element.QualifiedName, element)) - { - goto RemoveAll; - } - } - foreach (XmlSchemaAttribute attribute in otherSet.GlobalAttributes.Values) - { - if (!AddToTable(attributes, attribute.QualifiedName, attribute)) - { - goto RemoveAll; - } - } - foreach (XmlSchemaType schemaType in otherSet.GlobalTypes.Values) - { - if (!AddToTable(schemaTypes, schemaType.QualifiedName, schemaType)) - { - goto RemoveAll; - } - } - //TODO get otherSet's substitutionGroups - ProcessNewSubstitutionGroups(otherSet.SubstitutionGroups, false); - - newCompiledInfo.Add(_cachedCompiledInfo, _eventHandler); //Add all the items from the old to the new compiled object - newCompiledInfo.Add(otherSet.CompiledInfo, _eventHandler); //TODO: Throw error on conflicting types that are not from the same schema / baseUri - _cachedCompiledInfo = newCompiledInfo; //Replace the compiled info in the set after successful compilation - if (setIsCompiled) - { - _isCompiled = true; - _compileAll = false; - } - return; - - RemoveAll: - foreach (XmlSchema schemaToRemove in copyFromList.Values) - { - if (!existingSchemas.Contains(schemaToRemove)) - { - Remove(schemaToRemove, false); - } - } - foreach (XmlSchemaElement elementToRemove in otherSet.GlobalElements.Values) - { - if (!existingSchemas.Contains((XmlSchema)elementToRemove.Parent)) - { - elements.Remove(elementToRemove.QualifiedName); - } - } - foreach (XmlSchemaAttribute attributeToRemove in otherSet.GlobalAttributes.Values) - { - if (!existingSchemas.Contains((XmlSchema)attributeToRemove.Parent)) - { - attributes.Remove(attributeToRemove.QualifiedName); - } - } - foreach (XmlSchemaType schemaTypeToRemove in otherSet.GlobalTypes.Values) - { - if (!existingSchemas.Contains((XmlSchema)schemaTypeToRemove.Parent)) - { - schemaTypes.Remove(schemaTypeToRemove.QualifiedName); - } - } - } - - internal SchemaInfo CompiledInfo - { - get - { - return _cachedCompiledInfo; - } - } - - internal XmlReaderSettings ReaderSettings - { - get - { - return _readerSettings; - } - } - - internal XmlResolver GetResolver() - { - return _readerSettings.GetXmlResolver_CheckConfig(); - } - - internal ValidationEventHandler GetEventHandler() - { - return _eventHandler; - } - - internal SchemaNames GetSchemaNames(XmlNameTable nt) - { - if (_nameTable != nt) - { - return new SchemaNames(nt); - } - else - { - if (_schemaNames == null) - { - _schemaNames = new SchemaNames(_nameTable); - } - return _schemaNames; - } - } - - internal bool IsSchemaLoaded(Uri schemaUri, string targetNamespace, out XmlSchema schema) - { - schema = null; - if (targetNamespace == null) - { - targetNamespace = string.Empty; - } - if (GetSchemaByUri(schemaUri, out schema)) - { - if (_schemas.ContainsKey(schema.SchemaId) && (targetNamespace.Length == 0 || targetNamespace == schema.TargetNamespace)) - { //schema is present in set - //Schema found - } - else if (schema.TargetNamespace == null) - { //If schema not in set or namespace doesnt match, then it might be a chameleon - XmlSchema chameleonSchema = FindSchemaByNSAndUrl(schemaUri, targetNamespace, null); - if (chameleonSchema != null && _schemas.ContainsKey(chameleonSchema.SchemaId)) - { - schema = chameleonSchema; - } - else - { - schema = Add(targetNamespace, schema); - } - } - else if (targetNamespace.Length != 0 && targetNamespace != schema.TargetNamespace) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_MismatchTargetNamespaceEx, new string[] { targetNamespace, schema.TargetNamespace }), XmlSeverityType.Error); - schema = null; - } - else - { - //If here, schema not present in set but in loc and might be added in loc through an earlier include - //S.TNS != null && ( tns == null or tns == s.TNS) - AddSchemaToSet(schema); - } - return true; //Schema Found - } - return false; - } - - internal bool GetSchemaByUri(Uri schemaUri, out XmlSchema schema) - { - schema = null; - if (schemaUri == null || schemaUri.OriginalString.Length == 0) - { - return false; - } - schema = (XmlSchema)_schemaLocations[schemaUri]; - if (schema != null) - { - return true; - } - return false; - } - - internal string GetTargetNamespace(XmlSchema schema) - { - return schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; - } - - - internal SortedList SortedSchemas - { - get - { - return _schemas; - } - } - - internal bool CompileAll - { - get - { - return _compileAll; - } - } - - //Private Methods - private void RemoveSchemaFromCaches(XmlSchema schema) - { - //Remove From ChameleonSchemas and schemaLocations cache - List reprocessList = new List(); - schema.GetExternalSchemasList(reprocessList, schema); - for (int i = 0; i < reprocessList.Count; ++i) - { //Remove schema from schemaLocations & chameleonSchemas tables - if (reprocessList[i].BaseUri != null && reprocessList[i].BaseUri.OriginalString.Length != 0) - { - _schemaLocations.Remove(reprocessList[i].BaseUri); - } - //Remove from chameleon table - ICollection chameleonKeys = _chameleonSchemas.Keys; - ArrayList removalList = new ArrayList(); - foreach (ChameleonKey cKey in chameleonKeys) - { - if (cKey.chameleonLocation.Equals(reprocessList[i].BaseUri)) - { - // The key will have the originalSchema set to null if the location was not empty - // otherwise we need to care about it as there may be more chameleon schemas without - // a base URI and we want to remove only those which were created as a clone of the one - // we're removing. - if (cKey.originalSchema == null || Ref.ReferenceEquals(cKey.originalSchema, reprocessList[i])) - { - removalList.Add(cKey); - } - } - } - for (int j = 0; j < removalList.Count; ++j) - { - _chameleonSchemas.Remove(removalList[j]); - } - } - } - - private void RemoveSchemaFromGlobalTables(XmlSchema schema) - { - if (_schemas.Count == 0) - { - return; - } - VerifyTables(); - foreach (XmlSchemaElement elementToRemove in schema.Elements.Values) - { - XmlSchemaElement elem = (XmlSchemaElement)elements[elementToRemove.QualifiedName]; - if (elem == elementToRemove) - { - elements.Remove(elementToRemove.QualifiedName); - } - } - foreach (XmlSchemaAttribute attributeToRemove in schema.Attributes.Values) - { - XmlSchemaAttribute attr = (XmlSchemaAttribute)attributes[attributeToRemove.QualifiedName]; - if (attr == attributeToRemove) - { - attributes.Remove(attributeToRemove.QualifiedName); - } - } - foreach (XmlSchemaType schemaTypeToRemove in schema.SchemaTypes.Values) - { - XmlSchemaType schemaType = (XmlSchemaType)schemaTypes[schemaTypeToRemove.QualifiedName]; - if (schemaType == schemaTypeToRemove) - { - schemaTypes.Remove(schemaTypeToRemove.QualifiedName); - } - } - } - private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) - { - if (qname.Name.Length == 0) - { - return true; - } - XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; - if (existingObject != null) - { - if (existingObject == item || existingObject.SourceUri == item.SourceUri) - { - return true; - } - string code = string.Empty; - if (item is XmlSchemaComplexType) - { - code = ResXml.Sch_DupComplexType; - } - else if (item is XmlSchemaSimpleType) - { - code = ResXml.Sch_DupSimpleType; - } - else if (item is XmlSchemaElement) - { - code = ResXml.Sch_DupGlobalElement; - } - else if (item is XmlSchemaAttribute) - { - if (qname.Namespace == XmlReservedNs.NsXml) - { - XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema(); - XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname]; - if (existingObject == builtInAttribute) - { //replace built-in one - table.Insert(qname, item); - return true; - } - else if (item == builtInAttribute) - { //trying to overwrite customer's component with built-in, ignore built-in - return true; - } - } - code = ResXml.Sch_DupGlobalAttribute; - } - SendValidationEvent(new XmlSchemaException(code, qname.ToString()), XmlSeverityType.Error); - return false; - } - else - { - table.Add(qname, item); - return true; - } - } - - private void VerifyTables() - { - if (elements == null) - { - elements = new XmlSchemaObjectTable(); - } - if (attributes == null) - { - attributes = new XmlSchemaObjectTable(); - } - if (schemaTypes == null) - { - schemaTypes = new XmlSchemaObjectTable(); - } - if (substitutionGroups == null) - { - substitutionGroups = new XmlSchemaObjectTable(); - } - } - - private void InternalValidationCallback(object sender, ValidationEventArgs e) - { - if (e.Severity == XmlSeverityType.Error) - { - throw e.Exception; - } - } - - private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) - { - if (_eventHandler != null) - { - _eventHandler(this, new ValidationEventArgs(e, severity)); - } - else - { - throw e; - } - } - }; -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContent.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContent.cs deleted file mode 100644 index 4e49c0b2593..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContent.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleContent : XmlSchemaContentModel - { - private XmlSchemaContent _content; - - /// - /// - /// [To be supplied.] - /// - [XmlElement("restriction", typeof(XmlSchemaSimpleContentRestriction)), - XmlElement("extension", typeof(XmlSchemaSimpleContentExtension))] - public override XmlSchemaContent Content - { - get { return _content; } - set { _content = value; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentExtension.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentExtension.cs deleted file mode 100644 index 83c911d388d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentExtension.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleContentExtension : XmlSchemaContent - { - private XmlSchemaObjectCollection _attributes = new XmlSchemaObjectCollection(); - private XmlSchemaAnyAttribute _anyAttribute; - private XmlQualifiedName _baseTypeName = XmlQualifiedName.Empty; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("base")] - public XmlQualifiedName BaseTypeName - { - get { return _baseTypeName; } - set { _baseTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get { return _attributes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - internal void SetAttributes(XmlSchemaObjectCollection newAttributes) - { - _attributes = newAttributes; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentRestriction.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentRestriction.cs deleted file mode 100644 index 9f25b002593..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleContentRestriction.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleContentRestriction : XmlSchemaContent - { - private XmlQualifiedName _baseTypeName = XmlQualifiedName.Empty; - private XmlSchemaSimpleType _baseType; - private XmlSchemaObjectCollection _facets = new XmlSchemaObjectCollection(); - private XmlSchemaObjectCollection _attributes = new XmlSchemaObjectCollection(); - private XmlSchemaAnyAttribute _anyAttribute; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("base")] - public XmlQualifiedName BaseTypeName - { - get { return _baseTypeName; } - set { _baseTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaSimpleType BaseType - { - get { return _baseType; } - set { _baseType = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("length", typeof(XmlSchemaLengthFacet)), - XmlElement("minLength", typeof(XmlSchemaMinLengthFacet)), - XmlElement("maxLength", typeof(XmlSchemaMaxLengthFacet)), - XmlElement("pattern", typeof(XmlSchemaPatternFacet)), - XmlElement("enumeration", typeof(XmlSchemaEnumerationFacet)), - XmlElement("maxInclusive", typeof(XmlSchemaMaxInclusiveFacet)), - XmlElement("maxExclusive", typeof(XmlSchemaMaxExclusiveFacet)), - XmlElement("minInclusive", typeof(XmlSchemaMinInclusiveFacet)), - XmlElement("minExclusive", typeof(XmlSchemaMinExclusiveFacet)), - XmlElement("totalDigits", typeof(XmlSchemaTotalDigitsFacet)), - XmlElement("fractionDigits", typeof(XmlSchemaFractionDigitsFacet)), - XmlElement("whiteSpace", typeof(XmlSchemaWhiteSpaceFacet))] - public XmlSchemaObjectCollection Facets - { - get { return _facets; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("attribute", typeof(XmlSchemaAttribute)), - XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroupRef))] - public XmlSchemaObjectCollection Attributes - { - get { return _attributes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("anyAttribute")] - public XmlSchemaAnyAttribute AnyAttribute - { - get { return _anyAttribute; } - set { _anyAttribute = value; } - } - - internal void SetAttributes(XmlSchemaObjectCollection newAttributes) - { - _attributes = newAttributes; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleType.cs deleted file mode 100644 index 3a30717712c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleType.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - using System.Diagnostics; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleType : XmlSchemaType - { - private XmlSchemaSimpleTypeContent _content; - - /// - /// - /// [To be supplied.] - /// - - public XmlSchemaSimpleType() - { - Debug.Assert(SchemaContentType == XmlSchemaContentType.TextOnly); - } - - /// - [XmlElement("restriction", typeof(XmlSchemaSimpleTypeRestriction)), - XmlElement("list", typeof(XmlSchemaSimpleTypeList)), - XmlElement("union", typeof(XmlSchemaSimpleTypeUnion))] - public XmlSchemaSimpleTypeContent Content - { - get { return _content; } - set { _content = value; } - } - - internal override XmlQualifiedName DerivedFrom - { - get - { - if (_content == null) - { - // type derived from anyType - return XmlQualifiedName.Empty; - } - if (_content is XmlSchemaSimpleTypeRestriction) - { - return ((XmlSchemaSimpleTypeRestriction)_content).BaseTypeName; - } - return XmlQualifiedName.Empty; - } - } - - internal override XmlSchemaObject Clone() - { - XmlSchemaSimpleType newSimpleType = (XmlSchemaSimpleType)MemberwiseClone(); - if (_content != null) - { - newSimpleType.Content = (XmlSchemaSimpleTypeContent)_content.Clone(); - } - return newSimpleType; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeContent.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeContent.cs deleted file mode 100644 index 8d57b8f8b5d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeContent.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - /// - /// [To be supplied.] - /// - public abstract class XmlSchemaSimpleTypeContent : XmlSchemaAnnotated - { - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeList.cs deleted file mode 100644 index 4a9fa9f4205..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeList.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleTypeList : XmlSchemaSimpleTypeContent - { - private XmlQualifiedName _itemTypeName = XmlQualifiedName.Empty; - private XmlSchemaSimpleType _itemType; - private XmlSchemaSimpleType _baseItemType; //Compiled - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("itemType")] - public XmlQualifiedName ItemTypeName - { - get { return _itemTypeName; } - set { _itemTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaSimpleType ItemType - { - get { return _itemType; } - set { _itemType = value; } - } - - //Compiled - /// - [XmlIgnore] - public XmlSchemaSimpleType BaseItemType - { - get { return _baseItemType; } - set { _baseItemType = value; } - } - - internal override XmlSchemaObject Clone() - { - XmlSchemaSimpleTypeList newList = (XmlSchemaSimpleTypeList)MemberwiseClone(); - newList.ItemTypeName = _itemTypeName.Clone(); - return newList; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeRestriction.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeRestriction.cs deleted file mode 100644 index 743611e35a5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeRestriction.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleTypeRestriction : XmlSchemaSimpleTypeContent - { - private XmlQualifiedName _baseTypeName = XmlQualifiedName.Empty; - private XmlSchemaSimpleType _baseType; - private XmlSchemaObjectCollection _facets = new XmlSchemaObjectCollection(); - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("base")] - public XmlQualifiedName BaseTypeName - { - get { return _baseTypeName; } - set { _baseTypeName = (value == null ? XmlQualifiedName.Empty : value); } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaSimpleType BaseType - { - get { return _baseType; } - set { _baseType = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("length", typeof(XmlSchemaLengthFacet)), - XmlElement("minLength", typeof(XmlSchemaMinLengthFacet)), - XmlElement("maxLength", typeof(XmlSchemaMaxLengthFacet)), - XmlElement("pattern", typeof(XmlSchemaPatternFacet)), - XmlElement("enumeration", typeof(XmlSchemaEnumerationFacet)), - XmlElement("maxInclusive", typeof(XmlSchemaMaxInclusiveFacet)), - XmlElement("maxExclusive", typeof(XmlSchemaMaxExclusiveFacet)), - XmlElement("minInclusive", typeof(XmlSchemaMinInclusiveFacet)), - XmlElement("minExclusive", typeof(XmlSchemaMinExclusiveFacet)), - XmlElement("totalDigits", typeof(XmlSchemaTotalDigitsFacet)), - XmlElement("fractionDigits", typeof(XmlSchemaFractionDigitsFacet)), - XmlElement("whiteSpace", typeof(XmlSchemaWhiteSpaceFacet))] - public XmlSchemaObjectCollection Facets - { - get { return _facets; } - } - - internal override XmlSchemaObject Clone() - { - XmlSchemaSimpleTypeRestriction newRestriction = (XmlSchemaSimpleTypeRestriction)MemberwiseClone(); - newRestriction.BaseTypeName = _baseTypeName.Clone(); - return newRestriction; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeUnion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeUnion.cs deleted file mode 100644 index f2b0c8e8678..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSimpleTypeUnion.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaSimpleTypeUnion : XmlSchemaSimpleTypeContent - { - private XmlSchemaObjectCollection _baseTypes = new XmlSchemaObjectCollection(); - private XmlQualifiedName[] _memberTypes; - private XmlSchemaSimpleType[] _baseMemberTypes; // Compiled - - /// - /// - /// [To be supplied.] - /// - [XmlElement("simpleType", typeof(XmlSchemaSimpleType))] - public XmlSchemaObjectCollection BaseTypes - { - get { return _baseTypes; } - } - - /// - [XmlAttribute("memberTypes")] - public XmlQualifiedName[] MemberTypes - { - get { return _memberTypes; } - set { _memberTypes = value; } - } - - //Compiled Information - /// - [XmlIgnore] - public XmlSchemaSimpleType[] BaseMemberTypes - { - get { return _baseMemberTypes; } - } - - internal void SetBaseMemberTypes(XmlSchemaSimpleType[] baseMemberTypes) - { - _baseMemberTypes = baseMemberTypes; - } - - internal override XmlSchemaObject Clone() - { - if (_memberTypes != null && _memberTypes.Length > 0) - { //Only if the union has MemberTypes defined - XmlSchemaSimpleTypeUnion newUnion = (XmlSchemaSimpleTypeUnion)MemberwiseClone(); - XmlQualifiedName[] newQNames = new XmlQualifiedName[_memberTypes.Length]; - - for (int i = 0; i < _memberTypes.Length; i++) - { - newQNames[i] = _memberTypes[i].Clone(); - } - newUnion.MemberTypes = newQNames; - return newUnion; - } - return this; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSubstitutionGroup.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSubstitutionGroup.cs deleted file mode 100644 index de872c3f5a9..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaSubstitutionGroup.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using Microsoft.Xml.Serialization; - - internal class XmlSchemaSubstitutionGroup : XmlSchemaObject - { - private ArrayList _membersList = new ArrayList(); - private XmlQualifiedName _examplar = XmlQualifiedName.Empty; - - [XmlIgnore] - internal ArrayList Members - { - get { return _membersList; } - } - - [XmlIgnore] - internal XmlQualifiedName Examplar - { - get { return _examplar; } - set { _examplar = value; } - } - } - - internal class XmlSchemaSubstitutionGroupV1Compat : XmlSchemaSubstitutionGroup - { - private XmlSchemaChoice _choice = new XmlSchemaChoice(); - - [XmlIgnore] - internal XmlSchemaChoice Choice - { - get { return _choice; } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaType.cs deleted file mode 100644 index 249b64d4bee..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaType.cs +++ /dev/null @@ -1,361 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using System.ComponentModel; -using Microsoft.Xml.Serialization; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - - /// - /// - /// [To be supplied.] - /// - public class XmlSchemaType : XmlSchemaAnnotated - { - private string _name; - private XmlSchemaDerivationMethod _final = XmlSchemaDerivationMethod.None; - private XmlSchemaDerivationMethod _derivedBy; - private XmlSchemaType _baseSchemaType; - private XmlSchemaDatatype _datatype; - private XmlSchemaDerivationMethod _finalResolved; - private volatile SchemaElementDecl _elementDecl; - private volatile XmlQualifiedName _qname = XmlQualifiedName.Empty; - private XmlSchemaType _redefined; - - //compiled information - private XmlSchemaContentType _contentType; - - /// - /// - /// [To be supplied.] - /// - public static XmlSchemaSimpleType GetBuiltInSimpleType(XmlQualifiedName qualifiedName) - { - if (qualifiedName == null) - { - throw new ArgumentNullException("qualifiedName"); - } - return DatatypeImplementation.GetSimpleTypeFromXsdType(qualifiedName); - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchemaSimpleType GetBuiltInSimpleType(XmlTypeCode typeCode) - { - return DatatypeImplementation.GetSimpleTypeFromTypeCode(typeCode); - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchemaComplexType GetBuiltInComplexType(XmlTypeCode typeCode) - { - if (typeCode == XmlTypeCode.Item) - { - return XmlSchemaComplexType.AnyType; - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchemaComplexType GetBuiltInComplexType(XmlQualifiedName qualifiedName) - { - if (qualifiedName == null) - { - throw new ArgumentNullException("qualifiedName"); - } - if (qualifiedName.Equals(XmlSchemaComplexType.AnyType.QualifiedName)) - { - return XmlSchemaComplexType.AnyType; - } - if (qualifiedName.Equals(XmlSchemaComplexType.UntypedAnyType.QualifiedName)) - { - return XmlSchemaComplexType.UntypedAnyType; - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("final"), DefaultValue(XmlSchemaDerivationMethod.None)] - public XmlSchemaDerivationMethod Final - { - get { return _final; } - set { _final = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlQualifiedName QualifiedName - { - get { return _qname; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDerivationMethod FinalResolved - { - get { return _finalResolved; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - [Obsolete("This property has been deprecated. Please use BaseXmlSchemaType property that returns a strongly typed base schema type. http://go.microsoft.com/fwlink/?linkid=14202")] - public object BaseSchemaType - { - get - { - if (_baseSchemaType == null) - return null; - - if (_baseSchemaType.QualifiedName.Namespace == XmlReservedNs.NsXs) - { - return _baseSchemaType.Datatype; - } - return _baseSchemaType; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaType BaseXmlSchemaType - { - get { return _baseSchemaType; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDerivationMethod DerivedBy - { - get { return _derivedBy; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public XmlSchemaDatatype Datatype - { - get { return _datatype; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public virtual bool IsMixed - { - get { return false; } - set {; } - } - - [XmlIgnore] - public XmlTypeCode TypeCode - { - get - { - if (this == XmlSchemaComplexType.AnyType) - { - return XmlTypeCode.Item; - } - if (_datatype == null) - { - return XmlTypeCode.None; - } - return _datatype.TypeCode; - } - } - - [XmlIgnore] - internal XmlValueConverter ValueConverter - { - get - { - if (_datatype == null) - { //Default converter - return XmlUntypedConverter.Untyped; - } - return _datatype.ValueConverter; - } - } - - internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler) - { - if (schemaSet != null) - { - XmlReaderSettings readerSettings = new XmlReaderSettings(); - readerSettings.ValidationType = ValidationType.Schema; - readerSettings.Schemas = schemaSet; - readerSettings.ValidationEventHandler += valEventHandler; - return new XsdValidatingReader(reader, resolver, readerSettings, this); - } - return null; - } - - internal XmlSchemaContentType SchemaContentType - { - get - { - return _contentType; - } - } - - internal void SetQualifiedName(XmlQualifiedName value) - { - _qname = value; - } - - internal void SetFinalResolved(XmlSchemaDerivationMethod value) - { - _finalResolved = value; - } - - internal void SetBaseSchemaType(XmlSchemaType value) - { - _baseSchemaType = value; - } - - internal void SetDerivedBy(XmlSchemaDerivationMethod value) - { - _derivedBy = value; - } - - internal void SetDatatype(XmlSchemaDatatype value) - { - _datatype = value; - } - - internal SchemaElementDecl ElementDecl - { - get { return _elementDecl; } - set { _elementDecl = value; } - } - - [XmlIgnore] - internal XmlSchemaType Redefined - { - get { return _redefined; } - set { _redefined = value; } - } - - internal virtual XmlQualifiedName DerivedFrom - { - get { return XmlQualifiedName.Empty; } - } - - internal void SetContentType(XmlSchemaContentType value) - { - _contentType = value; - } - - public static bool IsDerivedFrom(XmlSchemaType derivedType, XmlSchemaType baseType, XmlSchemaDerivationMethod except) - { - if (derivedType == null || baseType == null) - { - return false; - } - - if (derivedType == baseType) - { - return true; - } - - if (baseType == XmlSchemaComplexType.AnyType) - { //Not checking for restriction blocked since all types are implicitly derived by restriction from xs:anyType - return true; - } - do - { - XmlSchemaSimpleType dt = derivedType as XmlSchemaSimpleType; - XmlSchemaSimpleType bt = baseType as XmlSchemaSimpleType; - if (bt != null && dt != null) - { //SimpleTypes - if (bt == DatatypeImplementation.AnySimpleType) - { //Not checking block=restriction - return true; - } - if ((except & derivedType.DerivedBy) != 0 || !dt.Datatype.IsDerivedFrom(bt.Datatype)) - { - return false; - } - return true; - } - else - { //Complex types - if ((except & derivedType.DerivedBy) != 0) - { - return false; - } - derivedType = derivedType.BaseXmlSchemaType; - if (derivedType == baseType) - { - return true; - } - } - } while (derivedType != null); - - return false; - } - - - internal static bool IsDerivedFromDatatype(XmlSchemaDatatype derivedDataType, XmlSchemaDatatype baseDataType, XmlSchemaDerivationMethod except) - { - if (DatatypeImplementation.AnySimpleType.Datatype == baseDataType) - { - return true; - } - return derivedDataType.IsDerivedFrom(baseDataType); - } - - [XmlIgnore] - internal override string NameAttribute - { - get { return Name; } - set { Name = value; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaUse.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaUse.cs deleted file mode 100644 index 1557d1d0f29..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaUse.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using Microsoft.Xml.Serialization; - - //nzeng: if change the enum, have to change xsdbuilder as well. - /// - /// - /// [To be supplied.] - /// - public enum XmlSchemaUse - { - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - None, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("optional")] - Optional, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("prohibited")] - Prohibited, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("required")] - Required, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidationException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidationException.cs deleted file mode 100644 index 7f5aab576f6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidationException.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.IO; - using System.Text; - using System.Resources; - using System.Diagnostics; - // using System.Security.Permissions; - - /// - // [Serializable], - public class XmlSchemaValidationException : XmlSchemaException - { - private Object _sourceNodeObject; - - /// - public XmlSchemaValidationException() : base(null) - { - } - - /// - public XmlSchemaValidationException(String message) : base(message, ((Exception)null), 0, 0) - { - } - - /// - public XmlSchemaValidationException(String message, Exception innerException) : base(message, innerException, 0, 0) - { - } - - /// - public XmlSchemaValidationException(String message, Exception innerException, int lineNumber, int linePosition) : - base(message, innerException, lineNumber, linePosition) - { - } - - internal XmlSchemaValidationException(string res, string[] args) : base(res, args, null, null, 0, 0, null) - { - } - - internal XmlSchemaValidationException(string res, string arg) : base(res, new string[] { arg }, null, null, 0, 0, null) - { - } - - internal XmlSchemaValidationException(string res, string arg, string sourceUri, int lineNumber, int linePosition) : - base(res, new string[] { arg }, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaValidationException(string res, string sourceUri, int lineNumber, int linePosition) : - base(res, (string[])null, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaValidationException(string res, string[] args, string sourceUri, int lineNumber, int linePosition) : - base(res, args, null, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaValidationException(string res, string[] args, Exception innerException, string sourceUri, int lineNumber, int linePosition) : - base(res, args, innerException, sourceUri, lineNumber, linePosition, null) - { - } - - internal XmlSchemaValidationException(string res, string[] args, object sourceNode) : - base(res, args, null, null, 0, 0, null) - { - _sourceNodeObject = sourceNode; - } - - internal XmlSchemaValidationException(string res, string[] args, string sourceUri, object sourceNode) : - base(res, args, null, sourceUri, 0, 0, null) - { - _sourceNodeObject = sourceNode; - } - - internal XmlSchemaValidationException(string res, string[] args, string sourceUri, int lineNumber, int linePosition, XmlSchemaObject source, object sourceNode) : - base(res, args, null, sourceUri, lineNumber, linePosition, source) - { - _sourceNodeObject = sourceNode; - } - - /// - public Object SourceObject - { - get { return _sourceNodeObject; } - } - - protected internal void SetSourceObject(Object sourceObject) - { - _sourceNodeObject = sourceObject; - } - }; -} // namespace Microsoft.Xml.Schema - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidator.cs deleted file mode 100644 index 445954c1930..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidator.cs +++ /dev/null @@ -1,2900 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Diagnostics; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.XPath; -using System.Threading; -using System.Runtime.Versioning; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - public delegate object XmlValueGetter(); - - [Flags] - public enum XmlSchemaValidationFlags - { - None = 0x0000, - ProcessInlineSchema = 0x0001, - ProcessSchemaLocation = 0x0002, - ReportValidationWarnings = 0x0004, - ProcessIdentityConstraints = 0x0008, - AllowXmlAttributes = 0x0010, - } - - internal enum ValidatorState - { - None, - Start, - TopLevelAttribute, - TopLevelTextOrWS, - Element, - Attribute, - EndOfAttributes, - Text, - Whitespace, - EndElement, - SkipToEndElement, - Finish, - } - internal class IdRefNode - { - internal string Id; - internal int LineNo; - internal int LinePos; - internal IdRefNode Next; - - internal IdRefNode(IdRefNode next, string id, int lineNo, int linePos) - { - this.Id = id; - this.LineNo = lineNo; - this.LinePos = linePos; - this.Next = next; - } - } - - public sealed class XmlSchemaValidator - { - //Schema Set - private XmlSchemaSet _schemaSet; - - //Validation Settings - private XmlSchemaValidationFlags _validationFlags; - - //Validation - private int _startIDConstraint = -1; - private const int STACK_INCREMENT = 10; - private bool _isRoot; - private bool _rootHasSchema; - - //PSVI - private bool _attrValid; - private bool _checkEntity; - - private SchemaInfo _compiledSchemaInfo; - private IDtdInfo _dtdSchemaInfo; - private Hashtable _validatedNamespaces; - - private HWStack _validationStack; // validaton contexts - private ValidationState _context; // current context - private ValidatorState _currentState; - - //Attributes & IDS - private Hashtable _attPresence; //(AttName Vs AttIndex) - private SchemaAttDef _wildID; - - private Hashtable _IDs; - private IdRefNode _idRefListHead; - - //Parsing - private XmlQualifiedName _contextQName; - - //Avoid SchemaNames creation - private string _nsXs; - private string _nsXsi; - private string _nsXmlNs; - private string _nsXml; - - //PartialValidation - private XmlSchemaObject _partialValidationType; - - //text to typedValue - private StringBuilder _textValue; - - //Other state - private ValidationEventHandler _eventHandler; - private object _validationEventSender; - private XmlNameTable _nameTable; - private IXmlLineInfo _positionInfo; - private IXmlLineInfo _dummyPositionInfo; - - private XmlResolver _xmlResolver; - private Uri _sourceUri; - private string _sourceUriString; - private IXmlNamespaceResolver _nsResolver; - - private XmlSchemaContentProcessing _processContents = XmlSchemaContentProcessing.Strict; - - private static XmlSchemaAttribute s_xsiTypeSO; - private static XmlSchemaAttribute s_xsiNilSO; - private static XmlSchemaAttribute s_xsiSLSO; - private static XmlSchemaAttribute s_xsiNoNsSLSO; - - //Xsi Attributes that are atomized - private string _xsiTypeString; - private string _xsiNilString; - private string _xsiSchemaLocationString; - private string _xsiNoNamespaceSchemaLocationString; - - //Xsi Attributes parsing - private static readonly XmlSchemaDatatype s_dtQName = XmlSchemaDatatype.FromXmlTokenizedTypeXsd(XmlTokenizedType.QName); - private static readonly XmlSchemaDatatype s_dtCDATA = XmlSchemaDatatype.FromXmlTokenizedType(XmlTokenizedType.CDATA); - private static readonly XmlSchemaDatatype s_dtStringArray = s_dtCDATA.DeriveByList(null); - - //Error message constants - private const string Quote = "'"; - - //Empty arrays - private static XmlSchemaParticle[] s_emptyParticleArray = new XmlSchemaParticle[0]; - private static XmlSchemaAttribute[] s_emptyAttributeArray = new XmlSchemaAttribute[0]; - - //Whitespace check for text nodes - private XmlCharType _xmlCharType = XmlCharType.Instance; - - internal static bool[,] ValidStates = new bool[12, 12] { - /*ValidatorState.None*/ /*ValidatorState.Start /*ValidatorState.TopLevelAttribute*/ /*ValidatorState.TopLevelTOrWS*/ /*ValidatorState.Element*/ /*ValidatorState.Attribute*/ /*ValidatorState.EndAttributes*/ /*ValidatorState.Text/ /*ValidatorState.WS/* /*ValidatorState.EndElement*/ /*ValidatorState.SkipToEndElement*/ /*ValidatorState.Finish*/ - /*ValidatorState.None*/ { true, true, false, false, false, false, false, false, false, false, false, false}, - /*ValidatorState.Start*/ { false, true, true, true, true, false, false, false, false, false, false, true }, - /*ValidatorState.TopLevelAttribute*/{ false, false, false, false, false, false, false, false, false, false, false, true }, - /*ValidatorState.TopLevelTextOrWS*/ { false, false, false, true, true, false, false, false, false, false, false, true }, - /*ValidatorState.Element*/ { false, false, false, true, false, true, true, false, false, true, true, false}, - /*ValidatorState.Attribute*/ { false, false, false, false, false, true, true, false, false, true, true, false}, - /*ValidatorState.EndAttributes*/ { false, false, false, false, true, false, false, true, true, true, true, false}, - /*ValidatorState.Text*/ { false, false, false, false, true, false, false, true, true, true, true, false}, - /*ValidatorState.Whitespace*/ { false, false, false, false, true, false, false, true, true, true, true, false}, - /*ValidatorState.EndElement*/ { false, false, false, true, true, false, false, true, true, true, true /*?*/, true }, - /*ValidatorState.SkipToEndElement*/ { false, false, false, true, true, false, false, true, true, true, true, true }, - /*ValidatorState.Finish*/ { false, true, false, false, false, false, false, false, false, false, false, false}, - }; - - private static string[] s_methodNames = new string[12] { "None", "Initialize", "top-level ValidateAttribute", "top-level ValidateText or ValidateWhitespace", "ValidateElement", "ValidateAttribute", "ValidateEndOfAttributes", "ValidateText", "ValidateWhitespace", "ValidateEndElement", "SkipToEndElement", "EndValidation" }; - - public XmlSchemaValidator(XmlNameTable nameTable, XmlSchemaSet schemas, IXmlNamespaceResolver namespaceResolver, XmlSchemaValidationFlags validationFlags) - { - if (nameTable == null) - { - throw new ArgumentNullException("nameTable"); - } - if (schemas == null) - { - throw new ArgumentNullException("schemas"); - } - if (namespaceResolver == null) - { - throw new ArgumentNullException("namespaceResolver"); - } - _nameTable = nameTable; - _nsResolver = namespaceResolver; - _validationFlags = validationFlags; - - - if (((validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != 0) || ((validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != 0)) - { //Process schema hints in xml document, hence user's set might change - _schemaSet = new XmlSchemaSet(nameTable); - _schemaSet.ValidationEventHandler += schemas.GetEventHandler(); - _schemaSet.CompilationSettings = schemas.CompilationSettings; - _schemaSet.XmlResolver = schemas.GetResolver(); - _schemaSet.Add(schemas); - _validatedNamespaces = new Hashtable(); - } - else - { //Use the same set from the user - _schemaSet = schemas; - } - Init(); - } - - private void Init() - { - _validationStack = new HWStack(STACK_INCREMENT); - _attPresence = new Hashtable(); - Push(XmlQualifiedName.Empty); - - _dummyPositionInfo = new PositionInfo(); //Dummy position info, will return (0,0) if user does not set the LineInfoProvider property - _positionInfo = _dummyPositionInfo; - _validationEventSender = this; - _currentState = ValidatorState.None; - _textValue = new StringBuilder(100); - _xmlResolver = Microsoft.Xml.XmlConfiguration.XmlReaderSection.CreateDefaultResolver(); - _contextQName = new XmlQualifiedName(); //Re-use qname - Reset(); - - RecompileSchemaSet(); //Gets compiled info from set as well - //Get already Atomized strings - _nsXs = _nameTable.Add(XmlReservedNs.NsXs); - _nsXsi = _nameTable.Add(XmlReservedNs.NsXsi); - _nsXmlNs = _nameTable.Add(XmlReservedNs.NsXmlNs); - _nsXml = _nameTable.Add(XmlReservedNs.NsXml); - _xsiTypeString = _nameTable.Add("type"); - _xsiNilString = _nameTable.Add("nil"); - _xsiSchemaLocationString = _nameTable.Add("schemaLocation"); - _xsiNoNamespaceSchemaLocationString = _nameTable.Add("noNamespaceSchemaLocation"); - } - - private void Reset() - { - _isRoot = true; - _rootHasSchema = true; - while (_validationStack.Length > 1) - { //Clear all other context from stack - _validationStack.Pop(); - } - _startIDConstraint = -1; - _partialValidationType = null; - - //Clear previous tables - if (_IDs != null) - { - _IDs.Clear(); - } - if (ProcessSchemaHints) - { - _validatedNamespaces.Clear(); - } - } - - //Properties - public XmlResolver XmlResolver - { - set - { - _xmlResolver = value; - } - } - - public IXmlLineInfo LineInfoProvider - { - get - { - return _positionInfo; - } - set - { - if (value == null) - { //If value is null, retain the default dummy line info - _positionInfo = _dummyPositionInfo; - } - else - { - _positionInfo = value; - } - } - } - - public Uri SourceUri - { - get - { - return _sourceUri; - } - set - { - _sourceUri = value; - _sourceUriString = _sourceUri.ToString(); - } - } - - public object ValidationEventSender - { - get - { - return _validationEventSender; - } - set - { - _validationEventSender = value; - } - } - - public event ValidationEventHandler ValidationEventHandler - { - add - { - _eventHandler += value; - } - remove - { - _eventHandler -= value; - } - } - - //Methods - - public void AddSchema(XmlSchema schema) - { - if (schema == null) - { - throw new ArgumentNullException("schema"); - } - if ((_validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) == 0) - { //Do not process schema if processInlineSchema is not set - return; - } - string tns = schema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - //Store the previous locations - Hashtable schemaLocations = _schemaSet.SchemaLocations; - DictionaryEntry[] oldLocations = new DictionaryEntry[schemaLocations.Count]; - schemaLocations.CopyTo(oldLocations, 0); - - //TODO should i not error if SOM reference same as one in the set or should i assume that inline schema will always be a new SOM ref - Debug.Assert(_validatedNamespaces != null); - if (_validatedNamespaces[tns] != null && _schemaSet.FindSchemaByNSAndUrl(schema.BaseUri, tns, oldLocations) == null) - { - SendValidationEvent(ResXml.Sch_ComponentAlreadySeenForNS, tns, XmlSeverityType.Error); - } - if (schema.ErrorCount == 0) - { - try - { - _schemaSet.Add(schema); - RecompileSchemaSet(); - } - catch (XmlSchemaException e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { schema.BaseUri.ToString(), e.Message }, e); - } - for (int i = 0; i < schema.ImportedSchemas.Count; ++i) - { //Check for its imports - XmlSchema impSchema = (XmlSchema)schema.ImportedSchemas[i]; - tns = impSchema.TargetNamespace; - if (tns == null) - { - tns = string.Empty; - } - if (_validatedNamespaces[tns] != null && _schemaSet.FindSchemaByNSAndUrl(impSchema.BaseUri, tns, oldLocations) == null) - { - SendValidationEvent(ResXml.Sch_ComponentAlreadySeenForNS, tns, XmlSeverityType.Error); - _schemaSet.RemoveRecursive(schema); - break; - } - } - } - } - - public void Initialize() - { - if (_currentState != ValidatorState.None && _currentState != ValidatorState.Finish) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidStateTransition, new string[] { s_methodNames[(int)_currentState], s_methodNames[(int)ValidatorState.Start] })); - } - _currentState = ValidatorState.Start; - Reset(); - } - - public void Initialize(XmlSchemaObject partialValidationType) - { - if (_currentState != ValidatorState.None && _currentState != ValidatorState.Finish) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidStateTransition, new string[] { s_methodNames[(int)_currentState], s_methodNames[(int)ValidatorState.Start] })); - } - if (partialValidationType == null) - { - throw new ArgumentNullException("partialValidationType"); - } - if (!(partialValidationType is XmlSchemaElement || partialValidationType is XmlSchemaAttribute || partialValidationType is XmlSchemaType)) - { - throw new ArgumentException(ResXml.Sch_InvalidPartialValidationType); - } - _currentState = ValidatorState.Start; - Reset(); - _partialValidationType = partialValidationType; - } - - // SxS: This method passes null as resource names and does not expose any resources to the caller. - // It's OK to disable the SxS warning. - - - public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo) - { - ValidateElement(localName, namespaceUri, schemaInfo, null, null, null, null); - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo, string xsiType, string xsiNil, string xsiSchemaLocation, string xsiNoNamespaceSchemaLocation) - { - if (localName == null) - { - throw new ArgumentNullException("localName"); - } - if (namespaceUri == null) - { - throw new ArgumentNullException("namespaceUri"); - } - - CheckStateTransition(ValidatorState.Element, s_methodNames[(int)ValidatorState.Element]); - - ClearPSVI(); - _contextQName.Init(localName, namespaceUri); - XmlQualifiedName elementName = _contextQName; - - bool invalidElementInContext; - object particle = ValidateElementContext(elementName, out invalidElementInContext); //Check element name is allowed in current position - SchemaElementDecl elementDecl = FastGetElementDecl(elementName, particle); - - //Change context to current element and update element decl - Push(elementName); - - //Change current context's error state depending on whether this element was validated in its context correctly - if (invalidElementInContext) - { - _context.Validity = XmlSchemaValidity.Invalid; - } - - //Check if there are Xsi attributes - if ((_validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != 0 && _xmlResolver != null) - { //we should process schema location - ProcessSchemaLocations(xsiSchemaLocation, xsiNoNamespaceSchemaLocation); - } - - if (_processContents != XmlSchemaContentProcessing.Skip) - { - if (elementDecl == null && _partialValidationType == null) - { //Since new schemaLocations might have been added, try for decl from the set again only if no PVType is set - elementDecl = _compiledSchemaInfo.GetElementDecl(elementName); - } - bool declFound = elementDecl != null; - if (xsiType != null || xsiNil != null) - { - elementDecl = CheckXsiTypeAndNil(elementDecl, xsiType, xsiNil, ref declFound); - } - if (elementDecl == null) - { - ThrowDeclNotFoundWarningOrError(declFound); //This updates processContents - } - } - - _context.ElementDecl = elementDecl; - XmlSchemaElement localSchemaElement = null; - XmlSchemaType localSchemaType = null; - if (elementDecl != null) - { - CheckElementProperties(); - _attPresence.Clear(); //Clear attributes hashtable for every element - _context.NeedValidateChildren = _processContents != XmlSchemaContentProcessing.Skip; - ValidateStartElementIdentityConstraints(); //Need attr collection validated here - elementDecl.ContentValidator.InitValidation(_context); - - localSchemaType = elementDecl.SchemaType; - localSchemaElement = GetSchemaElement(); - } - - if (schemaInfo != null) - { - schemaInfo.SchemaType = localSchemaType; - schemaInfo.SchemaElement = localSchemaElement; - schemaInfo.IsNil = _context.IsNill; - schemaInfo.Validity = _context.Validity; - } - if (ProcessSchemaHints) - { - if (_validatedNamespaces[namespaceUri] == null) - { - _validatedNamespaces.Add(namespaceUri, namespaceUri); - } - } - - if (_isRoot) - { - _isRoot = false; - } - } - - public object ValidateAttribute(string localName, string namespaceUri, string attributeValue, XmlSchemaInfo schemaInfo) - { - if (attributeValue == null) - { - throw new ArgumentNullException("attributeValue"); - } - return ValidateAttribute(localName, namespaceUri, null, attributeValue, schemaInfo); - } - - public object ValidateAttribute(string localName, string namespaceUri, XmlValueGetter attributeValue, XmlSchemaInfo schemaInfo) - { - if (attributeValue == null) - { - throw new ArgumentNullException("attributeValue"); - } - return ValidateAttribute(localName, namespaceUri, attributeValue, null, schemaInfo); - } - - private object ValidateAttribute(string lName, string ns, XmlValueGetter attributeValueGetter, string attributeStringValue, XmlSchemaInfo schemaInfo) - { - if (lName == null) - { - throw new ArgumentNullException("localName"); - } - if (ns == null) - { - throw new ArgumentNullException("namespaceUri"); - } - - ValidatorState toState = _validationStack.Length > 1 ? ValidatorState.Attribute : ValidatorState.TopLevelAttribute; - CheckStateTransition(toState, s_methodNames[(int)toState]); - - object typedVal = null; - _attrValid = true; - XmlSchemaValidity localValidity = XmlSchemaValidity.NotKnown; - XmlSchemaAttribute localAttribute = null; - XmlSchemaSimpleType localMemberType = null; - - ns = _nameTable.Add(ns); - if (Ref.Equal(ns, _nsXmlNs)) - { - return null; - } - - SchemaAttDef attributeDef = null; - SchemaElementDecl currentElementDecl = _context.ElementDecl; - XmlQualifiedName attQName = new XmlQualifiedName(lName, ns); - if (_attPresence[attQName] != null) - { //this attribute already checked as it is duplicate; - SendValidationEvent(ResXml.Sch_DuplicateAttribute, attQName.ToString()); - if (schemaInfo != null) - { - schemaInfo.Clear(); - } - return null; - } - - if (!Ref.Equal(ns, _nsXsi)) - { //TODO add xmlns check here - XmlSchemaObject pvtAttribute = _currentState == ValidatorState.TopLevelAttribute ? _partialValidationType : null; - AttributeMatchState attributeMatchState; - attributeDef = _compiledSchemaInfo.GetAttributeXsd(currentElementDecl, attQName, pvtAttribute, out attributeMatchState); - - switch (attributeMatchState) - { - case AttributeMatchState.UndeclaredElementAndAttribute: - if ((attributeDef = CheckIsXmlAttribute(attQName)) != null) - { //Try for xml attribute - goto case AttributeMatchState.AttributeFound; - } - if (currentElementDecl == null - && _processContents == XmlSchemaContentProcessing.Strict - && attQName.Namespace.Length != 0 - && _compiledSchemaInfo.Contains(attQName.Namespace) - ) - { - _attrValid = false; - SendValidationEvent(ResXml.Sch_UndeclaredAttribute, attQName.ToString()); - } - else if (_processContents != XmlSchemaContentProcessing.Skip) - { - SendValidationEvent(ResXml.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning); - } - break; - - case AttributeMatchState.UndeclaredAttribute: - if ((attributeDef = CheckIsXmlAttribute(attQName)) != null) - { - goto case AttributeMatchState.AttributeFound; - } - else - { - _attrValid = false; - SendValidationEvent(ResXml.Sch_UndeclaredAttribute, attQName.ToString()); - } - break; - - case AttributeMatchState.ProhibitedAnyAttribute: - if ((attributeDef = CheckIsXmlAttribute(attQName)) != null) - { - goto case AttributeMatchState.AttributeFound; - } - else - { - _attrValid = false; - SendValidationEvent(ResXml.Sch_ProhibitedAttribute, attQName.ToString()); - } - break; - - case AttributeMatchState.ProhibitedAttribute: - _attrValid = false; - SendValidationEvent(ResXml.Sch_ProhibitedAttribute, attQName.ToString()); - break; - - case AttributeMatchState.AttributeNameMismatch: - _attrValid = false; - SendValidationEvent(ResXml.Sch_SchemaAttributeNameMismatch, new string[] { attQName.ToString(), ((XmlSchemaAttribute)pvtAttribute).QualifiedName.ToString() }); - break; - - case AttributeMatchState.ValidateAttributeInvalidCall: - Debug.Assert(_currentState == ValidatorState.TopLevelAttribute); //Re-set state back to start on error with partial validation type - _currentState = ValidatorState.Start; - _attrValid = false; - SendValidationEvent(ResXml.Sch_ValidateAttributeInvalidCall, string.Empty); - break; - - case AttributeMatchState.AnyIdAttributeFound: - if (_wildID == null) - { - _wildID = attributeDef; - Debug.Assert(currentElementDecl != null); - XmlSchemaComplexType ct = currentElementDecl.SchemaType as XmlSchemaComplexType; - Debug.Assert(ct != null); - if (ct.ContainsIdAttribute(false)) - { - SendValidationEvent(ResXml.Sch_AttrUseAndWildId, string.Empty); - } - else - { - goto case AttributeMatchState.AttributeFound; - } - } - else - { //More than one attribute per element cannot match wildcard if both their types are derived from ID - SendValidationEvent(ResXml.Sch_MoreThanOneWildId, string.Empty); - } - break; - - case AttributeMatchState.AttributeFound: - Debug.Assert(attributeDef != null); - localAttribute = attributeDef.SchemaAttribute; - if (currentElementDecl != null) - { //Have to add to hashtable to check whether to add default attributes - _attPresence.Add(attQName, attributeDef); - } - object attValue; - if (attributeValueGetter != null) - { - attValue = attributeValueGetter(); - } - else - { - attValue = attributeStringValue; - } - typedVal = CheckAttributeValue(attValue, attributeDef); - XmlSchemaDatatype datatype = attributeDef.Datatype; - if (datatype.Variety == XmlSchemaDatatypeVariety.Union && typedVal != null) - { //Unpack the union - XsdSimpleValue simpleValue = typedVal as XsdSimpleValue; - Debug.Assert(simpleValue != null); - - localMemberType = simpleValue.XmlType; - datatype = simpleValue.XmlType.Datatype; - typedVal = simpleValue.TypedValue; - } - CheckTokenizedTypes(datatype, typedVal, true); - if (HasIdentityConstraints) - { - AttributeIdentityConstraints(attQName.Name, attQName.Namespace, typedVal, attValue.ToString(), datatype); - } - break; - - case AttributeMatchState.AnyAttributeLax: - SendValidationEvent(ResXml.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning); - break; - - case AttributeMatchState.AnyAttributeSkip: - break; - - default: - break; - } - } - else - { //Attribute from xsi namespace - lName = _nameTable.Add(lName); - if (Ref.Equal(lName, _xsiTypeString) || Ref.Equal(lName, _xsiNilString) || Ref.Equal(lName, _xsiSchemaLocationString) || Ref.Equal(lName, _xsiNoNamespaceSchemaLocationString)) - { - _attPresence.Add(attQName, SchemaAttDef.Empty); - } - else - { - _attrValid = false; - SendValidationEvent(ResXml.Sch_NotXsiAttribute, attQName.ToString()); - } - } - - if (!_attrValid) - { - localValidity = XmlSchemaValidity.Invalid; - } - else if (attributeDef != null) - { - localValidity = XmlSchemaValidity.Valid; - } - if (schemaInfo != null) - { - schemaInfo.SchemaAttribute = localAttribute; - schemaInfo.SchemaType = localAttribute == null ? null : localAttribute.AttributeSchemaType; - schemaInfo.MemberType = localMemberType; - schemaInfo.IsDefault = false; - schemaInfo.Validity = localValidity; - } - if (ProcessSchemaHints) - { - if (_validatedNamespaces[ns] == null) - { - _validatedNamespaces.Add(ns, ns); - } - } - return typedVal; - } - - public void GetUnspecifiedDefaultAttributes(ArrayList defaultAttributes) - { - if (defaultAttributes == null) - { - throw new ArgumentNullException("defaultAttributes"); - } - CheckStateTransition(ValidatorState.Attribute, "GetUnspecifiedDefaultAttributes"); - GetUnspecifiedDefaultAttributes(defaultAttributes, false); - } - - public void ValidateEndOfAttributes(XmlSchemaInfo schemaInfo) - { - CheckStateTransition(ValidatorState.EndOfAttributes, s_methodNames[(int)ValidatorState.EndOfAttributes]); - //Check required attributes - SchemaElementDecl currentElementDecl = _context.ElementDecl; - if (currentElementDecl != null && currentElementDecl.HasRequiredAttribute) - { - _context.CheckRequiredAttribute = false; - CheckRequiredAttributes(currentElementDecl); - } - if (schemaInfo != null) - { //set validity depending on whether all required attributes were validated successfully - schemaInfo.Validity = _context.Validity; - } - } - - public void ValidateText(string elementValue) - { - if (elementValue == null) - { - throw new ArgumentNullException("elementValue"); - } - ValidateText(elementValue, null); - } - - public void ValidateText(XmlValueGetter elementValue) - { - if (elementValue == null) - { - throw new ArgumentNullException("elementValue"); - } - ValidateText(null, elementValue); - } - - private void ValidateText(string elementStringValue, XmlValueGetter elementValueGetter) - { - ValidatorState toState = _validationStack.Length > 1 ? ValidatorState.Text : ValidatorState.TopLevelTextOrWS; - CheckStateTransition(toState, s_methodNames[(int)toState]); - - if (_context.NeedValidateChildren) - { - if (_context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, QNameString(_context.LocalName, _context.Namespace)); - return; - } - XmlSchemaContentType contentType = _context.ElementDecl.ContentValidator.ContentType; - switch (contentType) - { - case XmlSchemaContentType.Empty: - SendValidationEvent(ResXml.Sch_InvalidTextInEmpty, string.Empty); - break; - - case XmlSchemaContentType.TextOnly: - if (elementValueGetter != null) - { - SaveTextValue(elementValueGetter()); - } - else - { - SaveTextValue(elementStringValue); - } - break; - - case XmlSchemaContentType.ElementOnly: - string textValue = elementValueGetter != null ? elementValueGetter().ToString() : elementStringValue; - if (_xmlCharType.IsOnlyWhitespace(textValue)) - { - break; - } - ArrayList names = _context.ElementDecl.ContentValidator.ExpectedParticles(_context, false, _schemaSet); - if (names == null || names.Count == 0) - { - SendValidationEvent(ResXml.Sch_InvalidTextInElement, BuildElementName(_context.LocalName, _context.Namespace)); - } - else - { - Debug.Assert(names.Count > 0); - SendValidationEvent(ResXml.Sch_InvalidTextInElementExpecting, new string[] { BuildElementName(_context.LocalName, _context.Namespace), PrintExpectedElements(names, true) }); - } - break; - - case XmlSchemaContentType.Mixed: - if (_context.ElementDecl.DefaultValueTyped != null) - { - if (elementValueGetter != null) - { - SaveTextValue(elementValueGetter()); - } - else - { - SaveTextValue(elementStringValue); - } - } - break; - } - } - } - - public void ValidateWhitespace(string elementValue) - { - if (elementValue == null) - { - throw new ArgumentNullException("elementValue"); - } - ValidateWhitespace(elementValue, null); - } - - public void ValidateWhitespace(XmlValueGetter elementValue) - { - if (elementValue == null) - { - throw new ArgumentNullException("elementValue"); - } - ValidateWhitespace(null, elementValue); - } - - private void ValidateWhitespace(string elementStringValue, XmlValueGetter elementValueGetter) - { - ValidatorState toState = _validationStack.Length > 1 ? ValidatorState.Whitespace : ValidatorState.TopLevelTextOrWS; - CheckStateTransition(toState, s_methodNames[(int)toState]); - - if (_context.NeedValidateChildren) - { - if (_context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, QNameString(_context.LocalName, _context.Namespace)); - } - XmlSchemaContentType contentType = _context.ElementDecl.ContentValidator.ContentType; - switch (contentType) - { - case XmlSchemaContentType.Empty: - SendValidationEvent(ResXml.Sch_InvalidWhitespaceInEmpty, string.Empty); - break; - - case XmlSchemaContentType.TextOnly: - if (elementValueGetter != null) - { - SaveTextValue(elementValueGetter()); - } - else - { - SaveTextValue(elementStringValue); - } - break; - - case XmlSchemaContentType.Mixed: - if (_context.ElementDecl.DefaultValueTyped != null) - { - if (elementValueGetter != null) - { - SaveTextValue(elementValueGetter()); - } - else - { - SaveTextValue(elementStringValue); - } - } - break; - - default: - break; - } - } - } - - - public object ValidateEndElement(XmlSchemaInfo schemaInfo) - { - return InternalValidateEndElement(schemaInfo, null); - } - - public object ValidateEndElement(XmlSchemaInfo schemaInfo, object typedValue) - { - if (typedValue == null) - { - throw new ArgumentNullException("typedValue"); - } - if (_textValue.Length > 0) - { - throw new InvalidOperationException(ResXml.Sch_InvalidEndElementCall); - } - return InternalValidateEndElement(schemaInfo, typedValue); - } - - public void SkipToEndElement(XmlSchemaInfo schemaInfo) - { - if (_validationStack.Length <= 1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidEndElementMultiple, s_methodNames[(int)ValidatorState.SkipToEndElement])); - } - CheckStateTransition(ValidatorState.SkipToEndElement, s_methodNames[(int)ValidatorState.SkipToEndElement]); - - if (schemaInfo != null) - { - SchemaElementDecl currentElementDecl = _context.ElementDecl; - if (currentElementDecl != null) - { - schemaInfo.SchemaType = currentElementDecl.SchemaType; - schemaInfo.SchemaElement = GetSchemaElement(); - } - else - { - schemaInfo.SchemaType = null; - schemaInfo.SchemaElement = null; - } - schemaInfo.MemberType = null; - schemaInfo.IsNil = _context.IsNill; - schemaInfo.IsDefault = _context.IsDefault; - Debug.Assert(_context.Validity != XmlSchemaValidity.Valid); - schemaInfo.Validity = _context.Validity; - } - _context.ValidationSkipped = true; - _currentState = ValidatorState.SkipToEndElement; - Pop(); - } - - public void EndValidation() - { - if (_validationStack.Length > 1) - { //We have pending elements in the stack to call ValidateEndElement - throw new InvalidOperationException(ResXml.Sch_InvalidEndValidation); - } - CheckStateTransition(ValidatorState.Finish, s_methodNames[(int)ValidatorState.Finish]); - CheckForwardRefs(); - } - - public XmlSchemaParticle[] GetExpectedParticles() - { - if (_currentState == ValidatorState.Start || _currentState == ValidatorState.TopLevelTextOrWS) - { //Right after initialize - if (_partialValidationType != null) - { - XmlSchemaElement element = _partialValidationType as XmlSchemaElement; - if (element != null) - { - return new XmlSchemaParticle[1] { element }; - } - return s_emptyParticleArray; - } - else - { //Should return all global elements - ICollection elements = _schemaSet.GlobalElements.Values; - ArrayList expected = new ArrayList(elements.Count); - foreach (XmlSchemaElement element in elements) - { //Check for substitutions - ContentValidator.AddParticleToExpected(element, _schemaSet, expected, true); - } - return expected.ToArray(typeof(XmlSchemaParticle)) as XmlSchemaParticle[]; - } - } - if (_context.ElementDecl != null) - { - ArrayList expected = _context.ElementDecl.ContentValidator.ExpectedParticles(_context, false, _schemaSet); - if (expected != null) - { - return expected.ToArray(typeof(XmlSchemaParticle)) as XmlSchemaParticle[]; - } - } - return s_emptyParticleArray; - } - - public XmlSchemaAttribute[] GetExpectedAttributes() - { - if (_currentState == ValidatorState.Element || _currentState == ValidatorState.Attribute) - { - SchemaElementDecl elementDecl = _context.ElementDecl; - ArrayList attList = new ArrayList(); - if (elementDecl != null) - { - foreach (SchemaAttDef attDef in elementDecl.AttDefs.Values) - { - if (_attPresence[attDef.Name] == null) - { - attList.Add(attDef.SchemaAttribute); - } - } - } - if (_nsResolver.LookupPrefix(_nsXsi) != null) - { //Xsi namespace defined - AddXsiAttributes(attList); - } - return attList.ToArray(typeof(XmlSchemaAttribute)) as XmlSchemaAttribute[]; - } - else if (_currentState == ValidatorState.Start) - { - if (_partialValidationType != null) - { - XmlSchemaAttribute attribute = _partialValidationType as XmlSchemaAttribute; - if (attribute != null) - { - return new XmlSchemaAttribute[1] { attribute }; - } - } - } - return s_emptyAttributeArray; - } - - internal void GetUnspecifiedDefaultAttributes(ArrayList defaultAttributes, bool createNodeData) - { - _currentState = ValidatorState.Attribute; - SchemaElementDecl currentElementDecl = _context.ElementDecl; - - if (currentElementDecl != null && currentElementDecl.HasDefaultAttribute) - { - for (int i = 0; i < currentElementDecl.DefaultAttDefs.Count; ++i) - { - SchemaAttDef attdef = (SchemaAttDef)currentElementDecl.DefaultAttDefs[i]; - if (!_attPresence.Contains(attdef.Name)) - { - if (attdef.DefaultValueTyped == null) - { //Invalid attribute default in the schema - continue; - } - - //Check to see default attributes WILL be qualified if attributeFormDefault = qualified in schema - string attributeNS = _nameTable.Add(attdef.Name.Namespace); - string defaultPrefix = string.Empty; - if (attributeNS.Length > 0) - { - defaultPrefix = GetDefaultAttributePrefix(attributeNS); - if (defaultPrefix == null || defaultPrefix.Length == 0) - { - SendValidationEvent(ResXml.Sch_DefaultAttributeNotApplied, new string[2] { attdef.Name.ToString(), QNameString(_context.LocalName, _context.Namespace) }); - continue; - } - } - XmlSchemaDatatype datatype = attdef.Datatype; - if (createNodeData) - { - ValidatingReaderNodeData attrData = new ValidatingReaderNodeData(); - attrData.LocalName = _nameTable.Add(attdef.Name.Name); - attrData.Namespace = attributeNS; - attrData.Prefix = _nameTable.Add(defaultPrefix); - attrData.NodeType = XmlNodeType.Attribute; - - //set PSVI properties - AttributePSVIInfo attrValidInfo = new AttributePSVIInfo(); - XmlSchemaInfo attSchemaInfo = attrValidInfo.attributeSchemaInfo; - Debug.Assert(attSchemaInfo != null); - if (attdef.Datatype.Variety == XmlSchemaDatatypeVariety.Union) - { - XsdSimpleValue simpleValue = attdef.DefaultValueTyped as XsdSimpleValue; - attSchemaInfo.MemberType = simpleValue.XmlType; - datatype = simpleValue.XmlType.Datatype; - attrValidInfo.typedAttributeValue = simpleValue.TypedValue; - } - else - { - attrValidInfo.typedAttributeValue = attdef.DefaultValueTyped; - } - attSchemaInfo.IsDefault = true; - attSchemaInfo.Validity = XmlSchemaValidity.Valid; - attSchemaInfo.SchemaType = attdef.SchemaType; - attSchemaInfo.SchemaAttribute = attdef.SchemaAttribute; - attrData.RawValue = attSchemaInfo.XmlType.ValueConverter.ToString(attrValidInfo.typedAttributeValue); - - attrData.AttInfo = attrValidInfo; - defaultAttributes.Add(attrData); - } - else - { - defaultAttributes.Add(attdef.SchemaAttribute); - } - CheckTokenizedTypes(datatype, attdef.DefaultValueTyped, true); - if (HasIdentityConstraints) - { - AttributeIdentityConstraints(attdef.Name.Name, attdef.Name.Namespace, attdef.DefaultValueTyped, attdef.DefaultValueRaw, datatype); - } - } - } - } - return; - } - - internal XmlSchemaSet SchemaSet - { - get - { - return _schemaSet; - } - } - - internal XmlSchemaValidationFlags ValidationFlags - { - get - { - return _validationFlags; - } - } - - internal XmlSchemaContentType CurrentContentType - { - get - { - if (_context.ElementDecl == null) - { - return XmlSchemaContentType.Empty; - } - return _context.ElementDecl.ContentValidator.ContentType; - } - } - - internal XmlSchemaContentProcessing CurrentProcessContents - { - get - { - return _processContents; - } - } - - internal void SetDtdSchemaInfo(IDtdInfo dtdSchemaInfo) - { - _dtdSchemaInfo = dtdSchemaInfo; - _checkEntity = true; - } - - private bool StrictlyAssessed - { - get - { - return (_processContents == XmlSchemaContentProcessing.Strict || _processContents == XmlSchemaContentProcessing.Lax) && _context.ElementDecl != null && !_context.ValidationSkipped; - } - } - - private bool HasSchema - { - get - { - if (_isRoot) - { - _isRoot = false; - if (!_compiledSchemaInfo.Contains(_context.Namespace)) - { - _rootHasSchema = false; - } - } - return _rootHasSchema; - } - } - - internal string GetConcatenatedValue() - { - return _textValue.ToString(); - } - - private object InternalValidateEndElement(XmlSchemaInfo schemaInfo, object typedValue) - { - if (_validationStack.Length <= 1) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidEndElementMultiple, s_methodNames[(int)ValidatorState.EndElement])); - } - CheckStateTransition(ValidatorState.EndElement, s_methodNames[(int)ValidatorState.EndElement]); - - SchemaElementDecl contextElementDecl = _context.ElementDecl; - XmlSchemaSimpleType memberType = null; - XmlSchemaType localSchemaType = null; - XmlSchemaElement localSchemaElement = null; - - string stringValue = string.Empty; - - if (contextElementDecl != null) - { - if (_context.CheckRequiredAttribute && contextElementDecl.HasRequiredAttribute) - { - CheckRequiredAttributes(contextElementDecl); - } - if (!_context.IsNill) - { - if (_context.NeedValidateChildren) - { - XmlSchemaContentType contentType = contextElementDecl.ContentValidator.ContentType; - switch (contentType) - { - case XmlSchemaContentType.TextOnly: - if (typedValue == null) - { - stringValue = _textValue.ToString(); - typedValue = ValidateAtomicValue(stringValue, out memberType); - } - else - { //Parsed object passed in, need to verify only facets - typedValue = ValidateAtomicValue(typedValue, out memberType); - } - break; - - case XmlSchemaContentType.Mixed: - if (contextElementDecl.DefaultValueTyped != null) - { - if (typedValue == null) - { - stringValue = _textValue.ToString(); - typedValue = CheckMixedValueConstraint(stringValue); - } - } - break; - - case XmlSchemaContentType.ElementOnly: - if (typedValue != null) - { //Cannot pass in typedValue for complex content - throw new InvalidOperationException(ResXml.Sch_InvalidEndElementCallTyped); - } - break; - - default: - break; - } - if (!contextElementDecl.ContentValidator.CompleteValidation(_context)) - { - CompleteValidationError(_context, _eventHandler, _nsResolver, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition, _schemaSet); - _context.Validity = XmlSchemaValidity.Invalid; - } - } - } - // for each level in the stack, endchildren and fill value from element - if (HasIdentityConstraints) - { - XmlSchemaType xmlType = memberType == null ? contextElementDecl.SchemaType : memberType; - EndElementIdentityConstraints(typedValue, stringValue, xmlType.Datatype); - } - localSchemaType = contextElementDecl.SchemaType; - localSchemaElement = GetSchemaElement(); - } - if (schemaInfo != null) - { //SET SchemaInfo - schemaInfo.SchemaType = localSchemaType; - schemaInfo.SchemaElement = localSchemaElement; - schemaInfo.MemberType = memberType; - schemaInfo.IsNil = _context.IsNill; - schemaInfo.IsDefault = _context.IsDefault; - if (_context.Validity == XmlSchemaValidity.NotKnown && StrictlyAssessed) - { - _context.Validity = XmlSchemaValidity.Valid; - } - schemaInfo.Validity = _context.Validity; - } - Pop(); - return typedValue; - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void ProcessSchemaLocations(string xsiSchemaLocation, string xsiNoNamespaceSchemaLocation) - { - bool compile = false; - if (xsiNoNamespaceSchemaLocation != null) - { - compile = true; - LoadSchema(string.Empty, xsiNoNamespaceSchemaLocation); - } - if (xsiSchemaLocation != null) - { - object typedValue; - Exception exception = s_dtStringArray.TryParseValue(xsiSchemaLocation, _nameTable, _nsResolver, out typedValue); - if (exception != null) - { - SendValidationEvent(ResXml.Sch_InvalidValueDetailedAttribute, new string[] { "schemaLocation", xsiSchemaLocation, s_dtStringArray.TypeCodeString, exception.Message }, exception); - return; - } - string[] locations = (string[])typedValue; - compile = true; - try - { - for (int j = 0; j < locations.Length - 1; j += 2) - { - LoadSchema((string)locations[j], (string)locations[j + 1]); - } - } - catch (XmlSchemaException schemaException) - { - SendValidationEvent(schemaException); - } - } - if (compile) - { - RecompileSchemaSet(); - } - } - - - private object ValidateElementContext(XmlQualifiedName elementName, out bool invalidElementInContext) - { - object particle = null; - int errorCode = 0; - XmlQualifiedName head; - XmlSchemaElement headElement = null; - invalidElementInContext = false; - - if (_context.NeedValidateChildren) - { - if (_context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, QNameString(_context.LocalName, _context.Namespace)); - return null; - } - ContentValidator contentValidator = _context.ElementDecl.ContentValidator; - if (contentValidator.ContentType == XmlSchemaContentType.Mixed && _context.ElementDecl.Presence == SchemaDeclBase.Use.Fixed) - { //Mixed with default or fixed - SendValidationEvent(ResXml.Sch_ElementInMixedWithFixed, QNameString(_context.LocalName, _context.Namespace)); - return null; - } - - head = elementName; - bool substitution = false; - - while (true) - { - particle = _context.ElementDecl.ContentValidator.ValidateElement(head, _context, out errorCode); - if (particle != null) - { //Match found - break; - } - if (errorCode == -2) - { //ContentModel all group error - SendValidationEvent(ResXml.Sch_AllElement, elementName.ToString()); - invalidElementInContext = true; - _processContents = _context.ProcessContents = XmlSchemaContentProcessing.Skip; - return null; - } - //Match not found; check for substitutionGroup - substitution = true; - headElement = GetSubstitutionGroupHead(head); - if (headElement == null) - { - break; - } - else - { - head = headElement.QualifiedName; - } - } - - if (substitution) - { - XmlSchemaElement matchedElem = particle as XmlSchemaElement; - if (matchedElem == null) - { //It matched an xs:any in that position - particle = null; - } - else if (matchedElem.RefName.IsEmpty) - { //It is not element ref but a local element - //If the head and matched particle are not hte same, then this is not substitutable, duped by a localElement with same QName - SendValidationEvent(ResXml.Sch_InvalidElementSubstitution, BuildElementName(elementName), BuildElementName(matchedElem.QualifiedName)); - invalidElementInContext = true; - _processContents = _context.ProcessContents = XmlSchemaContentProcessing.Skip; - } - else - { //Correct substitution head found - particle = _compiledSchemaInfo.GetElement(elementName); //Re-assign correct particle - _context.NeedValidateChildren = true; //This will be reset to false once member match is not found - } - } - if (particle == null) - { - ElementValidationError(elementName, _context, _eventHandler, _nsResolver, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition, _schemaSet); - invalidElementInContext = true; - _processContents = _context.ProcessContents = XmlSchemaContentProcessing.Skip; - } - } - return particle; - } - - - private XmlSchemaElement GetSubstitutionGroupHead(XmlQualifiedName member) - { - XmlSchemaElement memberElem = _compiledSchemaInfo.GetElement(member); - if (memberElem != null) - { - XmlQualifiedName head = memberElem.SubstitutionGroup; - if (!head.IsEmpty) - { - XmlSchemaElement headElem = _compiledSchemaInfo.GetElement(head); - if (headElem != null) - { - if ((headElem.BlockResolved & XmlSchemaDerivationMethod.Substitution) != 0) - { - SendValidationEvent(ResXml.Sch_SubstitutionNotAllowed, new string[] { member.ToString(), head.ToString() }); - return null; - } - if (!XmlSchemaType.IsDerivedFrom(memberElem.ElementSchemaType, headElem.ElementSchemaType, headElem.BlockResolved)) - { - SendValidationEvent(ResXml.Sch_SubstitutionBlocked, new string[] { member.ToString(), head.ToString() }); - return null; - } - return headElem; - } - } - } - return null; - } - - private object ValidateAtomicValue(string stringValue, out XmlSchemaSimpleType memberType) - { - object typedVal = null; - memberType = null; - SchemaElementDecl currentElementDecl = _context.ElementDecl; - if (!_context.IsNill) - { - if (stringValue.Length == 0 && currentElementDecl.DefaultValueTyped != null) - { //default value maybe present - SchemaElementDecl declBeforeXsi = _context.ElementDeclBeforeXsi; - if (declBeforeXsi != null && declBeforeXsi != currentElementDecl) - { //There was xsi:type - Debug.Assert(currentElementDecl.Datatype != null); - Exception exception = currentElementDecl.Datatype.TryParseValue(currentElementDecl.DefaultValueRaw, _nameTable, _nsResolver, out typedVal); - if (exception != null) - { - SendValidationEvent(ResXml.Sch_InvalidElementDefaultValue, new string[] { currentElementDecl.DefaultValueRaw, QNameString(_context.LocalName, _context.Namespace) }); - } - else - { - _context.IsDefault = true; - } - } - else - { - _context.IsDefault = true; - typedVal = currentElementDecl.DefaultValueTyped; - } - } - else - { - typedVal = CheckElementValue(stringValue); - } - XsdSimpleValue simpleValue = typedVal as XsdSimpleValue; - XmlSchemaDatatype dtype = currentElementDecl.Datatype; - if (simpleValue != null) - { - memberType = simpleValue.XmlType; - typedVal = simpleValue.TypedValue; - dtype = memberType.Datatype; - } - CheckTokenizedTypes(dtype, typedVal, false); - } - return typedVal; - } - - private object ValidateAtomicValue(object parsedValue, out XmlSchemaSimpleType memberType) - { - memberType = null; - SchemaElementDecl currentElementDecl = _context.ElementDecl; - object typedValue = null; - if (!_context.IsNill) - { - SchemaDeclBase decl = currentElementDecl as SchemaDeclBase; - XmlSchemaDatatype dtype = currentElementDecl.Datatype; - Exception exception = dtype.TryParseValue(parsedValue, _nameTable, _nsResolver, out typedValue); - if (exception != null) - { - string stringValue = parsedValue as string; - if (stringValue == null) - { - stringValue = XmlSchemaDatatype.ConcatenatedToString(parsedValue); - } - SendValidationEvent(ResXml.Sch_ElementValueDataTypeDetailed, new string[] { QNameString(_context.LocalName, _context.Namespace), stringValue, GetTypeName(decl), exception.Message }, exception); - return null; - } - if (!decl.CheckValue(typedValue)) - { - SendValidationEvent(ResXml.Sch_FixedElementValue, QNameString(_context.LocalName, _context.Namespace)); - } - if (dtype.Variety == XmlSchemaDatatypeVariety.Union) - { - XsdSimpleValue simpleValue = typedValue as XsdSimpleValue; - Debug.Assert(simpleValue != null); - memberType = simpleValue.XmlType; - typedValue = simpleValue.TypedValue; - dtype = memberType.Datatype; - } - CheckTokenizedTypes(dtype, typedValue, false); - } - return typedValue; - } - - private string GetTypeName(SchemaDeclBase decl) - { - Debug.Assert(decl != null && decl.SchemaType != null); - string typeName = decl.SchemaType.QualifiedName.ToString(); - if (typeName.Length == 0) - { - typeName = decl.Datatype.TypeCodeString; - } - return typeName; - } - - private void SaveTextValue(object value) - { - string s = value.ToString(); //For strings, which will mostly be the case, ToString() will return this. For other typedValues, need to go through value converter (eg: TimeSpan, DateTime etc) - _textValue.Append(s); - } - - private void Push(XmlQualifiedName elementName) - { - _context = (ValidationState)_validationStack.Push(); - if (_context == null) - { - _context = new ValidationState(); - _validationStack.AddToTop(_context); - } - _context.LocalName = elementName.Name; - _context.Namespace = elementName.Namespace; - _context.HasMatched = false; - _context.IsNill = false; - _context.IsDefault = false; - _context.CheckRequiredAttribute = true; - _context.ValidationSkipped = false; - _context.Validity = XmlSchemaValidity.NotKnown; - _context.NeedValidateChildren = false; - _context.ProcessContents = _processContents; - _context.ElementDeclBeforeXsi = null; - _context.Constr = null; //resetting the constraints to be null incase context != null - // when pushing onto stack; - } - - private void Pop() - { - Debug.Assert(_validationStack.Length > 1); - ValidationState previousContext = (ValidationState)_validationStack.Pop(); - - if (_startIDConstraint == _validationStack.Length) - { - _startIDConstraint = -1; - } - _context = (ValidationState)_validationStack.Peek(); - if (previousContext.Validity == XmlSchemaValidity.Invalid) - { //Should set current context's validity to that of what was popped now in case of Invalid - _context.Validity = XmlSchemaValidity.Invalid; - } - if (previousContext.ValidationSkipped) - { - _context.ValidationSkipped = true; - } - _processContents = _context.ProcessContents; - } - - private void AddXsiAttributes(ArrayList attList) - { - BuildXsiAttributes(); - if (_attPresence[s_xsiTypeSO.QualifiedName] == null) - { - attList.Add(s_xsiTypeSO); - } - if (_attPresence[s_xsiNilSO.QualifiedName] == null) - { - attList.Add(s_xsiNilSO); - } - if (_attPresence[s_xsiSLSO.QualifiedName] == null) - { - attList.Add(s_xsiSLSO); - } - if (_attPresence[s_xsiNoNsSLSO.QualifiedName] == null) - { - attList.Add(s_xsiNoNsSLSO); - } - } - - private SchemaElementDecl FastGetElementDecl(XmlQualifiedName elementName, object particle) - { - SchemaElementDecl elementDecl = null; - if (particle != null) - { - XmlSchemaElement element = particle as XmlSchemaElement; - if (element != null) - { - elementDecl = element.ElementDecl; - } - else - { - XmlSchemaAny any = (XmlSchemaAny)particle; - _processContents = any.ProcessContentsCorrect; - } - } - if (elementDecl == null && _processContents != XmlSchemaContentProcessing.Skip) - { - if (_isRoot && _partialValidationType != null) - { - if (_partialValidationType is XmlSchemaElement) - { - XmlSchemaElement element = (XmlSchemaElement)_partialValidationType; - if (elementName.Equals(element.QualifiedName)) - { - elementDecl = element.ElementDecl; - } - else - { - SendValidationEvent(ResXml.Sch_SchemaElementNameMismatch, elementName.ToString(), element.QualifiedName.ToString()); - } - } - else if (_partialValidationType is XmlSchemaType) - { //Element name is wildcard - XmlSchemaType type = (XmlSchemaType)_partialValidationType; - elementDecl = type.ElementDecl; - } - else - { //its XmlSchemaAttribute - Debug.Assert(_partialValidationType is XmlSchemaAttribute); - SendValidationEvent(ResXml.Sch_ValidateElementInvalidCall, string.Empty); - } - } - else - { - elementDecl = _compiledSchemaInfo.GetElementDecl(elementName); - } - } - return elementDecl; - } - - private SchemaElementDecl CheckXsiTypeAndNil(SchemaElementDecl elementDecl, string xsiType, string xsiNil, ref bool declFound) - { - XmlQualifiedName xsiTypeName = XmlQualifiedName.Empty; - if (xsiType != null) - { - object typedVal = null; - Exception exception = s_dtQName.TryParseValue(xsiType, _nameTable, _nsResolver, out typedVal); - if (exception != null) - { - SendValidationEvent(ResXml.Sch_InvalidValueDetailedAttribute, new string[] { "type", xsiType, s_dtQName.TypeCodeString, exception.Message }, exception); - } - else - { - xsiTypeName = typedVal as XmlQualifiedName; - } - } - if (elementDecl != null) - { //nillable is not dependent on xsi:type. - if (elementDecl.IsNillable) - { - if (xsiNil != null) - { - _context.IsNill = XmlConvert.ToBoolean(xsiNil); - if (_context.IsNill && elementDecl.Presence == SchemaDeclBase.Use.Fixed) - { - Debug.Assert(elementDecl.DefaultValueTyped != null); - SendValidationEvent(ResXml.Sch_XsiNilAndFixed); - } - } - } - else if (xsiNil != null) - { - SendValidationEvent(ResXml.Sch_InvalidXsiNill); - } - } - if (xsiTypeName.IsEmpty) - { - if (elementDecl != null && elementDecl.IsAbstract) - { - SendValidationEvent(ResXml.Sch_AbstractElement, QNameString(_context.LocalName, _context.Namespace)); - elementDecl = null; - } - } - else - { - SchemaElementDecl elementDeclXsi = _compiledSchemaInfo.GetTypeDecl(xsiTypeName); - XmlSeverityType severity = XmlSeverityType.Warning; - if (HasSchema && _processContents == XmlSchemaContentProcessing.Strict) - { - severity = XmlSeverityType.Error; - } - if (elementDeclXsi == null && xsiTypeName.Namespace == _nsXs) - { - XmlSchemaType schemaType = DatatypeImplementation.GetSimpleTypeFromXsdType(xsiTypeName); - if (schemaType == null) - { //try getting complexType - xs:anyType - schemaType = XmlSchemaType.GetBuiltInComplexType(xsiTypeName); - } - if (schemaType != null) - { - elementDeclXsi = schemaType.ElementDecl; - } - } - if (elementDeclXsi == null) - { - SendValidationEvent(ResXml.Sch_XsiTypeNotFound, xsiTypeName.ToString(), severity); - elementDecl = null; - } - else - { - declFound = true; - if (elementDeclXsi.IsAbstract) - { - SendValidationEvent(ResXml.Sch_XsiTypeAbstract, xsiTypeName.ToString(), severity); - elementDecl = null; - } - else if (elementDecl != null && !XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block)) - { - SendValidationEvent(ResXml.Sch_XsiTypeBlockedEx, new string[] { xsiTypeName.ToString(), QNameString(_context.LocalName, _context.Namespace) }); - elementDecl = null; - } - else - { - if (elementDecl != null) - { //Get all element decl properties before assigning xsi:type decl; nillable already checked - elementDeclXsi = elementDeclXsi.Clone(); //Before updating properties onto xsi:type decl, clone it - elementDeclXsi.Constraints = elementDecl.Constraints; - elementDeclXsi.DefaultValueRaw = elementDecl.DefaultValueRaw; - elementDeclXsi.DefaultValueTyped = elementDecl.DefaultValueTyped; - elementDeclXsi.Block = elementDecl.Block; - } - _context.ElementDeclBeforeXsi = elementDecl; - elementDecl = elementDeclXsi; - } - } - } - return elementDecl; - } - - private void ThrowDeclNotFoundWarningOrError(bool declFound) - { - if (declFound) - { //But invalid, so discontinue processing of children - _processContents = _context.ProcessContents = XmlSchemaContentProcessing.Skip; - _context.NeedValidateChildren = false; - } - else if (HasSchema && _processContents == XmlSchemaContentProcessing.Strict) - { //Error and skip validation for children - _processContents = _context.ProcessContents = XmlSchemaContentProcessing.Skip; - _context.NeedValidateChildren = false; - SendValidationEvent(ResXml.Sch_UndeclaredElement, QNameString(_context.LocalName, _context.Namespace)); - } - else - { - SendValidationEvent(ResXml.Sch_NoElementSchemaFound, QNameString(_context.LocalName, _context.Namespace), XmlSeverityType.Warning); - } - } - - private void CheckElementProperties() - { - if (_context.ElementDecl.IsAbstract) - { - SendValidationEvent(ResXml.Sch_AbstractElement, QNameString(_context.LocalName, _context.Namespace)); - } - } - - private void ValidateStartElementIdentityConstraints() - { - // added on June 15, set the context here, so the stack can have them - if (ProcessIdentityConstraints && _context.ElementDecl.Constraints != null) - { - AddIdentityConstraints(); - } - //foreach constraint in stack (including the current one) - if (HasIdentityConstraints) - { - ElementIdentityConstraints(); - } - } - - private SchemaAttDef CheckIsXmlAttribute(XmlQualifiedName attQName) - { - SchemaAttDef attdef = null; - if (Ref.Equal(attQName.Namespace, _nsXml) && (_validationFlags & XmlSchemaValidationFlags.AllowXmlAttributes) != 0) - { //Need to check if this attribute is an xml attribute - if (!_compiledSchemaInfo.Contains(_nsXml)) - { //We dont have a schema for xml namespace - // It can happen that the schemaSet already contains the schema for xml namespace - // and we just have a stale compiled schema info (for example if the same schema set is used - // by two validators at the same time and the one before us added the xml namespace schema - // via this code here) - // In that case it is actually OK to try to add the schema for xml namespace again - // since we're adding the exact same instance (the built in xml namespace schema is a singleton) - // The addition on the schemaset is an effective no-op plus it's thread safe, so it's better to leave - // that up to the schema set. The result of the below call will be simply that we update the - // reference to the comipledSchemaInfo - which is exactly what we want in that case. - // In theory it can actually happen that there is some other schema registered for the xml namespace - // (other than our built in one), and we don't know about it. In that case we don't support such scenario - // as the user is modifying the schemaset as we're using it, which we don't support - // for bunch of other reasons, so trying to add our built-in schema won't make it worse. - AddXmlNamespaceSchema(); - } - _compiledSchemaInfo.AttributeDecls.TryGetValue(attQName, out attdef); //the xml attributes are all global attributes - } - return attdef; - } - - private void AddXmlNamespaceSchema() - { - XmlSchemaSet localSet = new XmlSchemaSet(); //Avoiding cost of incremental compilation checks by compiling schema in a seperate set and adding compiled set - localSet.Add(Preprocessor.GetBuildInSchema()); - localSet.Compile(); - _schemaSet.Add(localSet); - RecompileSchemaSet(); - } - - internal object CheckMixedValueConstraint(string elementValue) - { - SchemaElementDecl elementDecl = _context.ElementDecl; - Debug.Assert(elementDecl.ContentValidator.ContentType == XmlSchemaContentType.Mixed && elementDecl.DefaultValueTyped != null); - if (_context.IsNill) - { //Nil and fixed is error; Nil and default is compile time error - return null; - } - if (elementValue.Length == 0) - { - _context.IsDefault = true; - return elementDecl.DefaultValueTyped; - } - else - { - SchemaDeclBase decl = elementDecl as SchemaDeclBase; - Debug.Assert(decl != null); - if (decl.Presence == SchemaDeclBase.Use.Fixed && !elementValue.Equals(elementDecl.DefaultValueRaw)) - { //check string equality for mixed as it is untyped. - SendValidationEvent(ResXml.Sch_FixedElementValue, elementDecl.Name.ToString()); - } - return elementValue; - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void LoadSchema(string uri, string url) - { - Debug.Assert(_xmlResolver != null); - XmlReader Reader = null; - try - { - Uri ruri = _xmlResolver.ResolveUri(_sourceUri, url); - Stream stm = (Stream)_xmlResolver.GetEntity(ruri, null, null); - XmlReaderSettings readerSettings = _schemaSet.ReaderSettings; - readerSettings.CloseInput = true; - readerSettings.XmlResolver = _xmlResolver; - Reader = XmlReader.Create(stm, readerSettings, ruri.ToString()); - _schemaSet.Add(uri, Reader, _validatedNamespaces); - while (Reader.Read()) ;// wellformness check - } - catch (XmlSchemaException e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, e); - } - catch (Exception e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, e, XmlSeverityType.Warning); - } - finally - { - if (Reader != null) - { - Reader.Close(); - } - } - } - - - internal void RecompileSchemaSet() - { - if (!_schemaSet.IsCompiled) - { - try - { - _schemaSet.Compile(); - } - catch (XmlSchemaException e) - { - SendValidationEvent(e); - } - } - _compiledSchemaInfo = _schemaSet.CompiledInfo; //Fetch compiled info from set - } - - private void ProcessTokenizedType(XmlTokenizedType ttype, string name, bool attrValue) - { - switch (ttype) - { - case XmlTokenizedType.ID: - if (ProcessIdentityConstraints) - { - if (FindId(name) != null) - { - if (attrValue) - { - _attrValid = false; - } - SendValidationEvent(ResXml.Sch_DupId, name); - } - else - { - if (_IDs == null) - { //ADD ID - _IDs = new Hashtable(); - } - _IDs.Add(name, _context.LocalName); - } - } - break; - case XmlTokenizedType.IDREF: - if (ProcessIdentityConstraints) - { - object p = FindId(name); - if (p == null) - { // add it to linked list to check it later - _idRefListHead = new IdRefNode(_idRefListHead, name, _positionInfo.LineNumber, _positionInfo.LinePosition); - } - } - break; - case XmlTokenizedType.ENTITY: - ProcessEntity(name); - break; - default: - break; - } - } - - private object CheckAttributeValue(object value, SchemaAttDef attdef) - { - object typedValue = null; - SchemaDeclBase decl = attdef as SchemaDeclBase; - - XmlSchemaDatatype dtype = attdef.Datatype; - Debug.Assert(dtype != null); - string stringValue = value as string; - Exception exception = null; - - if (stringValue != null) - { //TODO: Combine both ParseValue with same signature in XmlSchemaDatatype - exception = dtype.TryParseValue(stringValue, _nameTable, _nsResolver, out typedValue); - if (exception != null) goto Error; - } - else - { //Calling object ParseValue for checking facets - exception = dtype.TryParseValue(value, _nameTable, _nsResolver, out typedValue); - if (exception != null) goto Error; - } - if (!decl.CheckValue(typedValue)) - { - _attrValid = false; - SendValidationEvent(ResXml.Sch_FixedAttributeValue, attdef.Name.ToString()); - } - return typedValue; - - Error: - _attrValid = false; - if (stringValue == null) - { - stringValue = XmlSchemaDatatype.ConcatenatedToString(value); - } - SendValidationEvent(ResXml.Sch_AttributeValueDataTypeDetailed, new string[] { attdef.Name.ToString(), stringValue, GetTypeName(decl), exception.Message }, exception); - return null; - } - - private object CheckElementValue(string stringValue) - { - object typedValue = null; - SchemaDeclBase decl = _context.ElementDecl as SchemaDeclBase; - - XmlSchemaDatatype dtype = decl.Datatype; - Debug.Assert(dtype != null); - - Exception exception = dtype.TryParseValue(stringValue, _nameTable, _nsResolver, out typedValue); - if (exception != null) - { - SendValidationEvent(ResXml.Sch_ElementValueDataTypeDetailed, new string[] { QNameString(_context.LocalName, _context.Namespace), stringValue, GetTypeName(decl), exception.Message }, exception); - return null; - } - if (!decl.CheckValue(typedValue)) - { - SendValidationEvent(ResXml.Sch_FixedElementValue, QNameString(_context.LocalName, _context.Namespace)); - } - return typedValue; - } - - private void CheckTokenizedTypes(XmlSchemaDatatype dtype, object typedValue, bool attrValue) - { - // Check special types - if (typedValue == null) - { - return; - } - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessTokenizedType(dtype.TokenizedType, ss[i], attrValue); - } - } - else - { - ProcessTokenizedType(dtype.TokenizedType, (string)typedValue, attrValue); - } - } - } - - private object FindId(string name) - { - return _IDs == null ? null : _IDs[name]; - } - - private void CheckForwardRefs() - { - IdRefNode next = _idRefListHead; - while (next != null) - { - if (FindId(next.Id) == null) - { - SendValidationEvent(new XmlSchemaValidationException(ResXml.Sch_UndeclaredId, next.Id, _sourceUriString, next.LineNo, next.LinePos), XmlSeverityType.Error); - } - IdRefNode ptr = next.Next; - next.Next = null; // unhook each object so it is cleaned up by Garbage Collector - next = ptr; - } - // not needed any more. - _idRefListHead = null; - } - - - private bool HasIdentityConstraints - { - get { return ProcessIdentityConstraints && _startIDConstraint != -1; } - } - - internal bool ProcessIdentityConstraints - { - get - { - return (_validationFlags & XmlSchemaValidationFlags.ProcessIdentityConstraints) != 0; - } - } - - internal bool ReportValidationWarnings - { - get - { - return (_validationFlags & XmlSchemaValidationFlags.ReportValidationWarnings) != 0; - } - } - - internal bool ProcessInlineSchema - { - get - { - return (_validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != 0; - } - } - - internal bool ProcessSchemaLocation - { - get - { - return (_validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != 0; - } - } - - internal bool ProcessSchemaHints - { - get - { - return (_validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != 0 || - (_validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != 0; - } - } - - private void CheckStateTransition(ValidatorState toState, string methodName) - { - if (!ValidStates[(int)_currentState, (int)toState]) - { - if (_currentState == ValidatorState.None) - { - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidStartTransition, new string[] { methodName, s_methodNames[(int)ValidatorState.Start] })); - } - throw new InvalidOperationException(string.Format(ResXml.Sch_InvalidStateTransition, new string[] { s_methodNames[(int)_currentState], methodName })); - } - _currentState = toState; - } - - private void ClearPSVI() - { - if (_textValue != null) - { - _textValue.Length = 0; - } - _attPresence.Clear(); //Clear attributes hashtable for every element - _wildID = null; //clear it for every element - } - - private void CheckRequiredAttributes(SchemaElementDecl currentElementDecl) - { - Debug.Assert(currentElementDecl != null); - Dictionary attributeDefs = currentElementDecl.AttDefs; - foreach (SchemaAttDef attdef in attributeDefs.Values) - { - if (_attPresence[attdef.Name] == null) - { - if (attdef.Presence == SchemaDeclBase.Use.Required || attdef.Presence == SchemaDeclBase.Use.RequiredFixed) - { - SendValidationEvent(ResXml.Sch_MissRequiredAttribute, attdef.Name.ToString()); - } - } - } - } - - private XmlSchemaElement GetSchemaElement() - { - SchemaElementDecl beforeXsiDecl = _context.ElementDeclBeforeXsi; - SchemaElementDecl currentDecl = _context.ElementDecl; - - if (beforeXsiDecl != null) - { //Have a xsi:type - if (beforeXsiDecl.SchemaElement != null) - { - XmlSchemaElement xsiElement = (XmlSchemaElement)beforeXsiDecl.SchemaElement.Clone(null); - xsiElement.SchemaTypeName = XmlQualifiedName.Empty; //Reset typeName on element as this might be different - xsiElement.SchemaType = currentDecl.SchemaType; - xsiElement.SetElementType(currentDecl.SchemaType); - xsiElement.ElementDecl = currentDecl; - return xsiElement; - } - } - return currentDecl.SchemaElement; - } - - internal string GetDefaultAttributePrefix(string attributeNS) - { - IDictionary namespaceDecls = _nsResolver.GetNamespacesInScope(XmlNamespaceScope.All); - string defaultPrefix = null; - string defaultNS; - - foreach (KeyValuePair pair in namespaceDecls) - { - defaultNS = _nameTable.Add(pair.Value); - if (Ref.Equal(defaultNS, attributeNS)) - { - defaultPrefix = pair.Key; - if (defaultPrefix.Length != 0) - { //Locate first non-empty prefix - return defaultPrefix; - } - } - } - return defaultPrefix; - } - - private void AddIdentityConstraints() - { - SchemaElementDecl currentElementDecl = _context.ElementDecl; - _context.Constr = new ConstraintStruct[currentElementDecl.Constraints.Length]; - int id = 0; - for (int i = 0; i < currentElementDecl.Constraints.Length; ++i) - { - _context.Constr[id++] = new ConstraintStruct(currentElementDecl.Constraints[i]); - } // foreach constraint /constraintstruct - - // added on June 19, make connections between new keyref tables with key/unique tables in stack - // i can't put it in the above loop, coz there will be key on the same level - for (int i = 0; i < _context.Constr.Length; ++i) - { - if (_context.Constr[i].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - { - bool find = false; - // go upwards checking or only in this level - for (int level = _validationStack.Length - 1; level >= ((_startIDConstraint >= 0) ? _startIDConstraint : _validationStack.Length - 1); level--) - { - // no constraint for this level - if (((ValidationState)(_validationStack[level])).Constr == null) - { - continue; - } - // else - ConstraintStruct[] constraintStructures = ((ValidationState)_validationStack[level]).Constr; - for (int j = 0; j < constraintStructures.Length; ++j) - { - if (constraintStructures[j].constraint.name == _context.Constr[i].constraint.refer) - { - find = true; - if (constraintStructures[j].keyrefTable == null) - { - constraintStructures[j].keyrefTable = new Hashtable(); - } - _context.Constr[i].qualifiedTable = constraintStructures[j].keyrefTable; - break; - } - } - - if (find) - { - break; - } - } - if (!find) - { - // didn't find connections, throw exceptions - SendValidationEvent(ResXml.Sch_RefNotInScope, QNameString(_context.LocalName, _context.Namespace)); - } - } // finished dealing with keyref - } // end foreach - - // initial set - if (_startIDConstraint == -1) - { - _startIDConstraint = _validationStack.Length - 1; - } - } - - private void ElementIdentityConstraints() - { - SchemaElementDecl currentElementDecl = _context.ElementDecl; - string localName = _context.LocalName; - string namespaceUri = _context.Namespace; - - for (int i = _startIDConstraint; i < _validationStack.Length; i++) - { - // no constraint for this level - if (((ValidationState)(_validationStack[i])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraintStructures = ((ValidationState)_validationStack[i]).Constr; - for (int j = 0; j < constraintStructures.Length; ++j) - { - // check selector from here - if (constraintStructures[j].axisSelector.MoveToStartElement(localName, namespaceUri)) - { - // selector selects new node, activate a new set of fields - Debug.WriteLine("Selector Match!"); - Debug.WriteLine("Name: " + localName + "\t|\tURI: " + namespaceUri + "\n"); - - // in which axisFields got updated - constraintStructures[j].axisSelector.PushKS(_positionInfo.LineNumber, _positionInfo.LinePosition); - } - - // axisFields is not null, but may be empty - for (int k = 0; k < constraintStructures[j].axisFields.Count; ++k) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraintStructures[j].axisFields[k]; - - // check field from here - if (laxis.MoveToStartElement(localName, namespaceUri)) - { - Debug.WriteLine("Element Field Match!"); - // checking simpleType / simpleContent - if (currentElementDecl != null) - { // nextElement can be null when xml/xsd are not valid - if (currentElementDecl.Datatype == null || currentElementDecl.ContentValidator.ContentType == XmlSchemaContentType.Mixed) - { - SendValidationEvent(ResXml.Sch_FieldSimpleTypeExpected, localName); - } - else - { - // can't fill value here, wait till later.... - // fill type : xsdType - laxis.isMatched = true; - // since it's simpletyped element, the endchildren will come consequently... don't worry - } - } - } - } - } - } - } - - private void AttributeIdentityConstraints(string name, string ns, object obj, string sobj, XmlSchemaDatatype datatype) - { - for (int ci = _startIDConstraint; ci < _validationStack.Length; ci++) - { - // no constraint for this level - if (((ValidationState)(_validationStack[ci])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraintStructures = ((ValidationState)_validationStack[ci]).Constr; - for (int i = 0; i < constraintStructures.Length; ++i) - { - // axisFields is not null, but may be empty - for (int j = 0; j < constraintStructures[i].axisFields.Count; ++j) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraintStructures[i].axisFields[j]; - - // check field from here - if (laxis.MoveToAttribute(name, ns)) - { - Debug.WriteLine("Attribute Field Match!"); - //attribute is only simpletype, so needn't checking... - // can fill value here, yeah!! - Debug.WriteLine("Attribute Field Filling Value!"); - Debug.WriteLine("Name: " + name + "\t|\tURI: " + ns + "\t|\tValue: " + obj + "\n"); - if (laxis.Ks[laxis.Column] != null) - { - // should be evaluated to either an empty node-set or a node-set with exactly one member - // two matches... - SendValidationEvent(ResXml.Sch_FieldSingleValueExpected, name); - } - else - { - Debug.Assert(datatype != null); - laxis.Ks[laxis.Column] = new TypedObject(obj, sobj, datatype); - } - } - } - } - } - } - - private void EndElementIdentityConstraints(object typedValue, string stringValue, XmlSchemaDatatype datatype) - { - string localName = _context.LocalName; - string namespaceUri = _context.Namespace; - for (int ci = _validationStack.Length - 1; ci >= _startIDConstraint; ci--) - { - // no constraint for this level - if (((ValidationState)(_validationStack[ci])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraints = ((ValidationState)_validationStack[ci]).Constr; - for (int i = 0; i < constraints.Length; ++i) - { - // EndChildren - // axisFields is not null, but may be empty - for (int j = 0; j < constraints[i].axisFields.Count; ++j) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraints[i].axisFields[j]; - - // check field from here - // isMatched is false when nextElement is null. so needn't change this part. - if (laxis.isMatched) - { - Debug.WriteLine("Element Field Filling Value!"); - Debug.WriteLine("Name: " + localName + "\t|\tURI: " + namespaceUri + "\t|\tValue: " + typedValue + "\n"); - // fill value - laxis.isMatched = false; - if (laxis.Ks[laxis.Column] != null) - { - // [field...] should be evaluated to either an empty node-set or a node-set with exactly one member - // two matches... already existing field value in the table. - SendValidationEvent(ResXml.Sch_FieldSingleValueExpected, localName); - } - else - { - // for element, Reader.Value = ""; - if (typedValue != null && stringValue.Length != 0) - { - laxis.Ks[laxis.Column] = new TypedObject(typedValue, stringValue, datatype); - } - } - } - // EndChildren - laxis.EndElement(localName, namespaceUri); - } - - if (constraints[i].axisSelector.EndElement(localName, namespaceUri)) - { - // insert key sequence into hash (+ located active axis tuple leave for later) - KeySequence ks = constraints[i].axisSelector.PopKS(); - // unqualified keysequence are not allowed - switch (constraints[i].constraint.Role) - { - case CompiledIdentityConstraint.ConstraintRole.Key: - if (!ks.IsQualified()) - { - //Key's fields can't be null... if we can return context node's line info maybe it will be better - //only keymissing & keyduplicate reporting cases are necessary to be dealt with... 3 places... - SendValidationEvent(new XmlSchemaValidationException(ResXml.Sch_MissingKey, constraints[i].constraint.name.ToString(), _sourceUriString, ks.PosLine, ks.PosCol)); - } - else if (constraints[i].qualifiedTable.Contains(ks)) - { - // unique or key checking value confliction - // for redundant key, reporting both occurings - // doesn't work... how can i retrieve value out?? - // KeySequence ks2 = (KeySequence) conuct.qualifiedTable[ks]; - SendValidationEvent(new XmlSchemaValidationException(ResXml.Sch_DuplicateKey, - new string[2] { ks.ToString(), constraints[i].constraint.name.ToString() }, - _sourceUriString, ks.PosLine, ks.PosCol)); - } - else - { - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - - case CompiledIdentityConstraint.ConstraintRole.Unique: - - if (constraints[i].qualifiedTable.Contains(ks)) - { - // unique or key checking confliction - // KeySequence ks2 = (KeySequence) conuct.qualifiedTable[ks]; - SendValidationEvent(new XmlSchemaValidationException(ResXml.Sch_DuplicateKey, - new string[2] { ks.ToString(), constraints[i].constraint.name.ToString() }, - _sourceUriString, ks.PosLine, ks.PosCol)); - } - else - { - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - case CompiledIdentityConstraint.ConstraintRole.Keyref: - // is there any possibility: - // 2 keyrefs: value is equal, type is not - // both put in the hashtable, 1 reference, 1 not - if (constraints[i].qualifiedTable != null) - { //Will be null in cases when the keyref is outside the scope of the key, that is not allowed by our impl - if (!ks.IsQualified() || constraints[i].qualifiedTable.Contains(ks)) - { - continue; - } - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - } - } - } - } - - - // current level's constraint struct - ConstraintStruct[] vcs = ((ValidationState)(_validationStack[_validationStack.Length - 1])).Constr; - if (vcs != null) - { - // validating all referencing tables... - - for (int i = 0; i < vcs.Length; ++i) - { - if ((vcs[i].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - || (vcs[i].keyrefTable == null)) - { - continue; - } - foreach (KeySequence ks in vcs[i].keyrefTable.Keys) - { - if (!vcs[i].qualifiedTable.Contains(ks)) - { - SendValidationEvent(new XmlSchemaValidationException(ResXml.Sch_UnresolvedKeyref, new string[2] { ks.ToString(), vcs[i].constraint.name.ToString() }, - _sourceUriString, ks.PosLine, ks.PosCol)); - } - } - } - } - } //End of method - - private static void BuildXsiAttributes() - { - if (s_xsiTypeSO == null) - { //xsi:type attribute - XmlSchemaAttribute tempXsiTypeSO = new XmlSchemaAttribute(); - tempXsiTypeSO.Name = "type"; - tempXsiTypeSO.SetQualifiedName(new XmlQualifiedName("type", XmlReservedNs.NsXsi)); - tempXsiTypeSO.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName)); - Interlocked.CompareExchange(ref s_xsiTypeSO, tempXsiTypeSO, null); - } - if (s_xsiNilSO == null) - { //xsi:nil - XmlSchemaAttribute tempxsiNilSO = new XmlSchemaAttribute(); - tempxsiNilSO.Name = "nil"; - tempxsiNilSO.SetQualifiedName(new XmlQualifiedName("nil", XmlReservedNs.NsXsi)); - tempxsiNilSO.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean)); - Interlocked.CompareExchange(ref s_xsiNilSO, tempxsiNilSO, null); - } - if (s_xsiSLSO == null) - { //xsi:schemaLocation - XmlSchemaSimpleType stringType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String); - XmlSchemaAttribute tempxsiSLSO = new XmlSchemaAttribute(); - tempxsiSLSO.Name = "schemaLocation"; - tempxsiSLSO.SetQualifiedName(new XmlQualifiedName("schemaLocation", XmlReservedNs.NsXsi)); - tempxsiSLSO.SetAttributeType(stringType); - Interlocked.CompareExchange(ref s_xsiSLSO, tempxsiSLSO, null); - } - if (s_xsiNoNsSLSO == null) - { - XmlSchemaSimpleType stringType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String); - XmlSchemaAttribute tempxsiNoNsSLSO = new XmlSchemaAttribute(); - tempxsiNoNsSLSO.Name = "noNamespaceSchemaLocation"; - tempxsiNoNsSLSO.SetQualifiedName(new XmlQualifiedName("noNamespaceSchemaLocation", XmlReservedNs.NsXsi)); - tempxsiNoNsSLSO.SetAttributeType(stringType); - Interlocked.CompareExchange(ref s_xsiNoNsSLSO, tempxsiNoNsSLSO, null); - } - } - - internal static void ElementValidationError(XmlQualifiedName name, ValidationState context, ValidationEventHandler eventHandler, object sender, string sourceUri, int lineNo, int linePos, XmlSchemaSet schemaSet) - { - ArrayList names = null; - if (context.ElementDecl != null) - { - ContentValidator contentValidator = context.ElementDecl.ContentValidator; - XmlSchemaContentType contentType = contentValidator.ContentType; - if (contentType == XmlSchemaContentType.ElementOnly || (contentType == XmlSchemaContentType.Mixed && contentValidator != ContentValidator.Mixed && contentValidator != ContentValidator.Any)) - { - Debug.Assert(contentValidator is DfaContentValidator || contentValidator is NfaContentValidator || contentValidator is RangeContentValidator || contentValidator is AllElementsContentValidator); - bool getParticles = schemaSet != null; - if (getParticles) - { - names = contentValidator.ExpectedParticles(context, false, schemaSet); - } - else - { - names = contentValidator.ExpectedElements(context, false); - } - - if (names == null || names.Count == 0) - { - if (context.TooComplex) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementContentComplex, new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), ResXml.Sch_ComplexContentModel }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - else - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementContent, new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name) }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - } - else - { - Debug.Assert(names.Count > 0); - if (context.TooComplex) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementContentExpectingComplex, new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), PrintExpectedElements(names, getParticles), ResXml.Sch_ComplexContentModel }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - else - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementContentExpecting, new string[] { BuildElementName(context.LocalName, context.Namespace), BuildElementName(name), PrintExpectedElements(names, getParticles) }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - } - } - else - { //Base ContentValidator: Empty || TextOnly || Mixed || Any - if (contentType == XmlSchemaContentType.Empty) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementInEmptyEx, new string[] { QNameString(context.LocalName, context.Namespace), name.ToString() }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - else if (!contentValidator.IsOpen) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_InvalidElementInTextOnlyEx, new string[] { QNameString(context.LocalName, context.Namespace), name.ToString() }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - } - } - } - - internal static void CompleteValidationError(ValidationState context, ValidationEventHandler eventHandler, object sender, string sourceUri, int lineNo, int linePos, XmlSchemaSet schemaSet) - { - ArrayList names = null; - bool getParticles = schemaSet != null; - if (context.ElementDecl != null) - { - if (getParticles) - { - names = context.ElementDecl.ContentValidator.ExpectedParticles(context, true, schemaSet); - } - else - { - names = context.ElementDecl.ContentValidator.ExpectedElements(context, true); - } - } - if (names == null || names.Count == 0) - { - if (context.TooComplex) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_IncompleteContentComplex, new string[] { BuildElementName(context.LocalName, context.Namespace), ResXml.Sch_ComplexContentModel }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_IncompleteContent, BuildElementName(context.LocalName, context.Namespace), sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - else - { - Debug.Assert(names.Count > 0); - if (context.TooComplex) - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_IncompleteContentExpectingComplex, new string[] { BuildElementName(context.LocalName, context.Namespace), PrintExpectedElements(names, getParticles), ResXml.Sch_ComplexContentModel }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - else - { - SendValidationEvent(eventHandler, sender, new XmlSchemaValidationException(ResXml.Sch_IncompleteContentExpecting, new string[] { BuildElementName(context.LocalName, context.Namespace), PrintExpectedElements(names, getParticles) }, sourceUri, lineNo, linePos), XmlSeverityType.Error); - } - } - } - - internal static string PrintExpectedElements(ArrayList expected, bool getParticles) - { - if (getParticles) - { - string ContinuationString = string.Format(ResXml.Sch_ContinuationString, new string[] { " " }); - XmlSchemaParticle currentParticle = null; - XmlSchemaParticle nextParticle = null; - XmlQualifiedName currentQName; - ArrayList expectedNames = new ArrayList(); - StringBuilder builder = new StringBuilder(); - - if (expected.Count == 1) - { - nextParticle = expected[0] as XmlSchemaParticle; - } - else - { - for (int i = 1; i < expected.Count; i++) - { - currentParticle = expected[i - 1] as XmlSchemaParticle; - nextParticle = expected[i] as XmlSchemaParticle; - currentQName = currentParticle.GetQualifiedName(); - if (currentQName.Namespace != nextParticle.GetQualifiedName().Namespace) - { - expectedNames.Add(currentQName); - PrintNamesWithNS(expectedNames, builder); - expectedNames.Clear(); - Debug.Assert(builder.Length != 0); - builder.Append(ContinuationString); - } - else - { - expectedNames.Add(currentQName); - } - } - } - //Add last one. - expectedNames.Add(nextParticle.GetQualifiedName()); - PrintNamesWithNS(expectedNames, builder); - - return builder.ToString(); - } - else - { - return PrintNames(expected); - } - } - - private static string PrintNames(ArrayList expected) - { - StringBuilder builder = new StringBuilder(); - builder.Append(Quote); - builder.Append(expected[0].ToString()); - for (int i = 1; i < expected.Count; ++i) - { - builder.Append(" "); - builder.Append(expected[i].ToString()); - } - builder.Append(Quote); - return builder.ToString(); - } - - private static void PrintNamesWithNS(ArrayList expected, StringBuilder builder) - { - XmlQualifiedName name = null; - name = expected[0] as XmlQualifiedName; - if (expected.Count == 1) - { //In case of one element in a namespace or any - if (name.Name == "*") - { //Any - EnumerateAny(builder, name.Namespace); - } - else - { - if (name.Namespace.Length != 0) - { - builder.Append(string.Format(ResXml.Sch_ElementNameAndNamespace, name.Name, name.Namespace)); - } - else - { - builder.Append(string.Format(ResXml.Sch_ElementName, name.Name)); - } - } - } - else - { - bool foundAny = false; - bool first = true; - StringBuilder subBuilder = new StringBuilder(); - for (int i = 0; i < expected.Count; i++) - { - name = expected[i] as XmlQualifiedName; - if (name.Name == "*") - { //rare case where ns of element and that of Any match - foundAny = true; - continue; - } - if (first) - { - first = false; - } - else - { - subBuilder.Append(", "); - } - subBuilder.Append(name.Name); - } - if (foundAny) - { - subBuilder.Append(", "); - subBuilder.Append(ResXml.Sch_AnyElement); - } - else - { - if (name.Namespace.Length != 0) - { - builder.Append(string.Format(ResXml.Sch_ElementNameAndNamespace, subBuilder.ToString(), name.Namespace)); - } - else - { - builder.Append(string.Format(ResXml.Sch_ElementName, subBuilder.ToString())); - } - } - } - } - - private static void EnumerateAny(StringBuilder builder, string namespaces) - { - StringBuilder subBuilder = new StringBuilder(); - if (namespaces == "##any" || namespaces == "##other") - { - subBuilder.Append(namespaces); - } - else - { - string[] nsList = XmlConvert.SplitString(namespaces); - Debug.Assert(nsList.Length > 0); - subBuilder.Append(nsList[0]); - for (int i = 1; i < nsList.Length; i++) - { - subBuilder.Append(", "); - subBuilder.Append(nsList[i]); - } - } - builder.Append(string.Format(ResXml.Sch_AnyElementNS, subBuilder.ToString())); - } - - internal static string QNameString(string localName, string ns) - { - return (ns.Length != 0) ? string.Concat(ns, ":", localName) : localName; - } - - internal static string BuildElementName(XmlQualifiedName qname) - { - return BuildElementName(qname.Name, qname.Namespace); - } - - internal static string BuildElementName(string localName, string ns) - { - if (ns.Length != 0) - { - return string.Format(ResXml.Sch_ElementNameAndNamespace, localName, ns); - } - else - { - return string.Format(ResXml.Sch_ElementName, localName); - } - } - - private void ProcessEntity(string name) - { - if (!_checkEntity) - { - return; - } - IDtdEntityInfo entityInfo = null; - if (_dtdSchemaInfo != null) - { - entityInfo = _dtdSchemaInfo.LookupEntity(name); - } - if (entityInfo == null) - { - // validation error, see xml spec [68] - SendValidationEvent(ResXml.Sch_UndeclaredEntity, name); - } - else if (entityInfo.IsUnparsedEntity) - { - // validation error, see xml spec [68] - SendValidationEvent(ResXml.Sch_UnparsedEntityRef, name); - } - } - - private void SendValidationEvent(string code) - { - SendValidationEvent(code, string.Empty); - } - - private void SendValidationEvent(string code, string[] args) - { - SendValidationEvent(new XmlSchemaValidationException(code, args, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - private void SendValidationEvent(string code, string arg) - { - SendValidationEvent(new XmlSchemaValidationException(code, arg, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - private void SendValidationEvent(string code, string arg1, string arg2) - { - SendValidationEvent(new XmlSchemaValidationException(code, new string[] { arg1, arg2 }, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - private void SendValidationEvent(string code, string[] args, Exception innerException, XmlSeverityType severity) - { - if (severity != XmlSeverityType.Warning || ReportValidationWarnings) - { - SendValidationEvent(new XmlSchemaValidationException(code, args, innerException, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - } - - private void SendValidationEvent(string code, string[] args, Exception innerException) - { - SendValidationEvent(new XmlSchemaValidationException(code, args, innerException, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition), XmlSeverityType.Error); - } - - private void SendValidationEvent(XmlSchemaValidationException e) - { - SendValidationEvent(e, XmlSeverityType.Error); - } - - private void SendValidationEvent(XmlSchemaException e) - { - SendValidationEvent(new XmlSchemaValidationException(e.GetRes, e.Args, e.SourceUri, e.LineNumber, e.LinePosition), XmlSeverityType.Error); - } - - private void SendValidationEvent(string code, string msg, XmlSeverityType severity) - { - if (severity != XmlSeverityType.Warning || ReportValidationWarnings) - { - SendValidationEvent(new XmlSchemaValidationException(code, msg, _sourceUriString, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - } - - private void SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity) - { - bool errorSeverity = false; - if (severity == XmlSeverityType.Error) - { - errorSeverity = true; - _context.Validity = XmlSchemaValidity.Invalid; - } - if (errorSeverity) - { - if (_eventHandler != null) - { - _eventHandler(_validationEventSender, new ValidationEventArgs(e, severity)); - } - else - { - throw e; - } - } - else if (ReportValidationWarnings && _eventHandler != null) - { - _eventHandler(_validationEventSender, new ValidationEventArgs(e, severity)); - } - } - - internal static void SendValidationEvent(ValidationEventHandler eventHandler, object sender, XmlSchemaValidationException e, XmlSeverityType severity) - { - if (eventHandler != null) - { - eventHandler(sender, new ValidationEventArgs(e, severity)); - } - else if (severity == XmlSeverityType.Error) - { - throw e; - } - } - } //End of class -} //End of namespace diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidity.cs deleted file mode 100644 index d649eccf9c7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSchemaValidity.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - /// - /// [To be supplied.] - /// - public enum XmlSchemaValidity - { - /// - NotKnown, - /// - Valid, - /// - Invalid, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSeverityType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSeverityType.cs deleted file mode 100644 index e7ff07c6089..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlSeverityType.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - //UE Atention - /// - public enum XmlSeverityType - { - /// Errors that can be recovered from. - /// - Error, - /// Errors that can be ignored - /// - Warning - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTokenizedType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTokenizedType.cs deleted file mode 100644 index cf3459ddc36..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTokenizedType.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -namespace Microsoft.Xml -{ - using System; - - - // NOTE: Absolute numbering is utilized in DtdParser. -HelenaK - public enum XmlTokenizedType - { - CDATA = 0, - ID = 1, - IDREF = 2, - IDREFS = 3, - ENTITY = 4, - ENTITIES = 5, - NMTOKEN = 6, - NMTOKENS = 7, - NOTATION = 8, - ENUMERATION = 9, - QName = 10, - NCName = 11, - None = 12 - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTypeCode.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTypeCode.cs deleted file mode 100644 index 18eb5e468ad..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlTypeCode.cs +++ /dev/null @@ -1,179 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - /// - public enum XmlTypeCode - { - /// - None, - - /// - Item, - - /// - Node, - - /// - Document, - - /// - Element, - - /// - Attribute, - - /// - Namespace, - - /// - ProcessingInstruction, - - /// - Comment, - - /// - Text, - - /// - AnyAtomicType, - - /// - UntypedAtomic, - - /// - String, - - /// - Boolean, - - /// - Decimal, - - /// - Float, - - /// - Double, - - /// - Duration, - - /// - DateTime, - - /// - Time, - - /// - Date, - - /// - GYearMonth, - - /// - GYear, - - /// - GMonthDay, - - /// - GDay, - - /// - GMonth, - - /// - HexBinary, - - /// - Base64Binary, - - /// - AnyUri, - - /// - QName, - - /// - Notation, - - /// - NormalizedString, - - /// - Token, - - /// - Language, - - /// - NmToken, - - /// - Name, - - /// - NCName, - - /// - Id, - - /// - Idref, - - /// - Entity, - - /// - Integer, - - /// - NonPositiveInteger, - - /// - NegativeInteger, - - /// - Long, - - /// - Int, - - /// - Short, - - /// - Byte, - - /// - NonNegativeInteger, - - /// - UnsignedLong, - - /// - UnsignedInt, - - /// - UnsignedShort, - - /// - UnsignedByte, - - /// - PositiveInteger, - - /// - YearMonthDuration, - - /// - DayTimeDuration, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlValueConverter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlValueConverter.cs deleted file mode 100644 index 6dfa392d251..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XmlValueConverter.cs +++ /dev/null @@ -1,3733 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using Microsoft.Xml.XPath; -using System.Globalization; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; -using Microsoft.Xml.Schema; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; -using System.Reflection; - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - // - // NOTE!!! LARGE PORTIONS OF THIS FILE ARE AUTOGENERATED BY GENERATECONVERTER.CS. DO NOT MANUALLY CHANGE ANY CODE - // WITHIN #REGION. INSTEAD, MODIFY GENERATECONVERTER.CS. - // - - // SUMMARY - // ======= - // For each Xml type, there is a set of Clr types that can represent it. Some of these mappings involve - // loss of fidelity. For example, xsd:dateTime can be represented as System.DateTime, but only at the expense - // of normalizing the time zone. And xs:duration can be represented as System.TimeSpan, but only at the expense - // of discarding variations such as "P50H", "P1D26H", "P2D2H", all of which are normalized as "P2D2H". - // - // Implementations of this class convert between the various Clr representations of Xml types. Note that - // in *no* case is the Xml type ever modified. Only the Clr type is changed. This means that in cases where - // the Xml type is part of the representation (such as XmlAtomicValue), the destination value is guaranteed - // to have the same Xml type. - // - // For all converters, converting to typeof(object) is identical to converting to XmlSchemaType.Datatype.ValueType. - // - // - // ATOMIC MAPPINGS - // =============== - // - // ----------------------------------------------------------------------------------------------------------- - // Source/Destination System.String Other Clr Type - // ----------------------------------------------------------------------------------------------------------- - // System.String No-op conversion. Use Xsd rules to convert from the string - // to primitive, full-fidelity Clr type (use - // XmlConvert where possible). Use Clr rules - // to convert to destination type. - // ----------------------------------------------------------------------------------------------------------- - // Other Clr Type Use Clr rules to convert from Use Clr rules to convert from source to - // source type to primitive, full- destination type. - // fidelity Clr type. Use Xsd rules - // to convert to a string (use - // XmlConvert where possible). - // ----------------------------------------------------------------------------------------------------------- - // - // - // LIST MAPPINGS - // ============= - // The following Clr types can be used to represent Xsd list types: IList, ICollection, IEnumerable, Type[], - // String. - // - // ----------------------------------------------------------------------------------------------------------- - // Source/Destination System.String Clr List Type - // ----------------------------------------------------------------------------------------------------------- - // System.String No-op conversion Tokenize the string by whitespace, create a - // String[] from tokens, and follow List => List - // rules. - // ----------------------------------------------------------------------------------------------------------- - // Clr List Type Follow List => String[] rules, Create destination list having the same length - // then concatenate strings from array, as the source list. For each item in the - // separating adjacent strings with a source list, call the atomic converter to - // single space character. convert to the destination type. The destination - // item type for IList, ICollection, IEnumerable - // is typeof(object). The destination item type - // for Type[] is Type. - // ----------------------------------------------------------------------------------------------------------- - // - // - // UNION MAPPINGS - // ============== - // Union types may only be represented using Microsoft.Xml.Schema.XmlAtomicValue or System.String. Either the - // source type or the destination type must therefore always be either System.String or - // Microsoft.Xml.Schema.XmlAtomicValue. - // - // ----------------------------------------------------------------------------------------------------------- - // Source/Destination System.String XmlAtomicValue Other Clr Type - // ----------------------------------------------------------------------------------------------------------- - // System.String No-op conversion Follow System.String=> Call ParseValue in order to determine - // Other Clr Type rules. the member type. Call ChangeType on - // the member type's converter to convert - // to desired Clr type. - // ----------------------------------------------------------------------------------------------------------- - // XmlAtomicValue Follow XmlAtomicValue No-op conversion. Call ReadValueAs, where destinationType - // => Other Clr Type is the desired Clr type. - // rules. - // ----------------------------------------------------------------------------------------------------------- - // Other Clr Type InvalidCastException InvalidCastException InvalidCastException - // ----------------------------------------------------------------------------------------------------------- - // - // - // EXAMPLES - // ======== - // - // ----------------------------------------------------------------------------------------------------------- - // Source Destination - // Xml Type Value Type Conversion Steps Explanation - // ----------------------------------------------------------------------------------------------------------- - // xs:int "10" Byte "10" => 10M => (byte) 10 Primitive, full-fidelity for xs:int - // is a truncated decimal - // ----------------------------------------------------------------------------------------------------------- - // xs:int "10.10" Byte FormatException xs:integer parsing rules do not - // allow fractional parts - // ----------------------------------------------------------------------------------------------------------- - // xs:int 10.10M Byte 10.10M => (byte) 10 Default Clr rules truncate when - // converting from Decimal to Byte - // ----------------------------------------------------------------------------------------------------------- - // xs:int 10.10M Decimal 10.10M => 10.10M Decimal => Decimal is no-op - // ----------------------------------------------------------------------------------------------------------- - // xs:int 10.10M String 10.10M => 10M => "10" - // ----------------------------------------------------------------------------------------------------------- - // xs:int "hello" String "hello" => "hello" String => String is no-op - // ----------------------------------------------------------------------------------------------------------- - // xs:byte "300" Int32 "300" => 300M => (int) 300 - // ----------------------------------------------------------------------------------------------------------- - // xs:byte 300 Byte 300 => 300M => OverflowException Clr overflows when converting from - // Decimal to Byte - // ----------------------------------------------------------------------------------------------------------- - // xs:byte 300 XmlAtomicValue new XmlAtomicValue(xs:byte, 300) Invalid atomic value created - // ----------------------------------------------------------------------------------------------------------- - // xs:double 1.234f String 1.234f => 1.2339999675750732d => Converting a Single value to a Double - // "1.2339999675750732" value zero-extends it in base-2, so - // "garbage" digits appear when it's - // converted to base-10. - // ----------------------------------------------------------------------------------------------------------- - // xs:int* {1, "2", String {1, "2", 3.1M} => Delegate to xs:int converter to - // 3.1M} {"1", "2", "3"} => "1 2 3" convert each item to a string. - // ----------------------------------------------------------------------------------------------------------- - // xs:int* "1 2 3" Int32[] "1 2 3" => {"1", "2", "3"} => - // {1, 2, 3} - // ----------------------------------------------------------------------------------------------------------- - // xs:int* {1, "2", Object[] {1, "2", 3.1M} => xs:int converter uses Int32 by default, - // 3.1M} {(object)1, (object)2, (object)3} so returns boxed Int32 values. - // ----------------------------------------------------------------------------------------------------------- - // (xs:int | "1 2001" XmlAtomicValue[] "1 2001" => {(xs:int) 1, - // xs:gYear)* (xs:gYear) 2001} - // ----------------------------------------------------------------------------------------------------------- - // (xs:int* | "1 2001" String "1 2001" No-op conversion even though - // xs:gYear*) ParseValue would fail if it were called. - // ----------------------------------------------------------------------------------------------------------- - // (xs:int* | "1 2001" Int[] XmlSchemaException ParseValue fails. - // xs:gYear*) - // ----------------------------------------------------------------------------------------------------------- - // - internal abstract class XmlValueConverter - { - public abstract bool ToBoolean(bool value); - public abstract bool ToBoolean(long value); - public abstract bool ToBoolean(int value); - public abstract bool ToBoolean(decimal value); - public abstract bool ToBoolean(float value); - public abstract bool ToBoolean(double value); - public abstract bool ToBoolean(DateTime value); - public abstract bool ToBoolean(DateTimeOffset value); - public abstract bool ToBoolean(string value); - public abstract bool ToBoolean(object value); - - public abstract int ToInt32(bool value); - public abstract int ToInt32(int value); - public abstract int ToInt32(long value); - public abstract int ToInt32(decimal value); - public abstract int ToInt32(float value); - public abstract int ToInt32(double value); - public abstract int ToInt32(DateTime value); - public abstract int ToInt32(DateTimeOffset value); - public abstract int ToInt32(string value); - public abstract int ToInt32(object value); - - public abstract long ToInt64(bool value); - public abstract long ToInt64(int value); - public abstract long ToInt64(long value); - public abstract long ToInt64(decimal value); - public abstract long ToInt64(float value); - public abstract long ToInt64(double value); - public abstract long ToInt64(DateTime value); - public abstract long ToInt64(DateTimeOffset value); - public abstract long ToInt64(string value); - public abstract long ToInt64(object value); - - public abstract decimal ToDecimal(bool value); - public abstract decimal ToDecimal(int value); - public abstract decimal ToDecimal(long value); - public abstract decimal ToDecimal(decimal value); - public abstract decimal ToDecimal(float value); - public abstract decimal ToDecimal(double value); - public abstract decimal ToDecimal(DateTime value); - public abstract decimal ToDecimal(DateTimeOffset value); - public abstract decimal ToDecimal(string value); - public abstract decimal ToDecimal(object value); - - public abstract double ToDouble(bool value); - public abstract double ToDouble(int value); - public abstract double ToDouble(long value); - public abstract double ToDouble(decimal value); - public abstract double ToDouble(float value); - public abstract double ToDouble(double value); - public abstract double ToDouble(DateTime value); - public abstract double ToDouble(DateTimeOffset value); - public abstract double ToDouble(string value); - public abstract double ToDouble(object value); - - public abstract float ToSingle(bool value); - public abstract float ToSingle(int value); - public abstract float ToSingle(long value); - public abstract float ToSingle(decimal value); - public abstract float ToSingle(float value); - public abstract float ToSingle(double value); - public abstract float ToSingle(DateTime value); - public abstract float ToSingle(DateTimeOffset value); - public abstract float ToSingle(string value); - public abstract float ToSingle(object value); - - public abstract DateTime ToDateTime(bool value); - public abstract DateTime ToDateTime(int value); - public abstract DateTime ToDateTime(long value); - public abstract DateTime ToDateTime(decimal value); - public abstract DateTime ToDateTime(float value); - public abstract DateTime ToDateTime(double value); - public abstract DateTime ToDateTime(DateTime value); - public abstract DateTime ToDateTime(DateTimeOffset value); - public abstract DateTime ToDateTime(string value); - public abstract DateTime ToDateTime(object value); - - public abstract DateTimeOffset ToDateTimeOffset(bool value); - public abstract DateTimeOffset ToDateTimeOffset(int value); - public abstract DateTimeOffset ToDateTimeOffset(long value); - public abstract DateTimeOffset ToDateTimeOffset(decimal value); - public abstract DateTimeOffset ToDateTimeOffset(float value); - public abstract DateTimeOffset ToDateTimeOffset(double value); - public abstract DateTimeOffset ToDateTimeOffset(DateTime value); - public abstract DateTimeOffset ToDateTimeOffset(DateTimeOffset value); - public abstract DateTimeOffset ToDateTimeOffset(string value); - public abstract DateTimeOffset ToDateTimeOffset(object value); - - public abstract string ToString(bool value); - public abstract string ToString(int value); - public abstract string ToString(long value); - public abstract string ToString(decimal value); - public abstract string ToString(float value); - public abstract string ToString(double value); - public abstract string ToString(DateTime value); - public abstract string ToString(DateTimeOffset value); - public abstract string ToString(string value); - public abstract string ToString(string value, IXmlNamespaceResolver nsResolver); - public abstract string ToString(object value); - public abstract string ToString(object value, IXmlNamespaceResolver nsResolver); - - public abstract object ChangeType(bool value, Type destinationType); - public abstract object ChangeType(int value, Type destinationType); - public abstract object ChangeType(long value, Type destinationType); - public abstract object ChangeType(decimal value, Type destinationType); - public abstract object ChangeType(float value, Type destinationType); - public abstract object ChangeType(double value, Type destinationType); - public abstract object ChangeType(DateTime value, Type destinationType); - public abstract object ChangeType(DateTimeOffset value, Type destinationType); - public abstract object ChangeType(string value, Type destinationType); - public abstract object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver); - public abstract object ChangeType(object value, Type destinationType); - public abstract object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver); - } - - internal abstract class XmlBaseConverter : XmlValueConverter - { - private XmlSchemaType _schemaType; - private XmlTypeCode _typeCode; - private Type _clrTypeDefault; - - protected XmlBaseConverter(XmlSchemaType schemaType) - { - // XmlValueConverter is defined only on types with simple content - XmlSchemaDatatype datatype = schemaType.Datatype; - Debug.Assert(schemaType != null && datatype != null, "schemaType or schemaType.Datatype may not be null"); - - while (schemaType != null && !(schemaType is XmlSchemaSimpleType)) - { - schemaType = schemaType.BaseXmlSchemaType; - } - if (schemaType == null) - { //Did not find any simple type in the parent chain - schemaType = XmlSchemaType.GetBuiltInSimpleType(datatype.TypeCode); - } - Debug.Assert(schemaType.Datatype.Variety != XmlSchemaDatatypeVariety.List, "schemaType must be list's item type, not list itself"); - - _schemaType = schemaType; - _typeCode = schemaType.TypeCode; - _clrTypeDefault = schemaType.Datatype.ValueType; - } - - protected XmlBaseConverter(XmlTypeCode typeCode) - { - switch (typeCode) - { - case XmlTypeCode.Item: - _clrTypeDefault = XPathItemType; - break; - - case XmlTypeCode.Node: - _clrTypeDefault = XPathNavigatorType; - break; - - case XmlTypeCode.AnyAtomicType: - _clrTypeDefault = XmlAtomicValueType; - break; - - default: - Debug.Assert(false, "Type code " + typeCode + " is not supported."); - break; - } - - _typeCode = typeCode; - } - - protected XmlBaseConverter(XmlBaseConverter converterAtomic) - { - _schemaType = converterAtomic._schemaType; - _typeCode = converterAtomic._typeCode; - _clrTypeDefault = Array.CreateInstance(converterAtomic.DefaultClrType, 0).GetType(); - } - - protected XmlBaseConverter(XmlBaseConverter converterAtomic, Type clrTypeDefault) - { - _schemaType = converterAtomic._schemaType; - _typeCode = converterAtomic._typeCode; - _clrTypeDefault = clrTypeDefault; - } - - protected static readonly Type ICollectionType = typeof(ICollection); - protected static readonly Type IEnumerableType = typeof(IEnumerable); - protected static readonly Type IListType = typeof(IList); - protected static readonly Type ObjectArrayType = typeof(object[]); - protected static readonly Type StringArrayType = typeof(string[]); - protected static readonly Type XmlAtomicValueArrayType = typeof(XmlAtomicValue[]); - - #region AUTOGENERATED_XMLBASECONVERTER - protected static readonly Type DecimalType = typeof(decimal); - protected static readonly Type Int32Type = typeof(int); - protected static readonly Type Int64Type = typeof(long); - protected static readonly Type StringType = typeof(string); - protected static readonly Type XmlAtomicValueType = typeof(XmlAtomicValue); - protected static readonly Type ObjectType = typeof(object); - protected static readonly Type ByteType = typeof(byte); - protected static readonly Type Int16Type = typeof(short); - protected static readonly Type SByteType = typeof(sbyte); - protected static readonly Type UInt16Type = typeof(ushort); - protected static readonly Type UInt32Type = typeof(uint); - protected static readonly Type UInt64Type = typeof(ulong); - protected static readonly Type XPathItemType = typeof(XPathItem); - protected static readonly Type DoubleType = typeof(double); - protected static readonly Type SingleType = typeof(float); - protected static readonly Type DateTimeType = typeof(DateTime); - protected static readonly Type DateTimeOffsetType = typeof(DateTimeOffset); - protected static readonly Type BooleanType = typeof(bool); - protected static readonly Type ByteArrayType = typeof(Byte[]); - protected static readonly Type XmlQualifiedNameType = typeof(XmlQualifiedName); - protected static readonly Type UriType = typeof(Uri); - protected static readonly Type TimeSpanType = typeof(TimeSpan); - protected static readonly Type XPathNavigatorType = typeof(XPathNavigator); - - public override bool ToBoolean(bool value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(DateTime value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(DateTimeOffset value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(decimal value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(double value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(int value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(long value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(float value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(string value) { return (bool)ChangeType((object)value, BooleanType, null); } - public override bool ToBoolean(object value) { return (bool)ChangeType((object)value, BooleanType, null); } - - public override DateTime ToDateTime(bool value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(DateTime value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(DateTimeOffset value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(decimal value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(double value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(int value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(long value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(float value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(string value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - public override DateTime ToDateTime(object value) { return (DateTime)ChangeType((object)value, DateTimeType, null); } - - public override DateTimeOffset ToDateTimeOffset(bool value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(DateTime value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(DateTimeOffset value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(decimal value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(double value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(int value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(long value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(float value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(string value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - public override DateTimeOffset ToDateTimeOffset(object value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); } - - public override decimal ToDecimal(bool value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(DateTime value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(DateTimeOffset value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(decimal value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(double value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(int value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(long value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(float value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(string value) { return (decimal)ChangeType((object)value, DecimalType, null); } - public override decimal ToDecimal(object value) { return (decimal)ChangeType((object)value, DecimalType, null); } - - public override double ToDouble(bool value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(DateTime value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(DateTimeOffset value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(decimal value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(double value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(int value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(long value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(float value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(string value) { return (double)ChangeType((object)value, DoubleType, null); } - public override double ToDouble(object value) { return (double)ChangeType((object)value, DoubleType, null); } - - public override int ToInt32(bool value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(DateTime value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(DateTimeOffset value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(decimal value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(double value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(int value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(long value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(float value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(string value) { return (int)ChangeType((object)value, Int32Type, null); } - public override int ToInt32(object value) { return (int)ChangeType((object)value, Int32Type, null); } - - public override long ToInt64(bool value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(DateTime value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(DateTimeOffset value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(decimal value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(double value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(int value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(long value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(float value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(string value) { return (long)ChangeType((object)value, Int64Type, null); } - public override long ToInt64(object value) { return (long)ChangeType((object)value, Int64Type, null); } - - public override float ToSingle(bool value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(DateTime value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(DateTimeOffset value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(decimal value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(double value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(int value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(long value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(float value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(string value) { return (float)ChangeType((object)value, SingleType, null); } - public override float ToSingle(object value) { return (float)ChangeType((object)value, SingleType, null); } - - public override string ToString(bool value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(DateTime value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(DateTimeOffset value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(decimal value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(double value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(int value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(long value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(float value) { return (string)ChangeType((object)value, StringType, null); } - public override string ToString(string value, IXmlNamespaceResolver nsResolver) { return (string)ChangeType((object)value, StringType, nsResolver); } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) { return (string)ChangeType((object)value, StringType, nsResolver); } - public override string ToString(string value) { return this.ToString(value, null); } - public override string ToString(object value) { return this.ToString(value, null); } - - public override object ChangeType(bool value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(DateTime value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(DateTimeOffset value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(decimal value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(double value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(int value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(long value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(float value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); } - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) { return (object)ChangeType((object)value, destinationType, nsResolver); } - public override object ChangeType(string value, Type destinationType) { return this.ChangeType(value, destinationType, null); } - public override object ChangeType(object value, Type destinationType) { return this.ChangeType(value, destinationType, null); } - - #endregion - - /// - /// Return this converter's prime schema type (may be null in case of Node, Item, etc). - /// - protected XmlSchemaType SchemaType - { - get { return _schemaType; } - } - - /// - /// Return the XmlTypeCode of this converter's prime schema type. - /// - protected XmlTypeCode TypeCode - { - get { return _typeCode; } - } - - /// - /// Return a string representation of this converter's prime schema type. - /// - protected string XmlTypeName - { - get - { - XmlSchemaType type = _schemaType; - - if (type != null) - { - while (type.QualifiedName.IsEmpty) - { - // Walk base classes until one with a name is found (in worst case, all simple types derive from xs:anySimpleType) - type = type.BaseXmlSchemaType; - } - - return QNameToString(type.QualifiedName); - } - - // SchemaType is null in the case of item, node, and xdt:anyAtomicType - if (_typeCode == XmlTypeCode.Node) return "node"; - if (_typeCode == XmlTypeCode.AnyAtomicType) return "xdt:anyAtomicType"; - - Debug.Assert(_typeCode == XmlTypeCode.Item, "If SchemaType is null, then TypeCode may only be Item, Node, or AnyAtomicType"); - return "item"; - } - } - - /// - /// Return default V1 Clr mapping of this converter's type. - /// - protected Type DefaultClrType - { - get { return _clrTypeDefault; } - } - - /// - /// Type.IsSubtypeOf does not return true if types are equal, this method does. - /// - protected static bool IsDerivedFrom(Type derivedType, Type baseType) - { - while (derivedType != null) - { - if (derivedType == baseType) - return true; - - derivedType = derivedType.GetTypeInfo().BaseType; - } - return false; - } - - /// - /// Create an InvalidCastException for cases where either "destinationType" or "sourceType" is not a supported CLR representation - /// for this Xml type. - /// - protected Exception CreateInvalidClrMappingException(Type sourceType, Type destinationType) - { - if (sourceType == destinationType) - return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeBadMapping, XmlTypeName, sourceType.Name)); - - return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name)); - } - - /// - /// Convert an XmlQualifiedName to a string, using somewhat different rules than XmlQualifiedName.ToString(): - /// 1. Recognize the built-in xs: and xdt: namespaces and print the short prefix rather than the long namespace - /// 2. Use brace characters "{", "}" around the namespace portion of the QName - /// - protected static string QNameToString(XmlQualifiedName name) - { - if (name.Namespace.Length == 0) - { - return name.Name; - } - else if (name.Namespace == XmlReservedNs.NsXs) - { - return "xs:" + name.Name; - } - else if (name.Namespace == XmlReservedNs.NsXQueryDataType) - { - return "xdt:" + name.Name; - } - else - { - return "{" + name.Namespace + "}" + name.Name; - } - } - - /// - /// This method is called when a valid conversion cannot be found. By default, this method throws an error. It can - /// be overriden in derived classes to support list conversions. - /// - protected virtual object ChangeListType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - throw CreateInvalidClrMappingException(value.GetType(), destinationType); - } - - - //------------------------------------------------------------------------ - // From String Conversion Helpers - //------------------------------------------------------------------------ - - protected static byte[] StringToBase64Binary(string value) - { - return Convert.FromBase64String(XmlConvert.TrimString(value)); - } - - protected static DateTime StringToDate(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.Date)); - } - - protected static DateTime StringToDateTime(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.DateTime)); - } - - protected static TimeSpan StringToDayTimeDuration(string value) - { - // Parse string as DayTimeDuration and convert it to a DayTimeDuration TimeSpan (it is an error to have year and month parts) - return new XsdDuration(value, XsdDuration.DurationType.DayTimeDuration).ToTimeSpan(XsdDuration.DurationType.DayTimeDuration); - } - - protected static TimeSpan StringToDuration(string value) - { - return new XsdDuration(value, XsdDuration.DurationType.Duration).ToTimeSpan(XsdDuration.DurationType.Duration); - } - - protected static DateTime StringToGDay(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.GDay)); - } - - protected static DateTime StringToGMonth(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.GMonth)); - } - - protected static DateTime StringToGMonthDay(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.GMonthDay)); - } - - protected static DateTime StringToGYear(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.GYear)); - } - - protected static DateTime StringToGYearMonth(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.GYearMonth)); - } - - protected static DateTimeOffset StringToDateOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Date)); - } - - protected static DateTimeOffset StringToDateTimeOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.DateTime)); - } - - protected static DateTimeOffset StringToGDayOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GDay)); - } - - protected static DateTimeOffset StringToGMonthOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonth)); - } - - protected static DateTimeOffset StringToGMonthDayOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonthDay)); - } - - protected static DateTimeOffset StringToGYearOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYear)); - } - - protected static DateTimeOffset StringToGYearMonthOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYearMonth)); - } - - protected static byte[] StringToHexBinary(string value) - { - try - { - return XmlConvert.FromBinHexString(XmlConvert.TrimString(value), false); - } - catch (XmlException e) - { - throw new FormatException(e.Message); - } - } - - protected static XmlQualifiedName StringToQName(string value, IXmlNamespaceResolver nsResolver) - { - string prefix, localName, ns; - - value = value.Trim(); - - // Parse prefix:localName - try - { - ValidateNames.ParseQNameThrow(value, out prefix, out localName); - } - catch (XmlException e) - { - throw new FormatException(e.Message); - } - - // Throw error if no namespaces are in scope - if (nsResolver == null) - throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoNamespace, value, prefix)); - - // Lookup namespace - ns = nsResolver.LookupNamespace(prefix); - if (ns == null) - throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoNamespace, value, prefix)); - - // Create XmlQualfiedName - return new XmlQualifiedName(localName, ns); - } - - protected static DateTime StringToTime(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.Time)); - } - - protected static DateTimeOffset StringToTimeOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Time)); - } - - protected static TimeSpan StringToYearMonthDuration(string value) - { - // Parse string as YearMonthDuration and convert it to a YearMonthDuration TimeSpan (it is an error to have day and time parts) - return new XsdDuration(value, XsdDuration.DurationType.YearMonthDuration).ToTimeSpan(XsdDuration.DurationType.YearMonthDuration); - } - - - //------------------------------------------------------------------------ - // To String Conversion Helpers - //------------------------------------------------------------------------ - - protected static string AnyUriToString(Uri value) - { - return value.OriginalString; - } - - protected static string Base64BinaryToString(byte[] value) - { - return Convert.ToBase64String(value); - } - - protected static string DateToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.Date)).ToString(); - } - - protected static string DateTimeToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.DateTime)).ToString(); - } - - protected static string DayTimeDurationToString(TimeSpan value) - { - return new XsdDuration(value, XsdDuration.DurationType.DayTimeDuration).ToString(XsdDuration.DurationType.DayTimeDuration); - } - - protected static string DurationToString(TimeSpan value) - { - return new XsdDuration(value, XsdDuration.DurationType.Duration).ToString(XsdDuration.DurationType.Duration); - } - - protected static string GDayToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GDay)).ToString(); - } - - protected static string GMonthToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GMonth)).ToString(); - } - - protected static string GMonthDayToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GMonthDay)).ToString(); - } - - protected static string GYearToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GYear)).ToString(); - } - - protected static string GYearMonthToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GYearMonth)).ToString(); - } - - protected static string DateOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.Date)).ToString(); - } - - protected static string DateTimeOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.DateTime)).ToString(); - } - - protected static string GDayOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GDay)).ToString(); - } - - protected static string GMonthOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GMonth)).ToString(); - } - - protected static string GMonthDayOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GMonthDay)).ToString(); - } - - protected static string GYearOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GYear)).ToString(); - } - - protected static string GYearMonthOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.GYearMonth)).ToString(); - } - - protected static string QNameToString(XmlQualifiedName qname, IXmlNamespaceResolver nsResolver) - { - string prefix; - - if (nsResolver == null) - return string.Concat("{", qname.Namespace, "}", qname.Name); - - prefix = nsResolver.LookupPrefix(qname.Namespace); - if (prefix == null) - throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeNoPrefix, qname.ToString(), qname.Namespace)); - - return (prefix.Length != 0) ? string.Concat(prefix, ":", qname.Name) : qname.Name; - } - - protected static string TimeToString(DateTime value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.Time)).ToString(); - } - - protected static string TimeOffsetToString(DateTimeOffset value) - { - return (new XsdDateTime(value, XsdDateTimeFlags.Time)).ToString(); - } - - protected static string YearMonthDurationToString(TimeSpan value) - { - return new XsdDuration(value, XsdDuration.DurationType.YearMonthDuration).ToString(XsdDuration.DurationType.YearMonthDuration); - } - - - //------------------------------------------------------------------------ - // Other Conversion Helpers - //------------------------------------------------------------------------ - - internal static DateTime DateTimeOffsetToDateTime(DateTimeOffset value) - { - return value.LocalDateTime; - } - - internal static int DecimalToInt32(decimal value) - { - if (value < (decimal)Int32.MinValue || value > (decimal)Int32.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "Int32" })); - - return (int)value; - } - - protected static long DecimalToInt64(decimal value) - { - if (value < (decimal)Int64.MinValue || value > (decimal)Int64.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "Int64" })); - - return (long)value; - } - - protected static ulong DecimalToUInt64(decimal value) - { - if (value < (decimal)UInt64.MinValue || value > (decimal)UInt64.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "UInt64" })); - - return (ulong)value; - } - - protected static byte Int32ToByte(int value) - { - if (value < (int)Byte.MinValue || value > (int)Byte.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "Byte" })); - - return (byte)value; - } - - protected static short Int32ToInt16(int value) - { - if (value < (int)Int16.MinValue || value > (int)Int16.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "Int16" })); - - return (short)value; - } - - protected static sbyte Int32ToSByte(int value) - { - if (value < (int)SByte.MinValue || value > (int)SByte.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "SByte" })); - - return (sbyte)value; - } - - protected static ushort Int32ToUInt16(int value) - { - if (value < (int)UInt16.MinValue || value > (int)UInt16.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "UInt16" })); - - return (ushort)value; - } - - protected static int Int64ToInt32(long value) - { - if (value < (long)Int32.MinValue || value > (long)Int32.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "Int32" })); - - return (int)value; - } - - protected static uint Int64ToUInt32(long value) - { - if (value < (long)UInt32.MinValue || value > (long)UInt32.MaxValue) - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, new string[] { XmlConvert.ToString(value), "UInt32" })); - - return (uint)value; - } - - protected static DateTime UntypedAtomicToDateTime(string value) - { - return (DateTime)(new XsdDateTime(value, XsdDateTimeFlags.AllXsd)); - } - - protected static DateTimeOffset UntypedAtomicToDateTimeOffset(string value) - { - return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.AllXsd)); - } - } - - internal class XmlNumeric10Converter : XmlBaseConverter - { - protected XmlNumeric10Converter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlNumeric10Converter(schemaType); - } - - #region AUTOGENERATED_XMLNUMERIC10CONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - public override decimal ToDecimal(decimal value) - { - return ((decimal)value); - } - public override decimal ToDecimal(int value) - { - return ((decimal)(int)value); - } - public override decimal ToDecimal(long value) - { - return ((decimal)(long)value); - } - public override decimal ToDecimal(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - if (TypeCode == XmlTypeCode.Decimal) return XmlConvert.ToDecimal((string)value); - return XmlConvert.ToInteger((string)value); - } - public override decimal ToDecimal(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DecimalType) return ((decimal)value); - if (sourceType == Int32Type) return ((decimal)(int)value); - if (sourceType == Int64Type) return ((decimal)(long)value); - if (sourceType == StringType) return this.ToDecimal((string)value); - if (sourceType == XmlAtomicValueType) return ((decimal)((XmlAtomicValue)value).ValueAs(DecimalType)); - - return (decimal)ChangeTypeWildcardDestination(value, DecimalType, null); - } - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - public override int ToInt32(decimal value) - { - return DecimalToInt32((decimal)value); - } - public override int ToInt32(int value) - { - return ((int)value); - } - public override int ToInt32(long value) - { - return Int64ToInt32((long)value); - } - public override int ToInt32(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - if (TypeCode == XmlTypeCode.Decimal) return DecimalToInt32(XmlConvert.ToDecimal((string)value)); - return XmlConvert.ToInt32((string)value); - } - public override int ToInt32(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DecimalType) return DecimalToInt32((decimal)value); - if (sourceType == Int32Type) return ((int)value); - if (sourceType == Int64Type) return Int64ToInt32((long)value); - if (sourceType == StringType) return this.ToInt32((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsInt; - - return (int)ChangeTypeWildcardDestination(value, Int32Type, null); - } - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - public override long ToInt64(decimal value) - { - return DecimalToInt64((decimal)value); - } - public override long ToInt64(int value) - { - return ((long)(int)value); - } - public override long ToInt64(long value) - { - return ((long)value); - } - public override long ToInt64(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - if (TypeCode == XmlTypeCode.Decimal) return DecimalToInt64(XmlConvert.ToDecimal((string)value)); - return XmlConvert.ToInt64((string)value); - } - public override long ToInt64(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DecimalType) return DecimalToInt64((decimal)value); - if (sourceType == Int32Type) return ((long)(int)value); - if (sourceType == Int64Type) return ((long)value); - if (sourceType == StringType) return this.ToInt64((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsLong; - - return (long)ChangeTypeWildcardDestination(value, Int64Type, null); - } - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(decimal value) - { - if (TypeCode == XmlTypeCode.Decimal) return XmlConvert.ToString((decimal)value); - return XmlConvert.ToString(decimal.Truncate((decimal)value)); - } - public override string ToString(int value) - { - return XmlConvert.ToString((int)value); - } - public override string ToString(long value) - { - return XmlConvert.ToString((long)value); - } - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DecimalType) return this.ToString((decimal)value); - if (sourceType == Int32Type) return XmlConvert.ToString((int)value); - if (sourceType == Int64Type) return XmlConvert.ToString((long)value); - if (sourceType == StringType) return ((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).Value; - - return (string)ChangeTypeWildcardDestination(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(decimal value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DecimalType) return ((decimal)value); - if (destinationType == Int32Type) return DecimalToInt32((decimal)value); - if (destinationType == Int64Type) return DecimalToInt64((decimal)value); - if (destinationType == StringType) return this.ToString((decimal)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(int value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DecimalType) return ((decimal)(int)value); - if (destinationType == Int32Type) return ((int)value); - if (destinationType == Int64Type) return ((long)(int)value); - if (destinationType == StringType) return XmlConvert.ToString((int)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (int)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (int)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(long value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DecimalType) return ((decimal)(long)value); - if (destinationType == Int32Type) return Int64ToInt32((long)value); - if (destinationType == Int64Type) return ((long)value); - if (destinationType == StringType) return XmlConvert.ToString((long)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (long)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (long)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DecimalType) return this.ToDecimal((string)value); - if (destinationType == Int32Type) return this.ToInt32((string)value); - if (destinationType == Int64Type) return this.ToInt64((string)value); - if (destinationType == StringType) return ((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - - return ChangeTypeWildcardSource(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DecimalType) return this.ToDecimal(value); - if (destinationType == Int32Type) return this.ToInt32(value); - if (destinationType == Int64Type) return this.ToInt64(value); - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) - { - if (sourceType == DecimalType) return (new XmlAtomicValue(SchemaType, value)); - if (sourceType == Int32Type) return (new XmlAtomicValue(SchemaType, (int)value)); - if (sourceType == Int64Type) return (new XmlAtomicValue(SchemaType, (long)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) - { - if (sourceType == DecimalType) return (new XmlAtomicValue(SchemaType, value)); - if (sourceType == Int32Type) return (new XmlAtomicValue(SchemaType, (int)value)); - if (sourceType == Int64Type) return (new XmlAtomicValue(SchemaType, (long)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == ByteType) return Int32ToByte(this.ToInt32(value)); - if (destinationType == Int16Type) return Int32ToInt16(this.ToInt32(value)); - if (destinationType == SByteType) return Int32ToSByte(this.ToInt32(value)); - if (destinationType == UInt16Type) return Int32ToUInt16(this.ToInt32(value)); - if (destinationType == UInt32Type) return Int64ToUInt32(this.ToInt64(value)); - if (destinationType == UInt64Type) return DecimalToUInt64(this.ToDecimal(value)); - if (sourceType == ByteType) return this.ChangeType((int)(byte)value, destinationType); - if (sourceType == Int16Type) return this.ChangeType((int)(short)value, destinationType); - if (sourceType == SByteType) return this.ChangeType((int)(sbyte)value, destinationType); - if (sourceType == UInt16Type) return this.ChangeType((int)(ushort)value, destinationType); - if (sourceType == UInt32Type) return this.ChangeType((long)(uint)value, destinationType); - if (sourceType == UInt64Type) return this.ChangeType((decimal)(ulong)value, destinationType); - - return ChangeListType(value, destinationType, nsResolver); - } - - - //----------------------------------------------- - // Helpers - //----------------------------------------------- - - private object ChangeTypeWildcardDestination(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - if (sourceType == ByteType) return this.ChangeType((int)(byte)value, destinationType); - if (sourceType == Int16Type) return this.ChangeType((int)(short)value, destinationType); - if (sourceType == SByteType) return this.ChangeType((int)(sbyte)value, destinationType); - if (sourceType == UInt16Type) return this.ChangeType((int)(ushort)value, destinationType); - if (sourceType == UInt32Type) return this.ChangeType((long)(uint)value, destinationType); - if (sourceType == UInt64Type) return this.ChangeType((decimal)(ulong)value, destinationType); - - return ChangeListType(value, destinationType, nsResolver); - } - private object ChangeTypeWildcardSource(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (destinationType == ByteType) return Int32ToByte(this.ToInt32(value)); - if (destinationType == Int16Type) return Int32ToInt16(this.ToInt32(value)); - if (destinationType == SByteType) return Int32ToSByte(this.ToInt32(value)); - if (destinationType == UInt16Type) return Int32ToUInt16(this.ToInt32(value)); - if (destinationType == UInt32Type) return Int64ToUInt32(this.ToInt64(value)); - if (destinationType == UInt64Type) return DecimalToUInt64(this.ToDecimal(value)); - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlNumeric2Converter : XmlBaseConverter - { - protected XmlNumeric2Converter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlNumeric2Converter(schemaType); - } - - #region AUTOGENERATED_XMLNUMERIC2CONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - public override double ToDouble(double value) - { - return ((double)value); - } - public override double ToDouble(float value) - { - return ((double)(float)value); - } - public override double ToDouble(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - if (TypeCode == XmlTypeCode.Float) return ((double)XmlConvert.ToSingle((string)value)); - return XmlConvert.ToDouble((string)value); - } - public override double ToDouble(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DoubleType) return ((double)value); - if (sourceType == SingleType) return ((double)(float)value); - if (sourceType == StringType) return this.ToDouble((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDouble; - - return (double)ChangeListType(value, DoubleType, null); - } - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - public override float ToSingle(double value) - { - return ((float)(double)value); - } - public override float ToSingle(float value) - { - return ((float)value); - } - public override float ToSingle(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - if (TypeCode == XmlTypeCode.Float) return XmlConvert.ToSingle((string)value); - return ((float)XmlConvert.ToDouble((string)value)); - } - public override float ToSingle(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DoubleType) return ((float)(double)value); - if (sourceType == SingleType) return ((float)value); - if (sourceType == StringType) return this.ToSingle((string)value); - if (sourceType == XmlAtomicValueType) return ((float)((XmlAtomicValue)value).ValueAs(SingleType)); - - return (float)ChangeListType(value, SingleType, null); - } - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(double value) - { - if (TypeCode == XmlTypeCode.Float) return XmlConvert.ToString(ToSingle((double)value)); - return XmlConvert.ToString((double)value); - } - public override string ToString(float value) - { - if (TypeCode == XmlTypeCode.Float) return XmlConvert.ToString((float)value); - return XmlConvert.ToString((double)(float)value); - } - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DoubleType) return this.ToString((double)value); - if (sourceType == SingleType) return this.ToString((float)value); - if (sourceType == StringType) return ((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).Value; - - return (string)ChangeListType(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(double value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DoubleType) return ((double)value); - if (destinationType == SingleType) return ((float)(double)value); - if (destinationType == StringType) return this.ToString((double)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (double)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (double)value)); - - return ChangeListType(value, destinationType, null); - } - - public override object ChangeType(float value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DoubleType) return ((double)(float)value); - if (destinationType == SingleType) return ((float)value); - if (destinationType == StringType) return this.ToString((float)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, value)); - - return ChangeListType(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DoubleType) return this.ToDouble((string)value); - if (destinationType == SingleType) return this.ToSingle((string)value); - if (destinationType == StringType) return ((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - - return ChangeListType(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DoubleType) return this.ToDouble(value); - if (destinationType == SingleType) return this.ToSingle(value); - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) - { - if (sourceType == DoubleType) return (new XmlAtomicValue(SchemaType, (double)value)); - if (sourceType == SingleType) return (new XmlAtomicValue(SchemaType, value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) - { - if (sourceType == DoubleType) return (new XmlAtomicValue(SchemaType, (double)value)); - if (sourceType == SingleType) return (new XmlAtomicValue(SchemaType, value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlDateTimeConverter : XmlBaseConverter - { - protected XmlDateTimeConverter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlDateTimeConverter(schemaType); - } - - #region AUTOGENERATED_XMLDATETIMECONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - public override DateTime ToDateTime(DateTime value) - { - return ((DateTime)value); - } - - public override DateTime ToDateTime(DateTimeOffset value) - { - return DateTimeOffsetToDateTime(value); - } - - public override DateTime ToDateTime(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - switch (TypeCode) - { - case XmlTypeCode.Date: return StringToDate((string)value); - case XmlTypeCode.Time: return StringToTime((string)value); - case XmlTypeCode.GDay: return StringToGDay((string)value); - case XmlTypeCode.GMonth: return StringToGMonth((string)value); - case XmlTypeCode.GMonthDay: return StringToGMonthDay((string)value); - case XmlTypeCode.GYear: return StringToGYear((string)value); - case XmlTypeCode.GYearMonth: return StringToGYearMonth((string)value); - } - return StringToDateTime((string)value); - } - public override DateTime ToDateTime(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DateTimeType) return ((DateTime)value); - if (sourceType == DateTimeOffsetType) return this.ToDateTime((DateTimeOffset)value); - if (sourceType == StringType) return this.ToDateTime((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDateTime; - - return (DateTime)ChangeListType(value, DateTimeType, null); - } - - //----------------------------------------------- - // ToDateTimeOffset - //----------------------------------------------- - - public override DateTimeOffset ToDateTimeOffset(DateTime value) - { - return new DateTimeOffset(value); - } - - public override DateTimeOffset ToDateTimeOffset(DateTimeOffset value) - { - return ((DateTimeOffset)value); - } - - public override DateTimeOffset ToDateTimeOffset(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - switch (TypeCode) - { - case XmlTypeCode.Date: return StringToDateOffset((string)value); - case XmlTypeCode.Time: return StringToTimeOffset((string)value); - case XmlTypeCode.GDay: return StringToGDayOffset((string)value); - case XmlTypeCode.GMonth: return StringToGMonthOffset((string)value); - case XmlTypeCode.GMonthDay: return StringToGMonthDayOffset((string)value); - case XmlTypeCode.GYear: return StringToGYearOffset((string)value); - case XmlTypeCode.GYearMonth: return StringToGYearMonthOffset((string)value); - } - return StringToDateTimeOffset((string)value); - } - - public override DateTimeOffset ToDateTimeOffset(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DateTimeType) return ToDateTimeOffset((DateTime)value); - if (sourceType == DateTimeOffsetType) return ((DateTimeOffset)value); - if (sourceType == StringType) return this.ToDateTimeOffset((string)value); - if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAsDateTime; - - return (DateTimeOffset)ChangeListType(value, DateTimeOffsetType, null); - } - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(DateTime value) - { - switch (TypeCode) - { - case XmlTypeCode.Date: return DateToString((DateTime)value); - case XmlTypeCode.Time: return TimeToString((DateTime)value); - case XmlTypeCode.GDay: return GDayToString((DateTime)value); - case XmlTypeCode.GMonth: return GMonthToString((DateTime)value); - case XmlTypeCode.GMonthDay: return GMonthDayToString((DateTime)value); - case XmlTypeCode.GYear: return GYearToString((DateTime)value); - case XmlTypeCode.GYearMonth: return GYearMonthToString((DateTime)value); - } - return DateTimeToString((DateTime)value); - } - - public override string ToString(DateTimeOffset value) - { - switch (TypeCode) - { - case XmlTypeCode.Date: return DateOffsetToString((DateTimeOffset)value); - case XmlTypeCode.Time: return TimeOffsetToString((DateTimeOffset)value); - case XmlTypeCode.GDay: return GDayOffsetToString((DateTimeOffset)value); - case XmlTypeCode.GMonth: return GMonthOffsetToString((DateTimeOffset)value); - case XmlTypeCode.GMonthDay: return GMonthDayOffsetToString((DateTimeOffset)value); - case XmlTypeCode.GYear: return GYearOffsetToString((DateTimeOffset)value); - case XmlTypeCode.GYearMonth: return GYearMonthOffsetToString((DateTimeOffset)value); - } - return DateTimeOffsetToString((DateTimeOffset)value); - } - - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == DateTimeType) return this.ToString((DateTime)value); - if (sourceType == DateTimeOffsetType) return this.ToString((DateTimeOffset)value); - if (sourceType == StringType) return ((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).Value; - - return (string)ChangeListType(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(DateTime value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DateTimeType) return ((DateTime)value); - if (destinationType == DateTimeOffsetType) return this.ToDateTimeOffset((DateTime)value); - if (destinationType == StringType) return this.ToString((DateTime)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (DateTime)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (DateTime)value)); - - return ChangeListType(value, destinationType, null); - } - - public override object ChangeType(DateTimeOffset value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DateTimeType) return this.ToDateTime((DateTimeOffset)value); - if (destinationType == DateTimeOffsetType) return ((DateTimeOffset)value); - if (destinationType == StringType) return this.ToString((DateTimeOffset)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value)); - - return ChangeListType(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DateTimeType) return this.ToDateTime((string)value); - if (destinationType == DateTimeOffsetType) return this.ToDateTimeOffset((string)value); - if (destinationType == StringType) return ((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - - return ChangeListType(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == DateTimeType) return this.ToDateTime(value); - if (destinationType == DateTimeOffsetType) return this.ToDateTimeOffset(value); - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) - { - if (sourceType == DateTimeType) return (new XmlAtomicValue(SchemaType, (DateTime)value)); - if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) - { - if (sourceType == DateTimeType) return (new XmlAtomicValue(SchemaType, (DateTime)value)); - if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlBooleanConverter : XmlBaseConverter - { - protected XmlBooleanConverter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlBooleanConverter(schemaType); - } - - #region AUTOGENERATED_XMLBOOLEANCONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - public override bool ToBoolean(bool value) - { - return ((bool)value); - } - public override bool ToBoolean(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToBoolean((string)value); - } - public override bool ToBoolean(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == BooleanType) return ((bool)value); - if (sourceType == StringType) return XmlConvert.ToBoolean((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsBoolean; - - return (bool)ChangeListType(value, BooleanType, null); - } - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(bool value) - { - return XmlConvert.ToString((bool)value); - } - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == BooleanType) return XmlConvert.ToString((bool)value); - if (sourceType == StringType) return ((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).Value; - - return (string)ChangeListType(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(bool value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) return ((bool)value); - if (destinationType == StringType) return XmlConvert.ToString((bool)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (bool)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (bool)value)); - - return ChangeListType(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) return XmlConvert.ToBoolean((string)value); - if (destinationType == StringType) return ((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - - return ChangeListType(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) return this.ToBoolean(value); - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) - { - if (sourceType == BooleanType) return (new XmlAtomicValue(SchemaType, (bool)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) - { - if (sourceType == BooleanType) return (new XmlAtomicValue(SchemaType, (bool)value)); - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlMiscConverter : XmlBaseConverter - { - protected XmlMiscConverter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlMiscConverter(schemaType); - } - - #region AUTOGENERATED_XMLMISCCONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return (string)value; - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == ByteArrayType) - { - switch (TypeCode) - { - case XmlTypeCode.Base64Binary: return Base64BinaryToString((byte[])value); - case XmlTypeCode.HexBinary: return XmlConvert.ToBinHexString((byte[])value); - } - } - if (sourceType == StringType) return (string)value; - if (IsDerivedFrom(sourceType, UriType)) if (TypeCode == XmlTypeCode.AnyUri) return AnyUriToString((Uri)value); - if (sourceType == TimeSpanType) - { - switch (TypeCode) - { - case XmlTypeCode.DayTimeDuration: return DayTimeDurationToString((TimeSpan)value); - case XmlTypeCode.Duration: return DurationToString((TimeSpan)value); - case XmlTypeCode.YearMonthDuration: return YearMonthDurationToString((TimeSpan)value); - } - } - if (IsDerivedFrom(sourceType, XmlQualifiedNameType)) - { - switch (TypeCode) - { - case XmlTypeCode.Notation: return QNameToString((XmlQualifiedName)value, nsResolver); - case XmlTypeCode.QName: return QNameToString((XmlQualifiedName)value, nsResolver); - } - } - - return (string)ChangeTypeWildcardDestination(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == ByteArrayType) - { - switch (TypeCode) - { - case XmlTypeCode.Base64Binary: return StringToBase64Binary((string)value); - case XmlTypeCode.HexBinary: return StringToHexBinary((string)value); - } - } - if (destinationType == XmlQualifiedNameType) - { - switch (TypeCode) - { - case XmlTypeCode.Notation: return StringToQName((string)value, nsResolver); - case XmlTypeCode.QName: return StringToQName((string)value, nsResolver); - } - } - if (destinationType == StringType) return (string)value; - if (destinationType == TimeSpanType) - { - switch (TypeCode) - { - case XmlTypeCode.DayTimeDuration: return StringToDayTimeDuration((string)value); - case XmlTypeCode.Duration: return StringToDuration((string)value); - case XmlTypeCode.YearMonthDuration: return StringToYearMonthDuration((string)value); - } - } - if (destinationType == UriType) if (TypeCode == XmlTypeCode.AnyUri) return XmlConvert.ToUri((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value, nsResolver)); - - return ChangeTypeWildcardSource(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == ByteArrayType) - { - if (sourceType == ByteArrayType) - { - switch (TypeCode) - { - case XmlTypeCode.Base64Binary: return ((byte[])value); - case XmlTypeCode.HexBinary: return ((byte[])value); - } - } - if (sourceType == StringType) - { - switch (TypeCode) - { - case XmlTypeCode.Base64Binary: return StringToBase64Binary((string)value); - case XmlTypeCode.HexBinary: return StringToHexBinary((string)value); - } - } - } - if (destinationType == XmlQualifiedNameType) - { - if (sourceType == StringType) - { - switch (TypeCode) - { - case XmlTypeCode.Notation: return StringToQName((string)value, nsResolver); - case XmlTypeCode.QName: return StringToQName((string)value, nsResolver); - } - } - if (IsDerivedFrom(sourceType, XmlQualifiedNameType)) - { - switch (TypeCode) - { - case XmlTypeCode.Notation: return ((XmlQualifiedName)value); - case XmlTypeCode.QName: return ((XmlQualifiedName)value); - } - } - } - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == TimeSpanType) - { - if (sourceType == StringType) - { - switch (TypeCode) - { - case XmlTypeCode.DayTimeDuration: return StringToDayTimeDuration((string)value); - case XmlTypeCode.Duration: return StringToDuration((string)value); - case XmlTypeCode.YearMonthDuration: return StringToYearMonthDuration((string)value); - } - } - if (sourceType == TimeSpanType) - { - switch (TypeCode) - { - case XmlTypeCode.DayTimeDuration: return ((TimeSpan)value); - case XmlTypeCode.Duration: return ((TimeSpan)value); - case XmlTypeCode.YearMonthDuration: return ((TimeSpan)value); - } - } - } - if (destinationType == UriType) - { - if (sourceType == StringType) if (TypeCode == XmlTypeCode.AnyUri) return XmlConvert.ToUri((string)value); - if (IsDerivedFrom(sourceType, UriType)) if (TypeCode == XmlTypeCode.AnyUri) return ((Uri)value); - } - if (destinationType == XmlAtomicValueType) - { - if (sourceType == ByteArrayType) - { - switch (TypeCode) - { - case XmlTypeCode.Base64Binary: return (new XmlAtomicValue(SchemaType, value)); - case XmlTypeCode.HexBinary: return (new XmlAtomicValue(SchemaType, value)); - } - } - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value, nsResolver)); - if (sourceType == TimeSpanType) - { - switch (TypeCode) - { - case XmlTypeCode.DayTimeDuration: return (new XmlAtomicValue(SchemaType, value)); - case XmlTypeCode.Duration: return (new XmlAtomicValue(SchemaType, value)); - case XmlTypeCode.YearMonthDuration: return (new XmlAtomicValue(SchemaType, value)); - } - } - if (IsDerivedFrom(sourceType, UriType)) if (TypeCode == XmlTypeCode.AnyUri) return (new XmlAtomicValue(SchemaType, value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - if (IsDerivedFrom(sourceType, XmlQualifiedNameType)) - { - switch (TypeCode) - { - case XmlTypeCode.Notation: return (new XmlAtomicValue(SchemaType, value, nsResolver)); - case XmlTypeCode.QName: return (new XmlAtomicValue(SchemaType, value, nsResolver)); - } - } - } - if (destinationType == XPathItemType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) return ((XPathItem)this.ChangeType(value, XmlAtomicValueType, nsResolver)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - - - //----------------------------------------------- - // Helpers - //----------------------------------------------- - - private object ChangeTypeWildcardDestination(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - private object ChangeTypeWildcardSource(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (destinationType == XPathItemType) return ((XPathItem)this.ChangeType(value, XmlAtomicValueType, nsResolver)); - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlStringConverter : XmlBaseConverter - { - protected XmlStringConverter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlStringConverter(schemaType); - } - - #region AUTOGENERATED_XMLSTRINGCONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return ((string)value); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).Value; - - return (string)ChangeListType(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return ((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - - return ChangeListType(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) - { - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XPathItemType) - { - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlUntypedConverter : XmlListConverter - { - private bool _allowListToList; - - protected XmlUntypedConverter() : base(DatatypeImplementation.UntypedAtomicType) - { - } - - protected XmlUntypedConverter(XmlUntypedConverter atomicConverter, bool allowListToList) - : base(atomicConverter, allowListToList ? StringArrayType : StringType) - { - _allowListToList = allowListToList; - } - - public static readonly XmlValueConverter Untyped = new XmlUntypedConverter(new XmlUntypedConverter(), false); - public static readonly XmlValueConverter UntypedList = new XmlUntypedConverter(new XmlUntypedConverter(), true); - - #region AUTOGENERATED_XMLUNTYPEDCONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - public override bool ToBoolean(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToBoolean((string)value); - } - public override bool ToBoolean(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToBoolean((string)value); - - return (bool)ChangeTypeWildcardDestination(value, BooleanType, null); - } - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - public override DateTime ToDateTime(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return UntypedAtomicToDateTime((string)value); - } - public override DateTime ToDateTime(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return UntypedAtomicToDateTime((string)value); - - return (DateTime)ChangeTypeWildcardDestination(value, DateTimeType, null); - } - - //----------------------------------------------- - // ToDateTimeOffset - //----------------------------------------------- - - public override DateTimeOffset ToDateTimeOffset(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return UntypedAtomicToDateTimeOffset((string)value); - } - - public override DateTimeOffset ToDateTimeOffset(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return UntypedAtomicToDateTimeOffset((string)value); - - return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null); - } - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - public override decimal ToDecimal(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToDecimal((string)value); - } - public override decimal ToDecimal(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToDecimal((string)value); - - return (decimal)ChangeTypeWildcardDestination(value, DecimalType, null); - } - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - public override double ToDouble(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToDouble((string)value); - } - public override double ToDouble(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToDouble((string)value); - - return (double)ChangeTypeWildcardDestination(value, DoubleType, null); - } - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - public override int ToInt32(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToInt32((string)value); - } - public override int ToInt32(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToInt32((string)value); - - return (int)ChangeTypeWildcardDestination(value, Int32Type, null); - } - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - public override long ToInt64(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToInt64((string)value); - } - public override long ToInt64(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToInt64((string)value); - - return (long)ChangeTypeWildcardDestination(value, Int64Type, null); - } - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - public override float ToSingle(string value) - { - if (value == null) throw new ArgumentNullException("value"); - - return XmlConvert.ToSingle((string)value); - } - public override float ToSingle(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == StringType) return XmlConvert.ToSingle((string)value); - - return (float)ChangeTypeWildcardDestination(value, SingleType, null); - } - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - public override string ToString(bool value) - { - return XmlConvert.ToString((bool)value); - } - public override string ToString(DateTime value) - { - return DateTimeToString((DateTime)value); - } - public override string ToString(DateTimeOffset value) - { - return DateTimeOffsetToString((DateTimeOffset)value); - } - public override string ToString(decimal value) - { - return XmlConvert.ToString((decimal)value); - } - public override string ToString(double value) - { - return XmlConvert.ToString((double)value); - } - public override string ToString(int value) - { - return XmlConvert.ToString((int)value); - } - public override string ToString(long value) - { - return XmlConvert.ToString((long)value); - } - public override string ToString(float value) - { - return XmlConvert.ToString((float)value); - } - public override string ToString(string value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - return ((string)value); - } - public override string ToString(object value, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == BooleanType) return XmlConvert.ToString((bool)value); - if (sourceType == ByteType) return XmlConvert.ToString((byte)value); - if (sourceType == ByteArrayType) return Base64BinaryToString((byte[])value); - if (sourceType == DateTimeType) return DateTimeToString((DateTime)value); - if (sourceType == DateTimeOffsetType) return DateTimeOffsetToString((DateTimeOffset)value); - if (sourceType == DecimalType) return XmlConvert.ToString((decimal)value); - if (sourceType == DoubleType) return XmlConvert.ToString((double)value); - if (sourceType == Int16Type) return XmlConvert.ToString((short)value); - if (sourceType == Int32Type) return XmlConvert.ToString((int)value); - if (sourceType == Int64Type) return XmlConvert.ToString((long)value); - if (sourceType == SByteType) return XmlConvert.ToString((sbyte)value); - if (sourceType == SingleType) return XmlConvert.ToString((float)value); - if (sourceType == StringType) return ((string)value); - if (sourceType == TimeSpanType) return DurationToString((TimeSpan)value); - if (sourceType == UInt16Type) return XmlConvert.ToString((ushort)value); - if (sourceType == UInt32Type) return XmlConvert.ToString((uint)value); - if (sourceType == UInt64Type) return XmlConvert.ToString((ulong)value); - if (IsDerivedFrom(sourceType, UriType)) return AnyUriToString((Uri)value); - if (sourceType == XmlAtomicValueType) return ((string)((XmlAtomicValue)value).ValueAs(StringType, nsResolver)); - if (IsDerivedFrom(sourceType, XmlQualifiedNameType)) return QNameToString((XmlQualifiedName)value, nsResolver); - - return (string)ChangeTypeWildcardDestination(value, StringType, nsResolver); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(bool value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((bool)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(DateTime value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return DateTimeToString((DateTime)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(DateTimeOffset value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return DateTimeOffsetToString((DateTimeOffset)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(decimal value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((decimal)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(double value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((double)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(int value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((int)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(long value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((long)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(float value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == StringType) return XmlConvert.ToString((float)value); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) return XmlConvert.ToBoolean((string)value); - if (destinationType == ByteType) return Int32ToByte(XmlConvert.ToInt32((string)value)); - if (destinationType == ByteArrayType) return StringToBase64Binary((string)value); - if (destinationType == DateTimeType) return UntypedAtomicToDateTime((string)value); - if (destinationType == DateTimeOffsetType) return UntypedAtomicToDateTimeOffset((string)value); - if (destinationType == DecimalType) return XmlConvert.ToDecimal((string)value); - if (destinationType == DoubleType) return XmlConvert.ToDouble((string)value); - if (destinationType == Int16Type) return Int32ToInt16(XmlConvert.ToInt32((string)value)); - if (destinationType == Int32Type) return XmlConvert.ToInt32((string)value); - if (destinationType == Int64Type) return XmlConvert.ToInt64((string)value); - if (destinationType == SByteType) return Int32ToSByte(XmlConvert.ToInt32((string)value)); - if (destinationType == SingleType) return XmlConvert.ToSingle((string)value); - if (destinationType == TimeSpanType) return StringToDuration((string)value); - if (destinationType == UInt16Type) return Int32ToUInt16(XmlConvert.ToInt32((string)value)); - if (destinationType == UInt32Type) return Int64ToUInt32(XmlConvert.ToInt64((string)value)); - if (destinationType == UInt64Type) return DecimalToUInt64(XmlConvert.ToDecimal((string)value)); - if (destinationType == UriType) return XmlConvert.ToUri((string)value); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == XmlQualifiedNameType) return StringToQName((string)value, nsResolver); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (destinationType == StringType) return ((string)value); - - return ChangeTypeWildcardSource(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) - { - if (sourceType == StringType) return XmlConvert.ToBoolean((string)value); - } - if (destinationType == ByteType) - { - if (sourceType == StringType) return Int32ToByte(XmlConvert.ToInt32((string)value)); - } - if (destinationType == ByteArrayType) - { - if (sourceType == StringType) return StringToBase64Binary((string)value); - } - if (destinationType == DateTimeType) - { - if (sourceType == StringType) return UntypedAtomicToDateTime((string)value); - } - if (destinationType == DateTimeOffsetType) - { - if (sourceType == StringType) return UntypedAtomicToDateTimeOffset((string)value); - } - if (destinationType == DecimalType) - { - if (sourceType == StringType) return XmlConvert.ToDecimal((string)value); - } - if (destinationType == DoubleType) - { - if (sourceType == StringType) return XmlConvert.ToDouble((string)value); - } - if (destinationType == Int16Type) - { - if (sourceType == StringType) return Int32ToInt16(XmlConvert.ToInt32((string)value)); - } - if (destinationType == Int32Type) - { - if (sourceType == StringType) return XmlConvert.ToInt32((string)value); - } - if (destinationType == Int64Type) - { - if (sourceType == StringType) return XmlConvert.ToInt64((string)value); - } - if (destinationType == SByteType) - { - if (sourceType == StringType) return Int32ToSByte(XmlConvert.ToInt32((string)value)); - } - if (destinationType == SingleType) - { - if (sourceType == StringType) return XmlConvert.ToSingle((string)value); - } - if (destinationType == TimeSpanType) - { - if (sourceType == StringType) return StringToDuration((string)value); - } - if (destinationType == UInt16Type) - { - if (sourceType == StringType) return Int32ToUInt16(XmlConvert.ToInt32((string)value)); - } - if (destinationType == UInt32Type) - { - if (sourceType == StringType) return Int64ToUInt32(XmlConvert.ToInt64((string)value)); - } - if (destinationType == UInt64Type) - { - if (sourceType == StringType) return DecimalToUInt64(XmlConvert.ToDecimal((string)value)); - } - if (destinationType == UriType) - { - if (sourceType == StringType) return XmlConvert.ToUri((string)value); - } - if (destinationType == XmlAtomicValueType) - { - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == XmlQualifiedNameType) - { - if (sourceType == StringType) return StringToQName((string)value, nsResolver); - } - if (destinationType == XPathItemType) - { - if (sourceType == StringType) return (new XmlAtomicValue(SchemaType, (string)value)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - } - if (destinationType == StringType) return this.ToString(value, nsResolver); - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver))); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver))); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - - - //----------------------------------------------- - // Helpers - //----------------------------------------------- - - private object ChangeTypeWildcardDestination(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - private object ChangeTypeWildcardSource(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver))); - if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, this.ToString(value, nsResolver))); - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - - - //----------------------------------------------- - // Helpers - //----------------------------------------------- - - protected override object ChangeListType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - // 1. If there is no nested atomic converter, then do not support lists at all - // 2. If list to list conversions are not allowed, only allow string => list and list => string - if ((this.atomicConverter == null) || (!_allowListToList && sourceType != StringType && destinationType != StringType)) - { - if (SupportsType(sourceType)) - throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeToString, XmlTypeName, sourceType.Name)); - - if (SupportsType(destinationType)) - throw new InvalidCastException(string.Format(ResXml.XmlConvert_TypeFromString, XmlTypeName, destinationType.Name)); - - throw CreateInvalidClrMappingException(sourceType, destinationType); - } - - return base.ChangeListType(value, destinationType, nsResolver); - } - - private bool SupportsType(Type clrType) - { - if (clrType == BooleanType) return true; - if (clrType == ByteType) return true; - if (clrType == ByteArrayType) return true; - if (clrType == DateTimeType) return true; - if (clrType == DateTimeOffsetType) return true; - if (clrType == DecimalType) return true; - if (clrType == DoubleType) return true; - if (clrType == Int16Type) return true; - if (clrType == Int32Type) return true; - if (clrType == Int64Type) return true; - if (clrType == SByteType) return true; - if (clrType == SingleType) return true; - if (clrType == TimeSpanType) return true; - if (clrType == UInt16Type) return true; - if (clrType == UInt32Type) return true; - if (clrType == UInt64Type) return true; - if (clrType == UriType) return true; - if (clrType == XmlQualifiedNameType) return true; - - return false; - } - } - - internal class XmlNodeConverter : XmlBaseConverter - { - protected XmlNodeConverter() : base(XmlTypeCode.Node) - { - } - - public static readonly XmlValueConverter Node = new XmlNodeConverter(); - - #region AUTOGENERATED_XMLNODECONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - // This converter does not support conversions to Boolean. - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - // This converter does not support conversions to DateTime. - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - // This converter does not support conversions to Decimal. - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - // This converter does not support conversions to Double. - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - // This converter does not support conversions to Int32. - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - // This converter does not support conversions to Int64. - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - // This converter does not support conversions to Single. - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - // This converter does not support conversions to String. - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XPathNavigatorType) - { - if (IsDerivedFrom(sourceType, XPathNavigatorType)) return ((XPathNavigator)value); - } - if (destinationType == XPathItemType) - { - if (IsDerivedFrom(sourceType, XPathNavigatorType)) return ((XPathItem)value); - } - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - } - - internal class XmlAnyConverter : XmlBaseConverter - { - protected XmlAnyConverter(XmlTypeCode typeCode) : base(typeCode) - { - } - - public static readonly XmlValueConverter Item = new XmlAnyConverter(XmlTypeCode.Item); - public static readonly XmlValueConverter AnyAtomic = new XmlAnyConverter(XmlTypeCode.AnyAtomicType); - - #region AUTOGENERATED_XMLANYCONVERTER - - //----------------------------------------------- - // ToBoolean - //----------------------------------------------- - - public override bool ToBoolean(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsBoolean; - - return (bool)ChangeTypeWildcardDestination(value, BooleanType, null); - } - - - //----------------------------------------------- - // ToDateTime - //----------------------------------------------- - - public override DateTime ToDateTime(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDateTime; - - return (DateTime)ChangeTypeWildcardDestination(value, DateTimeType, null); - } - - //----------------------------------------------- - // ToDateTimeOffset - //----------------------------------------------- - - public override DateTimeOffset ToDateTimeOffset(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAs(DateTimeOffsetType); - - return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null); - } - - - //----------------------------------------------- - // ToDecimal - //----------------------------------------------- - - public override decimal ToDecimal(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((decimal)((XmlAtomicValue)value).ValueAs(DecimalType)); - - return (decimal)ChangeTypeWildcardDestination(value, DecimalType, null); - } - - - //----------------------------------------------- - // ToDouble - //----------------------------------------------- - - public override double ToDouble(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDouble; - - return (double)ChangeTypeWildcardDestination(value, DoubleType, null); - } - - - //----------------------------------------------- - // ToInt32 - //----------------------------------------------- - - public override int ToInt32(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsInt; - - return (int)ChangeTypeWildcardDestination(value, Int32Type, null); - } - - - //----------------------------------------------- - // ToInt64 - //----------------------------------------------- - - public override long ToInt64(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsLong; - - return (long)ChangeTypeWildcardDestination(value, Int64Type, null); - } - - - //----------------------------------------------- - // ToSingle - //----------------------------------------------- - - public override float ToSingle(object value) - { - if (value == null) throw new ArgumentNullException("value"); - - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((float)((XmlAtomicValue)value).ValueAs(SingleType)); - - return (float)ChangeTypeWildcardDestination(value, SingleType, null); - } - - - //----------------------------------------------- - // ToString - //----------------------------------------------- - - // This converter does not support conversions to String. - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(bool value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean), (bool)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(DateTime value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTime)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(DateTimeOffset value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(decimal value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Decimal), value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(double value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Double), (double)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(int value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int), (int)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(long value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Long), (long)value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(float value, Type destinationType) - { - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Float), value)); - - return ChangeTypeWildcardSource(value, destinationType, null); - } - - public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String), (string)value)); - - return ChangeTypeWildcardSource(value, destinationType, nsResolver); - } - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - if (destinationType == BooleanType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsBoolean; - } - if (destinationType == DateTimeType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDateTime; - } - if (destinationType == DateTimeOffsetType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(DateTimeOffsetType); - } - if (destinationType == DecimalType) - { - if (sourceType == XmlAtomicValueType) return ((decimal)((XmlAtomicValue)value).ValueAs(DecimalType)); - } - if (destinationType == DoubleType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsDouble; - } - if (destinationType == Int32Type) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsInt; - } - if (destinationType == Int64Type) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAsLong; - } - if (destinationType == SingleType) - { - if (sourceType == XmlAtomicValueType) return ((float)((XmlAtomicValue)value).ValueAs(SingleType)); - } - if (destinationType == XmlAtomicValueType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - if (sourceType == BooleanType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean), (bool)value)); - if (sourceType == ByteType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedByte), value)); - if (sourceType == ByteArrayType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Base64Binary), value)); - if (sourceType == DateTimeType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTime)value)); - if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value)); - if (sourceType == DecimalType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Decimal), value)); - if (sourceType == DoubleType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Double), (double)value)); - if (sourceType == Int16Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Short), value)); - if (sourceType == Int32Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int), (int)value)); - if (sourceType == Int64Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Long), (long)value)); - if (sourceType == SByteType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Byte), value)); - if (sourceType == SingleType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Float), value)); - if (sourceType == StringType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String), (string)value)); - if (sourceType == TimeSpanType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Duration), value)); - if (sourceType == UInt16Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedShort), value)); - if (sourceType == UInt32Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedInt), value)); - if (sourceType == UInt64Type) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedLong), value)); - if (IsDerivedFrom(sourceType, UriType)) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyUri), value)); - if (IsDerivedFrom(sourceType, XmlQualifiedNameType)) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName), value, nsResolver)); - } - if (destinationType == XPathItemType) - { - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value); - if (IsDerivedFrom(sourceType, XPathNavigatorType)) return ((XPathNavigator)value); - } - if (destinationType == XPathNavigatorType) - { - if (IsDerivedFrom(sourceType, XPathNavigatorType)) return ToNavigator((XPathNavigator)value); - } - if (destinationType == XPathItemType) return ((XPathItem)this.ChangeType(value, XmlAtomicValueType, nsResolver)); - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - - - //----------------------------------------------- - // Helpers - //----------------------------------------------- - - private object ChangeTypeWildcardDestination(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - if (sourceType == XmlAtomicValueType) return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - return ChangeListType(value, destinationType, nsResolver); - } - private object ChangeTypeWildcardSource(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (destinationType == XPathItemType) return ((XPathItem)this.ChangeType(value, XmlAtomicValueType, nsResolver)); - - return ChangeListType(value, destinationType, nsResolver); - } - #endregion - - /// - /// Throw an exception if nodes are not allowed by this converter. - /// - private XPathNavigator ToNavigator(XPathNavigator nav) - { - if (TypeCode != XmlTypeCode.Item) - throw CreateInvalidClrMappingException(XPathNavigatorType, XPathNavigatorType); - - return nav; - } - } - - internal class XmlAnyListConverter : XmlListConverter - { - protected XmlAnyListConverter(XmlBaseConverter atomicConverter) : base(atomicConverter) - { - } - - public static readonly XmlValueConverter ItemList = new XmlAnyListConverter((XmlBaseConverter)XmlAnyConverter.Item); - public static readonly XmlValueConverter AnyAtomicList = new XmlAnyListConverter((XmlBaseConverter)XmlAnyConverter.AnyAtomic); - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - // If source value does not implement IEnumerable, or it is a string or byte[], - if (!(value is IEnumerable) || value.GetType() == StringType || value.GetType() == ByteArrayType) - { - // Then create a list from it - value = new object[] { value }; - } - - return ChangeListType(value, destinationType, nsResolver); - } - } - - internal class XmlListConverter : XmlBaseConverter - { - protected XmlValueConverter atomicConverter; - - protected XmlListConverter(XmlBaseConverter atomicConverter) : base(atomicConverter) - { - this.atomicConverter = atomicConverter; - } - - protected XmlListConverter(XmlBaseConverter atomicConverter, Type clrTypeDefault) : base(atomicConverter, clrTypeDefault) - { - this.atomicConverter = atomicConverter; - } - - protected XmlListConverter(XmlSchemaType schemaType) : base(schemaType) - { - } - - public static XmlValueConverter Create(XmlValueConverter atomicConverter) - { - if (atomicConverter == XmlUntypedConverter.Untyped) - return XmlUntypedConverter.UntypedList; - - if (atomicConverter == XmlAnyConverter.Item) - return XmlAnyListConverter.ItemList; - - if (atomicConverter == XmlAnyConverter.AnyAtomic) - return XmlAnyListConverter.AnyAtomicList; - - Debug.Assert(!(atomicConverter is XmlListConverter) || ((XmlListConverter)atomicConverter).atomicConverter == null, - "List converters should not be nested within one another."); - - return new XmlListConverter((XmlBaseConverter)atomicConverter); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - return ChangeListType(value, destinationType, nsResolver); - } - - - //------------------------------------------------------------------------ - // Helpers - //------------------------------------------------------------------------ - - protected override object ChangeListType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - Type sourceType = value.GetType(); - - if (destinationType == ObjectType) destinationType = DefaultClrType; - - // Input value must support IEnumerable and destination type should be IEnumerable, ICollection, IList, Type[], or String - if (!(value is IEnumerable) || !IsListType(destinationType)) - throw CreateInvalidClrMappingException(sourceType, destinationType); - - // Handle case where destination type is a string - if (destinationType == StringType) - { - // Conversion from string to string is a no-op - if (sourceType == StringType) - return value; - - // Convert from list to string - return ListAsString((IEnumerable)value, nsResolver); - } - - // Handle case where source type is a string - // Tokenize string and create a list out of resulting string tokens - if (sourceType == StringType) - value = StringAsList((string)value); - - if (destinationType.IsArray) - { - // Convert from source value to strongly-typed array; special-case each possible item type for performance - Type itemTypeDst = destinationType.GetElementType(); - - // Converting from object[] to object[] is not necessarily a no-op (i.e. xs:int* stored as an object[] - // containing String values will need to be converted to an object[] containing Int32 values). - if (itemTypeDst == ObjectType) return ToArray(value, nsResolver); - - // For all types except object[], sourceType = destinationType is a no-op conversion - if (sourceType == destinationType) return value; - - // Otherwise, iterate over values in source list, convert them to output item type, and store them in result array - if (itemTypeDst == BooleanType) return ToArray(value, nsResolver); - if (itemTypeDst == ByteType) return ToArray(value, nsResolver); - if (itemTypeDst == ByteArrayType) return ToArray(value, nsResolver); - if (itemTypeDst == DateTimeType) return ToArray(value, nsResolver); - if (itemTypeDst == DateTimeOffsetType) return ToArray(value, nsResolver); - if (itemTypeDst == DecimalType) return ToArray(value, nsResolver); - if (itemTypeDst == DoubleType) return ToArray(value, nsResolver); - if (itemTypeDst == Int16Type) return ToArray(value, nsResolver); - if (itemTypeDst == Int32Type) return ToArray(value, nsResolver); - if (itemTypeDst == Int64Type) return ToArray(value, nsResolver); - if (itemTypeDst == SByteType) return ToArray(value, nsResolver); - if (itemTypeDst == SingleType) return ToArray(value, nsResolver); - if (itemTypeDst == StringType) return ToArray(value, nsResolver); - if (itemTypeDst == TimeSpanType) return ToArray(value, nsResolver); - if (itemTypeDst == UInt16Type) return ToArray(value, nsResolver); - if (itemTypeDst == UInt32Type) return ToArray(value, nsResolver); - if (itemTypeDst == UInt64Type) return ToArray(value, nsResolver); - if (itemTypeDst == UriType) return ToArray(value, nsResolver); - if (itemTypeDst == XmlAtomicValueType) return ToArray(value, nsResolver); - if (itemTypeDst == XmlQualifiedNameType) return ToArray(value, nsResolver); - if (itemTypeDst == XPathItemType) return ToArray(value, nsResolver); - if (itemTypeDst == XPathNavigatorType) return ToArray(value, nsResolver); - - throw CreateInvalidClrMappingException(sourceType, destinationType); - } - - // Destination type is IList, ICollection or IEnumerable - // If source value is an array of values having the default representation, then conversion is a no-op - if (sourceType == DefaultClrType && sourceType != ObjectArrayType) - return value; - - return ToList(value, nsResolver); - } - - /// - /// Return true if "type" is one of the following: - /// 1. IList, ICollection, IEnumerable - /// 2. A strongly-typed array - /// 3. A string - /// - private bool IsListType(Type type) - { - // IsClrListType returns true if "type" is one of the list interfaces - if (type == IListType || type == ICollectionType || type == IEnumerableType || type == StringType) - return true; - - return type.IsArray; - } - - /// - /// Convert "list" to an array of type T by iterating over each item in "list" and converting it to type "T" - /// by invoking the atomic converter. - /// - private T[] ToArray(object list, IXmlNamespaceResolver nsResolver) - { - // IList --> Array - IList listSrc = list as IList; - if (listSrc != null) - { - T[] arrDst = new T[listSrc.Count]; - - for (int i = 0; i < listSrc.Count; i++) - arrDst[i] = (T)this.atomicConverter.ChangeType(listSrc[i], typeof(T), nsResolver); - - return arrDst; - } - - // IEnumerable --> Array - IEnumerable enumSrc = list as IEnumerable; - Debug.Assert(enumSrc != null, "Value passed to ToArray must implement IEnumerable"); - - List listDst = new List(); - foreach (object value in enumSrc) - listDst.Add((T)this.atomicConverter.ChangeType(value, typeof(T), nsResolver)); - - return listDst.ToArray(); - } - - /// - /// Convert "list" to an IList containing items in the atomic type's default representation. - /// - private IList ToList(object list, IXmlNamespaceResolver nsResolver) - { - // IList --> object[] - IList listSrc = list as IList; - if (listSrc != null) - { - object[] arrDst = new object[listSrc.Count]; - - for (int i = 0; i < listSrc.Count; i++) - arrDst[i] = this.atomicConverter.ChangeType(listSrc[i], ObjectType, nsResolver); - - return arrDst; - } - - // IEnumerable --> List - IEnumerable enumSrc = list as IEnumerable; - Debug.Assert(enumSrc != null, "Value passed to ToArray must implement IEnumerable"); - - List listDst = new List(); - foreach (object value in enumSrc) - listDst.Add(this.atomicConverter.ChangeType(value, ObjectType, nsResolver)); - - return listDst; - } - - /// - /// Tokenize "value" by splitting it on whitespace characters. Insert tokens into an ArrayList and return the list. - /// - private List StringAsList(string value) - { - return new List(XmlConvert.SplitString(value)); - } - - /// - /// Convert a list to a corresponding list of strings. Then concatenate the strings, which adjacent values delimited - /// by a space character. - /// - private string ListAsString(IEnumerable list, IXmlNamespaceResolver nsResolver) - { - StringBuilder bldr = new StringBuilder(); - - foreach (object value in list) - { - // skip null values - if (value != null) - { - // Separate values by single space character - if (bldr.Length != 0) - bldr.Append(' '); - - // Append string value of next item in the list - bldr.Append(this.atomicConverter.ToString(value, nsResolver)); - } - } - - return bldr.ToString(); - } - - /// - /// Create an InvalidCastException for cases where either "destinationType" or "sourceType" is not a supported CLR representation - /// for this Xml type. - /// - private new Exception CreateInvalidClrMappingException(Type sourceType, Type destinationType) - { - if (sourceType == destinationType) - return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeListBadMapping, XmlTypeName, sourceType.Name)); - - return new InvalidCastException(string.Format(ResXml.XmlConvert_TypeListBadMapping2, XmlTypeName, sourceType.Name, destinationType.Name)); - } - } - - internal class XmlUnionConverter : XmlBaseConverter - { - private XmlValueConverter[] _converters; - private bool _hasAtomicMember,_hasListMember; - - protected XmlUnionConverter(XmlSchemaType schemaType) : base(schemaType) - { - // Skip restrictions. It is safe to do that because this is a union, so it's not a built-in type - while (schemaType.DerivedBy == XmlSchemaDerivationMethod.Restriction) - schemaType = schemaType.BaseXmlSchemaType; - - // Get a converter for each member type in the union - Debug.Assert(schemaType.DerivedBy == XmlSchemaDerivationMethod.Union); - XmlSchemaSimpleType[] memberTypes = ((XmlSchemaSimpleTypeUnion)((XmlSchemaSimpleType)schemaType).Content).BaseMemberTypes; - - _converters = new XmlValueConverter[memberTypes.Length]; - for (int i = 0; i < memberTypes.Length; i++) - { - _converters[i] = memberTypes[i].ValueConverter; - - // Track whether this union's member types include a list type - if (memberTypes[i].Datatype.Variety == XmlSchemaDatatypeVariety.List) - _hasListMember = true; - else if (memberTypes[i].Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) - _hasAtomicMember = true; - } - } - - public static XmlValueConverter Create(XmlSchemaType schemaType) - { - return new XmlUnionConverter(schemaType); - } - - - //----------------------------------------------- - // ChangeType - //----------------------------------------------- - - public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver) - { - if (value == null) throw new ArgumentNullException("value"); - if (destinationType == null) throw new ArgumentNullException("destinationType"); - - Type sourceType = value.GetType(); - - // If source value is an XmlAtomicValue, then allow it to perform the conversion - if (sourceType == XmlAtomicValueType && _hasAtomicMember) - return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver); - - // If source value is an XmlAtomicValue[], then use item* converter - if (sourceType == XmlAtomicValueArrayType && _hasListMember) - return XmlAnyListConverter.ItemList.ChangeType(value, destinationType, nsResolver); - - // If source value is a string, then validate the string in order to determine the member type - if (sourceType == StringType) - { - if (destinationType == StringType) return value; - - XsdSimpleValue simpleValue = (XsdSimpleValue)SchemaType.Datatype.ParseValue((string)value, new NameTable(), nsResolver, true); - - // Allow the member type to perform the conversion - return simpleValue.XmlType.ValueConverter.ChangeType((string)value, destinationType, nsResolver); - } - - throw CreateInvalidClrMappingException(sourceType, destinationType); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdBuilder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdBuilder.cs deleted file mode 100644 index 649ec9a3715..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdBuilder.cs +++ /dev/null @@ -1,2609 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.IO; - using System.Collections; - using System.Diagnostics; - using Microsoft.Xml.Serialization; - - - internal sealed class XsdBuilder : SchemaBuilder - { - private enum State - { - Root, - Schema, - Annotation, - Include, - Import, - Element, - Attribute, - AttributeGroup, - AttributeGroupRef, - AnyAttribute, - Group, - GroupRef, - All, - Choice, - Sequence, - Any, - Notation, - SimpleType, - ComplexType, - ComplexContent, - ComplexContentRestriction, - ComplexContentExtension, - SimpleContent, - SimpleContentExtension, - SimpleContentRestriction, - SimpleTypeUnion, - SimpleTypeList, - SimpleTypeRestriction, - Unique, - Key, - KeyRef, - Selector, - Field, - MinExclusive, - MinInclusive, - MaxExclusive, - MaxInclusive, - TotalDigits, - FractionDigits, - Length, - MinLength, - MaxLength, - Enumeration, - Pattern, - WhiteSpace, - AppInfo, - Documentation, - Redefine, - } - private const int STACK_INCREMENT = 10; - - private delegate void XsdBuildFunction(XsdBuilder builder, string value); - private delegate void XsdInitFunction(XsdBuilder builder, string value); - private delegate void XsdEndChildFunction(XsdBuilder builder); - - private sealed class XsdAttributeEntry - { - public SchemaNames.Token Attribute; // possible attribute names - public XsdBuildFunction BuildFunc; // Corresponding build functions for attribute value - - public XsdAttributeEntry(SchemaNames.Token a, XsdBuildFunction build) - { - Attribute = a; - BuildFunc = build; - } - }; - - // - // XsdEntry controls the states of parsing a schema document - // and calls the corresponding "init", "end" and "build" functions when necessary - // - private sealed class XsdEntry - { - public SchemaNames.Token Name; // the name of the object it is comparing to - public State CurrentState; - public State[] NextStates; // possible next states - public XsdAttributeEntry[] Attributes; // allowed attributes - public XsdInitFunction InitFunc; // "init" functions in XsdBuilder - public XsdEndChildFunction EndChildFunc; // "end" functions in XsdBuilder for EndChildren - public bool ParseContent; // whether text content is allowed - - public XsdEntry(SchemaNames.Token n, - State state, - State[] nextStates, - XsdAttributeEntry[] attributes, - XsdInitFunction init, - XsdEndChildFunction end, - bool parseContent) - { - Name = n; - CurrentState = state; - NextStates = nextStates; - Attributes = attributes; - InitFunc = init; - EndChildFunc = end; - ParseContent = parseContent; - } - }; - - - //required for Parsing QName - private class BuilderNamespaceManager : XmlNamespaceManager - { - private XmlNamespaceManager _nsMgr; - private XmlReader _reader; - - public BuilderNamespaceManager(XmlNamespaceManager nsMgr, XmlReader reader) - { - _nsMgr = nsMgr; - _reader = reader; - } - - public override string LookupNamespace(string prefix) - { - string ns = _nsMgr.LookupNamespace(prefix); - if (ns == null) - { - ns = _reader.LookupNamespace(prefix); - } - return ns; - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data structures for XSD Schema, Sept 2000 version - // - - // - //Elements - // - private static readonly State[] s_schemaElement = { - State.Schema}; - private static readonly State[] s_schemaSubelements = { - State.Annotation, State.Include, State.Import, State.Redefine, - State.ComplexType, State.SimpleType, State.Element, State.Attribute, - State.AttributeGroup, State.Group, State.Notation}; - private static readonly State[] s_attributeSubelements = { - State.Annotation, State.SimpleType}; - private static readonly State[] s_elementSubelements = { - State.Annotation, State.SimpleType, State.ComplexType, - State.Unique, State.Key, State.KeyRef}; - private static readonly State[] s_complexTypeSubelements = { - State.Annotation, State.SimpleContent, State.ComplexContent, - State.GroupRef, State.All, State.Choice, State.Sequence, - State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_simpleContentSubelements = { - State.Annotation, State.SimpleContentRestriction, State.SimpleContentExtension }; - private static readonly State[] s_simpleContentExtensionSubelements = { - State.Annotation, State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_simpleContentRestrictionSubelements = { - State.Annotation, State.SimpleType, - State.Enumeration, State.Length, State.MaxExclusive, State.MaxInclusive, State.MaxLength, State.MinExclusive, - State.MinInclusive, State.MinLength, State.Pattern, State.TotalDigits, State.FractionDigits, State.WhiteSpace, - State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_complexContentSubelements = { - State.Annotation, State.ComplexContentRestriction, State.ComplexContentExtension }; - private static readonly State[] s_complexContentExtensionSubelements = { - State.Annotation, State.GroupRef, State.All, State.Choice, State.Sequence, - State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_complexContentRestrictionSubelements = { - State.Annotation, State.GroupRef, State.All, State.Choice, State.Sequence, - State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_simpleTypeSubelements = { - State.Annotation, State.SimpleTypeList, State.SimpleTypeRestriction, State.SimpleTypeUnion}; - private static readonly State[] s_simpleTypeRestrictionSubelements = { - State.Annotation, State.SimpleType, - State.Enumeration, State.Length, State.MaxExclusive, State.MaxInclusive, State.MaxLength, State.MinExclusive, - State.MinInclusive, State.MinLength, State.Pattern, State.TotalDigits, State.FractionDigits, State.WhiteSpace}; - private static readonly State[] s_simpleTypeListSubelements = { - State.Annotation, State.SimpleType}; - private static readonly State[] s_simpleTypeUnionSubelements = { - State.Annotation, State.SimpleType}; - private static readonly State[] s_redefineSubelements = { - State.Annotation, State.AttributeGroup, State.ComplexType, State.Group, State.SimpleType }; - private static readonly State[] s_attributeGroupSubelements = { - State.Annotation, State.Attribute, State.AttributeGroupRef, State.AnyAttribute}; - private static readonly State[] s_groupSubelements = { - State.Annotation, State.All, State.Choice, State.Sequence}; - private static readonly State[] s_allSubelements = { - State.Annotation, State.Element}; - private static readonly State[] s_choiceSequenceSubelements = { - State.Annotation, State.Element, State.GroupRef, State.Choice, State.Sequence, State.Any}; - private static readonly State[] s_identityConstraintSubelements = { - State.Annotation, State.Selector, State.Field}; - private static readonly State[] s_annotationSubelements = { - State.AppInfo, State.Documentation}; - private static readonly State[] s_annotatedSubelements = { - State.Annotation}; - - - // - //Attributes - // - private static readonly XsdAttributeEntry[] s_schemaAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaAttributeFormDefault, new XsdBuildFunction(BuildSchema_AttributeFormDefault) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaElementFormDefault, new XsdBuildFunction(BuildSchema_ElementFormDefault) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaTargetNamespace, new XsdBuildFunction(BuildSchema_TargetNamespace) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaVersion, new XsdBuildFunction(BuildSchema_Version) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFinalDefault, new XsdBuildFunction(BuildSchema_FinalDefault) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaBlockDefault, new XsdBuildFunction(BuildSchema_BlockDefault) ) - }; - - private static readonly XsdAttributeEntry[] s_attributeAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaDefault, new XsdBuildFunction(BuildAttribute_Default) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFixed, new XsdBuildFunction(BuildAttribute_Fixed) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaForm, new XsdBuildFunction(BuildAttribute_Form) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildAttribute_Name) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaRef, new XsdBuildFunction(BuildAttribute_Ref) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaType, new XsdBuildFunction(BuildAttribute_Type) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaUse, new XsdBuildFunction(BuildAttribute_Use) ) - }; - - private static readonly XsdAttributeEntry[] s_elementAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaAbstract, new XsdBuildFunction(BuildElement_Abstract) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaBlock, new XsdBuildFunction(BuildElement_Block) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaDefault, new XsdBuildFunction(BuildElement_Default) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFinal, new XsdBuildFunction(BuildElement_Final) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFixed, new XsdBuildFunction(BuildElement_Fixed) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaForm, new XsdBuildFunction(BuildElement_Form) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMaxOccurs, new XsdBuildFunction(BuildElement_MaxOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMinOccurs, new XsdBuildFunction(BuildElement_MinOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildElement_Name) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaNillable, new XsdBuildFunction(BuildElement_Nillable) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaRef, new XsdBuildFunction(BuildElement_Ref) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaSubstitutionGroup, new XsdBuildFunction(BuildElement_SubstitutionGroup) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaType, new XsdBuildFunction(BuildElement_Type) ) - }; - - private static readonly XsdAttributeEntry[] s_complexTypeAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaAbstract, new XsdBuildFunction(BuildComplexType_Abstract) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaBlock, new XsdBuildFunction(BuildComplexType_Block) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFinal, new XsdBuildFunction(BuildComplexType_Final) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMixed, new XsdBuildFunction(BuildComplexType_Mixed) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildComplexType_Name) ) - }; - - private static readonly XsdAttributeEntry[] s_simpleContentAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - - private static readonly XsdAttributeEntry[] s_simpleContentExtensionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaBase, new XsdBuildFunction(BuildSimpleContentExtension_Base) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ) - }; - - private static readonly XsdAttributeEntry[] s_simpleContentRestrictionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaBase, new XsdBuildFunction(BuildSimpleContentRestriction_Base) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - - private static readonly XsdAttributeEntry[] s_complexContentAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMixed, new XsdBuildFunction(BuildComplexContent_Mixed) ), - }; - - private static readonly XsdAttributeEntry[] s_complexContentExtensionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaBase, new XsdBuildFunction(BuildComplexContentExtension_Base) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - - private static readonly XsdAttributeEntry[] s_complexContentRestrictionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaBase, new XsdBuildFunction(BuildComplexContentRestriction_Base) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - - private static readonly XsdAttributeEntry[] s_simpleTypeAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFinal, new XsdBuildFunction(BuildSimpleType_Final) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildSimpleType_Name) ) - }; - - private static readonly XsdAttributeEntry[] s_simpleTypeRestrictionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaBase, new XsdBuildFunction(BuildSimpleTypeRestriction_Base) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - - private static readonly XsdAttributeEntry[] s_simpleTypeUnionAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMemberTypes, new XsdBuildFunction(BuildSimpleTypeUnion_MemberTypes) ), - }; - - private static readonly XsdAttributeEntry[] s_simpleTypeListAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaItemType, new XsdBuildFunction(BuildSimpleTypeList_ItemType) ), - }; - - private static readonly XsdAttributeEntry[] s_attributeGroupAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildAttributeGroup_Name) ), - }; - - private static readonly XsdAttributeEntry[] s_attributeGroupRefAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaRef, new XsdBuildFunction(BuildAttributeGroupRef_Ref) ) - }; - - private static readonly XsdAttributeEntry[] s_groupAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildGroup_Name) ), - }; - - private static readonly XsdAttributeEntry[] s_groupRefAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMaxOccurs, new XsdBuildFunction(BuildParticle_MaxOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMinOccurs, new XsdBuildFunction(BuildParticle_MinOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaRef, new XsdBuildFunction(BuildGroupRef_Ref) ) - }; - - private static readonly XsdAttributeEntry[] s_particleAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMaxOccurs, new XsdBuildFunction(BuildParticle_MaxOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMinOccurs, new XsdBuildFunction(BuildParticle_MinOccurs) ), - }; - - - private static readonly XsdAttributeEntry[] s_anyAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMaxOccurs, new XsdBuildFunction(BuildParticle_MaxOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaMinOccurs, new XsdBuildFunction(BuildParticle_MinOccurs) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaNamespace, new XsdBuildFunction(BuildAny_Namespace) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaProcessContents, new XsdBuildFunction(BuildAny_ProcessContents) ) - }; - - private static readonly XsdAttributeEntry[] s_identityConstraintAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildIdentityConstraint_Name) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaRefer, new XsdBuildFunction(BuildIdentityConstraint_Refer) ) - }; - - private static readonly XsdAttributeEntry[] s_selectorAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaXPath, new XsdBuildFunction(BuildSelector_XPath) ) - }; - - private static readonly XsdAttributeEntry[] s_fieldAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaXPath, new XsdBuildFunction(BuildField_XPath) ) - }; - - private static readonly XsdAttributeEntry[] s_notationAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaName, new XsdBuildFunction(BuildNotation_Name) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaPublic, new XsdBuildFunction(BuildNotation_Public) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaSystem, new XsdBuildFunction(BuildNotation_System) ) - }; - - private static readonly XsdAttributeEntry[] s_includeAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaSchemaLocation, new XsdBuildFunction(BuildInclude_SchemaLocation) ) - }; - - private static readonly XsdAttributeEntry[] s_importAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaNamespace, new XsdBuildFunction(BuildImport_Namespace) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaSchemaLocation, new XsdBuildFunction(BuildImport_SchemaLocation) ) - }; - - private static readonly XsdAttributeEntry[] s_facetAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaFixed, new XsdBuildFunction(BuildFacet_Fixed) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaValue, new XsdBuildFunction(BuildFacet_Value) ) - }; - - private static readonly XsdAttributeEntry[] s_anyAttributeAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaNamespace, new XsdBuildFunction(BuildAnyAttribute_Namespace) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaProcessContents, new XsdBuildFunction(BuildAnyAttribute_ProcessContents) ) - }; - - private static readonly XsdAttributeEntry[] s_documentationAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaSource, new XsdBuildFunction(BuildDocumentation_Source) ), - new XsdAttributeEntry(SchemaNames.Token.XmlLang, new XsdBuildFunction(BuildDocumentation_XmlLang) ) - }; - - private static readonly XsdAttributeEntry[] s_appinfoAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaSource, new XsdBuildFunction(BuildAppinfo_Source) ) - }; - - private static readonly XsdAttributeEntry[] s_redefineAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - new XsdAttributeEntry(SchemaNames.Token.SchemaSchemaLocation, new XsdBuildFunction(BuildRedefine_SchemaLocation) ) - }; - - private static readonly XsdAttributeEntry[] s_annotationAttributes = { - new XsdAttributeEntry(SchemaNames.Token.SchemaId, new XsdBuildFunction(BuildAnnotated_Id) ), - }; - // - // XSD Schema entries - // - - private static readonly XsdEntry[] s_schemaEntries = { - /* Root */ new XsdEntry( SchemaNames.Token.Empty, State.Root, s_schemaElement, null, - null, - null, - true), - /* Schema */ new XsdEntry( SchemaNames.Token.XsdSchema, State.Schema, s_schemaSubelements, s_schemaAttributes, - new XsdInitFunction(InitSchema), - null, - true), - /* Annotation */ new XsdEntry( SchemaNames.Token.XsdAnnotation, State.Annotation, s_annotationSubelements, s_annotationAttributes, - new XsdInitFunction(InitAnnotation), - null, - true), - /* Include */ new XsdEntry( SchemaNames.Token.XsdInclude, State.Include, s_annotatedSubelements, s_includeAttributes, - new XsdInitFunction(InitInclude), - null, - true), - /* Import */ new XsdEntry( SchemaNames.Token.XsdImport, State.Import, s_annotatedSubelements, s_importAttributes, - new XsdInitFunction(InitImport), - null, - true), - /* Element */ new XsdEntry( SchemaNames.Token.XsdElement, State.Element, s_elementSubelements, s_elementAttributes, - new XsdInitFunction(InitElement), - null, - true), - /* Attribute */ new XsdEntry( SchemaNames.Token.XsdAttribute, State.Attribute, s_attributeSubelements, s_attributeAttributes, - new XsdInitFunction(InitAttribute), - null, - true), - /* AttributeGroup */ new XsdEntry( SchemaNames.Token.xsdAttributeGroup, State.AttributeGroup, s_attributeGroupSubelements, s_attributeGroupAttributes, - new XsdInitFunction(InitAttributeGroup), - null, - true), - /* AttributeGroupRef */ new XsdEntry( SchemaNames.Token.xsdAttributeGroup, State.AttributeGroupRef, s_annotatedSubelements, s_attributeGroupRefAttributes, - new XsdInitFunction(InitAttributeGroupRef), - null, - true), - /* AnyAttribute */ new XsdEntry( SchemaNames.Token.XsdAnyAttribute, State.AnyAttribute, s_annotatedSubelements, s_anyAttributeAttributes, - new XsdInitFunction(InitAnyAttribute), - null, - true), - /* Group */ new XsdEntry( SchemaNames.Token.XsdGroup, State.Group, s_groupSubelements, s_groupAttributes, - new XsdInitFunction(InitGroup), - null, - true), - /* GroupRef */ new XsdEntry( SchemaNames.Token.XsdGroup, State.GroupRef, s_annotatedSubelements, s_groupRefAttributes, - new XsdInitFunction(InitGroupRef), - null, - true), - /* All */ new XsdEntry( SchemaNames.Token.XsdAll, State.All, s_allSubelements, s_particleAttributes, - new XsdInitFunction(InitAll), - null, - true), - /* Choice */ new XsdEntry( SchemaNames.Token.XsdChoice, State.Choice, s_choiceSequenceSubelements, s_particleAttributes, - new XsdInitFunction(InitChoice), - null, - true), - /* Sequence */ new XsdEntry( SchemaNames.Token.XsdSequence, State.Sequence, s_choiceSequenceSubelements, s_particleAttributes, - new XsdInitFunction(InitSequence), - null, - true), - /* Any */ new XsdEntry( SchemaNames.Token.XsdAny, State.Any, s_annotatedSubelements, s_anyAttributes, - new XsdInitFunction(InitAny), - null, - true), - /* Notation */ new XsdEntry( SchemaNames.Token.XsdNotation, State.Notation, s_annotatedSubelements, s_notationAttributes, - new XsdInitFunction(InitNotation), - null, - true), - /* SimpleType */ new XsdEntry( SchemaNames.Token.XsdSimpleType, State.SimpleType, s_simpleTypeSubelements, s_simpleTypeAttributes, - new XsdInitFunction(InitSimpleType), - null, - true), - /* ComplexType */ new XsdEntry( SchemaNames.Token.XsdComplexType, State.ComplexType, s_complexTypeSubelements, s_complexTypeAttributes, - new XsdInitFunction(InitComplexType), - null, - true), - /* ComplexContent */ new XsdEntry( SchemaNames.Token.XsdComplexContent, State.ComplexContent, s_complexContentSubelements, s_complexContentAttributes, - new XsdInitFunction(InitComplexContent), - null, - true), - /* ComplexContentRestriction */ new XsdEntry( SchemaNames.Token.XsdComplexContentRestriction, State.ComplexContentRestriction, s_complexContentRestrictionSubelements, s_complexContentRestrictionAttributes, - new XsdInitFunction(InitComplexContentRestriction), - null, - true), - /* ComplexContentExtension */ new XsdEntry( SchemaNames.Token.XsdComplexContentExtension, State.ComplexContentExtension, s_complexContentExtensionSubelements, s_complexContentExtensionAttributes, - new XsdInitFunction(InitComplexContentExtension), - null, - true), - /* SimpleContent */ new XsdEntry( SchemaNames.Token.XsdSimpleContent, State.SimpleContent, s_simpleContentSubelements, s_simpleContentAttributes, - new XsdInitFunction(InitSimpleContent), - null, - true), - /* SimpleContentExtension */ new XsdEntry( SchemaNames.Token.XsdSimpleContentExtension, State.SimpleContentExtension, s_simpleContentExtensionSubelements, s_simpleContentExtensionAttributes, - new XsdInitFunction(InitSimpleContentExtension), - null, - true), - /* SimpleContentRestriction */ new XsdEntry( SchemaNames.Token.XsdSimpleContentRestriction, State.SimpleContentRestriction, s_simpleContentRestrictionSubelements, s_simpleContentRestrictionAttributes, - new XsdInitFunction(InitSimpleContentRestriction), - null, - true), - /* SimpleTypeUnion */ new XsdEntry( SchemaNames.Token.XsdSimpleTypeUnion, State.SimpleTypeUnion, s_simpleTypeUnionSubelements, s_simpleTypeUnionAttributes, - new XsdInitFunction(InitSimpleTypeUnion), - null, - true), - /* SimpleTypeList */ new XsdEntry( SchemaNames.Token.XsdSimpleTypeList, State.SimpleTypeList, s_simpleTypeListSubelements, s_simpleTypeListAttributes, - new XsdInitFunction(InitSimpleTypeList), - null, - true), - /* SimpleTypeRestriction */ new XsdEntry( SchemaNames.Token.XsdSimpleTypeRestriction, State.SimpleTypeRestriction, s_simpleTypeRestrictionSubelements, s_simpleTypeRestrictionAttributes, - new XsdInitFunction(InitSimpleTypeRestriction), - null, - true), - /* Unique */ new XsdEntry( SchemaNames.Token.XsdUnique, State.Unique, s_identityConstraintSubelements, s_identityConstraintAttributes, - new XsdInitFunction(InitIdentityConstraint), - null, - true), - /* Key */ new XsdEntry( SchemaNames.Token.XsdKey, State.Key, s_identityConstraintSubelements, s_identityConstraintAttributes, - new XsdInitFunction(InitIdentityConstraint), - null, - true), - /* KeyRef */ new XsdEntry( SchemaNames.Token.XsdKeyref, State.KeyRef, s_identityConstraintSubelements, s_identityConstraintAttributes, - new XsdInitFunction(InitIdentityConstraint), - null, - true), - /* Selector */ new XsdEntry( SchemaNames.Token.XsdSelector, State.Selector, s_annotatedSubelements, s_selectorAttributes, - new XsdInitFunction(InitSelector), - null, - true), - /* Field */ new XsdEntry( SchemaNames.Token.XsdField, State.Field, s_annotatedSubelements, s_fieldAttributes, - new XsdInitFunction(InitField), - null, - true), - /* MinExclusive */ new XsdEntry( SchemaNames.Token.XsdMinExclusive, State.MinExclusive, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* MinInclusive */ new XsdEntry( SchemaNames.Token.XsdMinInclusive, State.MinInclusive, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* MaxExclusive */ new XsdEntry( SchemaNames.Token.XsdMaxExclusive, State.MaxExclusive, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* MaxInclusive */ new XsdEntry( SchemaNames.Token.XsdMaxInclusive, State.MaxInclusive, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* TotalDigits */ new XsdEntry( SchemaNames.Token.XsdTotalDigits, State.TotalDigits, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* FractionDigits */ new XsdEntry( SchemaNames.Token.XsdFractionDigits, State.FractionDigits, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* Length */ new XsdEntry( SchemaNames.Token.XsdLength, State.Length, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* MinLength */ new XsdEntry( SchemaNames.Token.XsdMinLength, State.MinLength, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* MaxLength */ new XsdEntry( SchemaNames.Token.XsdMaxLength, State.MaxLength, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* Enumeration */ new XsdEntry( SchemaNames.Token.XsdEnumeration, State.Enumeration, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* Pattern */ new XsdEntry( SchemaNames.Token.XsdPattern, State.Pattern, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* WhiteSpace */ new XsdEntry( SchemaNames.Token.XsdWhitespace, State.WhiteSpace, s_annotatedSubelements, s_facetAttributes, - new XsdInitFunction(InitFacet), - null, - true), - /* AppInfo */ new XsdEntry( SchemaNames.Token.XsdAppInfo, State.AppInfo, null, s_appinfoAttributes, - new XsdInitFunction(InitAppinfo), - new XsdEndChildFunction(EndAppinfo), - false), - /* Documentation */ new XsdEntry( SchemaNames.Token.XsdDocumentation, State.Documentation, null, s_documentationAttributes, - new XsdInitFunction(InitDocumentation), - new XsdEndChildFunction(EndDocumentation), - false), - /* Redefine */ new XsdEntry( SchemaNames.Token.XsdRedefine, State.Redefine, s_redefineSubelements, s_redefineAttributes, - new XsdInitFunction(InitRedefine), - new XsdEndChildFunction(EndRedefine), - true) - }; - - // - // for 'block' and 'final' attribute values - // - private static readonly int[] s_derivationMethodValues = { - (int)XmlSchemaDerivationMethod.Substitution, - (int)XmlSchemaDerivationMethod.Extension, - (int)XmlSchemaDerivationMethod.Restriction, - (int)XmlSchemaDerivationMethod.List, - (int)XmlSchemaDerivationMethod.Union, - (int)XmlSchemaDerivationMethod.All, - }; - private static readonly string[] s_derivationMethodStrings = { - "substitution", - "extension", - "restriction", - "list", - "union", - "#all", - }; - - private static readonly string[] s_formStringValues = { "qualified", "unqualified" }; - private static readonly string[] s_useStringValues = { "optional", "prohibited", "required" }; - private static readonly string[] s_processContentsStringValues = { "skip", "lax", "strict" }; - - private XmlReader _reader; - private PositionInfo _positionInfo; - private XsdEntry _currentEntry; - private XsdEntry _nextEntry; - private bool _hasChild; - private HWStack _stateHistory = new HWStack(STACK_INCREMENT); - private Stack _containerStack = new Stack(); - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private XmlNamespaceManager _namespaceManager; - private bool _canIncludeImport; - - private XmlSchema _schema; - private XmlSchemaObject _xso; - private XmlSchemaElement _element; - private XmlSchemaAny _anyElement; - private XmlSchemaAttribute _attribute; - private XmlSchemaAnyAttribute _anyAttribute; - private XmlSchemaComplexType _complexType; - private XmlSchemaSimpleType _simpleType; - private XmlSchemaComplexContent _complexContent; - private XmlSchemaComplexContentExtension _complexContentExtension; - private XmlSchemaComplexContentRestriction _complexContentRestriction; - private XmlSchemaSimpleContent _simpleContent; - private XmlSchemaSimpleContentExtension _simpleContentExtension; - private XmlSchemaSimpleContentRestriction _simpleContentRestriction; - private XmlSchemaSimpleTypeUnion _simpleTypeUnion; - private XmlSchemaSimpleTypeList _simpleTypeList; - private XmlSchemaSimpleTypeRestriction _simpleTypeRestriction; - private XmlSchemaGroup _group; - private XmlSchemaGroupRef _groupRef; - private XmlSchemaAll _all; - private XmlSchemaChoice _choice; - private XmlSchemaSequence _sequence; - private XmlSchemaParticle _particle; - private XmlSchemaAttributeGroup _attributeGroup; - private XmlSchemaAttributeGroupRef _attributeGroupRef; - private XmlSchemaNotation _notation; - private XmlSchemaIdentityConstraint _identityConstraint; - private XmlSchemaXPath _xpath; - private XmlSchemaInclude _include; - private XmlSchemaImport _import; - private XmlSchemaAnnotation _annotation; - private XmlSchemaAppInfo _appInfo; - private XmlSchemaDocumentation _documentation; - private XmlSchemaFacet _facet; - private XmlNode[] _markup; - private XmlSchemaRedefine _redefine; - - private ValidationEventHandler _validationEventHandler; - private ArrayList _unhandledAttributes = new ArrayList(); - private Hashtable _namespaces; - - internal XsdBuilder( - XmlReader reader, - XmlNamespaceManager curmgr, - XmlSchema schema, - XmlNameTable nameTable, - SchemaNames schemaNames, - ValidationEventHandler eventhandler - ) - { - _reader = reader; - _xso = _schema = schema; - _namespaceManager = new BuilderNamespaceManager(curmgr, reader); - _validationEventHandler = eventhandler; - _nameTable = nameTable; - _schemaNames = schemaNames; - _stateHistory = new HWStack(STACK_INCREMENT); - _currentEntry = s_schemaEntries[0]; - _positionInfo = PositionInfo.GetPositionInfo(reader); - } - - internal override bool ProcessElement(string prefix, string name, string ns) - { - XmlQualifiedName qname = new XmlQualifiedName(name, ns); - if (GetNextState(qname)) - { - Push(); - Debug.Assert(_currentEntry.InitFunc != null); - _xso = null; - _currentEntry.InitFunc(this, null); - Debug.Assert(_xso != null); - RecordPosition(); - } - else - { - if (!IsSkipableElement(qname)) - { - SendValidationEvent(ResXml.Sch_UnsupportedElement, qname.ToString()); - } - return false; - } - return true; - } - - internal override void ProcessAttribute(string prefix, string name, string ns, string value) - { - XmlQualifiedName qname = new XmlQualifiedName(name, ns); - if (_currentEntry.Attributes != null) - { - for (int i = 0; i < _currentEntry.Attributes.Length; i++) - { - XsdAttributeEntry a = _currentEntry.Attributes[i]; - if (_schemaNames.TokenToQName[(int)a.Attribute].Equals(qname)) - { - try - { - a.BuildFunc(this, value); - } - catch (XmlSchemaException e) - { - e.SetSource(_reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition); - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeDatatypeValue, new string[] { name, e.Message }, XmlSeverityType.Error); - } - return; - } - } - } - - // Check non-supported attribute - if ((ns != _schemaNames.NsXs) && (ns.Length != 0)) - { - if (ns == _schemaNames.NsXmlNs) - { - if (_namespaces == null) - { - _namespaces = new Hashtable(); - } - _namespaces.Add((name == _schemaNames.QnXmlNs.Name) ? string.Empty : name, value); - } - else - { - XmlAttribute attribute = new XmlAttribute(prefix, name, ns, _schema.Document); - attribute.Value = value; - _unhandledAttributes.Add(attribute); - } - } - else - { - SendValidationEvent(ResXml.Sch_UnsupportedAttribute, qname.ToString()); - } - } - - internal override bool IsContentParsed() - { - return _currentEntry.ParseContent; - } - - internal override void ProcessMarkup(XmlNode[] markup) - { - _markup = markup; - } - - internal override void ProcessCData(string value) - { - SendValidationEvent(ResXml.Sch_TextNotAllowed, value); - } - - internal override void StartChildren() - { - if (_xso != null) - { - if (_namespaces != null && _namespaces.Count > 0) - { - _xso.Namespaces.Namespaces = _namespaces; - _namespaces = null; - } - if (_unhandledAttributes.Count != 0) - { - _xso.SetUnhandledAttributes((XmlAttribute[])_unhandledAttributes.ToArray(typeof(Microsoft.Xml.XmlAttribute))); - _unhandledAttributes.Clear(); - } - } - } - - internal override void EndChildren() - { - if (_currentEntry.EndChildFunc != null) - { - (this._currentEntry.EndChildFunc)(this); - } - Pop(); - } - - - // State stack push & pop - private void Push() - { - _stateHistory.Push(); - _stateHistory[_stateHistory.Length - 1] = _currentEntry; - _containerStack.Push(GetContainer(_currentEntry.CurrentState)); - _currentEntry = _nextEntry; - if (_currentEntry.Name != SchemaNames.Token.XsdAnnotation) - { - _hasChild = false; - } - } - - private void Pop() - { - _currentEntry = (XsdEntry)_stateHistory.Pop(); - SetContainer(_currentEntry.CurrentState, _containerStack.Pop()); - _hasChild = true; - } - - private SchemaNames.Token CurrentElement - { - get { return _currentEntry.Name; } - } - - private SchemaNames.Token ParentElement - { - get { return ((XsdEntry)_stateHistory[_stateHistory.Length - 1]).Name; } - } - - private XmlSchemaObject ParentContainer - { - get { return (XmlSchemaObject)_containerStack.Peek(); } - } - - private XmlSchemaObject GetContainer(State state) - { - XmlSchemaObject container = null; - switch (state) - { - case State.Root: - break; - case State.Schema: - container = _schema; - break; - case State.Annotation: - container = _annotation; - break; - case State.Include: - container = _include; - break; - case State.Import: - container = _import; - break; - case State.Element: - container = _element; - break; - case State.Attribute: - container = _attribute; - break; - case State.AttributeGroup: - container = _attributeGroup; - break; - case State.AttributeGroupRef: - container = _attributeGroupRef; - break; - case State.AnyAttribute: - container = _anyAttribute; - break; - case State.Group: - container = _group; - break; - case State.GroupRef: - container = _groupRef; - break; - case State.All: - container = _all; - break; - case State.Choice: - container = _choice; - break; - case State.Sequence: - container = _sequence; - break; - case State.Any: - container = _anyElement; - break; - case State.Notation: - container = _notation; - break; - case State.SimpleType: - container = _simpleType; - break; - case State.ComplexType: - container = _complexType; - break; - case State.ComplexContent: - container = _complexContent; - break; - case State.ComplexContentExtension: - container = _complexContentExtension; - break; - case State.ComplexContentRestriction: - container = _complexContentRestriction; - break; - case State.SimpleContent: - container = _simpleContent; - break; - case State.SimpleContentExtension: - container = _simpleContentExtension; - break; - case State.SimpleContentRestriction: - container = _simpleContentRestriction; - break; - case State.SimpleTypeUnion: - container = _simpleTypeUnion; - break; - case State.SimpleTypeList: - container = _simpleTypeList; - break; - case State.SimpleTypeRestriction: - container = _simpleTypeRestriction; - break; - case State.Unique: - case State.Key: - case State.KeyRef: - container = _identityConstraint; - break; - case State.Selector: - case State.Field: - container = _xpath; - break; - case State.MinExclusive: - case State.MinInclusive: - case State.MaxExclusive: - case State.MaxInclusive: - case State.TotalDigits: - case State.FractionDigits: - case State.Length: - case State.MinLength: - case State.MaxLength: - case State.Enumeration: - case State.Pattern: - case State.WhiteSpace: - container = _facet; - break; - case State.AppInfo: - container = _appInfo; - break; - case State.Documentation: - container = _documentation; - break; - case State.Redefine: - container = _redefine; - break; - default: - Debug.Assert(false, "State is " + state); - break; - } - return container; - } - - private void SetContainer(State state, object container) - { - switch (state) - { - case State.Root: - break; - case State.Schema: - break; - case State.Annotation: - _annotation = (XmlSchemaAnnotation)container; - break; - case State.Include: - _include = (XmlSchemaInclude)container; - break; - case State.Import: - _import = (XmlSchemaImport)container; - break; - case State.Element: - _element = (XmlSchemaElement)container; - break; - case State.Attribute: - _attribute = (XmlSchemaAttribute)container; - break; - case State.AttributeGroup: - _attributeGroup = (XmlSchemaAttributeGroup)container; - break; - case State.AttributeGroupRef: - _attributeGroupRef = (XmlSchemaAttributeGroupRef)container; - break; - case State.AnyAttribute: - _anyAttribute = (XmlSchemaAnyAttribute)container; - break; - case State.Group: - _group = (XmlSchemaGroup)container; - break; - case State.GroupRef: - _groupRef = (XmlSchemaGroupRef)container; - break; - case State.All: - _all = (XmlSchemaAll)container; - break; - case State.Choice: - _choice = (XmlSchemaChoice)container; - break; - case State.Sequence: - _sequence = (XmlSchemaSequence)container; - break; - case State.Any: - _anyElement = (XmlSchemaAny)container; - break; - case State.Notation: - _notation = (XmlSchemaNotation)container; - break; - case State.SimpleType: - _simpleType = (XmlSchemaSimpleType)container; - break; - case State.ComplexType: - _complexType = (XmlSchemaComplexType)container; - break; - case State.ComplexContent: - _complexContent = (XmlSchemaComplexContent)container; - break; - case State.ComplexContentExtension: - _complexContentExtension = (XmlSchemaComplexContentExtension)container; - break; - case State.ComplexContentRestriction: - _complexContentRestriction = (XmlSchemaComplexContentRestriction)container; - break; - case State.SimpleContent: - _simpleContent = (XmlSchemaSimpleContent)container; - break; - case State.SimpleContentExtension: - _simpleContentExtension = (XmlSchemaSimpleContentExtension)container; - break; - case State.SimpleContentRestriction: - _simpleContentRestriction = (XmlSchemaSimpleContentRestriction)container; - break; - case State.SimpleTypeUnion: - _simpleTypeUnion = (XmlSchemaSimpleTypeUnion)container; - break; - case State.SimpleTypeList: - _simpleTypeList = (XmlSchemaSimpleTypeList)container; - break; - case State.SimpleTypeRestriction: - _simpleTypeRestriction = (XmlSchemaSimpleTypeRestriction)container; - break; - case State.Unique: - case State.Key: - case State.KeyRef: - _identityConstraint = (XmlSchemaIdentityConstraint)container; - break; - case State.Selector: - case State.Field: - _xpath = (XmlSchemaXPath)container; - break; - case State.MinExclusive: - case State.MinInclusive: - case State.MaxExclusive: - case State.MaxInclusive: - case State.TotalDigits: - case State.FractionDigits: - case State.Length: - case State.MinLength: - case State.MaxLength: - case State.Enumeration: - case State.Pattern: - case State.WhiteSpace: - _facet = (XmlSchemaFacet)container; - break; - case State.AppInfo: - _appInfo = (XmlSchemaAppInfo)container; - break; - case State.Documentation: - _documentation = (XmlSchemaDocumentation)container; - break; - case State.Redefine: - _redefine = (XmlSchemaRedefine)container; - break; - default: - Debug.Assert(false, "State is " + state); - break; - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // XSD Schema - // - - private static void BuildAnnotated_Id(XsdBuilder builder, string value) - { - builder._xso.IdAttribute = value; - } - - /* - - Content: ((include | import | redefine | annotation)* , ((attribute | attributeGroup | complexType | element | group | notation | simpleType) , annotation*)*) - - */ - - private static void BuildSchema_AttributeFormDefault(XsdBuilder builder, string value) - { - builder._schema.AttributeFormDefault = (XmlSchemaForm)builder.ParseEnum(value, "attributeFormDefault", s_formStringValues); - } - - private static void BuildSchema_ElementFormDefault(XsdBuilder builder, string value) - { - builder._schema.ElementFormDefault = (XmlSchemaForm)builder.ParseEnum(value, "elementFormDefault", s_formStringValues); - } - - private static void BuildSchema_TargetNamespace(XsdBuilder builder, string value) - { - builder._schema.TargetNamespace = value; - } - - private static void BuildSchema_Version(XsdBuilder builder, string value) - { - builder._schema.Version = value; - } - - private static void BuildSchema_FinalDefault(XsdBuilder builder, string value) - { - builder._schema.FinalDefault = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "finalDefault"); - } - - private static void BuildSchema_BlockDefault(XsdBuilder builder, string value) - { - builder._schema.BlockDefault = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "blockDefault"); - } - - private static void InitSchema(XsdBuilder builder, string value) - { - builder._canIncludeImport = true; - builder._xso = builder._schema; - } - - /* - - Content: (annotation?) - - */ - private static void InitInclude(XsdBuilder builder, string value) - { - if (!builder._canIncludeImport) - { - builder.SendValidationEvent(ResXml.Sch_IncludeLocation, null); - } - builder._xso = builder._include = new XmlSchemaInclude(); - builder._schema.Includes.Add(builder._include); - } - - private static void BuildInclude_SchemaLocation(XsdBuilder builder, string value) - { - builder._include.SchemaLocation = value; - } - - /* - - Content: (annotation?) - - */ - private static void InitImport(XsdBuilder builder, string value) - { - if (!builder._canIncludeImport) - { - builder.SendValidationEvent(ResXml.Sch_ImportLocation, null); - } - builder._xso = builder._import = new XmlSchemaImport(); - builder._schema.Includes.Add(builder._import); - } - - private static void BuildImport_Namespace(XsdBuilder builder, string value) - { - builder._import.Namespace = value; - } - - private static void BuildImport_SchemaLocation(XsdBuilder builder, string value) - { - builder._import.SchemaLocation = value; - } - - /* - - Content: (annotation | (attributeGroup | complexType | group | simpleType))* - - */ - private static void InitRedefine(XsdBuilder builder, string value) - { - if (!builder._canIncludeImport) - { - builder.SendValidationEvent(ResXml.Sch_RedefineLocation, null); - } - builder._xso = builder._redefine = new XmlSchemaRedefine(); - builder._schema.Includes.Add(builder._redefine); - } - - private static void BuildRedefine_SchemaLocation(XsdBuilder builder, string value) - { - builder._redefine.SchemaLocation = value; - } - - private static void EndRedefine(XsdBuilder builder) - { - builder._canIncludeImport = true; - } - - /* - - Content: (annotation? , (simpleType?)) - - */ - private static void InitAttribute(XsdBuilder builder, string value) - { - builder._xso = builder._attribute = new XmlSchemaAttribute(); - if (builder.ParentElement == SchemaNames.Token.XsdSchema) - builder._schema.Items.Add(builder._attribute); - else - builder.AddAttribute(builder._attribute); - builder._canIncludeImport = false; // disable import and include elements in schema - } - - private static void BuildAttribute_Default(XsdBuilder builder, string value) - { - builder._attribute.DefaultValue = value; - } - - private static void BuildAttribute_Fixed(XsdBuilder builder, string value) - { - builder._attribute.FixedValue = value; - } - - private static void BuildAttribute_Form(XsdBuilder builder, string value) - { - builder._attribute.Form = (XmlSchemaForm)builder.ParseEnum(value, "form", s_formStringValues); - } - - private static void BuildAttribute_Use(XsdBuilder builder, string value) - { - builder._attribute.Use = (XmlSchemaUse)builder.ParseEnum(value, "use", s_useStringValues); - } - - private static void BuildAttribute_Ref(XsdBuilder builder, string value) - { - builder._attribute.RefName = builder.ParseQName(value, "ref"); - } - - private static void BuildAttribute_Name(XsdBuilder builder, string value) - { - builder._attribute.Name = value; - } - - private static void BuildAttribute_Type(XsdBuilder builder, string value) - { - builder._attribute.SchemaTypeName = builder.ParseQName(value, "type"); - } - - /* - - Content: (annotation? , ((simpleType | complexType)? , (key | keyref | unique)*)) - - */ - private static void InitElement(XsdBuilder builder, string value) - { - builder._xso = builder._element = new XmlSchemaElement(); - builder._canIncludeImport = false; - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdSchema: - builder._schema.Items.Add(builder._element); - break; - case SchemaNames.Token.XsdAll: - builder._all.Items.Add(builder._element); - break; - case SchemaNames.Token.XsdChoice: - builder._choice.Items.Add(builder._element); - break; - case SchemaNames.Token.XsdSequence: - builder._sequence.Items.Add(builder._element); - break; - default: - Debug.Assert(false); - break; - } - } - - private static void BuildElement_Abstract(XsdBuilder builder, string value) - { - builder._element.IsAbstract = builder.ParseBoolean(value, "abstract"); - } - - private static void BuildElement_Block(XsdBuilder builder, string value) - { - builder._element.Block = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "block"); - } - - private static void BuildElement_Default(XsdBuilder builder, string value) - { - builder._element.DefaultValue = value; - } - - private static void BuildElement_Form(XsdBuilder builder, string value) - { - builder._element.Form = (XmlSchemaForm)builder.ParseEnum(value, "form", s_formStringValues); - } - - private static void BuildElement_SubstitutionGroup(XsdBuilder builder, string value) - { - builder._element.SubstitutionGroup = builder.ParseQName(value, "substitutionGroup"); - } - - private static void BuildElement_Final(XsdBuilder builder, string value) - { - builder._element.Final = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "final"); - } - - private static void BuildElement_Fixed(XsdBuilder builder, string value) - { - builder._element.FixedValue = value; - } - - private static void BuildElement_MaxOccurs(XsdBuilder builder, string value) - { - builder.SetMaxOccurs(builder._element, value); - } - - private static void BuildElement_MinOccurs(XsdBuilder builder, string value) - { - builder.SetMinOccurs(builder._element, value); - } - - private static void BuildElement_Name(XsdBuilder builder, string value) - { - builder._element.Name = value; - } - - private static void BuildElement_Nillable(XsdBuilder builder, string value) - { - builder._element.IsNillable = builder.ParseBoolean(value, "nillable"); - } - - private static void BuildElement_Ref(XsdBuilder builder, string value) - { - builder._element.RefName = builder.ParseQName(value, "ref"); - } - - private static void BuildElement_Type(XsdBuilder builder, string value) - { - builder._element.SchemaTypeName = builder.ParseQName(value, "type"); - } - - /* - - Content: (annotation? , ((list | restriction | union))) - - */ - private static void InitSimpleType(XsdBuilder builder, string value) - { - builder._xso = builder._simpleType = new XmlSchemaSimpleType(); - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdSchema: - builder._canIncludeImport = false; // disable import and include elements in schema - builder._schema.Items.Add(builder._simpleType); - break; - case SchemaNames.Token.XsdRedefine: - builder._redefine.Items.Add(builder._simpleType); - break; - case SchemaNames.Token.XsdAttribute: - if (builder._attribute.SchemaType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupXsdElement, "simpleType"); - } - builder._attribute.SchemaType = builder._simpleType; - break; - case SchemaNames.Token.XsdElement: - if (builder._element.SchemaType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupXsdElement, "simpleType"); - } - if (builder._element.Constraints.Count != 0) - { - builder.SendValidationEvent(ResXml.Sch_TypeAfterConstraints, null); - } - builder._element.SchemaType = builder._simpleType; - break; - case SchemaNames.Token.XsdSimpleTypeList: - if (builder._simpleTypeList.ItemType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupXsdElement, "simpleType"); - } - builder._simpleTypeList.ItemType = builder._simpleType; - break; - case SchemaNames.Token.XsdSimpleTypeRestriction: - if (builder._simpleTypeRestriction.BaseType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupXsdElement, "simpleType"); - } - builder._simpleTypeRestriction.BaseType = builder._simpleType; - break; - case SchemaNames.Token.XsdSimpleContentRestriction: - if (builder._simpleContentRestriction.BaseType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupXsdElement, "simpleType"); - } - if ( - builder._simpleContentRestriction.Attributes.Count != 0 || - builder._simpleContentRestriction.AnyAttribute != null || - builder._simpleContentRestriction.Facets.Count != 0 - ) - { - builder.SendValidationEvent(ResXml.Sch_SimpleTypeRestriction, null); - } - builder._simpleContentRestriction.BaseType = builder._simpleType; - break; - - case SchemaNames.Token.XsdSimpleTypeUnion: - builder._simpleTypeUnion.BaseTypes.Add(builder._simpleType); - break; - } - } - - private static void BuildSimpleType_Name(XsdBuilder builder, string value) - { - builder._simpleType.Name = value; - } - - private static void BuildSimpleType_Final(XsdBuilder builder, string value) - { - builder._simpleType.Final = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "final"); - } - - - /* - - Content: (annotation? , (simpleType*)) - - */ - private static void InitSimpleTypeUnion(XsdBuilder builder, string value) - { - if (builder._simpleType.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_DupSimpleTypeChild, null); - } - builder._xso = builder._simpleTypeUnion = new XmlSchemaSimpleTypeUnion(); - builder._simpleType.Content = builder._simpleTypeUnion; - } - - private static void BuildSimpleTypeUnion_MemberTypes(XsdBuilder builder, string value) - { - XmlSchemaDatatype dt = XmlSchemaDatatype.FromXmlTokenizedTypeXsd(XmlTokenizedType.QName).DeriveByList(null); - try - { - builder._simpleTypeUnion.MemberTypes = (XmlQualifiedName[])dt.ParseValue(value, builder._nameTable, builder._namespaceManager); - } - catch (XmlSchemaException e) - { - e.SetSource(builder._reader.BaseURI, builder._positionInfo.LineNumber, builder._positionInfo.LinePosition); - builder.SendValidationEvent(e); - } - } - - - /* - - Content: (annotation? , (simpleType?)) - - */ - private static void InitSimpleTypeList(XsdBuilder builder, string value) - { - if (builder._simpleType.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_DupSimpleTypeChild, null); - } - builder._xso = builder._simpleTypeList = new XmlSchemaSimpleTypeList(); - builder._simpleType.Content = builder._simpleTypeList; - } - - private static void BuildSimpleTypeList_ItemType(XsdBuilder builder, string value) - { - builder._simpleTypeList.ItemTypeName = builder.ParseQName(value, "itemType"); - } - - /* - - Content: (annotation? , (simpleType? , ((duration | encoding | enumeration | length | maxExclusive | maxInclusive | maxLength | minExclusive | minInclusive | minLength | pattern | period | TotalDigits | FractionDigits)*))) - - */ - private static void InitSimpleTypeRestriction(XsdBuilder builder, string value) - { - if (builder._simpleType.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_DupSimpleTypeChild, null); - } - builder._xso = builder._simpleTypeRestriction = new XmlSchemaSimpleTypeRestriction(); - builder._simpleType.Content = builder._simpleTypeRestriction; - } - - private static void BuildSimpleTypeRestriction_Base(XsdBuilder builder, string value) - { - builder._simpleTypeRestriction.BaseTypeName = builder.ParseQName(value, "base"); - } - - /* - - Content: (annotation? , (simpleContent | complexContent | ((group | all | choice | sequence)? , ((attribute | attributeGroup)* , anyAttribute?)))) - - */ - private static void InitComplexType(XsdBuilder builder, string value) - { - builder._xso = builder._complexType = new XmlSchemaComplexType(); - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdSchema: - builder._canIncludeImport = false; // disable import and include elements in schema - builder._schema.Items.Add(builder._complexType); - break; - case SchemaNames.Token.XsdRedefine: - builder._redefine.Items.Add(builder._complexType); - break; - case SchemaNames.Token.XsdElement: - if (builder._element.SchemaType != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "complexType"); - } - if (builder._element.Constraints.Count != 0) - { - builder.SendValidationEvent(ResXml.Sch_TypeAfterConstraints, null); - } - builder._element.SchemaType = builder._complexType; - break; - } - } - - private static void BuildComplexType_Abstract(XsdBuilder builder, string value) - { - builder._complexType.IsAbstract = builder.ParseBoolean(value, "abstract"); - } - - private static void BuildComplexType_Block(XsdBuilder builder, string value) - { - builder._complexType.Block = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "block"); - } - - private static void BuildComplexType_Final(XsdBuilder builder, string value) - { - builder._complexType.Final = (XmlSchemaDerivationMethod)builder.ParseBlockFinalEnum(value, "final"); - } - - private static void BuildComplexType_Mixed(XsdBuilder builder, string value) - { - builder._complexType.IsMixed = builder.ParseBoolean(value, "mixed"); - } - - private static void BuildComplexType_Name(XsdBuilder builder, string value) - { - builder._complexType.Name = value; - } - - /* - - Content: (annotation? , (restriction | extension)) - - */ - private static void InitComplexContent(XsdBuilder builder, string value) - { - if ((builder._complexType.ContentModel != null) || - (builder._complexType.Particle != null || builder._complexType.Attributes.Count != 0 || builder._complexType.AnyAttribute != null) - ) - { - builder.SendValidationEvent(ResXml.Sch_ComplexTypeContentModel, "complexContent"); - } - builder._xso = builder._complexContent = new XmlSchemaComplexContent(); - builder._complexType.ContentModel = builder._complexContent; - } - - private static void BuildComplexContent_Mixed(XsdBuilder builder, string value) - { - builder._complexContent.IsMixed = builder.ParseBoolean(value, "mixed"); - } - - /* - - Content: (annotation? , ((group | all | choice | sequence)? , ((attribute | attributeGroup)* , anyAttribute?))) - - */ - private static void InitComplexContentExtension(XsdBuilder builder, string value) - { - if (builder._complexContent.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_ComplexContentContentModel, "extension"); - } - builder._xso = builder._complexContentExtension = new XmlSchemaComplexContentExtension(); - builder._complexContent.Content = builder._complexContentExtension; - } - - private static void BuildComplexContentExtension_Base(XsdBuilder builder, string value) - { - builder._complexContentExtension.BaseTypeName = builder.ParseQName(value, "base"); - } - - /* - - Content: (annotation? , (group | all | choice | sequence)? , ((attribute | attributeGroup)* , anyAttribute?)) - - */ - private static void InitComplexContentRestriction(XsdBuilder builder, string value) - { - builder._xso = builder._complexContentRestriction = new XmlSchemaComplexContentRestriction(); - builder._complexContent.Content = builder._complexContentRestriction; - } - - private static void BuildComplexContentRestriction_Base(XsdBuilder builder, string value) - { - builder._complexContentRestriction.BaseTypeName = builder.ParseQName(value, "base"); - } - - /* - - Content: (annotation? , (restriction | extension)) - - */ - private static void InitSimpleContent(XsdBuilder builder, string value) - { - if ((builder._complexType.ContentModel != null) || - (builder._complexType.Particle != null || builder._complexType.Attributes.Count != 0 || builder._complexType.AnyAttribute != null) - ) - { - builder.SendValidationEvent(ResXml.Sch_ComplexTypeContentModel, "simpleContent"); - } - builder._xso = builder._simpleContent = new XmlSchemaSimpleContent(); - builder._complexType.ContentModel = builder._simpleContent; - } - - /* - - Content: (annotation? , ((attribute | attributeGroup)* , anyAttribute?)) - - */ - - private static void InitSimpleContentExtension(XsdBuilder builder, string value) - { - if (builder._simpleContent.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "extension"); - } - builder._xso = builder._simpleContentExtension = new XmlSchemaSimpleContentExtension(); - builder._simpleContent.Content = builder._simpleContentExtension; - } - - private static void BuildSimpleContentExtension_Base(XsdBuilder builder, string value) - { - builder._simpleContentExtension.BaseTypeName = builder.ParseQName(value, "base"); - } - - - /* - - Content: (annotation? , ((duration | encoding | enumeration | length | maxExclusive | maxInclusive | maxLength | minExclusive | minInclusive | minLength | pattern | period | totalDigits | fractionDigits)*)? , ((attribute | attributeGroup)* , anyAttribute?)) - - */ - private static void InitSimpleContentRestriction(XsdBuilder builder, string value) - { - if (builder._simpleContent.Content != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "restriction"); - } - builder._xso = builder._simpleContentRestriction = new XmlSchemaSimpleContentRestriction(); - builder._simpleContent.Content = builder._simpleContentRestriction; - } - - private static void BuildSimpleContentRestriction_Base(XsdBuilder builder, string value) - { - builder._simpleContentRestriction.BaseTypeName = builder.ParseQName(value, "base"); - } - - /* - - Content: (annotation? , ((attribute | attributeGroup)* , anyAttribute?)) - - */ - private static void InitAttributeGroup(XsdBuilder builder, string value) - { - builder._canIncludeImport = false; - builder._xso = builder._attributeGroup = new XmlSchemaAttributeGroup(); - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdSchema: - builder._schema.Items.Add(builder._attributeGroup); - break; - case SchemaNames.Token.XsdRedefine: - builder._redefine.Items.Add(builder._attributeGroup); - break; - } - } - - private static void BuildAttributeGroup_Name(XsdBuilder builder, string value) - { - builder._attributeGroup.Name = value; - } - - /* - - Content: (annotation?) - - */ - private static void InitAttributeGroupRef(XsdBuilder builder, string value) - { - builder._xso = builder._attributeGroupRef = new XmlSchemaAttributeGroupRef(); - builder.AddAttribute(builder._attributeGroupRef); - } - - private static void BuildAttributeGroupRef_Ref(XsdBuilder builder, string value) - { - builder._attributeGroupRef.RefName = builder.ParseQName(value, "ref"); - } - - /* - - Content: (annotation?) - - */ - private static void InitAnyAttribute(XsdBuilder builder, string value) - { - builder._xso = builder._anyAttribute = new XmlSchemaAnyAttribute(); - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdComplexType: - if (builder._complexType.ContentModel != null) - { - builder.SendValidationEvent(ResXml.Sch_AttributeMutuallyExclusive, "anyAttribute"); - } - if (builder._complexType.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._complexType.AnyAttribute = builder._anyAttribute; - break; - case SchemaNames.Token.XsdSimpleContentRestriction: - if (builder._simpleContentRestriction.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._simpleContentRestriction.AnyAttribute = builder._anyAttribute; - break; - case SchemaNames.Token.XsdSimpleContentExtension: - if (builder._simpleContentExtension.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._simpleContentExtension.AnyAttribute = builder._anyAttribute; - break; - case SchemaNames.Token.XsdComplexContentExtension: - if (builder._complexContentExtension.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._complexContentExtension.AnyAttribute = builder._anyAttribute; - break; - case SchemaNames.Token.XsdComplexContentRestriction: - if (builder._complexContentRestriction.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._complexContentRestriction.AnyAttribute = builder._anyAttribute; - break; - case SchemaNames.Token.xsdAttributeGroup: - if (builder._attributeGroup.AnyAttribute != null) - { - builder.SendValidationEvent(ResXml.Sch_DupElement, "anyAttribute"); - } - builder._attributeGroup.AnyAttribute = builder._anyAttribute; - break; - } - } - - private static void BuildAnyAttribute_Namespace(XsdBuilder builder, string value) - { - builder._anyAttribute.Namespace = value; - } - - private static void BuildAnyAttribute_ProcessContents(XsdBuilder builder, string value) - { - builder._anyAttribute.ProcessContents = (XmlSchemaContentProcessing)builder.ParseEnum(value, "processContents", s_processContentsStringValues); - } - - /* - - Content: (annotation? , (all | choice | sequence)?) - - */ - private static void InitGroup(XsdBuilder builder, string value) - { - builder._xso = builder._group = new XmlSchemaGroup(); - builder._canIncludeImport = false; // disable import and include elements in schema - switch (builder.ParentElement) - { - case SchemaNames.Token.XsdSchema: - builder._schema.Items.Add(builder._group); - break; - case SchemaNames.Token.XsdRedefine: - builder._redefine.Items.Add(builder._group); - break; - } - } - - private static void BuildGroup_Name(XsdBuilder builder, string value) - { - builder._group.Name = value; - } - - /* - - Content: (annotation?) - - */ - private static void InitGroupRef(XsdBuilder builder, string value) - { - builder._xso = builder._particle = builder._groupRef = new XmlSchemaGroupRef(); - builder.AddParticle(builder._groupRef); - } - - private static void BuildParticle_MaxOccurs(XsdBuilder builder, string value) - { - builder.SetMaxOccurs(builder._particle, value); - } - - private static void BuildParticle_MinOccurs(XsdBuilder builder, string value) - { - builder.SetMinOccurs(builder._particle, value); - } - - private static void BuildGroupRef_Ref(XsdBuilder builder, string value) - { - builder._groupRef.RefName = builder.ParseQName(value, "ref"); - } - - /* - - Content: (annotation? , element*) - - */ - private static void InitAll(XsdBuilder builder, string value) - { - builder._xso = builder._particle = builder._all = new XmlSchemaAll(); - builder.AddParticle(builder._all); - } - - /* - - Content: (annotation? , (element | group | choice | sequence | any)*) - - */ - private static void InitChoice(XsdBuilder builder, string value) - { - builder._xso = builder._particle = builder._choice = new XmlSchemaChoice(); - builder.AddParticle(builder._choice); - } - - /* - - Content: (annotation? , (element | group | choice | sequence | any)*) - - */ - private static void InitSequence(XsdBuilder builder, string value) - { - builder._xso = builder._particle = builder._sequence = new XmlSchemaSequence(); - builder.AddParticle(builder._sequence); - } - - /* - - Content: (annotation?) - - */ - private static void InitAny(XsdBuilder builder, string value) - { - builder._xso = builder._particle = builder._anyElement = new XmlSchemaAny(); - builder.AddParticle(builder._anyElement); - } - - private static void BuildAny_Namespace(XsdBuilder builder, string value) - { - builder._anyElement.Namespace = value; - } - - private static void BuildAny_ProcessContents(XsdBuilder builder, string value) - { - builder._anyElement.ProcessContents = (XmlSchemaContentProcessing)builder.ParseEnum(value, "processContents", s_processContentsStringValues); - } - - /* - - Content: (annotation?) - - */ - private static void InitNotation(XsdBuilder builder, string value) - { - builder._xso = builder._notation = new XmlSchemaNotation(); - builder._canIncludeImport = false; - builder._schema.Items.Add(builder._notation); - } - - private static void BuildNotation_Name(XsdBuilder builder, string value) - { - builder._notation.Name = value; - } - - private static void BuildNotation_Public(XsdBuilder builder, string value) - { - builder._notation.Public = value; - } - - private static void BuildNotation_System(XsdBuilder builder, string value) - { - builder._notation.System = value; - } - - // - // Facets - // - /* - - Content: (annotation?) - - */ - private static void InitFacet(XsdBuilder builder, string value) - { - switch (builder.CurrentElement) - { - case SchemaNames.Token.XsdEnumeration: - builder._facet = new XmlSchemaEnumerationFacet(); - break; - case SchemaNames.Token.XsdLength: - builder._facet = new XmlSchemaLengthFacet(); - break; - case SchemaNames.Token.XsdMaxExclusive: - builder._facet = new XmlSchemaMaxExclusiveFacet(); - break; - case SchemaNames.Token.XsdMaxInclusive: - builder._facet = new XmlSchemaMaxInclusiveFacet(); - break; - case SchemaNames.Token.XsdMaxLength: - builder._facet = new XmlSchemaMaxLengthFacet(); - break; - case SchemaNames.Token.XsdMinExclusive: - builder._facet = new XmlSchemaMinExclusiveFacet(); - break; - case SchemaNames.Token.XsdMinInclusive: - builder._facet = new XmlSchemaMinInclusiveFacet(); - break; - case SchemaNames.Token.XsdMinLength: - builder._facet = new XmlSchemaMinLengthFacet(); - break; - case SchemaNames.Token.XsdPattern: - builder._facet = new XmlSchemaPatternFacet(); - break; - case SchemaNames.Token.XsdTotalDigits: - builder._facet = new XmlSchemaTotalDigitsFacet(); - break; - case SchemaNames.Token.XsdFractionDigits: - builder._facet = new XmlSchemaFractionDigitsFacet(); - break; - case SchemaNames.Token.XsdWhitespace: - builder._facet = new XmlSchemaWhiteSpaceFacet(); - break; - } - builder._xso = builder._facet; - if (SchemaNames.Token.XsdSimpleTypeRestriction == builder.ParentElement) - { - builder._simpleTypeRestriction.Facets.Add(builder._facet); - } - else - { - if (builder._simpleContentRestriction.Attributes.Count != 0 || (builder._simpleContentRestriction.AnyAttribute != null)) - { - builder.SendValidationEvent(ResXml.Sch_InvalidFacetPosition, null); - } - builder._simpleContentRestriction.Facets.Add(builder._facet); - } - } - - private static void BuildFacet_Fixed(XsdBuilder builder, string value) - { - builder._facet.IsFixed = builder.ParseBoolean(value, "fixed"); - } - - private static void BuildFacet_Value(XsdBuilder builder, string value) - { - builder._facet.Value = value; - } - - /* - - Content: (annotation? , (selector , field+)) - - - - Content: (annotation? , (selector , field+)) - - - - Content: (annotation? , (selector , field+)) - - */ - private static void InitIdentityConstraint(XsdBuilder builder, string value) - { - if (!builder._element.RefName.IsEmpty) - { - builder.SendValidationEvent(ResXml.Sch_ElementRef, null); - } - - switch (builder.CurrentElement) - { - case SchemaNames.Token.XsdUnique: - builder._xso = builder._identityConstraint = new XmlSchemaUnique(); - break; - case SchemaNames.Token.XsdKey: - builder._xso = builder._identityConstraint = new XmlSchemaKey(); - break; - case SchemaNames.Token.XsdKeyref: - builder._xso = builder._identityConstraint = new XmlSchemaKeyref(); - break; - } - builder._element.Constraints.Add(builder._identityConstraint); - } - - private static void BuildIdentityConstraint_Name(XsdBuilder builder, string value) - { - builder._identityConstraint.Name = value; - } - - private static void BuildIdentityConstraint_Refer(XsdBuilder builder, string value) - { - if (builder._identityConstraint is XmlSchemaKeyref) - { - ((XmlSchemaKeyref)builder._identityConstraint).Refer = builder.ParseQName(value, "refer"); - } - else - { - builder.SendValidationEvent(ResXml.Sch_UnsupportedAttribute, "refer"); - } - } - - /* - - Content: (annotation?) - - */ - private static void InitSelector(XsdBuilder builder, string value) - { - builder._xso = builder._xpath = new XmlSchemaXPath(); - if (builder._identityConstraint.Selector == null) - { - builder._identityConstraint.Selector = builder._xpath; - } - else - { - builder.SendValidationEvent(ResXml.Sch_DupSelector, builder._identityConstraint.Name); - } - } - - private static void BuildSelector_XPath(XsdBuilder builder, string value) - { - builder._xpath.XPath = value; - } - - /* - - Content: (annotation?) - - */ - private static void InitField(XsdBuilder builder, string value) - { - builder._xso = builder._xpath = new XmlSchemaXPath(); - // no selector before fields? - if (builder._identityConstraint.Selector == null) - { - builder.SendValidationEvent(ResXml.Sch_SelectorBeforeFields, builder._identityConstraint.Name); - } - builder._identityConstraint.Fields.Add(builder._xpath); - } - - private static void BuildField_XPath(XsdBuilder builder, string value) - { - builder._xpath.XPath = value; - } - - /* - - Content: (appinfo | documentation)* - - */ - private static void InitAnnotation(XsdBuilder builder, string value) - { - // On most elements annotations are only allowed to be the first child - // (so the element must not have any children by now), and only one annotation is allowed. - // Exceptions are xs:schema and xs:redefine, these can have any number of annotations - // in any place. - if (builder._hasChild && - builder.ParentElement != SchemaNames.Token.XsdSchema && - builder.ParentElement != SchemaNames.Token.XsdRedefine) - { - builder.SendValidationEvent(ResXml.Sch_AnnotationLocation, null); - } - builder._xso = builder._annotation = new XmlSchemaAnnotation(); - builder.ParentContainer.AddAnnotation(builder._annotation); - } - - /* - - Content: ({any})* - - */ - private static void InitAppinfo(XsdBuilder builder, string value) - { - builder._xso = builder._appInfo = new XmlSchemaAppInfo(); - builder._annotation.Items.Add(builder._appInfo); - builder._markup = new XmlNode[] { }; - } - - private static void BuildAppinfo_Source(XsdBuilder builder, string value) - { - builder._appInfo.Source = ParseUriReference(value); - } - - private static void EndAppinfo(XsdBuilder builder) - { - builder._appInfo.Markup = builder._markup; - } - - - /* - - Content: ({any})* - - */ - private static void InitDocumentation(XsdBuilder builder, string value) - { - builder._xso = builder._documentation = new XmlSchemaDocumentation(); - builder._annotation.Items.Add(builder._documentation); - builder._markup = new XmlNode[] { }; - } - - private static void BuildDocumentation_Source(XsdBuilder builder, string value) - { - builder._documentation.Source = ParseUriReference(value); - } - - private static void BuildDocumentation_XmlLang(XsdBuilder builder, string value) - { - try - { - builder._documentation.Language = value; - } - catch (XmlSchemaException e) - { - e.SetSource(builder._reader.BaseURI, builder._positionInfo.LineNumber, builder._positionInfo.LinePosition); - builder.SendValidationEvent(e); - } - } - - private static void EndDocumentation(XsdBuilder builder) - { - builder._documentation.Markup = builder._markup; - } - - - /////////////////////////////////////////////////////////////////////////////////////////////// - // - // helper functions - - private void AddAttribute(XmlSchemaObject value) - { - switch (this.ParentElement) - { - case SchemaNames.Token.XsdComplexType: - if (_complexType.ContentModel != null) - { - SendValidationEvent(ResXml.Sch_AttributeMutuallyExclusive, "attribute"); - } - if (_complexType.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _complexType.Attributes.Add(value); - break; - case SchemaNames.Token.XsdSimpleContentRestriction: - if (_simpleContentRestriction.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _simpleContentRestriction.Attributes.Add(value); - break; - case SchemaNames.Token.XsdSimpleContentExtension: - if (_simpleContentExtension.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _simpleContentExtension.Attributes.Add(value); - break; - case SchemaNames.Token.XsdComplexContentExtension: - if (_complexContentExtension.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _complexContentExtension.Attributes.Add(value); - break; - case SchemaNames.Token.XsdComplexContentRestriction: - if (_complexContentRestriction.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _complexContentRestriction.Attributes.Add(value); - break; - case SchemaNames.Token.xsdAttributeGroup: - if (_attributeGroup.AnyAttribute != null) - { - SendValidationEvent(ResXml.Sch_AnyAttributeLastChild, null); - } - _attributeGroup.Attributes.Add(value); - break; - default: - Debug.Assert(false); - break; - } - } - - private void AddParticle(XmlSchemaParticle particle) - { - switch (this.ParentElement) - { - case SchemaNames.Token.XsdComplexType: - if ((_complexType.ContentModel != null) || - (_complexType.Attributes.Count != 0 || _complexType.AnyAttribute != null) || - (_complexType.Particle != null) - ) - { - SendValidationEvent(ResXml.Sch_ComplexTypeContentModel, "complexType"); - } - _complexType.Particle = particle; - break; - case SchemaNames.Token.XsdComplexContentExtension: - if ((_complexContentExtension.Particle != null) || - (_complexContentExtension.Attributes.Count != 0 || _complexContentExtension.AnyAttribute != null) - ) - { - SendValidationEvent(ResXml.Sch_ComplexContentContentModel, "ComplexContentExtension"); - } - _complexContentExtension.Particle = particle; - break; - case SchemaNames.Token.XsdComplexContentRestriction: - if ((_complexContentRestriction.Particle != null) || - (_complexContentRestriction.Attributes.Count != 0 || _complexContentRestriction.AnyAttribute != null) - ) - { - SendValidationEvent(ResXml.Sch_ComplexContentContentModel, "ComplexContentExtension"); - } - _complexContentRestriction.Particle = particle; - break; - case SchemaNames.Token.XsdGroup: - if (_group.Particle != null) - { - SendValidationEvent(ResXml.Sch_DupGroupParticle, "particle"); - } - _group.Particle = (XmlSchemaGroupBase)particle; - break; - case SchemaNames.Token.XsdChoice: - case SchemaNames.Token.XsdSequence: - ((XmlSchemaGroupBase)this.ParentContainer).Items.Add(particle); - break; - default: - Debug.Assert(false); - break; - } - } - - private bool GetNextState(XmlQualifiedName qname) - { - if (_currentEntry.NextStates != null) - { - for (int i = 0; i < _currentEntry.NextStates.Length; ++i) - { - int state = (int)_currentEntry.NextStates[i]; - if (_schemaNames.TokenToQName[(int)s_schemaEntries[state].Name].Equals(qname)) - { - _nextEntry = s_schemaEntries[state]; - return true; - } - } - } - - return false; - } - - private bool IsSkipableElement(XmlQualifiedName qname) - { - return ((CurrentElement == SchemaNames.Token.XsdDocumentation) || - (CurrentElement == SchemaNames.Token.XsdAppInfo)); - } - - private void SetMinOccurs(XmlSchemaParticle particle, string value) - { - try - { - particle.MinOccursString = value; - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_MinOccursInvalidXsd, null); - } - } - - private void SetMaxOccurs(XmlSchemaParticle particle, string value) - { - try - { - particle.MaxOccursString = value; - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_MaxOccursInvalidXsd, null); - } - } - - private bool ParseBoolean(string value, string attributeName) - { - try - { - return XmlConvert.ToBoolean(value); - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, value, null); - return false; - } - } - - private int ParseEnum(string value, string attributeName, string[] values) - { - string s = value.Trim(); - for (int i = 0; i < values.Length; i++) - { - if (values[i] == s) - return i + 1; - } - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, s, null); - return 0; - } - - private XmlQualifiedName ParseQName(string value, string attributeName) - { - try - { - string prefix; - value = XmlComplianceUtil.NonCDataNormalize(value); //Normalize QName - return XmlQualifiedName.Parse(value, _namespaceManager, out prefix); - } - catch (Exception) - { - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, value, null); - return XmlQualifiedName.Empty; - } - } - - private int ParseBlockFinalEnum(string value, string attributeName) - { - const int HashAllLength = 4; // Length of "#all" - int r = 0; - string[] stringValues = XmlConvert.SplitString(value); - for (int i = 0; i < stringValues.Length; i++) - { - bool matched = false; - for (int j = 0; j < s_derivationMethodStrings.Length; j++) - { - if (stringValues[i] == s_derivationMethodStrings[j]) - { - if ((r & s_derivationMethodValues[j]) != 0 && (r & s_derivationMethodValues[j]) != s_derivationMethodValues[j]) - { - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, value, null); - return 0; - } - r |= s_derivationMethodValues[j]; - matched = true; - break; - } - } - if (!matched) - { - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, value, null); - return 0; - } - if (r == (int)XmlSchemaDerivationMethod.All && value.Length > HashAllLength) - { //#all is not allowed with other values - SendValidationEvent(ResXml.Sch_InvalidXsdAttributeValue, attributeName, value, null); - return 0; - } - } - return r; - } - - private static string ParseUriReference(string s) - { - return s; - } - - private void SendValidationEvent(string code, string arg0, string arg1, string arg2) - { - SendValidationEvent(new XmlSchemaException(code, new string[] { arg0, arg1, arg2 }, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - private void SendValidationEvent(string code, string msg) - { - SendValidationEvent(new XmlSchemaException(code, msg, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - private void SendValidationEvent(string code, string[] args, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, args, _reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - - private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) - { - _schema.ErrorCount++; - e.SetSchemaObject(_schema); - if (_validationEventHandler != null) - { - _validationEventHandler(null, new ValidationEventArgs(e, severity)); - } - else if (severity == XmlSeverityType.Error) - { - throw e; - } - } - - private void SendValidationEvent(XmlSchemaException e) - { - SendValidationEvent(e, XmlSeverityType.Error); - } - - private void RecordPosition() - { - _xso.SourceUri = _reader.BaseURI; - _xso.LineNumber = _positionInfo.LineNumber; - _xso.LinePosition = _positionInfo.LinePosition; - if (_xso != _schema) - { - _xso.Parent = this.ParentContainer; - } - } - }; // class XsdBuilder -} // namespace Microsoft.Xml.Schema diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDateTime.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDateTime.cs deleted file mode 100644 index d80a08a3955..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDateTime.cs +++ /dev/null @@ -1,1099 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - using System.Diagnostics; - using System.Text; - - /// - /// This enum specifies what format should be used when converting string to XsdDateTime - /// - [Flags] - internal enum XsdDateTimeFlags - { - DateTime = 0x01, - Time = 0x02, - Date = 0x04, - GYearMonth = 0x08, - GYear = 0x10, - GMonthDay = 0x20, - GDay = 0x40, - GMonth = 0x80, - XdrDateTimeNoTz = 0x100, - XdrDateTime = 0x200, - XdrTimeNoTz = 0x400, //XDRTime with tz is the same as xsd:time - AllXsd = 0xFF //All still does not include the XDR formats - } - - /// - /// This structure extends System.DateTime to support timeInTicks zone and Gregorian types scomponents of an Xsd Duration. It is used internally to support Xsd durations without loss - /// of fidelity. XsdDuration structures are immutable once they've been created. - /// - internal struct XsdDateTime - { - // DateTime is being used as an internal representation only - // Casting XsdDateTime to DateTime might return a different value - private DateTime _dt; - - // Additional information that DateTime is not preserving - // Information is stored in the following format: - // Bits Info - // 31-24 DateTimeTypeCode - // 23-16 XsdDateTimeKind - // 15-8 Zone Hours - // 7-0 Zone Minutes - private uint _extra; - - - // Subset of XML Schema types XsdDateTime represents - private enum DateTimeTypeCode - { - DateTime, - Time, - Date, - GYearMonth, - GYear, - GMonthDay, - GDay, - GMonth, - XdrDateTime, - } - - // Internal representation of DateTimeKind - private enum XsdDateTimeKind - { - Unspecified, - Zulu, - LocalWestOfZulu, // GMT-1..14, N..Y - LocalEastOfZulu // GMT+1..14, A..M - } - - // Masks and shifts used for packing and unpacking extra - private const uint TypeMask = 0xFF000000; - private const uint KindMask = 0x00FF0000; - private const uint ZoneHourMask = 0x0000FF00; - private const uint ZoneMinuteMask = 0x000000FF; - private const int TypeShift = 24; - private const int KindShift = 16; - private const int ZoneHourShift = 8; - - // Maximum number of fraction digits; - private const short maxFractionDigits = 7; - - private static readonly int s_lzyyyy = "yyyy".Length; - private static readonly int s_lzyyyy_ = "yyyy-".Length; - private static readonly int s_lzyyyy_MM = "yyyy-MM".Length; - private static readonly int s_lzyyyy_MM_ = "yyyy-MM-".Length; - private static readonly int s_lzyyyy_MM_dd = "yyyy-MM-dd".Length; - private static readonly int s_lzyyyy_MM_ddT = "yyyy-MM-ddT".Length; - private static readonly int s_lzHH = "HH".Length; - private static readonly int s_lzHH_ = "HH:".Length; - private static readonly int s_lzHH_mm = "HH:mm".Length; - private static readonly int s_lzHH_mm_ = "HH:mm:".Length; - private static readonly int s_lzHH_mm_ss = "HH:mm:ss".Length; - private static readonly int s_Lz_ = "-".Length; - private static readonly int s_lz_zz = "-zz".Length; - private static readonly int s_lz_zz_ = "-zz:".Length; - private static readonly int s_lz_zz_zz = "-zz:zz".Length; - private static readonly int s_Lz__ = "--".Length; - private static readonly int s_lz__mm = "--MM".Length; - private static readonly int s_lz__mm_ = "--MM-".Length; - private static readonly int s_lz__mm__ = "--MM--".Length; - private static readonly int s_lz__mm_dd = "--MM-dd".Length; - private static readonly int s_Lz___ = "---".Length; - private static readonly int s_lz___dd = "---dd".Length; - - - /// - /// Constructs an XsdDateTime from a string trying all possible formats. - /// - public XsdDateTime(string text) : this(text, XsdDateTimeFlags.AllXsd) - { - } - - /// - /// Constructs an XsdDateTime from a string using specific format. - /// - public XsdDateTime(string text, XsdDateTimeFlags kinds) : this() - { - Parser parser = new Parser(); - if (!parser.Parse(text, kinds)) - { - throw new FormatException(string.Format(ResXml.XmlConvert_BadFormat, text, kinds)); - } - InitiateXsdDateTime(parser); - } - - private XsdDateTime(Parser parser) : this() - { - InitiateXsdDateTime(parser); - } - - private void InitiateXsdDateTime(Parser parser) - { - _dt = new DateTime(parser.year, parser.month, parser.day, parser.hour, parser.minute, parser.second); - if (parser.fraction != 0) - { - _dt = _dt.AddTicks(parser.fraction); - } - _extra = (uint)(((int)parser.typeCode << TypeShift) | ((int)parser.kind << KindShift) | (parser.zoneHour << ZoneHourShift) | parser.zoneMinute); - } - - internal static bool TryParse(string text, XsdDateTimeFlags kinds, out XsdDateTime result) - { - Parser parser = new Parser(); - if (!parser.Parse(text, kinds)) - { - result = new XsdDateTime(); - return false; - } - result = new XsdDateTime(parser); - return true; - } - - /// - /// Constructs an XsdDateTime from a DateTime. - /// - public XsdDateTime(DateTime dateTime, XsdDateTimeFlags kinds) - { - Debug.Assert(Bits.ExactlyOne((uint)kinds), "Only one DateTime type code can be set."); - _dt = dateTime; - - DateTimeTypeCode code = (DateTimeTypeCode)(Bits.LeastPosition((uint)kinds) - 1); - int zoneHour = 0; - int zoneMinute = 0; - XsdDateTimeKind kind; - - switch (dateTime.Kind) - { - case DateTimeKind.Unspecified: kind = XsdDateTimeKind.Unspecified; break; - case DateTimeKind.Utc: kind = XsdDateTimeKind.Zulu; break; - - default: - { - Debug.Assert(dateTime.Kind == DateTimeKind.Local, "Unknown DateTimeKind: " + dateTime.Kind); - TimeSpan utcOffset = TimeZoneInfo.Local.GetUtcOffset(dateTime); - - if (utcOffset.Ticks < 0) - { - kind = XsdDateTimeKind.LocalWestOfZulu; - zoneHour = -utcOffset.Hours; - zoneMinute = -utcOffset.Minutes; - } - else - { - kind = XsdDateTimeKind.LocalEastOfZulu; - zoneHour = utcOffset.Hours; - zoneMinute = utcOffset.Minutes; - } - break; - } - } - - _extra = (uint)(((int)code << TypeShift) | ((int)kind << KindShift) | (zoneHour << ZoneHourShift) | zoneMinute); - } - - // Constructs an XsdDateTime from a DateTimeOffset - public XsdDateTime(DateTimeOffset dateTimeOffset) : this(dateTimeOffset, XsdDateTimeFlags.DateTime) - { - } - - public XsdDateTime(DateTimeOffset dateTimeOffset, XsdDateTimeFlags kinds) - { - Debug.Assert(Bits.ExactlyOne((uint)kinds), "Only one DateTime type code can be set."); - - _dt = dateTimeOffset.DateTime; - - TimeSpan zoneOffset = dateTimeOffset.Offset; - DateTimeTypeCode code = (DateTimeTypeCode)(Bits.LeastPosition((uint)kinds) - 1); - XsdDateTimeKind kind; - if (zoneOffset.TotalMinutes < 0) - { - zoneOffset = zoneOffset.Negate(); - kind = XsdDateTimeKind.LocalWestOfZulu; - } - else if (zoneOffset.TotalMinutes > 0) - { - kind = XsdDateTimeKind.LocalEastOfZulu; - } - else - { - kind = XsdDateTimeKind.Zulu; - } - - _extra = (uint)(((int)code << TypeShift) | ((int)kind << KindShift) | (zoneOffset.Hours << ZoneHourShift) | zoneOffset.Minutes); - } - - /// - /// Returns auxiliary enumeration of XSD date type - /// - private DateTimeTypeCode InternalTypeCode - { - get { return (DateTimeTypeCode)((_extra & TypeMask) >> TypeShift); } - } - - /// - /// Returns geographical "position" of the value - /// - private XsdDateTimeKind InternalKind - { - get { return (XsdDateTimeKind)((_extra & KindMask) >> KindShift); } - } - - /// - /// Returns XmlTypeCode of the value being stored - /// - public XmlTypeCode TypeCode - { - get { return s_typeCodes[(int)InternalTypeCode]; } - } - - /// - /// Returns whether object represent local, UTC or unspecified time - /// - public DateTimeKind Kind - { - get - { - switch (InternalKind) - { - case XsdDateTimeKind.Unspecified: - return DateTimeKind.Unspecified; - case XsdDateTimeKind.Zulu: - return DateTimeKind.Utc; - default: - // XsdDateTimeKind.LocalEastOfZulu: - // XsdDateTimeKind.LocalWestOfZulu: - return DateTimeKind.Local; - } - } - } - - /// - /// Returns the year part of XsdDateTime - /// The returned value is integer between 1 and 9999 - /// - public int Year - { - get { return _dt.Year; } - } - - /// - /// Returns the month part of XsdDateTime - /// The returned value is integer between 1 and 12 - /// - public int Month - { - get { return _dt.Month; } - } - - /// - /// Returns the day of the month part of XsdDateTime - /// The returned value is integer between 1 and 31 - /// - public int Day - { - get { return _dt.Day; } - } - - /// - /// Returns the hour part of XsdDateTime - /// The returned value is integer between 0 and 23 - /// - public int Hour - { - get { return _dt.Hour; } - } - - /// - /// Returns the minute part of XsdDateTime - /// The returned value is integer between 0 and 60 - /// - public int Minute - { - get { return _dt.Minute; } - } - - /// - /// Returns the second part of XsdDateTime - /// The returned value is integer between 0 and 60 - /// - public int Second - { - get { return _dt.Second; } - } - - /// - /// Returns number of ticks in the fraction of the second - /// The returned value is integer between 0 and 9999999 - /// - public int Fraction - { - get { return (int)(_dt.Ticks - new DateTime(_dt.Year, _dt.Month, _dt.Day, _dt.Hour, _dt.Minute, _dt.Second).Ticks); } - } - - /// - /// Returns the hour part of the time zone - /// The returned value is integer between -13 and 13 - /// - public int ZoneHour - { - get - { - uint result = (_extra & ZoneHourMask) >> ZoneHourShift; - return (int)result; - } - } - - /// - /// Returns the minute part of the time zone - /// The returned value is integer between 0 and 60 - /// - public int ZoneMinute - { - get - { - uint result = (_extra & ZoneMinuteMask); - return (int)result; - } - } - - public DateTime ToZulu() - { - switch (InternalKind) - { - case XsdDateTimeKind.Zulu: - // set it to UTC - return new DateTime(_dt.Ticks, DateTimeKind.Utc); - case XsdDateTimeKind.LocalEastOfZulu: - // Adjust to UTC and then convert to local in the current time zone - return new DateTime(_dt.Subtract(new TimeSpan(ZoneHour, ZoneMinute, 0)).Ticks, DateTimeKind.Utc); - case XsdDateTimeKind.LocalWestOfZulu: - // Adjust to UTC and then convert to local in the current time zone - return new DateTime(_dt.Add(new TimeSpan(ZoneHour, ZoneMinute, 0)).Ticks, DateTimeKind.Utc); - default: - return _dt; - } - } - - /// - /// Cast to DateTime - /// The following table describes the behaviors of getting the default value - /// when a certain year/month/day values are missing. - /// - /// An "X" means that the value exists. And "--" means that value is missing. - /// - /// Year Month Day => ResultYear ResultMonth ResultDay Note - /// - /// X X X Parsed year Parsed month Parsed day - /// X X -- Parsed Year Parsed month First day If we have year and month, assume the first day of that month. - /// X -- X Parsed year First month Parsed day If the month is missing, assume first month of that year. - /// X -- -- Parsed year First month First day If we have only the year, assume the first day of that year. - /// - /// -- X X CurrentYear Parsed month Parsed day If the year is missing, assume the current year. - /// -- X -- CurrentYear Parsed month First day If we have only a month value, assume the current year and current day. - /// -- -- X CurrentYear First month Parsed day If we have only a day value, assume current year and first month. - /// -- -- -- CurrentYear Current month Current day So this means that if the date string only contains time, you will get current date. - /// - public static implicit operator DateTime(XsdDateTime xdt) - { - DateTime result; - switch (xdt.InternalTypeCode) - { - case DateTimeTypeCode.GMonth: - case DateTimeTypeCode.GDay: - result = new DateTime(DateTime.Now.Year, xdt.Month, xdt.Day); - break; - case DateTimeTypeCode.Time: - //back to DateTime.Now - DateTime currentDateTime = DateTime.Now; - TimeSpan addDiff = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day) - new DateTime(xdt.Year, xdt.Month, xdt.Day); - result = xdt._dt.Add(addDiff); - break; - default: - result = xdt._dt; - break; - } - - long ticks; - switch (xdt.InternalKind) - { - case XsdDateTimeKind.Zulu: - // set it to UTC - result = new DateTime(result.Ticks, DateTimeKind.Utc); - break; - case XsdDateTimeKind.LocalEastOfZulu: - // Adjust to UTC and then convert to local in the current time zone - ticks = result.Ticks - new TimeSpan(xdt.ZoneHour, xdt.ZoneMinute, 0).Ticks; - if (ticks < DateTime.MinValue.Ticks) - { - // Underflow. Return the DateTime as local time directly - ticks += TimeZoneInfo.Local.GetUtcOffset(result).Ticks; - if (ticks < DateTime.MinValue.Ticks) - ticks = DateTime.MinValue.Ticks; - return new DateTime(ticks, DateTimeKind.Local); - } - result = new DateTime(ticks, DateTimeKind.Utc).ToLocalTime(); - break; - case XsdDateTimeKind.LocalWestOfZulu: - // Adjust to UTC and then convert to local in the current time zone - ticks = result.Ticks + new TimeSpan(xdt.ZoneHour, xdt.ZoneMinute, 0).Ticks; - if (ticks > DateTime.MaxValue.Ticks) - { - // Overflow. Return the DateTime as local time directly - ticks += TimeZoneInfo.Local.GetUtcOffset(result).Ticks; - if (ticks > DateTime.MaxValue.Ticks) - ticks = DateTime.MaxValue.Ticks; - return new DateTime(ticks, DateTimeKind.Local); - } - result = new DateTime(ticks, DateTimeKind.Utc).ToLocalTime(); - break; - default: - break; - } - return result; - } - - public static implicit operator DateTimeOffset(XsdDateTime xdt) - { - DateTime dt; - - switch (xdt.InternalTypeCode) - { - case DateTimeTypeCode.GMonth: - case DateTimeTypeCode.GDay: - dt = new DateTime(DateTime.Now.Year, xdt.Month, xdt.Day); - break; - case DateTimeTypeCode.Time: - //back to DateTime.Now - DateTime currentDateTime = DateTime.Now; - TimeSpan addDiff = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day) - new DateTime(xdt.Year, xdt.Month, xdt.Day); - dt = xdt._dt.Add(addDiff); - break; - default: - dt = xdt._dt; - break; - } - - DateTimeOffset result; - switch (xdt.InternalKind) - { - case XsdDateTimeKind.LocalEastOfZulu: - result = new DateTimeOffset(dt, new TimeSpan(xdt.ZoneHour, xdt.ZoneMinute, 0)); - break; - case XsdDateTimeKind.LocalWestOfZulu: - result = new DateTimeOffset(dt, new TimeSpan(-xdt.ZoneHour, -xdt.ZoneMinute, 0)); - break; - case XsdDateTimeKind.Zulu: - result = new DateTimeOffset(dt, new TimeSpan(0)); - break; - case XsdDateTimeKind.Unspecified: - default: - result = new DateTimeOffset(dt, TimeZoneInfo.Local.GetUtcOffset(dt)); - break; - } - - return result; - } - - /// - /// Compares two DateTime values, returning an integer that indicates - /// their relationship. - /// - public static int Compare(XsdDateTime left, XsdDateTime right) - { - if (left._extra == right._extra) - { - return DateTime.Compare(left._dt, right._dt); - } - else - { - // Xsd types should be the same for it to be comparable - if (left.InternalTypeCode != right.InternalTypeCode) - { - throw new ArgumentException(string.Format(ResXml.Sch_XsdDateTimeCompare, left.TypeCode, right.TypeCode)); - } - // Convert both to UTC - return DateTime.Compare(left.GetZuluDateTime(), right.GetZuluDateTime()); - } - } - - // Compares this DateTime to a given object. This method provides an - // implementation of the IComparable interface. The object - // argument must be another DateTime, or otherwise an exception - // occurs. Null is considered less than any instance. - // - // Returns a value less than zero if this object - /// - public int CompareTo(Object value) - { - if (value == null) return 1; - return Compare(this, (XsdDateTime)value); - } - - /// - /// Serialization to a string - /// - public override string ToString() - { - StringBuilder sb = new StringBuilder(64); - char[] text; - switch (InternalTypeCode) - { - case DateTimeTypeCode.DateTime: - PrintDate(sb); - sb.Append('T'); - PrintTime(sb); - break; - case DateTimeTypeCode.Time: - PrintTime(sb); - break; - case DateTimeTypeCode.Date: - PrintDate(sb); - break; - case DateTimeTypeCode.GYearMonth: - text = new char[s_lzyyyy_MM]; - IntToCharArray(text, 0, Year, 4); - text[s_lzyyyy] = '-'; - ShortToCharArray(text, s_lzyyyy_, Month); - sb.Append(text); - break; - case DateTimeTypeCode.GYear: - text = new char[s_lzyyyy]; - IntToCharArray(text, 0, Year, 4); - sb.Append(text); - break; - case DateTimeTypeCode.GMonthDay: - text = new char[s_lz__mm_dd]; - text[0] = '-'; - text[s_Lz_] = '-'; - ShortToCharArray(text, s_Lz__, Month); - text[s_lz__mm] = '-'; - ShortToCharArray(text, s_lz__mm_, Day); - sb.Append(text); - break; - case DateTimeTypeCode.GDay: - text = new char[s_lz___dd]; - text[0] = '-'; - text[s_Lz_] = '-'; - text[s_Lz__] = '-'; - ShortToCharArray(text, s_Lz__, Day); - sb.Append(text); - break; - case DateTimeTypeCode.GMonth: - text = new char[s_lz__mm__]; - text[0] = '-'; - text[s_Lz_] = '-'; - ShortToCharArray(text, s_Lz__, Month); - text[s_lz__mm] = '-'; - text[s_lz__mm_] = '-'; - sb.Append(text); - break; - } - PrintZone(sb); - return sb.ToString(); - } - - // Serialize year, month and day - private void PrintDate(StringBuilder sb) - { - char[] text = new char[s_lzyyyy_MM_dd]; - IntToCharArray(text, 0, Year, 4); - text[s_lzyyyy] = '-'; - ShortToCharArray(text, s_lzyyyy_, Month); - text[s_lzyyyy_MM] = '-'; - ShortToCharArray(text, s_lzyyyy_MM_, Day); - sb.Append(text); - } - - // Serialize hour, minute, second and fraction - private void PrintTime(StringBuilder sb) - { - char[] text = new char[s_lzHH_mm_ss]; - ShortToCharArray(text, 0, Hour); - text[s_lzHH] = ':'; - ShortToCharArray(text, s_lzHH_, Minute); - text[s_lzHH_mm] = ':'; - ShortToCharArray(text, s_lzHH_mm_, Second); - sb.Append(text); - int fraction = Fraction; - if (fraction != 0) - { - int fractionDigits = maxFractionDigits; - while (fraction % 10 == 0) - { - fractionDigits--; - fraction /= 10; - } - text = new char[fractionDigits + 1]; - text[0] = '.'; - IntToCharArray(text, 1, fraction, fractionDigits); - sb.Append(text); - } - } - - // Serialize time zone - private void PrintZone(StringBuilder sb) - { - char[] text; - switch (InternalKind) - { - case XsdDateTimeKind.Zulu: - sb.Append('Z'); - break; - case XsdDateTimeKind.LocalWestOfZulu: - text = new char[s_lz_zz_zz]; - text[0] = '-'; - ShortToCharArray(text, s_Lz_, ZoneHour); - text[s_lz_zz] = ':'; - ShortToCharArray(text, s_lz_zz_, ZoneMinute); - sb.Append(text); - break; - case XsdDateTimeKind.LocalEastOfZulu: - text = new char[s_lz_zz_zz]; - text[0] = '+'; - ShortToCharArray(text, s_Lz_, ZoneHour); - text[s_lz_zz] = ':'; - ShortToCharArray(text, s_lz_zz_, ZoneMinute); - sb.Append(text); - break; - default: - // do nothing - break; - } - } - - // Serialize integer into character array starting with index [start]. - // Number of digits is set by [digits] - private void IntToCharArray(char[] text, int start, int value, int digits) - { - while (digits-- != 0) - { - text[start + digits] = (char)(value % 10 + '0'); - value /= 10; - } - } - - // Serialize two digit integer into character array starting with index [start]. - private void ShortToCharArray(char[] text, int start, int value) - { - text[start] = (char)(value / 10 + '0'); - text[start + 1] = (char)(value % 10 + '0'); - } - - // Auxiliary for compare. - // Returns UTC DateTime - private DateTime GetZuluDateTime() - { - switch (InternalKind) - { - case XsdDateTimeKind.Zulu: - return _dt; - case XsdDateTimeKind.LocalEastOfZulu: - return _dt.Subtract(new TimeSpan(ZoneHour, ZoneMinute, 0)); - case XsdDateTimeKind.LocalWestOfZulu: - return _dt.Add(new TimeSpan(ZoneHour, ZoneMinute, 0)); - default: - return _dt.ToUniversalTime(); - } - } - - private static readonly XmlTypeCode[] s_typeCodes = { - XmlTypeCode.DateTime, - XmlTypeCode.Time, - XmlTypeCode.Date, - XmlTypeCode.GYearMonth, - XmlTypeCode.GYear, - XmlTypeCode.GMonthDay, - XmlTypeCode.GDay, - XmlTypeCode.GMonth - }; - - - // Parsing string according to XML schema spec - private struct Parser - { - private const int leapYear = 1904; - private const int firstMonth = 1; - private const int firstDay = 1; - - public DateTimeTypeCode typeCode; - public int year; - public int month; - public int day; - public int hour; - public int minute; - public int second; - public int fraction; - public XsdDateTimeKind kind; - public int zoneHour; - public int zoneMinute; - - private string _text; - private int _length; - - public bool Parse(string text, XsdDateTimeFlags kinds) - { - _text = text; - _length = text.Length; - - // Skip leading withitespace - int start = 0; - while (start < _length && char.IsWhiteSpace(text[start])) - { - start++; - } - // Choose format starting from the most common and trying not to reparse the same thing too many times - - if (Test(kinds, XsdDateTimeFlags.DateTime | XsdDateTimeFlags.Date | XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrDateTimeNoTz)) - { - if (ParseDate(start)) - { - if (Test(kinds, XsdDateTimeFlags.DateTime)) - { - if (ParseChar(start + s_lzyyyy_MM_dd, 'T') && ParseTimeAndZoneAndWhitespace(start + s_lzyyyy_MM_ddT)) - { - typeCode = DateTimeTypeCode.DateTime; - return true; - } - } - if (Test(kinds, XsdDateTimeFlags.Date)) - { - if (ParseZoneAndWhitespace(start + s_lzyyyy_MM_dd)) - { - typeCode = DateTimeTypeCode.Date; - return true; - } - } - if (Test(kinds, XsdDateTimeFlags.XdrDateTime)) - { - if (ParseZoneAndWhitespace(start + s_lzyyyy_MM_dd) || (ParseChar(start + s_lzyyyy_MM_dd, 'T') && ParseTimeAndZoneAndWhitespace(start + s_lzyyyy_MM_ddT))) - { - typeCode = DateTimeTypeCode.XdrDateTime; - return true; - } - } - if (Test(kinds, XsdDateTimeFlags.XdrDateTimeNoTz)) - { - if (ParseChar(start + s_lzyyyy_MM_dd, 'T')) - { - if (ParseTimeAndWhitespace(start + s_lzyyyy_MM_ddT)) - { - typeCode = DateTimeTypeCode.XdrDateTime; - return true; - } - } - else - { - typeCode = DateTimeTypeCode.XdrDateTime; - return true; - } - } - } - } - - if (Test(kinds, XsdDateTimeFlags.Time)) - { - if (ParseTimeAndZoneAndWhitespace(start)) - { //Equivalent to NoCurrentDateDefault on DateTimeStyles while parsing xs:time - year = leapYear; - month = firstMonth; - day = firstDay; - typeCode = DateTimeTypeCode.Time; - return true; - } - } - - if (Test(kinds, XsdDateTimeFlags.XdrTimeNoTz)) - { - if (ParseTimeAndWhitespace(start)) - { //Equivalent to NoCurrentDateDefault on DateTimeStyles while parsing xs:time - year = leapYear; - month = firstMonth; - day = firstDay; - typeCode = DateTimeTypeCode.Time; - return true; - } - } - - if (Test(kinds, XsdDateTimeFlags.GYearMonth | XsdDateTimeFlags.GYear)) - { - if (Parse4Dig(start, ref year) && 1 <= year) - { - if (Test(kinds, XsdDateTimeFlags.GYearMonth)) - { - if ( - ParseChar(start + s_lzyyyy, '-') && - Parse2Dig(start + s_lzyyyy_, ref month) && 1 <= month && month <= 12 && - ParseZoneAndWhitespace(start + s_lzyyyy_MM) - ) - { - day = firstDay; - typeCode = DateTimeTypeCode.GYearMonth; - return true; - } - } - if (Test(kinds, XsdDateTimeFlags.GYear)) - { - if (ParseZoneAndWhitespace(start + s_lzyyyy)) - { - month = firstMonth; - day = firstDay; - typeCode = DateTimeTypeCode.GYear; - return true; - } - } - } - } - if (Test(kinds, XsdDateTimeFlags.GMonthDay | XsdDateTimeFlags.GMonth)) - { - if ( - ParseChar(start, '-') && - ParseChar(start + s_Lz_, '-') && - Parse2Dig(start + s_Lz__, ref month) && 1 <= month && month <= 12 - ) - { - if (Test(kinds, XsdDateTimeFlags.GMonthDay) && ParseChar(start + s_lz__mm, '-')) - { - if ( - Parse2Dig(start + s_lz__mm_, ref day) && 1 <= day && day <= DateTime.DaysInMonth(leapYear, month) && - ParseZoneAndWhitespace(start + s_lz__mm_dd) - ) - { - year = leapYear; - typeCode = DateTimeTypeCode.GMonthDay; - return true; - } - } - if (Test(kinds, XsdDateTimeFlags.GMonth)) - { - if (ParseZoneAndWhitespace(start + s_lz__mm) || (ParseChar(start + s_lz__mm, '-') && ParseChar(start + s_lz__mm_, '-') && ParseZoneAndWhitespace(start + s_lz__mm__))) - { - year = leapYear; - day = firstDay; - typeCode = DateTimeTypeCode.GMonth; - return true; - } - } - } - } - if (Test(kinds, XsdDateTimeFlags.GDay)) - { - if ( - ParseChar(start, '-') && - ParseChar(start + s_Lz_, '-') && - ParseChar(start + s_Lz__, '-') && - Parse2Dig(start + s_Lz___, ref day) && 1 <= day && day <= DateTime.DaysInMonth(leapYear, firstMonth) && - ParseZoneAndWhitespace(start + s_lz___dd) - - ) - { - year = leapYear; - month = firstMonth; - typeCode = DateTimeTypeCode.GDay; - return true; - } - } - return false; - } - - - private bool ParseDate(int start) - { - return - Parse4Dig(start, ref year) && 1 <= year && - ParseChar(start + s_lzyyyy, '-') && - Parse2Dig(start + s_lzyyyy_, ref month) && 1 <= month && month <= 12 && - ParseChar(start + s_lzyyyy_MM, '-') && - Parse2Dig(start + s_lzyyyy_MM_, ref day) && 1 <= day && day <= DateTime.DaysInMonth(year, month); - } - - private bool ParseTimeAndZoneAndWhitespace(int start) - { - if (ParseTime(ref start)) - { - if (ParseZoneAndWhitespace(start)) - { - return true; - } - } - return false; - } - - private bool ParseTimeAndWhitespace(int start) - { - if (ParseTime(ref start)) - { - while (start < _length) - {//&& char.IsWhiteSpace(text[start])) { - start++; - } - return start == _length; - } - return false; - } - - private static int[] s_power10 = new int[maxFractionDigits] { -1, 10, 100, 1000, 10000, 100000, 1000000 }; - private bool ParseTime(ref int start) - { - if ( - Parse2Dig(start, ref hour) && hour < 24 && - ParseChar(start + s_lzHH, ':') && - Parse2Dig(start + s_lzHH_, ref minute) && minute < 60 && - ParseChar(start + s_lzHH_mm, ':') && - Parse2Dig(start + s_lzHH_mm_, ref second) && second < 60 - ) - { - start += s_lzHH_mm_ss; - if (ParseChar(start, '.')) - { - // Parse factional part of seconds - // We allow any number of digits, but keep only first 7 - this.fraction = 0; - int fractionDigits = 0; - int round = 0; - while (++start < _length) - { - int d = _text[start] - '0'; - if (9u < (uint)d) - { // d < 0 || 9 < d - break; - } - if (fractionDigits < maxFractionDigits) - { - this.fraction = (this.fraction * 10) + d; - } - else if (fractionDigits == maxFractionDigits) - { - if (5 < d) - { - round = 1; - } - else if (d == 5) - { - round = -1; - } - } - else if (round < 0 && d != 0) - { - round = 1; - } - fractionDigits++; - } - if (fractionDigits < maxFractionDigits) - { - if (fractionDigits == 0) - { - return false; // cannot end with . - } - fraction *= s_power10[maxFractionDigits - fractionDigits]; - } - else - { - if (round < 0) - { - round = fraction & 1; - } - fraction += round; - } - } - return true; - } - // cleanup - conflict with gYear - hour = 0; - return false; - } - - private bool ParseZoneAndWhitespace(int start) - { - if (start < _length) - { - char ch = _text[start]; - if (ch == 'Z' || ch == 'z') - { - kind = XsdDateTimeKind.Zulu; - start++; - } - else if (start + 5 < _length) - { - if ( - Parse2Dig(start + s_Lz_, ref zoneHour) && zoneHour <= 99 && - ParseChar(start + s_lz_zz, ':') && - Parse2Dig(start + s_lz_zz_, ref zoneMinute) && zoneMinute <= 99 - ) - { - if (ch == '-') - { - kind = XsdDateTimeKind.LocalWestOfZulu; - start += s_lz_zz_zz; - } - else if (ch == '+') - { - kind = XsdDateTimeKind.LocalEastOfZulu; - start += s_lz_zz_zz; - } - } - } - } - while (start < _length && char.IsWhiteSpace(_text[start])) - { - start++; - } - return start == _length; - } - - - private bool Parse4Dig(int start, ref int num) - { - if (start + 3 < _length) - { - int d4 = _text[start] - '0'; - int d3 = _text[start + 1] - '0'; - int d2 = _text[start + 2] - '0'; - int d1 = _text[start + 3] - '0'; - if (0 <= d4 && d4 < 10 && - 0 <= d3 && d3 < 10 && - 0 <= d2 && d2 < 10 && - 0 <= d1 && d1 < 10 - ) - { - num = ((d4 * 10 + d3) * 10 + d2) * 10 + d1; - return true; - } - } - return false; - } - - private bool Parse2Dig(int start, ref int num) - { - if (start + 1 < _length) - { - int d2 = _text[start] - '0'; - int d1 = _text[start + 1] - '0'; - if (0 <= d2 && d2 < 10 && - 0 <= d1 && d1 < 10 - ) - { - num = d2 * 10 + d1; - return true; - } - } - return false; - } - - private bool ParseChar(int start, char ch) - { - return start < _length && _text[start] == ch; - } - - private static bool Test(XsdDateTimeFlags left, XsdDateTimeFlags right) - { - return (left & right) != 0; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDuration.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDuration.cs deleted file mode 100644 index c27fd4f5fdb..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/XsdDuration.cs +++ /dev/null @@ -1,726 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Diagnostics; - using System.Text; - - /// - /// This structure holds components of an Xsd Duration. It is used internally to support Xsd durations without loss - /// of fidelity. XsdDuration structures are immutable once they've been created. - /// - internal struct XsdDuration - { - private int _years; - private int _months; - private int _days; - private int _hours; - private int _minutes; - private int _seconds; - private uint _nanoseconds; // High bit is used to indicate whether duration is negative - - private const uint NegativeBit = 0x80000000; - - private enum Parts - { - HasNone = 0, - HasYears = 1, - HasMonths = 2, - HasDays = 4, - HasHours = 8, - HasMinutes = 16, - HasSeconds = 32, - } - - public enum DurationType - { - Duration, - YearMonthDuration, - DayTimeDuration, - }; - - /// - /// Construct an XsdDuration from component parts. - /// - public XsdDuration(bool isNegative, int years, int months, int days, int hours, int minutes, int seconds, int nanoseconds) - { - if (years < 0) throw new ArgumentOutOfRangeException("years"); - if (months < 0) throw new ArgumentOutOfRangeException("months"); - if (days < 0) throw new ArgumentOutOfRangeException("days"); - if (hours < 0) throw new ArgumentOutOfRangeException("hours"); - if (minutes < 0) throw new ArgumentOutOfRangeException("minutes"); - if (seconds < 0) throw new ArgumentOutOfRangeException("seconds"); - if (nanoseconds < 0 || nanoseconds > 999999999) throw new ArgumentOutOfRangeException("nanoseconds"); - - _years = years; - _months = months; - _days = days; - _hours = hours; - _minutes = minutes; - _seconds = seconds; - _nanoseconds = (uint)nanoseconds; - - if (isNegative) - _nanoseconds |= NegativeBit; - } - - /// - /// Construct an XsdDuration from a TimeSpan value. - /// - public XsdDuration(TimeSpan timeSpan) : this(timeSpan, DurationType.Duration) - { - } - - /// - /// Construct an XsdDuration from a TimeSpan value that represents an xsd:duration, an xdt:dayTimeDuration, or - /// an xdt:yearMonthDuration. - /// - public XsdDuration(TimeSpan timeSpan, DurationType durationType) - { - long ticks = timeSpan.Ticks; - ulong ticksPos; - bool isNegative; - - if (ticks < 0) - { - // Note that (ulong) -Int64.MinValue = Int64.MaxValue + 1, which is what we want for that special case - isNegative = true; - ticksPos = (ulong)-ticks; - } - else - { - isNegative = false; - ticksPos = (ulong)ticks; - } - - if (durationType == DurationType.YearMonthDuration) - { - int years = (int)(ticksPos / ((ulong)TimeSpan.TicksPerDay * 365)); - int months = (int)((ticksPos % ((ulong)TimeSpan.TicksPerDay * 365)) / ((ulong)TimeSpan.TicksPerDay * 30)); - - if (months == 12) - { - // If remaining days >= 360 and < 365, then round off to year - years++; - months = 0; - } - - this = new XsdDuration(isNegative, years, months, 0, 0, 0, 0, 0); - } - else - { - Debug.Assert(durationType == DurationType.Duration || durationType == DurationType.DayTimeDuration); - - // Tick count is expressed in 100 nanosecond intervals - _nanoseconds = (uint)(ticksPos % 10000000) * 100; - if (isNegative) - _nanoseconds |= NegativeBit; - - _years = 0; - _months = 0; - _days = (int)(ticksPos / (ulong)TimeSpan.TicksPerDay); - _hours = (int)((ticksPos / (ulong)TimeSpan.TicksPerHour) % 24); - _minutes = (int)((ticksPos / (ulong)TimeSpan.TicksPerMinute) % 60); - _seconds = (int)((ticksPos / (ulong)TimeSpan.TicksPerSecond) % 60); - } - } - - /// - /// Constructs an XsdDuration from a string in the xsd:duration format. Components are stored with loss - /// of fidelity (except in the case of overflow). - /// - public XsdDuration(string s) : this(s, DurationType.Duration) - { - } - - /// - /// Constructs an XsdDuration from a string in the xsd:duration format. Components are stored without loss - /// of fidelity (except in the case of overflow). - /// - public XsdDuration(string s, DurationType durationType) - { - XsdDuration result; - Exception exception = TryParse(s, durationType, out result); - if (exception != null) - { - throw exception; - } - _years = result.Years; - _months = result.Months; - _days = result.Days; - _hours = result.Hours; - _minutes = result.Minutes; - _seconds = result.Seconds; - _nanoseconds = (uint)result.Nanoseconds; - if (result.IsNegative) - { - _nanoseconds |= NegativeBit; - } - return; - } - - /// - /// Return true if this duration is negative. - /// - public bool IsNegative - { - get { return (_nanoseconds & NegativeBit) != 0; } - } - - /// - /// Return number of years in this duration (stored in 31 bits). - /// - public int Years - { - get { return _years; } - } - - /// - /// Return number of months in this duration (stored in 31 bits). - /// - public int Months - { - get { return _months; } - } - - /// - /// Return number of days in this duration (stored in 31 bits). - /// - public int Days - { - get { return _days; } - } - - /// - /// Return number of hours in this duration (stored in 31 bits). - /// - public int Hours - { - get { return _hours; } - } - - /// - /// Return number of minutes in this duration (stored in 31 bits). - /// - public int Minutes - { - get { return _minutes; } - } - - /// - /// Return number of seconds in this duration (stored in 31 bits). - /// - public int Seconds - { - get { return _seconds; } - } - - /// - /// Return number of nanoseconds in this duration. - /// - public int Nanoseconds - { - get { return (int)(_nanoseconds & ~NegativeBit); } - } - - /// - /// Return number of microseconds in this duration. - /// - public int Microseconds - { - get { return Nanoseconds / 1000; } - } - - /// - /// Return number of milliseconds in this duration. - /// - public int Milliseconds - { - get { return Nanoseconds / 1000000; } - } - - /// - /// Normalize year-month part and day-time part so that month < 12, hour < 24, minute < 60, and second < 60. - /// - public XsdDuration Normalize() - { - int years = Years; - int months = Months; - int days = Days; - int hours = Hours; - int minutes = Minutes; - int seconds = Seconds; - - try - { - checked - { - if (months >= 12) - { - years += months / 12; - months %= 12; - } - - if (seconds >= 60) - { - minutes += seconds / 60; - seconds %= 60; - } - - if (minutes >= 60) - { - hours += minutes / 60; - minutes %= 60; - } - - if (hours >= 24) - { - days += hours / 24; - hours %= 24; - } - } - } - catch (OverflowException) - { - throw new OverflowException(string.Format(ResXml.XmlConvert_Overflow, ToString(), "Duration")); - } - - return new XsdDuration(IsNegative, years, months, days, hours, minutes, seconds, Nanoseconds); - } - - /// - /// Internal helper method that converts an Xsd duration to a TimeSpan value. This code uses the estimate - /// that there are 365 days in the year and 30 days in a month. - /// - public TimeSpan ToTimeSpan() - { - return ToTimeSpan(DurationType.Duration); - } - - /// - /// Internal helper method that converts an Xsd duration to a TimeSpan value. This code uses the estimate - /// that there are 365 days in the year and 30 days in a month. - /// - public TimeSpan ToTimeSpan(DurationType durationType) - { - TimeSpan result; - Exception exception = TryToTimeSpan(durationType, out result); - if (exception != null) - { - throw exception; - } - return result; - } - - internal Exception TryToTimeSpan(out TimeSpan result) - { - return TryToTimeSpan(DurationType.Duration, out result); - } - - internal Exception TryToTimeSpan(DurationType durationType, out TimeSpan result) - { - Exception exception = null; - ulong ticks = 0; - - // Throw error if result cannot fit into a long - try - { - checked - { - // Discard year and month parts if constructing TimeSpan for DayTimeDuration - if (durationType != DurationType.DayTimeDuration) - { - ticks += ((ulong)_years + (ulong)_months / 12) * 365; - ticks += ((ulong)_months % 12) * 30; - } - - // Discard day and time parts if constructing TimeSpan for YearMonthDuration - if (durationType != DurationType.YearMonthDuration) - { - ticks += (ulong)_days; - - ticks *= 24; - ticks += (ulong)_hours; - - ticks *= 60; - ticks += (ulong)_minutes; - - ticks *= 60; - ticks += (ulong)_seconds; - - // Tick count interval is in 100 nanosecond intervals (7 digits) - ticks *= (ulong)TimeSpan.TicksPerSecond; - ticks += (ulong)Nanoseconds / 100; - } - else - { - // Multiply YearMonth duration by number of ticks per day - ticks *= (ulong)TimeSpan.TicksPerDay; - } - - if (IsNegative) - { - // Handle special case of Int64.MaxValue + 1 before negation, since it would otherwise overflow - if (ticks == (ulong)Int64.MaxValue + 1) - { - result = new TimeSpan(Int64.MinValue); - } - else - { - result = new TimeSpan(-((long)ticks)); - } - } - else - { - result = new TimeSpan((long)ticks); - } - return null; - } - } - catch (OverflowException) - { - result = TimeSpan.MinValue; - exception = new OverflowException(string.Format(ResXml.XmlConvert_Overflow, durationType, "TimeSpan")); - } - return exception; - } - - /// - /// Return the string representation of this Xsd duration. - /// - public override string ToString() - { - return ToString(DurationType.Duration); - } - - /// - /// Return the string representation according to xsd:duration rules, xdt:dayTimeDuration rules, or - /// xdt:yearMonthDuration rules. - /// - internal string ToString(DurationType durationType) - { - StringBuilder sb = new StringBuilder(20); - int nanoseconds, digit, zeroIdx, len; - - if (IsNegative) - sb.Append('-'); - - sb.Append('P'); - - if (durationType != DurationType.DayTimeDuration) - { - if (_years != 0) - { - sb.Append(XmlConvert.ToString(_years)); - sb.Append('Y'); - } - - if (_months != 0) - { - sb.Append(XmlConvert.ToString(_months)); - sb.Append('M'); - } - } - - if (durationType != DurationType.YearMonthDuration) - { - if (_days != 0) - { - sb.Append(XmlConvert.ToString(_days)); - sb.Append('D'); - } - - if (_hours != 0 || _minutes != 0 || _seconds != 0 || Nanoseconds != 0) - { - sb.Append('T'); - if (_hours != 0) - { - sb.Append(XmlConvert.ToString(_hours)); - sb.Append('H'); - } - - if (_minutes != 0) - { - sb.Append(XmlConvert.ToString(_minutes)); - sb.Append('M'); - } - - nanoseconds = Nanoseconds; - if (_seconds != 0 || nanoseconds != 0) - { - sb.Append(XmlConvert.ToString(_seconds)); - if (nanoseconds != 0) - { - sb.Append('.'); - - len = sb.Length; - sb.Length += 9; - zeroIdx = sb.Length - 1; - - for (int idx = zeroIdx; idx >= len; idx--) - { - digit = nanoseconds % 10; - sb[idx] = (char)(digit + '0'); - - if (zeroIdx == idx && digit == 0) - zeroIdx--; - - nanoseconds /= 10; - } - - sb.Length = zeroIdx + 1; - } - sb.Append('S'); - } - } - - // Zero is represented as "PT0S" - if (sb[sb.Length - 1] == 'P') - sb.Append("T0S"); - } - else - { - // Zero is represented as "T0M" - if (sb[sb.Length - 1] == 'P') - sb.Append("0M"); - } - - return sb.ToString(); - } - - internal static Exception TryParse(string s, out XsdDuration result) - { - return TryParse(s, DurationType.Duration, out result); - } - - internal static Exception TryParse(string s, DurationType durationType, out XsdDuration result) - { - string errorCode; - int length; - int value, pos, numDigits; - Parts parts = Parts.HasNone; - - result = new XsdDuration(); - - s = s.Trim(); - length = s.Length; - - pos = 0; - numDigits = 0; - - if (pos >= length) goto InvalidFormat; - - if (s[pos] == '-') - { - pos++; - result._nanoseconds = NegativeBit; - } - else - { - result._nanoseconds = 0; - } - - if (pos >= length) goto InvalidFormat; - - if (s[pos++] != 'P') goto InvalidFormat; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - - if (s[pos] == 'Y') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasYears; - result._years = value; - if (++pos == length) goto Done; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - } - - if (s[pos] == 'M') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasMonths; - result._months = value; - if (++pos == length) goto Done; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - } - - if (s[pos] == 'D') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasDays; - result._days = value; - if (++pos == length) goto Done; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - } - - if (s[pos] == 'T') - { - if (numDigits != 0) goto InvalidFormat; - - pos++; - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - - if (s[pos] == 'H') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasHours; - result._hours = value; - if (++pos == length) goto Done; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - } - - if (s[pos] == 'M') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasMinutes; - result._minutes = value; - if (++pos == length) goto Done; - - errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits); - if (errorCode != null) goto Error; - - if (pos >= length) goto InvalidFormat; - } - - if (s[pos] == '.') - { - pos++; - - parts |= Parts.HasSeconds; - result._seconds = value; - - errorCode = TryParseDigits(s, ref pos, true, out value, out numDigits); - if (errorCode != null) goto Error; - - if (numDigits == 0) - { //If there are no digits after the decimal point, assume 0 - value = 0; - } - // Normalize to nanosecond intervals - for (; numDigits > 9; numDigits--) - value /= 10; - - for (; numDigits < 9; numDigits++) - value *= 10; - - result._nanoseconds |= (uint)value; - - if (pos >= length) goto InvalidFormat; - - if (s[pos] != 'S') goto InvalidFormat; - if (++pos == length) goto Done; - } - else if (s[pos] == 'S') - { - if (numDigits == 0) goto InvalidFormat; - - parts |= Parts.HasSeconds; - result._seconds = value; - if (++pos == length) goto Done; - } - } - - // Duration cannot end with digits - if (numDigits != 0) goto InvalidFormat; - - // No further characters are allowed - if (pos != length) goto InvalidFormat; - - Done: - // At least one part must be defined - if (parts == Parts.HasNone) goto InvalidFormat; - - if (durationType == DurationType.DayTimeDuration) - { - if ((parts & (Parts.HasYears | Parts.HasMonths)) != 0) - goto InvalidFormat; - } - else if (durationType == DurationType.YearMonthDuration) - { - if ((parts & ~(XsdDuration.Parts.HasYears | XsdDuration.Parts.HasMonths)) != 0) - goto InvalidFormat; - } - return null; - - InvalidFormat: - return new FormatException(string.Format(ResXml.XmlConvert_BadFormat, s, durationType)); - - Error: - return new OverflowException(string.Format(ResXml.XmlConvert_Overflow, s, durationType)); - } - - /// Helper method that constructs an integer from leading digits starting at s[offset]. "offset" is - /// updated to contain an offset just beyond the last digit. The number of digits consumed is returned in - /// cntDigits. The integer is returned (0 if no digits). If the digits cannot fit into an Int32: - /// 1. If eatDigits is true, then additional digits will be silently discarded (don't count towards numDigits) - /// 2. If eatDigits is false, an overflow exception is thrown - private static string TryParseDigits(string s, ref int offset, bool eatDigits, out int result, out int numDigits) - { - int offsetStart = offset; - int offsetEnd = s.Length; - int digit; - - result = 0; - numDigits = 0; - - while (offset < offsetEnd && s[offset] >= '0' && s[offset] <= '9') - { - digit = s[offset] - '0'; - - if (result > (Int32.MaxValue - digit) / 10) - { - if (!eatDigits) - { - return ResXml.XmlConvert_Overflow; - } - - // Skip past any remaining digits - numDigits = offset - offsetStart; - - while (offset < offsetEnd && s[offset] >= '0' && s[offset] <= '9') - { - offset++; - } - - return null; - } - - result = result * 10 + digit; - offset++; - } - - numDigits = offset - offsetStart; - return null; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/autovalidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/autovalidator.cs deleted file mode 100644 index 8a4b70314ee..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/autovalidator.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Diagnostics; - using System.Globalization; - -#pragma warning disable 618 - - internal class AutoValidator : BaseValidator - { - private const string x_schema = "x-schema"; - - public AutoValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling) : base(reader, schemaCollection, eventHandling) - { - schemaInfo = new SchemaInfo(); - } - - public override bool PreserveWhitespace - { - get { return false; } - } - - public override void Validate() - { - ValidationType valType = DetectValidationType(); - switch (valType) - { - case ValidationType.XDR: - reader.Validator = new XdrValidator(this); - reader.Validator.Validate(); - break; - - case ValidationType.Schema: - reader.Validator = new XsdValidator(this); - reader.Validator.Validate(); - break; - - case ValidationType.Auto: - break; - } - } - - public override void CompleteValidation() { } - - public override object FindId(string name) - { - return null; - } - - private ValidationType DetectValidationType() - { - //Type not yet detected : Check in Schema Collection - if (reader.Schemas != null && reader.Schemas.Count > 0) - { - XmlSchemaCollectionEnumerator enumerator = reader.Schemas.GetEnumerator(); - while (enumerator.MoveNext()) - { - XmlSchemaCollectionNode node = enumerator.CurrentNode; - SchemaInfo schemaInfo = node.SchemaInfo; - if (schemaInfo.SchemaType == SchemaType.XSD) - return ValidationType.Schema; - else if (schemaInfo.SchemaType == SchemaType.XDR) - return ValidationType.XDR; - } - } - - if (reader.NodeType == XmlNodeType.Element) - { - SchemaType schemaType = SchemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI); - if (schemaType == SchemaType.XSD) - { - return ValidationType.Schema; - } - else if (schemaType == SchemaType.XDR) - { - return ValidationType.XDR; - } - else - { - int count = reader.AttributeCount; - for (int i = 0; i < count; i++) - { - reader.MoveToAttribute(i); - string objectNs = reader.NamespaceURI; - string objectName = reader.LocalName; - if (Ref.Equal(objectNs, SchemaNames.NsXmlNs)) - { - if (XdrBuilder.IsXdrSchema(reader.Value)) - { - reader.MoveToElement(); - return ValidationType.XDR; - } - } - else if (Ref.Equal(objectNs, SchemaNames.NsXsi)) - { - reader.MoveToElement(); - return ValidationType.Schema; - } - else if (Ref.Equal(objectNs, SchemaNames.QnDtDt.Namespace) && Ref.Equal(objectName, SchemaNames.QnDtDt.Name)) - { - reader.SchemaTypeObject = XmlSchemaDatatype.FromXdrName(reader.Value); - reader.MoveToElement(); - return ValidationType.XDR; - } - } //end of for - if (count > 0) - { - reader.MoveToElement(); - } - } - } - return ValidationType.Auto; - } - } -#pragma warning restore 618 -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/basevalidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/basevalidator.cs deleted file mode 100644 index 62708ca7392..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/basevalidator.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.IO; - using System.Diagnostics; - using System.Text; - using System.Collections; - -#pragma warning disable 618 - - internal class BaseValidator - { - private XmlSchemaCollection _schemaCollection; - private IValidationEventHandling _eventHandling; - private XmlNameTable _nameTable; - private SchemaNames _schemaNames; - private PositionInfo _positionInfo; - private XmlResolver _xmlResolver; - private Uri _baseUri; - - protected SchemaInfo schemaInfo; - protected XmlValidatingReaderImpl reader; - protected XmlQualifiedName elementName; - protected ValidationState context; - protected StringBuilder textValue; - protected string textString; - protected bool hasSibling; - protected bool checkDatatype; - - public BaseValidator(BaseValidator other) - { - reader = other.reader; - _schemaCollection = other._schemaCollection; - _eventHandling = other._eventHandling; - _nameTable = other._nameTable; - _schemaNames = other._schemaNames; - _positionInfo = other._positionInfo; - _xmlResolver = other._xmlResolver; - _baseUri = other._baseUri; - elementName = other.elementName; - } - - public BaseValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling) - { - Debug.Assert(schemaCollection == null || schemaCollection.NameTable == reader.NameTable); - this.reader = reader; - _schemaCollection = schemaCollection; - _eventHandling = eventHandling; - _nameTable = reader.NameTable; - _positionInfo = PositionInfo.GetPositionInfo(reader); - elementName = new XmlQualifiedName(); - } - - public XmlValidatingReaderImpl Reader - { - get { return reader; } - } - - public XmlSchemaCollection SchemaCollection - { - get { return _schemaCollection; } - } - - public XmlNameTable NameTable - { - get { return _nameTable; } - } - - public SchemaNames SchemaNames - { - get - { - if (_schemaNames != null) - { - return _schemaNames; - } - if (_schemaCollection != null) - { - _schemaNames = _schemaCollection.GetSchemaNames(_nameTable); - } - else - { - _schemaNames = new SchemaNames(_nameTable); - } - return _schemaNames; - } - } - - public PositionInfo PositionInfo - { - get { return _positionInfo; } - } - - public XmlResolver XmlResolver - { - get { return _xmlResolver; } - set { _xmlResolver = value; } - } - - public Uri BaseUri - { - get { return _baseUri; } - set { _baseUri = value; } - } - - public ValidationEventHandler EventHandler - { - get { return (ValidationEventHandler)_eventHandling.EventHandler; } - } - - public SchemaInfo SchemaInfo - { - get - { - return schemaInfo; - } - set - { - schemaInfo = value; - } - } - - public IDtdInfo DtdInfo - { - get - { - return schemaInfo; - } - set - { - SchemaInfo tmpSchemaInfo = value as SchemaInfo; - if (tmpSchemaInfo == null) - { - throw new XmlException(ResXml.Xml_InternalError, string.Empty); - } - this.schemaInfo = tmpSchemaInfo; - } - } - - public virtual bool PreserveWhitespace - { - get - { - return false; - } - } - - public virtual void Validate() - { - } - - public virtual void CompleteValidation() - { - } - - public virtual object FindId(string name) - { - return null; - } - - public void ValidateText() - { - if (context.NeedValidateChildren) - { - if (context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - return; - } - ContentValidator contentValidator = context.ElementDecl.ContentValidator; - XmlSchemaContentType contentType = contentValidator.ContentType; - if (contentType == XmlSchemaContentType.ElementOnly) - { - ArrayList names = contentValidator.ExpectedElements(context, false); - if (names == null) - { - SendValidationEvent(ResXml.Sch_InvalidTextInElement, XmlSchemaValidator.BuildElementName(context.LocalName, context.Namespace)); - } - else - { - Debug.Assert(names.Count > 0); - SendValidationEvent(ResXml.Sch_InvalidTextInElementExpecting, new string[] { XmlSchemaValidator.BuildElementName(context.LocalName, context.Namespace), XmlSchemaValidator.PrintExpectedElements(names, false) }); - } - } - else if (contentType == XmlSchemaContentType.Empty) - { - SendValidationEvent(ResXml.Sch_InvalidTextInEmpty, string.Empty); - } - if (checkDatatype) - { - SaveTextValue(reader.Value); - } - } - } - - public void ValidateWhitespace() - { - if (context.NeedValidateChildren) - { - XmlSchemaContentType contentType = context.ElementDecl.ContentValidator.ContentType; - if (context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - if (contentType == XmlSchemaContentType.Empty) - { - SendValidationEvent(ResXml.Sch_InvalidWhitespaceInEmpty, string.Empty); - } - if (checkDatatype) - { - SaveTextValue(reader.Value); - } - } - } - - private void SaveTextValue(string value) - { - if (textString.Length == 0) - { - textString = value; - } - else - { - if (!hasSibling) - { - textValue.Append(textString); - hasSibling = true; - } - textValue.Append(value); - } - } - - protected void SendValidationEvent(string code) - { - SendValidationEvent(code, string.Empty); - } - - protected void SendValidationEvent(string code, string[] args) - { - SendValidationEvent(new XmlSchemaException(code, args, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - protected void SendValidationEvent(string code, string arg) - { - SendValidationEvent(new XmlSchemaException(code, arg, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - protected void SendValidationEvent(string code, string arg1, string arg2) - { - SendValidationEvent(new XmlSchemaException(code, new string[] { arg1, arg2 }, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition)); - } - - protected void SendValidationEvent(XmlSchemaException e) - { - SendValidationEvent(e, XmlSeverityType.Error); - } - - protected void SendValidationEvent(string code, string msg, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, msg, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - - protected void SendValidationEvent(string code, string[] args, XmlSeverityType severity) - { - SendValidationEvent(new XmlSchemaException(code, args, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition), severity); - } - - protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) - { - if (_eventHandling != null) - { - _eventHandling.SendEvent(e, severity); - } - else if (severity == XmlSeverityType.Error) - { - throw e; - } - } - - protected static void ProcessEntity(SchemaInfo sinfo, string name, object sender, ValidationEventHandler eventhandler, string baseUri, int lineNumber, int linePosition) - { - SchemaEntity en; - XmlSchemaException e = null; - if (!sinfo.GeneralEntities.TryGetValue(new XmlQualifiedName(name), out en)) - { - // validation error, see xml spec [68] - e = new XmlSchemaException(ResXml.Sch_UndeclaredEntity, name, baseUri, lineNumber, linePosition); - } - else if (en.NData.IsEmpty) - { - e = new XmlSchemaException(ResXml.Sch_UnparsedEntityRef, name, baseUri, lineNumber, linePosition); - } - if (e != null) - { - if (eventhandler != null) - { - eventhandler(sender, new ValidationEventArgs(e)); - } - else - { - throw e; - } - } - } - - protected static void ProcessEntity(SchemaInfo sinfo, string name, IValidationEventHandling eventHandling, string baseUriStr, int lineNumber, int linePosition) - { - SchemaEntity en; - string errorResId = null; - if (!sinfo.GeneralEntities.TryGetValue(new XmlQualifiedName(name), out en)) - { - // validation error, see xml spec [68] - errorResId = ResXml.Sch_UndeclaredEntity; - } - else if (en.NData.IsEmpty) - { - errorResId = ResXml.Sch_UnparsedEntityRef; - } - if (errorResId != null) - { - XmlSchemaException e = new XmlSchemaException(errorResId, name, baseUriStr, lineNumber, linePosition); - - if (eventHandling != null) - { - eventHandling.SendEvent(e, XmlSeverityType.Error); - } - else - { - throw e; - } - } - } - - public static BaseValidator CreateInstance(ValidationType valType, XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling, bool processIdentityConstraints) - { - switch (valType) - { - case ValidationType.XDR: - return new XdrValidator(reader, schemaCollection, eventHandling); - - case ValidationType.Schema: - return new XsdValidator(reader, schemaCollection, eventHandling); - - case ValidationType.DTD: - return new DtdValidator(reader, eventHandling, processIdentityConstraints); - - case ValidationType.Auto: - return new AutoValidator(reader, schemaCollection, eventHandling); - - case ValidationType.None: - return new BaseValidator(reader, schemaCollection, eventHandling); - - default: - break; - } - return null; - } - } -#pragma warning restore 618 -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/dtdvalidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/dtdvalidator.cs deleted file mode 100644 index 96a9162a7e7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/dtdvalidator.cs +++ /dev/null @@ -1,629 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Text; - using System.IO; - using System.Net; - using System.Diagnostics; - using Microsoft.Xml; - using Microsoft.Xml.XPath; - -#pragma warning disable 618 - - internal sealed class DtdValidator : BaseValidator - { - //required by ParseValue - private class NamespaceManager : XmlNamespaceManager - { - public override string LookupNamespace(string prefix) { return prefix; } - } - - private static NamespaceManager s_namespaceManager = new NamespaceManager(); - private const int STACK_INCREMENT = 10; - private HWStack _validationStack; // validaton contexts - private Hashtable _attPresence; - private XmlQualifiedName _name = XmlQualifiedName.Empty; - private Hashtable _IDs; - private IdRefNode _idRefListHead; - private bool _processIdentityConstraints; - - internal DtdValidator(XmlValidatingReaderImpl reader, IValidationEventHandling eventHandling, bool processIdentityConstraints) : base(reader, null, eventHandling) - { - _processIdentityConstraints = processIdentityConstraints; - Init(); - } - - private void Init() - { - Debug.Assert(reader != null); - _validationStack = new HWStack(STACK_INCREMENT); - textValue = new StringBuilder(); - _name = XmlQualifiedName.Empty; - _attPresence = new Hashtable(); - schemaInfo = new SchemaInfo(); - checkDatatype = false; - Push(_name); - } - - public override void Validate() - { - if (schemaInfo.SchemaType == SchemaType.DTD) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - ValidateElement(); - if (reader.IsEmptyElement) - { - goto case XmlNodeType.EndElement; - } - break; - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - if (MeetsStandAloneConstraint()) - { - ValidateWhitespace(); - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - ValidatePIComment(); - break; - - case XmlNodeType.Text: // text inside a node - case XmlNodeType.CDATA: // - ValidateText(); - break; - case XmlNodeType.EntityReference: - if (!GenEntity(new XmlQualifiedName(reader.LocalName, reader.Prefix))) - { - ValidateText(); - } - break; - case XmlNodeType.EndElement: - ValidateEndElement(); - break; - } - } - else - { - if (reader.Depth == 0 && - reader.NodeType == XmlNodeType.Element) - { - SendValidationEvent(ResXml.Xml_NoDTDPresent, _name.ToString(), XmlSeverityType.Warning); - } - } - } - - private bool MeetsStandAloneConstraint() - { - if (reader.StandAlone && // VC 1 - iv - context.ElementDecl != null && - context.ElementDecl.IsDeclaredInExternal && - context.ElementDecl.ContentValidator.ContentType == XmlSchemaContentType.ElementOnly) - { - SendValidationEvent(ResXml.Sch_StandAlone); - return false; - } - return true; - } - - private void ValidatePIComment() - { - // When validating with a dtd, empty elements should be lexically empty. - if (context.NeedValidateChildren) - { - if (context.ElementDecl.ContentValidator == ContentValidator.Empty) - { - SendValidationEvent(ResXml.Sch_InvalidPIComment); - } - } - } - - private void ValidateElement() - { - elementName.Init(reader.LocalName, reader.Prefix); - if ((reader.Depth == 0) && - (!schemaInfo.DocTypeName.IsEmpty) && - (!schemaInfo.DocTypeName.Equals(elementName))) - { //VC 1 - SendValidationEvent(ResXml.Sch_RootMatchDocType); - } - else - { - ValidateChildElement(); - } - ProcessElement(); - } - - private void ValidateChildElement() - { - Debug.Assert(reader.NodeType == XmlNodeType.Element); - if (context.NeedValidateChildren) - { //i think i can get away with removing this if cond since won't make this call for documentelement - int errorCode = 0; - context.ElementDecl.ContentValidator.ValidateElement(elementName, context, out errorCode); - if (errorCode < 0) - { - XmlSchemaValidator.ElementValidationError(elementName, context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - } - - private void ValidateStartElement() - { - if (context.ElementDecl != null) - { - Reader.SchemaTypeObject = context.ElementDecl.SchemaType; - - if (Reader.IsEmptyElement && context.ElementDecl.DefaultValueTyped != null) - { - Reader.TypedValueObject = context.ElementDecl.DefaultValueTyped; - context.IsNill = true; // reusing IsNill - what is this flag later used for?? - } - if (context.ElementDecl.HasRequiredAttribute) - { - _attPresence.Clear(); - } - } - - if (Reader.MoveToFirstAttribute()) - { - do - { - try - { - reader.SchemaTypeObject = null; - SchemaAttDef attnDef = context.ElementDecl.GetAttDef(new XmlQualifiedName(reader.LocalName, reader.Prefix)); - if (attnDef != null) - { - if (context.ElementDecl != null && context.ElementDecl.HasRequiredAttribute) - { - _attPresence.Add(attnDef.Name, attnDef); - } - Reader.SchemaTypeObject = attnDef.SchemaType; - - if (attnDef.Datatype != null && !reader.IsDefault) - { //Since XmlTextReader adds default attributes, do not check again - // set typed value - CheckValue(Reader.Value, attnDef); - } - } - else - { - SendValidationEvent(ResXml.Sch_UndeclaredAttribute, reader.Name); - } - } - catch (XmlSchemaException e) - { - e.SetSource(Reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } while (Reader.MoveToNextAttribute()); - Reader.MoveToElement(); - } - } - - private void ValidateEndStartElement() - { - if (context.ElementDecl.HasRequiredAttribute) - { - try - { - context.ElementDecl.CheckAttributes(_attPresence, Reader.StandAlone); - } - catch (XmlSchemaException e) - { - e.SetSource(Reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } - - if (context.ElementDecl.Datatype != null) - { - checkDatatype = true; - hasSibling = false; - textString = string.Empty; - textValue.Length = 0; - } - } - - private void ProcessElement() - { - SchemaElementDecl elementDecl = schemaInfo.GetElementDecl(elementName); - Push(elementName); - if (elementDecl != null) - { - context.ElementDecl = elementDecl; - ValidateStartElement(); - ValidateEndStartElement(); - context.NeedValidateChildren = true; - elementDecl.ContentValidator.InitValidation(context); - } - else - { - SendValidationEvent(ResXml.Sch_UndeclaredElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - context.ElementDecl = null; - } - } - - public override void CompleteValidation() - { - if (schemaInfo.SchemaType == SchemaType.DTD) - { - do - { - ValidateEndElement(); - } while (Pop()); - CheckForwardRefs(); - } - } - - private void ValidateEndElement() - { - if (context.ElementDecl != null) - { - if (context.NeedValidateChildren) - { - if (!context.ElementDecl.ContentValidator.CompleteValidation(context)) - { - XmlSchemaValidator.CompleteValidationError(context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - - if (checkDatatype) - { - string stringValue = !hasSibling ? textString : textValue.ToString(); // only for identity-constraint exception reporting - CheckValue(stringValue, null); - checkDatatype = false; - textValue.Length = 0; // cleanup - textString = string.Empty; - } - } - Pop(); - } - - public override bool PreserveWhitespace - { - get { return context.ElementDecl != null ? context.ElementDecl.ContentValidator.PreserveWhitespace : false; } - } - - - private void ProcessTokenizedType( - XmlTokenizedType ttype, - string name - ) - { - switch (ttype) - { - case XmlTokenizedType.ID: - if (_processIdentityConstraints) - { - if (FindId(name) != null) - { - SendValidationEvent(ResXml.Sch_DupId, name); - } - else - { - AddID(name, context.LocalName); - } - } - break; - case XmlTokenizedType.IDREF: - if (_processIdentityConstraints) - { - object p = FindId(name); - if (p == null) - { // add it to linked list to check it later - _idRefListHead = new IdRefNode(_idRefListHead, name, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); - } - } - - break; - case XmlTokenizedType.ENTITY: - ProcessEntity(schemaInfo, name, this, EventHandler, Reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - break; - default: - break; - } - } - - //check the contents of this attribute to ensure it is valid according to the specified attribute type. - private void CheckValue(string value, SchemaAttDef attdef) - { - try - { - reader.TypedValueObject = null; - bool isAttn = attdef != null; - XmlSchemaDatatype dtype = isAttn ? attdef.Datatype : context.ElementDecl.Datatype; - if (dtype == null) - { - return; // no reason to check - } - - if (dtype.TokenizedType != XmlTokenizedType.CDATA) - { - value = value.Trim(); - } - - object typedValue = dtype.ParseValue(value, NameTable, s_namespaceManager); - reader.TypedValueObject = typedValue; - // Check special types - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessTokenizedType(dtype.TokenizedType, ss[i]); - } - } - else - { - ProcessTokenizedType(dtype.TokenizedType, (string)typedValue); - } - } - - SchemaDeclBase decl = isAttn ? (SchemaDeclBase)attdef : (SchemaDeclBase)context.ElementDecl; - if (decl.Values != null && !decl.CheckEnumeration(typedValue)) - { - if (dtype.TokenizedType == XmlTokenizedType.NOTATION) - { - SendValidationEvent(ResXml.Sch_NotationValue, typedValue.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_EnumerationValue, typedValue.ToString()); - } - } - if (!decl.CheckValue(typedValue)) - { - if (isAttn) - { - SendValidationEvent(ResXml.Sch_FixedAttributeValue, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_FixedElementValue, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - } - catch (XmlSchemaException) - { - if (attdef != null) - { - SendValidationEvent(ResXml.Sch_AttributeValueDataType, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_ElementValueDataType, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - } - - - internal void AddID(string name, object node) - { - // Note: It used to be true that we only called this if _fValidate was true, - // but due to the fact that you can now dynamically type somethign as an ID - // that is no longer true. - if (_IDs == null) - { - _IDs = new Hashtable(); - } - - _IDs.Add(name, node); - } - - public override object FindId(string name) - { - return _IDs == null ? null : _IDs[name]; - } - - private bool GenEntity(XmlQualifiedName qname) - { - string n = qname.Name; - if (n[0] == '#') - { // char entity reference - return false; - } - else if (SchemaEntity.IsPredefinedEntity(n)) - { - return false; - } - else - { - SchemaEntity en = GetEntity(qname, false); - if (en == null) - { - // well-formness error, see xml spec [68] - throw new XmlException(ResXml.Xml_UndeclaredEntity, n); - } - if (!en.NData.IsEmpty) - { - // well-formness error, see xml spec [68] - throw new XmlException(ResXml.Xml_UnparsedEntityRef, n); - } - - if (reader.StandAlone && en.DeclaredInExternal) - { - SendValidationEvent(ResXml.Sch_StandAlone); - } - return true; - } - } - - - private SchemaEntity GetEntity(XmlQualifiedName qname, bool fParameterEntity) - { - SchemaEntity entity; - if (fParameterEntity) - { - if (schemaInfo.ParameterEntities.TryGetValue(qname, out entity)) - { - return entity; - } - } - else - { - if (schemaInfo.GeneralEntities.TryGetValue(qname, out entity)) - { - return entity; - } - } - return null; - } - - private void CheckForwardRefs() - { - IdRefNode next = _idRefListHead; - while (next != null) - { - if (FindId(next.Id) == null) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_UndeclaredId, next.Id, reader.BaseURI, next.LineNo, next.LinePos)); - } - IdRefNode ptr = next.Next; - next.Next = null; // unhook each object so it is cleaned up by Garbage Collector - next = ptr; - } - // not needed any more. - _idRefListHead = null; - } - - private void Push(XmlQualifiedName elementName) - { - context = (ValidationState)_validationStack.Push(); - if (context == null) - { - context = new ValidationState(); - _validationStack.AddToTop(context); - } - context.LocalName = elementName.Name; - context.Namespace = elementName.Namespace; - context.HasMatched = false; - context.IsNill = false; - context.NeedValidateChildren = false; - } - - private bool Pop() - { - if (_validationStack.Length > 1) - { - _validationStack.Pop(); - context = (ValidationState)_validationStack.Peek(); - return true; - } - return false; - } - - public static void SetDefaultTypedValue( - SchemaAttDef attdef, - IDtdParserAdapter readerAdapter - ) - { - try - { - string value = attdef.DefaultValueExpanded; - XmlSchemaDatatype dtype = attdef.Datatype; - if (dtype == null) - { - return; // no reason to check - } - if (dtype.TokenizedType != XmlTokenizedType.CDATA) - { - value = value.Trim(); - } - attdef.DefaultValueTyped = dtype.ParseValue(value, readerAdapter.NameTable, readerAdapter.NamespaceResolver); - } -#if DEBUG && disabled - catch (XmlSchemaException ex) { - Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); -#else - catch (Exception) - { -#endif - IValidationEventHandling eventHandling = ((IDtdParserAdapterWithValidation)readerAdapter).ValidationEventHandling; - if (eventHandling != null) - { - XmlSchemaException e = new XmlSchemaException(ResXml.Sch_AttributeDefaultDataType, attdef.Name.ToString()); - eventHandling.SendEvent(e, XmlSeverityType.Error); - } - } - } - - public static void CheckDefaultValue( - SchemaAttDef attdef, - SchemaInfo sinfo, - IValidationEventHandling eventHandling, - string baseUriStr - ) - { - try - { - if (baseUriStr == null) - { - baseUriStr = string.Empty; - } - XmlSchemaDatatype dtype = attdef.Datatype; - if (dtype == null) - { - return; // no reason to check - } - object typedValue = attdef.DefaultValueTyped; - - // Check special types - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessEntity(sinfo, ss[i], eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); - } - } - else - { - ProcessEntity(sinfo, (string)typedValue, eventHandling, baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); - } - } - else if (ttype == XmlTokenizedType.ENUMERATION) - { - if (!attdef.CheckEnumeration(typedValue)) - { - if (eventHandling != null) - { - XmlSchemaException e = new XmlSchemaException(ResXml.Sch_EnumerationValue, typedValue.ToString(), baseUriStr, attdef.ValueLineNumber, attdef.ValueLinePosition); - eventHandling.SendEvent(e, XmlSeverityType.Error); - } - } - } - } -#if DEBUG && disabled - catch (XmlSchemaException ex) { - Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); -#else - catch (Exception) - { -#endif - - if (eventHandling != null) - { - XmlSchemaException e = new XmlSchemaException(ResXml.Sch_AttributeDefaultDataType, attdef.Name.ToString()); - eventHandling.SendEvent(e, XmlSeverityType.Error); - } - } - } - } -#pragma warning restore 618 -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/validationstate.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/validationstate.cs deleted file mode 100644 index 5fd7210b51d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/validationstate.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Runtime.InteropServices; - - [StructLayout(LayoutKind.Explicit)] - internal struct StateUnion - { - [FieldOffset(0)] public int State; //DFA - [FieldOffset(0)] public int AllElementsRequired; //AllContentValidator - [FieldOffset(0)] public int CurPosIndex; //NFAContentValidator - [FieldOffset(0)] public int NumberOfRunningPos; //RangeContentValidator - } - - internal sealed class ValidationState - { - public bool IsNill; - public bool IsDefault; - public bool NeedValidateChildren; // whether need to validate the children of this element - public bool CheckRequiredAttribute; //PSVI - public bool ValidationSkipped; - //public int Depth; // The validation state - public XmlSchemaContentProcessing ProcessContents; - public XmlSchemaValidity Validity; - public SchemaElementDecl ElementDecl; // ElementDecl - public SchemaElementDecl ElementDeclBeforeXsi; //elementDecl before its changed by that of xsi:type's - public string LocalName; - public string Namespace; - public ConstraintStruct[] Constr; - - public StateUnion CurrentState; - - //For content model validation - public bool HasMatched; // whether the element has been verified correctly - - //For NFAs - public BitSet[] CurPos = new BitSet[2]; - - //For all - public BitSet AllElementsSet; - - //For MinMaxNFA - public List RunningPositions; - public bool TooComplex; - }; -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xdrvalidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xdrvalidator.cs deleted file mode 100644 index 9c2e4826eb8..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xdrvalidator.cs +++ /dev/null @@ -1,702 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.IO; - using System.Text; - using System.Collections; - using System.Diagnostics; - using System.Globalization; - using System.Runtime.Versioning; - -#pragma warning disable 618 - internal sealed class XdrValidator : BaseValidator - { - private const int STACK_INCREMENT = 10; - private HWStack _validationStack; // validaton contexts - private Hashtable _attPresence; - private XmlQualifiedName _name = XmlQualifiedName.Empty; - private XmlNamespaceManager _nsManager; - private bool _isProcessContents = false; - private Hashtable _IDs; - private IdRefNode _idRefListHead; - private Parser _inlineSchemaParser = null; - private const string x_schema = "x-schema:"; - - internal XdrValidator(BaseValidator validator) : base(validator) - { - Init(); - } - - internal XdrValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling) : base(reader, schemaCollection, eventHandling) - { - Init(); - } - - private void Init() - { - _nsManager = reader.NamespaceManager; - if (_nsManager == null) - { - _nsManager = new XmlNamespaceManager(NameTable); - _isProcessContents = true; - } - _validationStack = new HWStack(STACK_INCREMENT); - textValue = new StringBuilder(); - _name = XmlQualifiedName.Empty; - _attPresence = new Hashtable(); - Push(XmlQualifiedName.Empty); - schemaInfo = new SchemaInfo(); - checkDatatype = false; - } - - public override void Validate() - { - if (IsInlineSchemaStarted) - { - ProcessInlineSchema(); - } - else - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - ValidateElement(); - if (reader.IsEmptyElement) - { - goto case XmlNodeType.EndElement; - } - break; - case XmlNodeType.Whitespace: - ValidateWhitespace(); - break; - case XmlNodeType.Text: // text inside a node - case XmlNodeType.CDATA: // - case XmlNodeType.SignificantWhitespace: - ValidateText(); - break; - case XmlNodeType.EndElement: - ValidateEndElement(); - break; - } - } - } - - private void ValidateElement() - { - elementName.Init(reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(reader.NamespaceURI, NameTable, SchemaNames)); - ValidateChildElement(); - if (SchemaNames.IsXDRRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) - { - _inlineSchemaParser = new Parser(SchemaType.XDR, NameTable, SchemaNames, EventHandler); - _inlineSchemaParser.StartParsing(reader, null); - _inlineSchemaParser.ParseReaderNode(); - } - else - { - ProcessElement(); - } - } - - private void ValidateChildElement() - { - if (context.NeedValidateChildren) - { - int errorCode = 0; - context.ElementDecl.ContentValidator.ValidateElement(elementName, context, out errorCode); - if (errorCode < 0) - { - XmlSchemaValidator.ElementValidationError(elementName, context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - } - - private bool IsInlineSchemaStarted - { - get { return _inlineSchemaParser != null; } - } - - private void ProcessInlineSchema() - { - if (!_inlineSchemaParser.ParseReaderNode()) - { // Done - _inlineSchemaParser.FinishParsing(); - SchemaInfo xdrSchema = _inlineSchemaParser.XdrSchema; - if (xdrSchema != null && xdrSchema.ErrorCount == 0) - { - foreach (string inlineNS in xdrSchema.TargetNamespaces.Keys) - { - if (!this.schemaInfo.HasSchema(inlineNS)) - { - schemaInfo.Add(xdrSchema, EventHandler); - SchemaCollection.Add(inlineNS, xdrSchema, null, false); - break; - } - } - } - _inlineSchemaParser = null; - } - } - - private void ProcessElement() - { - Push(elementName); - if (_isProcessContents) - { - _nsManager.PopScope(); - } - context.ElementDecl = ThoroughGetElementDecl(); - if (context.ElementDecl != null) - { - ValidateStartElement(); - ValidateEndStartElement(); - context.NeedValidateChildren = true; - context.ElementDecl.ContentValidator.InitValidation(context); - } - } - - private void ValidateEndElement() - { - if (_isProcessContents) - { - _nsManager.PopScope(); - } - if (context.ElementDecl != null) - { - if (context.NeedValidateChildren) - { - if (!context.ElementDecl.ContentValidator.CompleteValidation(context)) - { - XmlSchemaValidator.CompleteValidationError(context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - if (checkDatatype) - { - string stringValue = !hasSibling ? textString : textValue.ToString(); // only for identity-constraint exception reporting - CheckValue(stringValue, null); - checkDatatype = false; - textValue.Length = 0; // cleanup - textString = string.Empty; - } - } - Pop(); - } - - // SxS: This method processes resource names read from the source document and does not expose - // any resources to the caller. It is fine to disable the SxS warning. - - - private SchemaElementDecl ThoroughGetElementDecl() - { - if (reader.Depth == 0) - { - LoadSchema(string.Empty); - } - if (reader.MoveToFirstAttribute()) - { - do - { - string objectNs = reader.NamespaceURI; - string objectName = reader.LocalName; - if (Ref.Equal(objectNs, SchemaNames.NsXmlNs)) - { - LoadSchema(reader.Value); - if (_isProcessContents) - { - _nsManager.AddNamespace(reader.Prefix.Length == 0 ? string.Empty : reader.LocalName, reader.Value); - } - } - if ( - Ref.Equal(objectNs, SchemaNames.QnDtDt.Namespace) && - Ref.Equal(objectName, SchemaNames.QnDtDt.Name) - ) - { - reader.SchemaTypeObject = XmlSchemaDatatype.FromXdrName(reader.Value); - } - } while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - SchemaElementDecl elementDecl = schemaInfo.GetElementDecl(elementName); - if (elementDecl == null) - { - if (schemaInfo.TargetNamespaces.ContainsKey(context.Namespace)) - { - SendValidationEvent(ResXml.Sch_UndeclaredElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - return elementDecl; - } - - private void ValidateStartElement() - { - if (context.ElementDecl != null) - { - if (context.ElementDecl.SchemaType != null) - { - reader.SchemaTypeObject = context.ElementDecl.SchemaType; - } - else - { - reader.SchemaTypeObject = context.ElementDecl.Datatype; - } - if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null) - { - reader.TypedValueObject = context.ElementDecl.DefaultValueTyped; - context.IsNill = true; // reusing IsNill - } - if (this.context.ElementDecl.HasRequiredAttribute) - { - _attPresence.Clear(); - } - } - - if (reader.MoveToFirstAttribute()) - { - do - { - if ((object)reader.NamespaceURI == (object)SchemaNames.NsXmlNs) - { - continue; - } - - try - { - reader.SchemaTypeObject = null; - SchemaAttDef attnDef = schemaInfo.GetAttributeXdr(context.ElementDecl, QualifiedName(reader.LocalName, reader.NamespaceURI)); - if (attnDef != null) - { - if (context.ElementDecl != null && context.ElementDecl.HasRequiredAttribute) - { - _attPresence.Add(attnDef.Name, attnDef); - } - reader.SchemaTypeObject = (attnDef.SchemaType != null) ? (object)attnDef.SchemaType : (object)attnDef.Datatype; - if (attnDef.Datatype != null) - { - string attributeValue = reader.Value; - // need to check the contents of this attribute to make sure - // it is valid according to the specified attribute type. - CheckValue(attributeValue, attnDef); - } - } - } - catch (XmlSchemaException e) - { - e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - } - - private void ValidateEndStartElement() - { - if (context.ElementDecl.HasDefaultAttribute) - { - for (int i = 0; i < context.ElementDecl.DefaultAttDefs.Count; ++i) - { - reader.AddDefaultAttribute((SchemaAttDef)context.ElementDecl.DefaultAttDefs[i]); - } - } - if (context.ElementDecl.HasRequiredAttribute) - { - try - { - context.ElementDecl.CheckAttributes(_attPresence, reader.StandAlone); - } - catch (XmlSchemaException e) - { - e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } - if (context.ElementDecl.Datatype != null) - { - checkDatatype = true; - hasSibling = false; - textString = string.Empty; - textValue.Length = 0; - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void LoadSchemaFromLocation(string uri) - { - // is x-schema - if (!XdrBuilder.IsXdrSchema(uri)) - { - return; - } - string url = uri.Substring(x_schema.Length); - XmlReader reader = null; - SchemaInfo xdrSchema = null; - try - { - Uri ruri = this.XmlResolver.ResolveUri(BaseUri, url); - Stream stm = (Stream)this.XmlResolver.GetEntity(ruri, null, null); - reader = new XmlTextReader(ruri.ToString(), stm, NameTable); - ((XmlTextReader)reader).XmlResolver = this.XmlResolver; - Parser parser = new Parser(SchemaType.XDR, NameTable, SchemaNames, EventHandler); - parser.XmlResolver = this.XmlResolver; - parser.Parse(reader, uri); - while (reader.Read()) ;// wellformness check - xdrSchema = parser.XdrSchema; - } - catch (XmlSchemaException e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, XmlSeverityType.Error); - } - catch (Exception e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, XmlSeverityType.Warning); - } - finally - { - if (reader != null) - { - reader.Close(); - } - } - if (xdrSchema != null && xdrSchema.ErrorCount == 0) - { - schemaInfo.Add(xdrSchema, EventHandler); - SchemaCollection.Add(uri, xdrSchema, null, false); - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void LoadSchema(string uri) - { - if (this.schemaInfo.TargetNamespaces.ContainsKey(uri)) - { - return; - } - if (this.XmlResolver == null) - { - return; - } - - SchemaInfo schemaInfo = null; - if (SchemaCollection != null) - schemaInfo = SchemaCollection.GetSchemaInfo(uri); - if (schemaInfo != null) - { - if (schemaInfo.SchemaType != SchemaType.XDR) - { - throw new XmlException(ResXml.Xml_MultipleValidaitonTypes, string.Empty, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); - } - this.schemaInfo.Add(schemaInfo, EventHandler); - return; - } - LoadSchemaFromLocation(uri); - } - - private bool HasSchema { get { return schemaInfo.SchemaType != SchemaType.None; } } - - public override bool PreserveWhitespace - { - get { return context.ElementDecl != null ? context.ElementDecl.ContentValidator.PreserveWhitespace : false; } - } - - private void ProcessTokenizedType( - XmlTokenizedType ttype, - string name - ) - { - switch (ttype) - { - case XmlTokenizedType.ID: - if (FindId(name) != null) - { - SendValidationEvent(ResXml.Sch_DupId, name); - } - else - { - AddID(name, context.LocalName); - } - break; - case XmlTokenizedType.IDREF: - object p = FindId(name); - if (p == null) - { // add it to linked list to check it later - _idRefListHead = new IdRefNode(_idRefListHead, name, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); - } - break; - case XmlTokenizedType.ENTITY: - ProcessEntity(schemaInfo, name, this, EventHandler, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - break; - default: - break; - } - } - - - public override void CompleteValidation() - { - if (HasSchema) - { - CheckForwardRefs(); - } - else - { - SendValidationEvent(new XmlSchemaException(ResXml.Xml_NoValidation, string.Empty), XmlSeverityType.Warning); - } - } - - - private void CheckValue( - string value, - SchemaAttDef attdef - ) - { - try - { - reader.TypedValueObject = null; - bool isAttn = attdef != null; - XmlSchemaDatatype dtype = isAttn ? attdef.Datatype : context.ElementDecl.Datatype; - if (dtype == null) - { - return; // no reason to check - } - - if (dtype.TokenizedType != XmlTokenizedType.CDATA) - { - value = value.Trim(); - } - if (value.Length == 0) - { - return; // don't need to check - } - - - object typedValue = dtype.ParseValue(value, NameTable, _nsManager); - reader.TypedValueObject = typedValue; - // Check special types - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessTokenizedType(dtype.TokenizedType, ss[i]); - } - } - else - { - ProcessTokenizedType(dtype.TokenizedType, (string)typedValue); - } - } - - SchemaDeclBase decl = isAttn ? (SchemaDeclBase)attdef : (SchemaDeclBase)context.ElementDecl; - - if (decl.MaxLength != uint.MaxValue) - { - if (value.Length > decl.MaxLength) - { - SendValidationEvent(ResXml.Sch_MaxLengthConstraintFailed, value); - } - } - if (decl.MinLength != uint.MaxValue) - { - if (value.Length < decl.MinLength) - { - SendValidationEvent(ResXml.Sch_MinLengthConstraintFailed, value); - } - } - if (decl.Values != null && !decl.CheckEnumeration(typedValue)) - { - if (dtype.TokenizedType == XmlTokenizedType.NOTATION) - { - SendValidationEvent(ResXml.Sch_NotationValue, typedValue.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_EnumerationValue, typedValue.ToString()); - } - } - if (!decl.CheckValue(typedValue)) - { - if (isAttn) - { - SendValidationEvent(ResXml.Sch_FixedAttributeValue, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_FixedElementValue, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - } - catch (XmlSchemaException) - { - if (attdef != null) - { - SendValidationEvent(ResXml.Sch_AttributeValueDataType, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_ElementValueDataType, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - } - - public static void CheckDefaultValue( - string value, - SchemaAttDef attdef, - SchemaInfo sinfo, - XmlNamespaceManager nsManager, - XmlNameTable NameTable, - object sender, - ValidationEventHandler eventhandler, - string baseUri, - int lineNo, - int linePos - ) - { - try - { - XmlSchemaDatatype dtype = attdef.Datatype; - if (dtype == null) - { - return; // no reason to check - } - - if (dtype.TokenizedType != XmlTokenizedType.CDATA) - { - value = value.Trim(); - } - if (value.Length == 0) - { - return; // don't need to check - } - object typedValue = dtype.ParseValue(value, NameTable, nsManager); - - // Check special types - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessEntity(sinfo, ss[i], sender, eventhandler, baseUri, lineNo, linePos); - } - } - else - { - ProcessEntity(sinfo, (string)typedValue, sender, eventhandler, baseUri, lineNo, linePos); - } - } - else if (ttype == XmlTokenizedType.ENUMERATION) - { - if (!attdef.CheckEnumeration(typedValue)) - { - XmlSchemaException e = new XmlSchemaException(ResXml.Sch_EnumerationValue, typedValue.ToString(), baseUri, lineNo, linePos); - if (eventhandler != null) - { - eventhandler(sender, new ValidationEventArgs(e)); - } - else - { - throw e; - } - } - } - attdef.DefaultValueTyped = typedValue; - } -#if DEBUG && disabled - catch (XmlSchemaException ex) { - Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message); -#else - catch - { -#endif - XmlSchemaException e = new XmlSchemaException(ResXml.Sch_AttributeDefaultDataType, attdef.Name.ToString(), baseUri, lineNo, linePos); - if (eventhandler != null) - { - eventhandler(sender, new ValidationEventArgs(e)); - } - else - { - throw e; - } - } - } - - internal void AddID(string name, object node) - { - // Note: It used to be true that we only called this if _fValidate was true, - // but due to the fact that you can now dynamically type somethign as an ID - // that is no longer true. - if (_IDs == null) - { - _IDs = new Hashtable(); - } - - _IDs.Add(name, node); - } - - public override object FindId(string name) - { - return _IDs == null ? null : _IDs[name]; - } - - private void Push(XmlQualifiedName elementName) - { - context = (ValidationState)_validationStack.Push(); - if (context == null) - { - context = new ValidationState(); - _validationStack.AddToTop(context); - } - context.LocalName = elementName.Name; - context.Namespace = elementName.Namespace; - context.HasMatched = false; - context.IsNill = false; - context.NeedValidateChildren = false; - } - - private void Pop() - { - if (_validationStack.Length > 1) - { - _validationStack.Pop(); - context = (ValidationState)_validationStack.Peek(); - } - } - - private void CheckForwardRefs() - { - IdRefNode next = _idRefListHead; - while (next != null) - { - if (FindId(next.Id) == null) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_UndeclaredId, next.Id, reader.BaseURI, next.LineNo, next.LinePos)); - } - IdRefNode ptr = next.Next; - next.Next = null; // unhook each object so it is cleaned up by Garbage Collector - next = ptr; - } - // not needed any more. - _idRefListHead = null; - } - - private XmlQualifiedName QualifiedName(string name, string ns) - { - return new XmlQualifiedName(name, XmlSchemaDatatype.XdrCanonizeUri(ns, NameTable, SchemaNames)); - } - }; -#pragma warning restore 618 -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xsdvalidator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xsdvalidator.cs deleted file mode 100644 index 102aba7e795..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/schema/xsdvalidator.cs +++ /dev/null @@ -1,1170 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml.Schema -{ - using System; - using Microsoft.Xml; - - - using System.Collections; - using System.Collections.Specialized; - using System.Text; - using System.IO; - using System.Diagnostics; - using Microsoft.Xml.Schema; - using Microsoft.Xml.XPath; - using System.Runtime.Versioning; - -#pragma warning disable 618 - internal sealed class XsdValidator : BaseValidator - { - private int _startIDConstraint = -1; - private const int STACK_INCREMENT = 10; - private HWStack _validationStack; // validaton contexts - - private Hashtable _attPresence; - private XmlNamespaceManager _nsManager; - private bool _bManageNamespaces = false; - private Hashtable _IDs; - private IdRefNode _idRefListHead; - private Parser _inlineSchemaParser = null; - private XmlSchemaContentProcessing _processContents; - - private static readonly XmlSchemaDatatype s_dtCDATA = XmlSchemaDatatype.FromXmlTokenizedType(XmlTokenizedType.CDATA); - private static readonly XmlSchemaDatatype s_dtQName = XmlSchemaDatatype.FromXmlTokenizedTypeXsd(XmlTokenizedType.QName); - private static readonly XmlSchemaDatatype s_dtStringArray = s_dtCDATA.DeriveByList(null); - - //To avoid SchemaNames creation - private string _nsXmlNs; - private string _nsXs; - private string _nsXsi; - private string _xsiType; - private string _xsiNil; - private string _xsiSchemaLocation; - private string _xsiNoNamespaceSchemaLocation; - private string _xsdSchema; - - - internal XsdValidator(BaseValidator validator) : base(validator) - { - Init(); - } - - internal XsdValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling) : base(reader, schemaCollection, eventHandling) - { - Init(); - } - - private void Init() - { - _nsManager = reader.NamespaceManager; - if (_nsManager == null) - { - _nsManager = new XmlNamespaceManager(NameTable); - _bManageNamespaces = true; - } - _validationStack = new HWStack(STACK_INCREMENT); - textValue = new StringBuilder(); - _attPresence = new Hashtable(); - schemaInfo = new SchemaInfo(); - checkDatatype = false; - _processContents = XmlSchemaContentProcessing.Strict; - Push(XmlQualifiedName.Empty); - - //Add common strings to be compared to NameTable - _nsXmlNs = NameTable.Add(XmlReservedNs.NsXmlNs); - _nsXs = NameTable.Add(XmlReservedNs.NsXs); - _nsXsi = NameTable.Add(XmlReservedNs.NsXsi); - _xsiType = NameTable.Add("type"); - _xsiNil = NameTable.Add("nil"); - _xsiSchemaLocation = NameTable.Add("schemaLocation"); - _xsiNoNamespaceSchemaLocation = NameTable.Add("noNamespaceSchemaLocation"); - _xsdSchema = NameTable.Add("schema"); - } - - public override void Validate() - { - if (IsInlineSchemaStarted) - { - ProcessInlineSchema(); - } - else - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - ValidateElement(); - if (reader.IsEmptyElement) - { - goto case XmlNodeType.EndElement; - } - break; - case XmlNodeType.Whitespace: - ValidateWhitespace(); - break; - case XmlNodeType.Text: // text inside a node - case XmlNodeType.CDATA: // - case XmlNodeType.SignificantWhitespace: - ValidateText(); - break; - case XmlNodeType.EndElement: - ValidateEndElement(); - break; - } - } - } - - - public override void CompleteValidation() - { - CheckForwardRefs(); - } - - //for frag validation - public ValidationState Context - { - set { context = value; } - } - - //share for frag validation - public static XmlSchemaDatatype DtQName - { - get { return s_dtQName; } - } - - private bool IsInlineSchemaStarted - { - get { return _inlineSchemaParser != null; } - } - - private void ProcessInlineSchema() - { - if (!_inlineSchemaParser.ParseReaderNode()) - { // Done - _inlineSchemaParser.FinishParsing(); - XmlSchema schema = _inlineSchemaParser.XmlSchema; - string inlineNS = null; - if (schema != null && schema.ErrorCount == 0) - { - try - { - SchemaInfo inlineSchemaInfo = new SchemaInfo(); - inlineSchemaInfo.SchemaType = SchemaType.XSD; - inlineNS = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; - if (!SchemaInfo.TargetNamespaces.ContainsKey(inlineNS)) - { - if (SchemaCollection.Add(inlineNS, inlineSchemaInfo, schema, true) != null) - { //If no errors on compile - //Add to validator's SchemaInfo - SchemaInfo.Add(inlineSchemaInfo, EventHandler); - } - } - } - catch (XmlSchemaException e) - { - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { BaseUri.AbsoluteUri, e.Message }, XmlSeverityType.Error); - } - } - _inlineSchemaParser = null; - } - } - - private void ValidateElement() - { - elementName.Init(reader.LocalName, reader.NamespaceURI); - object particle = ValidateChildElement(); - if (IsXSDRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) - { - _inlineSchemaParser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); - _inlineSchemaParser.StartParsing(reader, null); - ProcessInlineSchema(); - } - else - { - ProcessElement(particle); - } - } - - private object ValidateChildElement() - { - object particle = null; - int errorCode = 0; - if (context.NeedValidateChildren) - { - if (context.IsNill) - { - SendValidationEvent(ResXml.Sch_ContentInNill, elementName.ToString()); - return null; - } - particle = context.ElementDecl.ContentValidator.ValidateElement(elementName, context, out errorCode); - if (particle == null) - { - _processContents = context.ProcessContents = XmlSchemaContentProcessing.Skip; - if (errorCode == -2) - { //ContentModel all group error - SendValidationEvent(ResXml.Sch_AllElement, elementName.ToString()); - } - XmlSchemaValidator.ElementValidationError(elementName, context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - return particle; - } - - private void ProcessElement(object particle) - { - XmlQualifiedName xsiType; - string xsiNil; - SchemaElementDecl elementDecl = FastGetElementDecl(particle); - Push(elementName); - if (_bManageNamespaces) - { - _nsManager.PushScope(); - } - ProcessXsiAttributes(out xsiType, out xsiNil); - if (_processContents != XmlSchemaContentProcessing.Skip) - { - if (elementDecl == null || !xsiType.IsEmpty || xsiNil != null) - { - elementDecl = ThoroughGetElementDecl(elementDecl, xsiType, xsiNil); - } - if (elementDecl == null) - { - if (HasSchema && _processContents == XmlSchemaContentProcessing.Strict) - { - SendValidationEvent(ResXml.Sch_UndeclaredElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - else - { - SendValidationEvent(ResXml.Sch_NoElementSchemaFound, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace), XmlSeverityType.Warning); - } - } - } - - context.ElementDecl = elementDecl; - ValidateStartElementIdentityConstraints(); - ValidateStartElement(); - if (context.ElementDecl != null) - { - ValidateEndStartElement(); - context.NeedValidateChildren = _processContents != XmlSchemaContentProcessing.Skip; - context.ElementDecl.ContentValidator.InitValidation(context); - } - } - - // SxS: This method processes attributes read from source document and does not expose any resources. - // It's OK to disable the SxS warning. - - - private void ProcessXsiAttributes(out XmlQualifiedName xsiType, out string xsiNil) - { - string[] xsiSchemaLocation = null; - string xsiNoNamespaceSchemaLocation = null; - xsiType = XmlQualifiedName.Empty; - xsiNil = null; - - if (reader.Depth == 0) - { - //Load schema for empty namespace - LoadSchema(string.Empty, null); - - //Should load schemas for namespaces already added to nsManager - foreach (string ns in _nsManager.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml).Values) - { - LoadSchema(ns, null); - } - } - - if (reader.MoveToFirstAttribute()) - { - do - { - string objectNs = reader.NamespaceURI; - string objectName = reader.LocalName; - if (Ref.Equal(objectNs, _nsXmlNs)) - { - LoadSchema(reader.Value, null); - if (_bManageNamespaces) - { - _nsManager.AddNamespace(reader.Prefix.Length == 0 ? string.Empty : reader.LocalName, reader.Value); - } - } - else if (Ref.Equal(objectNs, _nsXsi)) - { - if (Ref.Equal(objectName, _xsiSchemaLocation)) - { - xsiSchemaLocation = (string[])s_dtStringArray.ParseValue(reader.Value, NameTable, _nsManager); - } - else if (Ref.Equal(objectName, _xsiNoNamespaceSchemaLocation)) - { - xsiNoNamespaceSchemaLocation = reader.Value; - } - else if (Ref.Equal(objectName, _xsiType)) - { - xsiType = (XmlQualifiedName)s_dtQName.ParseValue(reader.Value, NameTable, _nsManager); - } - else if (Ref.Equal(objectName, _xsiNil)) - { - xsiNil = reader.Value; - } - } - } while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - if (xsiNoNamespaceSchemaLocation != null) - { - LoadSchema(string.Empty, xsiNoNamespaceSchemaLocation); - } - if (xsiSchemaLocation != null) - { - for (int i = 0; i < xsiSchemaLocation.Length - 1; i += 2) - { - LoadSchema((string)xsiSchemaLocation[i], (string)xsiSchemaLocation[i + 1]); - } - } - } - - private void ValidateEndElement() - { - if (_bManageNamespaces) - { - _nsManager.PopScope(); - } - if (context.ElementDecl != null) - { - if (!context.IsNill) - { - if (context.NeedValidateChildren) - { - if (!context.ElementDecl.ContentValidator.CompleteValidation(context)) - { - XmlSchemaValidator.CompleteValidationError(context, EventHandler, reader, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition, null); - } - } - - if (checkDatatype && !context.IsNill) - { - string stringValue = !hasSibling ? textString : textValue.ToString(); // only for identity-constraint exception reporting - if (!(stringValue.Length == 0 && context.ElementDecl.DefaultValueTyped != null)) - { - CheckValue(stringValue, null); - checkDatatype = false; - } - } - } - - // for each level in the stack, endchildren and fill value from element - if (HasIdentityConstraints) - { - EndElementIdentityConstraints(); - } - } - Pop(); - } - - private SchemaElementDecl FastGetElementDecl(object particle) - { - SchemaElementDecl elementDecl = null; - if (particle != null) - { - XmlSchemaElement element = particle as XmlSchemaElement; - if (element != null) - { - elementDecl = element.ElementDecl; - } - else - { - XmlSchemaAny any = (XmlSchemaAny)particle; - _processContents = any.ProcessContentsCorrect; - } - } - return elementDecl; - } - - private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil) - { - if (elementDecl == null) - { - elementDecl = schemaInfo.GetElementDecl(elementName); - } - if (elementDecl != null) - { - if (xsiType.IsEmpty) - { - if (elementDecl.IsAbstract) - { - SendValidationEvent(ResXml.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - elementDecl = null; - } - } - else if (xsiNil != null && xsiNil.Equals("true")) - { - SendValidationEvent(ResXml.Sch_XsiNilAndType); - } - else - { - SchemaElementDecl elementDeclXsi; - if (!schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out elementDeclXsi) && xsiType.Namespace == _nsXs) - { - XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, _nsXs)); - if (simpleType != null) - { - elementDeclXsi = simpleType.ElementDecl; - } - } - if (elementDeclXsi == null) - { - SendValidationEvent(ResXml.Sch_XsiTypeNotFound, xsiType.ToString()); - elementDecl = null; - } - else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block)) - { - SendValidationEvent(ResXml.Sch_XsiTypeBlockedEx, new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(context.LocalName, context.Namespace) }); - elementDecl = null; - } - else - { - elementDecl = elementDeclXsi; - } - } - if (elementDecl != null && elementDecl.IsNillable) - { - if (xsiNil != null) - { - context.IsNill = XmlConvert.ToBoolean(xsiNil); - if (context.IsNill && elementDecl.DefaultValueTyped != null) - { - SendValidationEvent(ResXml.Sch_XsiNilAndFixed); - } - } - } - else if (xsiNil != null) - { - SendValidationEvent(ResXml.Sch_InvalidXsiNill); - } - } - return elementDecl; - } - - private void ValidateStartElement() - { - if (context.ElementDecl != null) - { - if (context.ElementDecl.IsAbstract) - { - SendValidationEvent(ResXml.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - - reader.SchemaTypeObject = context.ElementDecl.SchemaType; - - if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null) - { - reader.TypedValueObject = UnWrapUnion(context.ElementDecl.DefaultValueTyped); - context.IsNill = true; // reusing IsNill - } - else - { - reader.TypedValueObject = null; //Typed value cleanup - } - if (this.context.ElementDecl.HasRequiredAttribute || HasIdentityConstraints) - { - _attPresence.Clear(); - } - } - - if (reader.MoveToFirstAttribute()) - { - do - { - if ((object)reader.NamespaceURI == (object)_nsXmlNs) - { - continue; - } - if ((object)reader.NamespaceURI == (object)_nsXsi) - { - continue; - } - - try - { - reader.SchemaTypeObject = null; - XmlQualifiedName attQName = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI); - bool skipContents = (_processContents == XmlSchemaContentProcessing.Skip); - SchemaAttDef attnDef = schemaInfo.GetAttributeXsd(context.ElementDecl, attQName, ref skipContents); - - if (attnDef != null) - { - if (context.ElementDecl != null && (context.ElementDecl.HasRequiredAttribute || _startIDConstraint != -1)) - { - _attPresence.Add(attnDef.Name, attnDef); - } - Debug.Assert(attnDef.SchemaType != null); - reader.SchemaTypeObject = attnDef.SchemaType; - if (attnDef.Datatype != null) - { - // need to check the contents of this attribute to make sure - // it is valid according to the specified attribute type. - CheckValue(reader.Value, attnDef); - } - if (HasIdentityConstraints) - { - AttributeIdentityConstraints(reader.LocalName, reader.NamespaceURI, reader.TypedValueObject, reader.Value, attnDef); - } - } - else if (!skipContents) - { - if (context.ElementDecl == null - && _processContents == XmlSchemaContentProcessing.Strict - && attQName.Namespace.Length != 0 - && schemaInfo.Contains(attQName.Namespace) - ) - { - SendValidationEvent(ResXml.Sch_UndeclaredAttribute, attQName.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning); - } - } - } - catch (XmlSchemaException e) - { - e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - } - - private void ValidateEndStartElement() - { - if (context.ElementDecl.HasDefaultAttribute) - { - for (int i = 0; i < context.ElementDecl.DefaultAttDefs.Count; ++i) - { - SchemaAttDef attdef = (SchemaAttDef)context.ElementDecl.DefaultAttDefs[i]; - reader.AddDefaultAttribute(attdef); - // even default attribute i have to move to... but can't exist - if (HasIdentityConstraints && !_attPresence.Contains(attdef.Name)) - { - AttributeIdentityConstraints(attdef.Name.Name, attdef.Name.Namespace, UnWrapUnion(attdef.DefaultValueTyped), attdef.DefaultValueRaw, attdef); - } - } - } - - if (context.ElementDecl.HasRequiredAttribute) - { - try - { - context.ElementDecl.CheckAttributes(_attPresence, reader.StandAlone); - } - catch (XmlSchemaException e) - { - e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - SendValidationEvent(e); - } - } - if (context.ElementDecl.Datatype != null) - { - checkDatatype = true; - hasSibling = false; - textString = string.Empty; - textValue.Length = 0; - } - } - - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void LoadSchemaFromLocation(string uri, string url) - { - XmlReader reader = null; - SchemaInfo schemaInfo = null; - - try - { - Uri ruri = this.XmlResolver.ResolveUri(BaseUri, url); - Stream stm = (Stream)this.XmlResolver.GetEntity(ruri, null, null); - reader = new XmlTextReader(ruri.ToString(), stm, NameTable); - //XmlSchema schema = SchemaCollection.Add(uri, reader, this.XmlResolver); - - Parser parser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); - parser.XmlResolver = this.XmlResolver; - SchemaType schemaType = parser.Parse(reader, uri); - - schemaInfo = new SchemaInfo(); - schemaInfo.SchemaType = schemaType; - if (schemaType == SchemaType.XSD) - { - if (SchemaCollection.EventHandler == null) - { - SchemaCollection.EventHandler = this.EventHandler; - } - SchemaCollection.Add(uri, schemaInfo, parser.XmlSchema, true); - } - //Add to validator's SchemaInfo - SchemaInfo.Add(schemaInfo, EventHandler); - - while (reader.Read()) ;// wellformness check - } - catch (XmlSchemaException e) - { - schemaInfo = null; - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, XmlSeverityType.Error); - } - catch (Exception e) - { - schemaInfo = null; - SendValidationEvent(ResXml.Sch_CannotLoadSchema, new string[] { uri, e.Message }, XmlSeverityType.Warning); - } - finally - { - if (reader != null) - { - reader.Close(); - } - } - } - - // [ResourceConsumption(ResourceScope.Machine)] - // [ResourceExposure(ResourceScope.Machine)] - private void LoadSchema(string uri, string url) - { - if (this.XmlResolver == null) - { - return; - } - if (SchemaInfo.TargetNamespaces.ContainsKey(uri) && _nsManager.LookupPrefix(uri) != null) - { - return; - } - - SchemaInfo schemaInfo = null; - if (SchemaCollection != null) - schemaInfo = SchemaCollection.GetSchemaInfo(uri); - if (schemaInfo != null) - { - if (schemaInfo.SchemaType != SchemaType.XSD) - { - throw new XmlException(ResXml.Xml_MultipleValidaitonTypes, string.Empty, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); - } - SchemaInfo.Add(schemaInfo, EventHandler); - return; - } - if (url != null) - { - LoadSchemaFromLocation(uri, url); - } - } - - private bool HasSchema { get { return schemaInfo.SchemaType != SchemaType.None; } } - - public override bool PreserveWhitespace - { - get { return context.ElementDecl != null ? context.ElementDecl.ContentValidator.PreserveWhitespace : false; } - } - - - private void ProcessTokenizedType( - XmlTokenizedType ttype, - string name - ) - { - switch (ttype) - { - case XmlTokenizedType.ID: - if (FindId(name) != null) - { - SendValidationEvent(ResXml.Sch_DupId, name); - } - else - { - AddID(name, context.LocalName); - } - break; - case XmlTokenizedType.IDREF: - object p = FindId(name); - if (p == null) - { // add it to linked list to check it later - _idRefListHead = new IdRefNode(_idRefListHead, name, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition); - } - break; - case XmlTokenizedType.ENTITY: - ProcessEntity(schemaInfo, name, this, EventHandler, reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition); - break; - default: - break; - } - } - - private void CheckValue( - string value, - SchemaAttDef attdef - ) - { - try - { - reader.TypedValueObject = null; - bool isAttn = attdef != null; - XmlSchemaDatatype dtype = isAttn ? attdef.Datatype : context.ElementDecl.Datatype; - if (dtype == null) - { - return; // no reason to check - } - - object typedValue = dtype.ParseValue(value, NameTable, _nsManager, true); - - // Check special types - XmlTokenizedType ttype = dtype.TokenizedType; - if (ttype == XmlTokenizedType.ENTITY || ttype == XmlTokenizedType.ID || ttype == XmlTokenizedType.IDREF) - { - if (dtype.Variety == XmlSchemaDatatypeVariety.List) - { - string[] ss = (string[])typedValue; - for (int i = 0; i < ss.Length; ++i) - { - ProcessTokenizedType(dtype.TokenizedType, ss[i]); - } - } - else - { - ProcessTokenizedType(dtype.TokenizedType, (string)typedValue); - } - } - - SchemaDeclBase decl = isAttn ? (SchemaDeclBase)attdef : (SchemaDeclBase)context.ElementDecl; - if (!decl.CheckValue(typedValue)) - { - if (isAttn) - { - SendValidationEvent(ResXml.Sch_FixedAttributeValue, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_FixedElementValue, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - if (dtype.Variety == XmlSchemaDatatypeVariety.Union) - { - typedValue = UnWrapUnion(typedValue); - } - reader.TypedValueObject = typedValue; - } - catch (XmlSchemaException) - { - if (attdef != null) - { - SendValidationEvent(ResXml.Sch_AttributeValueDataType, attdef.Name.ToString()); - } - else - { - SendValidationEvent(ResXml.Sch_ElementValueDataType, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } - } - - - - internal void AddID(string name, object node) - { - // Note: It used to be true that we only called this if _fValidate was true, - // but due to the fact that you can now dynamically type somethign as an ID - // that is no longer true. - if (_IDs == null) - { - _IDs = new Hashtable(); - } - - _IDs.Add(name, node); - } - - public override object FindId(string name) - { - return _IDs == null ? null : _IDs[name]; - } - - public bool IsXSDRoot(string localName, string ns) - { - return Ref.Equal(ns, _nsXs) && Ref.Equal(localName, _xsdSchema); - } - - private void Push(XmlQualifiedName elementName) - { - context = (ValidationState)_validationStack.Push(); - if (context == null) - { - context = new ValidationState(); - _validationStack.AddToTop(context); - } - context.LocalName = elementName.Name; - context.Namespace = elementName.Namespace; - context.HasMatched = false; - context.IsNill = false; - context.ProcessContents = _processContents; - context.NeedValidateChildren = false; - context.Constr = null; //resetting the constraints to be null incase context != null - // when pushing onto stack; - } - - - private void Pop() - { - if (_validationStack.Length > 1) - { - _validationStack.Pop(); - if (_startIDConstraint == _validationStack.Length) - { - _startIDConstraint = -1; - } - context = (ValidationState)_validationStack.Peek(); - _processContents = context.ProcessContents; - } - } - - private void CheckForwardRefs() - { - IdRefNode next = _idRefListHead; - while (next != null) - { - if (FindId(next.Id) == null) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_UndeclaredId, next.Id, reader.BaseURI, next.LineNo, next.LinePos)); - } - IdRefNode ptr = next.Next; - next.Next = null; // unhook each object so it is cleaned up by Garbage Collector - next = ptr; - } - // not needed any more. - _idRefListHead = null; - } - - - private void ValidateStartElementIdentityConstraints() - { - // added on June 15, set the context here, so the stack can have them - if (context.ElementDecl != null) - { - if (context.ElementDecl.Constraints != null) - { - AddIdentityConstraints(); - } - //foreach constraint in stack (including the current one) - if (HasIdentityConstraints) - { - ElementIdentityConstraints(); - } - } - } - - private bool HasIdentityConstraints - { - get { return _startIDConstraint != -1; } - } - - private void AddIdentityConstraints() - { - context.Constr = new ConstraintStruct[context.ElementDecl.Constraints.Length]; - int id = 0; - for (int i = 0; i < context.ElementDecl.Constraints.Length; ++i) - { - context.Constr[id++] = new ConstraintStruct(context.ElementDecl.Constraints[i]); - } // foreach constraint /constraintstruct - - // added on June 19, make connections between new keyref tables with key/unique tables in stack - // i can't put it in the above loop, coz there will be key on the same level - for (int i = 0; i < context.Constr.Length; ++i) - { - if (context.Constr[i].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - { - bool find = false; - // go upwards checking or only in this level - for (int level = _validationStack.Length - 1; level >= ((_startIDConstraint >= 0) ? _startIDConstraint : _validationStack.Length - 1); level--) - { - // no constraint for this level - if (((ValidationState)(_validationStack[level])).Constr == null) - { - continue; - } - // else - ConstraintStruct[] constraints = ((ValidationState)_validationStack[level]).Constr; - for (int j = 0; j < constraints.Length; ++j) - { - if (constraints[j].constraint.name == context.Constr[i].constraint.refer) - { - find = true; - if (constraints[j].keyrefTable == null) - { - constraints[j].keyrefTable = new Hashtable(); - } - context.Constr[i].qualifiedTable = constraints[j].keyrefTable; - break; - } - } - - if (find) - { - break; - } - } - if (!find) - { - // didn't find connections, throw exceptions - SendValidationEvent(ResXml.Sch_RefNotInScope, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); - } - } // finished dealing with keyref - } // end foreach - - // initial set - if (_startIDConstraint == -1) - { - _startIDConstraint = _validationStack.Length - 1; - } - } - - private void ElementIdentityConstraints() - { - for (int i = _startIDConstraint; i < _validationStack.Length; i++) - { - // no constraint for this level - if (((ValidationState)(_validationStack[i])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraints = ((ValidationState)_validationStack[i]).Constr; - for (int j = 0; j < constraints.Length; ++j) - { - // check selector from here - if (constraints[j].axisSelector.MoveToStartElement(reader.LocalName, reader.NamespaceURI)) - { - // selector selects new node, activate a new set of fields - Debug.WriteLine("Selector Match!"); - Debug.WriteLine("Name: " + reader.LocalName + "\t|\tURI: " + reader.NamespaceURI + "\n"); - // in which axisFields got updated - constraints[j].axisSelector.PushKS(PositionInfo.LineNumber, PositionInfo.LinePosition); - } - - // axisFields is not null, but may be empty - for (int k = 0; k < constraints[j].axisFields.Count; ++k) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraints[j].axisFields[k]; - - // check field from here - if (laxis.MoveToStartElement(reader.LocalName, reader.NamespaceURI)) - { - Debug.WriteLine("Element Field Match!"); - // checking simpleType / simpleContent - if (context.ElementDecl != null) - { // nextElement can be null when xml/xsd are not valid - if (context.ElementDecl.Datatype == null) - { - SendValidationEvent(ResXml.Sch_FieldSimpleTypeExpected, reader.LocalName); - } - else - { - // can't fill value here, wait till later.... - // fill type : xsdType - laxis.isMatched = true; - // since it's simpletyped element, the endchildren will come consequently... don't worry - } - } - } - } - } - } - } - - // facilitate modifying - private void AttributeIdentityConstraints(string name, string ns, object obj, string sobj, SchemaAttDef attdef) - { - for (int ci = _startIDConstraint; ci < _validationStack.Length; ci++) - { - // no constraint for this level - if (((ValidationState)(_validationStack[ci])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraints = ((ValidationState)_validationStack[ci]).Constr; - for (int i = 0; i < constraints.Length; ++i) - { - // axisFields is not null, but may be empty - for (int j = 0; j < constraints[i].axisFields.Count; ++j) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraints[i].axisFields[j]; - - // check field from here - if (laxis.MoveToAttribute(name, ns)) - { - Debug.WriteLine("Attribute Field Match!"); - //attribute is only simpletype, so needn't checking... - // can fill value here, yeah!! - Debug.WriteLine("Attribute Field Filling Value!"); - Debug.WriteLine("Name: " + name + "\t|\tURI: " + ns + "\t|\tValue: " + obj + "\n"); - if (laxis.Ks[laxis.Column] != null) - { - // should be evaluated to either an empty node-set or a node-set with exactly one member - // two matches... - SendValidationEvent(ResXml.Sch_FieldSingleValueExpected, name); - } - else if ((attdef != null) && (attdef.Datatype != null)) - { - laxis.Ks[laxis.Column] = new TypedObject(obj, sobj, attdef.Datatype); - } - } - } - } - } - } - - private object UnWrapUnion(object typedValue) - { - XsdSimpleValue simpleValue = typedValue as XsdSimpleValue; - if (simpleValue != null) - { - typedValue = simpleValue.TypedValue; - } - return typedValue; - } - - private void EndElementIdentityConstraints() - { - for (int ci = _validationStack.Length - 1; ci >= _startIDConstraint; ci--) - { - // no constraint for this level - if (((ValidationState)(_validationStack[ci])).Constr == null) - { - continue; - } - - // else - ConstraintStruct[] constraints = ((ValidationState)_validationStack[ci]).Constr; - for (int i = 0; i < constraints.Length; ++i) - { - // EndChildren - // axisFields is not null, but may be empty - for (int j = 0; j < constraints[i].axisFields.Count; ++j) - { - LocatedActiveAxis laxis = (LocatedActiveAxis)constraints[i].axisFields[j]; - // check field from here - // isMatched is false when nextElement is null. so needn't change this part. - if (laxis.isMatched) - { - Debug.WriteLine("Element Field Filling Value!"); - Debug.WriteLine("Name: " + reader.LocalName + "\t|\tURI: " + reader.NamespaceURI + "\t|\tValue: " + reader.TypedValueObject + "\n"); - // fill value - laxis.isMatched = false; - if (laxis.Ks[laxis.Column] != null) - { - // [field...] should be evaluated to either an empty node-set or a node-set with exactly one member - // two matches... already existing field value in the table. - SendValidationEvent(ResXml.Sch_FieldSingleValueExpected, reader.LocalName); - } - else - { - // for element, reader.Value = ""; - string stringValue = !hasSibling ? textString : textValue.ToString(); // only for identity-constraint exception reporting - if (reader.TypedValueObject != null && stringValue.Length != 0) - { - laxis.Ks[laxis.Column] = new TypedObject(reader.TypedValueObject, stringValue, context.ElementDecl.Datatype); - } - } - } - // EndChildren - laxis.EndElement(reader.LocalName, reader.NamespaceURI); - } - - if (constraints[i].axisSelector.EndElement(reader.LocalName, reader.NamespaceURI)) - { - // insert key sequence into hash (+ located active axis tuple leave for later) - KeySequence ks = constraints[i].axisSelector.PopKS(); - // unqualified keysequence are not allowed - switch (constraints[i].constraint.Role) - { - case CompiledIdentityConstraint.ConstraintRole.Key: - if (!ks.IsQualified()) - { - //Key's fields can't be null... if we can return context node's line info maybe it will be better - //only keymissing & keyduplicate reporting cases are necessary to be dealt with... 3 places... - SendValidationEvent(new XmlSchemaException(ResXml.Sch_MissingKey, constraints[i].constraint.name.ToString(), reader.BaseURI, ks.PosLine, ks.PosCol)); - } - else if (constraints[i].qualifiedTable.Contains(ks)) - { - // unique or key checking value confliction - // for redundant key, reporting both occurings - // doesn't work... how can i retrieve value out?? - SendValidationEvent(new XmlSchemaException(ResXml.Sch_DuplicateKey, - new string[2] { ks.ToString(), constraints[i].constraint.name.ToString() }, - reader.BaseURI, ks.PosLine, ks.PosCol)); - } - else - { - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - case CompiledIdentityConstraint.ConstraintRole.Unique: - if (!ks.IsQualified()) - { - continue; - } - if (constraints[i].qualifiedTable.Contains(ks)) - { - // unique or key checking confliction - SendValidationEvent(new XmlSchemaException(ResXml.Sch_DuplicateKey, - new string[2] { ks.ToString(), constraints[i].constraint.name.ToString() }, - reader.BaseURI, ks.PosLine, ks.PosCol)); - } - else - { - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - case CompiledIdentityConstraint.ConstraintRole.Keyref: - // is there any possibility: - // 2 keyrefs: value is equal, type is not - // both put in the hashtable, 1 reference, 1 not - if (constraints[i].qualifiedTable != null) - { //Will be null in cases when the keyref is outside the scope of the key, that is not allowed by our impl - if (!ks.IsQualified() || constraints[i].qualifiedTable.Contains(ks)) - { - continue; - } - constraints[i].qualifiedTable.Add(ks, ks); - } - break; - } - } - } - } - - // current level's constraint struct - ConstraintStruct[] vcs = ((ValidationState)(_validationStack[_validationStack.Length - 1])).Constr; - if (vcs != null) - { - // validating all referencing tables... - for (int i = 0; i < vcs.Length; ++i) - { - if ((vcs[i].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref) - || (vcs[i].keyrefTable == null)) - { - continue; - } - foreach (KeySequence ks in vcs[i].keyrefTable.Keys) - { - if (!vcs[i].qualifiedTable.Contains(ks)) - { - SendValidationEvent(new XmlSchemaException(ResXml.Sch_UnresolvedKeyref, new string[2] { ks.ToString(), vcs[i].constraint.name.ToString() }, - reader.BaseURI, ks.PosLine, ks.PosCol)); - } - } - } - } - } - } -#pragma warning restore 618 -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Attributes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Attributes.cs index bcb5ae564a6..fa7620f172b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Attributes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Attributes.cs @@ -5,7 +5,7 @@ using System; using System.Globalization; using System.IO; -using Microsoft.Xml; +using System.Xml; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs index cf9288148a0..7fc8c23a60d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs @@ -12,8 +12,8 @@ namespace System.Runtime.Serialization using System.Globalization; using System.Reflection; using System.Threading; - using Microsoft.Xml; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using DataContractDictionary = System.Collections.Generic.Dictionary; using System.Security; using System.Linq; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs index 98fd88e5d35..08f9bdbfb4a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs @@ -14,9 +14,9 @@ namespace System.Runtime.Serialization using System.Reflection; using System.Security; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using System.Xml.Schema; + using DataContractDictionary = System.Collections.Generic.Dictionary; internal class CodeExporter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeGenerator.cs index 955031de4e7..82564a9d9b8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeGenerator.cs @@ -6,7 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; -using Microsoft.Xml; +using System.Xml; using System.Reflection; using System.Reflection.Emit; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs index 4d6a507be90..5b2baca3aab 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs @@ -11,9 +11,9 @@ namespace System.Runtime.Serialization using System.Collections.Generic; using System.Reflection; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.Linq; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using DataContractDictionary = System.Collections.Generic.Dictionary; using System.Security; //Special Adapter class to serialize KeyValuePair as Dictionary needs it when polymorphism is involved diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs index 6209784d703..fa0e54611c4 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs @@ -9,9 +9,9 @@ namespace System.Runtime.Serialization using System.Globalization; using System.Reflection; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using System.Xml.Schema; + using DataContractDictionary = System.Collections.Generic.Dictionary; using System.Security; using System.Text.RegularExpressions; using System.Runtime.CompilerServices; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractResolver.cs index 7dcbbfe4839..507d11da54b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractResolver.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.Runtime.Serialization diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializer.cs index 77878037391..cddb37d0788 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializer.cs @@ -11,11 +11,11 @@ namespace System.Runtime.Serialization using System.IO; using System.Reflection; using System.Text; - using Microsoft.Xml; + using System.Xml; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.CompilerServices; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using DataContractDictionary = System.Collections.Generic.Dictionary; public sealed class DataContractSerializer : XmlObjectSerializer { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializerSettings.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializerSettings.cs index 9e1ae5ed183..2135c2d51e0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializerSettings.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializerSettings.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Microsoft.Xml; +using System.Xml; namespace System.Runtime.Serialization diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSet.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSet.cs index a12cc0de00f..b281b75c5ba 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSet.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSet.cs @@ -9,8 +9,8 @@ namespace System.Runtime.Serialization using System.Collections.Generic; using System.Reflection; using System.Text; - using Microsoft.Xml; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using DataContractDictionary = System.Collections.Generic.Dictionary; internal class DataContractSet { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataMember.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataMember.cs index 0dc6c7d6ed9..a34f75b74e9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataMember.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DataMember.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Globalization; using System.Reflection; -using Microsoft.Xml; +using System.Xml; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DateTimeOffsetAdapter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DateTimeOffsetAdapter.cs index 562c0a9f495..1edd88409a1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DateTimeOffsetAdapter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DateTimeOffsetAdapter.cs @@ -4,7 +4,7 @@ using System; using System.Reflection; -using Microsoft.Xml; +using System.Xml; using System.Globalization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DictionaryGlobals.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DictionaryGlobals.cs index 34d740e3931..987ec811198 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DictionaryGlobals.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/DictionaryGlobals.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/EnumDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/EnumDataContract.cs index 28ecdb16fb9..f0f05cabdb9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/EnumDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/EnumDataContract.cs @@ -9,7 +9,7 @@ using System.Reflection; using System.Threading; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Security; using System.Linq; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExceptionDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExceptionDataContract.cs index ce8e8853cc4..7c19cad7dcf 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExceptionDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExceptionDataContract.cs @@ -9,7 +9,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; using System.Security; using System.Collections; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataObject.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataObject.cs index c003b34715d..e86aef6b4f5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataObject.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataObject.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; using System.Globalization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataReader.cs index 64a8690e88a..2dba1b39aea 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ExtensionDataReader.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs index b6e258c2fc5..0e2abaacea5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs @@ -4,9 +4,9 @@ using System; using System.ComponentModel; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.Serialization; +using System.Xml; +using System.Xml.Schema; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Reflection; using System.Collections; using System.Collections.Generic; @@ -1098,7 +1098,7 @@ internal static bool IsDBNullValue(object o) public const string SerPrefixForSchema = "ser"; public const string ElementPrefix = "q"; public const string DataContractXsdBaseNamespace = "http://schemas.datacontract.org/2004/07/"; - public const string DataContractXmlNamespace = DataContractXsdBaseNamespace + "Microsoft.Xml"; + public const string DataContractXmlNamespace = DataContractXsdBaseNamespace + "System.Xml"; public const string SchemaInstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance"; public const string SchemaNamespace = "http://www.w3.org/2001/XMLSchema"; public const string XsiNilLocalName = "nil"; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/HybridObjectCache.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/HybridObjectCache.cs index 486658797a8..8887f8ea63d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/HybridObjectCache.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/HybridObjectCache.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/KnownTypeDataContractResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/KnownTypeDataContractResolver.cs index 324ca5b8933..a0816e57a71 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/KnownTypeDataContractResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/KnownTypeDataContractResolver.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Reflection; namespace System.Runtime.Serialization diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ObjectReferenceStack.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ObjectReferenceStack.cs index bc4c275d0e1..c962c79d39d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ObjectReferenceStack.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ObjectReferenceStack.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/PrimitiveDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/PrimitiveDataContract.cs index 38a6f709130..448e045b098 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/PrimitiveDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/PrimitiveDataContract.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Globalization; using System.Reflection; -using Microsoft.Xml; +using System.Xml; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaExporter.cs index b20c2e3d940..3ae2794c3ca 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaExporter.cs @@ -6,9 +6,9 @@ namespace System.Runtime.Serialization { using System; using System.Linq; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Reflection; using System.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaHelper.cs index 3b60b5d1316..05a3345527b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaHelper.cs @@ -5,11 +5,11 @@ namespace System.Runtime.Serialization { using System; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using System.Collections; using System.Collections.Generic; - using SchemaObjectDictionary = System.Collections.Generic.Dictionary; + using SchemaObjectDictionary = System.Collections.Generic.Dictionary; internal class SchemaObjectInfo { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaImporter.cs index bbeae2840b9..aed97442efb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaImporter.cs @@ -12,10 +12,10 @@ namespace System.Runtime.Serialization using System.IO; using System.Reflection; using System.Security; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using DataContractDictionary = System.Collections.Generic.Dictionary; - using SchemaObjectDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using System.Xml.Schema; + using DataContractDictionary = System.Collections.Generic.Dictionary; + using SchemaObjectDictionary = System.Collections.Generic.Dictionary; internal class SchemaImporter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ScopedKnownTypes.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ScopedKnownTypes.cs index 19fc4e9217f..08e0ece0ebe 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ScopedKnownTypes.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/ScopedKnownTypes.cs @@ -5,8 +5,8 @@ namespace System.Runtime.Serialization { using System; - using Microsoft.Xml; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using DataContractDictionary = System.Collections.Generic.Dictionary; internal struct ScopedKnownTypes { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SpecialTypeDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SpecialTypeDataContract.cs index 58b43191145..b68b98ca1dc 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SpecialTypeDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SpecialTypeDataContract.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Security; namespace System.Runtime.Serialization diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs index 5dda3ea7af7..de58536a846 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlDataContract.cs @@ -8,10 +8,10 @@ namespace System.Runtime.Serialization using System.Collections.Generic; using System.Reflection; using System.Threading; - using Microsoft.Xml; - using DataContractDictionary = System.Collections.Generic.Dictionary; - using Microsoft.Xml.Serialization; - using Microsoft.Xml.Schema; + using System.Xml; + using DataContractDictionary = System.Collections.Generic.Dictionary; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; + using System.Xml.Schema; using System.Security; using System.Linq; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs index 7af2f1b8b04..55f5a11e072 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs @@ -5,7 +5,7 @@ using System; using System.Reflection; using System.Security; -using Microsoft.Xml; +using System.Xml; using System.Collections; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatReaderGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatReaderGenerator.cs index b1f7316e6d3..b6d6486ecc2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatReaderGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatReaderGenerator.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using System.Reflection; using System.Reflection.Emit; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatWriterGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatWriterGenerator.cs index 9ffcad79c11..225fa9ce590 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatWriterGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlFormatWriterGenerator.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using System.Reflection; using System.Reflection.Emit; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs index e0cad546f30..3df7fb52e18 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs @@ -8,11 +8,11 @@ namespace System.Runtime.Serialization using System.Diagnostics; using System.Globalization; using System.IO; - using Microsoft.Xml; + using System.Xml; using System.Runtime.CompilerServices; using System.Text; using System.Security; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using DataContractDictionary = System.Collections.Generic.Dictionary; public abstract class XmlObjectSerializer { @@ -200,8 +200,8 @@ internal bool CheckIfNeedsContractNsAtRoot(XmlDictionaryString name, XmlDictiona return false; } - string contractNs = XmlDictionaryString.GetString(contract.Namespace); - if (string.IsNullOrEmpty(contractNs) || contractNs == XmlDictionaryString.GetString(ns)) + string contractNs = contract.Namespace?.Value; + if (string.IsNullOrEmpty(contractNs) || contractNs == ns?.Value) return false; return true; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs index 5b42493e2ef..308fdca1c1c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs @@ -9,8 +9,8 @@ namespace System.Runtime.Serialization using System.Diagnostics; using System.Reflection; using System.Security; - using Microsoft.Xml; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using System.Xml; + using DataContractDictionary = System.Collections.Generic.Dictionary; #if USE_REFEMIT || NET_NATIVE public class XmlObjectSerializerContext diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs index e67b2c6e1f1..b1c030a5698 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs @@ -9,10 +9,10 @@ namespace System.Runtime.Serialization using System.Collections.Generic; using System.Diagnostics; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Security; - using DataContractDictionary = System.Collections.Generic.Dictionary; + using DataContractDictionary = System.Collections.Generic.Dictionary; #if USE_REFEMIT || NET_NATIVE public class XmlObjectSerializerReadContext : XmlObjectSerializerContext diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs index e53fbf5d956..a7db76c7283 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs @@ -9,9 +9,9 @@ using System.IO; using System.Reflection; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; -using Microsoft.Xml.Serialization; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Security; #if !NET_NATIVE using ExtensionDataObject = System.Object; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContextComplex.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContextComplex.cs index a23c1b791f1..437acf0ad14 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContextComplex.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContextComplex.cs @@ -9,7 +9,7 @@ using System.IO; using System.Reflection; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; using System.Security; using System.Runtime.CompilerServices; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlReaderDelegator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlReaderDelegator.cs index 1a84ea857e2..c0942d91a87 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlReaderDelegator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlReaderDelegator.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Globalization; using System.Collections.Generic; @@ -872,7 +872,7 @@ internal bool TryReadDoubleArray(XmlObjectSerializerReadContext context, internal IDictionary GetNamespacesInScope(XmlNamespaceScope scope) { - return (reader is IXmlNamespaceResolver) ? ((IXmlNamespaceResolver)reader).GetNamespacesInScope(scope) : null; + return (reader is IXmlNamespaceResolver) ? ((IXmlNamespaceResolver)reader).GetNamespacesInScope((System.Xml.XmlNamespaceScope)(int)scope) : null; } // IXmlLineInfo members diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableReader.cs index 6868970049a..a43c786239f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableReader.cs @@ -3,9 +3,9 @@ // See the LICENSE file in the project root for more information. using System.IO; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.Serialization; +using System.Xml; +using System.Xml.Schema; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableServices.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableServices.cs index 1b590484f47..9bea19ca2aa 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableServices.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableServices.cs @@ -5,7 +5,7 @@ namespace System.Runtime.Serialization { using System.Collections.Generic; - using Microsoft.Xml; + using System.Xml; public static class XmlSerializableServices { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableWriter.cs index 337849f709e..d757f6ec978 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlSerializableWriter.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; namespace System.Runtime.Serialization diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlWriterDelegator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlWriterDelegator.cs index 1cc9a85fad6..12b6dbb78b6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlWriterDelegator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XmlWriterDelegator.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Globalization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XsdDataContractImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XsdDataContractImporter.cs index 22f1e1ecadb..803e3c28644 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XsdDataContractImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/XsdDataContractImporter.cs @@ -8,9 +8,9 @@ namespace System.Runtime.Serialization using Microsoft.CodeDom; using System.Collections.Generic; using System.Security; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; - using Microsoft.Xml.Schema; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; + using System.Xml.Schema; public class XsdDataContractImporter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ArrayHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ArrayHelper.cs index 26a4ac37c5c..fc91589633b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ArrayHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ArrayHelper.cs @@ -5,7 +5,7 @@ using System; -namespace Microsoft.Xml +namespace System.Xml { internal abstract class ArrayHelper { @@ -18,8 +18,8 @@ public TArray[] ReadArray(XmlDictionaryReader reader, TArgument localName, TArgu int count; if (reader.TryGetArrayLength(out count)) { - if (count > XmlDictionaryReader.MaxInitialArrayLength) - count = XmlDictionaryReader.MaxInitialArrayLength; + if (count > 65535 /*XmlDictionaryReader.MaxInitialArrayLength*/) + count = 65535 /*XmlDictionaryReader.MaxInitialArrayLength*/; } else { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/BytesWithOffset.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/BytesWithOffset.cs index beb674ba3b1..62617d38cee 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/BytesWithOffset.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/BytesWithOffset.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace Microsoft.Xml +namespace System.Xml { internal struct BytesWithOffset { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/EncodingStreamWrapper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/EncodingStreamWrapper.cs index bb66af795f6..8fe823c8d1f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/EncodingStreamWrapper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/EncodingStreamWrapper.cs @@ -8,7 +8,7 @@ using System.Text; -namespace Microsoft.Xml +namespace System.Xml { // This wrapper does not support seek. // Constructors consume/emit byte order mark. diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IStreamProvider.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IStreamProvider.cs index df850af92bd..ed3b738dd35 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IStreamProvider.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IStreamProvider.cs @@ -4,7 +4,7 @@ using System.IO; -namespace Microsoft.Xml +namespace System.Xml { public interface IStreamProvider { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IXmlDictionary.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IXmlDictionary.cs deleted file mode 100644 index 71c01cc26d2..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/IXmlDictionary.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml -{ - public interface IXmlDictionary - { - bool TryLookup(string value, out XmlDictionaryString result); - bool TryLookup(int key, out XmlDictionaryString result); - bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result); - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/PrefixHandle.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/PrefixHandle.cs deleted file mode 100644 index 2da21019748..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/PrefixHandle.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.Serialization; -using System.Diagnostics; - - -namespace Microsoft.Xml -{ - internal enum PrefixHandleType - { - Empty, - A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, - Buffer, - Max, - } - - internal class PrefixHandle : IEquatable - { - private XmlBufferReader _bufferReader; - private PrefixHandleType _type; - private int _offset; - private int _length; - private static string[] s_prefixStrings = { "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }; - private static byte[] s_prefixBuffer = { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z' }; - - public PrefixHandle(XmlBufferReader bufferReader) - { - _bufferReader = bufferReader; - } - - public void SetValue(PrefixHandleType type) - { - DiagnosticUtility.DebugAssert(type != PrefixHandleType.Buffer, ""); - _type = type; - } - - public void SetValue(PrefixHandle prefix) - { - _type = prefix._type; - _offset = prefix._offset; - _length = prefix._length; - } - - public void SetValue(int offset, int length) - { - if (length == 0) - { - SetValue(PrefixHandleType.Empty); - return; - } - - if (length == 1) - { - byte ch = _bufferReader.GetByte(offset); - if (ch >= 'a' && ch <= 'z') - { - SetValue(GetAlphaPrefix(ch - 'a')); - return; - } - } - - _type = PrefixHandleType.Buffer; - _offset = offset; - _length = length; - } - - public bool IsEmpty - { - get - { - return _type == PrefixHandleType.Empty; - } - } - - public bool IsXmlns - { - get - { - if (_type != PrefixHandleType.Buffer) - return false; - if (_length != 5) - return false; - byte[] buffer = _bufferReader.Buffer; - int offset = _offset; - return buffer[offset + 0] == 'x' && - buffer[offset + 1] == 'm' && - buffer[offset + 2] == 'l' && - buffer[offset + 3] == 'n' && - buffer[offset + 4] == 's'; - } - } - - public bool IsXml - { - get - { - if (_type != PrefixHandleType.Buffer) - return false; - if (_length != 3) - return false; - byte[] buffer = _bufferReader.Buffer; - int offset = _offset; - return buffer[offset + 0] == 'x' && - buffer[offset + 1] == 'm' && - buffer[offset + 2] == 'l'; - } - } - - public bool TryGetShortPrefix(out PrefixHandleType type) - { - type = _type; - return (type != PrefixHandleType.Buffer); - } - - public static string GetString(PrefixHandleType type) - { - DiagnosticUtility.DebugAssert(type != PrefixHandleType.Buffer, ""); - return s_prefixStrings[(int)type]; - } - - public static PrefixHandleType GetAlphaPrefix(int index) - { - DiagnosticUtility.DebugAssert(index >= 0 && index < 26, ""); - return (PrefixHandleType)(PrefixHandleType.A + index); - } - - public static byte[] GetString(PrefixHandleType type, out int offset, out int length) - { - DiagnosticUtility.DebugAssert(type != PrefixHandleType.Buffer, ""); - if (type == PrefixHandleType.Empty) - { - offset = 0; - length = 0; - } - else - { - length = 1; - offset = (int)(type - PrefixHandleType.A); - } - return s_prefixBuffer; - } - - public string GetString(XmlNameTable nameTable) - { - PrefixHandleType type = _type; - if (type != PrefixHandleType.Buffer) - return GetString(type); - else - return _bufferReader.GetString(_offset, _length, nameTable); - } - - public string GetString() - { - PrefixHandleType type = _type; - if (type != PrefixHandleType.Buffer) - return GetString(type); - else - return _bufferReader.GetString(_offset, _length); - } - - public byte[] GetString(out int offset, out int length) - { - PrefixHandleType type = _type; - if (type != PrefixHandleType.Buffer) - return GetString(type, out offset, out length); - else - { - offset = _offset; - length = _length; - return _bufferReader.Buffer; - } - } - public int CompareTo(PrefixHandle that) - { - return GetString().CompareTo(that.GetString()); - } - - public bool Equals(PrefixHandle prefix2) - { - if (ReferenceEquals(prefix2, null)) - return false; - PrefixHandleType type1 = _type; - PrefixHandleType type2 = prefix2._type; - if (type1 != type2) - return false; - if (type1 != PrefixHandleType.Buffer) - return true; - if (_bufferReader == prefix2._bufferReader) - return _bufferReader.Equals2(_offset, _length, prefix2._offset, prefix2._length); - else - return _bufferReader.Equals2(_offset, _length, prefix2._bufferReader, prefix2._offset, prefix2._length); - } - - private bool Equals2(string prefix2) - { - PrefixHandleType type = _type; - if (type != PrefixHandleType.Buffer) - return GetString(type) == prefix2; - return _bufferReader.Equals2(_offset, _length, prefix2); - } - - private bool Equals2(XmlDictionaryString prefix2) - { - return Equals2(prefix2.Value); - } - static public bool operator ==(PrefixHandle prefix1, string prefix2) - { - return prefix1.Equals2(prefix2); - } - - static public bool operator !=(PrefixHandle prefix1, string prefix2) - { - return !prefix1.Equals2(prefix2); - } - - static public bool operator ==(PrefixHandle prefix1, XmlDictionaryString prefix2) - { - return prefix1.Equals2(prefix2); - } - - static public bool operator !=(PrefixHandle prefix1, XmlDictionaryString prefix2) - { - return !prefix1.Equals2(prefix2); - } - - static public bool operator ==(PrefixHandle prefix1, PrefixHandle prefix2) - { - return prefix1.Equals(prefix2); - } - - static public bool operator !=(PrefixHandle prefix1, PrefixHandle prefix2) - { - return !prefix1.Equals(prefix2); - } - public override bool Equals(object obj) - { - return Equals(obj as PrefixHandle); - } - - public override string ToString() - { - return GetString(); - } - - public override int GetHashCode() - { - return GetString().GetHashCode(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/StringHandle.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/StringHandle.cs deleted file mode 100644 index 7c34b1f94c5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/StringHandle.cs +++ /dev/null @@ -1,297 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.Serialization; -using System.Diagnostics; - - -namespace Microsoft.Xml -{ - internal enum StringHandleConstStringType - { - Type = 0, - Root = 1, - Item = 2 - } - - internal class StringHandle : IEquatable - { - private XmlBufferReader _bufferReader; - private StringHandleType _type; - private int _key; - private int _offset; - private int _length; - private static string[] s_constStrings = { - "type", - "root", - "item" - }; - - public StringHandle(XmlBufferReader bufferReader) - { - _bufferReader = bufferReader; - SetValue(0, 0); - } - - public void SetValue(int offset, int length) - { - _type = StringHandleType.UTF8; - _offset = offset; - _length = length; - } - - public void SetConstantValue(StringHandleConstStringType constStringType) - { - _type = StringHandleType.ConstString; - _key = (int)constStringType; - } - - public void SetValue(int offset, int length, bool escaped) - { - _type = (escaped ? StringHandleType.EscapedUTF8 : StringHandleType.UTF8); - _offset = offset; - _length = length; - } - - public void SetValue(int key) - { - _type = StringHandleType.Dictionary; - _key = key; - } - - public void SetValue(StringHandle value) - { - _type = value._type; - _key = value._key; - _offset = value._offset; - _length = value._length; - } - - public bool IsEmpty - { - get - { - if (_type == StringHandleType.UTF8) - return _length == 0; - return Equals2(string.Empty); - } - } - - public bool IsXmlns - { - get - { - if (_type == StringHandleType.UTF8) - { - if (_length != 5) - return false; - byte[] buffer = _bufferReader.Buffer; - int offset = _offset; - return buffer[offset + 0] == 'x' && - buffer[offset + 1] == 'm' && - buffer[offset + 2] == 'l' && - buffer[offset + 3] == 'n' && - buffer[offset + 4] == 's'; - } - return Equals2("xmlns"); - } - } - - public void ToPrefixHandle(PrefixHandle prefix) - { - DiagnosticUtility.DebugAssert(_type == StringHandleType.UTF8, ""); - prefix.SetValue(_offset, _length); - } - - public string GetString(XmlNameTable nameTable) - { - StringHandleType type = _type; - if (type == StringHandleType.UTF8) - return _bufferReader.GetString(_offset, _length, nameTable); - if (type == StringHandleType.Dictionary) - return nameTable.Add(_bufferReader.GetDictionaryString(_key).Value); - DiagnosticUtility.DebugAssert(type == StringHandleType.ConstString, "Should be ConstString"); - //If not Utf8 then the StringHandleType is ConstString - return nameTable.Add(s_constStrings[_key]); - } - - public string GetString() - { - StringHandleType type = _type; - if (type == StringHandleType.UTF8) - return _bufferReader.GetString(_offset, _length); - if (type == StringHandleType.Dictionary) - return _bufferReader.GetDictionaryString(_key).Value; - DiagnosticUtility.DebugAssert(type == StringHandleType.ConstString, "Should be ConstString"); - //If not Utf8 then the StringHandleType is ConstString - return s_constStrings[_key]; - } - - public byte[] GetString(out int offset, out int length) - { - StringHandleType type = _type; - if (type == StringHandleType.UTF8) - { - offset = _offset; - length = _length; - return _bufferReader.Buffer; - } - if (type == StringHandleType.Dictionary) - { - byte[] buffer = _bufferReader.GetDictionaryString(_key).ToUTF8(); - offset = 0; - length = buffer.Length; - return buffer; - } - if (type == StringHandleType.ConstString) - { - byte[] buffer = XmlConverter.ToBytes(s_constStrings[_key]); - offset = 0; - length = buffer.Length; - return buffer; - } - else - { - DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8, ""); - byte[] buffer = XmlConverter.ToBytes(_bufferReader.GetEscapedString(_offset, _length)); - offset = 0; - length = buffer.Length; - return buffer; - } - } - - public bool TryGetDictionaryString(out XmlDictionaryString value) - { - if (_type == StringHandleType.Dictionary) - { - value = _bufferReader.GetDictionaryString(_key); - return true; - } - else if (IsEmpty) - { - value = XmlDictionaryString.Empty; - return true; - } - - value = null; - return false; - } - public override string ToString() - { - return GetString(); - } - - private bool Equals2(int key2, XmlBufferReader bufferReader2) - { - StringHandleType type = _type; - if (type == StringHandleType.Dictionary) - return _bufferReader.Equals2(_key, key2, bufferReader2); - if (type == StringHandleType.UTF8) - return _bufferReader.Equals2(_offset, _length, bufferReader2.GetDictionaryString(key2).Value); - DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8 || type == StringHandleType.ConstString, ""); - return GetString() == _bufferReader.GetDictionaryString(key2).Value; - } - - private bool Equals2(XmlDictionaryString xmlString2) - { - StringHandleType type = _type; - if (type == StringHandleType.Dictionary) - return _bufferReader.Equals2(_key, xmlString2); - if (type == StringHandleType.UTF8) - return _bufferReader.Equals2(_offset, _length, xmlString2.ToUTF8()); - DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8 || type == StringHandleType.ConstString, ""); - return GetString() == xmlString2.Value; - } - - private bool Equals2(string s2) - { - StringHandleType type = _type; - if (type == StringHandleType.Dictionary) - return _bufferReader.GetDictionaryString(_key).Value == s2; - if (type == StringHandleType.UTF8) - return _bufferReader.Equals2(_offset, _length, s2); - DiagnosticUtility.DebugAssert(type == StringHandleType.ConstString, ""); - return GetString() == s2; - } - - private bool Equals2(int offset2, int length2, XmlBufferReader bufferReader2) - { - StringHandleType type = _type; - if (type == StringHandleType.Dictionary) - return bufferReader2.Equals2(offset2, length2, _bufferReader.GetDictionaryString(_key).Value); - if (type == StringHandleType.UTF8) - return _bufferReader.Equals2(_offset, _length, bufferReader2, offset2, length2); - DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8 || type == StringHandleType.ConstString, ""); - return GetString() == _bufferReader.GetString(offset2, length2); - } - - public bool Equals(StringHandle other) - { - if (ReferenceEquals(other, null)) - return false; - StringHandleType type = other._type; - if (type == StringHandleType.Dictionary) - return Equals2(other._key, other._bufferReader); - if (type == StringHandleType.UTF8) - return Equals2(other._offset, other._length, other._bufferReader); - DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8 || type == StringHandleType.ConstString, ""); - return Equals2(other.GetString()); - } - - static public bool operator ==(StringHandle s1, XmlDictionaryString xmlString2) - { - return s1.Equals2(xmlString2); - } - - static public bool operator !=(StringHandle s1, XmlDictionaryString xmlString2) - { - return !s1.Equals2(xmlString2); - } - static public bool operator ==(StringHandle s1, string s2) - { - return s1.Equals2(s2); - } - - static public bool operator !=(StringHandle s1, string s2) - { - return !s1.Equals2(s2); - } - - static public bool operator ==(StringHandle s1, StringHandle s2) - { - return s1.Equals(s2); - } - - static public bool operator !=(StringHandle s1, StringHandle s2) - { - return !s1.Equals(s2); - } - - public int CompareTo(StringHandle that) - { - if (_type == StringHandleType.UTF8 && that._type == StringHandleType.UTF8) - return _bufferReader.Compare(_offset, _length, that._offset, that._length); - else - return string.Compare(this.GetString(), that.GetString(), StringComparison.Ordinal); - } - public override bool Equals(object obj) - { - return Equals(obj as StringHandle); - } - - public override int GetHashCode() - { - return GetString().GetHashCode(); - } - - private enum StringHandleType - { - Dictionary, - UTF8, - EscapedUTF8, - ConstString - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/UniqueId.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/UniqueId.cs deleted file mode 100644 index 1d729f71e33..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/UniqueId.cs +++ /dev/null @@ -1,489 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xml; -using System.Text; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Security; - - -namespace Microsoft.Xml -{ - using System; - - public class UniqueId - { - private Int64 _idLow; - private Int64 _idHigh; - [SecurityCritical] - /// - /// Critical - some SecurityCritical unsafe code assumes that this field has been validated - /// - private string _s; - private const int guidLength = 16; - private const int uuidLength = 45; - - private static short[] s_char2val = new short[256] - { - /* 0-15 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 16-31 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 32-47 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 48-63 */ - 0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x080, 0x090, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 64-79 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 80-95 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 96-111 */ - 0x100, 0x0A0, 0x0B0, 0x0C0, 0x0D0, 0x0E0, 0x0F0, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 112-127 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - - /* 0-15 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 16-31 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 32-47 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 48-63 */ - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x009, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 64-79 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 80-95 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 96-111 */ - 0x100, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - /* 112-127 */ - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, - }; - - private const string val2char = "0123456789abcdef"; - - public UniqueId() : this(Guid.NewGuid()) - { - } - - public UniqueId(Guid guid) : this(guid.ToByteArray()) - { - } - - public UniqueId(byte[] guid) : this(guid, 0) - { - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public UniqueId(byte[] guid, int offset) - { - if (guid == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("guid")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > guid.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, guid.Length))); - if (guidLength > guid.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.XmlArrayTooSmallInput, guidLength), "guid")); - fixed (byte* pb = &guid[offset]) - { - _idLow = UnsafeGetInt64(pb); - _idHigh = UnsafeGetInt64(&pb[8]); - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public UniqueId(string value) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - if (value.Length == 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(string.Format(SRSerialization.XmlInvalidUniqueId))); - fixed (char* pch = value) - { - UnsafeParse(pch, value.Length); - } - _s = value; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public UniqueId(char[] chars, int offset, int count) - { - if (chars == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > chars.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, chars.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > chars.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, chars.Length - offset))); - if (count == 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(string.Format(SRSerialization.XmlInvalidUniqueId))); - fixed (char* pch = &chars[offset]) - { - UnsafeParse(pch, count); - } - if (!IsGuid) - { - _s = new string(chars, offset, count); - } - } - - - public int CharArrayLength - { - /// - /// Critical - accesses critical field 's'. - /// Safe - doesn't leak any control or data - /// - [SecuritySafeCritical] - get - { - if (_s != null) - return _s.Length; - - return uuidLength; - } - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe int UnsafeDecode(short* char2val, char ch1, char ch2) - { - if ((ch1 | ch2) >= 0x80) - return 0x100; - - return char2val[ch1] | char2val[0x80 + ch2]; - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeEncode(char* val2char, byte b, char* pch) - { - pch[0] = val2char[b >> 4]; - pch[1] = val2char[b & 0x0F]; - } - - public bool IsGuid - { - get - { - return ((_idLow | _idHigh) != 0); - } - } - - // It must be the case that comparing UniqueId's as strings yields the same result as comparing UniqueId's as - // their binary equivalent. This means that there must be a 1-1 relationship between a string and its binary - // equivalent. Therefore, for example, we cannot accept both upper and lower case hex chars since there would - // then be more than 1 string that mapped to a binary equivalent. - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeParse(char* chars, int charCount) - { - // 1 2 3 4 - // 012345678901234567890123456789012345678901234 - // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - - if (charCount != uuidLength || - chars[0] != 'u' || chars[1] != 'r' || chars[2] != 'n' || chars[3] != ':' || - chars[4] != 'u' || chars[5] != 'u' || chars[6] != 'i' || chars[7] != 'd' || chars[8] != ':' || - chars[17] != '-' || chars[22] != '-' || chars[27] != '-' || chars[32] != '-') - { - return; - } - - byte* bytes = stackalloc byte[guidLength]; - - int i = 0; - int j = 0; - fixed (short* ps = s_char2val) - { - short* _char2val = ps; - - // 0 1 2 3 4 - // 012345678901234567890123456789012345678901234 - // urn:uuid:aabbccdd-eeff-gghh-0011-223344556677 - // - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 - // ddccbbaaffeehhgg0011223344556677 - - i = UnsafeDecode(_char2val, chars[15], chars[16]); bytes[0] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[13], chars[14]); bytes[1] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[11], chars[12]); bytes[2] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[9], chars[10]); bytes[3] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[20], chars[21]); bytes[4] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[18], chars[19]); bytes[5] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[25], chars[26]); bytes[6] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[23], chars[24]); bytes[7] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[28], chars[29]); bytes[8] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[30], chars[31]); bytes[9] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[33], chars[34]); bytes[10] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[35], chars[36]); bytes[11] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[37], chars[38]); bytes[12] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[39], chars[40]); bytes[13] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[41], chars[42]); bytes[14] = (byte)i; j |= i; - i = UnsafeDecode(_char2val, chars[43], chars[44]); bytes[15] = (byte)i; j |= i; - - if (j >= 0x100) - return; - - _idLow = UnsafeGetInt64(bytes); - _idHigh = UnsafeGetInt64(&bytes[8]); - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public int ToCharArray(char[] chars, int offset) - { - int count = CharArrayLength; - - if (chars == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars")); - - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > chars.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, chars.Length))); - - if (count > chars.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("chars", string.Format(SRSerialization.XmlArrayTooSmallOutput, count))); - - if (_s != null) - { - _s.CopyTo(0, chars, offset, count); - } - else - { - byte* bytes = stackalloc byte[guidLength]; - UnsafeSetInt64(_idLow, bytes); - UnsafeSetInt64(_idHigh, &bytes[8]); - - fixed (char* _pch = &chars[offset]) - { - char* pch = _pch; - pch[0] = 'u'; - pch[1] = 'r'; - pch[2] = 'n'; - pch[3] = ':'; - pch[4] = 'u'; - pch[5] = 'u'; - pch[6] = 'i'; - pch[7] = 'd'; - pch[8] = ':'; - pch[17] = '-'; - pch[22] = '-'; - pch[27] = '-'; - pch[32] = '-'; - - fixed (char* ps = val2char) - { - char* _val2char = ps; - UnsafeEncode(_val2char, bytes[0], &pch[15]); - UnsafeEncode(_val2char, bytes[1], &pch[13]); - UnsafeEncode(_val2char, bytes[2], &pch[11]); - UnsafeEncode(_val2char, bytes[3], &pch[9]); - UnsafeEncode(_val2char, bytes[4], &pch[20]); - UnsafeEncode(_val2char, bytes[5], &pch[18]); - UnsafeEncode(_val2char, bytes[6], &pch[25]); - UnsafeEncode(_val2char, bytes[7], &pch[23]); - UnsafeEncode(_val2char, bytes[8], &pch[28]); - UnsafeEncode(_val2char, bytes[9], &pch[30]); - UnsafeEncode(_val2char, bytes[10], &pch[33]); - UnsafeEncode(_val2char, bytes[11], &pch[35]); - UnsafeEncode(_val2char, bytes[12], &pch[37]); - UnsafeEncode(_val2char, bytes[13], &pch[39]); - UnsafeEncode(_val2char, bytes[14], &pch[41]); - UnsafeEncode(_val2char, bytes[15], &pch[43]); - } - } - } - - return count; - } - - public bool TryGetGuid(out Guid guid) - { - byte[] buffer = new byte[guidLength]; - if (!TryGetGuid(buffer, 0)) - { - guid = Guid.Empty; - return false; - } - - guid = new Guid(buffer); - return true; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public bool TryGetGuid(byte[] buffer, int offset) - { - if (!IsGuid) - return false; - - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); - - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > buffer.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, buffer.Length))); - - if (guidLength > buffer.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("buffer", string.Format(SRSerialization.XmlArrayTooSmallOutput, guidLength))); - - fixed (byte* pb = &buffer[offset]) - { - UnsafeSetInt64(_idLow, pb); - UnsafeSetInt64(_idHigh, &pb[8]); - } - - return true; - } - - /// - /// Critical - accesses critical field 's'. - /// Safe - doesn't allow unchecked write access to the field - /// - [SecuritySafeCritical] - unsafe public override string ToString() - { - if (_s == null) - { - int length = CharArrayLength; - char[] chars = new char[length]; - ToCharArray(chars, 0); - _s = new string(chars, 0, length); - } - return _s; - } - - static public bool operator ==(UniqueId id1, UniqueId id2) - { - if (object.ReferenceEquals(id1, id2)) - return true; - - if (object.ReferenceEquals(id1, null) || object.ReferenceEquals(id2, null)) - return false; - -#pragma warning disable 56506 // Microsoft, checks for whether id1 and id2 are null done above. - if (id1.IsGuid && id2.IsGuid) - { - return id1._idLow == id2._idLow && id1._idHigh == id2._idHigh; - } - - return id1.ToString() == id2.ToString(); - } - - static public bool operator !=(UniqueId id1, UniqueId id2) - { - return !(id1 == id2); - } - - public override bool Equals(object obj) - { - return this == (obj as UniqueId); - } - - public override int GetHashCode() - { - if (IsGuid) - { - Int64 hash = (_idLow ^ _idHigh); - return ((int)(hash >> 32)) ^ ((int)hash); - } - else - { - return ToString().GetHashCode(); - } - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe Int64 UnsafeGetInt64(byte* pb) - { - Int32 idLow = UnsafeGetInt32(pb); - Int32 idHigh = UnsafeGetInt32(&pb[4]); - return (((Int64)idHigh) << 32) | ((UInt32)idLow); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe Int32 UnsafeGetInt32(byte* pb) - { - int value = pb[3]; - value <<= 8; - value |= pb[2]; - value <<= 8; - value |= pb[1]; - value <<= 8; - value |= pb[0]; - return value; - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeSetInt64(Int64 value, byte* pb) - { - UnsafeSetInt32((int)value, pb); - UnsafeSetInt32((int)(value >> 32), &pb[4]); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeSetInt32(Int32 value, byte* pb) - { - pb[0] = (byte)value; - value >>= 8; - pb[1] = (byte)value; - value >>= 8; - pb[2] = (byte)value; - value >>= 8; - pb[3] = (byte)value; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ValueHandle.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ValueHandle.cs deleted file mode 100644 index 7f5f280882a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/ValueHandle.cs +++ /dev/null @@ -1,927 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.Serialization; -using System.Diagnostics; -using System.Globalization; -using System.Text; - - -namespace Microsoft.Xml -{ - using System; - - internal enum ValueHandleConstStringType - { - String = 0, - Number = 1, - Array = 2, - Object = 3, - Boolean = 4, - Null = 5, - } - - internal static class ValueHandleLength - { - public const int Int8 = 1; - public const int Int16 = 2; - public const int Int32 = 4; - public const int Int64 = 8; - public const int UInt64 = 8; - public const int Single = 4; - public const int Double = 8; - public const int Decimal = 16; - public const int DateTime = 8; - public const int TimeSpan = 8; - public const int Guid = 16; - public const int UniqueId = 16; - } - - internal enum ValueHandleType - { - Empty, - True, - False, - Zero, - One, - Int8, - Int16, - Int32, - Int64, - UInt64, - Single, - Double, - Decimal, - DateTime, - TimeSpan, - Guid, - UniqueId, - UTF8, - EscapedUTF8, - Base64, - Dictionary, - List, - Char, - Unicode, - QName, - ConstString - } - - internal class ValueHandle - { - private XmlBufferReader _bufferReader; - private ValueHandleType _type; - private int _offset; - private int _length; - private static Base64Encoding s_base64Encoding; - private static string[] s_constStrings = { - "string", - "number", - "array", - "object", - "boolean", - "null", - }; - - public ValueHandle(XmlBufferReader bufferReader) - { - _bufferReader = bufferReader; - _type = ValueHandleType.Empty; - } - - private static Base64Encoding Base64Encoding - { - get - { - if (s_base64Encoding == null) - s_base64Encoding = new Base64Encoding(); - return s_base64Encoding; - } - } - public void SetConstantValue(ValueHandleConstStringType constStringType) - { - _type = ValueHandleType.ConstString; - _offset = (int)constStringType; - } - - public void SetValue(ValueHandleType type) - { - _type = type; - } - - public void SetDictionaryValue(int key) - { - SetValue(ValueHandleType.Dictionary, key, 0); - } - - public void SetCharValue(int ch) - { - SetValue(ValueHandleType.Char, ch, 0); - } - - public void SetQNameValue(int prefix, int key) - { - SetValue(ValueHandleType.QName, key, prefix); - } - public void SetValue(ValueHandleType type, int offset, int length) - { - _type = type; - _offset = offset; - _length = length; - } - - public bool IsWhitespace() - { - switch (_type) - { - case ValueHandleType.UTF8: - return _bufferReader.IsWhitespaceUTF8(_offset, _length); - - case ValueHandleType.Dictionary: - return _bufferReader.IsWhitespaceKey(_offset); - - case ValueHandleType.Char: - int ch = GetChar(); - if (ch > char.MaxValue) - return false; - return XmlConverter.IsWhitespace((char)ch); - - case ValueHandleType.EscapedUTF8: - return _bufferReader.IsWhitespaceUTF8(_offset, _length); - - case ValueHandleType.Unicode: - return _bufferReader.IsWhitespaceUnicode(_offset, _length); - - case ValueHandleType.True: - case ValueHandleType.False: - case ValueHandleType.Zero: - case ValueHandleType.One: - return false; - - case ValueHandleType.ConstString: - return s_constStrings[_offset].Length == 0; - - default: - return _length == 0; - } - } - - public Type ToType() - { - switch (_type) - { - case ValueHandleType.False: - case ValueHandleType.True: - return typeof(bool); - case ValueHandleType.Zero: - case ValueHandleType.One: - case ValueHandleType.Int8: - case ValueHandleType.Int16: - case ValueHandleType.Int32: - return typeof(int); - case ValueHandleType.Int64: - return typeof(long); - case ValueHandleType.UInt64: - return typeof(ulong); - case ValueHandleType.Single: - return typeof(float); - case ValueHandleType.Double: - return typeof(double); - case ValueHandleType.Decimal: - return typeof(decimal); - case ValueHandleType.DateTime: - return typeof(DateTime); - case ValueHandleType.Empty: - case ValueHandleType.UTF8: - case ValueHandleType.Unicode: - case ValueHandleType.EscapedUTF8: - case ValueHandleType.Dictionary: - case ValueHandleType.Char: - case ValueHandleType.QName: - case ValueHandleType.ConstString: - return typeof(string); - case ValueHandleType.Base64: - return typeof(byte[]); - case ValueHandleType.List: - return typeof(object[]); - case ValueHandleType.UniqueId: - return typeof(UniqueId); - case ValueHandleType.Guid: - return typeof(Guid); - case ValueHandleType.TimeSpan: - return typeof(TimeSpan); - default: - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException()); - } - } - - public Boolean ToBoolean() - { - ValueHandleType type = _type; - if (type == ValueHandleType.False) - return false; - if (type == ValueHandleType.True) - return true; - if (type == ValueHandleType.UTF8) - return XmlConverter.ToBoolean(_bufferReader.Buffer, _offset, _length); - if (type == ValueHandleType.Int8) - { - int value = GetInt8(); - if (value == 0) - return false; - if (value == 1) - return true; - } - return XmlConverter.ToBoolean(GetString()); - } - - public int ToInt() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type == ValueHandleType.Int8) - return GetInt8(); - if (type == ValueHandleType.Int16) - return GetInt16(); - if (type == ValueHandleType.Int32) - return GetInt32(); - if (type == ValueHandleType.Int64) - { - long value = GetInt64(); - if (value >= int.MinValue && value <= int.MaxValue) - { - return (int)value; - } - } - if (type == ValueHandleType.UInt64) - { - ulong value = GetUInt64(); - if (value <= int.MaxValue) - { - return (int)value; - } - } - if (type == ValueHandleType.UTF8) - return XmlConverter.ToInt32(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToInt32(GetString()); - } - - public long ToLong() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type == ValueHandleType.Int8) - return GetInt8(); - if (type == ValueHandleType.Int16) - return GetInt16(); - if (type == ValueHandleType.Int32) - return GetInt32(); - if (type == ValueHandleType.Int64) - return GetInt64(); - if (type == ValueHandleType.UInt64) - { - ulong value = GetUInt64(); - if (value <= long.MaxValue) - { - return (long)value; - } - } - if (type == ValueHandleType.UTF8) - { - return XmlConverter.ToInt64(_bufferReader.Buffer, _offset, _length); - } - return XmlConverter.ToInt64(GetString()); - } - - public ulong ToULong() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type >= ValueHandleType.Int8 && type <= ValueHandleType.Int64) - { - long value = ToLong(); - if (value >= 0) - return (ulong)value; - } - if (type == ValueHandleType.UInt64) - return GetUInt64(); - if (type == ValueHandleType.UTF8) - return XmlConverter.ToUInt64(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToUInt64(GetString()); - } - - public Single ToSingle() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Single) - return GetSingle(); - if (type == ValueHandleType.Double) - { - double value = GetDouble(); - if ((value >= Single.MinValue && value <= Single.MaxValue) || double.IsInfinity(value) || double.IsNaN(value)) - return (Single)value; - } - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type == ValueHandleType.Int8) - return GetInt8(); - if (type == ValueHandleType.Int16) - return GetInt16(); - if (type == ValueHandleType.UTF8) - return XmlConverter.ToSingle(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToSingle(GetString()); - } - - public Double ToDouble() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Double) - return GetDouble(); - if (type == ValueHandleType.Single) - return GetSingle(); - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type == ValueHandleType.Int8) - return GetInt8(); - if (type == ValueHandleType.Int16) - return GetInt16(); - if (type == ValueHandleType.Int32) - return GetInt32(); - if (type == ValueHandleType.UTF8) - return XmlConverter.ToDouble(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToDouble(GetString()); - } - - public Decimal ToDecimal() - { - ValueHandleType type = _type; - if (type == ValueHandleType.Decimal) - return GetDecimal(); - if (type == ValueHandleType.Zero) - return 0; - if (type == ValueHandleType.One) - return 1; - if (type >= ValueHandleType.Int8 && type <= ValueHandleType.Int64) - return ToLong(); - if (type == ValueHandleType.UInt64) - return GetUInt64(); - if (type == ValueHandleType.UTF8) - return XmlConverter.ToDecimal(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToDecimal(GetString()); - } - - public DateTime ToDateTime() - { - if (_type == ValueHandleType.DateTime) - { - return XmlConverter.ToDateTime(GetInt64()); - } - if (_type == ValueHandleType.UTF8) - { - return XmlConverter.ToDateTime(_bufferReader.Buffer, _offset, _length); - } - return XmlConverter.ToDateTime(GetString()); - } - - public UniqueId ToUniqueId() - { - if (_type == ValueHandleType.UniqueId) - return GetUniqueId(); - if (_type == ValueHandleType.UTF8) - return XmlConverter.ToUniqueId(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToUniqueId(GetString()); - } - - public TimeSpan ToTimeSpan() - { - if (_type == ValueHandleType.TimeSpan) - return new TimeSpan(GetInt64()); - if (_type == ValueHandleType.UTF8) - return XmlConverter.ToTimeSpan(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToTimeSpan(GetString()); - } - - public Guid ToGuid() - { - if (_type == ValueHandleType.Guid) - return GetGuid(); - if (_type == ValueHandleType.UTF8) - return XmlConverter.ToGuid(_bufferReader.Buffer, _offset, _length); - return XmlConverter.ToGuid(GetString()); - } - public override string ToString() - { - return GetString(); - } - - public byte[] ToByteArray() - { - if (_type == ValueHandleType.Base64) - { - byte[] buffer = new byte[_length]; - GetBase64(buffer, 0, _length); - return buffer; - } - if (_type == ValueHandleType.UTF8 && (_length % 4) == 0) - { - try - { - int expectedLength = _length / 4 * 3; - if (_length > 0) - { - if (_bufferReader.Buffer[_offset + _length - 1] == '=') - { - expectedLength--; - if (_bufferReader.Buffer[_offset + _length - 2] == '=') - expectedLength--; - } - } - byte[] buffer = new byte[expectedLength]; - int actualLength = Base64Encoding.GetBytes(_bufferReader.Buffer, _offset, _length, buffer, 0); - if (actualLength != buffer.Length) - { - byte[] newBuffer = new byte[actualLength]; - Buffer.BlockCopy(buffer, 0, newBuffer, 0, actualLength); - buffer = newBuffer; - } - return buffer; - } - catch (FormatException) - { - // Something unhappy with the characters, fall back to the hard way - } - } - try - { - return Base64Encoding.GetBytes(XmlConverter.StripWhitespace(GetString())); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(exception.Message, exception.InnerException)); - } - } - - public string GetString() - { - ValueHandleType type = _type; - if (type == ValueHandleType.UTF8) - return GetCharsText(); - - switch (type) - { - case ValueHandleType.False: - return "false"; - case ValueHandleType.True: - return "true"; - case ValueHandleType.Zero: - return "0"; - case ValueHandleType.One: - return "1"; - case ValueHandleType.Int8: - case ValueHandleType.Int16: - case ValueHandleType.Int32: - return XmlConverter.ToString(ToInt()); - case ValueHandleType.Int64: - return XmlConverter.ToString(GetInt64()); - case ValueHandleType.UInt64: - return XmlConverter.ToString(GetUInt64()); - case ValueHandleType.Single: - return XmlConverter.ToString(GetSingle()); - case ValueHandleType.Double: - return XmlConverter.ToString(GetDouble()); - case ValueHandleType.Decimal: - return XmlConverter.ToString(GetDecimal()); - case ValueHandleType.DateTime: - return XmlConverter.ToString(ToDateTime()); - case ValueHandleType.Empty: - return string.Empty; - case ValueHandleType.UTF8: - return GetCharsText(); - case ValueHandleType.Unicode: - return GetUnicodeCharsText(); - case ValueHandleType.EscapedUTF8: - return GetEscapedCharsText(); - case ValueHandleType.Char: - return GetCharText(); - case ValueHandleType.Dictionary: - return GetDictionaryString().Value; - case ValueHandleType.Base64: - byte[] bytes = ToByteArray(); - DiagnosticUtility.DebugAssert(bytes != null, ""); - return Base64Encoding.GetString(bytes, 0, bytes.Length); - case ValueHandleType.List: - return XmlConverter.ToString(ToList()); - case ValueHandleType.UniqueId: - return XmlConverter.ToString(ToUniqueId()); - case ValueHandleType.Guid: - return XmlConverter.ToString(ToGuid()); - case ValueHandleType.TimeSpan: - return XmlConverter.ToString(ToTimeSpan()); - case ValueHandleType.QName: - return GetQNameDictionaryText(); - case ValueHandleType.ConstString: - return s_constStrings[_offset]; - default: - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException()); - } - } - - // ASSUMPTION (Microsoft): all chars in str will be ASCII - public bool Equals2(string str, bool checkLower) - { - if (_type != ValueHandleType.UTF8) - return GetString() == str; - - if (_length != str.Length) - return false; - - byte[] buffer = _bufferReader.Buffer; - for (int i = 0; i < _length; ++i) - { - DiagnosticUtility.DebugAssert(str[i] < 128, ""); - byte ch = buffer[i + _offset]; - if (ch == str[i]) - continue; - - if (checkLower && char.ToLowerInvariant((char)ch) == str[i]) - continue; - - return false; - } - - return true; - } - - - public object[] ToList() - { - return _bufferReader.GetList(_offset, _length); - } - - public object ToObject() - { - switch (_type) - { - case ValueHandleType.False: - case ValueHandleType.True: - return ToBoolean(); - case ValueHandleType.Zero: - case ValueHandleType.One: - case ValueHandleType.Int8: - case ValueHandleType.Int16: - case ValueHandleType.Int32: - return ToInt(); - case ValueHandleType.Int64: - return ToLong(); - case ValueHandleType.UInt64: - return GetUInt64(); - case ValueHandleType.Single: - return ToSingle(); - case ValueHandleType.Double: - return ToDouble(); - case ValueHandleType.Decimal: - return ToDecimal(); - case ValueHandleType.DateTime: - return ToDateTime(); - case ValueHandleType.Empty: - case ValueHandleType.UTF8: - case ValueHandleType.Unicode: - case ValueHandleType.EscapedUTF8: - case ValueHandleType.Dictionary: - case ValueHandleType.Char: - case ValueHandleType.ConstString: - return ToString(); - case ValueHandleType.Base64: - return ToByteArray(); - case ValueHandleType.List: - return ToList(); - case ValueHandleType.UniqueId: - return ToUniqueId(); - case ValueHandleType.Guid: - return ToGuid(); - case ValueHandleType.TimeSpan: - return ToTimeSpan(); - default: - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException()); - } - } - - public bool TryReadBase64(byte[] buffer, int offset, int count, out int actual) - { - if (_type == ValueHandleType.Base64) - { - actual = Math.Min(_length, count); - GetBase64(buffer, offset, actual); - _offset += actual; - _length -= actual; - return true; - } - if (_type == ValueHandleType.UTF8 && count >= 3 && (_length % 4) == 0) - { - try - { - int charCount = Math.Min(count / 3 * 4, _length); - actual = Base64Encoding.GetBytes(_bufferReader.Buffer, _offset, charCount, buffer, offset); - _offset += charCount; - _length -= charCount; - return true; - } - catch (FormatException) - { - // Something unhappy with the characters, fall back to the hard way - } - } - actual = 0; - return false; - } - - public bool TryReadChars(char[] chars, int offset, int count, out int actual) - { - DiagnosticUtility.DebugAssert(offset + count <= chars.Length, string.Format("offset '{0}' + count '{1}' MUST BE <= chars.Length '{2}'", offset, count, chars.Length)); - - if (_type == ValueHandleType.Unicode) - return TryReadUnicodeChars(chars, offset, count, out actual); - - if (_type != ValueHandleType.UTF8) - { - actual = 0; - return false; - } - - int charOffset = offset; - int charCount = count; - byte[] bytes = _bufferReader.Buffer; - int byteOffset = _offset; - int byteCount = _length; - bool insufficientSpaceInCharsArray = false; - - while (true) - { - while (charCount > 0 && byteCount > 0) - { - // fast path for codepoints U+0000 - U+007F - byte b = bytes[byteOffset]; - if (b >= 0x80) - break; - chars[charOffset] = (char)b; - byteOffset++; - byteCount--; - charOffset++; - charCount--; - } - - if (charCount == 0 || byteCount == 0 || insufficientSpaceInCharsArray) - break; - - int actualByteCount; - int actualCharCount; - - UTF8Encoding encoding = new UTF8Encoding(false, true); - try - { - // If we're asking for more than are possibly available, or more than are truly available then we can return the entire thing - if (charCount >= encoding.GetMaxCharCount(byteCount) || charCount >= encoding.GetCharCount(bytes, byteOffset, byteCount)) - { - actualCharCount = encoding.GetChars(bytes, byteOffset, byteCount, chars, charOffset); - actualByteCount = byteCount; - } - else - { - Decoder decoder = encoding.GetDecoder(); - - // Since x bytes can never generate more than x characters this is a safe estimate as to what will fit - actualByteCount = Math.Min(charCount, byteCount); - - // We use a decoder so we don't error if we fall across a character boundary - actualCharCount = decoder.GetChars(bytes, byteOffset, actualByteCount, chars, charOffset); - - // We might've gotten zero characters though if < 4 bytes were requested because - // codepoints from U+0000 - U+FFFF can be up to 3 bytes in UTF-8, and represented as ONE char - // codepoints from U+10000 - U+10FFFF (last Unicode codepoint representable in UTF-8) are represented by up to 4 bytes in UTF-8 - // and represented as TWO chars (high+low surrogate) - // (e.g. 1 char requested, 1 char in the buffer represented in 3 bytes) - while (actualCharCount == 0) - { - // Note the by the time we arrive here, if actualByteCount == 3, the next decoder.GetChars() call will read the 4th byte - // if we don't bail out since the while loop will advance actualByteCount only after reading the byte. - if (actualByteCount >= 3 && charCount < 2) - { - // If we reach here, it means that we're: - // - trying to decode more than 3 bytes and, - // - there is only one char left of charCount where we're stuffing decoded characters. - // In this case, we need to back off since decoding > 3 bytes in UTF-8 means that we will get 2 16-bit chars - // (a high surrogate and a low surrogate) - the Decoder will attempt to provide both at once - // and an ArgumentException will be thrown complaining that there's not enough space in the output char array. - - // actualByteCount = 0 when the while loop is broken out of; decoder goes out of scope so its state no longer matters - - insufficientSpaceInCharsArray = true; - break; - } - else - { - DiagnosticUtility.DebugAssert(byteOffset + actualByteCount < bytes.Length, - string.Format("byteOffset {0} + actualByteCount {1} MUST BE < bytes.Length {2}", byteOffset, actualByteCount, bytes.Length)); - - // Request a few more bytes to get at least one character - actualCharCount = decoder.GetChars(bytes, byteOffset + actualByteCount, 1, chars, charOffset); - actualByteCount++; - } - } - - // Now that we actually retrieved some characters, figure out how many bytes it actually was - actualByteCount = encoding.GetByteCount(chars, charOffset, actualCharCount); - } - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateEncodingException(bytes, byteOffset, byteCount, exception)); - } - - // Advance - byteOffset += actualByteCount; - byteCount -= actualByteCount; - - charOffset += actualCharCount; - charCount -= actualCharCount; - } - - _offset = byteOffset; - _length = byteCount; - - actual = (count - charCount); - return true; - } - - private bool TryReadUnicodeChars(char[] chars, int offset, int count, out int actual) - { - int charCount = Math.Min(count, _length / sizeof(char)); - for (int i = 0; i < charCount; i++) - { - chars[offset + i] = (char)_bufferReader.GetInt16(_offset + i * sizeof(char)); - } - _offset += charCount * sizeof(char); - _length -= charCount * sizeof(char); - actual = charCount; - return true; - } - - public bool TryGetDictionaryString(out XmlDictionaryString value) - { - if (_type == ValueHandleType.Dictionary) - { - value = GetDictionaryString(); - return true; - } - else - { - value = null; - return false; - } - } - - public bool TryGetByteArrayLength(out int length) - { - if (_type == ValueHandleType.Base64) - { - length = _length; - return true; - } - length = 0; - return false; - } - private string GetCharsText() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.UTF8, ""); - if (_length == 1 && _bufferReader.GetByte(_offset) == '1') - return "1"; - return _bufferReader.GetString(_offset, _length); - } - - private string GetUnicodeCharsText() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Unicode, ""); - return _bufferReader.GetUnicodeString(_offset, _length); - } - - private string GetEscapedCharsText() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.EscapedUTF8, ""); - return _bufferReader.GetEscapedString(_offset, _length); - } - private string GetCharText() - { - int ch = GetChar(); - if (ch > char.MaxValue) - { - SurrogateChar surrogate = new SurrogateChar(ch); - char[] chars = new char[2]; - chars[0] = surrogate.HighChar; - chars[1] = surrogate.LowChar; - return new string(chars, 0, 2); - } - else - { - return ((char)ch).ToString(); - } - } - - private int GetChar() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Char, ""); - return _offset; - } - - private int GetInt8() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Int8, ""); - return _bufferReader.GetInt8(_offset); - } - - private int GetInt16() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Int16, ""); - return _bufferReader.GetInt16(_offset); - } - - private int GetInt32() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Int32, ""); - return _bufferReader.GetInt32(_offset); - } - - private long GetInt64() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Int64 || _type == ValueHandleType.TimeSpan || _type == ValueHandleType.DateTime, ""); - return _bufferReader.GetInt64(_offset); - } - - private ulong GetUInt64() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.UInt64, ""); - return _bufferReader.GetUInt64(_offset); - } - - private float GetSingle() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Single, ""); - return _bufferReader.GetSingle(_offset); - } - - private double GetDouble() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Double, ""); - return _bufferReader.GetDouble(_offset); - } - - private decimal GetDecimal() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Decimal, ""); - return _bufferReader.GetDecimal(_offset); - } - - private UniqueId GetUniqueId() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.UniqueId, ""); - return _bufferReader.GetUniqueId(_offset); - } - - private Guid GetGuid() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Guid, ""); - return _bufferReader.GetGuid(_offset); - } - - private void GetBase64(byte[] buffer, int offset, int count) - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Base64, ""); - _bufferReader.GetBase64(_offset, buffer, offset, count); - } - - private XmlDictionaryString GetDictionaryString() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.Dictionary, ""); - return _bufferReader.GetDictionaryString(_offset); - } - - private string GetQNameDictionaryText() - { - DiagnosticUtility.DebugAssert(_type == ValueHandleType.QName, ""); - return string.Concat(PrefixHandle.GetString(PrefixHandle.GetAlphaPrefix(_length)), ":", _bufferReader.GetDictionaryString(_offset)); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseReader.cs deleted file mode 100644 index 47da3a8b232..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseReader.cs +++ /dev/null @@ -1,2940 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; -using System.Globalization; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; - - -namespace Microsoft.Xml -{ - // Large numbers of attributes - // Use delimiter on node for figuring out Element/EndElement? - // Optimize StringHandle.CompareTo - // Fix FixXmlAttribute - Temporary until we actually write an XmlAttribute node - - internal abstract class XmlBaseReader : XmlDictionaryReader - { - private XmlBufferReader _bufferReader; - private XmlNode _node; - private NamespaceManager _nsMgr; - private XmlElementNode[] _elementNodes; - private XmlAttributeNode[] _attributeNodes; - private XmlAtomicTextNode _atomicTextNode; - private int _depth; - private int _attributeCount; - private int _attributeStart; // Starting index for searching - private XmlDictionaryReaderQuotas _quotas; - private XmlNameTable _nameTable; - private XmlDeclarationNode _declarationNode; - private XmlComplexTextNode _complexTextNode; - private XmlWhitespaceTextNode _whitespaceTextNode; - private XmlCDataNode _cdataNode; - private XmlCommentNode _commentNode; - private XmlElementNode _rootElementNode; - private int _attributeIndex; // Index for iteration - private char[] _chars; - private string _prefix; - private string _localName; - private string _ns; - private string _value; - private int _trailCharCount; - private int _trailByteCount; - private char[] _trailChars; - private byte[] _trailBytes; - private bool _rootElement; - private bool _readingElement; - private AttributeSorter _attributeSorter; - private static XmlInitialNode s_initialNode = new XmlInitialNode(XmlBufferReader.Empty); - private static XmlEndOfFileNode s_endOfFileNode = new XmlEndOfFileNode(XmlBufferReader.Empty); - private static XmlClosedNode s_closedNode = new XmlClosedNode(XmlBufferReader.Empty); - private static Base64Encoding s_base64Encoding; - private const string xmlns = "xmlns"; - private const string xml = "xml"; - private const string xmlnsNamespace = "http://www.w3.org/2000/xmlns/"; - private const string xmlNamespace = "http://www.w3.org/XML/1998/namespace"; - - - protected XmlBaseReader() - { - _bufferReader = new XmlBufferReader(this); - _nsMgr = new NamespaceManager(_bufferReader); - _quotas = new XmlDictionaryReaderQuotas(); - _rootElementNode = new XmlElementNode(_bufferReader); - _atomicTextNode = new XmlAtomicTextNode(_bufferReader); - _node = s_closedNode; - } - - - private static Base64Encoding Base64Encoding - { - get - { - if (s_base64Encoding == null) - s_base64Encoding = new Base64Encoding(); - return s_base64Encoding; - } - } - - protected XmlBufferReader BufferReader - { - get - { - return _bufferReader; - } - } - - public override XmlDictionaryReaderQuotas Quotas - { - get - { - return _quotas; - } - } - - protected XmlNode Node - { - get - { - return _node; - } - } - - protected void MoveToNode(XmlNode node) - { - _node = node; - _ns = null; - _localName = null; - _prefix = null; - _value = null; - } - - protected void MoveToInitial(XmlDictionaryReaderQuotas quotas) - { - if (quotas == null) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("quotas"); - - quotas.InternalCopyTo(_quotas); - _quotas.MakeReadOnly(); - _nsMgr.Clear(); - _depth = 0; - _attributeCount = 0; - _attributeStart = -1; - _attributeIndex = -1; - _rootElement = false; - _readingElement = false; - MoveToNode(s_initialNode); - } - - protected XmlDeclarationNode MoveToDeclaration() - { - if (_attributeCount < 1) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlDeclMissingVersion))); - - if (_attributeCount > 3) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlMalformedDecl))); - - // version - if (!CheckDeclAttribute(0, "version", "1.0", false, SRSerialization.XmlInvalidVersion)) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlDeclMissingVersion))); - - // encoding/standalone - // We only validate that they are the only attributes that exist. Encoding can have any value. - if (_attributeCount > 1) - { - if (CheckDeclAttribute(1, "encoding", null, true, SRSerialization.XmlInvalidEncoding)) - { - if (_attributeCount == 3 && !CheckStandalone(2)) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlMalformedDecl))); - } - else if (!CheckStandalone(1) || _attributeCount > 2) - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlMalformedDecl))); - } - } - - if (_declarationNode == null) - { - _declarationNode = new XmlDeclarationNode(_bufferReader); - } - MoveToNode(_declarationNode); - return _declarationNode; - } - - private bool CheckStandalone(int attr) - { - XmlAttributeNode node = _attributeNodes[attr]; - if (!node.Prefix.IsEmpty) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlMalformedDecl))); - - if (node.LocalName != "standalone") - return false; - - if (!node.Value.Equals2("yes", false) && !node.Value.Equals2("no", false)) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlInvalidStandalone))); - - return true; - } - - private bool CheckDeclAttribute(int index, string localName, string value, bool checkLower, string valueSR) - { - XmlAttributeNode node = _attributeNodes[index]; - if (!node.Prefix.IsEmpty) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlMalformedDecl))); - - if (node.LocalName != localName) - return false; - - if (value != null && !node.Value.Equals2(value, checkLower)) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(valueSR))); - - return true; - } - protected XmlCommentNode MoveToComment() - { - if (_commentNode == null) - { - _commentNode = new XmlCommentNode(_bufferReader); - } - MoveToNode(_commentNode); - return _commentNode; - } - - protected XmlCDataNode MoveToCData() - { - if (_cdataNode == null) - { - _cdataNode = new XmlCDataNode(_bufferReader); - } - MoveToNode(_cdataNode); - return _cdataNode; - } - - protected XmlAtomicTextNode MoveToAtomicText() - { - XmlAtomicTextNode textNode = _atomicTextNode; - MoveToNode(textNode); - return textNode; - } - - protected XmlComplexTextNode MoveToComplexText() - { - if (_complexTextNode == null) - { - _complexTextNode = new XmlComplexTextNode(_bufferReader); - } - MoveToNode(_complexTextNode); - return _complexTextNode; - } - - protected XmlTextNode MoveToWhitespaceText() - { - if (_whitespaceTextNode == null) - { - _whitespaceTextNode = new XmlWhitespaceTextNode(_bufferReader); - } - if (_nsMgr.XmlSpace == XmlSpace.Preserve) - _whitespaceTextNode.NodeType = XmlNodeType.SignificantWhitespace; - else - _whitespaceTextNode.NodeType = XmlNodeType.Whitespace; - MoveToNode(_whitespaceTextNode); - return _whitespaceTextNode; - } - protected XmlElementNode ElementNode - { - get - { - if (_depth == 0) - return _rootElementNode; - else - return _elementNodes[_depth]; - } - } - - protected void MoveToEndElement() - { - if (_depth == 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - XmlElementNode elementNode = _elementNodes[_depth]; - XmlEndElementNode endElementNode = elementNode.EndElement; - endElementNode.Namespace = elementNode.Namespace; - MoveToNode(endElementNode); - } - - protected void MoveToEndOfFile() - { - if (_depth != 0) - XmlExceptionHelper.ThrowUnexpectedEndOfFile(this); - MoveToNode(s_endOfFileNode); - } - - protected XmlElementNode EnterScope() - { - if (_depth == 0) - { - if (_rootElement) - XmlExceptionHelper.ThrowMultipleRootElements(this); - _rootElement = true; - } - _nsMgr.EnterScope(); - _depth++; - if (_depth > _quotas.MaxDepth) - XmlExceptionHelper.ThrowMaxDepthExceeded(this, _quotas.MaxDepth); - if (_elementNodes == null) - { - _elementNodes = new XmlElementNode[4]; - } - else if (_elementNodes.Length == _depth) - { - XmlElementNode[] newElementNodes = new XmlElementNode[_depth * 2]; - Array.Copy(_elementNodes, 0, newElementNodes, 0, _depth); - _elementNodes = newElementNodes; - } - XmlElementNode elementNode = _elementNodes[_depth]; - if (elementNode == null) - { - elementNode = new XmlElementNode(_bufferReader); - _elementNodes[_depth] = elementNode; - } - _attributeCount = 0; - _attributeStart = -1; - _attributeIndex = -1; - MoveToNode(elementNode); - return elementNode; - } - - protected void ExitScope() - { - if (_depth == 0) - XmlExceptionHelper.ThrowUnexpectedEndElement(this); - _depth--; - _nsMgr.ExitScope(); - } - - private XmlAttributeNode AddAttribute(QNameType qnameType, bool isAtomicValue) - { - int attributeIndex = _attributeCount; - if (_attributeNodes == null) - { - _attributeNodes = new XmlAttributeNode[4]; - } - else if (_attributeNodes.Length == attributeIndex) - { - XmlAttributeNode[] newAttributeNodes = new XmlAttributeNode[attributeIndex * 2]; - Array.Copy(_attributeNodes, 0, newAttributeNodes, 0, attributeIndex); - _attributeNodes = newAttributeNodes; - } - XmlAttributeNode attributeNode = _attributeNodes[attributeIndex]; - if (attributeNode == null) - { - attributeNode = new XmlAttributeNode(_bufferReader); - _attributeNodes[attributeIndex] = attributeNode; - } - attributeNode.QNameType = qnameType; - attributeNode.IsAtomicValue = isAtomicValue; - attributeNode.AttributeText.QNameType = qnameType; - attributeNode.AttributeText.IsAtomicValue = isAtomicValue; - _attributeCount++; - return attributeNode; - } - - protected Namespace AddNamespace() - { - return _nsMgr.AddNamespace(); - } - - protected XmlAttributeNode AddAttribute() - { - return AddAttribute(QNameType.Normal, true); - } - - protected XmlAttributeNode AddXmlAttribute() - { - return AddAttribute(QNameType.Normal, true); - } - protected XmlAttributeNode AddXmlnsAttribute(Namespace ns) - { - if (!ns.Prefix.IsEmpty && ns.Uri.IsEmpty) - XmlExceptionHelper.ThrowEmptyNamespace(this); - - // Some prefixes can only be bound to a particular namespace - if (ns.Prefix.IsXml && ns.Uri != xmlNamespace) - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlSpecificBindingPrefix, "xml", xmlNamespace))); - } - else if (ns.Prefix.IsXmlns && ns.Uri != xmlnsNamespace) - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlSpecificBindingPrefix, "xmlns", xmlnsNamespace))); - } - - _nsMgr.Register(ns); - XmlAttributeNode attributeNode = AddAttribute(QNameType.Xmlns, false); - attributeNode.Namespace = ns; - attributeNode.AttributeText.Namespace = ns; - return attributeNode; - } - - protected void FixXmlAttribute(XmlAttributeNode attributeNode) - { - if (attributeNode.Prefix == xml) - { - if (attributeNode.LocalName == "lang") - { - _nsMgr.AddLangAttribute(attributeNode.Value.GetString()); - } - else if (attributeNode.LocalName == "space") - { - string value = attributeNode.Value.GetString(); - if (value == "preserve") - { - _nsMgr.AddSpaceAttribute(XmlSpace.Preserve); - } - else if (value == "default") - { - _nsMgr.AddSpaceAttribute(XmlSpace.Default); - } - } - } - } - protected bool OutsideRootElement - { - get - { - return _depth == 0; - } - } - public override bool CanReadBinaryContent - { - get { return true; } - } - - public override bool CanReadValueChunk - { - get { return true; } - } - - public override string BaseURI - { - get - { - return string.Empty; - } - } - - public override bool HasValue - { - get - { - return _node.HasValue; - } - } - - public override bool IsDefault - { - get - { - return false; - } - } - - public override string this[int index] - { - get - { - return GetAttribute(index); - } - } - - public override string this[string name] - { - get - { - return GetAttribute(name); - } - } - - public override string this[string localName, string namespaceUri] - { - get - { - return GetAttribute(localName, namespaceUri); - } - } - - public override int AttributeCount - { - get - { - if (_node.CanGetAttribute) - return _attributeCount; - return 0; - } - } - - public override void Close() - { - MoveToNode(s_closedNode); - _nameTable = null; - if (_attributeNodes != null && _attributeNodes.Length > 16) - _attributeNodes = null; - if (_elementNodes != null && _elementNodes.Length > 16) - _elementNodes = null; - _nsMgr.Close(); - _bufferReader.Close(); - if (_attributeSorter != null) - _attributeSorter.Close(); - } - - public sealed override int Depth - { - get - { - // Internally, depth is simply measured by Element/EndElement. What XmlReader exposes is a little different - // so we need to account for this with some minor adjustments. - - // We increment depth immediately when we see an element, but XmlTextReader waits until its consumed - // We decrement depth when its consumed, but XmlTextReader decrements depth immediately - - // If we're on Attribute Text (i.e. ReadAttributeValue), then its considered a level deeper - return _depth + _node.DepthDelta; - } - } - - public override bool EOF - { - get - { - return _node.ReadState == ReadState.EndOfFile; - } - } - - private XmlAttributeNode GetAttributeNode(int index) - { - if (!_node.CanGetAttribute) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("index", string.Format(SRSerialization.XmlElementAttributes))); - if (index < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("index", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (index >= _attributeCount) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("index", string.Format(SRSerialization.OffsetExceedsBufferSize, _attributeCount))); - return _attributeNodes[index]; - } - - private XmlAttributeNode GetAttributeNode(string name) - { - if (name == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("name")); - if (!_node.CanGetAttribute) - return null; - int index = name.IndexOf(':'); - string prefix; - string localName; - if (index == -1) - { - if (name == xmlns) - { - prefix = xmlns; - localName = string.Empty; - } - else - { - prefix = string.Empty; - localName = name; - } - } - else - { - // If this function becomes a performance issue because of the allocated strings then we can - // make a version of Equals that takes an offset and count into the string. - prefix = name.Substring(0, index); - localName = name.Substring(index + 1); - } - XmlAttributeNode[] attributeNodes = _attributeNodes; - int attributeCount = _attributeCount; - int attributeIndex = _attributeStart; - for (int i = 0; i < attributeCount; i++) - { - if (++attributeIndex >= attributeCount) - { - attributeIndex = 0; - } - XmlAttributeNode attributeNode = attributeNodes[attributeIndex]; - if (attributeNode.IsPrefixAndLocalName(prefix, localName)) - { - _attributeStart = attributeIndex; - return attributeNode; - } - } - return null; - } - - private XmlAttributeNode GetAttributeNode(string localName, string namespaceUri) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName")); - if (namespaceUri == null) - namespaceUri = string.Empty; - if (!_node.CanGetAttribute) - return null; - XmlAttributeNode[] attributeNodes = _attributeNodes; - int attributeCount = _attributeCount; - int attributeIndex = _attributeStart; - for (int i = 0; i < attributeCount; i++) - { - if (++attributeIndex >= attributeCount) - { - attributeIndex = 0; - } - XmlAttributeNode attributeNode = attributeNodes[attributeIndex]; - if (attributeNode.IsLocalNameAndNamespaceUri(localName, namespaceUri)) - { - _attributeStart = attributeIndex; - return attributeNode; - } - } - return null; - } - - private XmlAttributeNode GetAttributeNode(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName")); - if (namespaceUri == null) - namespaceUri = XmlDictionaryString.Empty; - if (!_node.CanGetAttribute) - return null; - XmlAttributeNode[] attributeNodes = _attributeNodes; - int attributeCount = _attributeCount; - int attributeIndex = _attributeStart; - for (int i = 0; i < attributeCount; i++) - { - if (++attributeIndex >= attributeCount) - { - attributeIndex = 0; - } - XmlAttributeNode attributeNode = attributeNodes[attributeIndex]; - if (attributeNode.IsLocalNameAndNamespaceUri(localName, namespaceUri)) - { - _attributeStart = attributeIndex; - return attributeNode; - } - } - return null; - } - - - public override string GetAttribute(int index) - { - return GetAttributeNode(index).ValueAsString; - } - - public override string GetAttribute(string name) - { - XmlAttributeNode attributeNode = GetAttributeNode(name); - if (attributeNode == null) - return null; - return attributeNode.ValueAsString; - } - - public override string GetAttribute(string localName, string namespaceUri) - { - XmlAttributeNode attributeNode = GetAttributeNode(localName, namespaceUri); - if (attributeNode == null) - return null; - return attributeNode.ValueAsString; - } - - public override string GetAttribute(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - XmlAttributeNode attributeNode = GetAttributeNode(localName, namespaceUri); - if (attributeNode == null) - return null; - return attributeNode.ValueAsString; - } - public sealed override bool IsEmptyElement - { - get - { - return _node.IsEmptyElement; - } - } - - public override string LocalName - { - get - { - if (_localName == null) - { - QNameType qnameType = _node.QNameType; - if (qnameType == QNameType.Normal) - { - _localName = _node.LocalName.GetString(NameTable); - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - if (_node.Namespace.Prefix.IsEmpty) - _localName = xmlns; - else - _localName = _node.Namespace.Prefix.GetString(NameTable); - } - } - - return _localName; - } - } - - public override string LookupNamespace(string prefix) - { - Namespace ns = _nsMgr.LookupNamespace(prefix); - if (ns != null) - return ns.Uri.GetString(NameTable); - if (prefix == xmlns) - return xmlnsNamespace; - return null; - } - - protected Namespace LookupNamespace(PrefixHandleType prefix) - { - Namespace ns = _nsMgr.LookupNamespace(prefix); - if (ns == null) - XmlExceptionHelper.ThrowUndefinedPrefix(this, PrefixHandle.GetString(prefix)); - return ns; - } - - protected Namespace LookupNamespace(PrefixHandle prefix) - { - Namespace ns = _nsMgr.LookupNamespace(prefix); - if (ns == null) - XmlExceptionHelper.ThrowUndefinedPrefix(this, prefix.GetString()); - return ns; - } - - protected void ProcessAttributes() - { - if (_attributeCount > 0) - { - ProcessAttributes(_attributeNodes, _attributeCount); - } - } - - private void ProcessAttributes(XmlAttributeNode[] attributeNodes, int attributeCount) - { - for (int i = 0; i < attributeCount; i++) - { - XmlAttributeNode attributeNode = attributeNodes[i]; - if (attributeNode.QNameType == QNameType.Normal) - { - PrefixHandle prefix = attributeNode.Prefix; - if (!prefix.IsEmpty) - { - attributeNode.Namespace = LookupNamespace(prefix); - } - else - { - attributeNode.Namespace = NamespaceManager.EmptyNamespace; - } - attributeNode.AttributeText.Namespace = attributeNode.Namespace; - } - } - - if (attributeCount > 1) - { - if (attributeCount < 12) - { - // For small numbers of attributes, a naive n * (n - 1) / 2 comparisons to check for uniqueness is faster - for (int i = 0; i < attributeCount - 1; i++) - { - XmlAttributeNode attributeNode1 = attributeNodes[i]; - QNameType qnameType = attributeNode1.QNameType; - if (qnameType == QNameType.Normal) - { - for (int j = i + 1; j < attributeCount; j++) - { - XmlAttributeNode attributeNode2 = attributeNodes[j]; - if (attributeNode2.QNameType == QNameType.Normal && attributeNode1.LocalName == attributeNode2.LocalName && attributeNode1.Namespace.Uri == attributeNode2.Namespace.Uri) - { - XmlExceptionHelper.ThrowDuplicateAttribute(this, attributeNode1.Prefix.GetString(), attributeNode2.Prefix.GetString(), attributeNode1.LocalName.GetString(), attributeNode1.Namespace.Uri.GetString()); - } - } - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - for (int j = i + 1; j < attributeCount; j++) - { - XmlAttributeNode attributeNode2 = attributeNodes[j]; - if (attributeNode2.QNameType == QNameType.Xmlns && attributeNode1.Namespace.Prefix == attributeNode2.Namespace.Prefix) - XmlExceptionHelper.ThrowDuplicateAttribute(this, xmlns, xmlns, attributeNode1.Namespace.Prefix.GetString(), xmlnsNamespace); - } - } - } - } - else - { - CheckAttributes(attributeNodes, attributeCount); - } - } - } - - private void CheckAttributes(XmlAttributeNode[] attributeNodes, int attributeCount) - { - // For large numbers of attributes, sorting the attributes (n * lg(n)) is faster - if (_attributeSorter == null) - _attributeSorter = new AttributeSorter(); - - if (!_attributeSorter.Sort(attributeNodes, attributeCount)) - { - int attribute1, attribute2; - _attributeSorter.GetIndeces(out attribute1, out attribute2); - if (attributeNodes[attribute1].QNameType == QNameType.Xmlns) - XmlExceptionHelper.ThrowDuplicateXmlnsAttribute(this, attributeNodes[attribute1].Namespace.Prefix.GetString(), xmlnsNamespace); - else - XmlExceptionHelper.ThrowDuplicateAttribute(this, attributeNodes[attribute1].Prefix.GetString(), attributeNodes[attribute2].Prefix.GetString(), attributeNodes[attribute1].LocalName.GetString(), attributeNodes[attribute1].Namespace.Uri.GetString()); - } - } - - - public override void MoveToAttribute(int index) - { - MoveToNode(GetAttributeNode(index)); - } - public override bool MoveToAttribute(string name) - { - XmlNode attributeNode = GetAttributeNode(name); - if (attributeNode == null) - return false; - MoveToNode(attributeNode); - return true; - } - - public override bool MoveToAttribute(string localName, string namespaceUri) - { - XmlNode attributeNode = GetAttributeNode(localName, namespaceUri); - if (attributeNode == null) - return false; - MoveToNode(attributeNode); - return true; - } - - public override bool MoveToElement() - { - if (!_node.CanMoveToElement) - return false; - if (_depth == 0) - MoveToDeclaration(); - else - MoveToNode(_elementNodes[_depth]); - _attributeIndex = -1; - return true; - } - - public override XmlNodeType MoveToContent() - { - do - { - if (_node.HasContent) - { - if (_node.NodeType != XmlNodeType.Text && _node.NodeType != XmlNodeType.CDATA) - break; - - if (_trailByteCount > 0) - { - break; - } - - if (_value == null) - { - if (!_node.Value.IsWhitespace()) - break; - } - else - { - if (!XmlConverter.IsWhitespace(_value)) - break; - } - } - else - { - if (_node.NodeType == XmlNodeType.Attribute) - { - MoveToElement(); - break; - } - } - } - while (Read()); - return _node.NodeType; - } - - public override bool MoveToFirstAttribute() - { - if (!_node.CanGetAttribute || _attributeCount == 0) - return false; - MoveToNode(GetAttributeNode(0)); - _attributeIndex = 0; - return true; - } - - public override bool MoveToNextAttribute() - { - if (!_node.CanGetAttribute) - return false; - int attributeIndex = _attributeIndex + 1; - if (attributeIndex >= _attributeCount) - return false; - MoveToNode(GetAttributeNode(attributeIndex)); - _attributeIndex = attributeIndex; - return true; - } - - public override string NamespaceURI - { - get - { - if (_ns == null) - { - QNameType qnameType = _node.QNameType; - if (qnameType == QNameType.Normal) - { - _ns = _node.Namespace.Uri.GetString(NameTable); - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - _ns = xmlnsNamespace; - } - } - return _ns; - } - } - - public override XmlNameTable NameTable - { - get - { - if (_nameTable == null) - { - _nameTable = new NameTable(); - _nameTable.Add(xml); - _nameTable.Add(xmlns); - _nameTable.Add(xmlnsNamespace); - _nameTable.Add(xmlNamespace); - for (PrefixHandleType i = PrefixHandleType.A; i <= PrefixHandleType.Z; i++) - { - _nameTable.Add(PrefixHandle.GetString(i)); - } - } - - return _nameTable; - } - } - - public sealed override XmlNodeType NodeType - { - get - { - return _node.NodeType; - } - } - - public override string Prefix - { - get - { - if (_prefix == null) - { - QNameType qnameType = _node.QNameType; - if (qnameType == QNameType.Normal) - { - _prefix = _node.Prefix.GetString(NameTable); - } - else if (qnameType == QNameType.Xmlns) - { - if (_node.Namespace.Prefix.IsEmpty) - _prefix = string.Empty; - else - _prefix = xmlns; - } - else - { - _prefix = xml; - } - } - - return _prefix; - } - } - - - public override bool IsLocalName(string localName) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName")); - return _node.IsLocalName(localName); - } - - public override bool IsLocalName(XmlDictionaryString localName) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName")); - return _node.IsLocalName(localName); - } - public override bool IsNamespaceUri(string namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - return _node.IsNamespaceUri(namespaceUri); - } - - public override bool IsNamespaceUri(XmlDictionaryString namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - return _node.IsNamespaceUri(namespaceUri); - } - public override sealed bool IsStartElement() - { - XmlNodeType nodeType = _node.NodeType; - if (nodeType == XmlNodeType.Element) - return true; - if (nodeType == XmlNodeType.EndElement) - return false; - if (nodeType == XmlNodeType.None) - { - Read(); - if (_node.NodeType == XmlNodeType.Element) - return true; - } - return (MoveToContent() == XmlNodeType.Element); - } - - public override bool IsStartElement(string name) - { - if (name == null) - return false; - int index = name.IndexOf(':'); - string prefix; - string localName; - if (index == -1) - { - prefix = string.Empty; - localName = name; - } - else - { - prefix = name.Substring(0, index); - localName = name.Substring(index + 1); - } - return (_node.NodeType == XmlNodeType.Element || IsStartElement()) && _node.Prefix == prefix && _node.LocalName == localName; - } - - public override bool IsStartElement(string localName, string namespaceUri) - { - if (localName == null) - return false; - if (namespaceUri == null) - return false; - return (_node.NodeType == XmlNodeType.Element || IsStartElement()) && _node.LocalName == localName && _node.IsNamespaceUri(namespaceUri); - } - - public override bool IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localName"); - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - return (_node.NodeType == XmlNodeType.Element || IsStartElement()) && _node.LocalName == localName && _node.IsNamespaceUri(namespaceUri); - } - - public override int IndexOfLocalName(string[] localNames, string namespaceUri) - { - if (localNames == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localNames"); - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - QNameType qnameType = _node.QNameType; - if (_node.IsNamespaceUri(namespaceUri)) - { - if (qnameType == QNameType.Normal) - { - StringHandle localName = _node.LocalName; - for (int i = 0; i < localNames.Length; i++) - { - string value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (localName == value) - { - return i; - } - } - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - PrefixHandle prefix = _node.Namespace.Prefix; - for (int i = 0; i < localNames.Length; i++) - { - string value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (prefix == value) - { - return i; - } - } - } - } - return -1; - } - - public override int IndexOfLocalName(XmlDictionaryString[] localNames, XmlDictionaryString namespaceUri) - { - if (localNames == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localNames"); - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - QNameType qnameType = _node.QNameType; - if (_node.IsNamespaceUri(namespaceUri)) - { - if (qnameType == QNameType.Normal) - { - StringHandle localName = _node.LocalName; - for (int i = 0; i < localNames.Length; i++) - { - XmlDictionaryString value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (localName == value) - { - return i; - } - } - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - PrefixHandle prefix = _node.Namespace.Prefix; - for (int i = 0; i < localNames.Length; i++) - { - XmlDictionaryString value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (prefix == value) - { - return i; - } - } - } - } - return -1; - } - - public override int ReadValueChunk(char[] chars, int offset, int count) - { - if (chars == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > chars.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, chars.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > chars.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, chars.Length - offset))); - int actual; - - if (_value == null) - { - if (_node.QNameType == QNameType.Normal) - { - if (_node.Value.TryReadChars(chars, offset, count, out actual)) - return actual; - } - } - - string value = this.Value; - actual = Math.Min(count, value.Length); - value.CopyTo(0, chars, offset, actual); - _value = value.Substring(actual); - return actual; - } - - public override int ReadValueAsBase64(byte[] buffer, int offset, int count) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > buffer.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, buffer.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > buffer.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); - if (count == 0) - return 0; - int actual; - if (_value == null) - { - if (_trailByteCount == 0 && _trailCharCount == 0) - { - if (_node.QNameType == QNameType.Normal) - { - if (_node.Value.TryReadBase64(buffer, offset, count, out actual)) - return actual; - } - } - } - return ReadBytes(Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), false); - } - - public override string ReadElementContentAsString() - { - if (_node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - - if (_node.IsEmptyElement) - { - Read(); - return string.Empty; - } - else - { - Read(); - string s = ReadContentAsString(); - ReadEndElement(); - return s; - } - } - public override void ReadStartElement() - { - if (_node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - Read(); - } - - public override void ReadStartElement(string name) - { - MoveToStartElement(name); - Read(); - } - - public override void ReadStartElement(string localName, string namespaceUri) - { - MoveToStartElement(localName, namespaceUri); - Read(); - } - - public override void ReadEndElement() - { - if (_node.NodeType != XmlNodeType.EndElement && MoveToContent() != XmlNodeType.EndElement) - { - int nodeDepth = _node.NodeType == XmlNodeType.Element ? _depth - 1 : _depth; - if (nodeDepth == 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.XmlEndElementNoOpenNodes))); - // If depth is non-zero, then the document isn't what was expected - XmlElementNode elementNode = _elementNodes[nodeDepth]; - XmlExceptionHelper.ThrowEndElementExpected(this, elementNode.LocalName.GetString(), elementNode.Namespace.Uri.GetString()); - } - Read(); - } - - public override bool ReadAttributeValue() - { - XmlAttributeTextNode attributeTextNode = _node.AttributeText; - if (attributeTextNode == null) - return false; - MoveToNode(attributeTextNode); - return true; - } - - public override ReadState ReadState - { - get - { - return _node.ReadState; - } - } - - private void SkipValue(XmlNode node) - { - if (node.SkipValue) - Read(); - } - - public override bool TryGetBase64ContentLength(out int length) - { - if (_trailByteCount == 0 && _trailCharCount == 0 && _value == null) - { - XmlNode node = this.Node; - if (node.IsAtomicValue) - return node.Value.TryGetByteArrayLength(out length); - } - return base.TryGetBase64ContentLength(out length); - } - - public override byte[] ReadContentAsBase64() - { - if (_trailByteCount == 0 && _trailCharCount == 0 && _value == null) - { - XmlNode node = this.Node; - if (node.IsAtomicValue) - { - byte[] value = node.Value.ToByteArray(); - if (value.Length > _quotas.MaxArrayLength) - XmlExceptionHelper.ThrowMaxArrayLengthExceeded(this, _quotas.MaxArrayLength); - SkipValue(node); - return value; - } - } - - if (!_bufferReader.IsStreamed) - return ReadContentAsBase64(_quotas.MaxArrayLength, _bufferReader.Buffer.Length); - - return ReadContentAsBase64(_quotas.MaxArrayLength, XmlDictionaryReader.MaxInitialArrayLength); // Initial count will get ignored - } - - public override int ReadElementContentAsBase64(byte[] buffer, int offset, int count) - { - if (!_readingElement) - { - if (IsEmptyElement) - { - Read(); - return 0; - } - - ReadStartElement(); - _readingElement = true; - } - - int i = ReadContentAsBase64(buffer, offset, count); - - if (i == 0) - { - ReadEndElement(); - _readingElement = false; - } - - return i; - } - - public override int ReadContentAsBase64(byte[] buffer, int offset, int count) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > buffer.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, buffer.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > buffer.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); - if (count == 0) - return 0; - int actual; - if (_trailByteCount == 0 && _trailCharCount == 0 && _value == null) - { - if (_node.QNameType == QNameType.Normal) - { - while (_node.NodeType != XmlNodeType.Comment && _node.Value.TryReadBase64(buffer, offset, count, out actual)) - { - if (actual != 0) - return actual; - Read(); - } - } - } - XmlNodeType nodeType = _node.NodeType; - if (nodeType == XmlNodeType.Element || nodeType == XmlNodeType.EndElement) - return 0; - return ReadBytes(Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), true); - } - - - private int ReadBytes(Encoding encoding, int byteBlock, int charBlock, byte[] buffer, int offset, int byteCount, bool readContent) - { - // If there are any trailing buffer return them. - if (_trailByteCount > 0) - { - int actual = Math.Min(_trailByteCount, byteCount); - Array.Copy(_trailBytes, 0, buffer, offset, actual); - _trailByteCount -= actual; - Array.Copy(_trailBytes, actual, _trailBytes, 0, _trailByteCount); - return actual; - } - XmlNodeType nodeType = _node.NodeType; - if (nodeType == XmlNodeType.Element || nodeType == XmlNodeType.EndElement) - return 0; - int maxCharCount; - if (byteCount < byteBlock) - { - // Convert at least charBlock chars - maxCharCount = charBlock; - } - else - { - // Round down to the nearest multiple of charBlock - maxCharCount = byteCount / byteBlock * charBlock; - } - char[] chars = GetCharBuffer(maxCharCount); - int charCount = 0; - while (true) - { - // If we didn't align on the boundary, then we might have some remaining characters - if (_trailCharCount > 0) - { - Array.Copy(_trailChars, 0, chars, charCount, _trailCharCount); - charCount += _trailCharCount; - _trailCharCount = 0; - } - // Read until we at least get a charBlock - while (charCount < charBlock) - { - int actualCharCount; - if (readContent) - { - actualCharCount = ReadContentAsChars(chars, charCount, maxCharCount - charCount); - // When deserializing base64 content which contains new line chars (CR, LF) chars from ReadObject, the reader reads in chunks of base64 content, LF char, base64 content, LF char and so on - // Relying on encoding.GetBytes' exception to handle LF char would result in performance degradation so skipping LF char here - if (actualCharCount == 1 && chars[charCount] == '\n') - continue; - } - else - { - actualCharCount = ReadValueChunk(chars, charCount, maxCharCount - charCount); - } - if (actualCharCount == 0) - break; - charCount += actualCharCount; - } - // Trim so its a multiple of charBlock - if (charCount >= charBlock) - { - _trailCharCount = (charCount % charBlock); - if (_trailCharCount > 0) - { - if (_trailChars == null) - _trailChars = new char[4]; - charCount = charCount - _trailCharCount; - Array.Copy(chars, charCount, _trailChars, 0, _trailCharCount); - } - } - try - { - if (byteCount < byteBlock) - { - if (_trailBytes == null) - _trailBytes = new byte[3]; - _trailByteCount = encoding.GetBytes(chars, 0, charCount, _trailBytes, 0); - int actual = Math.Min(_trailByteCount, byteCount); - Array.Copy(_trailBytes, 0, buffer, offset, actual); - _trailByteCount -= actual; - Array.Copy(_trailBytes, actual, _trailBytes, 0, _trailByteCount); - return actual; - } - else - { - // charCount is a multiple of charBlock and we have enough room to convert everything - return encoding.GetBytes(chars, 0, charCount, buffer, offset); - } - } - catch (FormatException exception) - { - // Something was wrong with the format, see if we can strip the spaces - int i = 0; - int j = 0; - while (true) - { - while (j < charCount && XmlConverter.IsWhitespace(chars[j])) - j++; - if (j == charCount) - break; - chars[i++] = chars[j++]; - } - // No spaces, so don't try again - if (i == charCount) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(exception.Message, exception.InnerException)); - charCount = i; - } - } - } - - public override string ReadContentAsString() - { - string value; - XmlNode node = this.Node; - if (node.IsAtomicValue) - { - if (_value != null) - { - value = _value; - if (node.AttributeText == null) - _value = string.Empty; - } - else - { - value = node.Value.GetString(); - SkipValue(node); - if (value.Length > _quotas.MaxStringContentLength) - XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(this, _quotas.MaxStringContentLength); - } - return value; - } - return base.ReadContentAsString(_quotas.MaxStringContentLength); - } - - public override Boolean ReadContentAsBoolean() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - bool value = node.Value.ToBoolean(); - SkipValue(node); - return value; - } - return XmlConverter.ToBoolean(ReadContentAsString()); - } - - public override Int64 ReadContentAsLong() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - Int64 value = node.Value.ToLong(); - SkipValue(node); - return value; - } - return XmlConverter.ToInt64(ReadContentAsString()); - } - - public override Int32 ReadContentAsInt() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - Int32 value = node.Value.ToInt(); - SkipValue(node); - return value; - } - return XmlConverter.ToInt32(ReadContentAsString()); - } - - public override DateTime ReadContentAsDateTime() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - DateTime value = node.Value.ToDateTime(); - SkipValue(node); - return value; - } - return XmlConverter.ToDateTime(ReadContentAsString()); - } - - public override Double ReadContentAsDouble() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - double value = node.Value.ToDouble(); - SkipValue(node); - return value; - } - return XmlConverter.ToDouble(ReadContentAsString()); - } - - public override Single ReadContentAsFloat() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - float value = node.Value.ToSingle(); - SkipValue(node); - return value; - } - return XmlConverter.ToSingle(ReadContentAsString()); - } - - public override Decimal ReadContentAsDecimal() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - decimal value = node.Value.ToDecimal(); - SkipValue(node); - return value; - } - return XmlConverter.ToDecimal(ReadContentAsString()); - } - - public override UniqueId ReadContentAsUniqueId() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - UniqueId value = node.Value.ToUniqueId(); - SkipValue(node); - return value; - } - return XmlConverter.ToUniqueId(ReadContentAsString()); - } - - public override TimeSpan ReadContentAsTimeSpan() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - TimeSpan value = node.Value.ToTimeSpan(); - SkipValue(node); - return value; - } - return XmlConverter.ToTimeSpan(ReadContentAsString()); - } - - public override Guid ReadContentAsGuid() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - Guid value = node.Value.ToGuid(); - SkipValue(node); - return value; - } - return XmlConverter.ToGuid(ReadContentAsString()); - } - - public override object ReadContentAsObject() - { - XmlNode node = this.Node; - if (_value == null && node.IsAtomicValue) - { - object obj = node.Value.ToObject(); - SkipValue(node); - return obj; - } - return ReadContentAsString(); - } - - public override object ReadContentAs(Type type, IXmlNamespaceResolver namespaceResolver) - { - if (type == typeof(ulong)) - { - if (_value == null && _node.IsAtomicValue) - { - ulong value = _node.Value.ToULong(); - SkipValue(_node); - return value; - } - else - { - return XmlConverter.ToUInt64(ReadContentAsString()); - } - } - else if (type == typeof(bool)) - return ReadContentAsBoolean(); - else if (type == typeof(int)) - return ReadContentAsInt(); - else if (type == typeof(long)) - return ReadContentAsLong(); - else if (type == typeof(float)) - return ReadContentAsFloat(); - else if (type == typeof(double)) - return ReadContentAsDouble(); - else if (type == typeof(decimal)) - return ReadContentAsDecimal(); - else if (type == typeof(DateTime)) - return ReadContentAsDateTime(); - else if (type == typeof(UniqueId)) - return ReadContentAsUniqueId(); - else if (type == typeof(Guid)) - return ReadContentAsGuid(); - else if (type == typeof(TimeSpan)) - return ReadContentAsTimeSpan(); - else if (type == typeof(object)) - return ReadContentAsObject(); - else - return base.ReadContentAs(type, namespaceResolver); - } - - public override void ResolveEntity() - { - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.XmlInvalidOperation))); - } - - public override void Skip() - { - if (_node.ReadState != ReadState.Interactive) - return; - if ((_node.NodeType == XmlNodeType.Element || MoveToElement()) && !IsEmptyElement) - { - int depth = Depth; - while (Read() && depth < Depth) - { - // Nothing, just read on - } - // consume end tag - if (_node.NodeType == XmlNodeType.EndElement) - Read(); - } - else - { - Read(); - } - } - - public override string Value - { - get - { - if (_value == null) - { - _value = _node.ValueAsString; - } - - return _value; - } - } - - public override Type ValueType - { - get - { - if (_value == null && _node.QNameType == QNameType.Normal) - { - Type type = _node.Value.ToType(); - if (_node.IsAtomicValue) - return type; - if (type == typeof(byte[])) - return type; - } - return typeof(string); - } - } - - public override string XmlLang - { - get - { - return _nsMgr.XmlLang; - } - } - - public override XmlSpace XmlSpace - { - get - { - return _nsMgr.XmlSpace; - } - } - - public override bool TryGetLocalNameAsDictionaryString(out XmlDictionaryString localName) - { - return _node.TryGetLocalNameAsDictionaryString(out localName); - } - - public override bool TryGetNamespaceUriAsDictionaryString(out XmlDictionaryString localName) - { - return _node.TryGetNamespaceUriAsDictionaryString(out localName); - } - - public override bool TryGetValueAsDictionaryString(out XmlDictionaryString value) - { - return _node.TryGetValueAsDictionaryString(out value); - } - - public override Int16[] ReadInt16Array(string localName, string namespaceUri) - { - return Int16ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Int16[] ReadInt16Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int16ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Int32[] ReadInt32Array(string localName, string namespaceUri) - { - return Int32ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Int32[] ReadInt32Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int32ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Int64[] ReadInt64Array(string localName, string namespaceUri) - { - return Int64ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Int64[] ReadInt64Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int64ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override float[] ReadSingleArray(string localName, string namespaceUri) - { - return SingleArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override float[] ReadSingleArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return SingleArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override double[] ReadDoubleArray(string localName, string namespaceUri) - { - return DoubleArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override double[] ReadDoubleArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DoubleArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override decimal[] ReadDecimalArray(string localName, string namespaceUri) - { - return DecimalArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override decimal[] ReadDecimalArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DecimalArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override DateTime[] ReadDateTimeArray(string localName, string namespaceUri) - { - return DateTimeArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override DateTime[] ReadDateTimeArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DateTimeArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Guid[] ReadGuidArray(string localName, string namespaceUri) - { - return GuidArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override Guid[] ReadGuidArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return GuidArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override TimeSpan[] ReadTimeSpanArray(string localName, string namespaceUri) - { - return TimeSpanArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public override TimeSpan[] ReadTimeSpanArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return TimeSpanArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, _quotas.MaxArrayLength); - } - - public string GetOpenElements() - { - string s = string.Empty; - for (int i = _depth; i > 0; i--) - { - string localName = _elementNodes[i].LocalName.GetString(); - if (i != _depth) - s += ", "; - s += localName; - } - return s; - } - - private char[] GetCharBuffer(int count) - { - if (count > 1024) - return new char[count]; - - if (_chars == null || _chars.Length < count) - _chars = new char[count]; - - return _chars; - } - - - protected enum QNameType - { - Normal, - Xmlns, - } - - protected class XmlNode - { - private XmlNodeType _nodeType; - private PrefixHandle _prefix; - private StringHandle _localName; - private ValueHandle _value; - private Namespace _ns; - private bool _hasValue; - private bool _canGetAttribute; - private bool _canMoveToElement; - private ReadState _readState; - private XmlAttributeTextNode _attributeTextNode; - private bool _exitScope; - private int _depthDelta; - private bool _isAtomicValue; - private bool _skipValue; - private QNameType _qnameType; - private bool _hasContent; - private bool _isEmptyElement; - private char _quoteChar; - - protected enum XmlNodeFlags - { - None = 0x00, - CanGetAttribute = 0x01, - CanMoveToElement = 0x02, - HasValue = 0x04, - AtomicValue = 0x08, - SkipValue = 0x10, - HasContent = 0x20 - } - - protected XmlNode(XmlNodeType nodeType, - PrefixHandle prefix, - StringHandle localName, - ValueHandle value, - XmlNodeFlags nodeFlags, - ReadState readState, - XmlAttributeTextNode attributeTextNode, - int depthDelta) - { - _nodeType = nodeType; - _prefix = prefix; - _localName = localName; - _value = value; - _ns = NamespaceManager.EmptyNamespace; - _hasValue = ((nodeFlags & XmlNodeFlags.HasValue) != 0); - _canGetAttribute = ((nodeFlags & XmlNodeFlags.CanGetAttribute) != 0); - _canMoveToElement = ((nodeFlags & XmlNodeFlags.CanMoveToElement) != 0); - _isAtomicValue = ((nodeFlags & XmlNodeFlags.AtomicValue) != 0); - _skipValue = ((nodeFlags & XmlNodeFlags.SkipValue) != 0); - _hasContent = ((nodeFlags & XmlNodeFlags.HasContent) != 0); - _readState = readState; - _attributeTextNode = attributeTextNode; - _exitScope = (nodeType == XmlNodeType.EndElement); - _depthDelta = depthDelta; - _isEmptyElement = false; - _quoteChar = '"'; - - _qnameType = QNameType.Normal; - } - - // Most nodes are read-only and fixed for the particular node type, but a few need to be tweaked - // QNameType needs to get set for all nodes with a qname (Element/Attribute) - // NodeType gets set for WhiteSpace vs. SignificantWhitespace - // ExitScope/IsEmptyElement is only updated by text for empty elements - // QuoteChar is only updated by text for attributes - // IsAtomicValue is set to false for XmlnsAttributes so we don't have to check QNameType - - public bool HasValue { get { return _hasValue; } } - public ReadState ReadState { get { return _readState; } } - public StringHandle LocalName { get { DiagnosticUtility.DebugAssert(_qnameType != QNameType.Xmlns, ""); return _localName; } } - public PrefixHandle Prefix { get { DiagnosticUtility.DebugAssert(_qnameType != QNameType.Xmlns, ""); return _prefix; } } - public bool CanGetAttribute { get { return _canGetAttribute; } } - public bool CanMoveToElement { get { return _canMoveToElement; } } - public XmlAttributeTextNode AttributeText { get { return _attributeTextNode; } } - public bool SkipValue { get { return _skipValue; } } - public ValueHandle Value { get { DiagnosticUtility.DebugAssert(_qnameType != QNameType.Xmlns, ""); return _value; } } - public int DepthDelta { get { return _depthDelta; } } - public bool HasContent { get { return _hasContent; } } - - public XmlNodeType NodeType - { - get - { - return _nodeType; - } - set - { - _nodeType = value; - } - } - - public QNameType QNameType - { - get - { - return _qnameType; - } - set - { - _qnameType = value; - } - } - - public Namespace Namespace - { - get - { - return _ns; - } - set - { - _ns = value; - } - } - - public bool IsAtomicValue - { - get - { - return _isAtomicValue; - } - set - { - _isAtomicValue = value; - } - } - - public bool ExitScope - { - get - { - return _exitScope; - } - set - { - _exitScope = value; - } - } - - public bool IsEmptyElement - { - get - { - return _isEmptyElement; - } - set - { - _isEmptyElement = value; - } - } - - public char QuoteChar - { - get - { - return _quoteChar; - } - set - { - _quoteChar = value; - } - } - - public bool IsLocalName(string localName) - { - if (_qnameType == QNameType.Normal) - { - return this.LocalName == localName; - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return this.Namespace.Prefix == localName; - } - } - - public bool IsLocalName(XmlDictionaryString localName) - { - if (_qnameType == QNameType.Normal) - { - return this.LocalName == localName; - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return this.Namespace.Prefix == localName; - } - } - - public bool IsNamespaceUri(string ns) - { - if (_qnameType == QNameType.Normal) - { - return this.Namespace.IsUri(ns); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return ns == xmlnsNamespace; - } - } - - public bool IsNamespaceUri(XmlDictionaryString ns) - { - if (_qnameType == QNameType.Normal) - { - return this.Namespace.IsUri(ns); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return ns.Value == xmlnsNamespace; - } - } - - public bool IsLocalNameAndNamespaceUri(string localName, string ns) - { - if (_qnameType == QNameType.Normal) - { - return this.LocalName == localName && this.Namespace.IsUri(ns); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return this.Namespace.Prefix == localName && ns == xmlnsNamespace; - } - } - - public bool IsLocalNameAndNamespaceUri(XmlDictionaryString localName, XmlDictionaryString ns) - { - if (_qnameType == QNameType.Normal) - { - return this.LocalName == localName && this.Namespace.IsUri(ns); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return this.Namespace.Prefix == localName && ns.Value == xmlnsNamespace; - } - } - public bool IsPrefixAndLocalName(string prefix, string localName) - { - if (_qnameType == QNameType.Normal) - { - return this.Prefix == prefix && this.LocalName == localName; - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return prefix == xmlns && this.Namespace.Prefix == localName; - } - } - - public bool TryGetLocalNameAsDictionaryString(out XmlDictionaryString localName) - { - if (_qnameType == QNameType.Normal) - { - return this.LocalName.TryGetDictionaryString(out localName); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - localName = null; - return false; - } - } - - public bool TryGetNamespaceUriAsDictionaryString(out XmlDictionaryString ns) - { - if (_qnameType == QNameType.Normal) - { - return this.Namespace.Uri.TryGetDictionaryString(out ns); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - ns = null; - return false; - } - } - - public bool TryGetValueAsDictionaryString(out XmlDictionaryString value) - { - if (_qnameType == QNameType.Normal) - { - return this.Value.TryGetDictionaryString(out value); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - value = null; - return false; - } - } - public string ValueAsString - { - get - { - if (_qnameType == QNameType.Normal) - { - return Value.GetString(); - } - else - { - DiagnosticUtility.DebugAssert(_qnameType == QNameType.Xmlns, ""); - return Namespace.Uri.GetString(); - } - } - } - } - - protected class XmlElementNode : XmlNode - { - private XmlEndElementNode _endElementNode; - private int _bufferOffset; - - public XmlElementNode(XmlBufferReader bufferReader) - : this(new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader)) - { - } - - private XmlElementNode(PrefixHandle prefix, StringHandle localName, ValueHandle value) - : base(XmlNodeType.Element, - prefix, - localName, - value, - XmlNodeFlags.CanGetAttribute | XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - -1) - { - _endElementNode = new XmlEndElementNode(prefix, localName, value); - } - - public XmlEndElementNode EndElement - { - get - { - return _endElementNode; - } - } - - public int BufferOffset - { - get - { - return _bufferOffset; - } - set - { - _bufferOffset = value; - } - } - - public int NameOffset; - public int NameLength; - } - - protected class XmlAttributeNode : XmlNode - { - public XmlAttributeNode(XmlBufferReader bufferReader) - : this(new PrefixHandle(bufferReader), new StringHandle(bufferReader), new ValueHandle(bufferReader)) - { - } - - private XmlAttributeNode(PrefixHandle prefix, StringHandle localName, ValueHandle value) - : base(XmlNodeType.Attribute, - prefix, - localName, - value, - XmlNodeFlags.CanGetAttribute | XmlNodeFlags.CanMoveToElement | XmlNodeFlags.HasValue | XmlNodeFlags.AtomicValue, - ReadState.Interactive, - new XmlAttributeTextNode(prefix, localName, value), - 0) - { - } - } - - protected class XmlEndElementNode : XmlNode - { - public XmlEndElementNode(PrefixHandle prefix, StringHandle localName, ValueHandle value) - : base(XmlNodeType.EndElement, - prefix, - localName, - value, - XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - -1) - { - } - } - - protected class XmlTextNode : XmlNode - { - protected XmlTextNode(XmlNodeType nodeType, - PrefixHandle prefix, - StringHandle localName, - ValueHandle value, - XmlNodeFlags nodeFlags, - ReadState readState, - XmlAttributeTextNode attributeTextNode, - int depthDelta) - : - base(nodeType, prefix, localName, value, nodeFlags, readState, attributeTextNode, depthDelta) - { - } - } - - protected class XmlAtomicTextNode : XmlTextNode - { - public XmlAtomicTextNode(XmlBufferReader bufferReader) - : base(XmlNodeType.Text, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.HasValue | XmlNodeFlags.AtomicValue | XmlNodeFlags.SkipValue | XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - 0) - { - } - } - - protected class XmlComplexTextNode : XmlTextNode - { - public XmlComplexTextNode(XmlBufferReader bufferReader) - : base(XmlNodeType.Text, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.HasValue | XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - 0) - { - } - } - - protected class XmlWhitespaceTextNode : XmlTextNode - { - public XmlWhitespaceTextNode(XmlBufferReader bufferReader) - : base(XmlNodeType.Whitespace, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.HasValue, - ReadState.Interactive, - null, - 0) - { - } - } - - protected class XmlCDataNode : XmlTextNode - { - public XmlCDataNode(XmlBufferReader bufferReader) - : base(XmlNodeType.CDATA, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.HasValue | XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - 0) - { - } - } - - protected class XmlAttributeTextNode : XmlTextNode - { - public XmlAttributeTextNode(PrefixHandle prefix, StringHandle localName, ValueHandle value) - : base(XmlNodeType.Text, - prefix, - localName, - value, - XmlNodeFlags.HasValue | XmlNodeFlags.CanGetAttribute | XmlNodeFlags.CanMoveToElement | XmlNodeFlags.AtomicValue | XmlNodeFlags.HasContent, - ReadState.Interactive, - null, - 1) - { - } - } - - protected class XmlInitialNode : XmlNode - { - public XmlInitialNode(XmlBufferReader bufferReader) - : base(XmlNodeType.None, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.None, - ReadState.Initial, - null, - 0) - { - } - } - - protected class XmlDeclarationNode : XmlNode - { - public XmlDeclarationNode(XmlBufferReader bufferReader) - : base(XmlNodeType.XmlDeclaration, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.CanGetAttribute, - ReadState.Interactive, - null, - 0) - { - } - } - - protected class XmlCommentNode : XmlNode - { - public XmlCommentNode(XmlBufferReader bufferReader) - : base(XmlNodeType.Comment, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.HasValue, - ReadState.Interactive, - null, - 0) - { - } - } - protected class XmlEndOfFileNode : XmlNode - { - public XmlEndOfFileNode(XmlBufferReader bufferReader) - : base(XmlNodeType.None, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.None, - ReadState.EndOfFile, - null, - 0) - { - } - } - - protected class XmlClosedNode : XmlNode - { - public XmlClosedNode(XmlBufferReader bufferReader) - : base(XmlNodeType.None, - new PrefixHandle(bufferReader), - new StringHandle(bufferReader), - new ValueHandle(bufferReader), - XmlNodeFlags.None, - ReadState.Closed, - null, - 0) - { - } - } - - private class AttributeSorter : IComparer - { - private object[] _indeces; - private XmlAttributeNode[] _attributeNodes; - private int _attributeCount; - private int _attributeIndex1; - private int _attributeIndex2; - - public bool Sort(XmlAttributeNode[] attributeNodes, int attributeCount) - { - _attributeIndex1 = -1; - _attributeIndex2 = -1; - _attributeNodes = attributeNodes; - _attributeCount = attributeCount; - bool sorted = Sort(); - _attributeNodes = null; - _attributeCount = 0; - return sorted; - } - - public void GetIndeces(out int attributeIndex1, out int attributeIndex2) - { - attributeIndex1 = _attributeIndex1; - attributeIndex2 = _attributeIndex2; - } - - public void Close() - { - if (_indeces != null && _indeces.Length > 32) - { - _indeces = null; - } - } - - private bool Sort() - { - // Optimistically use the last sort order and check to see if that works. This helps the case - // where elements with large numbers of attributes are repeated. - if (_indeces != null && _indeces.Length == _attributeCount && IsSorted()) - return true; - - object[] newIndeces = new object[_attributeCount]; - for (int i = 0; i < newIndeces.Length; i++) - newIndeces[i] = i; - _indeces = newIndeces; - Array.Sort(_indeces, 0, _attributeCount, this); - return IsSorted(); - } - - private bool IsSorted() - { - for (int i = 0; i < _indeces.Length - 1; i++) - { - if (Compare(_indeces[i], _indeces[i + 1]) >= 0) - { - _attributeIndex1 = (int)_indeces[i]; - _attributeIndex2 = (int)_indeces[i + 1]; - return false; - } - } - return true; - } - - public int Compare(object obj1, object obj2) - { - int index1 = (int)obj1; - int index2 = (int)obj2; - XmlAttributeNode attribute1 = _attributeNodes[index1]; - XmlAttributeNode attribute2 = _attributeNodes[index2]; - - int i = CompareQNameType(attribute1.QNameType, attribute2.QNameType); - if (i == 0) - { - QNameType qnameType = attribute1.QNameType; - if (qnameType == QNameType.Normal) - { - i = attribute1.LocalName.CompareTo(attribute2.LocalName); - if (i == 0) - { - i = attribute1.Namespace.Uri.CompareTo(attribute2.Namespace.Uri); - } - } - else - { - DiagnosticUtility.DebugAssert(qnameType == QNameType.Xmlns, ""); - i = attribute1.Namespace.Prefix.CompareTo(attribute2.Namespace.Prefix); - } - } - - return i; - } - - public int CompareQNameType(QNameType type1, QNameType type2) - { - return (int)type1 - (int)type2; - } - } - - private class NamespaceManager - { - private XmlBufferReader _bufferReader; - private Namespace[] _namespaces; - private int _nsCount; - private int _depth; - private Namespace[] _shortPrefixUri; - private static Namespace s_emptyNamespace = new Namespace(XmlBufferReader.Empty); - private static Namespace s_xmlNamespace; - private XmlAttribute[] _attributes; - private int _attributeCount; - private XmlSpace _space; - private string _lang; - - public NamespaceManager(XmlBufferReader bufferReader) - { - _bufferReader = bufferReader; - _shortPrefixUri = new Namespace[(int)PrefixHandleType.Max]; - _shortPrefixUri[(int)PrefixHandleType.Empty] = s_emptyNamespace; - _namespaces = null; - _nsCount = 0; - _attributes = null; - _attributeCount = 0; - _space = XmlSpace.None; - _lang = string.Empty; - _depth = 0; - } - - public void Close() - { - if (_namespaces != null && _namespaces.Length > 32) - _namespaces = null; - if (_attributes != null && _attributes.Length > 4) - _attributes = null; - _lang = string.Empty; - } - - static public Namespace XmlNamespace - { - get - { - if (s_xmlNamespace == null) - { - byte[] xmlBuffer = - { - (byte)'x',(byte)'m',(byte)'l', - (byte)'h',(byte)'t',(byte)'t',(byte)'p',(byte)':',(byte)'/',(byte)'/',(byte)'w', - (byte)'w',(byte)'w',(byte)'.',(byte)'w',(byte)'3',(byte)'.',(byte)'o',(byte)'r', - (byte)'g',(byte)'/',(byte)'X',(byte)'M',(byte)'L',(byte)'/',(byte)'1',(byte)'9', - (byte)'9',(byte)'8',(byte)'/',(byte)'n',(byte)'a',(byte)'m',(byte)'e',(byte)'s', - (byte)'p',(byte)'a',(byte)'c',(byte)'e' - }; - Namespace nameSpace = new Namespace(new XmlBufferReader(xmlBuffer)); - nameSpace.Prefix.SetValue(0, 3); - nameSpace.Uri.SetValue(3, xmlBuffer.Length - 3); - s_xmlNamespace = nameSpace; - } - return s_xmlNamespace; - } - } - - static public Namespace EmptyNamespace - { - get - { - return s_emptyNamespace; - } - } - - public string XmlLang - { - get - { - return _lang; - } - } - - public XmlSpace XmlSpace - { - get - { - return _space; - } - } - - public void Clear() - { - if (_nsCount != 0) - { - if (_shortPrefixUri != null) - { - for (int i = 0; i < _shortPrefixUri.Length; i++) - { - _shortPrefixUri[i] = null; - } - } - _shortPrefixUri[(int)PrefixHandleType.Empty] = s_emptyNamespace; - _nsCount = 0; - } - _attributeCount = 0; - _space = XmlSpace.None; - _lang = string.Empty; - _depth = 0; - } - - public void EnterScope() - { - _depth++; - } - - public void ExitScope() - { - while (_nsCount > 0) - { - Namespace nameSpace = _namespaces[_nsCount - 1]; - if (nameSpace.Depth != _depth) - break; - PrefixHandleType shortPrefix; - if (nameSpace.Prefix.TryGetShortPrefix(out shortPrefix)) - { - _shortPrefixUri[(int)shortPrefix] = nameSpace.OuterUri; - } - _nsCount--; - } - while (_attributeCount > 0) - { - XmlAttribute attribute = _attributes[_attributeCount - 1]; - if (attribute.Depth != _depth) - break; - _space = attribute.XmlSpace; - _lang = attribute.XmlLang; - _attributeCount--; - } - _depth--; - } - - - public void AddLangAttribute(string lang) - { - AddAttribute(); - _lang = lang; - } - - public void AddSpaceAttribute(XmlSpace space) - { - AddAttribute(); - _space = space; - } - - private void AddAttribute() - { - if (_attributes == null) - { - _attributes = new XmlAttribute[1]; - } - else if (_attributes.Length == _attributeCount) - { - XmlAttribute[] newAttributes = new XmlAttribute[_attributeCount * 2]; - Array.Copy(_attributes, 0, newAttributes, 0, _attributeCount); - _attributes = newAttributes; - } - XmlAttribute attribute = _attributes[_attributeCount]; - if (attribute == null) - { - attribute = new XmlAttribute(); - _attributes[_attributeCount] = attribute; - } - attribute.XmlLang = _lang; - attribute.XmlSpace = _space; - attribute.Depth = _depth; - _attributeCount++; - } - - public void Register(Namespace nameSpace) - { - PrefixHandleType shortPrefix; - if (nameSpace.Prefix.TryGetShortPrefix(out shortPrefix)) - { - nameSpace.OuterUri = _shortPrefixUri[(int)shortPrefix]; - _shortPrefixUri[(int)shortPrefix] = nameSpace; - } - else - { - nameSpace.OuterUri = null; - } - } - - public Namespace AddNamespace() - { - if (_namespaces == null) - { - _namespaces = new Namespace[4]; - } - else if (_namespaces.Length == _nsCount) - { - Namespace[] newNamespaces = new Namespace[_nsCount * 2]; - Array.Copy(_namespaces, 0, newNamespaces, 0, _nsCount); - _namespaces = newNamespaces; - } - Namespace nameSpace = _namespaces[_nsCount]; - if (nameSpace == null) - { - nameSpace = new Namespace(_bufferReader); - _namespaces[_nsCount] = nameSpace; - } - nameSpace.Clear(); - nameSpace.Depth = _depth; - _nsCount++; - return nameSpace; - } - - public Namespace LookupNamespace(PrefixHandleType prefix) - { - return _shortPrefixUri[(int)prefix]; - } - - public Namespace LookupNamespace(PrefixHandle prefix) - { - PrefixHandleType shortPrefix; - if (prefix.TryGetShortPrefix(out shortPrefix)) - return LookupNamespace(shortPrefix); - for (int i = _nsCount - 1; i >= 0; i--) - { - Namespace nameSpace = _namespaces[i]; - if (nameSpace.Prefix == prefix) - return nameSpace; - } - if (prefix.IsXml) - return XmlNamespace; - return null; - } - public Namespace LookupNamespace(string prefix) - { - PrefixHandleType shortPrefix; - if (TryGetShortPrefix(prefix, out shortPrefix)) - return LookupNamespace(shortPrefix); - for (int i = _nsCount - 1; i >= 0; i--) - { - Namespace nameSpace = _namespaces[i]; - if (nameSpace.Prefix == prefix) - return nameSpace; - } - if (prefix == "xml") - return XmlNamespace; - return null; - } - - private bool TryGetShortPrefix(string s, out PrefixHandleType shortPrefix) - { - int length = s.Length; - if (length == 0) - { - shortPrefix = PrefixHandleType.Empty; - return true; - } - if (length == 1) - { - char ch = s[0]; - if (ch >= 'a' && ch <= 'z') - { - shortPrefix = PrefixHandle.GetAlphaPrefix(ch - 'a'); - return true; - } - } - shortPrefix = PrefixHandleType.Empty; - return false; - } - - private class XmlAttribute - { - private XmlSpace _space; - private string _lang; - private int _depth; - - public XmlAttribute() - { - } - - public int Depth - { - get - { - return _depth; - } - set - { - _depth = value; - } - } - - public string XmlLang - { - get - { - return _lang; - } - set - { - _lang = value; - } - } - - public XmlSpace XmlSpace - { - get - { - return _space; - } - set - { - _space = value; - } - } - } - } - protected class Namespace - { - private PrefixHandle _prefix; - private StringHandle _uri; - private int _depth; - private Namespace _outerUri; - private string _uriString; - - public Namespace(XmlBufferReader bufferReader) - { - _prefix = new PrefixHandle(bufferReader); - _uri = new StringHandle(bufferReader); - _outerUri = null; - _uriString = null; - } - - public void Clear() - { - _uriString = null; - } - - public int Depth - { - get - { - return _depth; - } - set - { - _depth = value; - } - } - - public PrefixHandle Prefix - { - get - { - return _prefix; - } - } - - public bool IsUri(string s) - { - DiagnosticUtility.DebugAssert(s != null, ""); - if (object.ReferenceEquals(s, _uriString)) - return true; - if (_uri == s) - { - _uriString = s; - return true; - } - return false; - } - - public bool IsUri(XmlDictionaryString s) - { - if (object.ReferenceEquals(s.Value, _uriString)) - return true; - if (_uri == s) - { - _uriString = s.Value; - return true; - } - return false; - } - public StringHandle Uri - { - get - { - return _uri; - } - } - - public Namespace OuterUri - { - get - { - return _outerUri; - } - set - { - _outerUri = value; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseWriter.cs index e428d56a304..1ceec908d70 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBaseWriter.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryNodeType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryNodeType.cs index 43c5e5a14ad..e6a896a2d0a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryNodeType.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryNodeType.cs @@ -1,276 +1,203 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Xml +namespace System.Xml { - // Element => StartElement Attribute* Content EndElement - // | StartElement Attribute* Text // Text must be WithEndElement - // | Array StartElement Attribute* EndElement type MB32(Count) byte[Count * sizeof(type)] - - // StartElement => ShortElementNode Name(LocalName) - // | ElementNode Name(Prefix) Name(LocalName) - // | ShortDictionaryElementNode MB32(LocalName) - // | PrefixDictionaryElement[A-Z]Node MB32(LocalName) - // | DictionaryElementNode Name(Prefix) MB32(LocalName) - // | PrefixElement[A-Z]Node Name(LocalName) - - // EndElement => EndElementNode - // Content => (Element | ArrayElement | Text | Comment)* - - // Attribute => ShortAttributeNode Name(LocalName) Text - // | AttributeNode Name(Prefix) Name(LocalName) Text - // | ShortDictionaryAttributeNode MB32(LocalName) Text - // | DictionaryAttributeNode Name(Prefix) MB32(LocalName) Text - // | ShortXmlnsAttributeNode Name(Namespace) - // | XmlnsAttributeNode Name(Prefix) Name(Namespace) - // | ShortDictionaryXmlnsAttributeNode MB32(Namespace) - // | DictionaryXmlnsAttributeNode Name(Prefix) MB32(Namespace) - // | PrefixAttribute[A-Z] Name(LocalName) Text - // | PrefixDictionaryAttribute[A-Z] MB32(LocalName) Text - - // Text => BinaryTextNode - // | CharsTextNode - // | EmptyTextNode - // | DictionaryTextNode MB32(Id) - // | ZeroTextNode - // | OneTextNode - // | TrueTextNode - // | FalseTextNode - // | Int8TextNode Int8 - // | Int16TextNode Int16 - // | Int32TextNode Int32 - // | Int64TextNode Int64 - // | FloatTextNode Float - // | DoubleTextNode Double - // | DecimalTextNode Decimal - // | DateTimeTextNode DateTime - // | StartListNode Text* EndListNode // Restriction: Cannot nest ListNode - // | UniqueIdTextNode byte[16] // byte[16] is a Guid (from Guid.ToBinary()) (urn:uuid:xxxx-xxxx-xxx) - // | GuidTextNode byte[16] // byte[16] is a Guid (from Guid.ToBinary()) (xxxx-xxxx-xxx) - // | TimeSpanNode Int64 - // | UInt64TextNode UInt64 - // | BoolTextNode Int8 - // BinaryText => Bytes8TextNode UInt8 byte* - // | Bytes16TextNode UInt16 byte* - // | Bytes32TextNode UInt31 byte* - // CharsText => Chars8TextNode UInt8 byte* // UTF8Chars - // | Chars16TextNode UInt16 byte* - // | Chars32TextNode Unt31 byte* - // | UnicodeChars8TextNode UInt8 char* - // | UnicodeChars16TextNode UInt16 char* - // | UnicodeChars32TextNode UInt31 char* - // | QNameDictionaryTextNode UInt8 MB32(LocalName) // UInt8 0-25 => 'a'-'z' - // Comment => CommentNode Name(Text) - // Name => MB32 byte* // Length, UTF8Chars - // MB32(x:x>=0x80) => byte(0x80 | (x & 0x7F)) MB32(x >> 7) - // MB32(x:x<0x80) => byte(x) - - - // In order to help differentiate text from binary (where someone mixes up format and implementation) we overlay binary - // nodes that are illegal to start a document with text characters that are legal to start a document. Specifically these values are: - // ' ' = 32 - // '\t' = 9 - // '\n' = 10 - // '\r' = 13 - // '<' = 60 - // The attribute nodes (MinAttribute to MaxAttribute) overlay all of these values and are invalid as the first byte of the document + using System; internal enum XmlBinaryNodeType { - // ProcessingInstruction = 0, // Reserved (Not supported) EndElement = 1, Comment = 2, Array = 3, + MinAttribute = 4, - MinAttribute = Array + 1, - ShortAttribute = MinAttribute + 0, - Attribute = MinAttribute + 1, - ShortDictionaryAttribute = MinAttribute + 2, - DictionaryAttribute = MinAttribute + 3, - ShortXmlnsAttribute = MinAttribute + 4, - XmlnsAttribute = MinAttribute + 5, - ShortDictionaryXmlnsAttribute = MinAttribute + 6, - DictionaryXmlnsAttribute = MinAttribute + 7, - PrefixDictionaryAttributeA = MinAttribute + 8, - PrefixDictionaryAttributeB = PrefixDictionaryAttributeA + 1, - PrefixDictionaryAttributeC = PrefixDictionaryAttributeB + 1, - PrefixDictionaryAttributeD = PrefixDictionaryAttributeC + 1, - PrefixDictionaryAttributeE = PrefixDictionaryAttributeD + 1, - PrefixDictionaryAttributeF = PrefixDictionaryAttributeE + 1, - PrefixDictionaryAttributeG = PrefixDictionaryAttributeF + 1, - PrefixDictionaryAttributeH = PrefixDictionaryAttributeG + 1, - PrefixDictionaryAttributeI = PrefixDictionaryAttributeH + 1, - PrefixDictionaryAttributeJ = PrefixDictionaryAttributeI + 1, - PrefixDictionaryAttributeK = PrefixDictionaryAttributeJ + 1, - PrefixDictionaryAttributeL = PrefixDictionaryAttributeK + 1, - PrefixDictionaryAttributeM = PrefixDictionaryAttributeL + 1, - PrefixDictionaryAttributeN = PrefixDictionaryAttributeM + 1, - PrefixDictionaryAttributeO = PrefixDictionaryAttributeN + 1, - PrefixDictionaryAttributeP = PrefixDictionaryAttributeO + 1, - PrefixDictionaryAttributeQ = PrefixDictionaryAttributeP + 1, - PrefixDictionaryAttributeR = PrefixDictionaryAttributeQ + 1, - PrefixDictionaryAttributeS = PrefixDictionaryAttributeR + 1, - PrefixDictionaryAttributeT = PrefixDictionaryAttributeS + 1, - PrefixDictionaryAttributeU = PrefixDictionaryAttributeT + 1, - PrefixDictionaryAttributeV = PrefixDictionaryAttributeU + 1, - PrefixDictionaryAttributeW = PrefixDictionaryAttributeV + 1, - PrefixDictionaryAttributeX = PrefixDictionaryAttributeW + 1, - PrefixDictionaryAttributeY = PrefixDictionaryAttributeX + 1, - PrefixDictionaryAttributeZ = PrefixDictionaryAttributeY + 1, - PrefixAttributeA = PrefixDictionaryAttributeZ + 1, - PrefixAttributeB = PrefixAttributeA + 1, - PrefixAttributeC = PrefixAttributeB + 1, - PrefixAttributeD = PrefixAttributeC + 1, - PrefixAttributeE = PrefixAttributeD + 1, - PrefixAttributeF = PrefixAttributeE + 1, - PrefixAttributeG = PrefixAttributeF + 1, - PrefixAttributeH = PrefixAttributeG + 1, - PrefixAttributeI = PrefixAttributeH + 1, - PrefixAttributeJ = PrefixAttributeI + 1, - PrefixAttributeK = PrefixAttributeJ + 1, - PrefixAttributeL = PrefixAttributeK + 1, - PrefixAttributeM = PrefixAttributeL + 1, - PrefixAttributeN = PrefixAttributeM + 1, - PrefixAttributeO = PrefixAttributeN + 1, - PrefixAttributeP = PrefixAttributeO + 1, - PrefixAttributeQ = PrefixAttributeP + 1, - PrefixAttributeR = PrefixAttributeQ + 1, - PrefixAttributeS = PrefixAttributeR + 1, - PrefixAttributeT = PrefixAttributeS + 1, - PrefixAttributeU = PrefixAttributeT + 1, - PrefixAttributeV = PrefixAttributeU + 1, - PrefixAttributeW = PrefixAttributeV + 1, - PrefixAttributeX = PrefixAttributeW + 1, - PrefixAttributeY = PrefixAttributeX + 1, - PrefixAttributeZ = PrefixAttributeY + 1, - MaxAttribute = PrefixAttributeZ, - - MinElement = MaxAttribute + 1, - ShortElement = MinElement, - Element = MinElement + 1, - ShortDictionaryElement = MinElement + 2, - DictionaryElement = MinElement + 3, - PrefixDictionaryElementA = MinElement + 4, - PrefixDictionaryElementB = PrefixDictionaryElementA + 1, - PrefixDictionaryElementC = PrefixDictionaryElementB + 1, - PrefixDictionaryElementD = PrefixDictionaryElementC + 1, - PrefixDictionaryElementE = PrefixDictionaryElementD + 1, - PrefixDictionaryElementF = PrefixDictionaryElementE + 1, - PrefixDictionaryElementG = PrefixDictionaryElementF + 1, - PrefixDictionaryElementH = PrefixDictionaryElementG + 1, - PrefixDictionaryElementI = PrefixDictionaryElementH + 1, - PrefixDictionaryElementJ = PrefixDictionaryElementI + 1, - PrefixDictionaryElementK = PrefixDictionaryElementJ + 1, - PrefixDictionaryElementL = PrefixDictionaryElementK + 1, - PrefixDictionaryElementM = PrefixDictionaryElementL + 1, - PrefixDictionaryElementN = PrefixDictionaryElementM + 1, - PrefixDictionaryElementO = PrefixDictionaryElementN + 1, - PrefixDictionaryElementP = PrefixDictionaryElementO + 1, - PrefixDictionaryElementQ = PrefixDictionaryElementP + 1, - PrefixDictionaryElementR = PrefixDictionaryElementQ + 1, - PrefixDictionaryElementS = PrefixDictionaryElementR + 1, - PrefixDictionaryElementT = PrefixDictionaryElementS + 1, - PrefixDictionaryElementU = PrefixDictionaryElementT + 1, - PrefixDictionaryElementV = PrefixDictionaryElementU + 1, - PrefixDictionaryElementW = PrefixDictionaryElementV + 1, - PrefixDictionaryElementX = PrefixDictionaryElementW + 1, - PrefixDictionaryElementY = PrefixDictionaryElementX + 1, - PrefixDictionaryElementZ = PrefixDictionaryElementY + 1, - PrefixElementA = PrefixDictionaryElementZ + 1, - PrefixElementB = PrefixElementA + 1, - PrefixElementC = PrefixElementB + 1, - PrefixElementD = PrefixElementC + 1, - PrefixElementE = PrefixElementD + 1, - PrefixElementF = PrefixElementE + 1, - PrefixElementG = PrefixElementF + 1, - PrefixElementH = PrefixElementG + 1, - PrefixElementI = PrefixElementH + 1, - PrefixElementJ = PrefixElementI + 1, - PrefixElementK = PrefixElementJ + 1, - PrefixElementL = PrefixElementK + 1, - PrefixElementM = PrefixElementL + 1, - PrefixElementN = PrefixElementM + 1, - PrefixElementO = PrefixElementN + 1, - PrefixElementP = PrefixElementO + 1, - PrefixElementQ = PrefixElementP + 1, - PrefixElementR = PrefixElementQ + 1, - PrefixElementS = PrefixElementR + 1, - PrefixElementT = PrefixElementS + 1, - PrefixElementU = PrefixElementT + 1, - PrefixElementV = PrefixElementU + 1, - PrefixElementW = PrefixElementV + 1, - PrefixElementX = PrefixElementW + 1, - PrefixElementY = PrefixElementX + 1, - PrefixElementZ = PrefixElementY + 1, - MaxElement = PrefixElementZ, + ShortAttribute = 4, + Attribute = 5, + ShortDictionaryAttribute = 6, + DictionaryAttribute = 7, + ShortXmlnsAttribute = 8, + XmlnsAttribute = 9, + ShortDictionaryXmlnsAttribute = 10, + DictionaryXmlnsAttribute = 11, + + PrefixDictionaryAttributeA = 12, + PrefixDictionaryAttributeB = 13, + PrefixDictionaryAttributeC = 14, + PrefixDictionaryAttributeD = 15, + PrefixDictionaryAttributeE = 16, + PrefixDictionaryAttributeF = 17, + PrefixDictionaryAttributeG = 18, + PrefixDictionaryAttributeH = 19, + PrefixDictionaryAttributeI = 20, + PrefixDictionaryAttributeJ = 21, + PrefixDictionaryAttributeK = 22, + PrefixDictionaryAttributeL = 23, + PrefixDictionaryAttributeM = 24, + PrefixDictionaryAttributeN = 25, + PrefixDictionaryAttributeO = 26, + PrefixDictionaryAttributeP = 27, + PrefixDictionaryAttributeQ = 28, + PrefixDictionaryAttributeR = 29, + PrefixDictionaryAttributeS = 30, + PrefixDictionaryAttributeT = 31, + PrefixDictionaryAttributeU = 32, + PrefixDictionaryAttributeV = 33, + PrefixDictionaryAttributeW = 34, + PrefixDictionaryAttributeX = 35, + PrefixDictionaryAttributeY = 36, + PrefixDictionaryAttributeZ = 37, + + PrefixAttributeA = 38, + PrefixAttributeB = 39, + PrefixAttributeC = 40, + PrefixAttributeD = 41, + PrefixAttributeE = 42, + PrefixAttributeF = 43, + PrefixAttributeG = 44, + PrefixAttributeH = 45, + PrefixAttributeI = 46, + PrefixAttributeJ = 47, + PrefixAttributeK = 48, + PrefixAttributeL = 49, + PrefixAttributeM = 50, + PrefixAttributeN = 51, + PrefixAttributeO = 52, + PrefixAttributeP = 53, + PrefixAttributeQ = 54, + PrefixAttributeR = 55, + PrefixAttributeS = 56, + PrefixAttributeT = 57, + PrefixAttributeU = 58, + PrefixAttributeV = 59, + PrefixAttributeW = 60, + PrefixAttributeX = 61, + PrefixAttributeY = 62, + PrefixAttributeZ = 63, + MaxAttribute = 63, - // MinorVersion = MaxElement + 1, // Reserved (Not supported) + MinElement = 64, + ShortElement = 64, + Element = 65, + ShortDictionaryElement = 66, + DictionaryElement = 67, + + PrefixDictionaryElementA = 68, + PrefixDictionaryElementB = 69, + PrefixDictionaryElementC = 70, + PrefixDictionaryElementD = 71, + PrefixDictionaryElementE = 72, + PrefixDictionaryElementF = 73, + PrefixDictionaryElementG = 74, + PrefixDictionaryElementH = 75, + PrefixDictionaryElementI = 76, + PrefixDictionaryElementJ = 77, + PrefixDictionaryElementK = 78, + PrefixDictionaryElementL = 79, + PrefixDictionaryElementM = 80, + PrefixDictionaryElementN = 81, + PrefixDictionaryElementO = 82, + PrefixDictionaryElementP = 83, + PrefixDictionaryElementQ = 84, + PrefixDictionaryElementR = 85, + PrefixDictionaryElementS = 86, + PrefixDictionaryElementT = 87, + PrefixDictionaryElementU = 88, + PrefixDictionaryElementV = 89, + PrefixDictionaryElementW = 90, + PrefixDictionaryElementX = 91, + PrefixDictionaryElementY = 92, + PrefixDictionaryElementZ = 93, + + PrefixElementA = 94, + PrefixElementB = 95, + PrefixElementC = 96, + PrefixElementD = 97, + PrefixElementE = 98, + PrefixElementF = 99, + PrefixElementG = 100, + PrefixElementH = 101, + PrefixElementI = 102, + PrefixElementJ = 103, + PrefixElementK = 104, + PrefixElementL = 105, + PrefixElementM = 106, + PrefixElementN = 107, + PrefixElementO = 108, + PrefixElementP = 109, + PrefixElementQ = 110, + PrefixElementR = 111, + PrefixElementS = 112, + PrefixElementT = 113, + PrefixElementU = 114, + PrefixElementV = 115, + PrefixElementW = 116, + PrefixElementX = 117, + PrefixElementY = 118, + PrefixElementZ = 119, + MaxElement = 119, - MinText = 0x80, // Must be even - ZeroText = MinText, - OneText = MinText + 1 * 2, - FalseText = MinText + 2 * 2, - TrueText = MinText + 3 * 2, - Int8Text = MinText + 4 * 2, - Int16Text = MinText + 5 * 2, - Int32Text = MinText + 6 * 2, - Int64Text = MinText + 7 * 2, - FloatText = MinText + 8 * 2, - DoubleText = MinText + 9 * 2, - DecimalText = MinText + 10 * 2, - DateTimeText = MinText + 11 * 2, - Chars8Text = MinText + 12 * 2, - Chars16Text = MinText + 13 * 2, - Chars32Text = MinText + 14 * 2, - Bytes8Text = MinText + 15 * 2, - Bytes16Text = MinText + 16 * 2, - Bytes32Text = MinText + 17 * 2, - StartListText = MinText + 18 * 2, - EndListText = MinText + 19 * 2, - EmptyText = MinText + 20 * 2, - DictionaryText = MinText + 21 * 2, - UniqueIdText = MinText + 22 * 2, - TimeSpanText = MinText + 23 * 2, - GuidText = MinText + 24 * 2, - UInt64Text = MinText + 25 * 2, - BoolText = MinText + 26 * 2, - UnicodeChars8Text = MinText + 27 * 2, - UnicodeChars16Text = MinText + 28 * 2, - UnicodeChars32Text = MinText + 29 * 2, - QNameDictionaryText = MinText + 30 * 2, + MinText = 128, + ZeroText = 128, + OneText = 130, + FalseText = 132, + TrueText = 134, + Int8Text = 136, + Int16Text = 138, + Int32Text = 140, + Int64Text = 142, + FloatText = 144, + DoubleText = 146, + DecimalText = 148, + DateTimeText = 150, + Chars8Text = 152, + Chars16Text = 154, + Chars32Text = 156, + Bytes8Text = 158, + Bytes16Text = 160, + Bytes32Text = 162, + StartListText = 164, + EndListText = 166, + EmptyText = 168, + DictionaryText = 170, + UniqueIdText = 172, + TimeSpanText = 174, + GuidText = 176, + UInt64Text = 178, + BoolText = 180, + UnicodeChars8Text = 182, + UnicodeChars16Text = 184, + UnicodeChars32Text = 186, + QNameDictionaryText = 188, - ZeroTextWithEndElement = ZeroText + 1, - OneTextWithEndElement = OneText + 1, - FalseTextWithEndElement = FalseText + 1, - TrueTextWithEndElement = TrueText + 1, - Int8TextWithEndElement = Int8Text + 1, - Int16TextWithEndElement = Int16Text + 1, - Int32TextWithEndElement = Int32Text + 1, - Int64TextWithEndElement = Int64Text + 1, - FloatTextWithEndElement = FloatText + 1, - DoubleTextWithEndElement = DoubleText + 1, - DecimalTextWithEndElement = DecimalText + 1, - DateTimeTextWithEndElement = DateTimeText + 1, - Chars8TextWithEndElement = Chars8Text + 1, - Chars16TextWithEndElement = Chars16Text + 1, - Chars32TextWithEndElement = Chars32Text + 1, - Bytes8TextWithEndElement = Bytes8Text + 1, - Bytes16TextWithEndElement = Bytes16Text + 1, - Bytes32TextWithEndElement = Bytes32Text + 1, - StartListTextWithEndElement = StartListText + 1, - EndListTextWithEndElement = EndListText + 1, - EmptyTextWithEndElement = EmptyText + 1, - DictionaryTextWithEndElement = DictionaryText + 1, - UniqueIdTextWithEndElement = UniqueIdText + 1, - TimeSpanTextWithEndElement = TimeSpanText + 1, - GuidTextWithEndElement = GuidText + 1, - UInt64TextWithEndElement = UInt64Text + 1, - BoolTextWithEndElement = BoolText + 1, - UnicodeChars8TextWithEndElement = UnicodeChars8Text + 1, - UnicodeChars16TextWithEndElement = UnicodeChars16Text + 1, - UnicodeChars32TextWithEndElement = UnicodeChars32Text + 1, - QNameDictionaryTextWithEndElement = QNameDictionaryText + 1, - MaxText = QNameDictionaryTextWithEndElement + ZeroTextWithEndElement = 129, + OneTextWithEndElement = 131, + FalseTextWithEndElement = 133, + TrueTextWithEndElement = 135, + Int8TextWithEndElement = 137, + Int16TextWithEndElement = 139, + Int32TextWithEndElement = 141, + Int64TextWithEndElement = 143, + FloatTextWithEndElement = 145, + DoubleTextWithEndElement = 147, + DecimalTextWithEndElement = 149, + DateTimeTextWithEndElement = 151, + Chars8TextWithEndElement = 153, + Chars16TextWithEndElement = 155, + Chars32TextWithEndElement = 157, + Bytes8TextWithEndElement = 159, + Bytes16TextWithEndElement = 161, + Bytes32TextWithEndElement = 163, + StartListTextWithEndElement = 165, + EndListTextWithEndElement = 167, + EmptyTextWithEndElement = 169, + DictionaryTextWithEndElement = 171, + UniqueIdTextWithEndElement = 173, + TimeSpanTextWithEndElement = 175, + GuidTextWithEndElement = 177, + UInt64TextWithEndElement = 179, + BoolTextWithEndElement = 181, + UnicodeChars8TextWithEndElement = 183, + UnicodeChars16TextWithEndElement = 185, + UnicodeChars32TextWithEndElement = 187, + QNameDictionaryTextWithEndElement = 189, + MaxText = 189 } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReader.cs deleted file mode 100644 index 60cc53fa25c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReader.cs +++ /dev/null @@ -1,1531 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; -using System.Globalization; -using System.Runtime.Serialization; - - -namespace Microsoft.Xml -{ - internal class XmlBinaryReader : XmlBaseReader - { - private bool _isTextWithEndElement; - private bool _buffered; - private ArrayState _arrayState; - private int _arrayCount; - private int _maxBytesPerRead; - private XmlBinaryNodeType _arrayNodeType; - - public XmlBinaryReader() - { - } - - public void SetInput(byte[] buffer, int offset, int count, - IXmlDictionary dictionary, - XmlDictionaryReaderQuotas quotas, - XmlBinaryReaderSession session) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer"); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > buffer.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, buffer.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > buffer.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); - MoveToInitial(quotas, session, null); - BufferReader.SetBuffer(buffer, offset, count, dictionary, session); - _buffered = true; - } - - public void SetInput(Stream stream, - IXmlDictionary dictionary, - XmlDictionaryReaderQuotas quotas, - XmlBinaryReaderSession session) - { - if (stream == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream"); - MoveToInitial(quotas, session, null); - BufferReader.SetBuffer(stream, dictionary, session); - _buffered = false; - } - - private void MoveToInitial(XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose) - { - MoveToInitial(quotas); - _maxBytesPerRead = quotas.MaxBytesPerRead; - _arrayState = ArrayState.None; - _isTextWithEndElement = false; - } - - public override void Close() - { - base.Close(); - } - - public override string ReadElementContentAsString() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (!CanOptimizeReadElementContent()) - return base.ReadElementContentAsString(); - string value; - switch (GetNodeType()) - { - case XmlBinaryNodeType.Chars8TextWithEndElement: - SkipNodeType(); - value = BufferReader.ReadUTF8String(ReadUInt8()); - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.DictionaryTextWithEndElement: - SkipNodeType(); - value = BufferReader.GetDictionaryString(ReadDictionaryKey()).Value; - ReadTextWithEndElement(); - break; - default: - value = base.ReadElementContentAsString(); - break; - } - if (value.Length > Quotas.MaxStringContentLength) - XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(this, Quotas.MaxStringContentLength); - return value; - } - - public override bool ReadElementContentAsBoolean() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (!CanOptimizeReadElementContent()) - return base.ReadElementContentAsBoolean(); - bool value; - switch (GetNodeType()) - { - case XmlBinaryNodeType.TrueTextWithEndElement: - SkipNodeType(); - value = true; - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.FalseTextWithEndElement: - SkipNodeType(); - value = false; - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.BoolTextWithEndElement: - SkipNodeType(); - value = (BufferReader.ReadUInt8() != 0); - ReadTextWithEndElement(); - break; - default: - value = base.ReadElementContentAsBoolean(); - break; - } - return value; - } - - public override int ReadElementContentAsInt() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (!CanOptimizeReadElementContent()) - return base.ReadElementContentAsInt(); - int value; - switch (GetNodeType()) - { - case XmlBinaryNodeType.ZeroTextWithEndElement: - SkipNodeType(); - value = 0; - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.OneTextWithEndElement: - SkipNodeType(); - value = 1; - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.Int8TextWithEndElement: - SkipNodeType(); - value = BufferReader.ReadInt8(); - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.Int16TextWithEndElement: - SkipNodeType(); - value = BufferReader.ReadInt16(); - ReadTextWithEndElement(); - break; - case XmlBinaryNodeType.Int32TextWithEndElement: - SkipNodeType(); - value = BufferReader.ReadInt32(); - ReadTextWithEndElement(); - break; - default: - value = base.ReadElementContentAsInt(); - break; - } - return value; - } - - private bool CanOptimizeReadElementContent() - { - return (_arrayState == ArrayState.None); - } - - public override float ReadElementContentAsFloat() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.FloatTextWithEndElement) - { - SkipNodeType(); - float value = BufferReader.ReadSingle(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsFloat(); - } - - public override double ReadElementContentAsDouble() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.DoubleTextWithEndElement) - { - SkipNodeType(); - double value = BufferReader.ReadDouble(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsDouble(); - } - - public override decimal ReadElementContentAsDecimal() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.DecimalTextWithEndElement) - { - SkipNodeType(); - decimal value = BufferReader.ReadDecimal(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsDecimal(); - } - - public override DateTime ReadElementContentAsDateTime() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.DateTimeTextWithEndElement) - { - SkipNodeType(); - DateTime value = BufferReader.ReadDateTime(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsDateTime(); - } - - public override TimeSpan ReadElementContentAsTimeSpan() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.TimeSpanTextWithEndElement) - { - SkipNodeType(); - TimeSpan value = BufferReader.ReadTimeSpan(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsTimeSpan(); - } - - public override Guid ReadElementContentAsGuid() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.GuidTextWithEndElement) - { - SkipNodeType(); - Guid value = BufferReader.ReadGuid(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsGuid(); - } - - public override UniqueId ReadElementContentAsUniqueId() - { - if (this.Node.NodeType != XmlNodeType.Element) - MoveToStartElement(); - if (CanOptimizeReadElementContent() && GetNodeType() == XmlBinaryNodeType.UniqueIdTextWithEndElement) - { - SkipNodeType(); - UniqueId value = BufferReader.ReadUniqueId(); - ReadTextWithEndElement(); - return value; - } - return base.ReadElementContentAsUniqueId(); - } - - public override bool TryGetBase64ContentLength(out int length) - { - length = 0; - if (!_buffered) - return false; - if (_arrayState != ArrayState.None) - return false; - int totalLength; - if (!this.Node.Value.TryGetByteArrayLength(out totalLength)) - return false; - int offset = BufferReader.Offset; - try - { - bool done = false; - while (!done && !BufferReader.EndOfFile) - { - XmlBinaryNodeType nodeType = GetNodeType(); - SkipNodeType(); - int actual; - switch (nodeType) - { - case XmlBinaryNodeType.Bytes8TextWithEndElement: - actual = BufferReader.ReadUInt8(); - done = true; - break; - case XmlBinaryNodeType.Bytes16TextWithEndElement: - actual = BufferReader.ReadUInt16(); - done = true; - break; - case XmlBinaryNodeType.Bytes32TextWithEndElement: - actual = BufferReader.ReadUInt31(); - done = true; - break; - case XmlBinaryNodeType.EndElement: - actual = 0; - done = true; - break; - case XmlBinaryNodeType.Bytes8Text: - actual = BufferReader.ReadUInt8(); - break; - case XmlBinaryNodeType.Bytes16Text: - actual = BufferReader.ReadUInt16(); - break; - case XmlBinaryNodeType.Bytes32Text: - actual = BufferReader.ReadUInt31(); - break; - default: - // Non-optimal or unexpected node - fallback - return false; - } - BufferReader.Advance(actual); - if (totalLength > int.MaxValue - actual) - return false; - totalLength += actual; - } - length = totalLength; - return true; - } - finally - { - BufferReader.Offset = offset; - } - } - - private void ReadTextWithEndElement() - { - ExitScope(); - ReadNode(); - } - - private XmlAtomicTextNode MoveToAtomicTextWithEndElement() - { - _isTextWithEndElement = true; - return MoveToAtomicText(); - } - - public override bool Read() - { - if (this.Node.ReadState == ReadState.Closed) - return false; - if (_isTextWithEndElement) - { - _isTextWithEndElement = false; - MoveToEndElement(); - return true; - } - if (_arrayState == ArrayState.Content) - { - if (_arrayCount != 0) - { - MoveToArrayElement(); - return true; - } - _arrayState = ArrayState.None; - } - if (this.Node.ExitScope) - { - ExitScope(); - } - return ReadNode(); - } - - private bool ReadNode() - { - if (!_buffered) - BufferReader.SetWindow(ElementNode.BufferOffset, _maxBytesPerRead); - - if (BufferReader.EndOfFile) - { - MoveToEndOfFile(); - return false; - } - - XmlBinaryNodeType nodeType; - if (_arrayState == ArrayState.None) - { - nodeType = GetNodeType(); - SkipNodeType(); - } - else - { - DiagnosticUtility.DebugAssert(_arrayState == ArrayState.Element, ""); - nodeType = _arrayNodeType; - _arrayCount--; - _arrayState = ArrayState.Content; - } - - XmlElementNode elementNode; - PrefixHandleType prefix; - switch (nodeType) - { - case XmlBinaryNodeType.ShortElement: - elementNode = EnterScope(); - elementNode.Prefix.SetValue(PrefixHandleType.Empty); - ReadName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(PrefixHandleType.Empty); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.Element: - elementNode = EnterScope(); - ReadName(elementNode.Prefix); - ReadName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(elementNode.Prefix); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.ShortDictionaryElement: - elementNode = EnterScope(); - elementNode.Prefix.SetValue(PrefixHandleType.Empty); - ReadDictionaryName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(PrefixHandleType.Empty); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.DictionaryElement: - elementNode = EnterScope(); - ReadName(elementNode.Prefix); - ReadDictionaryName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(elementNode.Prefix); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.PrefixElementA: - case XmlBinaryNodeType.PrefixElementB: - case XmlBinaryNodeType.PrefixElementC: - case XmlBinaryNodeType.PrefixElementD: - case XmlBinaryNodeType.PrefixElementE: - case XmlBinaryNodeType.PrefixElementF: - case XmlBinaryNodeType.PrefixElementG: - case XmlBinaryNodeType.PrefixElementH: - case XmlBinaryNodeType.PrefixElementI: - case XmlBinaryNodeType.PrefixElementJ: - case XmlBinaryNodeType.PrefixElementK: - case XmlBinaryNodeType.PrefixElementL: - case XmlBinaryNodeType.PrefixElementM: - case XmlBinaryNodeType.PrefixElementN: - case XmlBinaryNodeType.PrefixElementO: - case XmlBinaryNodeType.PrefixElementP: - case XmlBinaryNodeType.PrefixElementQ: - case XmlBinaryNodeType.PrefixElementR: - case XmlBinaryNodeType.PrefixElementS: - case XmlBinaryNodeType.PrefixElementT: - case XmlBinaryNodeType.PrefixElementU: - case XmlBinaryNodeType.PrefixElementV: - case XmlBinaryNodeType.PrefixElementW: - case XmlBinaryNodeType.PrefixElementX: - case XmlBinaryNodeType.PrefixElementY: - case XmlBinaryNodeType.PrefixElementZ: - elementNode = EnterScope(); - prefix = PrefixHandle.GetAlphaPrefix((int)nodeType - (int)XmlBinaryNodeType.PrefixElementA); - elementNode.Prefix.SetValue(prefix); - ReadName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(prefix); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.PrefixDictionaryElementA: - case XmlBinaryNodeType.PrefixDictionaryElementB: - case XmlBinaryNodeType.PrefixDictionaryElementC: - case XmlBinaryNodeType.PrefixDictionaryElementD: - case XmlBinaryNodeType.PrefixDictionaryElementE: - case XmlBinaryNodeType.PrefixDictionaryElementF: - case XmlBinaryNodeType.PrefixDictionaryElementG: - case XmlBinaryNodeType.PrefixDictionaryElementH: - case XmlBinaryNodeType.PrefixDictionaryElementI: - case XmlBinaryNodeType.PrefixDictionaryElementJ: - case XmlBinaryNodeType.PrefixDictionaryElementK: - case XmlBinaryNodeType.PrefixDictionaryElementL: - case XmlBinaryNodeType.PrefixDictionaryElementM: - case XmlBinaryNodeType.PrefixDictionaryElementN: - case XmlBinaryNodeType.PrefixDictionaryElementO: - case XmlBinaryNodeType.PrefixDictionaryElementP: - case XmlBinaryNodeType.PrefixDictionaryElementQ: - case XmlBinaryNodeType.PrefixDictionaryElementR: - case XmlBinaryNodeType.PrefixDictionaryElementS: - case XmlBinaryNodeType.PrefixDictionaryElementT: - case XmlBinaryNodeType.PrefixDictionaryElementU: - case XmlBinaryNodeType.PrefixDictionaryElementV: - case XmlBinaryNodeType.PrefixDictionaryElementW: - case XmlBinaryNodeType.PrefixDictionaryElementX: - case XmlBinaryNodeType.PrefixDictionaryElementY: - case XmlBinaryNodeType.PrefixDictionaryElementZ: - elementNode = EnterScope(); - prefix = PrefixHandle.GetAlphaPrefix((int)nodeType - (int)XmlBinaryNodeType.PrefixDictionaryElementA); - elementNode.Prefix.SetValue(prefix); - ReadDictionaryName(elementNode.LocalName); - ReadAttributes(); - elementNode.Namespace = LookupNamespace(prefix); - elementNode.BufferOffset = BufferReader.Offset; - return true; - case XmlBinaryNodeType.EndElement: - MoveToEndElement(); - return true; - case XmlBinaryNodeType.Comment: - ReadName(MoveToComment().Value); - return true; - case XmlBinaryNodeType.EmptyTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ValueHandleType.Empty); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.ZeroTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ValueHandleType.Zero); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.OneTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ValueHandleType.One); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.TrueTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ValueHandleType.True); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.FalseTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ValueHandleType.False); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.BoolTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetValue(ReadUInt8() != 0 ? ValueHandleType.True : ValueHandleType.False); - if (this.OutsideRootElement) - VerifyWhitespace(); - return true; - case XmlBinaryNodeType.Chars8TextWithEndElement: - if (_buffered) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UTF8, ReadUInt8()); - else - ReadPartialUTF8Text(true, ReadUInt8()); - return true; - case XmlBinaryNodeType.Chars8Text: - if (_buffered) - ReadText(MoveToComplexText(), ValueHandleType.UTF8, ReadUInt8()); - else - ReadPartialUTF8Text(false, ReadUInt8()); - return true; - case XmlBinaryNodeType.Chars16TextWithEndElement: - if (_buffered) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UTF8, ReadUInt16()); - else - ReadPartialUTF8Text(true, ReadUInt16()); - return true; - case XmlBinaryNodeType.Chars16Text: - if (_buffered) - ReadText(MoveToComplexText(), ValueHandleType.UTF8, ReadUInt16()); - else - ReadPartialUTF8Text(false, ReadUInt16()); - return true; - case XmlBinaryNodeType.Chars32TextWithEndElement: - if (_buffered) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UTF8, ReadUInt31()); - else - ReadPartialUTF8Text(true, ReadUInt31()); - return true; - case XmlBinaryNodeType.Chars32Text: - if (_buffered) - ReadText(MoveToComplexText(), ValueHandleType.UTF8, ReadUInt31()); - else - ReadPartialUTF8Text(false, ReadUInt31()); - return true; - case XmlBinaryNodeType.UnicodeChars8TextWithEndElement: - ReadUnicodeText(true, ReadUInt8()); - return true; - case XmlBinaryNodeType.UnicodeChars8Text: - ReadUnicodeText(false, ReadUInt8()); - return true; - case XmlBinaryNodeType.UnicodeChars16TextWithEndElement: - ReadUnicodeText(true, ReadUInt16()); - return true; - case XmlBinaryNodeType.UnicodeChars16Text: - ReadUnicodeText(false, ReadUInt16()); - return true; - case XmlBinaryNodeType.UnicodeChars32TextWithEndElement: - ReadUnicodeText(true, ReadUInt31()); - return true; - case XmlBinaryNodeType.UnicodeChars32Text: - ReadUnicodeText(false, ReadUInt31()); - return true; - case XmlBinaryNodeType.Bytes8TextWithEndElement: - if (_buffered) - ReadBinaryText(MoveToAtomicTextWithEndElement(), ReadUInt8()); - else - ReadPartialBinaryText(true, ReadUInt8()); - return true; - case XmlBinaryNodeType.Bytes8Text: - if (_buffered) - ReadBinaryText(MoveToComplexText(), ReadUInt8()); - else - ReadPartialBinaryText(false, ReadUInt8()); - return true; - case XmlBinaryNodeType.Bytes16TextWithEndElement: - if (_buffered) - ReadBinaryText(MoveToAtomicTextWithEndElement(), ReadUInt16()); - else - ReadPartialBinaryText(true, ReadUInt16()); - return true; - case XmlBinaryNodeType.Bytes16Text: - if (_buffered) - ReadBinaryText(MoveToComplexText(), ReadUInt16()); - else - ReadPartialBinaryText(false, ReadUInt16()); - return true; - case XmlBinaryNodeType.Bytes32TextWithEndElement: - if (_buffered) - ReadBinaryText(MoveToAtomicTextWithEndElement(), ReadUInt31()); - else - ReadPartialBinaryText(true, ReadUInt31()); - return true; - case XmlBinaryNodeType.Bytes32Text: - if (_buffered) - ReadBinaryText(MoveToComplexText(), ReadUInt31()); - else - ReadPartialBinaryText(false, ReadUInt31()); - return true; - case XmlBinaryNodeType.DictionaryTextWithEndElement: - MoveToAtomicTextWithEndElement().Value.SetDictionaryValue(ReadDictionaryKey()); - return true; - case XmlBinaryNodeType.UniqueIdTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UniqueId, ValueHandleLength.UniqueId); - return true; - case XmlBinaryNodeType.GuidTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Guid, ValueHandleLength.Guid); - return true; - case XmlBinaryNodeType.DecimalTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Decimal, ValueHandleLength.Decimal); - return true; - case XmlBinaryNodeType.Int8TextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Int8, ValueHandleLength.Int8); - return true; - case XmlBinaryNodeType.Int16TextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Int16, ValueHandleLength.Int16); - return true; - case XmlBinaryNodeType.Int32TextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Int32, ValueHandleLength.Int32); - return true; - case XmlBinaryNodeType.Int64TextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Int64, ValueHandleLength.Int64); - return true; - case XmlBinaryNodeType.UInt64TextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UInt64, ValueHandleLength.UInt64); - return true; - case XmlBinaryNodeType.FloatTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Single, ValueHandleLength.Single); - return true; - case XmlBinaryNodeType.DoubleTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Double, ValueHandleLength.Double); - return true; - case XmlBinaryNodeType.TimeSpanTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.TimeSpan, ValueHandleLength.TimeSpan); - return true; - case XmlBinaryNodeType.DateTimeTextWithEndElement: - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.DateTime, ValueHandleLength.DateTime); - return true; - case XmlBinaryNodeType.QNameDictionaryTextWithEndElement: - BufferReader.ReadQName(MoveToAtomicTextWithEndElement().Value); - return true; - case XmlBinaryNodeType.Array: - ReadArray(); - return true; - default: - BufferReader.ReadValue(nodeType, MoveToComplexText().Value); - return true; - } - } - - private void VerifyWhitespace() - { - if (!this.Node.Value.IsWhitespace()) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - } - - private void ReadAttributes() - { - XmlBinaryNodeType nodeType = GetNodeType(); - if (nodeType < XmlBinaryNodeType.MinAttribute || nodeType > XmlBinaryNodeType.MaxAttribute) - return; - ReadAttributes2(); - } - - private void ReadAttributes2() - { - int startOffset = 0; - if (_buffered) - startOffset = BufferReader.Offset; - - while (true) - { - XmlAttributeNode attributeNode; - Namespace nameSpace; - PrefixHandleType prefix; - XmlBinaryNodeType nodeType = GetNodeType(); - switch (nodeType) - { - case XmlBinaryNodeType.ShortAttribute: - SkipNodeType(); - attributeNode = AddAttribute(); - attributeNode.Prefix.SetValue(PrefixHandleType.Empty); - ReadName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - break; - case XmlBinaryNodeType.Attribute: - SkipNodeType(); - attributeNode = AddAttribute(); - ReadName(attributeNode.Prefix); - ReadName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - FixXmlAttribute(attributeNode); - break; - case XmlBinaryNodeType.ShortDictionaryAttribute: - SkipNodeType(); - attributeNode = AddAttribute(); - attributeNode.Prefix.SetValue(PrefixHandleType.Empty); - ReadDictionaryName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - break; - case XmlBinaryNodeType.DictionaryAttribute: - SkipNodeType(); - attributeNode = AddAttribute(); - ReadName(attributeNode.Prefix); - ReadDictionaryName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - break; - case XmlBinaryNodeType.XmlnsAttribute: - SkipNodeType(); - nameSpace = AddNamespace(); - ReadName(nameSpace.Prefix); - ReadName(nameSpace.Uri); - attributeNode = AddXmlnsAttribute(nameSpace); - break; - case XmlBinaryNodeType.ShortXmlnsAttribute: - SkipNodeType(); - nameSpace = AddNamespace(); - nameSpace.Prefix.SetValue(PrefixHandleType.Empty); - ReadName(nameSpace.Uri); - attributeNode = AddXmlnsAttribute(nameSpace); - break; - case XmlBinaryNodeType.ShortDictionaryXmlnsAttribute: - SkipNodeType(); - nameSpace = AddNamespace(); - nameSpace.Prefix.SetValue(PrefixHandleType.Empty); - ReadDictionaryName(nameSpace.Uri); - attributeNode = AddXmlnsAttribute(nameSpace); - break; - case XmlBinaryNodeType.DictionaryXmlnsAttribute: - SkipNodeType(); - nameSpace = AddNamespace(); - ReadName(nameSpace.Prefix); - ReadDictionaryName(nameSpace.Uri); - attributeNode = AddXmlnsAttribute(nameSpace); - break; - case XmlBinaryNodeType.PrefixDictionaryAttributeA: - case XmlBinaryNodeType.PrefixDictionaryAttributeB: - case XmlBinaryNodeType.PrefixDictionaryAttributeC: - case XmlBinaryNodeType.PrefixDictionaryAttributeD: - case XmlBinaryNodeType.PrefixDictionaryAttributeE: - case XmlBinaryNodeType.PrefixDictionaryAttributeF: - case XmlBinaryNodeType.PrefixDictionaryAttributeG: - case XmlBinaryNodeType.PrefixDictionaryAttributeH: - case XmlBinaryNodeType.PrefixDictionaryAttributeI: - case XmlBinaryNodeType.PrefixDictionaryAttributeJ: - case XmlBinaryNodeType.PrefixDictionaryAttributeK: - case XmlBinaryNodeType.PrefixDictionaryAttributeL: - case XmlBinaryNodeType.PrefixDictionaryAttributeM: - case XmlBinaryNodeType.PrefixDictionaryAttributeN: - case XmlBinaryNodeType.PrefixDictionaryAttributeO: - case XmlBinaryNodeType.PrefixDictionaryAttributeP: - case XmlBinaryNodeType.PrefixDictionaryAttributeQ: - case XmlBinaryNodeType.PrefixDictionaryAttributeR: - case XmlBinaryNodeType.PrefixDictionaryAttributeS: - case XmlBinaryNodeType.PrefixDictionaryAttributeT: - case XmlBinaryNodeType.PrefixDictionaryAttributeU: - case XmlBinaryNodeType.PrefixDictionaryAttributeV: - case XmlBinaryNodeType.PrefixDictionaryAttributeW: - case XmlBinaryNodeType.PrefixDictionaryAttributeX: - case XmlBinaryNodeType.PrefixDictionaryAttributeY: - case XmlBinaryNodeType.PrefixDictionaryAttributeZ: - SkipNodeType(); - attributeNode = AddAttribute(); - prefix = PrefixHandle.GetAlphaPrefix((int)nodeType - (int)XmlBinaryNodeType.PrefixDictionaryAttributeA); - attributeNode.Prefix.SetValue(prefix); - ReadDictionaryName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - break; - case XmlBinaryNodeType.PrefixAttributeA: - case XmlBinaryNodeType.PrefixAttributeB: - case XmlBinaryNodeType.PrefixAttributeC: - case XmlBinaryNodeType.PrefixAttributeD: - case XmlBinaryNodeType.PrefixAttributeE: - case XmlBinaryNodeType.PrefixAttributeF: - case XmlBinaryNodeType.PrefixAttributeG: - case XmlBinaryNodeType.PrefixAttributeH: - case XmlBinaryNodeType.PrefixAttributeI: - case XmlBinaryNodeType.PrefixAttributeJ: - case XmlBinaryNodeType.PrefixAttributeK: - case XmlBinaryNodeType.PrefixAttributeL: - case XmlBinaryNodeType.PrefixAttributeM: - case XmlBinaryNodeType.PrefixAttributeN: - case XmlBinaryNodeType.PrefixAttributeO: - case XmlBinaryNodeType.PrefixAttributeP: - case XmlBinaryNodeType.PrefixAttributeQ: - case XmlBinaryNodeType.PrefixAttributeR: - case XmlBinaryNodeType.PrefixAttributeS: - case XmlBinaryNodeType.PrefixAttributeT: - case XmlBinaryNodeType.PrefixAttributeU: - case XmlBinaryNodeType.PrefixAttributeV: - case XmlBinaryNodeType.PrefixAttributeW: - case XmlBinaryNodeType.PrefixAttributeX: - case XmlBinaryNodeType.PrefixAttributeY: - case XmlBinaryNodeType.PrefixAttributeZ: - SkipNodeType(); - attributeNode = AddAttribute(); - prefix = PrefixHandle.GetAlphaPrefix((int)nodeType - (int)XmlBinaryNodeType.PrefixAttributeA); - attributeNode.Prefix.SetValue(prefix); - ReadName(attributeNode.LocalName); - ReadAttributeText(attributeNode.AttributeText); - break; - default: - ProcessAttributes(); - return; - } - } - } - - private void ReadText(XmlTextNode textNode, ValueHandleType type, int length) - { - int offset = BufferReader.ReadBytes(length); - textNode.Value.SetValue(type, offset, length); - if (this.OutsideRootElement) - VerifyWhitespace(); - } - - private void ReadBinaryText(XmlTextNode textNode, int length) - { - ReadText(textNode, ValueHandleType.Base64, length); - } - - private void ReadPartialUTF8Text(bool withEndElement, int length) - { - // The maxBytesPerRead includes the quota for the XmlBinaryNodeType.TextNode, so we need - // to account for that. - const int maxTextNodeLength = 5; - int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0); - if (length <= maxLength) - { - if (withEndElement) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.UTF8, length); - else - ReadText(MoveToComplexText(), ValueHandleType.UTF8, length); - } - else - { - // We also need to make sure we have enough room to insert a new XmlBinaryNodeType.TextNode - // for the split data. - int actual = Math.Max(maxLength - maxTextNodeLength, 0); - int offset = BufferReader.ReadBytes(actual); - - // We need to make sure we don't split a utf8 character, so scan backwards for a - // character boundary. We'll actually always push off at least one character since - // although we find the character boundary, we don't bother to figure out if we have - // all the bytes that comprise the character. - int i; - for (i = offset + actual - 1; i >= offset; i--) - { - byte b = BufferReader.GetByte(i); - // The first byte of UTF8 character sequence has either the high bit off, or the - // two high bits set. - if ((b & 0x80) == 0 || (b & 0xC0) == 0xC0) - break; - } - - // Move any split characters so we can insert the node - int byteCount = (offset + actual - i); - - // Include the split characters in the count - BufferReader.Offset = BufferReader.Offset - byteCount; - actual -= byteCount; - MoveToComplexText().Value.SetValue(ValueHandleType.UTF8, offset, actual); - if (this.OutsideRootElement) - VerifyWhitespace(); - - XmlBinaryNodeType nodeType = (withEndElement ? XmlBinaryNodeType.Chars32TextWithEndElement : XmlBinaryNodeType.Chars32Text); - InsertNode(nodeType, length - actual); - } - } - - private void ReadUnicodeText(bool withEndElement, int length) - { - if ((length & 1) != 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - if (_buffered) - { - if (withEndElement) - { - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Unicode, length); - } - else - { - ReadText(MoveToComplexText(), ValueHandleType.Unicode, length); - } - } - else - { - ReadPartialUnicodeText(withEndElement, length); - } - } - - private void ReadPartialUnicodeText(bool withEndElement, int length) - { - // The maxBytesPerRead includes the quota for the XmlBinaryNodeType.TextNode, so we need - // to account for that. - const int maxTextNodeLength = 5; - int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0); - if (length <= maxLength) - { - if (withEndElement) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Unicode, length); - else - ReadText(MoveToComplexText(), ValueHandleType.Unicode, length); - } - else - { - // We also need to make sure we have enough room to insert a new XmlBinaryNodeType.TextNode - // for the split data. - int actual = Math.Max(maxLength - maxTextNodeLength, 0); - - // Make sure we break on a char boundary - if ((actual & 1) != 0) - actual--; - - int offset = BufferReader.ReadBytes(actual); - - // We need to make sure we don't split a unicode surrogate character - int byteCount = 0; - char ch = (char)BufferReader.GetInt16(offset + actual - sizeof(char)); - // If the last char is a high surrogate char, then move back - if (ch >= 0xD800 && ch < 0xDC00) - byteCount = sizeof(char); - - // Include the split characters in the count - BufferReader.Offset = BufferReader.Offset - byteCount; - actual -= byteCount; - MoveToComplexText().Value.SetValue(ValueHandleType.Unicode, offset, actual); - if (this.OutsideRootElement) - VerifyWhitespace(); - - XmlBinaryNodeType nodeType = (withEndElement ? XmlBinaryNodeType.UnicodeChars32TextWithEndElement : XmlBinaryNodeType.UnicodeChars32Text); - InsertNode(nodeType, length - actual); - } - } - - private void ReadPartialBinaryText(bool withEndElement, int length) - { - const int nodeLength = 5; - int maxBytesPerRead = Math.Max(_maxBytesPerRead - nodeLength, 0); - if (length <= maxBytesPerRead) - { - if (withEndElement) - ReadText(MoveToAtomicTextWithEndElement(), ValueHandleType.Base64, length); - else - ReadText(MoveToComplexText(), ValueHandleType.Base64, length); - } - else - { - int actual = maxBytesPerRead; - if (actual > 3) - actual -= (actual % 3); - ReadText(MoveToComplexText(), ValueHandleType.Base64, actual); - XmlBinaryNodeType nodeType = (withEndElement ? XmlBinaryNodeType.Bytes32TextWithEndElement : XmlBinaryNodeType.Bytes32Text); - InsertNode(nodeType, length - actual); - } - } - - private void InsertNode(XmlBinaryNodeType nodeType, int length) - { - byte[] buffer = new byte[5]; - buffer[0] = (byte)nodeType; - buffer[1] = (byte)length; - length >>= 8; - buffer[2] = (byte)length; - length >>= 8; - buffer[3] = (byte)length; - length >>= 8; - buffer[4] = (byte)length; - BufferReader.InsertBytes(buffer, 0, buffer.Length); - } - - private void ReadAttributeText(XmlAttributeTextNode textNode) - { - XmlBinaryNodeType nodeType = GetNodeType(); - SkipNodeType(); - BufferReader.ReadValue(nodeType, textNode.Value); - } - - private void ReadName(ValueHandle value) - { - int length = ReadMultiByteUInt31(); - int offset = BufferReader.ReadBytes(length); - value.SetValue(ValueHandleType.UTF8, offset, length); - } - - private void ReadName(StringHandle handle) - { - int length = ReadMultiByteUInt31(); - int offset = BufferReader.ReadBytes(length); - handle.SetValue(offset, length); - } - - private void ReadName(PrefixHandle prefix) - { - int length = ReadMultiByteUInt31(); - int offset = BufferReader.ReadBytes(length); - prefix.SetValue(offset, length); - } - - private void ReadDictionaryName(StringHandle s) - { - int key = ReadDictionaryKey(); - s.SetValue(key); - } - - private XmlBinaryNodeType GetNodeType() - { - return BufferReader.GetNodeType(); - } - - private void SkipNodeType() - { - BufferReader.SkipNodeType(); - } - - private int ReadDictionaryKey() - { - return BufferReader.ReadDictionaryKey(); - } - - private int ReadMultiByteUInt31() - { - return BufferReader.ReadMultiByteUInt31(); - } - - private int ReadUInt8() - { - return BufferReader.ReadUInt8(); - } - - private int ReadUInt16() - { - return BufferReader.ReadUInt16(); - } - - private int ReadUInt31() - { - return BufferReader.ReadUInt31(); - } - - private bool IsValidArrayType(XmlBinaryNodeType nodeType) - { - switch (nodeType) - { - case XmlBinaryNodeType.BoolTextWithEndElement: - case XmlBinaryNodeType.Int16TextWithEndElement: - case XmlBinaryNodeType.Int32TextWithEndElement: - case XmlBinaryNodeType.Int64TextWithEndElement: - case XmlBinaryNodeType.FloatTextWithEndElement: - case XmlBinaryNodeType.DoubleTextWithEndElement: - case XmlBinaryNodeType.DecimalTextWithEndElement: - case XmlBinaryNodeType.DateTimeTextWithEndElement: - case XmlBinaryNodeType.TimeSpanTextWithEndElement: - case XmlBinaryNodeType.GuidTextWithEndElement: - return true; - default: - return false; - } - } - - private void ReadArray() - { - if (GetNodeType() == XmlBinaryNodeType.Array) // Prevent recursion - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - ReadNode(); // ReadStartElement - if (this.Node.NodeType != XmlNodeType.Element) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - if (GetNodeType() == XmlBinaryNodeType.Array) // Prevent recursion - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - ReadNode(); // ReadEndElement - if (this.Node.NodeType != XmlNodeType.EndElement) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - _arrayState = ArrayState.Element; - _arrayNodeType = GetNodeType(); - if (!IsValidArrayType(_arrayNodeType)) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - SkipNodeType(); - _arrayCount = ReadMultiByteUInt31(); - if (_arrayCount == 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(this); - MoveToArrayElement(); - } - - private void MoveToArrayElement() - { - _arrayState = ArrayState.Element; - MoveToNode(ElementNode); - } - - private void SkipArrayElements(int count) - { - _arrayCount -= count; - if (_arrayCount == 0) - { - _arrayState = ArrayState.None; - ExitScope(); - ReadNode(); - } - } - - public override bool IsStartArray(out Type type) - { - type = null; - if (_arrayState != ArrayState.Element) - return false; - switch (_arrayNodeType) - { - case XmlBinaryNodeType.BoolTextWithEndElement: - type = typeof(bool); - break; - case XmlBinaryNodeType.Int16TextWithEndElement: - type = typeof(Int16); - break; - case XmlBinaryNodeType.Int32TextWithEndElement: - type = typeof(Int32); - break; - case XmlBinaryNodeType.Int64TextWithEndElement: - type = typeof(Int64); - break; - case XmlBinaryNodeType.FloatTextWithEndElement: - type = typeof(float); - break; - case XmlBinaryNodeType.DoubleTextWithEndElement: - type = typeof(double); - break; - case XmlBinaryNodeType.DecimalTextWithEndElement: - type = typeof(decimal); - break; - case XmlBinaryNodeType.DateTimeTextWithEndElement: - type = typeof(DateTime); - break; - case XmlBinaryNodeType.GuidTextWithEndElement: - type = typeof(Guid); - break; - case XmlBinaryNodeType.TimeSpanTextWithEndElement: - type = typeof(TimeSpan); - break; - case XmlBinaryNodeType.UniqueIdTextWithEndElement: - type = typeof(UniqueId); - break; - default: - return false; - } - return true; - } - - public override bool TryGetArrayLength(out int count) - { - count = 0; - if (!_buffered) - return false; - if (_arrayState != ArrayState.Element) - return false; - count = _arrayCount; - return true; - } - - private bool IsStartArray(string localName, string namespaceUri, XmlBinaryNodeType nodeType) - { - return IsStartElement(localName, namespaceUri) && _arrayState == ArrayState.Element && _arrayNodeType == nodeType; - } - - private bool IsStartArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType) - { - return IsStartElement(localName, namespaceUri) && _arrayState == ArrayState.Element && _arrayNodeType == nodeType; - } - - private void CheckArray(Array array, int offset, int count) - { - if (array == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("array")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > array.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, array.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > array.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, array.Length - offset))); - } - - // bool - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(bool[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (bool* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, bool[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // Int16 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(Int16[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (Int16* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, Int16[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int16[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // Int32 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(Int32[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (Int32* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, Int32[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int32[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // Int64 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(Int64[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (Int64* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, Int64[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int64[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement) && BitConverter.IsLittleEndian) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // float - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(float[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (float* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, float[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // double - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(double[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (double* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, double[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // decimal - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe int ReadArray(decimal[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - fixed (decimal* items = &array[offset]) - { - BufferReader.UnsafeReadArray((byte*)items, (byte*)&items[actual]); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, decimal[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // DateTime - private int ReadArray(DateTime[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - for (int i = 0; i < actual; i++) - { - array[offset + i] = BufferReader.ReadDateTime(); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, DateTime[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DateTimeTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.DateTimeTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // Guid - private int ReadArray(Guid[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - for (int i = 0; i < actual; i++) - { - array[offset + i] = BufferReader.ReadGuid(); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, Guid[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.GuidTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.GuidTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - // TimeSpan - private int ReadArray(TimeSpan[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = Math.Min(count, _arrayCount); - for (int i = 0; i < actual; i++) - { - array[offset + i] = BufferReader.ReadTimeSpan(); - } - SkipArrayElements(actual); - return actual; - } - - public override int ReadArray(string localName, string namespaceUri, TimeSpan[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.TimeSpanTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - public override int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count) - { - if (IsStartArray(localName, namespaceUri, XmlBinaryNodeType.TimeSpanTextWithEndElement)) - return ReadArray(array, offset, count); - return base.ReadArray(localName, namespaceUri, array, offset, count); - } - - private enum ArrayState - { - None, - Element, - Content - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReaderSession.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReaderSession.cs deleted file mode 100644 index 2d09dd6d76e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryReaderSession.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using StringHandle = System.Int64; -using Microsoft.Xml; -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace Microsoft.Xml -{ - using System; - - public class XmlBinaryReaderSession : IXmlDictionary - { - private const int MaxArrayEntries = 2048; - - private XmlDictionaryString[] _strings; - private Dictionary _stringDict; - - public XmlBinaryReaderSession() - { - } - - public XmlDictionaryString Add(int id, string value) - { - if (id < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(string.Format(SRSerialization.XmlInvalidID))); - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - XmlDictionaryString xmlString; - if (TryLookup(id, out xmlString)) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.XmlIDDefined))); - - xmlString = new XmlDictionaryString(this, value, id); - if (id >= MaxArrayEntries) - { - if (_stringDict == null) - _stringDict = new Dictionary(); - - _stringDict.Add(id, xmlString); - } - else - { - if (_strings == null) - { - _strings = new XmlDictionaryString[Math.Max(id + 1, 16)]; - } - else if (id >= _strings.Length) - { - XmlDictionaryString[] newStrings = new XmlDictionaryString[Math.Min(Math.Max(id + 1, _strings.Length * 2), MaxArrayEntries)]; - Array.Copy(_strings, 0, newStrings, 0, _strings.Length); - _strings = newStrings; - } - _strings[id] = xmlString; - } - return xmlString; - } - - public bool TryLookup(int key, out XmlDictionaryString result) - { - if (_strings != null && key >= 0 && key < _strings.Length) - { - result = _strings[key]; - return result != null; - } - else if (key >= MaxArrayEntries) - { - if (_stringDict != null) - return _stringDict.TryGetValue(key, out result); - } - result = null; - return false; - } - - public bool TryLookup(string value, out XmlDictionaryString result) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - - if (_strings != null) - { - for (int i = 0; i < _strings.Length; i++) - { - XmlDictionaryString s = _strings[i]; - if (s != null && s.Value == value) - { - result = s; - return true; - } - } - } - - if (_stringDict != null) - { - foreach (XmlDictionaryString s in _stringDict.Values) - { - if (s.Value == value) - { - result = s; - return true; - } - } - } - - result = null; - return false; - } - - public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); - if (value.Dictionary != this) - { - result = null; - return false; - } - result = value; - return true; - } - - public void Clear() - { - if (_strings != null) - Array.Clear(_strings, 0, _strings.Length); - - if (_stringDict != null) - _stringDict.Clear(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriter.cs deleted file mode 100644 index e82d942ca94..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriter.cs +++ /dev/null @@ -1,1635 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -// Uncomment to turn on logging of non-dictionary strings written to binary writers. -// This can help identify element/attribute name/ns that could be written as XmlDictionaryStrings to get better compactness and performance. -// #define LOG_NON_DICTIONARY_WRITES - -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Globalization; -using System.Collections.Generic; -using System.Security; - - -namespace Microsoft.Xml -{ - internal class XmlBinaryNodeWriter : XmlStreamNodeWriter - { - private IXmlDictionary _dictionary; - private XmlBinaryWriterSession _session; - private bool _inAttribute; - private bool _inList; - private bool _wroteAttributeValue; - private AttributeValue _attributeValue; - private const int maxBytesPerChar = 3; - private int _textNodeOffset; - - public XmlBinaryNodeWriter() - { - // Sanity check on node values - DiagnosticUtility.DebugAssert(XmlBinaryNodeType.MaxAttribute < XmlBinaryNodeType.MinElement && - XmlBinaryNodeType.MaxElement < XmlBinaryNodeType.MinText && - (int)XmlBinaryNodeType.MaxText < 256, "NodeTypes enumeration messed up"); - } - - public void SetOutput(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream) - { - _dictionary = dictionary; - _session = session; - _inAttribute = false; - _inList = false; - _attributeValue.Clear(); - _textNodeOffset = -1; - SetOutput(stream, ownsStream, null); - } - - private void WriteNode(XmlBinaryNodeType nodeType) - { - WriteByte((byte)nodeType); - _textNodeOffset = -1; - } - - private void WroteAttributeValue() - { - if (_wroteAttributeValue && !_inList) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.XmlOnlySingleValue))); - _wroteAttributeValue = true; - } - - private void WriteTextNode(XmlBinaryNodeType nodeType) - { - if (_inAttribute) - WroteAttributeValue(); - DiagnosticUtility.DebugAssert(nodeType >= XmlBinaryNodeType.MinText && nodeType <= XmlBinaryNodeType.MaxText && ((byte)nodeType & 1) == 0, "Invalid nodeType"); - WriteByte((byte)nodeType); - _textNodeOffset = this.BufferOffset - 1; - } - - private byte[] GetTextNodeBuffer(int size, out int offset) - { - if (_inAttribute) - WroteAttributeValue(); - byte[] buffer = GetBuffer(size, out offset); - _textNodeOffset = offset; - return buffer; - } - - private void WriteTextNodeWithLength(XmlBinaryNodeType nodeType, int length) - { - DiagnosticUtility.DebugAssert(nodeType == XmlBinaryNodeType.Chars8Text || nodeType == XmlBinaryNodeType.Bytes8Text || nodeType == XmlBinaryNodeType.UnicodeChars8Text, ""); - int offset; - byte[] buffer = GetTextNodeBuffer(5, out offset); - if (length < 256) - { - buffer[offset + 0] = (byte)nodeType; - buffer[offset + 1] = (byte)length; - Advance(2); - } - else if (length < 65536) - { - buffer[offset + 0] = (byte)(nodeType + 1 * 2); // WithEndElements interleave - buffer[offset + 1] = (byte)length; - length >>= 8; - buffer[offset + 2] = (byte)length; - Advance(3); - } - else - { - buffer[offset + 0] = (byte)(nodeType + 2 * 2); // WithEndElements interleave - buffer[offset + 1] = (byte)length; - length >>= 8; - buffer[offset + 2] = (byte)length; - length >>= 8; - buffer[offset + 3] = (byte)length; - length >>= 8; - buffer[offset + 4] = (byte)length; - Advance(5); - } - } - - private void WriteTextNodeWithInt64(XmlBinaryNodeType nodeType, Int64 value) - { - int offset; - byte[] buffer = GetTextNodeBuffer(9, out offset); - buffer[offset + 0] = (byte)nodeType; - buffer[offset + 1] = (byte)value; - value >>= 8; - buffer[offset + 2] = (byte)value; - value >>= 8; - buffer[offset + 3] = (byte)value; - value >>= 8; - buffer[offset + 4] = (byte)value; - value >>= 8; - buffer[offset + 5] = (byte)value; - value >>= 8; - buffer[offset + 6] = (byte)value; - value >>= 8; - buffer[offset + 7] = (byte)value; - value >>= 8; - buffer[offset + 8] = (byte)value; - Advance(9); - } - - public override void WriteDeclaration() - { - } - - public override void WriteStartElement(string prefix, string localName) - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortElement); - WriteName(localName); - } - else - { - char ch = prefix[0]; - - if (prefix.Length == 1 && ch >= 'a' && ch <= 'z') - { - WritePrefixNode(XmlBinaryNodeType.PrefixElementA, ch - 'a'); - WriteName(localName); - } - else - { - WriteNode(XmlBinaryNodeType.Element); - WriteName(prefix); - WriteName(localName); - } - } - } - - private void WritePrefixNode(XmlBinaryNodeType nodeType, int ch) - { - WriteNode((XmlBinaryNodeType)((int)nodeType + ch)); - } - - public override void WriteStartElement(string prefix, XmlDictionaryString localName) - { - int key; - if (!TryGetKey(localName, out key)) - { - WriteStartElement(prefix, localName.Value); - } - else - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortDictionaryElement); - WriteDictionaryString(localName, key); - } - else - { - char ch = prefix[0]; - - if (prefix.Length == 1 && ch >= 'a' && ch <= 'z') - { - WritePrefixNode(XmlBinaryNodeType.PrefixDictionaryElementA, ch - 'a'); - WriteDictionaryString(localName, key); - } - else - { - WriteNode(XmlBinaryNodeType.DictionaryElement); - WriteName(prefix); - WriteDictionaryString(localName, key); - } - } - } - } - - public override void WriteEndStartElement(bool isEmpty) - { - if (isEmpty) - { - WriteEndElement(); - } - } - - public override void WriteEndElement(string prefix, string localName) - { - WriteEndElement(); - } - - private void WriteEndElement() - { - if (_textNodeOffset != -1) - { - byte[] buffer = this.StreamBuffer; - XmlBinaryNodeType nodeType = (XmlBinaryNodeType)buffer[_textNodeOffset]; - DiagnosticUtility.DebugAssert(nodeType >= XmlBinaryNodeType.MinText && nodeType <= XmlBinaryNodeType.MaxText && ((byte)nodeType & 1) == 0, ""); - buffer[_textNodeOffset] = (byte)(nodeType + 1); - _textNodeOffset = -1; - } - else - { - WriteNode(XmlBinaryNodeType.EndElement); - } - } - - public override void WriteStartAttribute(string prefix, string localName) - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortAttribute); - WriteName(localName); - } - else - { - char ch = prefix[0]; - if (prefix.Length == 1 && ch >= 'a' && ch <= 'z') - { - WritePrefixNode(XmlBinaryNodeType.PrefixAttributeA, ch - 'a'); - WriteName(localName); - } - else - { - WriteNode(XmlBinaryNodeType.Attribute); - WriteName(prefix); - WriteName(localName); - } - } - _inAttribute = true; - _wroteAttributeValue = false; - } - - public override void WriteStartAttribute(string prefix, XmlDictionaryString localName) - { - int key; - if (!TryGetKey(localName, out key)) - { - WriteStartAttribute(prefix, localName.Value); - } - else - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortDictionaryAttribute); - WriteDictionaryString(localName, key); - } - else - { - char ch = prefix[0]; - if (prefix.Length == 1 && ch >= 'a' && ch <= 'z') - { - WritePrefixNode(XmlBinaryNodeType.PrefixDictionaryAttributeA, ch - 'a'); - WriteDictionaryString(localName, key); - } - else - { - WriteNode(XmlBinaryNodeType.DictionaryAttribute); - WriteName(prefix); - WriteDictionaryString(localName, key); - } - } - _inAttribute = true; - _wroteAttributeValue = false; - } - } - - public override void WriteEndAttribute() - { - _inAttribute = false; - if (!_wroteAttributeValue) - { - _attributeValue.WriteTo(this); - } - _textNodeOffset = -1; - } - - public override void WriteXmlnsAttribute(string prefix, string ns) - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortXmlnsAttribute); - WriteName(ns); - } - else - { - WriteNode(XmlBinaryNodeType.XmlnsAttribute); - WriteName(prefix); - WriteName(ns); - } - } - - public override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns) - { - int key; - if (!TryGetKey(ns, out key)) - { - WriteXmlnsAttribute(prefix, ns.Value); - } - else - { - if (prefix.Length == 0) - { - WriteNode(XmlBinaryNodeType.ShortDictionaryXmlnsAttribute); - WriteDictionaryString(ns, key); - } - else - { - WriteNode(XmlBinaryNodeType.DictionaryXmlnsAttribute); - WriteName(prefix); - WriteDictionaryString(ns, key); - } - } - } - - private bool TryGetKey(XmlDictionaryString s, out int key) - { - key = -1; - if (s.Dictionary == _dictionary) - { - key = s.Key * 2; - return true; - } - XmlDictionaryString t; - if (_dictionary != null && _dictionary.TryLookup(s, out t)) - { - DiagnosticUtility.DebugAssert(t.Dictionary == _dictionary, ""); - key = t.Key * 2; - return true; - } - - if (_session == null) - return false; - int sessionKey; - if (!_session.TryLookup(s, out sessionKey)) - { - if (!_session.TryAdd(s, out sessionKey)) - return false; - } - key = sessionKey * 2 + 1; - return true; - } - - private void WriteDictionaryString(XmlDictionaryString s, int key) - { - WriteMultiByteInt32(key); - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - private unsafe void WriteName(string s) - { - int length = s.Length; - if (length == 0) - { - WriteByte(0); - } - else - { - fixed (char* pch = s) - { - UnsafeWriteName(pch, length); - } - } - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeWriteName(char* chars, int charCount) - { - if (charCount < 128 / maxBytesPerChar) - { - // Optimize if we know we can fit the converted string in the buffer - // so we don't have to make a pass to count the bytes - - // 1 byte for the length - int offset; - byte[] buffer = GetBuffer(1 + charCount * maxBytesPerChar, out offset); - int length = UnsafeGetUTF8Chars(chars, charCount, buffer, offset + 1); - DiagnosticUtility.DebugAssert(length < 128, ""); - buffer[offset] = (byte)length; - Advance(1 + length); - } - else - { - int byteCount = UnsafeGetUTF8Length(chars, charCount); - WriteMultiByteInt32(byteCount); - UnsafeWriteUTF8Chars(chars, charCount); - } - } - - private void WriteMultiByteInt32(int i) - { - int offset; - byte[] buffer = GetBuffer(5, out offset); - - int startOffset = offset; - while ((i & 0xFFFFFF80) != 0) - { - buffer[offset++] = (byte)((i & 0x7F) | 0x80); - i >>= 7; - } - buffer[offset++] = (byte)i; - Advance(offset - startOffset); - } - - public override void WriteComment(string value) - { - WriteNode(XmlBinaryNodeType.Comment); - WriteName(value); - } - - public override void WriteCData(string value) - { - WriteText(value); - } - - private void WriteEmptyText() - { - WriteTextNode(XmlBinaryNodeType.EmptyText); - } - - public override void WriteBoolText(bool value) - { - if (value) - { - WriteTextNode(XmlBinaryNodeType.TrueText); - } - else - { - WriteTextNode(XmlBinaryNodeType.FalseText); - } - } - - public override void WriteInt32Text(int value) - { - if (value >= -128 && value < 128) - { - if (value == 0) - { - WriteTextNode(XmlBinaryNodeType.ZeroText); - } - else if (value == 1) - { - WriteTextNode(XmlBinaryNodeType.OneText); - } - else - { - int offset; - byte[] buffer = GetTextNodeBuffer(2, out offset); - buffer[offset + 0] = (byte)XmlBinaryNodeType.Int8Text; - buffer[offset + 1] = (byte)value; - Advance(2); - } - } - else if (value >= -32768 && value < 32768) - { - int offset; - byte[] buffer = GetTextNodeBuffer(3, out offset); - buffer[offset + 0] = (byte)XmlBinaryNodeType.Int16Text; - buffer[offset + 1] = (byte)value; - value >>= 8; - buffer[offset + 2] = (byte)value; - Advance(3); - } - else - { - int offset; - byte[] buffer = GetTextNodeBuffer(5, out offset); - buffer[offset + 0] = (byte)XmlBinaryNodeType.Int32Text; - buffer[offset + 1] = (byte)value; - value >>= 8; - buffer[offset + 2] = (byte)value; - value >>= 8; - buffer[offset + 3] = (byte)value; - value >>= 8; - buffer[offset + 4] = (byte)value; - Advance(5); - } - } - - public override void WriteInt64Text(Int64 value) - { - if (value >= int.MinValue && value <= int.MaxValue) - { - WriteInt32Text((int)value); - } - else - { - WriteTextNodeWithInt64(XmlBinaryNodeType.Int64Text, value); - } - } - - public override void WriteUInt64Text(UInt64 value) - { - if (value <= Int64.MaxValue) - { - WriteInt64Text((Int64)value); - } - else - { - WriteTextNodeWithInt64(XmlBinaryNodeType.UInt64Text, (Int64)value); - } - } - - private void WriteInt64(Int64 value) - { - int offset; - byte[] buffer = GetBuffer(8, out offset); - buffer[offset + 0] = (byte)value; - value >>= 8; - buffer[offset + 1] = (byte)value; - value >>= 8; - buffer[offset + 2] = (byte)value; - value >>= 8; - buffer[offset + 3] = (byte)value; - value >>= 8; - buffer[offset + 4] = (byte)value; - value >>= 8; - buffer[offset + 5] = (byte)value; - value >>= 8; - buffer[offset + 6] = (byte)value; - value >>= 8; - buffer[offset + 7] = (byte)value; - Advance(8); - } - - public override void WriteBase64Text(byte[] trailBytes, int trailByteCount, byte[] base64Buffer, int base64Offset, int base64Count) - { - if (_inAttribute) - { - _attributeValue.WriteBase64Text(trailBytes, trailByteCount, base64Buffer, base64Offset, base64Count); - } - else - { - int length = trailByteCount + base64Count; - if (length > 0) - { - WriteTextNodeWithLength(XmlBinaryNodeType.Bytes8Text, length); - if (trailByteCount > 0) - { - int offset; - byte[] buffer = GetBuffer(trailByteCount, out offset); - for (int i = 0; i < trailByteCount; i++) - buffer[offset + i] = trailBytes[i]; - Advance(trailByteCount); - } - if (base64Count > 0) - { - WriteBytes(base64Buffer, base64Offset, base64Count); - } - } - else - { - WriteEmptyText(); - } - } - } - - public override void WriteText(XmlDictionaryString value) - { - if (_inAttribute) - { - _attributeValue.WriteText(value); - } - else - { - int key; - if (!TryGetKey(value, out key)) - { - WriteText(value.Value); - } - else - { - WriteTextNode(XmlBinaryNodeType.DictionaryText); - WriteDictionaryString(value, key); - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteText(string value) - { - if (_inAttribute) - { - _attributeValue.WriteText(value); - } - else - { - if (value.Length > 0) - { - fixed (char* pch = value) - { - UnsafeWriteText(pch, value.Length); - } - } - else - { - WriteEmptyText(); - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteText(char[] chars, int offset, int count) - { - if (_inAttribute) - { - _attributeValue.WriteText(new string(chars, offset, count)); - } - else - { - if (count > 0) - { - fixed (char* pch = &chars[offset]) - { - UnsafeWriteText(pch, count); - } - } - else - { - WriteEmptyText(); - } - } - } - - public override void WriteText(byte[] chars, int charOffset, int charCount) - { - WriteTextNodeWithLength(XmlBinaryNodeType.Chars8Text, charCount); - WriteBytes(chars, charOffset, charCount); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeWriteText(char* chars, int charCount) - { - // Callers should handle zero - DiagnosticUtility.DebugAssert(charCount > 0, ""); - - if (charCount == 1) - { - char ch = chars[0]; - if (ch == '0') - { - WriteTextNode(XmlBinaryNodeType.ZeroText); - return; - } - if (ch == '1') - { - WriteTextNode(XmlBinaryNodeType.OneText); - return; - } - } - - if (charCount <= byte.MaxValue / maxBytesPerChar) - { - // Optimize if we know we can fit the converted string in the buffer - // so we don't have to make a pass to count the bytes - - int offset; - byte[] buffer = GetBuffer(1 + 1 + charCount * maxBytesPerChar, out offset); - int length = UnsafeGetUTF8Chars(chars, charCount, buffer, offset + 2); - - if (length / 2 <= charCount) - { - buffer[offset] = (byte)XmlBinaryNodeType.Chars8Text; - } - else - { - buffer[offset] = (byte)XmlBinaryNodeType.UnicodeChars8Text; - length = UnsafeGetUnicodeChars(chars, charCount, buffer, offset + 2); - } - _textNodeOffset = offset; - DiagnosticUtility.DebugAssert(length <= byte.MaxValue, ""); - buffer[offset + 1] = (byte)length; - Advance(2 + length); - } - else - { - int byteCount = UnsafeGetUTF8Length(chars, charCount); - if (byteCount / 2 > charCount) - { - WriteTextNodeWithLength(XmlBinaryNodeType.UnicodeChars8Text, charCount * 2); - UnsafeWriteUnicodeChars(chars, charCount); - } - else - { - WriteTextNodeWithLength(XmlBinaryNodeType.Chars8Text, byteCount); - UnsafeWriteUTF8Chars(chars, charCount); - } - } - } - - public override void WriteEscapedText(string value) - { - WriteText(value); - } - - public override void WriteEscapedText(XmlDictionaryString value) - { - WriteText(value); - } - - public override void WriteEscapedText(char[] chars, int offset, int count) - { - WriteText(chars, offset, count); - } - - public override void WriteEscapedText(byte[] chars, int offset, int count) - { - WriteText(chars, offset, count); - } - - public override void WriteCharEntity(int ch) - { - if (ch > char.MaxValue) - { - SurrogateChar sch = new SurrogateChar(ch); - char[] chars = new char[2] { sch.HighChar, sch.LowChar, }; - WriteText(chars, 0, 2); - } - else - { - char[] chars = new char[1] { (char)ch }; - WriteText(chars, 0, 1); - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteFloatText(float f) - { - long l; - if (f >= long.MinValue && f <= long.MaxValue && (l = (long)f) == f) - { - WriteInt64Text(l); - } - else - { - int offset; - byte[] buffer = GetTextNodeBuffer(1 + sizeof(float), out offset); - byte* bytes = (byte*)&f; - buffer[offset + 0] = (byte)XmlBinaryNodeType.FloatText; - buffer[offset + 1] = bytes[0]; - buffer[offset + 2] = bytes[1]; - buffer[offset + 3] = bytes[2]; - buffer[offset + 4] = bytes[3]; - Advance(1 + sizeof(float)); - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteDoubleText(double d) - { - float f; - if (d >= float.MinValue && d <= float.MaxValue && (f = (float)d) == d) - { - WriteFloatText(f); - } - else - { - int offset; - byte[] buffer = GetTextNodeBuffer(1 + sizeof(double), out offset); - byte* bytes = (byte*)&d; - buffer[offset + 0] = (byte)XmlBinaryNodeType.DoubleText; - buffer[offset + 1] = bytes[0]; - buffer[offset + 2] = bytes[1]; - buffer[offset + 3] = bytes[2]; - buffer[offset + 4] = bytes[3]; - buffer[offset + 5] = bytes[4]; - buffer[offset + 6] = bytes[5]; - buffer[offset + 7] = bytes[6]; - buffer[offset + 8] = bytes[7]; - Advance(1 + sizeof(double)); - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteDecimalText(decimal d) - { - int offset; - byte[] buffer = GetTextNodeBuffer(1 + sizeof(decimal), out offset); - byte* bytes = (byte*)&d; - buffer[offset++] = (byte)XmlBinaryNodeType.DecimalText; - for (int i = 0; i < sizeof(decimal); i++) - { - buffer[offset++] = bytes[i]; - } - Advance(1 + sizeof(decimal)); - } - - public override void WriteDateTimeText(DateTime dt) - { - WriteTextNodeWithInt64(XmlBinaryNodeType.DateTimeText, ToBinary(dt)); - } - private static long ToBinary(DateTime dt) - { - long temp = 0; - switch (dt.Kind) - { - case DateTimeKind.Local: - temp = temp | -9223372036854775808L; // 0x8000000000000000 - temp = temp | dt.ToUniversalTime().Ticks; - break; - case DateTimeKind.Utc: - temp = temp | 0x4000000000000000L; - temp = temp | dt.Ticks; - break; - case DateTimeKind.Unspecified: - temp = dt.Ticks; - break; - } - return temp; - } - - - public override void WriteUniqueIdText(UniqueId value) - { - if (value.IsGuid) - { - int offset; - byte[] buffer = GetTextNodeBuffer(17, out offset); - buffer[offset] = (byte)XmlBinaryNodeType.UniqueIdText; - value.TryGetGuid(buffer, offset + 1); - Advance(17); - } - else - { - WriteText(value.ToString()); - } - } - - public override void WriteGuidText(Guid guid) - { - int offset; - byte[] buffer = GetTextNodeBuffer(17, out offset); - buffer[offset] = (byte)XmlBinaryNodeType.GuidText; - Buffer.BlockCopy(guid.ToByteArray(), 0, buffer, offset + 1, 16); - Advance(17); - } - - public override void WriteTimeSpanText(TimeSpan value) - { - WriteTextNodeWithInt64(XmlBinaryNodeType.TimeSpanText, value.Ticks); - } - - public override void WriteStartListText() - { - DiagnosticUtility.DebugAssert(!_inList, ""); - _inList = true; - WriteNode(XmlBinaryNodeType.StartListText); - } - - public override void WriteListSeparator() - { - } - - public override void WriteEndListText() - { - DiagnosticUtility.DebugAssert(_inList, ""); - _inList = false; - _wroteAttributeValue = true; - WriteNode(XmlBinaryNodeType.EndListText); - } - - public void WriteArrayNode() - { - WriteNode(XmlBinaryNodeType.Array); - } - - private void WriteArrayInfo(XmlBinaryNodeType nodeType, int count) - { - WriteNode(nodeType); - WriteMultiByteInt32(count); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - unsafe public void UnsafeWriteArray(XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) - { - WriteArrayInfo(nodeType, count); - UnsafeWriteArray(array, (int)(arrayMax - array)); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeWriteArray(byte* array, int byteCount) - { - base.UnsafeWriteBytes(array, byteCount); - } - - public void WriteDateTimeArray(DateTime[] array, int offset, int count) - { - WriteArrayInfo(XmlBinaryNodeType.DateTimeTextWithEndElement, count); - for (int i = 0; i < count; i++) - { - WriteInt64(ToBinary(array[offset + i])); - } - } - - public void WriteGuidArray(Guid[] array, int offset, int count) - { - WriteArrayInfo(XmlBinaryNodeType.GuidTextWithEndElement, count); - for (int i = 0; i < count; i++) - { - byte[] buffer = array[offset + i].ToByteArray(); - WriteBytes(buffer, 0, 16); - } - } - - public void WriteTimeSpanArray(TimeSpan[] array, int offset, int count) - { - WriteArrayInfo(XmlBinaryNodeType.TimeSpanTextWithEndElement, count); - for (int i = 0; i < count; i++) - { - WriteInt64(array[offset + i].Ticks); - } - } - - public override void WriteQualifiedName(string prefix, XmlDictionaryString localName) - { - if (prefix.Length == 0) - { - WriteText(localName); - } - else - { - char ch = prefix[0]; - int key; - if (prefix.Length == 1 && (ch >= 'a' && ch <= 'z') && TryGetKey(localName, out key)) - { - WriteTextNode(XmlBinaryNodeType.QNameDictionaryText); - WriteByte((byte)(ch - 'a')); - WriteDictionaryString(localName, key); - } - else - { - WriteText(prefix); - WriteText(":"); - WriteText(localName); - } - } - } - - protected override void FlushBuffer() - { - base.FlushBuffer(); - _textNodeOffset = -1; - } - - public override void Close() - { - base.Close(); - _attributeValue.Clear(); - } - - private struct AttributeValue - { - private string _captureText; - private XmlDictionaryString _captureXText; - private MemoryStream _captureStream; - - public void Clear() - { - _captureText = null; - _captureXText = null; - _captureStream = null; - } - - public void WriteText(string s) - { - if (_captureStream != null) - { - ArraySegment arraySegment; - bool result = _captureStream.TryGetBuffer(out arraySegment); - DiagnosticUtility.DebugAssert(result, ""); - _captureText = XmlConverter.Base64Encoding.GetString(arraySegment.Array, arraySegment.Offset, arraySegment.Count); - _captureStream = null; - } - - if (_captureXText != null) - { - _captureText = _captureXText.Value; - _captureXText = null; - } - - if (_captureText == null || _captureText.Length == 0) - { - _captureText = s; - } - else - { - _captureText += s; - } - } - - public void WriteText(XmlDictionaryString s) - { - if (_captureText != null || _captureStream != null) - { - WriteText(s.Value); - } - else - { - _captureXText = s; - } - } - - public void WriteBase64Text(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count) - { - if (_captureText != null || _captureXText != null) - { - if (trailByteCount > 0) - { - WriteText(XmlConverter.Base64Encoding.GetString(trailBytes, 0, trailByteCount)); - } - WriteText(XmlConverter.Base64Encoding.GetString(buffer, offset, count)); - } - else - { - if (_captureStream == null) - _captureStream = new MemoryStream(); - - if (trailByteCount > 0) - _captureStream.Write(trailBytes, 0, trailByteCount); - - _captureStream.Write(buffer, offset, count); - } - } - - public void WriteTo(XmlBinaryNodeWriter writer) - { - if (_captureText != null) - { - writer.WriteText(_captureText); - _captureText = null; - } - else if (_captureXText != null) - { - writer.WriteText(_captureXText); - _captureXText = null; - } - else if (_captureStream != null) - { - ArraySegment arraySegment; - bool result = _captureStream.TryGetBuffer(out arraySegment); - DiagnosticUtility.DebugAssert(result, ""); - writer.WriteBase64Text(null, 0, arraySegment.Array, arraySegment.Offset, arraySegment.Count); - _captureStream = null; - } - else - { - writer.WriteEmptyText(); - } - } - } - } - - internal class XmlBinaryWriter : XmlBaseWriter - { - private XmlBinaryNodeWriter _writer; - private char[] _chars; - private byte[] _bytes; - - - public void SetOutput(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream) - { - if (stream == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("stream")); - if (_writer == null) - _writer = new XmlBinaryNodeWriter(); - _writer.SetOutput(stream, dictionary, session, ownsStream); - SetOutput(_writer); - } - - - protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute) - { - Type type = reader.ValueType; - if (type == typeof(string)) - { - XmlDictionaryString value; - if (reader.TryGetValueAsDictionaryString(out value)) - { - WriteString(value); - } - else - { - if (reader.CanReadValueChunk) - { - if (_chars == null) - { - _chars = new char[256]; - } - int count; - while ((count = reader.ReadValueChunk(_chars, 0, _chars.Length)) > 0) - { - this.WriteChars(_chars, 0, count); - } - } - else - { - WriteString(reader.Value); - } - } - if (!attribute) - { - reader.Read(); - } - } - else if (type == typeof(byte[])) - { - if (reader.CanReadBinaryContent) - { - // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text - if (_bytes == null) - { - _bytes = new byte[384]; - } - int count; - while ((count = reader.ReadValueAsBase64(_bytes, 0, _bytes.Length)) > 0) - { - this.WriteBase64(_bytes, 0, count); - } - } - else - { - WriteString(reader.Value); - } - if (!attribute) - { - reader.Read(); - } - } - else if (type == typeof(int)) - WriteValue(reader.ReadContentAsInt()); - else if (type == typeof(long)) - WriteValue(reader.ReadContentAsLong()); - else if (type == typeof(bool)) - WriteValue(reader.ReadContentAsBoolean()); - else if (type == typeof(double)) - WriteValue(reader.ReadContentAsDouble()); - else if (type == typeof(DateTime)) - WriteValue(reader.ReadContentAsDateTimeOffset().DateTime); - else if (type == typeof(float)) - WriteValue(reader.ReadContentAsFloat()); - else if (type == typeof(decimal)) - WriteValue(reader.ReadContentAsDecimal()); - else if (type == typeof(UniqueId)) - WriteValue(reader.ReadContentAsUniqueId()); - else if (type == typeof(Guid)) - WriteValue(reader.ReadContentAsGuid()); - else if (type == typeof(TimeSpan)) - WriteValue(reader.ReadContentAsTimeSpan()); - else - WriteValue(reader.ReadContentAsObject()); - } - - private void WriteStartArray(string prefix, string localName, string namespaceUri, int count) - { - StartArray(count); - _writer.WriteArrayNode(); - WriteStartElement(prefix, localName, namespaceUri); - WriteEndElement(); - } - - private void WriteStartArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int count) - { - StartArray(count); - _writer.WriteArrayNode(); - WriteStartElement(prefix, localName, namespaceUri); - WriteEndElement(); - } - - private void WriteEndArray() - { - EndArray(); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeWriteArray(string prefix, string localName, string namespaceUri, - XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.UnsafeWriteArray(nodeType, count, array, arrayMax); - WriteEndArray(); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeWriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, - XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.UnsafeWriteArray(nodeType, count, array, arrayMax); - WriteEndArray(); - } - - private void CheckArray(Array array, int offset, int count) - { - if (array == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("array")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > array.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, array.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > array.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, array.Length - offset))); - } - - // bool - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, bool[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (bool* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (bool* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // Int16 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, Int16[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int16* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int16[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int16* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // Int32 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, Int32[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int32* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int32[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int32* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // Int64 - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, Int64[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int64* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int64[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (Int64* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // float - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, float[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (float* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (float* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // double - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, double[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (double* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (double* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // decimal - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, string localName, string namespaceUri, decimal[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (decimal* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - fixed (decimal* items = &array[offset]) - { - UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement, count, (byte*)items, (byte*)&items[count]); - } - } - } - } - - // DateTime - public override void WriteArray(string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteDateTimeArray(array, offset, count); - WriteEndArray(); - } - } - } - - public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteDateTimeArray(array, offset, count); - WriteEndArray(); - } - } - } - - // Guid - public override void WriteArray(string prefix, string localName, string namespaceUri, Guid[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteGuidArray(array, offset, count); - WriteEndArray(); - } - } - } - - public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteGuidArray(array, offset, count); - WriteEndArray(); - } - } - } - - // TimeSpan - public override void WriteArray(string prefix, string localName, string namespaceUri, TimeSpan[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteTimeSpanArray(array, offset, count); - WriteEndArray(); - } - } - } - - public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count) - { - { - CheckArray(array, offset, count); - if (count > 0) - { - WriteStartArray(prefix, localName, namespaceUri, count); - _writer.WriteTimeSpanArray(array, offset, count); - WriteEndArray(); - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriterSession.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriterSession.cs deleted file mode 100644 index d8145a25741..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBinaryWriterSession.cs +++ /dev/null @@ -1,262 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; - - -namespace Microsoft.Xml -{ - public class XmlBinaryWriterSession - { - private PriorityDictionary _strings; - private PriorityDictionary _maps; - private int _nextKey; - - public XmlBinaryWriterSession() - { - _nextKey = 0; - _maps = new PriorityDictionary(); - _strings = new PriorityDictionary(); - } - - public virtual bool TryAdd(XmlDictionaryString value, out int key) - { - IntArray keys; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - - if (_maps.TryGetValue(value.Dictionary, out keys)) - { - key = (keys[value.Key] - 1); - - if (key != -1) - { - // If the key is already set, then something is wrong - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.XmlKeyAlreadyExists))); - } - - key = Add(value.Value); - keys[value.Key] = (key + 1); - return true; - } - - key = Add(value.Value); - keys = AddKeys(value.Dictionary, value.Key + 1); - keys[value.Key] = (key + 1); - return true; - } - - private int Add(string s) - { - int key = _nextKey++; - _strings.Add(s, key); - return key; - } - - private IntArray AddKeys(IXmlDictionary dictionary, int minCount) - { - IntArray keys = new IntArray(Math.Max(minCount, 16)); - _maps.Add(dictionary, keys); - return keys; - } - - public void Reset() - { - _nextKey = 0; - _maps.Clear(); - _strings.Clear(); - } - - internal bool TryLookup(XmlDictionaryString s, out int key) - { - IntArray keys; - if (_maps.TryGetValue(s.Dictionary, out keys)) - { - key = (keys[s.Key] - 1); - - if (key != -1) - { - return true; - } - } - - if (_strings.TryGetValue(s.Value, out key)) - { - if (keys == null) - { - keys = AddKeys(s.Dictionary, s.Key + 1); - } - - keys[s.Key] = (key + 1); - return true; - } - - key = -1; - return false; - } - - private class PriorityDictionary where K : class - { - private Dictionary _dictionary; - private Entry[] _list; - private int _listCount; - private int _now; - - public PriorityDictionary() - { - _list = new Entry[16]; - } - - public void Clear() - { - _now = 0; - _listCount = 0; - Array.Clear(_list, 0, _list.Length); - if (_dictionary != null) - _dictionary.Clear(); - } - - public bool TryGetValue(K key, out V value) - { - for (int i = 0; i < _listCount; i++) - { - if (_list[i].Key == key) - { - value = _list[i].Value; - _list[i].Time = Now; - return true; - } - } - - for (int i = 0; i < _listCount; i++) - { - if (_list[i].Key.Equals(key)) - { - value = _list[i].Value; - _list[i].Time = Now; - return true; - } - } - - if (_dictionary == null) - { - value = default(V); - return false; - } - - if (!_dictionary.TryGetValue(key, out value)) - { - return false; - } - - int minIndex = 0; - int minTime = _list[0].Time; - for (int i = 1; i < _listCount; i++) - { - if (_list[i].Time < minTime) - { - minIndex = i; - minTime = _list[i].Time; - } - } - - _list[minIndex].Key = key; - _list[minIndex].Value = value; - _list[minIndex].Time = Now; - return true; - } - - public void Add(K key, V value) - { - if (_listCount < _list.Length) - { - _list[_listCount].Key = key; - _list[_listCount].Value = value; - _listCount++; - } - else - { - if (_dictionary == null) - { - _dictionary = new Dictionary(); - for (int i = 0; i < _listCount; i++) - { - _dictionary.Add(_list[i].Key, _list[i].Value); - } - } - - _dictionary.Add(key, value); - } - } - - private int Now - { - get - { - if (++_now == int.MaxValue) - { - DecreaseAll(); - } - - return _now; - } - } - - private void DecreaseAll() - { - for (int i = 0; i < _listCount; i++) - { - _list[i].Time /= 2; - } - - _now /= 2; - } - - private struct Entry - { - public K Key; - public V Value; - public int Time; - } - } - - private class IntArray - { - private int[] _array; - - public IntArray(int size) - { - _array = new int[size]; - } - - public int this[int index] - { - get - { - if (index >= _array.Length) - return 0; - - return _array[index]; - } - set - { - if (index >= _array.Length) - { - int[] newArray = new int[Math.Max(index + 1, _array.Length * 2)]; - Array.Copy(_array, 0, newArray, 0, _array.Length); - _array = newArray; - } - - _array[index] = value; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBufferReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBufferReader.cs deleted file mode 100644 index 661ed8bf357..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlBufferReader.cs +++ /dev/null @@ -1,1397 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; -using System.Globalization; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; - - -namespace Microsoft.Xml -{ - internal class XmlBufferReader - { - private XmlDictionaryReader _reader; - private Stream _stream; - private byte[] _streamBuffer; - private byte[] _buffer; - private int _offsetMin; - private int _offsetMax; - private IXmlDictionary _dictionary; - private XmlBinaryReaderSession _session; - private byte[] _guid; - private int _offset; - private const int maxBytesPerChar = 3; - private char[] _chars; - private int _windowOffset; - private int _windowOffsetMax; - private ValueHandle _listValue; - private static XmlBufferReader s_empty = new XmlBufferReader(Array.Empty()); - - public XmlBufferReader(XmlDictionaryReader reader) - { - _reader = reader; - } - - public XmlBufferReader(byte[] buffer) - { - _reader = null; - _buffer = buffer; - } - - static public XmlBufferReader Empty - { - get - { - return s_empty; - } - } - - public byte[] Buffer - { - get - { - return _buffer; - } - } - - public bool IsStreamed - { - get - { - return _stream != null; - } - } - - - public void SetBuffer(Stream stream, IXmlDictionary dictionary, XmlBinaryReaderSession session) - { - if (_streamBuffer == null) - { - _streamBuffer = new byte[128]; - } - SetBuffer(stream, _streamBuffer, 0, 0, dictionary, session); - _windowOffset = 0; - _windowOffsetMax = _streamBuffer.Length; - } - - public void SetBuffer(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlBinaryReaderSession session) - { - SetBuffer(null, buffer, offset, count, dictionary, session); - } - - private void SetBuffer(Stream stream, byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlBinaryReaderSession session) - { - _stream = stream; - _buffer = buffer; - _offsetMin = offset; - _offset = offset; - _offsetMax = offset + count; - _dictionary = dictionary; - _session = session; - } - - public void Close() - { - if (_streamBuffer != null && _streamBuffer.Length > 4096) - { - _streamBuffer = null; - } - if (_stream != null) - { - _stream.Dispose(); - _stream = null; - } - _buffer = Array.Empty(); - _offset = 0; - _offsetMax = 0; - _windowOffset = 0; - _windowOffsetMax = 0; - _dictionary = null; - _session = null; - } - - public bool EndOfFile - { - get - { - return _offset == _offsetMax && !TryEnsureByte(); - } - } - - public byte GetByte() - { - int offset = _offset; - if (offset < _offsetMax) - return _buffer[offset]; - else - return GetByteHard(); - } - - public void SkipByte() - { - Advance(1); - } - - private byte GetByteHard() - { - EnsureByte(); - return _buffer[_offset]; - } - - public byte[] GetBuffer(int count, out int offset) - { - offset = _offset; - if (offset <= _offsetMax - count) - return _buffer; - return GetBufferHard(count, out offset); - } - - public byte[] GetBuffer(int count, out int offset, out int offsetMax) - { - offset = _offset; - if (offset <= _offsetMax - count) - { - offsetMax = _offset + count; - } - else - { - TryEnsureBytes(Math.Min(count, _windowOffsetMax - offset)); - offsetMax = _offsetMax; - } - return _buffer; - } - - public byte[] GetBuffer(out int offset, out int offsetMax) - { - offset = _offset; - offsetMax = _offsetMax; - return _buffer; - } - - private byte[] GetBufferHard(int count, out int offset) - { - offset = _offset; - EnsureBytes(count); - return _buffer; - } - - private void EnsureByte() - { - if (!TryEnsureByte()) - XmlExceptionHelper.ThrowUnexpectedEndOfFile(_reader); - } - - private bool TryEnsureByte() - { - if (_stream == null) - return false; - DiagnosticUtility.DebugAssert(_offsetMax < _windowOffsetMax, ""); - if (_offsetMax >= _buffer.Length) - return TryEnsureBytes(1); - int b = _stream.ReadByte(); - if (b == -1) - return false; - _buffer[_offsetMax++] = (byte)b; - return true; - } - - private void EnsureBytes(int count) - { - if (!TryEnsureBytes(count)) - XmlExceptionHelper.ThrowUnexpectedEndOfFile(_reader); - } - - private bool TryEnsureBytes(int count) - { - if (_stream == null) - return false; - DiagnosticUtility.DebugAssert(_offset <= int.MaxValue - count, ""); - int newOffsetMax = _offset + count; - if (newOffsetMax < _offsetMax) - return true; - DiagnosticUtility.DebugAssert(newOffsetMax <= _windowOffsetMax, ""); - if (newOffsetMax > _buffer.Length) - { - byte[] newBuffer = new byte[Math.Max(newOffsetMax, _buffer.Length * 2)]; - System.Buffer.BlockCopy(_buffer, 0, newBuffer, 0, _offsetMax); - _buffer = newBuffer; - _streamBuffer = newBuffer; - } - int needed = newOffsetMax - _offsetMax; - while (needed > 0) - { - int actual = _stream.Read(_buffer, _offsetMax, needed); - if (actual == 0) - return false; - _offsetMax += actual; - needed -= actual; - } - return true; - } - - public void Advance(int count) - { - DiagnosticUtility.DebugAssert(_offset + count <= _offsetMax, ""); - _offset += count; - } - - public void InsertBytes(byte[] buffer, int offset, int count) - { - DiagnosticUtility.DebugAssert(_stream != null, ""); - if (_offsetMax > buffer.Length - count) - { - byte[] newBuffer = new byte[_offsetMax + count]; - System.Buffer.BlockCopy(_buffer, 0, newBuffer, 0, _offsetMax); - _buffer = newBuffer; - _streamBuffer = newBuffer; - } - System.Buffer.BlockCopy(_buffer, _offset, _buffer, _offset + count, _offsetMax - _offset); - _offsetMax += count; - System.Buffer.BlockCopy(buffer, offset, _buffer, _offset, count); - } - - public void SetWindow(int windowOffset, int windowLength) - { - // [0...elementOffset-1][elementOffset..offset][offset..offsetMax-1][offsetMax..buffer.Length] - // ^--Elements, Attributes in scope - // ^-- The node just consumed - // ^--Data buffered, not consumed - // ^--Unused space - if (windowOffset > int.MaxValue - windowLength) - windowLength = int.MaxValue - windowOffset; - - if (_offset != windowOffset) - { - System.Buffer.BlockCopy(_buffer, _offset, _buffer, windowOffset, _offsetMax - _offset); - _offsetMax = windowOffset + (_offsetMax - _offset); - _offset = windowOffset; - } - _windowOffset = windowOffset; - _windowOffsetMax = Math.Max(windowOffset + windowLength, _offsetMax); - } - - public int Offset - { - get - { - return _offset; - } - set - { - DiagnosticUtility.DebugAssert(value >= _offsetMin && value <= _offsetMax, ""); - _offset = value; - } - } - - public int ReadBytes(int count) - { - DiagnosticUtility.DebugAssert(count >= 0, ""); - int offset = _offset; - if (offset > _offsetMax - count) - EnsureBytes(count); - _offset += count; - return offset; - } - - public int ReadMultiByteUInt31() - { - int i = GetByte(); - Advance(1); - if ((i & 0x80) == 0) - return i; - i &= 0x7F; - - int j = GetByte(); - Advance(1); - i |= ((j & 0x7F) << 7); - if ((j & 0x80) == 0) - return i; - - int k = GetByte(); - Advance(1); - i |= ((k & 0x7F) << 14); - if ((k & 0x80) == 0) - return i; - - int l = GetByte(); - Advance(1); - i |= ((l & 0x7F) << 21); - if ((l & 0x80) == 0) - return i; - - int m = GetByte(); - Advance(1); - i |= (m << 28); - if ((m & 0xF8) != 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - - return i; - } - - public int ReadUInt8() - { - byte b = GetByte(); - Advance(1); - return b; - } - - public int ReadInt8() - { - return (sbyte)ReadUInt8(); - } - - public int ReadUInt16() - { - int offset; - byte[] buffer = GetBuffer(2, out offset); - int i = buffer[offset + 0] + (buffer[offset + 1] << 8); - Advance(2); - return i; - } - - public int ReadInt16() - { - return (Int16)ReadUInt16(); - } - - public int ReadInt32() - { - int offset; - byte[] buffer = GetBuffer(4, out offset); - byte b1 = buffer[offset + 0]; - byte b2 = buffer[offset + 1]; - byte b3 = buffer[offset + 2]; - byte b4 = buffer[offset + 3]; - Advance(4); - return (((((b4 << 8) + b3) << 8) + b2) << 8) + b1; - } - - public int ReadUInt31() - { - int i = ReadInt32(); - if (i < 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - return i; - } - - public long ReadInt64() - { - Int64 lo = (UInt32)ReadInt32(); - Int64 hi = (UInt32)ReadInt32(); - return (hi << 32) + lo; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public float ReadSingle() - { - int offset; - byte[] buffer = GetBuffer(ValueHandleLength.Single, out offset); - float value; - byte* pb = (byte*)&value; - DiagnosticUtility.DebugAssert(sizeof(float) == 4, ""); - pb[0] = buffer[offset + 0]; - pb[1] = buffer[offset + 1]; - pb[2] = buffer[offset + 2]; - pb[3] = buffer[offset + 3]; - Advance(ValueHandleLength.Single); - return value; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public double ReadDouble() - { - int offset; - byte[] buffer = GetBuffer(ValueHandleLength.Double, out offset); - double value; - byte* pb = (byte*)&value; - DiagnosticUtility.DebugAssert(sizeof(double) == 8, ""); - pb[0] = buffer[offset + 0]; - pb[1] = buffer[offset + 1]; - pb[2] = buffer[offset + 2]; - pb[3] = buffer[offset + 3]; - pb[4] = buffer[offset + 4]; - pb[5] = buffer[offset + 5]; - pb[6] = buffer[offset + 6]; - pb[7] = buffer[offset + 7]; - Advance(ValueHandleLength.Double); - return value; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public decimal ReadDecimal() - { - int offset; - byte[] buffer = GetBuffer(ValueHandleLength.Decimal, out offset); - decimal value; - byte* pb = (byte*)&value; - for (int i = 0; i < sizeof(decimal); i++) - pb[i] = buffer[offset + i]; - Advance(ValueHandleLength.Decimal); - return value; - } - - public UniqueId ReadUniqueId() - { - int offset; - byte[] buffer = GetBuffer(ValueHandleLength.UniqueId, out offset); - UniqueId uniqueId = new UniqueId(buffer, offset); - Advance(ValueHandleLength.UniqueId); - return uniqueId; - } - - public DateTime ReadDateTime() - { - long value = 0; - try - { - value = ReadInt64(); - return DateTime.FromBinary(value); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "DateTime", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "DateTime", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "DateTime", exception)); - } - } - - public TimeSpan ReadTimeSpan() - { - long value = 0; - try - { - value = ReadInt64(); - return TimeSpan.FromTicks(value); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "TimeSpan", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "TimeSpan", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value.ToString(CultureInfo.InvariantCulture), "TimeSpan", exception)); - } - } - - public Guid ReadGuid() - { - int offset; - byte[] buffer = GetBuffer(ValueHandleLength.Guid, out offset); - Guid guid = GetGuid(offset); - Advance(ValueHandleLength.Guid); - return guid; - } - - public string ReadUTF8String(int length) - { - int offset; - byte[] buffer = GetBuffer(length, out offset); - char[] chars = GetCharBuffer(length); - int charCount = GetChars(offset, length, chars); - string value = new string(chars, 0, charCount); - Advance(length); - return value; - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - unsafe public void UnsafeReadArray(byte* dst, byte* dstMax) - { - UnsafeReadArray(dst, (int)(dstMax - dst)); - } - - /// - /// Critical - contains unsafe code - /// caller needs to validate arguments - /// - [SecurityCritical] - private unsafe void UnsafeReadArray(byte* dst, int length) - { - if (_stream != null) - { - const int chunk = 256; - while (length >= chunk) - { - byte[] _buffer = GetBuffer(chunk, out _offset); - for (int i = 0; i < chunk; i++) - { - *dst++ = _buffer[_offset + i]; - } - Advance(chunk); - length -= chunk; - } - } - - if (length > 0) - { - byte[] buffer = GetBuffer(length, out _offset); - fixed (byte* _src = &buffer[_offset]) - { - byte* src = _src; - byte* dstMax = dst + length; - while (dst < dstMax) - { - *dst = *src; - dst++; - src++; - } - } - Advance(length); - } - } - - private char[] GetCharBuffer(int count) - { - if (count > 1024) - return new char[count]; - if (_chars == null || _chars.Length < count) - _chars = new char[count]; - return _chars; - } - - private int GetChars(int offset, int length, char[] chars) - { - byte[] buffer = _buffer; - for (int i = 0; i < length; i++) - { - byte b = buffer[offset + i]; - if (b >= 0x80) - return i + XmlConverter.ToChars(buffer, offset + i, length - i, chars, i); - chars[i] = (char)b; - } - return length; - } - - private int GetChars(int offset, int length, char[] chars, int charOffset) - { - byte[] buffer = _buffer; - for (int i = 0; i < length; i++) - { - byte b = buffer[offset + i]; - if (b >= 0x80) - return i + XmlConverter.ToChars(buffer, offset + i, length - i, chars, charOffset + i); - chars[charOffset + i] = (char)b; - } - return length; - } - - public string GetString(int offset, int length) - { - char[] chars = GetCharBuffer(length); - int charCount = GetChars(offset, length, chars); - return new string(chars, 0, charCount); - } - - public string GetUnicodeString(int offset, int length) - { - return XmlConverter.ToStringUnicode(_buffer, offset, length); - } - - public string GetString(int offset, int length, XmlNameTable nameTable) - { - char[] chars = GetCharBuffer(length); - int charCount = GetChars(offset, length, chars); - return nameTable.Add(chars, 0, charCount); - } - - public int GetEscapedChars(int offset, int length, char[] chars) - { - byte[] buffer = _buffer; - int charCount = 0; - int textOffset = offset; - int offsetMax = offset + length; - while (true) - { - while (offset < offsetMax && IsAttrChar(buffer[offset])) - offset++; - charCount += GetChars(textOffset, offset - textOffset, chars, charCount); - if (offset == offsetMax) - break; - textOffset = offset; - if (buffer[offset] == '&') - { - while (offset < offsetMax && buffer[offset] != ';') - offset++; - offset++; - int ch = GetCharEntity(textOffset, offset - textOffset); - textOffset = offset; - if (ch > char.MaxValue) - { - SurrogateChar surrogate = new SurrogateChar(ch); - chars[charCount++] = surrogate.HighChar; - chars[charCount++] = surrogate.LowChar; - } - else - { - chars[charCount++] = (char)ch; - } - } - else if (buffer[offset] == '\n' || buffer[offset] == '\t') - { - chars[charCount++] = ' '; - offset++; - textOffset = offset; - } - else // '\r' - { - chars[charCount++] = ' '; - offset++; - - if (offset < offsetMax && buffer[offset] == '\n') - offset++; - - textOffset = offset; - } - } - return charCount; - } - - private bool IsAttrChar(int ch) - { - switch (ch) - { - case '&': - case '\r': - case '\t': - case '\n': - return false; - - default: - return true; - } - } - - public string GetEscapedString(int offset, int length) - { - char[] chars = GetCharBuffer(length); - int charCount = GetEscapedChars(offset, length, chars); - return new string(chars, 0, charCount); - } - - public string GetEscapedString(int offset, int length, XmlNameTable nameTable) - { - char[] chars = GetCharBuffer(length); - int charCount = GetEscapedChars(offset, length, chars); - return nameTable.Add(chars, 0, charCount); - } - - private int GetLessThanCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - if (length != 4 || - buffer[offset + 1] != (byte)'l' || - buffer[offset + 2] != (byte)'t') - { - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return (int)'<'; - } - - private int GetGreaterThanCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - if (length != 4 || - buffer[offset + 1] != (byte)'g' || - buffer[offset + 2] != (byte)'t') - { - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return (int)'>'; - } - - private int GetQuoteCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - if (length != 6 || - buffer[offset + 1] != (byte)'q' || - buffer[offset + 2] != (byte)'u' || - buffer[offset + 3] != (byte)'o' || - buffer[offset + 4] != (byte)'t') - { - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return (int)'"'; - } - - private int GetAmpersandCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - if (length != 5 || - buffer[offset + 1] != (byte)'a' || - buffer[offset + 2] != (byte)'m' || - buffer[offset + 3] != (byte)'p') - { - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return (int)'&'; - } - - private int GetApostropheCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - if (length != 6 || - buffer[offset + 1] != (byte)'a' || - buffer[offset + 2] != (byte)'p' || - buffer[offset + 3] != (byte)'o' || - buffer[offset + 4] != (byte)'s') - { - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return (int)'\''; - } - - private int GetDecimalCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - DiagnosticUtility.DebugAssert(buffer[offset + 0] == '&', ""); - DiagnosticUtility.DebugAssert(buffer[offset + 1] == '#', ""); - DiagnosticUtility.DebugAssert(buffer[offset + length - 1] == ';', ""); - int value = 0; - for (int i = 2; i < length - 1; i++) - { - byte ch = buffer[offset + i]; - if (ch < (byte)'0' || ch > (byte)'9') - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - value = value * 10 + (ch - '0'); - if (value > SurrogateChar.MaxValue) - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return value; - } - - private int GetHexCharEntity(int offset, int length) - { - byte[] buffer = _buffer; - DiagnosticUtility.DebugAssert(buffer[offset + 0] == '&', ""); - DiagnosticUtility.DebugAssert(buffer[offset + 1] == '#', ""); - DiagnosticUtility.DebugAssert(buffer[offset + 2] == 'x', ""); - DiagnosticUtility.DebugAssert(buffer[offset + length - 1] == ';', ""); - int value = 0; - for (int i = 3; i < length - 1; i++) - { - byte ch = buffer[offset + i]; - int digit = 0; - if (ch >= '0' && ch <= '9') - digit = (ch - '0'); - else if (ch >= 'a' && ch <= 'f') - digit = 10 + (ch - 'a'); - else if (ch >= 'A' && ch <= 'F') - digit = 10 + (ch - 'A'); - else - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - DiagnosticUtility.DebugAssert(digit >= 0 && digit < 16, ""); - value = value * 16 + digit; - if (value > SurrogateChar.MaxValue) - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - } - return value; - } - - public int GetCharEntity(int offset, int length) - { - if (length < 3) - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - byte[] buffer = _buffer; - DiagnosticUtility.DebugAssert(buffer[offset] == '&', ""); - DiagnosticUtility.DebugAssert(buffer[offset + length - 1] == ';', ""); - switch (buffer[offset + 1]) - { - case (byte)'l': - return GetLessThanCharEntity(offset, length); - case (byte)'g': - return GetGreaterThanCharEntity(offset, length); - case (byte)'a': - if (buffer[offset + 2] == (byte)'m') - return GetAmpersandCharEntity(offset, length); - else - return GetApostropheCharEntity(offset, length); - case (byte)'q': - return GetQuoteCharEntity(offset, length); - case (byte)'#': - if (buffer[offset + 2] == (byte)'x') - return GetHexCharEntity(offset, length); - else - return GetDecimalCharEntity(offset, length); - default: - XmlExceptionHelper.ThrowInvalidCharRef(_reader); - return 0; - } - } - - - public bool IsWhitespaceKey(int key) - { - string s = GetDictionaryString(key).Value; - for (int i = 0; i < s.Length; i++) - { - if (!XmlConverter.IsWhitespace(s[i])) - return false; - } - return true; - } - - public bool IsWhitespaceUTF8(int offset, int length) - { - byte[] buffer = _buffer; - for (int i = 0; i < length; i++) - { - if (!XmlConverter.IsWhitespace((char)buffer[offset + i])) - return false; - } - return true; - } - - public bool IsWhitespaceUnicode(int offset, int length) - { - byte[] buffer = _buffer; - for (int i = 0; i < length; i += sizeof(char)) - { - char ch = (char)GetInt16(offset + i); - if (!XmlConverter.IsWhitespace(ch)) - return false; - } - return true; - } - - public bool Equals2(int key1, int key2, XmlBufferReader bufferReader2) - { - // If the keys aren't from the same dictionary, they still might be the same - if (key1 == key2) - return true; - else - return GetDictionaryString(key1).Value == bufferReader2.GetDictionaryString(key2).Value; - } - - public bool Equals2(int key1, XmlDictionaryString xmlString2) - { - if ((key1 & 1) == 0 && xmlString2.Dictionary == _dictionary) - return xmlString2.Key == (key1 >> 1); - else - return GetDictionaryString(key1).Value == xmlString2.Value; - } - - public bool Equals2(int offset1, int length1, byte[] buffer2) - { - int length2 = buffer2.Length; - if (length1 != length2) - return false; - byte[] buffer1 = _buffer; - for (int i = 0; i < length1; i++) - { - if (buffer1[offset1 + i] != buffer2[i]) - return false; - } - return true; - } - - public bool Equals2(int offset1, int length1, XmlBufferReader bufferReader2, int offset2, int length2) - { - if (length1 != length2) - return false; - byte[] buffer1 = _buffer; - byte[] buffer2 = bufferReader2._buffer; - for (int i = 0; i < length1; i++) - { - if (buffer1[offset1 + i] != buffer2[offset2 + i]) - return false; - } - return true; - } - - public bool Equals2(int offset1, int length1, int offset2, int length2) - { - if (length1 != length2) - return false; - if (offset1 == offset2) - return true; - byte[] buffer = _buffer; - for (int i = 0; i < length1; i++) - { - if (buffer[offset1 + i] != buffer[offset2 + i]) - return false; - } - return true; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public bool Equals2(int offset1, int length1, string s2) - { - int byteLength = length1; - int charLength = s2.Length; - - // N unicode chars will be represented in at least N bytes, but - // no more than N * 3 bytes. If the byte count falls outside of this - // range, then the strings cannot be equal. - if (byteLength < charLength || byteLength > charLength * maxBytesPerChar) - return false; - - byte[] buffer = _buffer; - if (length1 < 8) - { - int length = Math.Min(byteLength, charLength); - int offset = offset1; - for (int i = 0; i < length; i++) - { - byte b = buffer[offset + i]; - if (b >= 0x80) - return XmlConverter.ToString(buffer, offset1, length1) == s2; - if (s2[i] != (char)b) - return false; - } - return byteLength == charLength; - } - else - { - int length = Math.Min(byteLength, charLength); - fixed (byte* _pb = &buffer[offset1]) - { - byte* pb = _pb; - byte* pbMax = pb + length; - fixed (char* _pch = s2) - { - char* pch = _pch; - // Try to do the fast comparison in ascii space - int t = 0; - while (pb < pbMax && *pb < 0x80) - { - t = *pb - (byte)*pch; - // The code generated is better if we break out then return - if (t != 0) - break; - pb++; - pch++; - } - if (t != 0) - return false; - if (pb == pbMax) - return (byteLength == charLength); - } - } - return XmlConverter.ToString(buffer, offset1, length1) == s2; - } - } - - public int Compare(int offset1, int length1, int offset2, int length2) - { - byte[] buffer = _buffer; - int length = Math.Min(length1, length2); - for (int i = 0; i < length; i++) - { - int s = buffer[offset1 + i] - buffer[offset2 + i]; - if (s != 0) - return s; - } - return length1 - length2; - } - - public byte GetByte(int offset) - { - return _buffer[offset]; - } - - public int GetInt8(int offset) - { - return (sbyte)GetByte(offset); - } - - public int GetInt16(int offset) - { - byte[] buffer = _buffer; - return (Int16)(buffer[offset] + (buffer[offset + 1] << 8)); - } - - public int GetInt32(int offset) - { - byte[] buffer = _buffer; - byte b1 = buffer[offset + 0]; - byte b2 = buffer[offset + 1]; - byte b3 = buffer[offset + 2]; - byte b4 = buffer[offset + 3]; - return (((((b4 << 8) + b3) << 8) + b2) << 8) + b1; - } - - public long GetInt64(int offset) - { - byte[] buffer = _buffer; - byte b1, b2, b3, b4; - b1 = buffer[offset + 0]; - b2 = buffer[offset + 1]; - b3 = buffer[offset + 2]; - b4 = buffer[offset + 3]; - Int64 lo = (UInt32)(((((b4 << 8) + b3) << 8) + b2) << 8) + b1; - b1 = buffer[offset + 4]; - b2 = buffer[offset + 5]; - b3 = buffer[offset + 6]; - b4 = buffer[offset + 7]; - Int64 hi = (UInt32)(((((b4 << 8) + b3) << 8) + b2) << 8) + b1; - return (hi << 32) + lo; - } - - public ulong GetUInt64(int offset) - { - return (ulong)GetInt64(offset); - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public float GetSingle(int offset) - { - byte[] buffer = _buffer; - float value; - byte* pb = (byte*)&value; - DiagnosticUtility.DebugAssert(sizeof(float) == 4, ""); - pb[0] = buffer[offset + 0]; - pb[1] = buffer[offset + 1]; - pb[2] = buffer[offset + 2]; - pb[3] = buffer[offset + 3]; - return value; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - unsafe public double GetDouble(int offset) - { - byte[] buffer = _buffer; - double value; - byte* pb = (byte*)&value; - DiagnosticUtility.DebugAssert(sizeof(double) == 8, ""); - pb[0] = buffer[offset + 0]; - pb[1] = buffer[offset + 1]; - pb[2] = buffer[offset + 2]; - pb[3] = buffer[offset + 3]; - pb[4] = buffer[offset + 4]; - pb[5] = buffer[offset + 5]; - pb[6] = buffer[offset + 6]; - pb[7] = buffer[offset + 7]; - return value; - } - - /// - /// Critical - contains unsafe code - /// Safe - unsafe code is effectively encapsulated, all inputs are validated - /// - [SecuritySafeCritical] - public unsafe decimal GetDecimal(int offset) - { - byte[] buffer = _buffer; - decimal value; - byte* pb = (byte*)&value; - for (int i = 0; i < sizeof(decimal); i++) - pb[i] = buffer[offset + i]; - return value; - } - - public UniqueId GetUniqueId(int offset) - { - return new UniqueId(_buffer, offset); - } - - public Guid GetGuid(int offset) - { - if (_guid == null) - _guid = new byte[16]; - System.Buffer.BlockCopy(_buffer, offset, _guid, 0, _guid.Length); - return new Guid(_guid); - } - - public void GetBase64(int srcOffset, byte[] buffer, int dstOffset, int count) - { - System.Buffer.BlockCopy(_buffer, srcOffset, buffer, dstOffset, count); - } - - - public XmlBinaryNodeType GetNodeType() - { - return (XmlBinaryNodeType)GetByte(); - } - - public void SkipNodeType() - { - SkipByte(); - } - - public object[] GetList(int offset, int count) - { - int bufferOffset = this.Offset; - this.Offset = offset; - try - { - object[] objects = new object[count]; - for (int i = 0; i < count; i++) - { - XmlBinaryNodeType nodeType = GetNodeType(); - SkipNodeType(); - DiagnosticUtility.DebugAssert(nodeType != XmlBinaryNodeType.StartListText, ""); - ReadValue(nodeType, _listValue); - objects[i] = _listValue.ToObject(); - } - return objects; - } - finally - { - this.Offset = bufferOffset; - } - } - - - public XmlDictionaryString GetDictionaryString(int key) - { - IXmlDictionary keyDictionary; - if ((key & 1) != 0) - { - keyDictionary = _session; - } - else - { - keyDictionary = _dictionary; - } - XmlDictionaryString s; - if (!keyDictionary.TryLookup(key >> 1, out s)) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - return s; - } - - public int ReadDictionaryKey() - { - int key = ReadMultiByteUInt31(); - if ((key & 1) != 0) - { - if (_session == null) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - int sessionKey = (key >> 1); - XmlDictionaryString xmlString; - if (!_session.TryLookup(sessionKey, out xmlString)) - { - if (sessionKey < XmlDictionaryString.MinKey || sessionKey > XmlDictionaryString.MaxKey) - XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(_reader); - XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedSession(_reader, sessionKey); - } - } - else - { - if (_dictionary == null) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - int staticKey = (key >> 1); - XmlDictionaryString xmlString; - if (!_dictionary.TryLookup(staticKey, out xmlString)) - { - if (staticKey < XmlDictionaryString.MinKey || staticKey > XmlDictionaryString.MaxKey) - XmlExceptionHelper.ThrowXmlDictionaryStringIDOutOfRange(_reader); - XmlExceptionHelper.ThrowXmlDictionaryStringIDUndefinedStatic(_reader, staticKey); - } - } - return key; - } - - public void ReadValue(XmlBinaryNodeType nodeType, ValueHandle value) - { - switch (nodeType) - { - case XmlBinaryNodeType.EmptyText: - value.SetValue(ValueHandleType.Empty); - break; - case XmlBinaryNodeType.ZeroText: - value.SetValue(ValueHandleType.Zero); - break; - case XmlBinaryNodeType.OneText: - value.SetValue(ValueHandleType.One); - break; - case XmlBinaryNodeType.TrueText: - value.SetValue(ValueHandleType.True); - break; - case XmlBinaryNodeType.FalseText: - value.SetValue(ValueHandleType.False); - break; - case XmlBinaryNodeType.BoolText: - value.SetValue(ReadUInt8() != 0 ? ValueHandleType.True : ValueHandleType.False); - break; - case XmlBinaryNodeType.Chars8Text: - ReadValue(value, ValueHandleType.UTF8, ReadUInt8()); - break; - case XmlBinaryNodeType.Chars16Text: - ReadValue(value, ValueHandleType.UTF8, ReadUInt16()); - break; - case XmlBinaryNodeType.Chars32Text: - ReadValue(value, ValueHandleType.UTF8, ReadUInt31()); - break; - case XmlBinaryNodeType.UnicodeChars8Text: - ReadUnicodeValue(value, ReadUInt8()); - break; - case XmlBinaryNodeType.UnicodeChars16Text: - ReadUnicodeValue(value, ReadUInt16()); - break; - case XmlBinaryNodeType.UnicodeChars32Text: - ReadUnicodeValue(value, ReadUInt31()); - break; - case XmlBinaryNodeType.Bytes8Text: - ReadValue(value, ValueHandleType.Base64, ReadUInt8()); - break; - case XmlBinaryNodeType.Bytes16Text: - ReadValue(value, ValueHandleType.Base64, ReadUInt16()); - break; - case XmlBinaryNodeType.Bytes32Text: - ReadValue(value, ValueHandleType.Base64, ReadUInt31()); - break; - case XmlBinaryNodeType.DictionaryText: - value.SetDictionaryValue(ReadDictionaryKey()); - break; - case XmlBinaryNodeType.UniqueIdText: - ReadValue(value, ValueHandleType.UniqueId, ValueHandleLength.UniqueId); - break; - case XmlBinaryNodeType.GuidText: - ReadValue(value, ValueHandleType.Guid, ValueHandleLength.Guid); - break; - case XmlBinaryNodeType.DecimalText: - ReadValue(value, ValueHandleType.Decimal, ValueHandleLength.Decimal); - break; - case XmlBinaryNodeType.Int8Text: - ReadValue(value, ValueHandleType.Int8, ValueHandleLength.Int8); - break; - case XmlBinaryNodeType.Int16Text: - ReadValue(value, ValueHandleType.Int16, ValueHandleLength.Int16); - break; - case XmlBinaryNodeType.Int32Text: - ReadValue(value, ValueHandleType.Int32, ValueHandleLength.Int32); - break; - case XmlBinaryNodeType.Int64Text: - ReadValue(value, ValueHandleType.Int64, ValueHandleLength.Int64); - break; - case XmlBinaryNodeType.UInt64Text: - ReadValue(value, ValueHandleType.UInt64, ValueHandleLength.UInt64); - break; - case XmlBinaryNodeType.FloatText: - ReadValue(value, ValueHandleType.Single, ValueHandleLength.Single); - break; - case XmlBinaryNodeType.DoubleText: - ReadValue(value, ValueHandleType.Double, ValueHandleLength.Double); - break; - case XmlBinaryNodeType.TimeSpanText: - ReadValue(value, ValueHandleType.TimeSpan, ValueHandleLength.TimeSpan); - break; - case XmlBinaryNodeType.DateTimeText: - ReadValue(value, ValueHandleType.DateTime, ValueHandleLength.DateTime); - break; - case XmlBinaryNodeType.StartListText: - ReadList(value); - break; - case XmlBinaryNodeType.QNameDictionaryText: - ReadQName(value); - break; - default: - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - break; - } - } - - private void ReadValue(ValueHandle value, ValueHandleType type, int length) - { - int offset = ReadBytes(length); - value.SetValue(type, offset, length); - } - - private void ReadUnicodeValue(ValueHandle value, int length) - { - if ((length & 1) != 0) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - ReadValue(value, ValueHandleType.Unicode, length); - } - - private void ReadList(ValueHandle value) - { - if (_listValue == null) - { - _listValue = new ValueHandle(this); - } - int count = 0; - int offset = this.Offset; - while (true) - { - XmlBinaryNodeType nodeType = GetNodeType(); - SkipNodeType(); - if (nodeType == XmlBinaryNodeType.StartListText) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - if (nodeType == XmlBinaryNodeType.EndListText) - break; - ReadValue(nodeType, _listValue); - count++; - } - value.SetValue(ValueHandleType.List, offset, count); - } - - - public void ReadQName(ValueHandle value) - { - int prefix = ReadUInt8(); - if (prefix >= 26) - XmlExceptionHelper.ThrowInvalidBinaryFormat(_reader); - int key = ReadDictionaryKey(); - value.SetQNameValue(prefix, key); - } - - public int[] GetRows() - { - if (_buffer == null) - { - return new int[1] { 0 }; - } - - List list = new List(); - list.Add(_offsetMin); - for (int i = _offsetMin; i < _offsetMax; i++) - { - if (_buffer[i] == (byte)13 || _buffer[i] == (byte)10) - { - if (i + 1 < _offsetMax && _buffer[i + 1] == (byte)10) - i++; - list.Add(i + 1); - } - } - return list.ToArray(); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlConverter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlConverter.cs index da956edffce..f36c2261da6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlConverter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlConverter.cs @@ -5,8 +5,8 @@ using System; using System.IO; using System.Runtime; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using System.Collections; using System.Diagnostics; using System.Runtime.InteropServices; @@ -18,7 +18,7 @@ using System.Collections.ObjectModel; -namespace Microsoft.Xml +namespace System.Xml { internal static class XmlConverter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionary.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionary.cs deleted file mode 100644 index 45c74e27140..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionary.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using System.Runtime.Serialization; - - -namespace Microsoft.Xml -{ - public class XmlDictionary : IXmlDictionary - { - private static IXmlDictionary s_empty; - private Dictionary _lookup; - private XmlDictionaryString[] _strings; - private int _nextId; - - static public IXmlDictionary Empty - { - get - { - if (s_empty == null) - s_empty = new EmptyDictionary(); - return s_empty; - } - } - - public XmlDictionary() - { - _lookup = new Dictionary(); - _strings = null; - _nextId = 0; - } - - public XmlDictionary(int capacity) - { - _lookup = new Dictionary(capacity); - _strings = new XmlDictionaryString[capacity]; - _nextId = 0; - } - - public virtual XmlDictionaryString Add(string value) - { - XmlDictionaryString str; - if (!_lookup.TryGetValue(value, out str)) - { - if (_strings == null) - { - _strings = new XmlDictionaryString[4]; - } - else if (_nextId == _strings.Length) - { - int newSize = _nextId * 2; - if (newSize == 0) - newSize = 4; - Array.Resize(ref _strings, newSize); - } - str = new XmlDictionaryString(this, value, _nextId); - _strings[_nextId] = str; - _lookup.Add(value, str); - _nextId++; - } - return str; - } - - public virtual bool TryLookup(string value, out XmlDictionaryString result) - { - return _lookup.TryGetValue(value, out result); - } - - public virtual bool TryLookup(int key, out XmlDictionaryString result) - { - if (key < 0 || key >= _nextId) - { - result = null; - return false; - } - result = _strings[key]; - return true; - } - - public virtual bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); - if (value.Dictionary != this) - { - result = null; - return false; - } - result = value; - return true; - } - - private class EmptyDictionary : IXmlDictionary - { - public bool TryLookup(string value, out XmlDictionaryString result) - { - result = null; - return false; - } - - public bool TryLookup(int key, out XmlDictionaryString result) - { - result = null; - return false; - } - - public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) - { - result = null; - return false; - } - } - } -} - - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryAsyncCheckWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryAsyncCheckWriter.cs index 6fb572fbafe..fbd8d50753b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryAsyncCheckWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryAsyncCheckWriter.cs @@ -10,7 +10,7 @@ using System.Text; using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { internal class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReader.cs deleted file mode 100644 index cb964f0e716..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReader.cs +++ /dev/null @@ -1,1716 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.IO; -using Microsoft.Xml; -using System.Diagnostics; -using System.Text; -using System.Runtime.Serialization; -using System.Globalization; - - -namespace Microsoft.Xml -{ - public delegate void OnXmlDictionaryReaderClose(XmlDictionaryReader reader); - - public abstract class XmlDictionaryReader : XmlReader - { - internal const int MaxInitialArrayLength = 65535; - - static public XmlDictionaryReader CreateDictionaryReader(XmlReader reader) - { - if (reader == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); - - XmlDictionaryReader dictionaryReader = reader as XmlDictionaryReader; - - if (dictionaryReader == null) - { - dictionaryReader = new XmlWrappedReader(reader, null); - } - - return dictionaryReader; - } - - public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, XmlDictionaryReaderQuotas quotas) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer"); - return CreateBinaryReader(buffer, 0, buffer.Length, quotas); - } - - public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas) - { - return CreateBinaryReader(buffer, offset, count, null, quotas); - } - - public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas) - { - return CreateBinaryReader(buffer, offset, count, dictionary, quotas, null); - } - - public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session) - { - XmlBinaryReader reader = new XmlBinaryReader(); - reader.SetInput(buffer, offset, count, dictionary, quotas, session); - return reader; - } - - - public static XmlDictionaryReader CreateBinaryReader(Stream stream, XmlDictionaryReaderQuotas quotas) - { - return CreateBinaryReader(stream, null, quotas); - } - - public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas) - { - return CreateBinaryReader(stream, dictionary, quotas, null); - } - - public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session) - { - XmlBinaryReader reader = new XmlBinaryReader(); - reader.SetInput(stream, dictionary, quotas, session); - return reader; - } - - static public XmlDictionaryReader CreateTextReader(byte[] buffer, XmlDictionaryReaderQuotas quotas) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer"); - return CreateTextReader(buffer, 0, buffer.Length, quotas); - } - - static public XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas) - { - MemoryStream ms = new MemoryStream(buffer, offset, count); - return CreateTextReader(ms, quotas); - } - - - static public XmlDictionaryReader CreateTextReader(Stream stream, XmlDictionaryReaderQuotas quotas) - { - return CreateTextReader(stream, null, quotas, null); - } - - static public XmlDictionaryReader CreateTextReader(Stream stream, Encoding encoding, - XmlDictionaryReaderQuotas quotas, - OnXmlDictionaryReaderClose onClose) - { - XmlUTF8TextReader reader = new XmlUTF8TextReader(); - reader.SetInput(stream, encoding, quotas, onClose); - return reader; - } - - public virtual bool CanCanonicalize - { - get - { - return false; - } - } - - public virtual XmlDictionaryReaderQuotas Quotas - { - get - { - return XmlDictionaryReaderQuotas.Max; - } - } - - public virtual void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); - } - - public virtual void EndCanonicalization() - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); - } - - public virtual void MoveToStartElement() - { - if (!IsStartElement()) - XmlExceptionHelper.ThrowStartElementExpected(this); - } - - public virtual void MoveToStartElement(string name) - { - if (!IsStartElement(name)) - XmlExceptionHelper.ThrowStartElementExpected(this, name); - } - - public virtual void MoveToStartElement(string localName, string namespaceUri) - { - if (!IsStartElement(localName, namespaceUri)) - XmlExceptionHelper.ThrowStartElementExpected(this, localName, namespaceUri); - } - - public virtual void MoveToStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - if (!IsStartElement(localName, namespaceUri)) - XmlExceptionHelper.ThrowStartElementExpected(this, localName, namespaceUri); - } - - public virtual bool IsLocalName(string localName) - { - return this.LocalName == localName; - } - - public virtual bool IsLocalName(XmlDictionaryString localName) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localName"); - - return IsLocalName(localName.Value); - } - - public virtual bool IsNamespaceUri(string namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - return this.NamespaceURI == namespaceUri; - } - - public virtual bool IsNamespaceUri(XmlDictionaryString namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - return IsNamespaceUri(namespaceUri.Value); - } - - public virtual void ReadFullStartElement() - { - MoveToStartElement(); - if (IsEmptyElement) - XmlExceptionHelper.ThrowFullStartElementExpected(this); - Read(); - } - - public virtual void ReadFullStartElement(string name) - { - MoveToStartElement(name); - if (IsEmptyElement) - XmlExceptionHelper.ThrowFullStartElementExpected(this, name); - Read(); - } - - public virtual void ReadFullStartElement(string localName, string namespaceUri) - { - MoveToStartElement(localName, namespaceUri); - if (IsEmptyElement) - XmlExceptionHelper.ThrowFullStartElementExpected(this, localName, namespaceUri); - Read(); - } - - public virtual void ReadFullStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - MoveToStartElement(localName, namespaceUri); - if (IsEmptyElement) - XmlExceptionHelper.ThrowFullStartElementExpected(this, localName, namespaceUri); - Read(); - } - - public virtual void ReadStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - MoveToStartElement(localName, namespaceUri); - Read(); - } - - public virtual bool IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return IsStartElement(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri)); - } - - public virtual int IndexOfLocalName(string[] localNames, string namespaceUri) - { - if (localNames == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localNames"); - - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - - if (this.NamespaceURI == namespaceUri) - { - string localName = this.LocalName; - for (int i = 0; i < localNames.Length; i++) - { - string value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (localName == value) - { - return i; - } - } - } - - return -1; - } - - public virtual int IndexOfLocalName(XmlDictionaryString[] localNames, XmlDictionaryString namespaceUri) - { - if (localNames == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localNames"); - - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - - if (this.NamespaceURI == namespaceUri.Value) - { - string localName = this.LocalName; - for (int i = 0; i < localNames.Length; i++) - { - XmlDictionaryString value = localNames[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "localNames[{0}]", i)); - if (localName == value.Value) - { - return i; - } - } - } - - return -1; - } - - public virtual string GetAttribute(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return GetAttribute(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri)); - } - - public virtual bool TryGetBase64ContentLength(out int length) - { - length = 0; - return false; - } - - public virtual int ReadValueAsBase64(byte[] buffer, int offset, int count) - { - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); - } - - public virtual byte[] ReadContentAsBase64() - { - return ReadContentAsBase64(Quotas.MaxArrayLength, MaxInitialArrayLength); - } - - internal byte[] ReadContentAsBase64(int maxByteArrayContentLength, int maxInitialCount) - { - int length; - if (TryGetBase64ContentLength(out length)) - { - if (length <= maxInitialCount) - { - byte[] buffer = new byte[length]; - int read = 0; - while (read < length) - { - int actual = ReadContentAsBase64(buffer, read, length - read); - if (actual == 0) - XmlExceptionHelper.ThrowBase64DataExpected(this); - read += actual; - } - return buffer; - } - } - return ReadContentAsBytes(true, maxByteArrayContentLength); - } - - public override string ReadContentAsString() - { - return ReadContentAsString(Quotas.MaxStringContentLength); - } - - protected string ReadContentAsString(int maxStringContentLength) - { - StringBuilder sb = null; - string result = string.Empty; - bool done = false; - while (true) - { - switch (this.NodeType) - { - case XmlNodeType.Attribute: - result = this.Value; - break; - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - case XmlNodeType.CDATA: - // merge text content - string value = this.Value; - if (result.Length == 0) - { - result = value; - } - else - { - if (sb == null) - sb = new StringBuilder(result); - sb.Append(value); - } - break; - case XmlNodeType.ProcessingInstruction: - case XmlNodeType.Comment: - case XmlNodeType.EndEntity: - // skip comments, pis and end entity nodes - break; - case XmlNodeType.EntityReference: - if (this.CanResolveEntity) - { - this.ResolveEntity(); - break; - } - goto default; - case XmlNodeType.Element: - case XmlNodeType.EndElement: - default: - done = true; - break; - } - if (done) - break; - if (this.AttributeCount != 0) - ReadAttributeValue(); - else - Read(); - } - if (sb != null) - result = sb.ToString(); - return result; - } - - - public virtual byte[] ReadContentAsBinHex() - { - return ReadContentAsBinHex(Quotas.MaxArrayLength); - } - - protected byte[] ReadContentAsBinHex(int maxByteArrayContentLength) - { - return ReadContentAsBytes(false, maxByteArrayContentLength); - } - - private byte[] ReadContentAsBytes(bool base64, int maxByteArrayContentLength) - { - byte[][] buffers = new byte[32][]; - byte[] buffer; - // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text - int count = 384; - int bufferCount = 0; - int totalRead = 0; - while (true) - { - buffer = new byte[count]; - buffers[bufferCount++] = buffer; - int read = 0; - while (read < buffer.Length) - { - int actual; - if (base64) - actual = ReadContentAsBase64(buffer, read, buffer.Length - read); - else - actual = ReadContentAsBinHex(buffer, read, buffer.Length - read); - if (actual == 0) - break; - read += actual; - } - totalRead += read; - if (read < buffer.Length) - break; - count = count * 2; - } - buffer = new byte[totalRead]; - int offset = 0; - for (int i = 0; i < bufferCount - 1; i++) - { - Buffer.BlockCopy(buffers[i], 0, buffer, offset, buffers[i].Length); - offset += buffers[i].Length; - } - Buffer.BlockCopy(buffers[bufferCount - 1], 0, buffer, offset, totalRead - offset); - return buffer; - } - - protected bool IsTextNode(XmlNodeType nodeType) - { - return nodeType == XmlNodeType.Text || - nodeType == XmlNodeType.Whitespace || - nodeType == XmlNodeType.SignificantWhitespace || - nodeType == XmlNodeType.CDATA || - nodeType == XmlNodeType.Attribute; - } - - public virtual int ReadContentAsChars(char[] chars, int offset, int count) - { - int read = 0; - while (true) - { - XmlNodeType nodeType = this.NodeType; - - if (nodeType == XmlNodeType.Element || nodeType == XmlNodeType.EndElement) - break; - - if (IsTextNode(nodeType)) - { - read = ReadValueChunk(chars, offset, count); - - if (read > 0) - break; - - if (nodeType == XmlNodeType.Attribute /* || inAttributeText */) - break; - - if (!Read()) - break; - } - else - { - if (!Read()) - break; - } - } - - return read; - } - - public override object ReadContentAs(Type type, IXmlNamespaceResolver namespaceResolver) - { - if (type == typeof(Guid[])) - { - string[] values = (string[])ReadContentAs(typeof(string[]), namespaceResolver); - Guid[] guids = new Guid[values.Length]; - for (int i = 0; i < values.Length; i++) - guids[i] = XmlConverter.ToGuid(values[i]); - return guids; - } - if (type == typeof(UniqueId[])) - { - string[] values = (string[])ReadContentAs(typeof(string[]), namespaceResolver); - UniqueId[] uniqueIds = new UniqueId[values.Length]; - for (int i = 0; i < values.Length; i++) - uniqueIds[i] = XmlConverter.ToUniqueId(values[i]); - return uniqueIds; - } - return base.ReadContentAs(type, namespaceResolver); - } - - public virtual string ReadContentAsString(string[] strings, out int index) - { - if (strings == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("strings"); - string s = ReadContentAsString(); - index = -1; - for (int i = 0; i < strings.Length; i++) - { - string value = strings[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "strings[{0}]", i)); - if (value == s) - { - index = i; - return value; - } - } - return s; - } - - public virtual string ReadContentAsString(XmlDictionaryString[] strings, out int index) - { - if (strings == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("strings"); - string s = ReadContentAsString(); - index = -1; - for (int i = 0; i < strings.Length; i++) - { - XmlDictionaryString value = strings[i]; - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "strings[{0}]", i)); - if (value.Value == s) - { - index = i; - return value.Value; - } - } - return s; - } - - public override decimal ReadContentAsDecimal() - { - return XmlConverter.ToDecimal(ReadContentAsString()); - } - - public override Single ReadContentAsFloat() - { - return XmlConverter.ToSingle(ReadContentAsString()); - } - - public virtual UniqueId ReadContentAsUniqueId() - { - return XmlConverter.ToUniqueId(ReadContentAsString()); - } - - public virtual Guid ReadContentAsGuid() - { - return XmlConverter.ToGuid(ReadContentAsString()); - } - - public virtual TimeSpan ReadContentAsTimeSpan() - { - return XmlConverter.ToTimeSpan(ReadContentAsString()); - } - - public virtual void ReadContentAsQualifiedName(out string localName, out string namespaceUri) - { - string prefix; - XmlConverter.ToQualifiedName(ReadContentAsString(), out prefix, out localName); - namespaceUri = LookupNamespace(prefix); - if (namespaceUri == null) - XmlExceptionHelper.ThrowUndefinedPrefix(this, prefix); - } - - /* string, bool, int, long, float, double, decimal, DateTime, base64, binhex, uniqueID, object, list*/ - public override string ReadElementContentAsString() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - string value; - - if (isEmptyElement) - { - Read(); - value = string.Empty; - } - else - { - ReadStartElement(); - value = ReadContentAsString(); - ReadEndElement(); - } - - return value; - } - - public override bool ReadElementContentAsBoolean() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - bool value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToBoolean(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsBoolean(); - ReadEndElement(); - } - - return value; - } - - public override int ReadElementContentAsInt() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - int value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToInt32(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsInt(); - ReadEndElement(); - } - - return value; - } - - public override long ReadElementContentAsLong() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - long value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToInt64(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsLong(); - ReadEndElement(); - } - - return value; - } - - public override float ReadElementContentAsFloat() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - float value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToSingle(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsFloat(); - ReadEndElement(); - } - - return value; - } - - public override double ReadElementContentAsDouble() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - double value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToDouble(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsDouble(); - ReadEndElement(); - } - - return value; - } - - public override decimal ReadElementContentAsDecimal() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - decimal value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToDecimal(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsDecimal(); - ReadEndElement(); - } - - return value; - } - - public override DateTime ReadElementContentAsDateTime() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - DateTime value; - - if (isEmptyElement) - { - Read(); - try - { - value = DateTime.Parse(string.Empty, NumberFormatInfo.InvariantInfo); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "DateTime", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "DateTime", exception)); - } - } - else - { - ReadStartElement(); - value = ReadContentAsDateTimeOffset().DateTime; - ReadEndElement(); - } - - return value; - } - - public virtual UniqueId ReadElementContentAsUniqueId() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - UniqueId value; - - if (isEmptyElement) - { - Read(); - try - { - value = new UniqueId(string.Empty); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "UniqueId", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "UniqueId", exception)); - } - } - else - { - ReadStartElement(); - value = ReadContentAsUniqueId(); - ReadEndElement(); - } - - return value; - } - - public virtual Guid ReadElementContentAsGuid() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - Guid value; - - if (isEmptyElement) - { - Read(); - try - { - value = new Guid(string.Empty); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "Guid", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "Guid", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(string.Empty, "Guid", exception)); - } - } - else - { - ReadStartElement(); - value = ReadContentAsGuid(); - ReadEndElement(); - } - - return value; - } - - public virtual TimeSpan ReadElementContentAsTimeSpan() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - TimeSpan value; - - if (isEmptyElement) - { - Read(); - value = XmlConverter.ToTimeSpan(string.Empty); - } - else - { - ReadStartElement(); - value = ReadContentAsTimeSpan(); - ReadEndElement(); - } - - return value; - } - - public virtual byte[] ReadElementContentAsBase64() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - byte[] buffer; - - if (isEmptyElement) - { - Read(); - buffer = Array.Empty(); - } - else - { - ReadStartElement(); - buffer = ReadContentAsBase64(); - ReadEndElement(); - } - - return buffer; - } - - public virtual byte[] ReadElementContentAsBinHex() - { - bool isEmptyElement = IsStartElement() && IsEmptyElement; - byte[] buffer; - - if (isEmptyElement) - { - Read(); - buffer = Array.Empty(); - } - else - { - ReadStartElement(); - buffer = ReadContentAsBinHex(); - ReadEndElement(); - } - - return buffer; - } - - public virtual bool TryGetLocalNameAsDictionaryString(out XmlDictionaryString localName) - { - localName = null; - return false; - } - - public virtual bool TryGetNamespaceUriAsDictionaryString(out XmlDictionaryString namespaceUri) - { - namespaceUri = null; - return false; - } - - public virtual bool TryGetValueAsDictionaryString(out XmlDictionaryString value) - { - value = null; - return false; - } - - private void CheckArray(Array array, int offset, int count) - { - if (array == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("array")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > array.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, array.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > array.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, array.Length - offset))); - } - - public virtual bool IsStartArray(out Type type) - { - type = null; - return false; - } - - public virtual bool TryGetArrayLength(out int count) - { - count = 0; - return false; - } - - // Boolean - public virtual bool[] ReadBooleanArray(string localName, string namespaceUri) - { - return BooleanArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual bool[] ReadBooleanArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return BooleanArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, bool[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsBoolean(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int16 - public virtual Int16[] ReadInt16Array(string localName, string namespaceUri) - { - return Int16ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual Int16[] ReadInt16Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int16ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, Int16[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - int i = ReadElementContentAsInt(); - if (i < Int16.MinValue || i > Int16.MaxValue) - XmlExceptionHelper.ThrowConversionOverflow(this, i.ToString(NumberFormatInfo.CurrentInfo), "Int16"); - array[offset + actual] = (Int16)i; - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int16[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int32 - public virtual Int32[] ReadInt32Array(string localName, string namespaceUri) - { - return Int32ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual Int32[] ReadInt32Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int32ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, Int32[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsInt(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int32[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int64 - public virtual Int64[] ReadInt64Array(string localName, string namespaceUri) - { - return Int64ArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual Int64[] ReadInt64Array(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return Int64ArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, Int64[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsLong(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int64[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Single - public virtual float[] ReadSingleArray(string localName, string namespaceUri) - { - return SingleArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual float[] ReadSingleArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return SingleArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, float[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsFloat(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Double - public virtual double[] ReadDoubleArray(string localName, string namespaceUri) - { - return DoubleArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual double[] ReadDoubleArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DoubleArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, double[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsDouble(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Decimal - public virtual decimal[] ReadDecimalArray(string localName, string namespaceUri) - { - return DecimalArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual decimal[] ReadDecimalArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DecimalArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, decimal[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsDecimal(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // DateTime - public virtual DateTime[] ReadDateTimeArray(string localName, string namespaceUri) - { - return DateTimeArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual DateTime[] ReadDateTimeArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return DateTimeArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, DateTime[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsDateTime(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Guid - public virtual Guid[] ReadGuidArray(string localName, string namespaceUri) - { - return GuidArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual Guid[] ReadGuidArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return GuidArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, Guid[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsGuid(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // TimeSpan - public virtual TimeSpan[] ReadTimeSpanArray(string localName, string namespaceUri) - { - return TimeSpanArrayHelperWithString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual TimeSpan[] ReadTimeSpanArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - return TimeSpanArrayHelperWithDictionaryString.Instance.ReadArray(this, localName, namespaceUri, Quotas.MaxArrayLength); - } - - public virtual int ReadArray(string localName, string namespaceUri, TimeSpan[] array, int offset, int count) - { - CheckArray(array, offset, count); - int actual = 0; - while (actual < count && IsStartElement(localName, namespaceUri)) - { - array[offset + actual] = ReadElementContentAsTimeSpan(); - actual++; - } - return actual; - } - - public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count) - { - return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - private class XmlWrappedReader : XmlDictionaryReader, IXmlLineInfo - { - private XmlReader _reader; - private XmlNamespaceManager _nsMgr; - - public XmlWrappedReader(XmlReader reader, XmlNamespaceManager nsMgr) - { - _reader = reader; - _nsMgr = nsMgr; - } - - public override int AttributeCount - { - get - { - return _reader.AttributeCount; - } - } - - public override string BaseURI - { - get - { - return _reader.BaseURI; - } - } - - public override bool CanReadBinaryContent - { - get { return _reader.CanReadBinaryContent; } - } - - public override bool CanReadValueChunk - { - get { return _reader.CanReadValueChunk; } - } - - public override void Close() - { - _reader.Dispose(); - _nsMgr = null; - } - - public override int Depth - { - get - { - return _reader.Depth; - } - } - - public override bool EOF - { - get - { - return _reader.EOF; - } - } - - public override string GetAttribute(int index) - { - return _reader.GetAttribute(index); - } - - public override string GetAttribute(string name) - { - return _reader.GetAttribute(name); - } - - public override string GetAttribute(string name, string namespaceUri) - { - return _reader.GetAttribute(name, namespaceUri); - } - - public override bool HasValue - { - get - { - return _reader.HasValue; - } - } - - public override bool IsDefault - { - get - { - return _reader.IsDefault; - } - } - - public override bool IsEmptyElement - { - get - { - return _reader.IsEmptyElement; - } - } - - public override bool IsStartElement(string name) - { - return _reader.IsStartElement(name); - } - - public override bool IsStartElement(string localName, string namespaceUri) - { - return _reader.IsStartElement(localName, namespaceUri); - } - - public override string LocalName - { - get - { - return _reader.LocalName; - } - } - - public override string LookupNamespace(string namespaceUri) - { - return _reader.LookupNamespace(namespaceUri); - } - - public override void MoveToAttribute(int index) - { - _reader.MoveToAttribute(index); - } - - public override bool MoveToAttribute(string name) - { - return _reader.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string name, string namespaceUri) - { - return _reader.MoveToAttribute(name, namespaceUri); - } - - public override bool MoveToElement() - { - return _reader.MoveToElement(); - } - - public override bool MoveToFirstAttribute() - { - return _reader.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - return _reader.MoveToNextAttribute(); - } - - public override string Name - { - get - { - return _reader.Name; - } - } - - public override string NamespaceURI - { - get - { - return _reader.NamespaceURI; - } - } - - public override XmlNameTable NameTable - { - get - { - return _reader.NameTable; - } - } - - public override XmlNodeType NodeType - { - get - { - return _reader.NodeType; - } - } - - public override string Prefix - { - get - { - return _reader.Prefix; - } - } - - - public override bool Read() - { - return _reader.Read(); - } - - public override bool ReadAttributeValue() - { - return _reader.ReadAttributeValue(); - } - - - public override string ReadInnerXml() - { - return _reader.ReadInnerXml(); - } - - public override string ReadOuterXml() - { - return _reader.ReadOuterXml(); - } - - public override void ReadStartElement(string name) - { - _reader.ReadStartElement(name); - } - - public override void ReadStartElement(string localName, string namespaceUri) - { - _reader.ReadStartElement(localName, namespaceUri); - } - - public override void ReadEndElement() - { - _reader.ReadEndElement(); - } - - public override ReadState ReadState - { - get - { - return _reader.ReadState; - } - } - - public override void ResolveEntity() - { - _reader.ResolveEntity(); - } - - public override string this[int index] - { - get - { - return _reader[index]; - } - } - - public override string this[string name] - { - get - { - return _reader[name]; - } - } - - public override string this[string name, string namespaceUri] - { - get - { - return _reader[name, namespaceUri]; - } - } - - public override string Value - { - get - { - return _reader.Value; - } - } - - public override string XmlLang - { - get - { - return _reader.XmlLang; - } - } - - public override XmlSpace XmlSpace - { - get - { - return _reader.XmlSpace; - } - } - - public override int ReadElementContentAsBase64(byte[] buffer, int offset, int count) - { - return _reader.ReadElementContentAsBase64(buffer, offset, count); - } - - public override int ReadContentAsBase64(byte[] buffer, int offset, int count) - { - return _reader.ReadContentAsBase64(buffer, offset, count); - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int offset, int count) - { - return _reader.ReadElementContentAsBinHex(buffer, offset, count); - } - - public override int ReadContentAsBinHex(byte[] buffer, int offset, int count) - { - return _reader.ReadContentAsBinHex(buffer, offset, count); - } - - public override int ReadValueChunk(char[] chars, int offset, int count) - { - return _reader.ReadValueChunk(chars, offset, count); - } - - public override Type ValueType - { - get - { - return _reader.ValueType; - } - } - - public override Boolean ReadContentAsBoolean() - { - try - { - return _reader.ReadContentAsBoolean(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Boolean", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Boolean", exception)); - } - } - - public override DateTime ReadContentAsDateTime() - { - try - { - return _reader.ReadContentAsDateTimeOffset().DateTime; - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("DateTime", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("DateTime", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("DateTime", exception)); - } - } - - public override Decimal ReadContentAsDecimal() - { - try - { - return (Decimal)_reader.ReadContentAs(typeof(Decimal), null); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); - } - } - - public override Double ReadContentAsDouble() - { - try - { - return _reader.ReadContentAsDouble(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); - } - } - - public override Int32 ReadContentAsInt() - { - try - { - return _reader.ReadContentAsInt(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); - } - } - - public override Int64 ReadContentAsLong() - { - try - { - return _reader.ReadContentAsLong(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); - } - } - - public override Single ReadContentAsFloat() - { - try - { - return _reader.ReadContentAsFloat(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); - } - catch (OverflowException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); - } - } - - public override string ReadContentAsString() - { - try - { - return _reader.ReadContentAsString(); - } - catch (ArgumentException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("String", exception)); - } - catch (FormatException exception) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("String", exception)); - } - } - - public override object ReadContentAs(Type type, IXmlNamespaceResolver namespaceResolver) - { - return _reader.ReadContentAs(type, namespaceResolver); - } - - public bool HasLineInfo() - { - IXmlLineInfo lineInfo = _reader as IXmlLineInfo; - - if (lineInfo == null) - return false; - - return lineInfo.HasLineInfo(); - } - - public int LineNumber - { - get - { - IXmlLineInfo lineInfo = _reader as IXmlLineInfo; - - if (lineInfo == null) - return 1; - - return lineInfo.LineNumber; - } - } - - public int LinePosition - { - get - { - IXmlLineInfo lineInfo = _reader as IXmlLineInfo; - - if (lineInfo == null) - return 1; - - return lineInfo.LinePosition; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReaderQuotas.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReaderQuotas.cs deleted file mode 100644 index f4f53fb2564..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryReaderQuotas.cs +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.Serialization; -using System.ComponentModel; - - -namespace Microsoft.Xml -{ - using System; - - [Flags] - public enum XmlDictionaryReaderQuotaTypes - { - MaxDepth = 0x01, - MaxStringContentLength = 0x02, - MaxArrayLength = 0x04, - MaxBytesPerRead = 0x08, - MaxNameTableCharCount = 0x10 - } - - public sealed class XmlDictionaryReaderQuotas - { - private bool _readOnly; - private int _maxStringContentLength; - private int _maxArrayLength; - private int _maxDepth; - private int _maxNameTableCharCount; - private int _maxBytesPerRead; - private XmlDictionaryReaderQuotaTypes _modifiedQuotas = 0x00; - private const int DefaultMaxDepth = 32; - private const int DefaultMaxStringContentLength = 8192; - private const int DefaultMaxArrayLength = 16384; - private const int DefaultMaxBytesPerRead = 4096; - private const int DefaultMaxNameTableCharCount = 16384; - private static readonly XmlDictionaryReaderQuotas s_maxQuota = new XmlDictionaryReaderQuotas(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, - XmlDictionaryReaderQuotaTypes.MaxDepth | XmlDictionaryReaderQuotaTypes.MaxStringContentLength | XmlDictionaryReaderQuotaTypes.MaxArrayLength | XmlDictionaryReaderQuotaTypes.MaxBytesPerRead | XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount); - - public XmlDictionaryReaderQuotas() - { - _maxDepth = DefaultMaxDepth; - _maxStringContentLength = DefaultMaxStringContentLength; - _maxArrayLength = DefaultMaxArrayLength; - _maxBytesPerRead = DefaultMaxBytesPerRead; - _maxNameTableCharCount = DefaultMaxNameTableCharCount; - } - - private XmlDictionaryReaderQuotas(int maxDepth, int maxStringContentLength, int maxArrayLength, int maxBytesPerRead, int maxNameTableCharCount, XmlDictionaryReaderQuotaTypes modifiedQuotas) - { - _maxDepth = maxDepth; - _maxStringContentLength = maxStringContentLength; - _maxArrayLength = maxArrayLength; - _maxBytesPerRead = maxBytesPerRead; - _maxNameTableCharCount = maxNameTableCharCount; - _modifiedQuotas = modifiedQuotas; - MakeReadOnly(); - } - - static public XmlDictionaryReaderQuotas Max - { - get - { - return s_maxQuota; - } - } - - public void CopyTo(XmlDictionaryReaderQuotas quotas) - { - if (quotas == null) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("quotas")); - if (quotas._readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaCopyReadOnly))); - - InternalCopyTo(quotas); - } - - internal void InternalCopyTo(XmlDictionaryReaderQuotas quotas) - { - quotas._maxStringContentLength = _maxStringContentLength; - quotas._maxArrayLength = _maxArrayLength; - quotas._maxDepth = _maxDepth; - quotas._maxNameTableCharCount = _maxNameTableCharCount; - quotas._maxBytesPerRead = _maxBytesPerRead; - quotas._modifiedQuotas = _modifiedQuotas; - } - - [DefaultValue(DefaultMaxStringContentLength)] - public int MaxStringContentLength - { - get - { - return _maxStringContentLength; - } - set - { - if (_readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaIsReadOnly, "MaxStringContentLength"))); - if (value <= 0) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.QuotaMustBePositive), "value")); - _maxStringContentLength = value; - _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxStringContentLength; - } - } - - [DefaultValue(DefaultMaxArrayLength)] - public int MaxArrayLength - { - get - { - return _maxArrayLength; - } - set - { - if (_readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaIsReadOnly, "MaxArrayLength"))); - if (value <= 0) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.QuotaMustBePositive), "value")); - _maxArrayLength = value; - _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxArrayLength; - } - } - - [DefaultValue(DefaultMaxBytesPerRead)] - public int MaxBytesPerRead - { - get - { - return _maxBytesPerRead; - } - set - { - if (_readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaIsReadOnly, "MaxBytesPerRead"))); - if (value <= 0) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.QuotaMustBePositive), "value")); - - _maxBytesPerRead = value; - _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxBytesPerRead; - } - } - - [DefaultValue(DefaultMaxDepth)] - public int MaxDepth - { - get - { - return _maxDepth; - } - set - { - if (_readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaIsReadOnly, "MaxDepth"))); - if (value <= 0) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.QuotaMustBePositive), "value")); - - _maxDepth = value; - _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxDepth; - } - } - - [DefaultValue(DefaultMaxNameTableCharCount)] - public int MaxNameTableCharCount - { - get - { - return _maxNameTableCharCount; - } - set - { - if (_readOnly) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRSerialization.QuotaIsReadOnly, "MaxNameTableCharCount"))); - if (value <= 0) - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(string.Format(SRSerialization.QuotaMustBePositive), "value")); - - _maxNameTableCharCount = value; - _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount; - } - } - - public XmlDictionaryReaderQuotaTypes ModifiedQuotas - { - get - { - return _modifiedQuotas; - } - } - - internal void MakeReadOnly() - { - _readOnly = true; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryString.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryString.cs deleted file mode 100644 index e14c3df0368..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryString.cs +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Xml; -using System.Text; -using System.Diagnostics; -using System.Runtime.Serialization; - - -namespace Microsoft.Xml -{ - public class XmlDictionaryString - { - internal const int MinKey = 0; - internal const int MaxKey = int.MaxValue / 4; - - private IXmlDictionary _dictionary; - private string _value; - private int _key; - private byte[] _buffer; - private static EmptyStringDictionary s_emptyStringDictionary = new EmptyStringDictionary(); - - public XmlDictionaryString(IXmlDictionary dictionary, string value, int key) - { - if (dictionary == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("dictionary")); - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); - if (key < MinKey || key > MaxKey) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("key", string.Format(SRSerialization.ValueMustBeInRange, MinKey, MaxKey))); - _dictionary = dictionary; - _value = value; - _key = key; - } - - static internal string GetString(XmlDictionaryString s) - { - if (s == null) - return null; - return s.Value; - } - - static public XmlDictionaryString Empty - { - get - { - return s_emptyStringDictionary.EmptyString; - } - } - - public IXmlDictionary Dictionary - { - get - { - return _dictionary; - } - } - - public int Key - { - get - { - return _key; - } - } - - public string Value - { - get - { - return _value; - } - } - - internal byte[] ToUTF8() - { - if (_buffer == null) - _buffer = System.Text.Encoding.UTF8.GetBytes(_value); - return _buffer; - } - - public override string ToString() - { - return _value; - } - - private class EmptyStringDictionary : IXmlDictionary - { - private XmlDictionaryString _empty; - - public EmptyStringDictionary() - { - _empty = new XmlDictionaryString(this, string.Empty, 0); - } - - public XmlDictionaryString EmptyString - { - get - { - return _empty; - } - } - - public bool TryLookup(string value, out XmlDictionaryString result) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - if (value.Length == 0) - { - result = _empty; - return true; - } - result = null; - return false; - } - - public bool TryLookup(int key, out XmlDictionaryString result) - { - if (key == 0) - { - result = _empty; - return true; - } - result = null; - return false; - } - - public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); - if (value.Dictionary != this) - { - result = null; - return false; - } - result = value; - return true; - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryWriter.cs deleted file mode 100644 index d8f79c9612d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlDictionaryWriter.cs +++ /dev/null @@ -1,843 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Microsoft.Xml; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Runtime.Serialization; -using System.Security; -using System.Text; - - -namespace Microsoft.Xml -{ - public abstract class XmlDictionaryWriter : XmlWriter - { - static public XmlDictionaryWriter CreateBinaryWriter(Stream stream) - { - return CreateBinaryWriter(stream, null); - } - - static public XmlDictionaryWriter CreateBinaryWriter(Stream stream, IXmlDictionary dictionary) - { - return CreateBinaryWriter(stream, dictionary, null); - } - - static public XmlDictionaryWriter CreateBinaryWriter(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session) - { - return CreateBinaryWriter(stream, dictionary, session, true); - } - - static public XmlDictionaryWriter CreateBinaryWriter(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream) - { - XmlBinaryWriter writer = new XmlBinaryWriter(); - writer.SetOutput(stream, dictionary, session, ownsStream); - return writer; - } - - private static readonly Encoding s_UTF8Encoding = new UTF8Encoding(false); - static public XmlDictionaryWriter CreateTextWriter(Stream stream) - { - return CreateTextWriter(stream, s_UTF8Encoding, true); - } - - static public XmlDictionaryWriter CreateTextWriter(Stream stream, Encoding encoding) - { - return CreateTextWriter(stream, encoding, true); - } - - static public XmlDictionaryWriter CreateTextWriter(Stream stream, Encoding encoding, bool ownsStream) - { - XmlUTF8TextWriter writer = new XmlUTF8TextWriter(); - writer.SetOutput(stream, encoding, ownsStream); - var asyncWriter = new XmlDictionaryAsyncCheckWriter(writer); - return asyncWriter; - } - - static public XmlDictionaryWriter CreateDictionaryWriter(XmlWriter writer) - { - if (writer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer"); - - XmlDictionaryWriter dictionaryWriter = writer as XmlDictionaryWriter; - - if (dictionaryWriter == null) - { - dictionaryWriter = new XmlWrappedWriter(writer); - } - - return dictionaryWriter; - } - - public void WriteStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - WriteStartElement((string)null, localName, namespaceUri); - } - - public virtual void WriteStartElement(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - WriteStartElement(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri)); - } - - public void WriteStartAttribute(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - WriteStartAttribute((string)null, localName, namespaceUri); - } - - public virtual void WriteStartAttribute(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - WriteStartAttribute(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri)); - } - - public void WriteAttributeString(XmlDictionaryString localName, XmlDictionaryString namespaceUri, string value) - { - WriteAttributeString((string)null, localName, namespaceUri, value); - } - - public virtual void WriteXmlnsAttribute(string prefix, string namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - if (prefix == null) - { - if (LookupPrefix(namespaceUri) != null) - return; -#pragma warning disable 56506 // Microsoft, namespaceUri is already checked - prefix = namespaceUri.Length == 0 ? string.Empty : string.Concat("d", namespaceUri.Length.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); - } - WriteAttributeString("xmlns", prefix, null, namespaceUri); - } - - public virtual void WriteXmlnsAttribute(string prefix, XmlDictionaryString namespaceUri) - { - WriteXmlnsAttribute(prefix, XmlDictionaryString.GetString(namespaceUri)); - } - - public virtual void WriteXmlAttribute(string localName, string value) - { - WriteAttributeString("xml", localName, null, value); - } - - public virtual void WriteXmlAttribute(XmlDictionaryString localName, XmlDictionaryString value) - { - WriteXmlAttribute(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(value)); - } - - public void WriteAttributeString(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, string value) - { - WriteStartAttribute(prefix, localName, namespaceUri); - WriteString(value); - WriteEndAttribute(); - } - - public void WriteElementString(XmlDictionaryString localName, XmlDictionaryString namespaceUri, string value) - { - WriteElementString((string)null, localName, namespaceUri, value); - } - - public void WriteElementString(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, string value) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteString(value); - WriteEndElement(); - } - - public virtual void WriteString(XmlDictionaryString value) - { - WriteString(XmlDictionaryString.GetString(value)); - } - - public virtual void WriteQualifiedName(XmlDictionaryString localName, XmlDictionaryString namespaceUri) - { - if (localName == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName")); - if (namespaceUri == null) - namespaceUri = XmlDictionaryString.Empty; -#pragma warning disable 56506 // Microsoft, XmlDictionaryString.Empty is never null - WriteQualifiedName(localName.Value, namespaceUri.Value); - } - - public virtual void WriteValue(XmlDictionaryString value) - { - WriteValue(XmlDictionaryString.GetString(value)); - } - - - public virtual void WriteValue(UniqueId value) - { - if (value == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); - - WriteString(value.ToString()); - } - - public virtual void WriteValue(Guid value) - { - WriteString(value.ToString()); - } - - public virtual void WriteValue(TimeSpan value) - { - WriteString(XmlConvert.ToString(value)); - } - - public virtual bool CanCanonicalize - { - get - { - return false; - } - } - - public virtual void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); - } - - public virtual void EndCanonicalization() - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); - } - - private void WriteElementNode(XmlDictionaryReader reader, bool defattr) - { - XmlDictionaryString localName; - XmlDictionaryString namespaceUri; - if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri)) - { - WriteStartElement(reader.Prefix, localName, namespaceUri); - } - else - { - WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); - } - if (defattr || !reader.IsDefault) - { - if (reader.MoveToFirstAttribute()) - { - do - { - if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri)) - { - WriteStartAttribute(reader.Prefix, localName, namespaceUri); - } - else - { - WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI); - } - while (reader.ReadAttributeValue()) - { - if (reader.NodeType == XmlNodeType.EntityReference) - { - WriteEntityRef(reader.Name); - } - else - { - WriteTextNode(reader, true); - } - } - WriteEndAttribute(); - } - while (reader.MoveToNextAttribute()); - reader.MoveToElement(); - } - } - if (reader.IsEmptyElement) - { - WriteEndElement(); - } - } - - private void WriteArrayNode(XmlDictionaryReader reader, string prefix, string localName, string namespaceUri, Type type) - { - if (type == typeof(bool)) - BooleanArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int16)) - Int16ArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int32)) - Int32ArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int64)) - Int64ArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(float)) - SingleArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(double)) - DoubleArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(decimal)) - DecimalArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(DateTime)) - DateTimeArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Guid)) - GuidArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(TimeSpan)) - TimeSpanArrayHelperWithString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else - { - WriteElementNode(reader, false); - reader.Read(); - } - } - - private void WriteArrayNode(XmlDictionaryReader reader, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Type type) - { - if (type == typeof(bool)) - BooleanArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int16)) - Int16ArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int32)) - Int32ArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Int64)) - Int64ArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(float)) - SingleArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(double)) - DoubleArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(decimal)) - DecimalArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(DateTime)) - DateTimeArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(Guid)) - GuidArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else if (type == typeof(TimeSpan)) - TimeSpanArrayHelperWithDictionaryString.Instance.WriteArray(this, prefix, localName, namespaceUri, reader); - else - { - WriteElementNode(reader, false); - reader.Read(); - } - } - - private void WriteArrayNode(XmlDictionaryReader reader, Type type) - { - XmlDictionaryString localName; - XmlDictionaryString namespaceUri; - if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri)) - WriteArrayNode(reader, reader.Prefix, localName, namespaceUri, type); - else - WriteArrayNode(reader, reader.Prefix, reader.LocalName, reader.NamespaceURI, type); - } - - protected virtual void WriteTextNode(XmlDictionaryReader reader, bool isAttribute) - { - XmlDictionaryString value; - if (reader.TryGetValueAsDictionaryString(out value)) - { - WriteString(value); - } - else - { - WriteString(reader.Value); - } - if (!isAttribute) - { - reader.Read(); - } - } - - public override void WriteNode(XmlReader reader, bool defattr) - { - XmlDictionaryReader dictionaryReader = reader as XmlDictionaryReader; - if (dictionaryReader != null) - WriteNode(dictionaryReader, defattr); - else - base.WriteNode(reader, defattr); - } - - public virtual void WriteNode(XmlDictionaryReader reader, bool defattr) - { - if (reader == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader")); - int d = (reader.NodeType == XmlNodeType.None ? -1 : reader.Depth); - do - { - XmlNodeType nodeType = reader.NodeType; - Type type; - if (nodeType == XmlNodeType.Text || nodeType == XmlNodeType.Whitespace || nodeType == XmlNodeType.SignificantWhitespace) - { - // This will advance if necessary, so we don't need to call Read() explicitly - WriteTextNode(reader, false); - } - else if (reader.Depth > d && reader.IsStartArray(out type)) - { - WriteArrayNode(reader, type); - } - else - { - // These will not advance, so we must call Read() explicitly - switch (nodeType) - { - case XmlNodeType.Element: - WriteElementNode(reader, defattr); - break; - case XmlNodeType.CDATA: - WriteCData(reader.Value); - break; - case XmlNodeType.EntityReference: - WriteEntityRef(reader.Name); - break; - case XmlNodeType.XmlDeclaration: - case XmlNodeType.ProcessingInstruction: - WriteProcessingInstruction(reader.Name, reader.Value); - break; - case XmlNodeType.DocumentType: - WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value); - break; - case XmlNodeType.Comment: - WriteComment(reader.Value); - break; - case XmlNodeType.EndElement: - WriteFullEndElement(); - break; - } - if (!reader.Read()) - break; - } - } - while (d < reader.Depth || (d == reader.Depth && reader.NodeType == XmlNodeType.EndElement)); - } - - private void CheckArray(Array array, int offset, int count) - { - if (array == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("array")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > array.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, array.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > array.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, array.Length - offset))); - } - - // bool - public virtual void WriteArray(string prefix, string localName, string namespaceUri, bool[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int16 - public virtual void WriteArray(string prefix, string localName, string namespaceUri, Int16[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int16[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int32 - public virtual void WriteArray(string prefix, string localName, string namespaceUri, Int32[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int32[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Int64 - public virtual void WriteArray(string prefix, string localName, string namespaceUri, Int64[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Int64[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // float - public virtual void WriteArray(string prefix, string localName, string namespaceUri, float[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // double - public virtual void WriteArray(string prefix, string localName, string namespaceUri, double[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // decimal - public virtual void WriteArray(string prefix, string localName, string namespaceUri, decimal[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // DateTime - public virtual void WriteArray(string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // Guid - public virtual void WriteArray(string prefix, string localName, string namespaceUri, Guid[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - // TimeSpan - public virtual void WriteArray(string prefix, string localName, string namespaceUri, TimeSpan[] array, int offset, int count) - { - CheckArray(array, offset, count); - for (int i = 0; i < count; i++) - { - WriteStartElement(prefix, localName, namespaceUri); - WriteValue(array[offset + i]); - WriteEndElement(); - } - } - - public virtual void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count) - { - WriteArray(prefix, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count); - } - - protected override void Dispose(bool disposing) - { - if (disposing && WriteState != WriteState.Closed) - { - Close(); - } - } - private class XmlWrappedWriter : XmlDictionaryWriter - { - private XmlWriter _writer; - private int _depth; - private int _prefix; - - public XmlWrappedWriter(XmlWriter writer) - { - _writer = writer; - _depth = 0; - } - - public override void Close() - { - _writer.Dispose(); - } - - public override void Flush() - { - _writer.Flush(); - } - - public override string LookupPrefix(string namespaceUri) - { - return _writer.LookupPrefix(namespaceUri); - } - - public override void WriteAttributes(XmlReader reader, bool defattr) - { - _writer.WriteAttributes(reader, defattr); - } - - public override void WriteBase64(byte[] buffer, int index, int count) - { - _writer.WriteBase64(buffer, index, count); - } - - public override void WriteBinHex(byte[] buffer, int index, int count) - { - _writer.WriteBinHex(buffer, index, count); - } - - public override void WriteCData(string text) - { - _writer.WriteCData(text); - } - - public override void WriteCharEntity(char ch) - { - _writer.WriteCharEntity(ch); - } - - public override void WriteChars(char[] buffer, int index, int count) - { - _writer.WriteChars(buffer, index, count); - } - - public override void WriteComment(string text) - { - _writer.WriteComment(text); - } - - public override void WriteDocType(string name, string pubid, string sysid, string subset) - { - _writer.WriteDocType(name, pubid, sysid, subset); - } - - public override void WriteEndAttribute() - { - _writer.WriteEndAttribute(); - } - - public override void WriteEndDocument() - { - _writer.WriteEndDocument(); - } - - public override void WriteEndElement() - { - _writer.WriteEndElement(); - _depth--; - } - - public override void WriteEntityRef(string name) - { - _writer.WriteEntityRef(name); - } - - public override void WriteFullEndElement() - { - _writer.WriteFullEndElement(); - } - - public override void WriteName(string name) - { - _writer.WriteName(name); - } - - public override void WriteNmToken(string name) - { - _writer.WriteNmToken(name); - } - - public override void WriteNode(XmlReader reader, bool defattr) - { - _writer.WriteNode(reader, defattr); - } - - public override void WriteProcessingInstruction(string name, string text) - { - _writer.WriteProcessingInstruction(name, text); - } - - public override void WriteQualifiedName(string localName, string namespaceUri) - { - _writer.WriteQualifiedName(localName, namespaceUri); - } - - public override void WriteRaw(char[] buffer, int index, int count) - { - _writer.WriteRaw(buffer, index, count); - } - - public override void WriteRaw(string data) - { - _writer.WriteRaw(data); - } - - public override void WriteStartAttribute(string prefix, string localName, string namespaceUri) - { - _writer.WriteStartAttribute(prefix, localName, namespaceUri); - _prefix++; - } - - public override void WriteStartDocument() - { - _writer.WriteStartDocument(); - } - - public override void WriteStartDocument(bool standalone) - { - _writer.WriteStartDocument(standalone); - } - - public override void WriteStartElement(string prefix, string localName, string namespaceUri) - { - _writer.WriteStartElement(prefix, localName, namespaceUri); - _depth++; - _prefix = 1; - } - - public override WriteState WriteState - { - get - { - return _writer.WriteState; - } - } - - public override void WriteString(string text) - { - _writer.WriteString(text); - } - - public override void WriteSurrogateCharEntity(char lowChar, char highChar) - { - _writer.WriteSurrogateCharEntity(lowChar, highChar); - } - - public override void WriteWhitespace(string whitespace) - { - _writer.WriteWhitespace(whitespace); - } - - public override void WriteValue(object value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(string value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(bool value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(DateTimeOffset value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(double value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(int value) - { - _writer.WriteValue(value); - } - - public override void WriteValue(long value) - { - _writer.WriteValue(value); - } - - public override void WriteXmlnsAttribute(string prefix, string namespaceUri) - { - if (namespaceUri == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("namespaceUri"); - if (prefix == null) - { - if (LookupPrefix(namespaceUri) != null) - return; - - if (namespaceUri.Length == 0) - { - prefix = string.Empty; - } - else - { - string depthStr = _depth.ToString(System.Globalization.NumberFormatInfo.InvariantInfo); - string prefixStr = _prefix.ToString(System.Globalization.NumberFormatInfo.InvariantInfo); - prefix = string.Concat("d", depthStr, "p", prefixStr); - } - } - WriteAttributeString("xmlns", prefix, null, namespaceUri); - } - - public override string XmlLang - { - get - { - return _writer.XmlLang; - } - } - - public override XmlSpace XmlSpace - { - get - { - return _writer.XmlSpace; - } - } - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlExceptionHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlExceptionHelper.cs index 7ff3488528d..9a3208da0a0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlExceptionHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlExceptionHelper.cs @@ -1,282 +1,27 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.Serialization; -using System.Globalization; - -namespace Microsoft.Xml +namespace System.Xml { using System; internal static class XmlExceptionHelper { - private static void ThrowXmlException(XmlDictionaryReader reader, string res) - { - ThrowXmlException(reader, res, null); - } - - static public void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1) - { - ThrowXmlException(reader, res, arg1, null); - } - - private static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2) - { - ThrowXmlException(reader, res, arg1, arg2, null); - } - - private static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2, string arg3) - { - string s = string.Format(res, arg1, arg2, arg3); - IXmlLineInfo lineInfo = reader as IXmlLineInfo; - if (lineInfo != null && lineInfo.HasLineInfo()) - { - s += " " + string.Format(SRSerialization.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); - } - - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); - } - - static public void ThrowXmlException(XmlDictionaryReader reader, XmlException exception) - { - string s = exception.Message; - IXmlLineInfo lineInfo = reader as IXmlLineInfo; - if (lineInfo != null && lineInfo.HasLineInfo()) - { - s += " " + string.Format(SRSerialization.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); - } - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); - } - - private static string GetName(string prefix, string localName) - { - if (prefix.Length == 0) - return localName; - else - return string.Concat(prefix, ":", localName); - } - - private static string GetWhatWasFound(XmlDictionaryReader reader) - { - if (reader.EOF) - return string.Format(SRSerialization.XmlFoundEndOfFile); - switch (reader.NodeType) - { - case XmlNodeType.Element: - return string.Format(SRSerialization.XmlFoundElement, GetName(reader.Prefix, reader.LocalName), reader.NamespaceURI); - case XmlNodeType.EndElement: - return string.Format(SRSerialization.XmlFoundEndElement, GetName(reader.Prefix, reader.LocalName), reader.NamespaceURI); - case XmlNodeType.Text: - case XmlNodeType.Whitespace: - case XmlNodeType.SignificantWhitespace: - return string.Format(SRSerialization.XmlFoundText, reader.Value); - case XmlNodeType.Comment: - return string.Format(SRSerialization.XmlFoundComment, reader.Value); - case XmlNodeType.CDATA: - return string.Format(SRSerialization.XmlFoundCData, reader.Value); - } - return string.Format(SRSerialization.XmlFoundNodeType, reader.NodeType); - } - - static public void ThrowStartElementExpected(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlStartElementExpected, GetWhatWasFound(reader)); - } - - static public void ThrowStartElementExpected(XmlDictionaryReader reader, string name) - { - ThrowXmlException(reader, SRSerialization.XmlStartElementNameExpected, name, GetWhatWasFound(reader)); - } - - static public void ThrowStartElementExpected(XmlDictionaryReader reader, string localName, string ns) - { - ThrowXmlException(reader, SRSerialization.XmlStartElementLocalNameNsExpected, localName, ns, GetWhatWasFound(reader)); - } - - static public void ThrowStartElementExpected(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns) - { - ThrowStartElementExpected(reader, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(ns)); - } - - static public void ThrowFullStartElementExpected(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlFullStartElementExpected, GetWhatWasFound(reader)); - } - - static public void ThrowFullStartElementExpected(XmlDictionaryReader reader, string name) - { - ThrowXmlException(reader, SRSerialization.XmlFullStartElementNameExpected, name, GetWhatWasFound(reader)); - } - - static public void ThrowFullStartElementExpected(XmlDictionaryReader reader, string localName, string ns) - { - ThrowXmlException(reader, SRSerialization.XmlFullStartElementLocalNameNsExpected, localName, ns, GetWhatWasFound(reader)); - } - - static public void ThrowFullStartElementExpected(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns) - { - ThrowFullStartElementExpected(reader, XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(ns)); - } - - static public void ThrowEndElementExpected(XmlDictionaryReader reader, string localName, string ns) - { - ThrowXmlException(reader, SRSerialization.XmlEndElementExpected, localName, ns, GetWhatWasFound(reader)); - } - - static public void ThrowMaxArrayLengthExceeded(XmlDictionaryReader reader, int maxArrayLength) - { - ThrowXmlException(reader, SRSerialization.XmlMaxArrayLengthExceeded, maxArrayLength.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowMaxBytesPerReadExceeded(XmlDictionaryReader reader, int maxBytesPerRead) - { - ThrowXmlException(reader, SRSerialization.XmlMaxBytesPerReadExceeded, maxBytesPerRead.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowMaxNameTableCharCountExceeded(XmlDictionaryReader reader, int maxNameTableCharCount) - { - ThrowXmlException(reader, SRSerialization.XmlMaxNameTableCharCountExceeded, maxNameTableCharCount.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowMaxDepthExceeded(XmlDictionaryReader reader, int maxDepth) - { - ThrowXmlException(reader, SRSerialization.XmlMaxDepthExceeded, maxDepth.ToString()); - } - - static public void ThrowMaxStringContentLengthExceeded(XmlDictionaryReader reader, int maxStringContentLength) - { - ThrowXmlException(reader, SRSerialization.XmlMaxStringContentLengthExceeded, maxStringContentLength.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowBase64DataExpected(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlBase64DataExpected, GetWhatWasFound(reader)); - } - - static public void ThrowUndefinedPrefix(XmlDictionaryReader reader, string prefix) - { - ThrowXmlException(reader, SRSerialization.XmlUndefinedPrefix, prefix); - } - - static public void ThrowProcessingInstructionNotSupported(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlProcessingInstructionNotSupported); - } - - static public void ThrowInvalidXml(XmlDictionaryReader reader, byte b) - { - ThrowXmlException(reader, SRSerialization.XmlInvalidXmlByte, b.ToString("X2", CultureInfo.InvariantCulture)); - } - - static public void ThrowUnexpectedEndOfFile(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlUnexpectedEndOfFile, ((XmlBaseReader)reader).GetOpenElements()); - } - - static public void ThrowUnexpectedEndElement(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlUnexpectedEndElement); - } - - static public void ThrowTokenExpected(XmlDictionaryReader reader, string expected, char found) - { - ThrowXmlException(reader, SRSerialization.XmlTokenExpected, expected, found.ToString()); - } - - static public void ThrowTokenExpected(XmlDictionaryReader reader, string expected, string found) - { - ThrowXmlException(reader, SRSerialization.XmlTokenExpected, expected, found); - } - - static public void ThrowInvalidCharRef(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlInvalidCharRef); - } - - static public void ThrowTagMismatch(XmlDictionaryReader reader, string expectedPrefix, string expectedLocalName, string foundPrefix, string foundLocalName) - { - ThrowXmlException(reader, SRSerialization.XmlTagMismatch, GetName(expectedPrefix, expectedLocalName), GetName(foundPrefix, foundLocalName)); - } - - static public void ThrowDuplicateXmlnsAttribute(XmlDictionaryReader reader, string localName, string ns) - { - string name; - if (localName.Length == 0) - name = "xmlns"; - else - name = "xmlns:" + localName; - ThrowXmlException(reader, SRSerialization.XmlDuplicateAttribute, name, name, ns); - } - - static public void ThrowDuplicateAttribute(XmlDictionaryReader reader, string prefix1, string prefix2, string localName, string ns) - { - ThrowXmlException(reader, SRSerialization.XmlDuplicateAttribute, GetName(prefix1, localName), GetName(prefix2, localName), ns); - } - - static public void ThrowInvalidBinaryFormat(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlInvalidFormat); - } - - static public void ThrowInvalidRootData(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlInvalidRootData); - } - - static public void ThrowMultipleRootElements(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlMultipleRootElements); - } - - static public void ThrowDeclarationNotFirst(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlDeclNotFirst); - } - - static public void ThrowConversionOverflow(XmlDictionaryReader reader, string value, string type) - { - ThrowXmlException(reader, SRSerialization.XmlConversionOverflow, value, type); - } - - static public void ThrowXmlDictionaryStringIDOutOfRange(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlDictionaryStringIDRange, XmlDictionaryString.MinKey.ToString(NumberFormatInfo.CurrentInfo), XmlDictionaryString.MaxKey.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowXmlDictionaryStringIDUndefinedStatic(XmlDictionaryReader reader, int key) - { - ThrowXmlException(reader, SRSerialization.XmlDictionaryStringIDUndefinedStatic, key.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowXmlDictionaryStringIDUndefinedSession(XmlDictionaryReader reader, int key) - { - ThrowXmlException(reader, SRSerialization.XmlDictionaryStringIDUndefinedSession, key.ToString(NumberFormatInfo.CurrentInfo)); - } - - static public void ThrowEmptyNamespace(XmlDictionaryReader reader) - { - ThrowXmlException(reader, SRSerialization.XmlEmptyNamespaceRequiresNullPrefix); - } - - static public XmlException CreateConversionException(string type, Exception exception) - { - return new XmlException(string.Format(SRSerialization.XmlInvalidConversionWithoutValue, type), exception); - } - - static public XmlException CreateConversionException(string value, string type, Exception exception) - { - return new XmlException(string.Format(SRSerialization.XmlInvalidConversion, value, type), exception); - } - - static public XmlException CreateEncodingException(byte[] buffer, int offset, int count, Exception exception) - { - return CreateEncodingException(new System.Text.UTF8Encoding(false, false).GetString(buffer, offset, count), exception); - } - - static public XmlException CreateEncodingException(string value, Exception exception) - { - return new XmlException(string.Format(SRSerialization.XmlInvalidUTF8Bytes, value), exception); - } + public static Exception CreateConversionException(string value, string type, Exception exception) + { + return new XmlException($"The value '{value}' cannot be parsed as the type '{type}'.", exception); + } + + public static ArgumentException CreateConversionException(string value, string type) + { + return new ArgumentException($"The value '{value}' cannot be parsed as the type '{type}'."); + } + + public static Exception CreateEncodingException(byte[] buffer, int offset, int count, Exception exception) + { + return new XmlException("Encoding exception", exception); + } + + public static Exception CreateEncodingException(string value, Exception exception) + { + return new XmlException("Encoding exception: " + value, exception); + } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlNodeWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlNodeWriter.cs index a269b0ba50a..8cbdcdb3c84 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlNodeWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlNodeWriter.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { internal abstract class XmlNodeWriter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlStreamNodeWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlStreamNodeWriter.cs index 75ebeac0300..04bcef8fe8c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlStreamNodeWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlStreamNodeWriter.cs @@ -8,7 +8,7 @@ using System.Security; using System.Threading.Tasks; -namespace Microsoft.Xml +namespace System.Xml { using System; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextReader.cs deleted file mode 100644 index e4e9e8f7d19..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextReader.cs +++ /dev/null @@ -1,1463 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//------------------------------------------------------------ -// Parser -// PERF: Optimize double, decimal? They get converted to strings in lots of cases -// PERF: Cleanup CharType. Don't generate tables at runtime. Use const tables. - -using System; -using System.IO; -using System.Runtime; -using Microsoft.Xml; -using System.Collections; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Runtime.Serialization; // For SR -using System.Security; -using System.Text; -using System.Globalization; - - -namespace Microsoft.Xml -{ - public interface IXmlTextReaderInitializer - { - void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose); - void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose); - } - - internal class XmlUTF8TextReader : XmlBaseReader, IXmlLineInfo, IXmlTextReaderInitializer - { - private const int MaxTextChunk = 2048; - - private PrefixHandle _prefix; - private StringHandle _localName; - private int[] _rowOffsets; - private OnXmlDictionaryReaderClose _onClose; - private bool _buffered; - private int _maxBytesPerRead; - private static byte[] s_charType = new byte[256] - { - /* 0 (.) */ - CharType.None, - /* 1 (.) */ - CharType.None, - /* 2 (.) */ - CharType.None, - /* 3 (.) */ - CharType.None, - /* 4 (.) */ - CharType.None, - /* 5 (.) */ - CharType.None, - /* 6 (.) */ - CharType.None, - /* 7 (.) */ - CharType.None, - /* 8 (.) */ - CharType.None, - /* 9 (.) */ - CharType.None|CharType.Comment|CharType.Comment|CharType.Whitespace|CharType.Text|CharType.SpecialWhitespace, - /* A (.) */ - CharType.None|CharType.Comment|CharType.Comment|CharType.Whitespace|CharType.Text|CharType.SpecialWhitespace, - /* B (.) */ - CharType.None, - /* C (.) */ - CharType.None, - /* D (.) */ - CharType.None|CharType.Comment|CharType.Comment|CharType.Whitespace, - /* E (.) */ - CharType.None, - /* F (.) */ - CharType.None, - /* 10 (.) */ - CharType.None, - /* 11 (.) */ - CharType.None, - /* 12 (.) */ - CharType.None, - /* 13 (.) */ - CharType.None, - /* 14 (.) */ - CharType.None, - /* 15 (.) */ - CharType.None, - /* 16 (.) */ - CharType.None, - /* 17 (.) */ - CharType.None, - /* 18 (.) */ - CharType.None, - /* 19 (.) */ - CharType.None, - /* 1A (.) */ - CharType.None, - /* 1B (.) */ - CharType.None, - /* 1C (.) */ - CharType.None, - /* 1D (.) */ - CharType.None, - /* 1E (.) */ - CharType.None, - /* 1F (.) */ - CharType.None, - /* 20 ( ) */ - CharType.None|CharType.Comment|CharType.Whitespace|CharType.Text|CharType.AttributeText|CharType.SpecialWhitespace, - /* 21 (!) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 22 (") */ - CharType.None|CharType.Comment|CharType.Text, - /* 23 (#) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 24 ($) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 25 (%) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 26 (&) */ - CharType.None|CharType.Comment, - /* 27 (') */ - CharType.None|CharType.Comment|CharType.Text, - /* 28 (() */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 29 ()) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 2A (*) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 2B (+) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 2C (,) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 2D (-) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 2E (.) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 2F (/) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 30 (0) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 31 (1) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 32 (2) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 33 (3) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 34 (4) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 35 (5) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 36 (6) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 37 (7) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 38 (8) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 39 (9) */ - CharType.None|CharType.Comment|CharType.Name|CharType.Text|CharType.AttributeText, - /* 3A (:) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 3B (;) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 3C (<) */ - CharType.None|CharType.Comment, - /* 3D (=) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 3E (>) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 3F (?) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 40 (@) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 41 (A) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 42 (B) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 43 (C) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 44 (D) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 45 (E) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 46 (F) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 47 (G) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 48 (H) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 49 (I) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4A (J) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4B (K) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4C (L) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4D (M) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4E (N) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 4F (O) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 50 (P) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 51 (Q) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 52 (R) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 53 (S) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 54 (T) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 55 (U) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 56 (V) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 57 (W) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 58 (X) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 59 (Y) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 5A (Z) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 5B ([) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 5C (\) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 5D (]) */ - CharType.None|CharType.Comment|CharType.AttributeText, - /* 5E (^) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 5F (_) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 60 (`) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 61 (a) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 62 (b) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 63 (c) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 64 (d) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 65 (e) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 66 (f) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 67 (g) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 68 (h) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 69 (i) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6A (j) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6B (k) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6C (l) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6D (m) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6E (n) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 6F (o) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 70 (p) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 71 (q) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 72 (r) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 73 (s) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 74 (t) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 75 (u) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 76 (v) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 77 (w) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 78 (x) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 79 (y) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 7A (z) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 7B ({) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 7C (|) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 7D (}) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 7E (~) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 7F (.) */ - CharType.None|CharType.Comment|CharType.Text|CharType.AttributeText, - /* 80 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 81 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 82 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 83 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 84 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 85 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 86 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 87 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 88 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 89 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8A (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8B (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8C (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8D (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8E (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 8F (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 90 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 91 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 92 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 93 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 94 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 95 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 96 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 97 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 98 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 99 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9A (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9B (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9C (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9D (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9E (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* 9F (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A0 (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A1 (¡) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A2 (¢) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A3 (£) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A4 (¤) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A5 (¥) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A6 (¦) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A7 (§) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A8 (¨) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* A9 (©) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AA (ª) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AB («) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AC (¬) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AD (.) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AE (®) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* AF (¯) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B0 (°) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B1 (±) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B2 (²) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B3 (³) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B4 (´) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B5 (µ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B6 (¶) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B7 (·) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B8 (¸) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* B9 (¹) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BA (º) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BB (») */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BC (¼) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BD (½) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BE (¾) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* BF (¿) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C0 (À) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C1 (Á) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C2 (Â) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C3 (Ã) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C4 (Ä) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C5 (Å) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C6 (Æ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C7 (Ç) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C8 (È) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* C9 (É) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CA (Ê) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CB (Ë) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CC (Ì) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CD (Í) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CE (Î) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* CF (Ï) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D0 (Ð) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D1 (Ñ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D2 (Ò) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D3 (Ó) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D4 (Ô) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D5 (Õ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D6 (Ö) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D7 (×) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D8 (Ø) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* D9 (Ù) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DA (Ú) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DB (Û) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DC (Ü) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DD (Ý) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DE (Þ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* DF (ß) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E0 (à) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E1 (á) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E2 (â) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E3 (ã) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E4 (ä) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E5 (å) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E6 (æ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E7 (ç) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E8 (è) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* E9 (é) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* EA (ê) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* EB (ë) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* EC (ì) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* ED (í) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* EE (î) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* EF (ï) */ - CharType.None|CharType.FirstName|CharType.Name, - /* F0 (ð) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F1 (ñ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F2 (ò) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F3 (ó) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F4 (ô) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F5 (õ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F6 (ö) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F7 (÷) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F8 (ø) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* F9 (ù) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FA (ú) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FB (û) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FC (ü) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FD (ý) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FE (þ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - /* FF (ÿ) */ - CharType.None|CharType.Comment|CharType.FirstName|CharType.Name|CharType.Text|CharType.AttributeText, - }; - - public XmlUTF8TextReader() - { - _prefix = new PrefixHandle(BufferReader); - _localName = new StringHandle(BufferReader); - } - - public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) - { - if (buffer == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); - if (offset < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (offset > buffer.Length) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", string.Format(SRSerialization.OffsetExceedsBufferSize, buffer.Length))); - if (count < 0) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.ValueMustBeNonNegative))); - if (count > buffer.Length - offset) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", string.Format(SRSerialization.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); - MoveToInitial(quotas, onClose); - ArraySegment seg = EncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding); - BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null); - _buffered = true; - } - - public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) - { - if (stream == null) - throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream"); - MoveToInitial(quotas, onClose); - stream = new EncodingStreamWrapper(stream, encoding); - BufferReader.SetBuffer(stream, null, null); - _buffered = false; - } - - private void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) - { - MoveToInitial(quotas); - _maxBytesPerRead = quotas.MaxBytesPerRead; - _onClose = onClose; - } - - public override void Close() - { - _rowOffsets = null; - base.Close(); - OnXmlDictionaryReaderClose onClose = _onClose; - _onClose = null; - if (onClose != null) - { - try - { - onClose(this); - } - catch (Exception e) - { - if (DiagnosticUtility.IsFatal(e)) throw; - - throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); - } - } - } - - private void SkipWhitespace() - { - while (!BufferReader.EndOfFile && (s_charType[BufferReader.GetByte()] & CharType.Whitespace) != 0) - BufferReader.SkipByte(); - } - - private void ReadDeclaration() - { - if (!_buffered) - BufferElement(); - int offset; - byte[] buffer = BufferReader.GetBuffer(5, out offset); - if (buffer[offset + 0] != (byte)'?' || - buffer[offset + 1] != (byte)'x' || - buffer[offset + 2] != (byte)'m' || - buffer[offset + 3] != (byte)'l' || - (s_charType[buffer[offset + 4]] & CharType.Whitespace) == 0) - { - XmlExceptionHelper.ThrowProcessingInstructionNotSupported(this); - } - // If anything came before the "" it's an error. - if (this.Node.ReadState != ReadState.Initial) - { - XmlExceptionHelper.ThrowDeclarationNotFirst(this); - } - BufferReader.Advance(5); - - int localNameOffset = offset + 1; - int localNameLength = 3; - - int valueOffset = BufferReader.Offset; - SkipWhitespace(); - ReadAttributes(); - int valueLength = BufferReader.Offset - valueOffset; - - // Backoff the spaces - while (valueLength > 0) - { - byte ch = BufferReader.GetByte(valueOffset + valueLength - 1); - if ((s_charType[ch] & CharType.Whitespace) == 0) - break; - valueLength--; - } - - buffer = BufferReader.GetBuffer(2, out offset); - if (buffer[offset + 0] != (byte)'?' || - buffer[offset + 1] != (byte)'>') - { - XmlExceptionHelper.ThrowTokenExpected(this, "?>", Encoding.UTF8.GetString(buffer, offset, 2)); - } - BufferReader.Advance(2); - XmlDeclarationNode declarationNode = MoveToDeclaration(); - declarationNode.LocalName.SetValue(localNameOffset, localNameLength); - declarationNode.Value.SetValue(ValueHandleType.UTF8, valueOffset, valueLength); - } - - private void VerifyNCName(string s) - { - try - { - XmlConvert.VerifyNCName(s); - } - catch (XmlException exception) - { - XmlExceptionHelper.ThrowXmlException(this, exception); - } - } - - private void ReadQualifiedName(PrefixHandle prefix, StringHandle localName) - { - int offset; - int offsetMax; - byte[] buffer = BufferReader.GetBuffer(out offset, out offsetMax); - - int ch = 0; - int anyChar = 0; - int prefixChar = 0; - int prefixOffset = offset; - if (offset < offsetMax) - { - ch = buffer[offset]; - prefixChar = ch; - if ((s_charType[ch] & CharType.FirstName) == 0) - anyChar |= 0x80; - anyChar |= ch; - offset++; - while (offset < offsetMax) - { - ch = buffer[offset]; - if ((s_charType[ch] & CharType.Name) == 0) - break; - anyChar |= ch; - offset++; - } - } - else - { - anyChar |= 0x80; - ch = 0; - } - if (ch == ':') - { - int prefixLength = offset - prefixOffset; - if (prefixLength == 1 && prefixChar >= 'a' && prefixChar <= 'z') - prefix.SetValue(PrefixHandle.GetAlphaPrefix(prefixChar - 'a')); - else - prefix.SetValue(prefixOffset, prefixLength); - - offset++; - int localNameOffset = offset; - if (offset < offsetMax) - { - ch = buffer[offset]; - if ((s_charType[ch] & CharType.FirstName) == 0) - anyChar |= 0x80; - anyChar |= ch; - offset++; - while (offset < offsetMax) - { - ch = buffer[offset]; - if ((s_charType[ch] & CharType.Name) == 0) - break; - anyChar |= ch; - offset++; - } - } - else - { - anyChar |= 0x80; - ch = 0; - } - localName.SetValue(localNameOffset, offset - localNameOffset); - if (anyChar >= 0x80) - { - VerifyNCName(prefix.GetString()); - VerifyNCName(localName.GetString()); - } - } - else - { - prefix.SetValue(PrefixHandleType.Empty); - localName.SetValue(prefixOffset, offset - prefixOffset); - if (anyChar >= 0x80) - { - VerifyNCName(localName.GetString()); - } - } - BufferReader.Advance(offset - prefixOffset); - } - - private int ReadAttributeText(byte[] buffer, int offset, int offsetMax) - { - byte[] charType = XmlUTF8TextReader.s_charType; - int textOffset = offset; - while (offset < offsetMax && (charType[buffer[offset]] & CharType.AttributeText) != 0) - offset++; - return offset - textOffset; - } - - private void ReadAttributes() - { - int startOffset = 0; - if (_buffered) - startOffset = BufferReader.Offset; - - while (true) - { - byte ch; - ReadQualifiedName(_prefix, _localName); - if (BufferReader.GetByte() != '=') - { - SkipWhitespace(); - if (BufferReader.GetByte() != '=') - XmlExceptionHelper.ThrowTokenExpected(this, "=", (char)BufferReader.GetByte()); - } - BufferReader.SkipByte(); - byte quoteChar = BufferReader.GetByte(); - if (quoteChar != '"' && quoteChar != '\'') - { - SkipWhitespace(); - quoteChar = BufferReader.GetByte(); - if (quoteChar != '"' && quoteChar != '\'') - XmlExceptionHelper.ThrowTokenExpected(this, "\"", (char)BufferReader.GetByte()); - } - BufferReader.SkipByte(); - bool escaped = false; - int valueOffset = BufferReader.Offset; - while (true) - { - int offset, offsetMax; - byte[] buffer = BufferReader.GetBuffer(out offset, out offsetMax); - int length = ReadAttributeText(buffer, offset, offsetMax); - BufferReader.Advance(length); - ch = BufferReader.GetByte(); - if (ch == quoteChar) - break; - if (ch == '&') - { - ReadCharRef(); - escaped = true; - } - else if (ch == '\'' || ch == '"') - { - BufferReader.SkipByte(); - } - else if (ch == '\n' || ch == '\r' || ch == '\t') - { - BufferReader.SkipByte(); - escaped = true; - } - else if (ch == 0xEF) - { - ReadNonFFFE(); - } - else - { - XmlExceptionHelper.ThrowTokenExpected(this, ((char)quoteChar).ToString(), (char)ch); - } - } - int valueLength = BufferReader.Offset - valueOffset; - - XmlAttributeNode attributeNode; - if (_prefix.IsXmlns) - { - Namespace ns = AddNamespace(); - _localName.ToPrefixHandle(ns.Prefix); - ns.Uri.SetValue(valueOffset, valueLength, escaped); - attributeNode = AddXmlnsAttribute(ns); - } - else if (_prefix.IsEmpty && _localName.IsXmlns) - { - Namespace ns = AddNamespace(); - ns.Prefix.SetValue(PrefixHandleType.Empty); - ns.Uri.SetValue(valueOffset, valueLength, escaped); - attributeNode = AddXmlnsAttribute(ns); - } - else if (_prefix.IsXml) - { - attributeNode = AddXmlAttribute(); - attributeNode.Prefix.SetValue(_prefix); - attributeNode.LocalName.SetValue(_localName); - attributeNode.Value.SetValue((escaped ? ValueHandleType.EscapedUTF8 : ValueHandleType.UTF8), valueOffset, valueLength); - FixXmlAttribute(attributeNode); - } - else - { - attributeNode = AddAttribute(); - attributeNode.Prefix.SetValue(_prefix); - attributeNode.LocalName.SetValue(_localName); - attributeNode.Value.SetValue((escaped ? ValueHandleType.EscapedUTF8 : ValueHandleType.UTF8), valueOffset, valueLength); - } - - attributeNode.QuoteChar = (char)quoteChar; - BufferReader.SkipByte(); - - ch = BufferReader.GetByte(); - - bool space = false; - while ((s_charType[ch] & CharType.Whitespace) != 0) - { - space = true; - BufferReader.SkipByte(); - ch = BufferReader.GetByte(); - } - - if (ch == '>' || ch == '/' || ch == '?') - break; - - if (!space) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlSpaceBetweenAttributes))); - } - - if (_buffered && (BufferReader.Offset - startOffset) > _maxBytesPerRead) - XmlExceptionHelper.ThrowMaxBytesPerReadExceeded(this, _maxBytesPerRead); - - ProcessAttributes(); - } - - // NOTE: Call only if 0xEF has been seen in the stream AND there are three valid bytes to check (buffer[offset], buffer[offset + 1], buffer[offset + 2]). - // 0xFFFE and 0xFFFF are not valid characters per Unicode specification. The first byte in the UTF8 representation is 0xEF. - private bool IsNextCharacterNonFFFE(byte[] buffer, int offset) - { - Fx.Assert(buffer[offset] == 0xEF, "buffer[offset] MUST be 0xEF."); - - if (buffer[offset + 1] == 0xBF && (buffer[offset + 2] == 0xBE || buffer[offset + 2] == 0xBF)) - { - // 0xFFFE : 0xEF 0xBF 0xBE - // 0xFFFF : 0xEF 0xBF 0xBF - // we know that buffer[offset] is already 0xEF, don't bother checking it. - return false; - } - - // no bad characters - return true; - } - - private void ReadNonFFFE() - { - int off; - byte[] buff = BufferReader.GetBuffer(3, out off); - if (buff[off + 1] == 0xBF && (buff[off + 2] == 0xBE || buff[off + 2] == 0xBF)) - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlInvalidFFFE))); - } - BufferReader.Advance(3); - } - - private void BufferElement() - { - int elementOffset = BufferReader.Offset; - const int byteCount = 128; - bool done = false; - byte quoteChar = 0; - while (!done) - { - int offset; - int offsetMax; - byte[] buffer = BufferReader.GetBuffer(byteCount, out offset, out offsetMax); - if (offset + byteCount != offsetMax) - break; - for (int i = offset; i < offsetMax && !done; i++) - { - byte b = buffer[i]; - if (quoteChar == 0) - { - if (b == '\'' || b == '"') - quoteChar = b; - if (b == '>') - done = true; - } - else - { - if (b == quoteChar) - { - quoteChar = 0; - } - } - } - BufferReader.Advance(byteCount); - } - BufferReader.Offset = elementOffset; - } - - private new void ReadStartElement() - { - if (!_buffered) - BufferElement(); - XmlElementNode elementNode = EnterScope(); - elementNode.NameOffset = BufferReader.Offset; - ReadQualifiedName(elementNode.Prefix, elementNode.LocalName); - elementNode.NameLength = BufferReader.Offset - elementNode.NameOffset; - byte ch = BufferReader.GetByte(); - while ((s_charType[ch] & CharType.Whitespace) != 0) - { - BufferReader.SkipByte(); - ch = BufferReader.GetByte(); - } - if (ch != '>' && ch != '/') - { - ReadAttributes(); - ch = BufferReader.GetByte(); - } - elementNode.Namespace = LookupNamespace(elementNode.Prefix); - bool isEmptyElement = false; - if (ch == '/') - { - isEmptyElement = true; - BufferReader.SkipByte(); - } - elementNode.IsEmptyElement = isEmptyElement; - elementNode.ExitScope = isEmptyElement; - if (BufferReader.GetByte() != '>') - XmlExceptionHelper.ThrowTokenExpected(this, ">", (char)BufferReader.GetByte()); - BufferReader.SkipByte(); - elementNode.BufferOffset = BufferReader.Offset; - } - - private new void ReadEndElement() - { - BufferReader.SkipByte(); - XmlElementNode elementNode = this.ElementNode; - int nameOffset = elementNode.NameOffset; - int nameLength = elementNode.NameLength; - int offset; - byte[] buffer = BufferReader.GetBuffer(nameLength, out offset); - for (int i = 0; i < nameLength; i++) - { - if (buffer[offset + i] != buffer[nameOffset + i]) - { - ReadQualifiedName(_prefix, _localName); - XmlExceptionHelper.ThrowTagMismatch(this, elementNode.Prefix.GetString(), elementNode.LocalName.GetString(), _prefix.GetString(), _localName.GetString()); - } - } - BufferReader.Advance(nameLength); - if (BufferReader.GetByte() != '>') - { - SkipWhitespace(); - if (BufferReader.GetByte() != '>') - XmlExceptionHelper.ThrowTokenExpected(this, ">", (char)BufferReader.GetByte()); - } - BufferReader.SkipByte(); - MoveToEndElement(); - } - - private void ReadComment() - { - BufferReader.SkipByte(); - if (BufferReader.GetByte() != '-') - XmlExceptionHelper.ThrowTokenExpected(this, "--", (char)BufferReader.GetByte()); - BufferReader.SkipByte(); - int commentOffset = BufferReader.Offset; - while (true) - { - while (true) - { - byte b = BufferReader.GetByte(); - if (b == '-') - break; - if ((s_charType[b] & CharType.Comment) == 0) - { - if (b == 0xEF) - ReadNonFFFE(); - else - XmlExceptionHelper.ThrowInvalidXml(this, b); - } - else - { - BufferReader.SkipByte(); - } - } - - int offset; - byte[] buffer = BufferReader.GetBuffer(3, out offset); - if (buffer[offset + 0] == (byte)'-' && - buffer[offset + 1] == (byte)'-') - { - if (buffer[offset + 2] == (byte)'>') - break; - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlInvalidCommentChars))); - } - BufferReader.SkipByte(); - } - int commentLength = BufferReader.Offset - commentOffset; - MoveToComment().Value.SetValue(ValueHandleType.UTF8, commentOffset, commentLength); - BufferReader.Advance(3); - } - - private void ReadCData() - { - int offset; - byte[] buffer = BufferReader.GetBuffer(7, out offset); - if (buffer[offset + 0] != (byte)'[' || - buffer[offset + 1] != (byte)'C' || - buffer[offset + 2] != (byte)'D' || - buffer[offset + 3] != (byte)'A' || - buffer[offset + 4] != (byte)'T' || - buffer[offset + 5] != (byte)'A' || - buffer[offset + 6] != (byte)'[') - { - XmlExceptionHelper.ThrowTokenExpected(this, "[CDATA[", Encoding.UTF8.GetString(buffer, offset, 7)); - } - BufferReader.Advance(7); - int cdataOffset = BufferReader.Offset; - while (true) - { - byte b; - while (true) - { - b = BufferReader.GetByte(); - if (b == ']') - break; - - if (b == 0xEF) - ReadNonFFFE(); - else - BufferReader.SkipByte(); - } - buffer = BufferReader.GetBuffer(3, out offset); - if (buffer[offset + 0] == (byte)']' && - buffer[offset + 1] == (byte)']' && - buffer[offset + 2] == (byte)'>') - break; - BufferReader.SkipByte(); - } - int cdataLength = BufferReader.Offset - cdataOffset; - MoveToCData().Value.SetValue(ValueHandleType.UTF8, cdataOffset, cdataLength); - BufferReader.Advance(3); - } - - private int ReadCharRef() - { - DiagnosticUtility.DebugAssert(BufferReader.GetByte() == '&', ""); - int charEntityOffset = BufferReader.Offset; - BufferReader.SkipByte(); - while (BufferReader.GetByte() != ';') - BufferReader.SkipByte(); - BufferReader.SkipByte(); - int charEntityLength = BufferReader.Offset - charEntityOffset; - BufferReader.Offset = charEntityOffset; - int ch = BufferReader.GetCharEntity(charEntityOffset, charEntityLength); - BufferReader.Advance(charEntityLength); - return ch; - } - - - private void ReadWhitespace() - { - byte[] buffer; - int offset; - int offsetMax; - int length; - - if (_buffered) - { - buffer = BufferReader.GetBuffer(out offset, out offsetMax); - length = ReadWhitespace(buffer, offset, offsetMax); - } - else - { - buffer = BufferReader.GetBuffer(MaxTextChunk, out offset, out offsetMax); - length = ReadWhitespace(buffer, offset, offsetMax); - length = BreakText(buffer, offset, length); - } - BufferReader.Advance(length); - - MoveToWhitespaceText().Value.SetValue(ValueHandleType.UTF8, offset, length); - } - - private int ReadWhitespace(byte[] buffer, int offset, int offsetMax) - { - byte[] charType = XmlUTF8TextReader.s_charType; - int wsOffset = offset; - while (offset < offsetMax && (charType[buffer[offset]] & CharType.SpecialWhitespace) != 0) - offset++; - return offset - wsOffset; - } - - private int ReadText(byte[] buffer, int offset, int offsetMax) - { - byte[] charType = XmlUTF8TextReader.s_charType; - int textOffset = offset; - while (offset < offsetMax && (charType[buffer[offset]] & CharType.Text) != 0) - offset++; - return offset - textOffset; - } - - // Read Unicode codepoints 0xFvvv - private int ReadTextAndWatchForInvalidCharacters(byte[] buffer, int offset, int offsetMax) - { - byte[] charType = XmlUTF8TextReader.s_charType; - int textOffset = offset; - - while (offset < offsetMax && ((charType[buffer[offset]] & CharType.Text) != 0 || buffer[offset] == 0xEF)) - { - if (buffer[offset] != 0xEF) - { - offset++; - } - else - { - // Ensure that we have three bytes (buffer[offset], buffer[offset + 1], buffer[offset + 2]) - // available for IsNextCharacterNonFFFE to check. - if (offset + 2 < offsetMax) - { - if (IsNextCharacterNonFFFE(buffer, offset)) - { - // if first byte is 0xEF, UTF8 mandates a 3-byte character representation of this Unicode code point - offset += 3; - } - else - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlInvalidFFFE))); - } - } - else - { - if (BufferReader.Offset < offset) - { - // We have read some characters already - // Let the outer ReadText advance the bufferReader and return text node to caller - break; - } - else - { - // Get enough bytes for us to process next character, then go back to top of while loop - int dummy; - BufferReader.GetBuffer(3, out dummy); - } - } - } - } - return offset - textOffset; - } - - // bytes bits UTF-8 representation - // ----- ---- ----------------------------------- - // 1 7 0vvvvvvv - // 2 11 110vvvvv 10vvvvvv - // 3 16 1110vvvv 10vvvvvv 10vvvvvv - // 4 21 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv - // ----- ---- ----------------------------------- - - private int BreakText(byte[] buffer, int offset, int length) - { - // See if we might be breaking a utf8 sequence - if (length > 0 && (buffer[offset + length - 1] & 0x80) == 0x80) - { - // Find the lead char of the utf8 sequence (0x11xxxxxx) - int originalLength = length; - do - { - length--; - } - while (length > 0 && (buffer[offset + length] & 0xC0) != 0xC0); - // Couldn't find the lead char - if (length == 0) - return originalLength; // Invalid utf8 sequence - can't break - // Count how many bytes follow the lead char - byte b = (byte)(buffer[offset + length] << 2); - int byteCount = 2; - while ((b & 0x80) == 0x80) - { - b = (byte)(b << 1); - byteCount++; - // There shouldn't be more than 3 bytes following the lead char - if (byteCount > 4) - return originalLength; // Invalid utf8 sequence - can't break - } - if (length + byteCount == originalLength) - return originalLength; // sequence fits exactly - if (length == 0) - return originalLength; // Quota too small to read a char - } - return length; - } - - private void ReadText(bool hasLeadingByteOf0xEF) - { - byte[] buffer; - int offset; - int offsetMax; - int length; - - if (_buffered) - { - buffer = BufferReader.GetBuffer(out offset, out offsetMax); - if (hasLeadingByteOf0xEF) - { - length = ReadTextAndWatchForInvalidCharacters(buffer, offset, offsetMax); - } - else - { - length = ReadText(buffer, offset, offsetMax); - } - } - else - { - buffer = BufferReader.GetBuffer(MaxTextChunk, out offset, out offsetMax); - if (hasLeadingByteOf0xEF) - { - length = ReadTextAndWatchForInvalidCharacters(buffer, offset, offsetMax); - } - else - { - length = ReadText(buffer, offset, offsetMax); - } - length = BreakText(buffer, offset, length); - } - BufferReader.Advance(length); - - if (offset < offsetMax - 1 - length && (buffer[offset + length] == (byte)'<' && buffer[offset + length + 1] != (byte)'!')) - { - MoveToAtomicText().Value.SetValue(ValueHandleType.UTF8, offset, length); - } - else - { - MoveToComplexText().Value.SetValue(ValueHandleType.UTF8, offset, length); - } - } - - private void ReadEscapedText() - { - int ch = ReadCharRef(); - if (ch < 256 && (s_charType[ch] & CharType.Whitespace) != 0) - MoveToWhitespaceText().Value.SetCharValue(ch); - else - MoveToComplexText().Value.SetCharValue(ch); - } - - public override bool Read() - { - if (this.Node.ReadState == ReadState.Closed) - return false; - - if (this.Node.CanMoveToElement) - { - // If we're positioned on an attribute or attribute text on an empty element, we need to move back - // to the element in order to get the correct setting of ExitScope - MoveToElement(); - } - - if (this.Node.ExitScope) - { - ExitScope(); - } - if (!_buffered) - BufferReader.SetWindow(ElementNode.BufferOffset, _maxBytesPerRead); - - if (BufferReader.EndOfFile) - { - MoveToEndOfFile(); - return false; - } - byte ch = BufferReader.GetByte(); - if (ch == (byte)'<') - { - BufferReader.SkipByte(); - ch = BufferReader.GetByte(); - if (ch == (byte)'/') - ReadEndElement(); - else if (ch == (byte)'!') - { - BufferReader.SkipByte(); - ch = BufferReader.GetByte(); - if (ch == '-') - { - ReadComment(); - } - else - { - if (OutsideRootElement) - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlCDATAInvalidAtTopLevel))); - - ReadCData(); - } - } - else if (ch == (byte)'?') - ReadDeclaration(); - else - ReadStartElement(); - } - else if ((s_charType[ch] & CharType.SpecialWhitespace) != 0) - { - ReadWhitespace(); - } - else if (OutsideRootElement && ch != '\r') - { - XmlExceptionHelper.ThrowInvalidRootData(this); - } - else if ((s_charType[ch] & CharType.Text) != 0) - { - ReadText(false); - } - else if (ch == '&') - { - ReadEscapedText(); - } - else if (ch == '\r') - { - BufferReader.SkipByte(); - - if (!BufferReader.EndOfFile && BufferReader.GetByte() == '\n') - ReadWhitespace(); - else - MoveToComplexText().Value.SetCharValue('\n'); - } - else if (ch == ']') - { - int offset; - byte[] buffer = BufferReader.GetBuffer(3, out offset); - if (buffer[offset + 0] == (byte)']' && - buffer[offset + 1] == (byte)']' && - buffer[offset + 2] == (byte)'>') - { - XmlExceptionHelper.ThrowXmlException(this, new XmlException(string.Format(SRSerialization.XmlCloseCData))); - } - - BufferReader.SkipByte(); - MoveToComplexText().Value.SetCharValue(']'); // Need to get past the ']' and keep going. - } - else if (ch == 0xEF) // Watch for invalid characters 0xfffe and 0xffff - { - ReadText(true); - } - else - { - XmlExceptionHelper.ThrowInvalidXml(this, ch); - } - return true; - } - - public bool HasLineInfo() - { - return true; - } - - public int LineNumber - { - get - { - int row, column; - GetPosition(out row, out column); - return row; - } - } - - public int LinePosition - { - get - { - int row, column; - GetPosition(out row, out column); - return column; - } - } - - private void GetPosition(out int row, out int column) - { - if (_rowOffsets == null) - { - _rowOffsets = BufferReader.GetRows(); - } - - int offset = BufferReader.Offset; - - int j = 0; - while (j < _rowOffsets.Length - 1 && _rowOffsets[j + 1] < offset) - j++; - - row = j + 1; - column = offset - _rowOffsets[j] + 1; - } - - private static class CharType - { - public const byte None = 0x00; - public const byte FirstName = 0x01; - public const byte Name = 0x02; - public const byte Whitespace = 0x04; - public const byte Text = 0x08; - public const byte AttributeText = 0x10; - public const byte SpecialWhitespace = 0x20; - public const byte Comment = 0x40; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextWriter.cs deleted file mode 100644 index 988d7467e13..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Xml/XmlUTF8TextWriter.cs +++ /dev/null @@ -1,828 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Security; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.Xml -{ - using System; - - internal interface IXmlTextWriterInitializer - { - void SetOutput(Stream stream, Encoding encoding, bool ownsStream); - } - - internal class XmlUTF8TextWriter : XmlBaseWriter, IXmlTextWriterInitializer - { - private XmlUTF8NodeWriter _writer; - - public void SetOutput(Stream stream, Encoding encoding, bool ownsStream) - { - if (stream == null) - throw new ArgumentNullException("stream"); - if (encoding == null) - throw new ArgumentNullException("encoding"); - if (encoding.WebName != Encoding.UTF8.WebName) - { - stream = new EncodingStreamWrapper(stream, encoding, true); - } - - if (_writer == null) - { - _writer = new XmlUTF8NodeWriter(); - } - _writer.SetOutput(stream, ownsStream, encoding); - SetOutput(_writer); - } - } - - internal class XmlUTF8NodeWriter : XmlStreamNodeWriter - { - private byte[] _entityChars; - private bool[] _isEscapedAttributeChar; - private bool[] _isEscapedElementChar; - private bool _inAttribute; - private const int bufferLength = 512; - private const int maxEntityLength = 32; - private Encoding _encoding; - private char[] _chars; - - private static readonly byte[] s_startDecl = - { - (byte)'<', (byte)'?', (byte)'x', (byte)'m', (byte)'l', (byte)' ', - (byte)'v', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n', (byte)'=', (byte)'"', (byte)'1', (byte)'.', (byte)'0', (byte)'"', (byte)' ', - (byte)'e', (byte)'n', (byte)'c', (byte)'o', (byte)'d', (byte)'i', (byte)'n', (byte)'g', (byte)'=', (byte)'"', - }; - private static readonly byte[] s_endDecl = - { - (byte)'"', (byte)'?', (byte)'>' - }; - private static readonly byte[] s_utf8Decl = - { - (byte)'<', (byte)'?', (byte)'x', (byte)'m', (byte)'l', (byte)' ', - (byte)'v', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n', (byte)'=', (byte)'"', (byte)'1', (byte)'.', (byte)'0', (byte)'"', (byte)' ', - (byte)'e', (byte)'n', (byte)'c', (byte)'o', (byte)'d', (byte)'i', (byte)'n', (byte)'g', (byte)'=', (byte)'"', (byte)'u', (byte)'t', (byte)'f', (byte)'-', (byte)'8', (byte)'"', - (byte)'?', (byte)'>' - }; - private static readonly byte[] s_digits = - { - (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', - (byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' - }; - private static readonly bool[] s_defaultIsEscapedAttributeChar = new bool[] - { - true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, - true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, - false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, // '"', '&' - false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false // '<', '>' - }; - private static readonly bool[] s_defaultIsEscapedElementChar = new bool[] - { - true, true, true, true, true, true, true, true, true, false, false, true, true, true, true, true, // All but 0x09, 0x0A - true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, - false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, // '&' - false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false // '<', '>' - }; - - public XmlUTF8NodeWriter() - : this(s_defaultIsEscapedAttributeChar, s_defaultIsEscapedElementChar) - { - } - - public XmlUTF8NodeWriter(bool[] isEscapedAttributeChar, bool[] isEscapedElementChar) - { - _isEscapedAttributeChar = isEscapedAttributeChar; - _isEscapedElementChar = isEscapedElementChar; - _inAttribute = false; - } - - new public void SetOutput(Stream stream, bool ownsStream, Encoding encoding) - { - Encoding utf8Encoding = null; - if (encoding != null && encoding == Encoding.UTF8) - { - utf8Encoding = encoding; - encoding = null; - } - base.SetOutput(stream, ownsStream, utf8Encoding); - _encoding = encoding; - _inAttribute = false; - } - - public Encoding Encoding - { - get - { - return _encoding; - } - } - - private byte[] GetCharEntityBuffer() - { - if (_entityChars == null) - { - _entityChars = new byte[maxEntityLength]; - } - return _entityChars; - } - - private char[] GetCharBuffer(int charCount) - { - if (charCount >= 256) - return new char[charCount]; - if (_chars == null || _chars.Length < charCount) - _chars = new char[charCount]; - return _chars; - } - - public override void WriteDeclaration() - { - if (_encoding == null) - { - WriteUTF8Chars(s_utf8Decl, 0, s_utf8Decl.Length); - } - else - { - WriteUTF8Chars(s_startDecl, 0, s_startDecl.Length); - if (_encoding.WebName == Encoding.BigEndianUnicode.WebName) - WriteUTF8Chars("utf-16BE"); - else - WriteUTF8Chars(_encoding.WebName); - WriteUTF8Chars(s_endDecl, 0, s_endDecl.Length); - } - } - - public override void WriteCData(string text) - { - byte[] buffer; - int offset; - - buffer = GetBuffer(9, out offset); - buffer[offset + 0] = (byte)'<'; - buffer[offset + 1] = (byte)'!'; - buffer[offset + 2] = (byte)'['; - buffer[offset + 3] = (byte)'C'; - buffer[offset + 4] = (byte)'D'; - buffer[offset + 5] = (byte)'A'; - buffer[offset + 6] = (byte)'T'; - buffer[offset + 7] = (byte)'A'; - buffer[offset + 8] = (byte)'['; - Advance(9); - - WriteUTF8Chars(text); - - buffer = GetBuffer(3, out offset); - buffer[offset + 0] = (byte)']'; - buffer[offset + 1] = (byte)']'; - buffer[offset + 2] = (byte)'>'; - Advance(3); - } - - private void WriteStartComment() - { - int offset; - byte[] buffer = GetBuffer(4, out offset); - buffer[offset + 0] = (byte)'<'; - buffer[offset + 1] = (byte)'!'; - buffer[offset + 2] = (byte)'-'; - buffer[offset + 3] = (byte)'-'; - Advance(4); - } - - private void WriteEndComment() - { - int offset; - byte[] buffer = GetBuffer(3, out offset); - buffer[offset + 0] = (byte)'-'; - buffer[offset + 1] = (byte)'-'; - buffer[offset + 2] = (byte)'>'; - Advance(3); - } - - public override void WriteComment(string text) - { - WriteStartComment(); - WriteUTF8Chars(text); - WriteEndComment(); - } - - public override void WriteStartElement(string prefix, string localName) - { - WriteByte('<'); - if (prefix.Length != 0) - { - WritePrefix(prefix); - WriteByte(':'); - } - WriteLocalName(localName); - } - - public override async Task WriteStartElementAsync(string prefix, string localName) - { - await WriteByteAsync('<').ConfigureAwait(false); - if (prefix.Length != 0) - { - // This method calls into unsafe method which cannot run asyncly. - WritePrefix(prefix); - await WriteByteAsync(':').ConfigureAwait(false); - } - - // This method calls into unsafe method which cannot run asyncly. - WriteLocalName(localName); - } - - public override void WriteStartElement(string prefix, XmlDictionaryString localName) - { - WriteStartElement(prefix, localName.Value); - } - - public override void WriteStartElement(byte[] prefixBuffer, int prefixOffset, int prefixLength, byte[] localNameBuffer, int localNameOffset, int localNameLength) - { - WriteByte('<'); - if (prefixLength != 0) - { - WritePrefix(prefixBuffer, prefixOffset, prefixLength); - WriteByte(':'); - } - WriteLocalName(localNameBuffer, localNameOffset, localNameLength); - } - - public override void WriteEndStartElement(bool isEmpty) - { - if (!isEmpty) - { - WriteByte('>'); - } - else - { - WriteBytes('/', '>'); - } - } - - public override async Task WriteEndStartElementAsync(bool isEmpty) - { - if (!isEmpty) - { - await WriteByteAsync('>').ConfigureAwait(false); - } - else - { - await WriteBytesAsync('/', '>').ConfigureAwait(false); - } - } - - public override void WriteEndElement(string prefix, string localName) - { - WriteBytes('<', '/'); - if (prefix.Length != 0) - { - WritePrefix(prefix); - WriteByte(':'); - } - WriteLocalName(localName); - WriteByte('>'); - } - - public override async Task WriteEndElementAsync(string prefix, string localName) - { - await WriteBytesAsync('<', '/').ConfigureAwait(false); - if (prefix.Length != 0) - { - WritePrefix(prefix); - await WriteByteAsync(':').ConfigureAwait(false); - } - WriteLocalName(localName); - await WriteByteAsync('>').ConfigureAwait(false); - } - - public override void WriteEndElement(byte[] prefixBuffer, int prefixOffset, int prefixLength, byte[] localNameBuffer, int localNameOffset, int localNameLength) - { - WriteBytes('<', '/'); - if (prefixLength != 0) - { - WritePrefix(prefixBuffer, prefixOffset, prefixLength); - WriteByte(':'); - } - WriteLocalName(localNameBuffer, localNameOffset, localNameLength); - WriteByte('>'); - } - - private void WriteStartXmlnsAttribute() - { - int offset; - byte[] buffer = GetBuffer(6, out offset); - buffer[offset + 0] = (byte)' '; - buffer[offset + 1] = (byte)'x'; - buffer[offset + 2] = (byte)'m'; - buffer[offset + 3] = (byte)'l'; - buffer[offset + 4] = (byte)'n'; - buffer[offset + 5] = (byte)'s'; - Advance(6); - _inAttribute = true; - } - - public override void WriteXmlnsAttribute(string prefix, string ns) - { - WriteStartXmlnsAttribute(); - if (prefix.Length != 0) - { - WriteByte(':'); - WritePrefix(prefix); - } - WriteBytes('=', '"'); - WriteEscapedText(ns); - WriteEndAttribute(); - } - - public override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns) - { - WriteXmlnsAttribute(prefix, ns.Value); - } - - public override void WriteXmlnsAttribute(byte[] prefixBuffer, int prefixOffset, int prefixLength, byte[] nsBuffer, int nsOffset, int nsLength) - { - WriteStartXmlnsAttribute(); - if (prefixLength != 0) - { - WriteByte(':'); - WritePrefix(prefixBuffer, prefixOffset, prefixLength); - } - WriteBytes('=', '"'); - WriteEscapedText(nsBuffer, nsOffset, nsLength); - WriteEndAttribute(); - } - - public override void WriteStartAttribute(string prefix, string localName) - { - WriteByte(' '); - if (prefix.Length != 0) - { - WritePrefix(prefix); - WriteByte(':'); - } - WriteLocalName(localName); - WriteBytes('=', '"'); - _inAttribute = true; - } - - public override void WriteStartAttribute(string prefix, XmlDictionaryString localName) - { - WriteStartAttribute(prefix, localName.Value); - } - - public override void WriteStartAttribute(byte[] prefixBuffer, int prefixOffset, int prefixLength, byte[] localNameBuffer, int localNameOffset, int localNameLength) - { - WriteByte(' '); - if (prefixLength != 0) - { - WritePrefix(prefixBuffer, prefixOffset, prefixLength); - WriteByte(':'); - } - WriteLocalName(localNameBuffer, localNameOffset, localNameLength); - WriteBytes('=', '"'); - _inAttribute = true; - } - - public override void WriteEndAttribute() - { - WriteByte('"'); - _inAttribute = false; - } - - public override async Task WriteEndAttributeAsync() - { - await WriteByteAsync('"').ConfigureAwait(false); - _inAttribute = false; - } - - private void WritePrefix(string prefix) - { - if (prefix.Length == 1) - { - WriteUTF8Char(prefix[0]); - } - else - { - WriteUTF8Chars(prefix); - } - } - - private void WritePrefix(byte[] prefixBuffer, int prefixOffset, int prefixLength) - { - if (prefixLength == 1) - { - WriteUTF8Char((char)prefixBuffer[prefixOffset]); - } - else - { - WriteUTF8Chars(prefixBuffer, prefixOffset, prefixLength); - } - } - - private void WriteLocalName(string localName) - { - WriteUTF8Chars(localName); - } - - private void WriteLocalName(byte[] localNameBuffer, int localNameOffset, int localNameLength) - { - WriteUTF8Chars(localNameBuffer, localNameOffset, localNameLength); - } - - public override void WriteEscapedText(XmlDictionaryString s) - { - WriteEscapedText(s.Value); - } - - [SecuritySafeCritical] - unsafe public override void WriteEscapedText(string s) - { - int count = s.Length; - if (count > 0) - { - fixed (char* chars = s) - { - UnsafeWriteEscapedText(chars, count); - } - } - } - - [SecuritySafeCritical] - unsafe public override void WriteEscapedText(char[] s, int offset, int count) - { - if (count > 0) - { - fixed (char* chars = &s[offset]) - { - UnsafeWriteEscapedText(chars, count); - } - } - } - - [SecurityCritical] - private unsafe void UnsafeWriteEscapedText(char* chars, int count) - { - bool[] isEscapedChar = (_inAttribute ? _isEscapedAttributeChar : _isEscapedElementChar); - int isEscapedCharLength = isEscapedChar.Length; - int i = 0; - for (int j = 0; j < count; j++) - { - char ch = chars[j]; - if (ch < isEscapedCharLength && isEscapedChar[ch] || ch >= 0xFFFE) - { - UnsafeWriteUTF8Chars(chars + i, j - i); - WriteCharEntity(ch); - i = j + 1; - } - } - UnsafeWriteUTF8Chars(chars + i, count - i); - } - - public override void WriteEscapedText(byte[] chars, int offset, int count) - { - bool[] isEscapedChar = (_inAttribute ? _isEscapedAttributeChar : _isEscapedElementChar); - int isEscapedCharLength = isEscapedChar.Length; - int i = 0; - for (int j = 0; j < count; j++) - { - byte ch = chars[offset + j]; - if (ch < isEscapedCharLength && isEscapedChar[ch]) - { - WriteUTF8Chars(chars, offset + i, j - i); - WriteCharEntity(ch); - i = j + 1; - } - else if (ch == 239 && offset + j + 2 < count) - { - // 0xFFFE and 0xFFFF must be written as char entities - // UTF8(239, 191, 190) = (char) 0xFFFE - // UTF8(239, 191, 191) = (char) 0xFFFF - byte ch2 = chars[offset + j + 1]; - byte ch3 = chars[offset + j + 2]; - if (ch2 == 191 && (ch3 == 190 || ch3 == 191)) - { - WriteUTF8Chars(chars, offset + i, j - i); - WriteCharEntity(ch3 == 190 ? (char)0xFFFE : (char)0xFFFF); - i = j + 3; - } - } - } - WriteUTF8Chars(chars, offset + i, count - i); - } - - public void WriteText(int ch) - { - WriteUTF8Char(ch); - } - - public override void WriteText(byte[] chars, int offset, int count) - { - WriteUTF8Chars(chars, offset, count); - } - - [SecuritySafeCritical] - unsafe public override void WriteText(char[] chars, int offset, int count) - { - if (count > 0) - { - fixed (char* pch = &chars[offset]) - { - UnsafeWriteUTF8Chars(pch, count); - } - } - } - - public override void WriteText(string value) - { - WriteUTF8Chars(value); - } - - public override void WriteText(XmlDictionaryString value) - { - WriteUTF8Chars(value.Value); - } - - public void WriteLessThanCharEntity() - { - int offset; - byte[] buffer = GetBuffer(4, out offset); - buffer[offset + 0] = (byte)'&'; - buffer[offset + 1] = (byte)'l'; - buffer[offset + 2] = (byte)'t'; - buffer[offset + 3] = (byte)';'; - Advance(4); - } - - public void WriteGreaterThanCharEntity() - { - int offset; - byte[] buffer = GetBuffer(4, out offset); - buffer[offset + 0] = (byte)'&'; - buffer[offset + 1] = (byte)'g'; - buffer[offset + 2] = (byte)'t'; - buffer[offset + 3] = (byte)';'; - Advance(4); - } - - public void WriteAmpersandCharEntity() - { - int offset; - byte[] buffer = GetBuffer(5, out offset); - buffer[offset + 0] = (byte)'&'; - buffer[offset + 1] = (byte)'a'; - buffer[offset + 2] = (byte)'m'; - buffer[offset + 3] = (byte)'p'; - buffer[offset + 4] = (byte)';'; - Advance(5); - } - - public void WriteApostropheCharEntity() - { - int offset; - byte[] buffer = GetBuffer(6, out offset); - buffer[offset + 0] = (byte)'&'; - buffer[offset + 1] = (byte)'a'; - buffer[offset + 2] = (byte)'p'; - buffer[offset + 3] = (byte)'o'; - buffer[offset + 4] = (byte)'s'; - buffer[offset + 5] = (byte)';'; - Advance(6); - } - - public void WriteQuoteCharEntity() - { - int offset; - byte[] buffer = GetBuffer(6, out offset); - buffer[offset + 0] = (byte)'&'; - buffer[offset + 1] = (byte)'q'; - buffer[offset + 2] = (byte)'u'; - buffer[offset + 3] = (byte)'o'; - buffer[offset + 4] = (byte)'t'; - buffer[offset + 5] = (byte)';'; - Advance(6); - } - - private void WriteHexCharEntity(int ch) - { - byte[] chars = GetCharEntityBuffer(); - int offset = maxEntityLength; - chars[--offset] = (byte)';'; - offset -= ToBase16(chars, offset, (uint)ch); - chars[--offset] = (byte)'x'; - chars[--offset] = (byte)'#'; - chars[--offset] = (byte)'&'; - WriteUTF8Chars(chars, offset, maxEntityLength - offset); - } - - public override void WriteCharEntity(int ch) - { - switch (ch) - { - case '<': - WriteLessThanCharEntity(); - break; - case '>': - WriteGreaterThanCharEntity(); - break; - case '&': - WriteAmpersandCharEntity(); - break; - case '\'': - WriteApostropheCharEntity(); - break; - case '"': - WriteQuoteCharEntity(); - break; - default: - WriteHexCharEntity(ch); - break; - } - } - - private int ToBase16(byte[] chars, int offset, uint value) - { - int count = 0; - do - { - count++; - chars[--offset] = s_digits[(int)(value & 0x0F)]; - value /= 16; - } - while (value != 0); - return count; - } - - public override void WriteBoolText(bool value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxBoolChars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteDecimalText(decimal value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxDecimalChars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteDoubleText(double value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxDoubleChars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteFloatText(float value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxFloatChars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteDateTimeText(DateTime value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxDateTimeChars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteUniqueIdText(UniqueId value) - { - if (value.IsGuid) - { - int charCount = value.CharArrayLength; - char[] chars = GetCharBuffer(charCount); - value.ToCharArray(chars, 0); - WriteText(chars, 0, charCount); - } - else - { - WriteEscapedText(value.ToString()); - } - } - - public override void WriteInt32Text(int value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxInt32Chars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteInt64Text(long value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxInt64Chars, out offset); - Advance(XmlConverter.ToChars(value, buffer, offset)); - } - - public override void WriteUInt64Text(ulong value) - { - int offset; - byte[] buffer = GetBuffer(XmlConverter.MaxUInt64Chars, out offset); - Advance(XmlConverter.ToChars((double)value, buffer, offset)); - } - - public override void WriteGuidText(Guid value) - { - WriteText(value.ToString()); - } - - public override void WriteBase64Text(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count) - { - if (trailByteCount > 0) - { - InternalWriteBase64Text(trailBytes, 0, trailByteCount); - } - InternalWriteBase64Text(buffer, offset, count); - } - - public override async Task WriteBase64TextAsync(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count) - { - if (trailByteCount > 0) - { - await InternalWriteBase64TextAsync(trailBytes, 0, trailByteCount).ConfigureAwait(false); - } - - await InternalWriteBase64TextAsync(buffer, offset, count).ConfigureAwait(false); - } - - private void InternalWriteBase64Text(byte[] buffer, int offset, int count) - { - Base64Encoding encoding = XmlConverter.Base64Encoding; - while (count >= 3) - { - int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3); - int charCount = byteCount / 3 * 4; - int charOffset; - byte[] chars = GetBuffer(charCount, out charOffset); - Advance(encoding.GetChars(buffer, offset, byteCount, chars, charOffset)); - offset += byteCount; - count -= byteCount; - } - if (count > 0) - { - int charOffset; - byte[] chars = GetBuffer(4, out charOffset); - Advance(encoding.GetChars(buffer, offset, count, chars, charOffset)); - } - } - - private async Task InternalWriteBase64TextAsync(byte[] buffer, int offset, int count) - { - Base64Encoding encoding = XmlConverter.Base64Encoding; - while (count >= 3) - { - int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3); - int charCount = byteCount / 3 * 4; - int charOffset; - BytesWithOffset bufferResult = await GetBufferAsync(charCount).ConfigureAwait(false); - byte[] chars = bufferResult.Bytes; - charOffset = bufferResult.Offset; - Advance(encoding.GetChars(buffer, offset, byteCount, chars, charOffset)); - offset += byteCount; - count -= byteCount; - } - if (count > 0) - { - int charOffset; - BytesWithOffset bufferResult = await GetBufferAsync(4).ConfigureAwait(false); - byte[] chars = bufferResult.Bytes; - charOffset = bufferResult.Offset; - Advance(encoding.GetChars(buffer, offset, count, chars, charOffset)); - } - } - - public override void WriteTimeSpanText(TimeSpan value) - { - WriteText(XmlConvert.ToString(value)); - } - - public override void WriteStartListText() - { - } - - public override void WriteListSeparator() - { - WriteByte(' '); - } - - public override void WriteEndListText() - { - } - - public override void WriteQualifiedName(string prefix, XmlDictionaryString localName) - { - if (prefix.Length != 0) - { - WritePrefix(prefix); - WriteByte(':'); - } - WriteText(localName); - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs index afbb0a1ffd7..bbb7e77b9b0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs @@ -7,7 +7,7 @@ using System.Globalization; using System.Security; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Diagnostics.CodeAnalysis; using System.ServiceModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DictionaryTraceRecord.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DictionaryTraceRecord.cs index 809aff70917..09736a0b732 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DictionaryTraceRecord.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/DictionaryTraceRecord.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections; namespace System.Runtime.Diagnostics diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/EtwDiagnosticTrace.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/EtwDiagnosticTrace.cs index 1a8e09867f3..fbc72fb4954 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/EtwDiagnosticTrace.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/EtwDiagnosticTrace.cs @@ -7,7 +7,7 @@ using System.IO; using System.Security; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Collections.Concurrent; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/StringTraceRecord.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/StringTraceRecord.cs index f7aa86fd68a..268ef73565e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/StringTraceRecord.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/StringTraceRecord.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.Runtime.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/TraceRecord.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/TraceRecord.cs index 416daf6316a..8c03502499d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/TraceRecord.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/Internals/System/Runtime/Diagnostics/TraceRecord.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.Runtime.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/SMDiagnostics/System/ServiceModel/Diagnostics/ExceptionUtility.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/SMDiagnostics/System/ServiceModel/Diagnostics/ExceptionUtility.cs index 24a30dda224..fb833dd93c9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/SMDiagnostics/System/ServiceModel/Diagnostics/ExceptionUtility.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/SMDiagnostics/System/ServiceModel/Diagnostics/ExceptionUtility.cs @@ -7,7 +7,7 @@ using System.Diagnostics.Tracing; using System.Runtime; using System.Runtime.Diagnostics; -using Microsoft.Xml; +using System.Xml; namespace System { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/CanonicalFormWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/CanonicalFormWriter.cs index e52d545e002..71f4caa35a7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/CanonicalFormWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/CanonicalFormWriter.cs @@ -5,7 +5,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/DictionaryManager.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/DictionaryManager.cs index 5cc2b25304f..e87aa4b0310 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/DictionaryManager.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/DictionaryManager.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISecurityElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISecurityElement.cs index 2a9e63848a5..14f6d520ff7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISecurityElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISecurityElement.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISignatureValueSecurityElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISignatureValueSecurityElement.cs index 12a89fce1f9..92d98be370d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISignatureValueSecurityElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/ISignatureValueSecurityElement.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/IdentityModelDictionary.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/IdentityModelDictionary.cs index 3e54a77ebc3..76c9cec93bd 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/IdentityModelDictionary.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/IdentityModelDictionary.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Security/WSTrust.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Security/WSTrust.cs index 4734d4309d3..3bab7ade36a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Security/WSTrust.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Security/WSTrust.cs @@ -11,7 +11,7 @@ namespace System.IdentityModel.Security using System.IdentityModel.Tokens; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using KeyIdentifierClauseEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierClauseEntry; internal class WSTrust : SecurityTokenSerializer.SerializerEntries diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenResolver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenResolver.cs index 99cce9edb47..9a9436d316c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenResolver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenResolver.cs @@ -5,7 +5,7 @@ using System.ServiceModel; using System.Collections.ObjectModel; using System.IdentityModel.Tokens; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel.Selectors { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenSerializer.cs index eaa033807f6..25fd5a42e4e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Selectors/SecurityTokenSerializer.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IdentityModel.Tokens; using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel.Selectors { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignatureResourcePool.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignatureResourcePool.cs index c384060d12d..b3b7ac0432c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignatureResourcePool.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignatureResourcePool.cs @@ -5,7 +5,7 @@ using System.IO; using System.Security.Cryptography; using System.IdentityModel.Tokens; -using Microsoft.Xml; +using System.Xml; using System.Text; namespace System.IdentityModel diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignedXml.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignedXml.cs index 196728cc4ca..673ebb43075 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignedXml.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/SignedXml.cs @@ -8,7 +8,7 @@ using System.IdentityModel.Tokens; using System.IdentityModel.Selectors; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel; namespace System.IdentityModel diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/KeyInfoSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/KeyInfoSerializer.cs index 85a7d4f30e9..4cf03a9dc0d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/KeyInfoSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/KeyInfoSerializer.cs @@ -9,7 +9,7 @@ namespace System.IdentityModel.Tokens //using System.IdentityModel.Security; using System.IdentityModel.Selectors; using System.Runtime; - using Microsoft.Xml; + using System.Xml; using System.Collections; /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlAssertion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlAssertion.cs index 0909307805e..be2d0f83e62 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlAssertion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlAssertion.cs @@ -16,7 +16,7 @@ namespace System.IdentityModel.Tokens using System.Runtime.InteropServices; using System.Security; using System.Security.Cryptography; - using Microsoft.Xml; + using System.Xml; public class SamlAssertion // TODO: ICanonicalWriterEndRootElementCallback { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSecurityToken.cs index 2aac7b20b57..6bf6127a883 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSecurityToken.cs @@ -8,9 +8,9 @@ namespace System.IdentityModel.Tokens using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; - using Microsoft.Xml.Serialization; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; + using System.Xml; + using System.Xml.Schema; using Microsoft.CodeDom; using System.Runtime.Serialization; using System.Globalization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSerializer.cs index 236ad45bef9..7b53e9848ea 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/SamlSerializer.cs @@ -14,7 +14,7 @@ namespace System.IdentityModel.Tokens using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; - using Microsoft.Xml; + using System.Xml; public class SamlSerializer { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityJan2004.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityJan2004.cs index 2b3a355f34b..47e1d93ee9e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityJan2004.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityJan2004.cs @@ -12,7 +12,7 @@ namespace System.IdentityModel.Tokens using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Text; - using Microsoft.Xml; + using System.Xml; //using HexBinary = System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary; using KeyIdentifierClauseEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierClauseEntry; using StrEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.StrEntry; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityXXX2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityXXX2005.cs index b5cb7e4e859..e1f5126c929 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityXXX2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/WSSecurityXXX2005.cs @@ -8,7 +8,7 @@ namespace System.IdentityModel.Tokens using System.Collections.Generic; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using KeyIdentifierClauseEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierClauseEntry; using StrEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.StrEntry; using TokenEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.TokenEntry; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlDsigSep2000.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlDsigSep2000.cs index 8f2c6061f6e..0d578e71845 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlDsigSep2000.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlDsigSep2000.cs @@ -10,7 +10,7 @@ namespace System.IdentityModel.Tokens using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; using KeyIdentifierEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierEntry; internal class XmlDsigSep2000 : SecurityTokenSerializer.SerializerEntries diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlEncApr2001.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlEncApr2001.cs index 73fbf7ab462..5bdd21d9447 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlEncApr2001.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/Tokens/XmlEncApr2001.cs @@ -6,7 +6,7 @@ namespace System.IdentityModel.Tokens { using System.Collections.Generic; using System.IdentityModel.Selectors; - using Microsoft.Xml; + using System.Xml; using KeyIdentifierClauseEntry = System.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierClauseEntry; internal class XmlEncApr2001 : SecurityTokenSerializer.SerializerEntries diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XD.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XD.cs index 20f7a8dec8d..c4fa16882f6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XD.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XD.cs @@ -5,7 +5,7 @@ // NOTE: this file was generated from 'xd.xml' using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XmlBuffer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XmlBuffer.cs index 697362209ac..5154d48dd13 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XmlBuffer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/IdentityModel/XmlBuffer.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Runtime; using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; namespace System.IdentityModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeader.cs index f207d3f8c6b..a243f15f29a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeader.cs @@ -6,7 +6,7 @@ using System.Runtime.Serialization; using System.ServiceModel.Dispatcher; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeaderCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeaderCollection.cs index 47eb7ddef86..8a847501dcd 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeaderCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressHeaderCollection.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Addressing.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Addressing.cs index c3f1b0febe1..9b49d66a810 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Addressing.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Addressing.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressingVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressingVersion.cs index 59b5ce93cdd..4bcd8f76e65 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressingVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AddressingVersion.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Security; namespace System.ServiceModel.Channels diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AsymmetricSecurityBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AsymmetricSecurityBindingElement.cs index ca87abd385b..e13bed53d61 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AsymmetricSecurityBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/AsymmetricSecurityBindingElement.cs @@ -11,7 +11,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Security.Tokens; using System.ServiceModel.Security; using System.ServiceModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncoder.cs index 559349589d7..b54a9f4913e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncoder.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncoder.cs @@ -10,7 +10,7 @@ using System.ServiceModel.Diagnostics; using System.Text; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncodingBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncodingBindingElement.cs index a53f84b2395..9d46ee5a338 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncodingBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryMessageEncodingBindingElement.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; using System.ComponentModel; namespace System.ServiceModel.Channels diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryVersion.cs index 5f5b0139cd2..6ef79fb4e24 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BinaryVersion.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BodyWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BodyWriter.cs index ca54cb196fc..eb1e83832c6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BodyWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BodyWriter.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageData.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageData.cs index 07176c571c1..b33b3630e8c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageData.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageData.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageWriter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageWriter.cs index 4971f8cab00..4b19e02db8b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageWriter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/BufferedMessageWriter.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.IO; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElement.cs index 20239710546..2c2f02d56a3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElement.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public sealed class CompositeDuplexBindingElement : BindingElement //, IPolicyExportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElementImporter.cs index 034bcb866a7..f24a8f49099 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/CompositeDuplexBindingElementImporter.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContentOnlyMessage.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContentOnlyMessage.cs index 4b6a151d1c9..f79356d2b7a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContentOnlyMessage.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContentOnlyMessage.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel.Diagnostics; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementImporter.cs index 791aa761010..ef9ca027a7b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementImporter.cs @@ -9,8 +9,8 @@ namespace System.ServiceModel.Channels using System.Runtime.CompilerServices; using System.ServiceModel.Description; using System.Web.Services.Description; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; public class ContextBindingElementImporter : IPolicyImportExtension, IWsdlImportExtension { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementPolicy.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementPolicy.cs index 6f430dc5adb..95ab97ad357 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementPolicy.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ContextBindingElementPolicy.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel.Channels using System; using System.Collections.Generic; using System.Collections.ObjectModel; - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; using System.Net.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/EncoderHelpers.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/EncoderHelpers.cs index cc263d7c7f1..330dc024d42 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/EncoderHelpers.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/EncoderHelpers.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpResponseMessageHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpResponseMessageHelper.cs index 0a359c07cfb..ecbcce6d4a3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpResponseMessageHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpResponseMessageHelper.cs @@ -9,7 +9,7 @@ using System.Runtime; using System.ServiceModel.Security; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpTransportBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpTransportBindingElement.cs index f82247924e4..f169fda7c6f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpTransportBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpTransportBindingElement.cs @@ -10,7 +10,7 @@ using System.Runtime; using System.Security.Authentication.ExtendedProtection; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpsTransportBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpsTransportBindingElement.cs index eb107ab7e7a..7d410c8746f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpsTransportBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/HttpsTransportBindingElement.cs @@ -7,7 +7,7 @@ using System.ComponentModel; using System.ServiceModel.Description; using System.ServiceModel.Security; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ITransportTokenAssertionProvider.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ITransportTokenAssertionProvider.cs index 431b0c428bf..30f6656e9a3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ITransportTokenAssertionProvider.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ITransportTokenAssertionProvider.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; public interface ITransportTokenAssertionProvider diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Message.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Message.cs index 8cbcd7e3835..09499a19d66 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Message.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/Message.cs @@ -11,7 +11,7 @@ using System.ServiceModel.Diagnostics; using System.ServiceModel.Dispatcher; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageBuffer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageBuffer.cs index 01ea5579b32..1685dd7a9fb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageBuffer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageBuffer.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.IO; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageEncodingBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageEncodingBindingElementImporter.cs index 211d6d07f74..44464988367 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageEncodingBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageEncodingBindingElementImporter.cs @@ -6,8 +6,8 @@ namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel.Description; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using System.Web.Services.Description; public class MessageEncodingBindingElementImporter : IWsdlImportExtension, IPolicyImportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageFault.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageFault.cs index 19e3185b51a..fc48cf5fc6e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageFault.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageFault.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; using System.Runtime.Serialization; using System.ServiceModel.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeader.cs index 39bd0955fc9..eec46087498 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeader.cs @@ -8,7 +8,7 @@ using System.Runtime.Serialization; using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaderInfo.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaderInfo.cs index cb02f4fb91a..fa6ec9f8fd5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaderInfo.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaderInfo.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.ServiceModel; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaders.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaders.cs index b4f535b3614..2906ccb070f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaders.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MessageHeaders.cs @@ -11,7 +11,7 @@ using System.ServiceModel.Diagnostics; using System.ServiceModel.Dispatcher; using System.Threading; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs index f1a086adf75..d572ac4f359 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel.Channels; using System.ServiceModel; using System.Text; - using Microsoft.Xml; + using System.Xml; using System.ComponentModel; public sealed class MtomMessageEncodingBindingElement : MessageEncodingBindingElement, IWsdlExportExtension, IPolicyExportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElement.cs index 11b970a5523..d82a73af6b5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElement.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public sealed class OneWayBindingElement : BindingElement, IPolicyExportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElementImporter.cs index 6ef8d4d98fa..50e09169c25 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/OneWayBindingElementImporter.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; using System.Collections; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElement.cs index 19668e733a8..a4a121f09b5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElement.cs @@ -5,7 +5,7 @@ namespace System.ServiceModel.Channels { using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; public sealed class PrivacyNoticeBindingElement : BindingElement, IPolicyExportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElementImporter.cs index 8397a7490f0..4a7b0059d1a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/PrivacyNoticeBindingElementImporter.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; internal static class PrivacyNoticePolicyStrings diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElement.cs index 98dbaf6a3ac..edea8952a6b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElement.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public sealed class ReliableSessionBindingElement : BindingElement, IPolicyExportExtension { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElementImporter.cs index 6e63abefe0b..c58b248d38a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/ReliableSessionBindingElementImporter.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Channels using System.Runtime; using System.ServiceModel; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; internal static class ReliableSessionPolicyStrings { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/RequestReplyCorrelator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/RequestReplyCorrelator.cs index ca5fe2fe9ff..bc60de35f6c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/RequestReplyCorrelator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/RequestReplyCorrelator.cs @@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime; using System.ServiceModel.Diagnostics; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityAttributeGenerationHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityAttributeGenerationHelper.cs index 0bd8012abfd..a2e6ce6ab58 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityAttributeGenerationHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityAttributeGenerationHelper.cs @@ -5,7 +5,7 @@ namespace System.ServiceModel.Channels { using Microsoft.CodeDom; - using Microsoft.Xml; + using System.Xml; internal static class SecurityAttributeGenerationHelper { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElement.cs index e4b856bf782..2ccb68db668 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElement.cs @@ -18,7 +18,7 @@ using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElementImporter.cs index 459c8631859..eb2638284fa 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SecurityBindingElementImporter.cs @@ -6,7 +6,7 @@ namespace System.ServiceModel.Channels { using System; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; using System.Collections.Generic; using System.Globalization; using System.Runtime.Serialization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SessionConnectionReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SessionConnectionReader.cs index 3281347aeb1..d010c93e643 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SessionConnectionReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SessionConnectionReader.cs @@ -5,7 +5,7 @@ using System.Runtime; using System.ServiceModel.Security; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SslStreamSecurityBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SslStreamSecurityBindingElement.cs index 69ccbe538d4..e6c69b5679d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SslStreamSecurityBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SslStreamSecurityBindingElement.cs @@ -7,7 +7,7 @@ using System.Security.Authentication; using System.ServiceModel.Description; using System.ServiceModel.Security; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/StandardBindingImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/StandardBindingImporter.cs index f09fb97c963..f6497a3310d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/StandardBindingImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/StandardBindingImporter.cs @@ -4,10 +4,10 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel; using System.ServiceModel.Description; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections.ObjectModel; using System.Collections.Generic; using WsdlNS = System.Web.Services.Description; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SymmetricSecurityBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SymmetricSecurityBindingElement.cs index 451ae4278be..878c366ffe9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SymmetricSecurityBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/SymmetricSecurityBindingElement.cs @@ -6,7 +6,7 @@ namespace System.ServiceModel.Channels { using System; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; using System.Collections.Generic; using System.Globalization; using System.Runtime.Serialization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncoder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncoder.cs index 24dba86df84..61d21a9de5c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncoder.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncoder.cs @@ -8,7 +8,7 @@ using System.Runtime.Diagnostics; using System.ServiceModel.Diagnostics; using System.Text; -using Microsoft.Xml; +using System.Xml; using System.Diagnostics.Contracts; using System.Threading.Tasks; using System.Net.Http.Headers; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncodingBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncodingBindingElement.cs index 482a9385d6e..62084f29a88 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncodingBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TextMessageEncodingBindingElement.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Text; -using Microsoft.Xml; +using System.Xml; using System.ComponentModel; namespace System.ServiceModel.Channels diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElement.cs index b37170e3132..ddda732e433 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElement.cs @@ -12,7 +12,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel.Security; using System.ComponentModel; //using System.ServiceModel.Transactions; - using Microsoft.Xml; + using System.Xml; public sealed class TransactionFlowBindingElement : BindingElement { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElementImporter.cs index 2bcbe252f79..e80a79813b9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransactionFlowBindingElementImporter.cs @@ -8,7 +8,7 @@ namespace System.ServiceModel.Channels using System.ServiceModel.Description; using System.ServiceModel.Security; using System.Collections.Generic; - using Microsoft.Xml; + using System.Xml; internal static class TransactionPolicyStrings { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElement.cs index 1271a427797..62a9c62abab 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElement.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel.Security; -using Microsoft.Xml; +using System.Xml; using System.Collections.ObjectModel; using System.ComponentModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElementImporter.cs index a1adebc2272..9f8dda058f1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportBindingElementImporter.cs @@ -4,11 +4,11 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections.ObjectModel; using System.Collections.Generic; using WsdlNS = System.Web.Services.Description; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportDefaults.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportDefaults.cs index faa7b540671..7b80ca0a6f1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportDefaults.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportDefaults.cs @@ -10,7 +10,7 @@ using System.Security.Principal; using System.ServiceModel.Security; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportOutputChannel.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportOutputChannel.cs index f78ff223da7..ed370ee308d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportOutputChannel.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/TransportOutputChannel.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel; -using Microsoft.Xml; +using System.Xml; using System.Runtime.Diagnostics; namespace System.ServiceModel.Channels diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportBindingElement.cs index af55f3c222a..192b0387311 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportBindingElement.cs @@ -11,7 +11,7 @@ namespace System.ServiceModel.Channels using System.Diagnostics.CodeAnalysis; using System.Runtime; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; // was UdpTransportBindingElement public class UdpTransportBindingElement diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportImporter.cs index 76878df136c..9746f115aa5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UdpTransportImporter.cs @@ -6,8 +6,8 @@ namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel.Description; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using WsdlNS = System.Web.Services.Description; public class UdpTransportImporter : IPolicyImportExtension, IWsdlImportExtension diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UnrecognizedAssertionsBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UnrecognizedAssertionsBindingElement.cs index 6f2635d1d03..308ae51eff2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UnrecognizedAssertionsBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UnrecognizedAssertionsBindingElement.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Channels using System.Collections.ObjectModel; using System.Runtime; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; internal class UnrecognizedAssertionsBindingElement : BindingElement { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElement.cs index d95179de833..0a75ad6de79 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElement.cs @@ -5,7 +5,7 @@ namespace System.ServiceModel.Channels { using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; public sealed class UseManagedPresentationBindingElement : BindingElement, IPolicyExportExtension { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElementImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElementImporter.cs index 8d5981e5bfd..32d7f4bd605 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElementImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/UseManagedPresentationBindingElementImporter.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Channels { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Description; internal static class UseManagedPresentationPolicyStrings diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/WindowsStreamSecurityBindingElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/WindowsStreamSecurityBindingElement.cs index 7cecd6bf5c1..4c11a39eb8f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/WindowsStreamSecurityBindingElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/WindowsStreamSecurityBindingElement.cs @@ -6,7 +6,7 @@ using System.Net.Security; using System.ServiceModel.Description; using System.ServiceModel.Security; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Channels { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs index 836a8d2ebc1..142b9ead1e7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs @@ -15,9 +15,9 @@ namespace System.ServiceModel.Channels using System.Text; using System.ServiceModel; using System.Runtime.Serialization; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using WsdlNS = System.Web.Services.Description; public class XmlSerializerImportOptions diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/BindingElementExtensionElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/BindingElementExtensionElement.cs index ff7432a50a0..ad55b7a51fd 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/BindingElementExtensionElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/BindingElementExtensionElement.cs @@ -8,7 +8,7 @@ namespace System.ServiceModel.Configuration using System; using System.ServiceModel.Channels; using System.Globalization; - using Microsoft.Xml; + using System.Xml; public abstract class BindingElementExtensionElement //TODO: ServiceModelExtensionElement { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElement.cs index dcaeb7171c1..beeb30f629a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElement.cs @@ -11,7 +11,7 @@ namespace System.ServiceModel.Configuration using System.Net.Security; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using System.Collections.ObjectModel; using System.Collections.Generic; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElementBase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElementBase.cs index a7a6ed81b5f..4dfbd0f262a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElementBase.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Configuration/SecurityElementBase.cs @@ -12,7 +12,7 @@ namespace System.ServiceModel.Configuration using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using System.Linq; public partial class SecurityElementBase : BindingElementExtensionElement diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DXD.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DXD.cs index d1725c5295a..ace5f2d59bc 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DXD.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DXD.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; namespace System.ServiceModel diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerMessageContractImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerMessageContractImporter.cs index e3daebf1f38..8740a552269 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerMessageContractImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerMessageContractImporter.cs @@ -11,11 +11,11 @@ namespace System.ServiceModel.Description using System.Text; using System.ServiceModel; using System.Runtime.Serialization; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using Microsoft.CodeDom; using WsdlNS = System.Web.Services.Description; - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; public class DataContractSerializerMessageContractImporter : IWsdlImportExtension { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerOperationBehavior.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerOperationBehavior.cs index 96b466a790c..65c0a710cd1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerOperationBehavior.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/DataContractSerializerOperationBehavior.cs @@ -6,7 +6,7 @@ using System.ServiceModel.Dispatcher; using System.Runtime.Serialization; using System.Collections.Generic; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/IWsdlImportExtension.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/IWsdlImportExtension.cs index d28f5ece04f..8d077157d47 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/IWsdlImportExtension.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/IWsdlImportExtension.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; using WsdlNS = System.Web.Services.Description; namespace System.ServiceModel.Description diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ImportedPolicyConversionContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ImportedPolicyConversionContext.cs index b848a4acc69..190de1394cf 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ImportedPolicyConversionContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ImportedPolicyConversionContext.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Description using System.Globalization; using System.Runtime; using System.ServiceModel.Channels; - using Microsoft.Xml; + using System.Xml; public abstract partial class MetadataImporter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractExporter.cs index c2844f7a7a3..422c2c5d453 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractExporter.cs @@ -14,9 +14,9 @@ namespace System.ServiceModel.Description using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Dispatcher; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using WsdlNS = System.Web.Services.Description; internal static class StockSchemas diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs index 3d904a9e8bf..269db62d772 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs @@ -18,9 +18,9 @@ namespace System.ServiceModel.Description using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Diagnostics; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using WsdlNS = System.Web.Services.Description; internal class MessageContractImporter @@ -840,9 +840,9 @@ private static XmlSchemaSet GatherSchemas(WsdlImporter importer) foreach (WsdlNS.ServiceDescription wsdl in importer.WsdlDocuments) { - XmlQualifiedName[] wsdlPrefixNsPairs = wsdl.Namespaces.ToArray(); if (wsdl.Types != null && wsdl.Types.Schemas != null) { + XmlQualifiedName[] wsdlPrefixNsPairs = wsdl.Namespaces.ToArray(); foreach (XmlSchema xsd in wsdl.Types.Schemas) { XmlSerializerNamespaces xsdNamespaces = xsd.Namespaces; @@ -853,19 +853,19 @@ private static XmlSchemaSet GatherSchemas(WsdlImporter importer) foreach (XmlQualifiedName pair in wsdlPrefixNsPairs) if (!prefixesUsed.ContainsKey(pair.Name)) xsdNamespaces.Add(pair.Name, pair.Namespace); - if (xsd.Items.Count > 0) + + if (xsd.Items.Count > 0 || (xsd.TargetNamespace != null && xsd.TargetNamespace.Length > 0)) { schemaSet.Add(xsd); } - else + + // only add include schemas + foreach (XmlSchemaExternal include in xsd.Includes) { - // only add include schemas - foreach (XmlSchemaExternal include in xsd.Includes) + if (include.Schema != null) { - if (include.Schema != null) - { - schemaSet.Add(include.Schema); - } + Console.WriteLine("DEBUG: Adding Included Schema: " + include.Schema.TargetNamespace); + schemaSet.Add(include.Schema); } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageDescription.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageDescription.cs index b0e31489fb3..92711336737 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageDescription.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageDescription.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; using System.Diagnostics; using System.Net.Security; using System.ServiceModel.Security; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageHeaderDescriptionCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageHeaderDescriptionCollection.cs index 4b16e652da7..d5c8a7b2217 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageHeaderDescriptionCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageHeaderDescriptionCollection.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessagePartDescriptionCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessagePartDescriptionCollection.cs index feca8fb24fa..3e1894469b8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessagePartDescriptionCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessagePartDescriptionCollection.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataExchangeClient.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataExchangeClient.cs index c2c3c13e691..feb302443a6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataExchangeClient.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataExchangeClient.cs @@ -20,9 +20,9 @@ namespace System.ServiceModel.Description using System.Text; using System.Threading; using System.Threading.Tasks; - using Microsoft.Xml; + using System.Xml; using WsdlNS = System.Web.Services.Description; - using XsdNS = Microsoft.Xml.Schema; + using XsdNS = System.Xml.Schema; public partial class MetadataExchangeClient { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataImporter.cs index 84e6c52bf51..f6b65dce35f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataImporter.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Description using System.Security; using System.ServiceModel; using System.ServiceModel.Channels; - using Microsoft.Xml; + using System.Xml; public abstract partial class MetadataImporter { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataLocation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataLocation.cs index cca264c7dea..1c7c33ce884 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataLocation.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataLocation.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml.Serialization; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataReference.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataReference.cs index a12ae15428b..0bcc23ad79c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataReference.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataReference.cs @@ -8,8 +8,8 @@ namespace System.ServiceModel.Description using System.ServiceModel; using System.Collections.Generic; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Collections.ObjectModel; using WsdlNS = System.Web.Services.Description; using System.ServiceModel.Channels; @@ -44,7 +44,7 @@ public AddressingVersion AddressVersion set { _addressVersion = value; } } - Microsoft.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() + System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() { return null; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSection.cs index bad88d9d69f..9ed33cb4dc3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSection.cs @@ -8,11 +8,11 @@ namespace System.ServiceModel.Description using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; - using Microsoft.Xml; + using System.Xml; using WsdlNS = System.Web.Services.Description; - using XsdNS = Microsoft.Xml.Schema; + using XsdNS = System.Xml.Schema; using System.Reflection; - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; [XmlRoot(ElementName = MetadataStrings.MetadataExchangeStrings.MetadataSection, Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] public class MetadataSection @@ -37,7 +37,7 @@ public MetadataSection(string dialect, string identifier, object metadata) } static public string ServiceDescriptionDialect { get { return System.Web.Services.Description.ServiceDescription.Namespace; } } - static public string XmlSchemaDialect { get { return Microsoft.Xml.Schema.XmlSchema.Namespace; } } + static public string XmlSchemaDialect { get { return System.Xml.Schema.XmlSchema.Namespace; } } static public string PolicyDialect { get { return MetadataStrings.WSPolicy.NamespaceUri; } } static public string MetadataExchangeDialect { get { return MetadataStrings.MetadataExchangeStrings.Namespace; } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSet.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSet.cs index a89811076dc..22d7f98f0d3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSet.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MetadataSet.cs @@ -10,8 +10,8 @@ namespace System.ServiceModel.Description using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; [XmlRoot(MetadataStrings.MetadataExchangeStrings.Metadata, Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] public class MetadataSet : IXmlSerializable @@ -61,7 +61,7 @@ public static MetadataSet ReadFrom(XmlReader reader) return (MetadataSet)xs.Deserialize(reader); } - Microsoft.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() + System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() { return null; } @@ -141,7 +141,7 @@ public bool ProcessOuterElement * * o.@Metadata = Reader.ReadElementString(); * to - o.@Metadata = Microsoft.Xml.Schema.XmlSchema.Read(this.Reader, null); + o.@Metadata = System.Xml.Schema.XmlSchema.Read(this.Reader, null); if (this.Reader.NodeType == XmlNodeType.EndElement) ReadEndElement(); * @@ -153,9 +153,9 @@ public bool ProcessOuterElement * } * to * - else if (o.@Metadata is global::Microsoft.Xml.Schema.XmlSchema) + else if (o.@Metadata is global::System.Xml.Schema.XmlSchema) { - ((global::Microsoft.Xml.Schema.XmlSchema)o.@Metadata).Write(this.Writer); + ((global::System.Xml.Schema.XmlSchema)o.@Metadata).Write(this.Writer); } * * (*) In XmlSerializationReaderMetadataSet.Read*_MetadataSection change @@ -225,7 +225,7 @@ public bool ProcessOuterElement * */ - internal class XmlSerializationWriterMetadataSet : Microsoft.Xml.Serialization.XmlSerializationWriter + internal class XmlSerializationWriterMetadataSet : System.Xml.Serialization.XmlSerializationWriter { private bool _processOuterElement = true; public bool ProcessOuterElement @@ -281,12 +281,12 @@ private void Write67_MetadataSet(string n, string ns, global::System.ServiceMode if (needType) WriteXsiType(@"MetadataSet", @"http://schemas.xmlsoap.org/ws/2004/09/mex"); { - global::System.Collections.ObjectModel.Collection a = (global::System.Collections.ObjectModel.Collection)o.@Attributes; + global::System.Collections.ObjectModel.Collection a = (global::System.Collections.ObjectModel.Collection)o.@Attributes; if (a != null) { for (int i = 0; i < ((System.Collections.ICollection)a).Count; i++) { - global::Microsoft.Xml.XmlAttribute ai = (global::Microsoft.Xml.XmlAttribute)a[i]; + global::System.Xml.XmlAttribute ai = (global::System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -333,12 +333,12 @@ private void Write66_MetadataSection(string n, string ns, global::System.Service WriteStartElement(n, ns, o, true, xmlSerializerNamespaces); if (needType) WriteXsiType(@"MetadataSection", @"http://schemas.xmlsoap.org/ws/2004/09/mex"); { - global::System.Collections.ObjectModel.Collection a = (global::System.Collections.ObjectModel.Collection)o.@Attributes; + global::System.Collections.ObjectModel.Collection a = (global::System.Collections.ObjectModel.Collection)o.@Attributes; if (a != null) { for (int i = 0; i < ((System.Collections.ICollection)a).Count; i++) { - global::Microsoft.Xml.XmlAttribute ai = (global::Microsoft.Xml.XmlAttribute)a[i]; + global::System.Xml.XmlAttribute ai = (global::System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -350,9 +350,9 @@ private void Write66_MetadataSection(string n, string ns, global::System.Service { ((global::System.Web.Services.Description.ServiceDescription)o.@Metadata).Write(this.Writer); } - else if (o.@Metadata is global::Microsoft.Xml.Schema.XmlSchema) + else if (o.@Metadata is global::System.Xml.Schema.XmlSchema) { - ((global::Microsoft.Xml.Schema.XmlSchema)o.@Metadata).Write(this.Writer); + ((global::System.Xml.Schema.XmlSchema)o.@Metadata).Write(this.Writer); } else if (o.@Metadata is global::System.ServiceModel.Description.MetadataSet) { @@ -364,14 +364,14 @@ private void Write66_MetadataSection(string n, string ns, global::System.Service } else if (o.@Metadata is global::System.ServiceModel.Description.MetadataReference) { - WriteSerializable((Microsoft.Xml.Serialization.IXmlSerializable)((global::System.ServiceModel.Description.MetadataReference)o.@Metadata), @"MetadataReference", @"http://schemas.xmlsoap.org/ws/2004/09/mex", false, true); + WriteSerializable((System.Xml.Serialization.IXmlSerializable)((global::System.ServiceModel.Description.MetadataReference)o.@Metadata), @"MetadataReference", @"http://schemas.xmlsoap.org/ws/2004/09/mex", false, true); } - else if (o.@Metadata is Microsoft.Xml.XmlElement) + else if (o.@Metadata is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)o.@Metadata; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)o.@Metadata; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -420,7 +420,7 @@ protected override void InitCallbacks() } } - internal class XmlSerializationReaderMetadataSet : Microsoft.Xml.Serialization.XmlSerializationReader + internal class XmlSerializationReaderMetadataSet : System.Xml.Serialization.XmlSerializationReader { private bool _processOuterElement = true; public bool ProcessOuterElement @@ -433,7 +433,7 @@ public object Read68_Metadata() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!_processOuterElement || (((object)Reader.LocalName == (object)_id1_Metadata && (object)Reader.NamespaceURI == (object)_id2_Item))) { @@ -453,28 +453,28 @@ public object Read68_Metadata() private global::System.ServiceModel.Description.MetadataSet Read67_MetadataSet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (!_processOuterElement || (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id3_MetadataSet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item))) + if (!_processOuterElement || (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id3_MetadataSet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item))) { } else - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType)); } if (isNull) return null; global::System.ServiceModel.Description.MetadataSet o; o = new global::System.ServiceModel.Description.MetadataSet(); global::System.Collections.ObjectModel.Collection a_0 = (global::System.Collections.ObjectModel.Collection)o.@MetadataSections; - global::System.Collections.ObjectModel.Collection a_1 = (global::System.Collections.ObjectModel.Collection)o.@Attributes; + global::System.Collections.ObjectModel.Collection a_1 = (global::System.Collections.ObjectModel.Collection)o.@Attributes; bool[] paramsRead = new bool[2]; while (Reader.MoveToNextAttribute()) { if (!IsXmlnsAttribute(Reader.Name)) { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); a_1.Add(attr); } @@ -489,9 +489,9 @@ public object Read68_Metadata() Reader.MoveToContent(); int whileIterations0 = 0; int readerCount0 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id4_MetadataSection && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -515,21 +515,21 @@ public object Read68_Metadata() private global::System.ServiceModel.Description.MetadataSection Read66_MetadataSection(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id4_MetadataSection && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id4_MetadataSection && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType)); } if (isNull) return null; global::System.ServiceModel.Description.MetadataSection o; o = new global::System.ServiceModel.Description.MetadataSection(); - global::System.Collections.ObjectModel.Collection a_0 = (global::System.Collections.ObjectModel.Collection)o.@Attributes; + global::System.Collections.ObjectModel.Collection a_0 = (global::System.Collections.ObjectModel.Collection)o.@Attributes; bool[] paramsRead = new bool[4]; while (Reader.MoveToNextAttribute()) { @@ -545,7 +545,7 @@ public object Read68_Metadata() } else if (!IsXmlnsAttribute(Reader.Name)) { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); a_0.Add(attr); } @@ -560,9 +560,9 @@ public object Read68_Metadata() Reader.MoveToContent(); int whileIterations1 = 0; int readerCount1 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id1_Metadata && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -571,7 +571,7 @@ public object Read68_Metadata() } else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id8_schema && (object)Reader.NamespaceURI == (object)_id9_Item)) { - o.@Metadata = Microsoft.Xml.Schema.XmlSchema.Read(this.Reader, null); + o.@Metadata = System.Xml.Schema.XmlSchema.Read(this.Reader, null); if (this.Reader.NodeType == XmlNodeType.EndElement) ReadEndElement(); paramsRead[3] = true; @@ -585,7 +585,7 @@ public object Read68_Metadata() } else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id12_MetadataReference && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Metadata = (global::System.ServiceModel.Description.MetadataReference)ReadSerializable((Microsoft.Xml.Serialization.IXmlSerializable)System.Activator.CreateInstance(typeof(global::System.ServiceModel.Description.MetadataReference), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic, null, new object[0], null)); + o.@Metadata = (global::System.ServiceModel.Description.MetadataReference)ReadSerializable((System.Xml.Serialization.IXmlSerializable)System.Activator.CreateInstance(typeof(global::System.ServiceModel.Description.MetadataReference), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic, null, new object[0], null)); paramsRead[3] = true; } else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id13_Location && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -595,7 +595,7 @@ public object Read68_Metadata() } else { - o.@Metadata = (global::Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@Metadata = (global::System.Xml.XmlElement)ReadXmlNode(false); } } else @@ -611,16 +611,16 @@ public object Read68_Metadata() private global::System.ServiceModel.Description.MetadataLocation Read65_MetadataLocation(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id14_MetadataLocation && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id14_MetadataLocation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType)); } if (isNull) return null; global::System.ServiceModel.Description.MetadataLocation o; @@ -643,17 +643,17 @@ public object Read68_Metadata() Reader.MoveToContent(); int whileIterations2 = 0; int readerCount2 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { string tmp = null; - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } - else if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Text || - Reader.NodeType == Microsoft.Xml.XmlNodeType.CDATA || - Reader.NodeType == Microsoft.Xml.XmlNodeType.Whitespace || - Reader.NodeType == Microsoft.Xml.XmlNodeType.SignificantWhitespace) + else if (Reader.NodeType == System.Xml.XmlNodeType.Text || + Reader.NodeType == System.Xml.XmlNodeType.CDATA || + Reader.NodeType == System.Xml.XmlNodeType.Whitespace || + Reader.NodeType == System.Xml.XmlNodeType.SignificantWhitespace) { tmp = ReadString(tmp, false); o.@Location = tmp; @@ -959,13 +959,13 @@ protected override void InitIDs() } } - internal abstract class XmlSerializer1 : Microsoft.Xml.Serialization.XmlSerializer + internal abstract class XmlSerializer1 : System.Xml.Serialization.XmlSerializer { - protected override Microsoft.Xml.Serialization.XmlSerializationReader CreateReader() + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { return new XmlSerializationReaderMetadataSet(); } - protected override Microsoft.Xml.Serialization.XmlSerializationWriter CreateWriter() + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { return new XmlSerializationWriterMetadataSet(); } @@ -980,28 +980,28 @@ public bool ProcessOuterElement set { _processOuterElement = value; } } - public override System.Boolean CanDeserialize(Microsoft.Xml.XmlReader xmlReader) + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { return xmlReader.IsStartElement(@"Metadata", @"http://schemas.xmlsoap.org/ws/2004/09/mex"); } - protected override void Serialize(object objectToSerialize, Microsoft.Xml.Serialization.XmlSerializationWriter writer) + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { ((XmlSerializationWriterMetadataSet)writer).ProcessOuterElement = _processOuterElement; ((XmlSerializationWriterMetadataSet)writer).Write68_Metadata(objectToSerialize); } - protected override object Deserialize(Microsoft.Xml.Serialization.XmlSerializationReader reader) + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { ((XmlSerializationReaderMetadataSet)reader).ProcessOuterElement = _processOuterElement; return ((XmlSerializationReaderMetadataSet)reader).Read68_Metadata(); } } - internal class XmlSerializerContract : global::Microsoft.Xml.Serialization.XmlSerializerImplementation + internal class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { - public override global::Microsoft.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderMetadataSet(); } } - public override global::Microsoft.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterMetadataSet(); } } + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderMetadataSet(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterMetadataSet(); } } private System.Collections.Hashtable _readMethods = null; public override System.Collections.Hashtable ReadMethods { @@ -1049,7 +1049,7 @@ public override System.Boolean CanSerialize(System.Type type) if (type == typeof(global::System.ServiceModel.Description.MetadataSet)) return true; return false; } - public override Microsoft.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { if (type == typeof(global::System.ServiceModel.Description.MetadataSet)) return new MetadataSetSerializer(); return null; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyAssertionCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyAssertionCollection.cs index bd6d1397c6a..76345e42bda 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyAssertionCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyAssertionCollection.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Description using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.Serialization; - using Microsoft.Xml; + using System.Xml; public class PolicyAssertionCollection : Collection { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyConversionContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyConversionContext.cs index f144f8f7048..79e47f15e89 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyConversionContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyConversionContext.cs @@ -4,7 +4,7 @@ namespace System.ServiceModel.Description { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Channels; using System.Collections; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyReader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyReader.cs index 3b43ba576db..1bb2b6f7a11 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyReader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/PolicyReader.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel.Description using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; - using Microsoft.Xml; + using System.Xml; using WsdlNS = System.Web.Services.Description; using System.Globalization; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SchemaHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SchemaHelper.cs index f8adb3883e2..8abb3476ef2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SchemaHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SchemaHelper.cs @@ -8,8 +8,8 @@ namespace System.ServiceModel.Description using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; internal static class SchemaHelper { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceEndpointCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceEndpointCollection.cs index b322b07e032..387d9ec1d82 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceEndpointCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceEndpointCollection.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceMetadataExtension.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceMetadataExtension.cs index 813e6d62453..5135e8d9d59 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceMetadataExtension.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceMetadataExtension.cs @@ -13,8 +13,8 @@ namespace System.ServiceModel.Description using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using System.Threading; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using WsdlNS = System.Web.Services.Description; // the description/metadata "mix-in" diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceReflector.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceReflector.cs index c87bf74223d..c34270603ac 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceReflector.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/ServiceReflector.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Reflection; using System.Runtime; -using Microsoft.Xml; +using System.Xml; using System.Threading.Tasks; using System.Threading; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SoapHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SoapHelper.cs index 14375d2c613..c0e83e49178 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SoapHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/SoapHelper.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel.Description using System.Collections.Generic; using System.Runtime; using System.ServiceModel.Dispatcher; - using Microsoft.Xml; + using System.Xml; using WsdlNS = System.Web.Services.Description; internal static class SoapHelper diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/TypeLoader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/TypeLoader.cs index 3f17d6aa0ee..23e31b442be 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/TypeLoader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/TypeLoader.cs @@ -13,7 +13,7 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlContractConversionContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlContractConversionContext.cs index 041a192dd29..3266546869a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlContractConversionContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlContractConversionContext.cs @@ -4,11 +4,11 @@ namespace System.ServiceModel.Description { - using Microsoft.Xml; + using System.Xml; using System.ServiceModel.Channels; - using Microsoft.Xml.Schema; + using System.Xml.Schema; using System.Collections.Generic; using System.Collections.ObjectModel; using WsdlNS = System.Web.Services.Description; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlEndpointConversionContext.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlEndpointConversionContext.cs index 4a57f9872a2..05d14570233 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlEndpointConversionContext.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlEndpointConversionContext.cs @@ -6,7 +6,7 @@ namespace System.ServiceModel.Description { using System.IO; using System.ServiceModel.Channels; - using Microsoft.Xml; + using System.Xml; using System.Collections.Generic; using System.Collections.ObjectModel; using WsdlNS = System.Web.Services.Description; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlExporter.cs index 876f15f435c..2f882acdda7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlExporter.cs @@ -11,9 +11,9 @@ namespace System.ServiceModel.Description using System.Runtime; using System.ServiceModel; using System.ServiceModel.Channels; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using WsdlNS = System.Web.Services.Description; public class WsdlExporter : MetadataExporter @@ -458,7 +458,7 @@ private static XmlDocument XmlDoc { if (s_xmlDocument == null) { - Microsoft.Xml.NameTable nameTable = new Microsoft.Xml.NameTable(); + System.Xml.NameTable nameTable = new System.Xml.NameTable(); nameTable.Add(MetadataStrings.WSPolicy.Elements.Policy); nameTable.Add(MetadataStrings.WSPolicy.Elements.All); nameTable.Add(MetadataStrings.WSPolicy.Elements.ExactlyOne); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlImporter.cs index e8afd0e65e3..39917e9648e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/WsdlImporter.cs @@ -13,8 +13,8 @@ namespace System.ServiceModel.Description using System.ServiceModel; using System.ServiceModel.Channels; using System.Text; - using Microsoft.Xml; - using Microsoft.Xml.Schema; + using System.Xml; + using System.Xml.Schema; using WsdlNS = System.Web.Services.Description; using WsdlConfigNS = System.Web.Services.Configuration; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationBehavior.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationBehavior.cs index f62260d4db1..78c7054c1a0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationBehavior.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationBehavior.cs @@ -13,8 +13,8 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; -using Microsoft.Xml; -using Microsoft.Xml.Serialization; +using System.Xml; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; namespace System.ServiceModel.Description { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs index a7f2cf9e0b8..70c2169015e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs @@ -9,7 +9,7 @@ using Microsoft.CodeDom; using System.Globalization; using System.Text; -using Microsoft.Xml.Serialization; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using Microsoft.CodeDom.Compiler; using System.Runtime.Serialization; using System.Reflection; @@ -143,7 +143,7 @@ void IOperationContractGenerationExtension.GenerateOperation(OperationContractGe XmlSerializerFormatAttribute xmlSerializerFormatAttribute = (xmlSerializerOperationBehavior == null) ? new XmlSerializerFormatAttribute() : xmlSerializerOperationBehavior.XmlSerializerFormatAttribute; OperationFormatStyle style = xmlSerializerFormatAttribute.Style; _operationGenerator.GenerateOperation(context, ref style, xmlSerializerFormatAttribute.IsEncoded, new WrappedBodyTypeGenerator(context), new Dictionary>()); - context.ServiceContractGenerator.AddReferencedAssembly(typeof(Microsoft.Xml.Serialization.XmlTypeAttribute).GetTypeInfo().Assembly); + context.ServiceContractGenerator.AddReferencedAssembly(typeof(System.Xml.Serialization.XmlTypeAttribute).GetTypeInfo().Assembly); xmlSerializerFormatAttribute.Style = style; context.SyncMethod.CustomAttributes.Add(OperationGenerator.GenerateAttributeDeclaration(context.Contract.ServiceContractGenerator, xmlSerializerFormatAttribute)); AddKnownTypes(context.SyncMethod.CustomAttributes, xmlSerializerFormatAttribute.IsEncoded ? SoapExporter.IncludeMetadata : XmlExporter.IncludeMetadata); @@ -165,7 +165,12 @@ private void AddKnownTypes(CodeAttributeDeclarationCollection destination, CodeA // Convert [XmlInclude] or [SoapInclude] attribute to [KnownType] attribute private CodeAttributeDeclaration ToKnownType(CodeAttributeDeclaration include) { - if (include.Name == typeof(SoapIncludeAttribute).FullName || include.Name == typeof(XmlIncludeAttribute).FullName) + // [Fix: Attribute Namespace Recognition] + // The SoapImporter now uses standard System.Xml types, so it generates attributes with standard namespaces. + // We must explicitly check for "System.Xml.Serialization.*" strings to recognize them, in addition to the + // internal fork types (which might resolve to Microsoft.Tools... depending on using directives). + if (include.Name == "System.Xml.Serialization.SoapIncludeAttribute" || include.Name == "System.Xml.Serialization.XmlIncludeAttribute" || + include.Name == typeof(SoapIncludeAttribute).FullName || include.Name == typeof(XmlIncludeAttribute).FullName) { CodeAttributeDeclaration knownType = new CodeAttributeDeclaration(new CodeTypeReference(typeof(ServiceKnownTypeAttribute))); foreach (CodeAttributeArgument argument in include.Arguments) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/ActivityIdHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/ActivityIdHeader.cs index 9586aa949cf..bb583951b99 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/ActivityIdHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/ActivityIdHeader.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Runtime; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/EventTraceActivityHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/EventTraceActivityHelper.cs index 15d1131b1fb..7aebd0a6d04 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/EventTraceActivityHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/EventTraceActivityHelper.cs @@ -7,7 +7,7 @@ using System.Runtime.Diagnostics; using System.Security; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageLogger.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageLogger.cs index 3517fff9f53..8268156a655 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageLogger.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageLogger.cs @@ -63,7 +63,7 @@ internal static void LogMessage(ArraySegment arraySegment, MessageLoggingS throw NotImplemented.ByDesign; } - internal static void LogMessage(ref Channels.Message message, Microsoft.Xml.XmlDictionaryReader xmlDictionaryReader, MessageLoggingSource messageLoggingSource) + internal static void LogMessage(ref Channels.Message message, System.Xml.XmlDictionaryReader xmlDictionaryReader, MessageLoggingSource messageLoggingSource) { throw NotImplemented.ByDesign; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTraceRecord.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTraceRecord.cs index a2dcdfaf3f6..54de4f4265f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTraceRecord.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTraceRecord.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Runtime.Diagnostics; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTransmitTraceRecord.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTransmitTraceRecord.cs index a5ee8e21358..a7433a7f4cb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTransmitTraceRecord.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Diagnostics/MessageTransmitTraceRecord.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Diagnostics { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ChannelHandler.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ChannelHandler.cs index d65dd20fdcd..836a456a6be 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ChannelHandler.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ChannelHandler.cs @@ -10,7 +10,7 @@ using System.ServiceModel.Description; using System.ServiceModel.Diagnostics; using System.Threading; -using Microsoft.Xml; +using System.Xml; using SessionIdleManager = System.ServiceModel.Channels.ServiceChannel.SessionIdleManager; namespace System.ServiceModel.Dispatcher diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ClientRuntime.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ClientRuntime.cs index 258fa6d5e33..1ad4db881e4 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ClientRuntime.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/ClientRuntime.cs @@ -11,7 +11,7 @@ using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Security; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Dispatcher { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs index 399dcc7ee03..d71cdd77bd1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs @@ -7,7 +7,7 @@ using System.Runtime.Serialization; using System.ServiceModel.Channels; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; using System.Linq; namespace System.ServiceModel.Dispatcher diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DuplexChannelBinder.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DuplexChannelBinder.cs index d75a889c336..18df8895771 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DuplexChannelBinder.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/DuplexChannelBinder.cs @@ -9,7 +9,7 @@ using System.ServiceModel.Security; using System.Threading; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Dispatcher { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/EndpointAddressProcessor.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/EndpointAddressProcessor.cs index 11495f80c93..5da828c24c6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/EndpointAddressProcessor.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/EndpointAddressProcessor.cs @@ -7,8 +7,8 @@ using System.Runtime; using System.ServiceModel.Channels; using System.Text; -using Microsoft.Xml; -using Microsoft.Xml.Schema; +using System.Xml; +using System.Xml.Schema; namespace System.ServiceModel.Dispatcher { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/FaultFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/FaultFormatter.cs index f17ca73ee09..8e47b3a0d1f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/FaultFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/FaultFormatter.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.ServiceModel.Channels; using System.Runtime.Serialization; -using Microsoft.Xml; +using System.Xml; using System.Runtime; namespace System.ServiceModel.Dispatcher diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/MessageRpc.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/MessageRpc.cs index 132e6099cb6..327ca5bbe26 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/MessageRpc.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/MessageRpc.cs @@ -10,7 +10,7 @@ using System.Security; using System.ServiceModel.Channels; using System.ServiceModel.Diagnostics; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Dispatcher { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/OperationFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/OperationFormatter.cs index 028f8f61a94..f73186be682 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/OperationFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/OperationFormatter.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.Runtime.Serialization; using System.Reflection; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Diagnostics; using System.ServiceModel.Channels; using System.Runtime.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/PrimitiveOperationFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/PrimitiveOperationFormatter.cs index e1e6a053f41..8e0908efa64 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/PrimitiveOperationFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/PrimitiveOperationFormatter.cs @@ -5,7 +5,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Runtime.Serialization; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Diagnostics; using System.Runtime; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/StreamFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/StreamFormatter.cs index a960b790005..b2595b584d9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/StreamFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/StreamFormatter.cs @@ -10,7 +10,7 @@ using System.ServiceModel.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Dispatcher { @@ -365,7 +365,7 @@ public void ReleaseStream(Stream stream) internal class StreamFormatterHelper { // The method was duplicated from the desktop implementation of - // Microsoft.Xml.XmlDictionaryWriter.WriteValue(IStreamProvider) + // System.Xml.XmlDictionaryWriter.WriteValue(IStreamProvider) public static void WriteValue(XmlDictionaryWriter writer, OperationStreamProvider value) { if (value == null) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerFaultFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerFaultFormatter.cs index 937e49df291..8368aa81d5f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerFaultFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerFaultFormatter.cs @@ -3,11 +3,11 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; using System.Text; using System.Reflection; using System.Diagnostics; -using Microsoft.Xml.Serialization; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Runtime.Serialization; using System.Collections.Generic; using System.ServiceModel.Channels; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerObjectSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerObjectSerializer.cs index 845ba4d5b4c..32abe20440b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerObjectSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerObjectSerializer.cs @@ -3,9 +3,9 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel; -using Microsoft.Xml.Serialization; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Collections.Generic; using System.Runtime.Serialization; using System.ServiceModel.Description; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerOperationFormatter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerOperationFormatter.cs index 6579e58a67e..025d8cd9752 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerOperationFormatter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Dispatcher/XmlSerializerOperationFormatter.cs @@ -11,11 +11,11 @@ using System.Diagnostics; using System.Runtime.Serialization; using System.Reflection; -using Microsoft.Xml; -using Microsoft.Xml.Serialization; +using System.Xml; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.ServiceModel.Diagnostics; using System.IO; -using Microsoft.Xml.Schema; +using System.Xml.Schema; namespace System.ServiceModel.Dispatcher { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DnsEndpointIdentity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DnsEndpointIdentity.cs index 5c6d0e7de48..9be94760720 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DnsEndpointIdentity.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/DnsEndpointIdentity.cs @@ -5,8 +5,8 @@ using System; using System.IdentityModel.Claims; using System.IdentityModel.Policy; -using Microsoft.Xml; -using Microsoft.Xml.Serialization; +using System.Xml; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointAddress.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointAddress.cs index 21a080a2eda..6cff6e10ad3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointAddress.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointAddress.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel using System.ComponentModel; using System.Runtime; using System.ServiceModel.Channels; - using Microsoft.Xml; + using System.Xml; public class EndpointAddress { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointIdentity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointIdentity.cs index 829e5d4d054..fdf9ceec1df 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointIdentity.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EndpointIdentity.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IdentityModel.Claims; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EnvelopeVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EnvelopeVersion.cs index 23e5e3db3e3..bccbe11e526 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EnvelopeVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/EnvelopeVersion.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/FederatedMessageSecurityOverHttp.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/FederatedMessageSecurityOverHttp.cs index 920f6040f33..45a1d4008fc 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/FederatedMessageSecurityOverHttp.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/FederatedMessageSecurityOverHttp.cs @@ -11,7 +11,7 @@ namespace System.ServiceModel using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using System.ComponentModel; public sealed class FederatedMessageSecurityOverHttp diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/HttpBindingBase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/HttpBindingBase.cs index 5277b1482e6..86a99867a26 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/HttpBindingBase.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/HttpBindingBase.cs @@ -6,7 +6,7 @@ using System.Runtime; using System.ServiceModel.Channels; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/MustUnderstandSoapException.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/MustUnderstandSoapException.cs index 22b240af411..00792140bcf 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/MustUnderstandSoapException.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/MustUnderstandSoapException.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Globalization; using System.Collections.ObjectModel; using System.ServiceModel.Channels; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpBinding.cs index c76ea2f02b0..8e3cab0a402 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpBinding.cs @@ -7,7 +7,7 @@ using System.Runtime; using System.ServiceModel.Channels; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpsBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpsBinding.cs index 2dc167a45af..90cc5f87d46 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpsBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetHttpsBinding.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetNamedPipeBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetNamedPipeBinding.cs index 2f343756b8b..e096ee0b9f0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetNamedPipeBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetNamedPipeBinding.cs @@ -4,7 +4,7 @@ using System.ComponentModel; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetTcpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetTcpBinding.cs index 9ed8f3b5a5f..cb4cf29ab79 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetTcpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/NetTcpBinding.cs @@ -5,7 +5,7 @@ using System.ComponentModel; using System.Diagnostics.Contracts; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ReliableMessagingVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ReliableMessagingVersion.cs index b0b61b439ad..fc59f3995c8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ReliableMessagingVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ReliableMessagingVersion.cs @@ -5,7 +5,7 @@ namespace System.ServiceModel { using System.ComponentModel; - using Microsoft.Xml; + using System.Xml; //TODO: [TypeConverter(typeof(ReliableMessagingVersionConverter))] public abstract class ReliableMessagingVersion diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/BinaryNegotiation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/BinaryNegotiation.cs index 5d3554c20d1..739ae526559 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/BinaryNegotiation.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/BinaryNegotiation.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ChannelProtectionRequirements.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ChannelProtectionRequirements.cs index e945e8f45ea..d901d156272 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ChannelProtectionRequirements.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ChannelProtectionRequirements.cs @@ -6,7 +6,7 @@ using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedData.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedData.cs index 918a1baa122..1441f3f5694 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedData.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedData.cs @@ -6,7 +6,7 @@ namespace System.ServiceModel.Security { using System.Security.Cryptography; using System.ServiceModel.Channels; - using Microsoft.Xml; + using System.Xml; internal class EncryptedData : EncryptedType { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedKey.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedKey.cs index f9aa80f2449..596aa494c99 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedKey.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedKey.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Security using System.IdentityModel.Tokens; using System.Runtime; using System.Runtime.CompilerServices; - using Microsoft.Xml; + using System.Xml; using DictionaryManager = System.IdentityModel.DictionaryManager; using ISecurityElement = System.IdentityModel.ISecurityElement; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedType.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedType.cs index 84d89ce08da..30b8359fe02 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedType.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/EncryptedType.cs @@ -6,7 +6,7 @@ namespace System.ServiceModel.Security { using System.IdentityModel; using System.Runtime.CompilerServices; - using Microsoft.Xml; + using System.Xml; [TypeForwardedFrom("System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class EncryptedKey : EncryptedType diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/MessagePartSpecification.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/MessagePartSpecification.cs index f95082a6fd4..0747831bd4e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/MessagePartSpecification.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/MessagePartSpecification.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Channels; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/NonceToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/NonceToken.cs index 5ddfb0825d9..716ee53df93 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/NonceToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/NonceToken.cs @@ -12,7 +12,7 @@ namespace System.ServiceModel.Security using System.Security.Cryptography; using System.ServiceModel.Security.Tokens; using System.Text; - using Microsoft.Xml; + using System.Xml; internal sealed class NonceToken : BinarySecretSecurityToken { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReceiveSecurityHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReceiveSecurityHeader.cs index c1720c9df5b..d21dafd49c5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReceiveSecurityHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReceiveSecurityHeader.cs @@ -4,7 +4,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReferenceList.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReferenceList.cs index 01b2cbad166..5edcb7fd7a1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReferenceList.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ReferenceList.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel.Security using System.Collections.Generic; using System.IdentityModel; using System.Runtime.CompilerServices; - using Microsoft.Xml; + using System.Xml; using DictionaryManager = System.IdentityModel.DictionaryManager; using ISecurityElement = System.IdentityModel.ISecurityElement; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityToken.cs index cf5f259ffac..2caf6b32389 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityToken.cs @@ -6,7 +6,7 @@ using System.IdentityModel.Tokens; using System.IdentityModel.Selectors; using System.Runtime.Serialization; -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponse.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponse.cs index 7ef139ab1a5..58a44c016f9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponse.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponse.cs @@ -10,7 +10,7 @@ using System.IO; using System.Runtime.Serialization; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Dispatcher; namespace System.ServiceModel.Security diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponseCollection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponseCollection.cs index 39c38fb4aa4..b738c926ebb 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponseCollection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/RequestSecurityTokenResponseCollection.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Globalization; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ScopedMessagePartSpecification.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ScopedMessagePartSpecification.cs index 4cf7ca944e7..0d97b41877d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ScopedMessagePartSpecification.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/ScopedMessagePartSpecification.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationDriver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationDriver.cs index 83d47cc7f34..5ead6a7b167 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationDriver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationDriver.cs @@ -9,7 +9,7 @@ using System.Runtime.Serialization; using System.Collections.Generic; using System.Diagnostics; -using Microsoft.Xml; +using System.Xml; using System.Security.Principal; namespace System.ServiceModel.Security diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationVersion.cs index 9296a681b49..38249302a3f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecureConversationVersion.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityAlgorithmSuite.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityAlgorithmSuite.cs index 3bcd07d4d1e..ac6b7cfdc68 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityAlgorithmSuite.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityAlgorithmSuite.cs @@ -15,7 +15,7 @@ using System.Text; using System.Runtime.Serialization; -using Microsoft.Xml; +using System.Xml; using System.ComponentModel; namespace System.ServiceModel.Security diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityContextKeyIdentifierClause.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityContextKeyIdentifierClause.cs index fa20d5d932e..be42b719e57 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityContextKeyIdentifierClause.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityContextKeyIdentifierClause.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel.Security using System.Globalization; using System.IdentityModel.Tokens; using System.Runtime.CompilerServices; - using Microsoft.Xml; + using System.Xml; using DiagnosticUtility = /*System.ServiceModel.*/DiagnosticUtility; [TypeForwardedFrom("System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityHeader.cs index 36206ebc164..6742ed54f38 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityHeader.cs @@ -6,7 +6,7 @@ using System.ServiceModel.Channels; using System.ServiceModel; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; using DictionaryManager = System.IdentityModel.DictionaryManager; using ISecurityElement = System.IdentityModel.ISecurityElement; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityStandardsManager.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityStandardsManager.cs index d266c02fb48..8100cb4cd9e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityStandardsManager.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityStandardsManager.cs @@ -11,7 +11,7 @@ using System.IdentityModel.Policy; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; -using Microsoft.Xml; +using System.Xml; using System.Runtime.CompilerServices; namespace System.ServiceModel.Security diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityTimestamp.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityTimestamp.cs index 41b3c038b1f..7983a1530f8 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityTimestamp.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityTimestamp.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.Runtime; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityUtils.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityUtils.cs index b5a83f61050..9fb584e15e6 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityUtils.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityUtils.cs @@ -21,7 +21,7 @@ using System.ServiceModel.Security.Tokens; using System.Text; using System.Threading; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityVersion.cs index 76858d5b19e..427b52471fd 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SecurityVersion.cs @@ -4,7 +4,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; using ISignatureValueSecurityElement = System.IdentityModel.ISignatureValueSecurityElement; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SendSecurityHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SendSecurityHeader.cs index 8aa1325761d..bb65fabb0a9 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SendSecurityHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SendSecurityHeader.cs @@ -4,7 +4,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureConfirmationElement.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureConfirmationElement.cs index 83f8e7bce90..2906826c3f1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureConfirmationElement.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureConfirmationElement.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureTargetIdManager.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureTargetIdManager.cs index 66d0bf9fe60..813305ce536 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureTargetIdManager.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/SignatureTargetIdManager.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/DerivedKeySecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/DerivedKeySecurityToken.cs index 868fdd3abab..8edab155301 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/DerivedKeySecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/DerivedKeySecurityToken.cs @@ -14,7 +14,7 @@ using System.IdentityModel.Selectors; using System.Security.Cryptography; using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security.Tokens { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/GenericXmlSecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/GenericXmlSecurityToken.cs index c0d42cbf9e9..4c50b4ba06c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/GenericXmlSecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/GenericXmlSecurityToken.cs @@ -12,7 +12,7 @@ namespace System.IdentityModel.Tokens using System.IdentityModel.Policy; using System.Security.Cryptography; using System.Security.Principal; - using Microsoft.Xml; + using System.Xml; using System.Runtime.Serialization; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/ISecurityContextSecurityTokenCache.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/ISecurityContextSecurityTokenCache.cs index aae72cb9af1..aaaaff172e3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/ISecurityContextSecurityTokenCache.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/ISecurityContextSecurityTokenCache.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections.ObjectModel; namespace System.ServiceModel.Security.Tokens diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/IssuedSecurityTokenParameters.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/IssuedSecurityTokenParameters.cs index 170cac1b552..6f22f251ae7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/IssuedSecurityTokenParameters.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/IssuedSecurityTokenParameters.cs @@ -14,7 +14,7 @@ namespace System.ServiceModel.Security.Tokens using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.Text; - using Microsoft.Xml; + using System.Xml; public class IssuedSecurityTokenParameters : SecurityTokenParameters { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextCookieSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextCookieSerializer.cs index 628d2534086..63f1b342ef3 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextCookieSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextCookieSerializer.cs @@ -12,7 +12,7 @@ using System.Security.Principal; using System.ServiceModel; using System.ServiceModel.Dispatcher; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security.Tokens { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextSecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextSecurityToken.cs index 880c332c17b..c08aca41a0c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextSecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/SecurityContextSecurityToken.cs @@ -8,7 +8,7 @@ using System.Globalization; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security.Tokens { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/WrappedKeySecurityToken.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/WrappedKeySecurityToken.cs index 813d5c875f8..3b2eabe29ac 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/WrappedKeySecurityToken.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/Tokens/WrappedKeySecurityToken.cs @@ -10,7 +10,7 @@ namespace System.ServiceModel.Security.Tokens using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; [TypeForwardedFrom("System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class WrappedKeySecurityToken : SecurityToken diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustDriver.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustDriver.cs index bfde3211029..6a3d10ce449 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustDriver.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustDriver.cs @@ -18,7 +18,7 @@ using System.Security.Cryptography; using System.ServiceModel.Security.Tokens; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustVersion.cs index ee8002375cb..82a97e24b4d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/TrustVersion.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSKeyInfoSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSKeyInfoSerializer.cs index 071446fa3ab..df6edf3ce0e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSKeyInfoSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSKeyInfoSerializer.cs @@ -7,7 +7,7 @@ using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; using System.ServiceModel.Security.Tokens; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { @@ -142,8 +142,8 @@ public override bool CanReadClause(XmlDictionaryReader reader, string tokenType) public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, int derivationLength, string tokenType) { - Microsoft.Xml.UniqueId uri = XmlHelper.GetAttributeAsUniqueId(reader, XD.SecurityJan2004Dictionary.URI, null); - Microsoft.Xml.UniqueId generation = ReadGeneration(reader); + System.Xml.UniqueId uri = XmlHelper.GetAttributeAsUniqueId(reader, XD.SecurityJan2004Dictionary.URI, null); + System.Xml.UniqueId generation = ReadGeneration(reader); if (reader.IsEmptyElement) { @@ -162,7 +162,7 @@ public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reade return new SecurityContextKeyIdentifierClause(uri, generation, derivationNonce, derivationLength); } - protected abstract Microsoft.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader); + protected abstract System.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader); public override bool SupportsCore(SecurityKeyIdentifierClause clause) { @@ -265,7 +265,7 @@ public SctStrEntryFeb2005(WSSecureConversationFeb2005 parent) { } - protected override Microsoft.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader) + protected override System.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader) { return XmlHelper.GetAttributeAsUniqueId( reader, @@ -321,7 +321,7 @@ public SctStrEntryDec2005(WSSecureConversationDec2005 parent) { } - protected override Microsoft.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader) + protected override System.Xml.UniqueId ReadGeneration(XmlDictionaryReader reader) { return XmlHelper.GetAttributeAsUniqueId(reader, this.Parent.SecurityTokenSerializer.DictionaryManager.SecureConversationDec2005Dictionary.Instance, this.Parent.SecurityTokenSerializer.DictionaryManager.SecureConversationDec2005Dictionary.Namespace); diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversation.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversation.cs index 546474651e9..202a090e5ce 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversation.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversation.cs @@ -11,7 +11,7 @@ namespace System.ServiceModel.Security using System.Runtime; using System.ServiceModel; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; using StrEntry = WSSecurityTokenSerializer.StrEntry; using TokenEntry = WSSecurityTokenSerializer.TokenEntry; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationDec2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationDec2005.cs index 34943fdeebd..9de53b3323c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationDec2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationDec2005.cs @@ -13,7 +13,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationFeb2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationFeb2005.cs index 52e221cbf5e..fd121c1b056 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationFeb2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecureConversationFeb2005.cs @@ -13,7 +13,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityJan2004.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityJan2004.cs index beaf5e92edf..e68c140d479 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityJan2004.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityJan2004.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel.Security using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; using System.Text; - using Microsoft.Xml; + using System.Xml; //using HexBinary = System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary; using KeyIdentifierClauseEntry = WSSecurityTokenSerializer.KeyIdentifierClauseEntry; using StrEntry = WSSecurityTokenSerializer.StrEntry; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneReceiveSecurityHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneReceiveSecurityHeader.cs index 8341b66dc2b..7a9adae8ad0 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneReceiveSecurityHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneReceiveSecurityHeader.cs @@ -8,7 +8,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Security.Tokens; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneSendSecurityHeader.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneSendSecurityHeader.cs index f2adae76ef8..5da9099808a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneSendSecurityHeader.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityOneDotOneSendSecurityHeader.cs @@ -11,7 +11,7 @@ using System.IdentityModel.Tokens; using System.Security.Cryptography; using System.ServiceModel.Security.Tokens; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Diagnostics; using ISignatureValueSecurityElement = System.IdentityModel.ISignatureValueSecurityElement; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy.cs index 72ceba805ba..f895b52aebe 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy.cs @@ -12,7 +12,7 @@ namespace System.ServiceModel.Security using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Security.Tokens; - using Microsoft.Xml; + using System.Xml; internal abstract class WSSecurityPolicy { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy11.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy11.cs index c967b438341..84c51269608 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy11.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy11.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel.Security using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Description; - using Microsoft.Xml; + using System.Xml; internal class WSSecurityPolicy11 : WSSecurityPolicy { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy12.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy12.cs index ccfe203a3f5..a233b83dc65 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy12.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityPolicy12.cs @@ -13,7 +13,7 @@ namespace System.ServiceModel.Security using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; using System.Text; - using Microsoft.Xml; + using System.Xml; internal class WSSecurityPolicy12 : WSSecurityPolicy { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityTokenSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityTokenSerializer.cs index 99bfe438939..d140848ebad 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityTokenSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityTokenSerializer.cs @@ -8,7 +8,7 @@ using System.Runtime; using System.ServiceModel; using System.ServiceModel.Security.Tokens; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Diagnostics; using System.Diagnostics; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityXXX2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityXXX2005.cs index af1111d4a53..3b962d03a3d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityXXX2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSSecurityXXX2005.cs @@ -13,7 +13,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrust.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrust.cs index a01daf61e46..6bc38ef3a23 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrust.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrust.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.Runtime; using System.Security.Cryptography; using System.IdentityModel.Claims; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustDec2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustDec2005.cs index 87abd733b57..9771ce1bcec 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustDec2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustDec2005.cs @@ -15,7 +15,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustFeb2005.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustFeb2005.cs index 8801cbc55fb..af8c9fffb5c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustFeb2005.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSTrustFeb2005.cs @@ -15,7 +15,7 @@ namespace System.ServiceModel.Security using System.IO; using System.Text; using System.Threading; - using Microsoft.Xml; + using System.Xml; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSUtilitySpecificationVersion.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSUtilitySpecificationVersion.cs index e4983b5666f..532a8425f60 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSUtilitySpecificationVersion.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/WSUtilitySpecificationVersion.cs @@ -14,7 +14,7 @@ namespace System.ServiceModel.Security using System.Globalization; using System.ServiceModel.Diagnostics; using System.Text; - using Microsoft.Xml; + using System.Xml; using CanonicalFormWriter = System.IdentityModel.CanonicalFormWriter; using SignatureResourcePool = System.IdentityModel.SignatureResourcePool; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/XmlHelper.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/XmlHelper.cs index 9235058a0b9..8f2b5e29999 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/XmlHelper.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Security/XmlHelper.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Text; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel.Security { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ServiceModelDictionary.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ServiceModelDictionary.cs index 079b5ecc9af..8e000530c7f 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ServiceModelDictionary.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/ServiceModelDictionary.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml; +using System.Xml; using System.Collections.Generic; namespace System.ServiceModel diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/SpnEndpointIdentity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/SpnEndpointIdentity.cs index 0465fa39d42..62243dd7738 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/SpnEndpointIdentity.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/SpnEndpointIdentity.cs @@ -7,7 +7,7 @@ namespace System.ServiceModel using System; using System.IdentityModel.Claims; - using Microsoft.Xml; + using System.Xml; public class SpnEndpointIdentity : EndpointIdentity { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UdpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UdpBinding.cs index 17e203af29d..6cfa09c0178 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UdpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UdpBinding.cs @@ -9,7 +9,7 @@ namespace System.ServiceModel using System.Runtime; using System.ServiceModel.Channels; using System.Text; - using Microsoft.Xml; + using System.Xml; public class UdpBinding : Binding, IBindingRuntimePreferences { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UpnEndpointIdentity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UpnEndpointIdentity.cs index ec87893a63f..1212f2270b4 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UpnEndpointIdentity.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/UpnEndpointIdentity.cs @@ -14,7 +14,7 @@ namespace System.ServiceModel // using System.ServiceModel.ComIntegration; using System.ServiceModel.Diagnostics; using System.Text; - using Microsoft.Xml; + using System.Xml; public class UpnEndpointIdentity : EndpointIdentity { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007FederationHttpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007FederationHttpBinding.cs index 71317fd0156..1e81bb76eb5 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007FederationHttpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007FederationHttpBinding.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel using System.ServiceModel.Channels; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public class WS2007FederationHttpBinding : WSFederationHttpBinding { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007HttpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007HttpBinding.cs index 414e8411bc0..663b6fdbb2d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007HttpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WS2007HttpBinding.cs @@ -15,7 +15,7 @@ namespace System.ServiceModel using System.Security.Principal; using System.ServiceModel.Channels; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public class WS2007HttpBinding : WSHttpBinding { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSAddressing10ProblemHeaderQNameFault.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSAddressing10ProblemHeaderQNameFault.cs index 8cda120839c..a8ac81fd5ba 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSAddressing10ProblemHeaderQNameFault.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSAddressing10ProblemHeaderQNameFault.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Globalization; -using Microsoft.Xml; +using System.Xml; using System.ServiceModel.Channels; namespace System.ServiceModel diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSFederationHttpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSFederationHttpBinding.cs index c3e222cd69a..0afc0edfd0a 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSFederationHttpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSFederationHttpBinding.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel using System.ServiceModel.Channels; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; using System.ComponentModel; public class WSFederationHttpBinding : WSHttpBindingBase diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBinding.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBinding.cs index 43bf282e30f..a254fe15aae 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBinding.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBinding.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel using System.Security.Principal; using System.ServiceModel.Channels; using System.ServiceModel.Security; - using Microsoft.Xml; + using System.Xml; public class WSHttpBinding : WSHttpBindingBase { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBindingBase.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBindingBase.cs index 8109f65aa51..7b7be87c79b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBindingBase.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/WSHttpBindingBase.cs @@ -16,7 +16,7 @@ namespace System.ServiceModel using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ComponentModel; - using Microsoft.Xml; + using System.Xml; public abstract class WSHttpBindingBase : Binding, IBindingRuntimePreferences { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/X509CertificateEndpointIdentity.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/X509CertificateEndpointIdentity.cs index dcbc8bc581e..26c7d3727f7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/X509CertificateEndpointIdentity.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/X509CertificateEndpointIdentity.cs @@ -9,8 +9,8 @@ namespace System.ServiceModel using System.IdentityModel.Policy; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; public class X509CertificateEndpointIdentity : EndpointIdentity { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XD.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XD.cs index fd68e274ac5..b4da9daf08b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XD.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XD.cs @@ -4,7 +4,7 @@ // NOTE: this file was generated from 'xd.xml' -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlBuffer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlBuffer.cs index af71391d374..8445678a333 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlBuffer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlBuffer.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Runtime; using System.ServiceModel.Channels; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlUtil.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlUtil.cs index 6c232886393..d55109e29b2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlUtil.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/XmlUtil.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Globalization; using System.Runtime; -using Microsoft.Xml; +using System.Xml; namespace System.ServiceModel { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs index 1502254717e..3262069fc87 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs @@ -9,7 +9,7 @@ namespace System.Web.Services.Configuration using System.Collections.Generic; using System.Reflection; using System.Web.Services.Description; - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; public sealed class WebServicesSection { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs index f197ab6ed8e..c19adcd1812 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs @@ -4,7 +4,7 @@ namespace System.Web.Services.Description { - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Web.Services.Configuration; /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs index 3c20d67a7a7..5ec42c806db 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs @@ -4,7 +4,7 @@ namespace System.Web.Services.Description { - using Microsoft.Xml.Serialization; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Collections; using System.ComponentModel; using System.Web.Services.Configuration; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs index 56c63448156..6cd6c90deee 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Xml.Serialization; -using Microsoft.Xml.Schema; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; +using System.Xml.Schema; using System.Collections; using System.Collections.Specialized; using System; -using Microsoft.Xml; +using System.Xml; using System.IO; using System.Reflection; using System.ComponentModel; @@ -248,7 +248,7 @@ protected override XmlSerializationWriter CreateWriter() { return new ServiceDescriptionSerializationWriter(); } - public override bool CanDeserialize(Microsoft.Xml.XmlReader xmlReader) + public override bool CanDeserialize(System.Xml.XmlReader xmlReader) { return xmlReader.IsStartElement("definitions", ServiceDescription.Namespace); } @@ -674,7 +674,7 @@ public XmlElement DocumentationElement } [XmlAnyAttribute] - public Microsoft.Xml.XmlAttribute[] ExtensibleAttributes + public System.Xml.XmlAttribute[] ExtensibleAttributes { get { diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs index 83da384be4b..f9157fb5e23 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs @@ -6,8 +6,8 @@ namespace System.Web.Services.Description { using System.Web.Services; using System.Web.Services.Protocols; - using Microsoft.Xml.Serialization; - using Microsoft.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; + using System.Xml.Schema; using System.Collections; using System.Collections.Specialized; using System.Collections.Generic; @@ -15,7 +15,7 @@ namespace System.Web.Services.Description using System.Reflection; using Microsoft.CodeDom.Compiler; using System.Web.Services.Configuration; - using Microsoft.Xml; + using System.Xml; using Microsoft.CodeDom; using System.Globalization; using System.Runtime.InteropServices; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs index 5f0c6bb0986..9d0371a593c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs @@ -4,7 +4,7 @@ namespace System.Web.Services.Description { - internal class ServiceDescriptionSerializationWriter : Microsoft.Xml.Serialization.XmlSerializationWriter + internal class ServiceDescriptionSerializationWriter : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationWriter { public void Write125_definitions(object o) { @@ -39,21 +39,21 @@ private void Write124_ServiceDescription(string n, string ns, global::System.Web WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"ServiceDescription", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); WriteAttribute(@"targetNamespace", @"", ((global::System.String)o.@TargetNamespace)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -65,9 +65,9 @@ private void Write124_ServiceDescription(string n, string ns, global::System.Web { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -151,20 +151,20 @@ private void Write123_Service(string n, string ns, global::System.Web.Services.D WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Service", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -176,9 +176,9 @@ private void Write123_Service(string n, string ns, global::System.Web.Services.D { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -221,21 +221,21 @@ private void Write122_Port(string n, string ns, global::System.Web.Services.Desc WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Port", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"binding", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Binding))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"binding", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Binding))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -261,12 +261,12 @@ private void Write122_Port(string n, string ns, global::System.Web.Services.Desc { Write119_SoapAddressBinding(@"address", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapAddressBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -309,7 +309,7 @@ private void Write119_SoapAddressBinding(string n, string ns, global::System.Web if (needType) WriteXsiType(@"SoapAddressBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); WriteEndElement(o); @@ -337,7 +337,7 @@ private void Write118_HttpAddressBinding(string n, string ns, global::System.Web if (needType) WriteXsiType(@"HttpAddressBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); WriteEndElement(o); @@ -365,7 +365,7 @@ private void Write121_Soap12AddressBinding(string n, string ns, global::System.W if (needType) WriteXsiType(@"Soap12AddressBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); WriteEndElement(o); @@ -392,21 +392,21 @@ private void Write117_Binding(string n, string ns, global::System.Web.Services.D WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Binding", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Type))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Type))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -432,12 +432,12 @@ private void Write117_Binding(string n, string ns, global::System.Web.Services.D { Write80_SoapBinding(@"binding", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -489,20 +489,20 @@ private void Write116_OperationBinding(string n, string ns, global::System.Web.S WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"OperationBinding", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -528,12 +528,12 @@ private void Write116_OperationBinding(string n, string ns, global::System.Web.S { Write86_SoapOperationBinding(@"operation", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapOperationBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -587,20 +587,20 @@ private void Write115_FaultBinding(string n, string ns, global::System.Web.Servi WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"FaultBinding", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -622,12 +622,12 @@ private void Write115_FaultBinding(string n, string ns, global::System.Web.Servi { Write112_SoapFaultBinding(@"fault", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapFaultBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -670,7 +670,7 @@ private void Write112_SoapFaultBinding(string n, string ns, global::System.Web.S if (needType) WriteXsiType(@"SoapFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -719,7 +719,7 @@ private void Write114_Soap12FaultBinding(string n, string ns, global::System.Web if (needType) WriteXsiType(@"Soap12FaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -767,20 +767,20 @@ private void Write111_OutputBinding(string n, string ns, global::System.Web.Serv WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"OutputBinding", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -826,12 +826,12 @@ private void Write111_OutputBinding(string n, string ns, global::System.Web.Serv { Write104_MimeMultipartRelatedBinding(@"multipartRelated", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeMultipartRelatedBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -874,7 +874,7 @@ private void Write104_MimeMultipartRelatedBinding(string n, string ns, global::S if (needType) WriteXsiType(@"MimeMultipartRelatedBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } { global::System.Web.Services.Description.MimePartCollection a = (global::System.Web.Services.Description.MimePartCollection)o.@Parts; @@ -911,7 +911,7 @@ private void Write103_MimePart(string n, string ns, global::System.Web.Services. if (needType) WriteXsiType(@"MimePart", @"http://schemas.xmlsoap.org/wsdl/mime/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } { global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; @@ -941,12 +941,12 @@ private void Write103_MimePart(string n, string ns, global::System.Web.Services. { Write97_MimeTextBinding(@"text", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -989,7 +989,7 @@ private void Write97_MimeTextBinding(string n, string ns, global::System.Web.Ser if (needType) WriteXsiType(@"MimeTextBinding", @"http://microsoft.com/wsdl/mime/textMatching/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } { global::System.Web.Services.Description.MimeTextMatchCollection a = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; @@ -1028,18 +1028,18 @@ private void Write96_MimeTextMatch(string n, string ns, global::System.Web.Servi WriteAttribute(@"type", @"", ((global::System.String)o.@Type)); if (((global::System.Int32)o.@Group) != 1) { - WriteAttribute(@"group", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Group))); + WriteAttribute(@"group", @"", System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Group))); } if (((global::System.Int32)o.@Capture) != 0) { - WriteAttribute(@"capture", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Capture))); + WriteAttribute(@"capture", @"", System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Capture))); } if (((global::System.String)o.@RepeatsString) != @"1") { WriteAttribute(@"repeats", @"", ((global::System.String)o.@RepeatsString)); } WriteAttribute(@"pattern", @"", ((global::System.String)o.@Pattern)); - WriteAttribute(@"ignoreCase", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IgnoreCase))); + WriteAttribute(@"ignoreCase", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IgnoreCase))); { global::System.Web.Services.Description.MimeTextMatchCollection a = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; if (a != null) @@ -1075,7 +1075,7 @@ private void Write94_MimeXmlBinding(string n, string ns, global::System.Web.Serv if (needType) WriteXsiType(@"MimeXmlBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); WriteEndElement(o); @@ -1103,7 +1103,7 @@ private void Write93_MimeContentBinding(string n, string ns, global::System.Web. if (needType) WriteXsiType(@"MimeContentBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); WriteAttribute(@"type", @"", ((global::System.String)o.@Type)); @@ -1132,7 +1132,7 @@ private void Write99_SoapBodyBinding(string n, string ns, global::System.Web.Ser if (needType) WriteXsiType(@"SoapBodyBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1172,7 +1172,7 @@ private void Write102_Soap12BodyBinding(string n, string ns, global::System.Web. if (needType) WriteXsiType(@"Soap12BodyBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1212,9 +1212,9 @@ private void Write106_SoapHeaderBinding(string n, string ns, global::System.Web. if (needType) WriteXsiType(@"SoapHeaderBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1254,9 +1254,9 @@ private void Write105_SoapHeaderFaultBinding(string n, string ns, global::System if (needType) WriteXsiType(@"SoapHeaderFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1295,9 +1295,9 @@ private void Write109_Soap12HeaderBinding(string n, string ns, global::System.We if (needType) WriteXsiType(@"Soap12HeaderBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1337,9 +1337,9 @@ private void Write107_SoapHeaderFaultBinding(string n, string ns, global::System if (needType) WriteXsiType(@"SoapHeaderFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) { @@ -1377,20 +1377,20 @@ private void Write110_InputBinding(string n, string ns, global::System.Web.Servi WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"InputBinding", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -1444,12 +1444,12 @@ private void Write110_InputBinding(string n, string ns, global::System.Web.Servi { Write94_MimeXmlBinding(@"mimeXml", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeXmlBinding)ai), false, false); } - else if (ai is Microsoft.Xml.XmlElement) + else if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { @@ -1492,7 +1492,7 @@ private void Write90_HttpUrlEncodedBinding(string n, string ns, global::System.W if (needType) WriteXsiType(@"HttpUrlEncodedBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteEndElement(o); } @@ -1519,7 +1519,7 @@ private void Write91_HttpUrlReplacementBinding(string n, string ns, global::Syst if (needType) WriteXsiType(@"HttpUrlReplacementBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteEndElement(o); } @@ -1546,7 +1546,7 @@ private void Write86_SoapOperationBinding(string n, string ns, global::System.We if (needType) WriteXsiType(@"SoapOperationBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"soapAction", @"", ((global::System.String)o.@SoapAction)); if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Default) @@ -1590,7 +1590,7 @@ private void Write85_HttpOperationBinding(string n, string ns, global::System.We if (needType) WriteXsiType(@"HttpOperationBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); WriteEndElement(o); @@ -1618,7 +1618,7 @@ private void Write88_Soap12OperationBinding(string n, string ns, global::System. if (needType) WriteXsiType(@"Soap12OperationBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"soapAction", @"", ((global::System.String)o.@SoapAction)); if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Default) @@ -1627,7 +1627,7 @@ private void Write88_Soap12OperationBinding(string n, string ns, global::System. } if (((global::System.Boolean)o.@SoapActionRequired) != false) { - WriteAttribute(@"soapActionRequired", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@SoapActionRequired))); + WriteAttribute(@"soapActionRequired", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@SoapActionRequired))); } WriteEndElement(o); } @@ -1666,7 +1666,7 @@ private void Write80_SoapBinding(string n, string ns, global::System.Web.Service if (needType) WriteXsiType(@"SoapBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"transport", @"", ((global::System.String)o.@Transport)); if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Document) @@ -1698,7 +1698,7 @@ private void Write77_HttpBinding(string n, string ns, global::System.Web.Service if (needType) WriteXsiType(@"HttpBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"verb", @"", ((global::System.String)o.@Verb)); WriteEndElement(o); @@ -1726,7 +1726,7 @@ private void Write84_Soap12Binding(string n, string ns, global::System.Web.Servi if (needType) WriteXsiType(@"Soap12Binding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); if (((global::System.Boolean)o.@Required) != false) { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); + WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); } WriteAttribute(@"transport", @"", ((global::System.String)o.@Transport)); if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Document) @@ -1757,20 +1757,20 @@ private void Write75_PortType(string n, string ns, global::System.Web.Services.D WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"PortType", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -1782,9 +1782,9 @@ private void Write75_PortType(string n, string ns, global::System.Web.Services.D { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -1827,12 +1827,12 @@ private void Write74_Operation(string n, string ns, global::System.Web.Services. WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Operation", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -1842,9 +1842,9 @@ private void Write74_Operation(string n, string ns, global::System.Web.Services. { WriteAttribute(@"parameterOrder", @"", ((global::System.String)o.@ParameterOrderString)); } - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -1856,9 +1856,9 @@ private void Write74_Operation(string n, string ns, global::System.Web.Services. { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -1928,21 +1928,21 @@ private void Write73_OperationFault(string n, string ns, global::System.Web.Serv WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"OperationFault", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -1954,9 +1954,9 @@ private void Write73_OperationFault(string n, string ns, global::System.Web.Serv { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -1989,21 +1989,21 @@ private void Write71_OperationInput(string n, string ns, global::System.Web.Serv WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"OperationInput", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -2015,9 +2015,9 @@ private void Write71_OperationInput(string n, string ns, global::System.Web.Serv { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -2050,21 +2050,21 @@ private void Write72_OperationOutput(string n, string ns, global::System.Web.Ser WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"OperationOutput", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -2076,9 +2076,9 @@ private void Write72_OperationOutput(string n, string ns, global::System.Web.Ser { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -2111,20 +2111,20 @@ private void Write69_Message(string n, string ns, global::System.Web.Services.De WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Message", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -2136,9 +2136,9 @@ private void Write69_Message(string n, string ns, global::System.Web.Services.De { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -2181,22 +2181,22 @@ private void Write68_MessagePart(string n, string ns, global::System.Web.Service WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"MessagePart", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"element", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Element))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Type))); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + WriteAttribute(@"element", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Element))); + WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Type))); + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -2208,9 +2208,9 @@ private void Write68_MessagePart(string n, string ns, global::System.Web.Service { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -2243,19 +2243,19 @@ private void Write67_Types(string n, string ns, global::System.Web.Services.Desc WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Types", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -2267,9 +2267,9 @@ private void Write67_Types(string n, string ns, global::System.Web.Services.Desc { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -2279,19 +2279,19 @@ private void Write67_Types(string n, string ns, global::System.Web.Services.Desc } } { - Microsoft.Xml.Serialization.XmlSchemas a = (Microsoft.Xml.Serialization.XmlSchemas)o.@Schemas; + System.Xml.Serialization.XmlSchemas a = (System.Xml.Serialization.XmlSchemas)o.@Schemas; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write66_XmlSchema(@"schema", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchema)a[ia]), false, false); + Write66_XmlSchema(@"schema", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchema)a[ia]), false, false); } } } WriteEndElement(o); } - private void Write66_XmlSchema(string n, string ns, Microsoft.Xml.Schema.XmlSchema o, bool isNullable, bool needType) + private void Write66_XmlSchema(string n, string ns, System.Xml.Schema.XmlSchema o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2301,7 +2301,7 @@ private void Write66_XmlSchema(string n, string ns, Microsoft.Xml.Schema.XmlSche if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchema)) + if (t == typeof(System.Xml.Schema.XmlSchema)) { } else @@ -2312,55 +2312,55 @@ private void Write66_XmlSchema(string n, string ns, Microsoft.Xml.Schema.XmlSche EscapeName = false; WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"XmlSchema", @"http://www.w3.org/2001/XMLSchema"); - if (((Microsoft.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault) != Microsoft.Xml.Schema.XmlSchemaForm.@None) + if (((System.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault) != System.Xml.Schema.XmlSchemaForm.@None) { - WriteAttribute(@"attributeFormDefault", @"", Write6_XmlSchemaForm(((Microsoft.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault))); + WriteAttribute(@"attributeFormDefault", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault))); } - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"blockDefault", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault))); + WriteAttribute(@"blockDefault", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault))); } - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"finalDefault", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault))); + WriteAttribute(@"finalDefault", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault))); } - if (((Microsoft.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault) != Microsoft.Xml.Schema.XmlSchemaForm.@None) + if (((System.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault) != System.Xml.Schema.XmlSchemaForm.@None) { - WriteAttribute(@"elementFormDefault", @"", Write6_XmlSchemaForm(((Microsoft.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault))); + WriteAttribute(@"elementFormDefault", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault))); } WriteAttribute(@"targetNamespace", @"", ((global::System.String)o.@TargetNamespace)); WriteAttribute(@"version", @"", ((global::System.String)o.@Version)); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaRedefine) + if (ai is System.Xml.Schema.XmlSchemaRedefine) { - Write64_XmlSchemaRedefine(@"redefine", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaRedefine)ai), false, false); + Write64_XmlSchemaRedefine(@"redefine", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaRedefine)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaImport) + else if (ai is System.Xml.Schema.XmlSchemaImport) { - Write13_XmlSchemaImport(@"import", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaImport)ai), false, false); + Write13_XmlSchemaImport(@"import", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaImport)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaInclude) + else if (ai is System.Xml.Schema.XmlSchemaInclude) { - Write12_XmlSchemaInclude(@"include", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaInclude)ai), false, false); + Write12_XmlSchemaInclude(@"include", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaInclude)ai), false, false); } else { @@ -2374,44 +2374,44 @@ private void Write66_XmlSchema(string n, string ns, Microsoft.Xml.Schema.XmlSche } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaElement) + if (ai is System.Xml.Schema.XmlSchemaElement) { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaElement)ai), false, false); + Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaComplexType) + else if (ai is System.Xml.Schema.XmlSchemaComplexType) { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexType)ai), false, false); + Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaSimpleType) + else if (ai is System.Xml.Schema.XmlSchemaSimpleType) { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)ai), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + else if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroup) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroup) { - Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); + Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaNotation) + else if (ai is System.Xml.Schema.XmlSchemaNotation) { - Write65_XmlSchemaNotation(@"notation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaNotation)ai), false, false); + Write65_XmlSchemaNotation(@"notation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaNotation)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaGroup) + else if (ai is System.Xml.Schema.XmlSchemaGroup) { - Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroup)ai), false, false); + Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroup)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAnnotation) + else if (ai is System.Xml.Schema.XmlSchemaAnnotation) { - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)ai), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)ai), false, false); } else { @@ -2427,7 +2427,7 @@ private void Write66_XmlSchema(string n, string ns, Microsoft.Xml.Schema.XmlSche WriteEndElement(o); } - private void Write11_XmlSchemaAnnotation(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAnnotation o, bool isNullable, bool needType) + private void Write11_XmlSchemaAnnotation(string n, string ns, System.Xml.Schema.XmlSchemaAnnotation o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2437,7 +2437,7 @@ private void Write11_XmlSchemaAnnotation(string n, string ns, Microsoft.Xml.Sche if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAnnotation)) + if (t == typeof(System.Xml.Schema.XmlSchemaAnnotation)) { } else @@ -2450,31 +2450,31 @@ private void Write11_XmlSchemaAnnotation(string n, string ns, Microsoft.Xml.Sche if (needType) WriteXsiType(@"XmlSchemaAnnotation", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAppInfo) + if (ai is System.Xml.Schema.XmlSchemaAppInfo) { - Write10_XmlSchemaAppInfo(@"appinfo", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAppInfo)ai), false, false); + Write10_XmlSchemaAppInfo(@"appinfo", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAppInfo)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaDocumentation) + else if (ai is System.Xml.Schema.XmlSchemaDocumentation) { - Write9_XmlSchemaDocumentation(@"documentation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaDocumentation)ai), false, false); + Write9_XmlSchemaDocumentation(@"documentation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaDocumentation)ai), false, false); } else { @@ -2490,7 +2490,7 @@ private void Write11_XmlSchemaAnnotation(string n, string ns, Microsoft.Xml.Sche WriteEndElement(o); } - private void Write9_XmlSchemaDocumentation(string n, string ns, Microsoft.Xml.Schema.XmlSchemaDocumentation o, bool isNullable, bool needType) + private void Write9_XmlSchemaDocumentation(string n, string ns, System.Xml.Schema.XmlSchemaDocumentation o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2500,7 +2500,7 @@ private void Write9_XmlSchemaDocumentation(string n, string ns, Microsoft.Xml.Sc if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaDocumentation)) + if (t == typeof(System.Xml.Schema.XmlSchemaDocumentation)) { } else @@ -2514,28 +2514,28 @@ private void Write9_XmlSchemaDocumentation(string n, string ns, Microsoft.Xml.Sc WriteAttribute(@"source", @"", ((global::System.String)o.@Source)); WriteAttribute(@"lang", @"http://www.w3.org/XML/1998/namespace", ((global::System.String)o.@Language)); { - Microsoft.Xml.XmlNode[] a = (Microsoft.Xml.XmlNode[])o.@Markup; + System.Xml.XmlNode[] a = (System.Xml.XmlNode[])o.@Markup; if (a != null) { for (int ia = 0; ia < a.Length; ia++) { - Microsoft.Xml.XmlNode ai = (Microsoft.Xml.XmlNode)a[ia]; + System.Xml.XmlNode ai = (System.Xml.XmlNode)a[ia]; { - if (ai is Microsoft.Xml.XmlElement) + if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { throw CreateInvalidAnyTypeException(elem); } } - else if (ai is Microsoft.Xml.XmlNode) + else if (ai is System.Xml.XmlNode) { - ((Microsoft.Xml.XmlNode)ai).WriteTo(Writer); + ((System.Xml.XmlNode)ai).WriteTo(Writer); } else { @@ -2551,7 +2551,7 @@ private void Write9_XmlSchemaDocumentation(string n, string ns, Microsoft.Xml.Sc WriteEndElement(o); } - private void Write10_XmlSchemaAppInfo(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAppInfo o, bool isNullable, bool needType) + private void Write10_XmlSchemaAppInfo(string n, string ns, System.Xml.Schema.XmlSchemaAppInfo o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2561,7 +2561,7 @@ private void Write10_XmlSchemaAppInfo(string n, string ns, Microsoft.Xml.Schema. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAppInfo)) + if (t == typeof(System.Xml.Schema.XmlSchemaAppInfo)) { } else @@ -2574,28 +2574,28 @@ private void Write10_XmlSchemaAppInfo(string n, string ns, Microsoft.Xml.Schema. if (needType) WriteXsiType(@"XmlSchemaAppInfo", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"source", @"", ((global::System.String)o.@Source)); { - Microsoft.Xml.XmlNode[] a = (Microsoft.Xml.XmlNode[])o.@Markup; + System.Xml.XmlNode[] a = (System.Xml.XmlNode[])o.@Markup; if (a != null) { for (int ia = 0; ia < a.Length; ia++) { - Microsoft.Xml.XmlNode ai = (Microsoft.Xml.XmlNode)a[ia]; + System.Xml.XmlNode ai = (System.Xml.XmlNode)a[ia]; { - if (ai is Microsoft.Xml.XmlElement) + if (ai is System.Xml.XmlElement) { - Microsoft.Xml.XmlElement elem = (Microsoft.Xml.XmlElement)ai; - if ((elem) is Microsoft.Xml.XmlNode || elem == null) + System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; + if ((elem) is System.Xml.XmlNode || elem == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)elem, @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); } else { throw CreateInvalidAnyTypeException(elem); } } - else if (ai is Microsoft.Xml.XmlNode) + else if (ai is System.Xml.XmlNode) { - ((Microsoft.Xml.XmlNode)ai).WriteTo(Writer); + ((System.Xml.XmlNode)ai).WriteTo(Writer); } else { @@ -2611,7 +2611,7 @@ private void Write10_XmlSchemaAppInfo(string n, string ns, Microsoft.Xml.Schema. WriteEndElement(o); } - private void Write63_XmlSchemaGroup(string n, string ns, Microsoft.Xml.Schema.XmlSchemaGroup o, bool isNullable, bool needType) + private void Write63_XmlSchemaGroup(string n, string ns, System.Xml.Schema.XmlSchemaGroup o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2621,7 +2621,7 @@ private void Write63_XmlSchemaGroup(string n, string ns, Microsoft.Xml.Schema.Xm if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaGroup)) + if (t == typeof(System.Xml.Schema.XmlSchemaGroup)) { } else @@ -2634,30 +2634,30 @@ private void Write63_XmlSchemaGroup(string n, string ns, Microsoft.Xml.Schema.Xm if (needType) WriteXsiType(@"XmlSchemaGroup", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaAll) + if (o.@Particle is System.Xml.Schema.XmlSchemaAll) { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); + Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaChoice) + else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaSequence) + else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); } else { @@ -2670,7 +2670,7 @@ private void Write63_XmlSchemaGroup(string n, string ns, Microsoft.Xml.Schema.Xm WriteEndElement(o); } - private void Write53_XmlSchemaSequence(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSequence o, bool isNullable, bool needType) + private void Write53_XmlSchemaSequence(string n, string ns, System.Xml.Schema.XmlSchemaSequence o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2680,7 +2680,7 @@ private void Write53_XmlSchemaSequence(string n, string ns, Microsoft.Xml.Schema if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSequence)) + if (t == typeof(System.Xml.Schema.XmlSchemaSequence)) { } else @@ -2693,46 +2693,46 @@ private void Write53_XmlSchemaSequence(string n, string ns, Microsoft.Xml.Schema if (needType) WriteXsiType(@"XmlSchemaSequence", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaChoice) + if (ai is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)ai), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaSequence) + else if (ai is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)ai), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaGroupRef) { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroupRef)ai), false, false); + Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaElement) + else if (ai is System.Xml.Schema.XmlSchemaElement) { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaElement)ai), false, false); + Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAny) + else if (ai is System.Xml.Schema.XmlSchemaAny) { - Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAny)ai), false, false); + Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAny)ai), false, false); } else { @@ -2748,7 +2748,7 @@ private void Write53_XmlSchemaSequence(string n, string ns, Microsoft.Xml.Schema WriteEndElement(o); } - private void Write46_XmlSchemaAny(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAny o, bool isNullable, bool needType) + private void Write46_XmlSchemaAny(string n, string ns, System.Xml.Schema.XmlSchemaAny o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2758,7 +2758,7 @@ private void Write46_XmlSchemaAny(string n, string ns, Microsoft.Xml.Schema.XmlS if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAny)) + if (t == typeof(System.Xml.Schema.XmlSchemaAny)) { } else @@ -2771,12 +2771,12 @@ private void Write46_XmlSchemaAny(string n, string ns, Microsoft.Xml.Schema.XmlS if (needType) WriteXsiType(@"XmlSchemaAny", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -2784,28 +2784,28 @@ private void Write46_XmlSchemaAny(string n, string ns, Microsoft.Xml.Schema.XmlS WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if (((Microsoft.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != Microsoft.Xml.Schema.XmlSchemaContentProcessing.@None) + if (((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != System.Xml.Schema.XmlSchemaContentProcessing.@None) { - WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((Microsoft.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); + WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private string Write38_XmlSchemaContentProcessing(Microsoft.Xml.Schema.XmlSchemaContentProcessing v) + private string Write38_XmlSchemaContentProcessing(System.Xml.Schema.XmlSchemaContentProcessing v) { string s = null; switch (v) { - case Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Skip: s = @"skip"; break; - case Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Lax: s = @"lax"; break; - case Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Strict: s = @"strict"; break; + case System.Xml.Schema.XmlSchemaContentProcessing.@Skip: s = @"skip"; break; + case System.Xml.Schema.XmlSchemaContentProcessing.@Lax: s = @"lax"; break; + case System.Xml.Schema.XmlSchemaContentProcessing.@Strict: s = @"strict"; break; default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaContentProcessing"); } return s; } - private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema.XmlSchemaElement o, bool isNullable, bool needType) + private void Write52_XmlSchemaElement(string n, string ns, System.Xml.Schema.XmlSchemaElement o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2815,7 +2815,7 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaElement)) + if (t == typeof(System.Xml.Schema.XmlSchemaElement)) { } else @@ -2828,12 +2828,12 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. if (needType) WriteXsiType(@"XmlSchemaElement", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -2842,21 +2842,21 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); if (((global::System.Boolean)o.@IsAbstract) != false) { - WriteAttribute(@"abstract", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); + WriteAttribute(@"abstract", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); } - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); + WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); } WriteAttribute(@"default", @"", ((global::System.String)o.@DefaultValue)); - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); + WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); } WriteAttribute(@"fixed", @"", ((global::System.String)o.@FixedValue)); - if (((Microsoft.Xml.Schema.XmlSchemaForm)o.@Form) != Microsoft.Xml.Schema.XmlSchemaForm.@None) + if (((System.Xml.Schema.XmlSchemaForm)o.@Form) != System.Xml.Schema.XmlSchemaForm.@None) { - WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((Microsoft.Xml.Schema.XmlSchemaForm)o.@Form))); + WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@Form))); } if ((((global::System.String)o.@Name) != null) && (((global::System.String)o.@Name).Length != 0)) { @@ -2864,20 +2864,20 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. } if (((global::System.Boolean)o.@IsNillable) != false) { - WriteAttribute(@"nillable", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsNillable))); + WriteAttribute(@"nillable", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsNillable))); } - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@RefName))); - WriteAttribute(@"substitutionGroup", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@SubstitutionGroup))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@SchemaTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); + WriteAttribute(@"substitutionGroup", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SubstitutionGroup))); + WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SchemaTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@SchemaType is Microsoft.Xml.Schema.XmlSchemaComplexType) + if (o.@SchemaType is System.Xml.Schema.XmlSchemaComplexType) { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexType)o.@SchemaType), false, false); + Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)o.@SchemaType), false, false); } - else if (o.@SchemaType is Microsoft.Xml.Schema.XmlSchemaSimpleType) + else if (o.@SchemaType is System.Xml.Schema.XmlSchemaSimpleType) { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); } else { @@ -2888,24 +2888,24 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaKeyref) + if (ai is System.Xml.Schema.XmlSchemaKeyref) { - Write51_XmlSchemaKeyref(@"keyref", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaKeyref)ai), false, false); + Write51_XmlSchemaKeyref(@"keyref", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaKeyref)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaUnique) + else if (ai is System.Xml.Schema.XmlSchemaUnique) { - Write50_XmlSchemaUnique(@"unique", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaUnique)ai), false, false); + Write50_XmlSchemaUnique(@"unique", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaUnique)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaKey) + else if (ai is System.Xml.Schema.XmlSchemaKey) { - Write49_XmlSchemaKey(@"key", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaKey)ai), false, false); + Write49_XmlSchemaKey(@"key", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaKey)ai), false, false); } else { @@ -2921,7 +2921,7 @@ private void Write52_XmlSchemaElement(string n, string ns, Microsoft.Xml.Schema. WriteEndElement(o); } - private void Write49_XmlSchemaKey(string n, string ns, Microsoft.Xml.Schema.XmlSchemaKey o, bool isNullable, bool needType) + private void Write49_XmlSchemaKey(string n, string ns, System.Xml.Schema.XmlSchemaKey o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2931,7 +2931,7 @@ private void Write49_XmlSchemaKey(string n, string ns, Microsoft.Xml.Schema.XmlS if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaKey)) + if (t == typeof(System.Xml.Schema.XmlSchemaKey)) { } else @@ -2944,33 +2944,33 @@ private void Write49_XmlSchemaKey(string n, string ns, Microsoft.Xml.Schema.XmlS if (needType) WriteXsiType(@"XmlSchemaKey", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); + Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); } } } WriteEndElement(o); } - private void Write47_XmlSchemaXPath(string n, string ns, Microsoft.Xml.Schema.XmlSchemaXPath o, bool isNullable, bool needType) + private void Write47_XmlSchemaXPath(string n, string ns, System.Xml.Schema.XmlSchemaXPath o, bool isNullable, bool needType) { if ((object)o == null) { @@ -2980,7 +2980,7 @@ private void Write47_XmlSchemaXPath(string n, string ns, Microsoft.Xml.Schema.Xm if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaXPath)) + if (t == typeof(System.Xml.Schema.XmlSchemaXPath)) { } else @@ -2993,12 +2993,12 @@ private void Write47_XmlSchemaXPath(string n, string ns, Microsoft.Xml.Schema.Xm if (needType) WriteXsiType(@"XmlSchemaXPath", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3007,11 +3007,11 @@ private void Write47_XmlSchemaXPath(string n, string ns, Microsoft.Xml.Schema.Xm { WriteAttribute(@"xpath", @"", ((global::System.String)o.@XPath)); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write50_XmlSchemaUnique(string n, string ns, Microsoft.Xml.Schema.XmlSchemaUnique o, bool isNullable, bool needType) + private void Write50_XmlSchemaUnique(string n, string ns, System.Xml.Schema.XmlSchemaUnique o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3021,7 +3021,7 @@ private void Write50_XmlSchemaUnique(string n, string ns, Microsoft.Xml.Schema.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaUnique)) + if (t == typeof(System.Xml.Schema.XmlSchemaUnique)) { } else @@ -3034,33 +3034,33 @@ private void Write50_XmlSchemaUnique(string n, string ns, Microsoft.Xml.Schema.X if (needType) WriteXsiType(@"XmlSchemaUnique", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); + Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); } } } WriteEndElement(o); } - private void Write51_XmlSchemaKeyref(string n, string ns, Microsoft.Xml.Schema.XmlSchemaKeyref o, bool isNullable, bool needType) + private void Write51_XmlSchemaKeyref(string n, string ns, System.Xml.Schema.XmlSchemaKeyref o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3070,7 +3070,7 @@ private void Write51_XmlSchemaKeyref(string n, string ns, Microsoft.Xml.Schema.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaKeyref)) + if (t == typeof(System.Xml.Schema.XmlSchemaKeyref)) { } else @@ -3083,34 +3083,34 @@ private void Write51_XmlSchemaKeyref(string n, string ns, Microsoft.Xml.Schema.X if (needType) WriteXsiType(@"XmlSchemaKeyref", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"refer", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@Refer))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); + WriteAttribute(@"refer", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Refer))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); + Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); } } } WriteEndElement(o); } - private void Write34_XmlSchemaSimpleType(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleType o, bool isNullable, bool needType) + private void Write34_XmlSchemaSimpleType(string n, string ns, System.Xml.Schema.XmlSchemaSimpleType o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3120,7 +3120,7 @@ private void Write34_XmlSchemaSimpleType(string n, string ns, Microsoft.Xml.Sche if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleType)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleType)) { } else @@ -3133,34 +3133,34 @@ private void Write34_XmlSchemaSimpleType(string n, string ns, Microsoft.Xml.Sche if (needType) WriteXsiType(@"XmlSchemaSimpleType", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); + WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Content is Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion) + if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeUnion) { - Write33_XmlSchemaSimpleTypeUnion(@"union", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion)o.@Content), false, false); + Write33_XmlSchemaSimpleTypeUnion(@"union", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeUnion)o.@Content), false, false); } - else if (o.@Content is Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction) + else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeRestriction) { - Write32_XmlSchemaSimpleTypeRestriction(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction)o.@Content), false, false); + Write32_XmlSchemaSimpleTypeRestriction(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeRestriction)o.@Content), false, false); } - else if (o.@Content is Microsoft.Xml.Schema.XmlSchemaSimpleTypeList) + else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeList) { - Write17_XmlSchemaSimpleTypeList(@"list", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleTypeList)o.@Content), false, false); + Write17_XmlSchemaSimpleTypeList(@"list", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeList)o.@Content), false, false); } else { @@ -3173,7 +3173,7 @@ private void Write34_XmlSchemaSimpleType(string n, string ns, Microsoft.Xml.Sche WriteEndElement(o); } - private void Write17_XmlSchemaSimpleTypeList(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleTypeList o, bool isNullable, bool needType) + private void Write17_XmlSchemaSimpleTypeList(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeList o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3183,7 +3183,7 @@ private void Write17_XmlSchemaSimpleTypeList(string n, string ns, Microsoft.Xml. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleTypeList)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeList)) { } else @@ -3196,23 +3196,23 @@ private void Write17_XmlSchemaSimpleTypeList(string n, string ns, Microsoft.Xml. if (needType) WriteXsiType(@"XmlSchemaSimpleTypeList", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"itemType", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@ItemTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)o.@ItemType), false, false); + WriteAttribute(@"itemType", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@ItemTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@ItemType), false, false); WriteEndElement(o); } - private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction o, bool isNullable, bool needType) + private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeRestriction o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3222,7 +3222,7 @@ private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, Microso if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeRestriction)) { } else @@ -3235,74 +3235,74 @@ private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, Microso if (needType) WriteXsiType(@"XmlSchemaSimpleTypeRestriction", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); + WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaLengthFacet) + if (ai is System.Xml.Schema.XmlSchemaLengthFacet) { - Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); + Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet) + else if (ai is System.Xml.Schema.XmlSchemaTotalDigitsFacet) { - Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); + Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxLengthFacet) { - Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); + Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet) + else if (ai is System.Xml.Schema.XmlSchemaFractionDigitsFacet) { - Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); + Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMinLengthFacet) + else if (ai is System.Xml.Schema.XmlSchemaMinLengthFacet) { - Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); + Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxExclusiveFacet) { - Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); + Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet) + else if (ai is System.Xml.Schema.XmlSchemaWhiteSpaceFacet) { - Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); + Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMinExclusiveFacet) { - Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); + Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaPatternFacet) + else if (ai is System.Xml.Schema.XmlSchemaPatternFacet) { - Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); + Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMinInclusiveFacet) { - Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); + Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxInclusiveFacet) { - Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); + Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaEnumerationFacet) + else if (ai is System.Xml.Schema.XmlSchemaEnumerationFacet) { - Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); + Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); } else { @@ -3318,7 +3318,7 @@ private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, Microso WriteEndElement(o); } - private void Write26_XmlSchemaEnumerationFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaEnumerationFacet o, bool isNullable, bool needType) + private void Write26_XmlSchemaEnumerationFacet(string n, string ns, System.Xml.Schema.XmlSchemaEnumerationFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3328,7 +3328,7 @@ private void Write26_XmlSchemaEnumerationFacet(string n, string ns, Microsoft.Xm if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaEnumerationFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaEnumerationFacet)) { } else @@ -3341,12 +3341,12 @@ private void Write26_XmlSchemaEnumerationFacet(string n, string ns, Microsoft.Xm if (needType) WriteXsiType(@"XmlSchemaEnumerationFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3354,13 +3354,13 @@ private void Write26_XmlSchemaEnumerationFacet(string n, string ns, Microsoft.Xm WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet o, bool isNullable, bool needType) + private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxInclusiveFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3370,7 +3370,7 @@ private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, Microsoft.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMaxInclusiveFacet)) { } else @@ -3383,12 +3383,12 @@ private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, Microsoft.X if (needType) WriteXsiType(@"XmlSchemaMaxInclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3396,13 +3396,13 @@ private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, Microsoft.X WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet o, bool isNullable, bool needType) + private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinInclusiveFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3412,7 +3412,7 @@ private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, Microsoft.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMinInclusiveFacet)) { } else @@ -3425,12 +3425,12 @@ private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, Microsoft.X if (needType) WriteXsiType(@"XmlSchemaMinInclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3438,13 +3438,13 @@ private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, Microsoft.X WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write25_XmlSchemaPatternFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaPatternFacet o, bool isNullable, bool needType) + private void Write25_XmlSchemaPatternFacet(string n, string ns, System.Xml.Schema.XmlSchemaPatternFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3454,7 +3454,7 @@ private void Write25_XmlSchemaPatternFacet(string n, string ns, Microsoft.Xml.Sc if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaPatternFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaPatternFacet)) { } else @@ -3467,12 +3467,12 @@ private void Write25_XmlSchemaPatternFacet(string n, string ns, Microsoft.Xml.Sc if (needType) WriteXsiType(@"XmlSchemaPatternFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3480,13 +3480,13 @@ private void Write25_XmlSchemaPatternFacet(string n, string ns, Microsoft.Xml.Sc WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet o, bool isNullable, bool needType) + private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinExclusiveFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3496,7 +3496,7 @@ private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, Microsoft.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMinExclusiveFacet)) { } else @@ -3509,12 +3509,12 @@ private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, Microsoft.X if (needType) WriteXsiType(@"XmlSchemaMinExclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3522,13 +3522,13 @@ private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, Microsoft.X WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet o, bool isNullable, bool needType) + private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, System.Xml.Schema.XmlSchemaWhiteSpaceFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3538,7 +3538,7 @@ private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, Microsoft.Xml if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaWhiteSpaceFacet)) { } else @@ -3551,12 +3551,12 @@ private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, Microsoft.Xml if (needType) WriteXsiType(@"XmlSchemaWhiteSpaceFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3564,13 +3564,13 @@ private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, Microsoft.Xml WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet o, bool isNullable, bool needType) + private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxExclusiveFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3580,7 +3580,7 @@ private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, Microsoft.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMaxExclusiveFacet)) { } else @@ -3593,12 +3593,12 @@ private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, Microsoft.X if (needType) WriteXsiType(@"XmlSchemaMaxExclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3606,13 +3606,13 @@ private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, Microsoft.X WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write31_XmlSchemaMinLengthFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMinLengthFacet o, bool isNullable, bool needType) + private void Write31_XmlSchemaMinLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinLengthFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3622,7 +3622,7 @@ private void Write31_XmlSchemaMinLengthFacet(string n, string ns, Microsoft.Xml. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMinLengthFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMinLengthFacet)) { } else @@ -3635,12 +3635,12 @@ private void Write31_XmlSchemaMinLengthFacet(string n, string ns, Microsoft.Xml. if (needType) WriteXsiType(@"XmlSchemaMinLengthFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3648,13 +3648,13 @@ private void Write31_XmlSchemaMinLengthFacet(string n, string ns, Microsoft.Xml. WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet o, bool isNullable, bool needType) + private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, System.Xml.Schema.XmlSchemaFractionDigitsFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3664,7 +3664,7 @@ private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, Microsoft if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaFractionDigitsFacet)) { } else @@ -3677,12 +3677,12 @@ private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, Microsoft if (needType) WriteXsiType(@"XmlSchemaFractionDigitsFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3690,13 +3690,13 @@ private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, Microsoft WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet o, bool isNullable, bool needType) + private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxLengthFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3706,7 +3706,7 @@ private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, Microsoft.Xml. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaMaxLengthFacet)) { } else @@ -3719,12 +3719,12 @@ private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, Microsoft.Xml. if (needType) WriteXsiType(@"XmlSchemaMaxLengthFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3732,13 +3732,13 @@ private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, Microsoft.Xml. WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet o, bool isNullable, bool needType) + private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, System.Xml.Schema.XmlSchemaTotalDigitsFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3748,7 +3748,7 @@ private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, Microsoft.Xm if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaTotalDigitsFacet)) { } else @@ -3761,12 +3761,12 @@ private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, Microsoft.Xm if (needType) WriteXsiType(@"XmlSchemaTotalDigitsFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3774,13 +3774,13 @@ private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, Microsoft.Xm WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write23_XmlSchemaLengthFacet(string n, string ns, Microsoft.Xml.Schema.XmlSchemaLengthFacet o, bool isNullable, bool needType) + private void Write23_XmlSchemaLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaLengthFacet o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3790,7 +3790,7 @@ private void Write23_XmlSchemaLengthFacet(string n, string ns, Microsoft.Xml.Sch if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaLengthFacet)) + if (t == typeof(System.Xml.Schema.XmlSchemaLengthFacet)) { } else @@ -3803,12 +3803,12 @@ private void Write23_XmlSchemaLengthFacet(string n, string ns, Microsoft.Xml.Sch if (needType) WriteXsiType(@"XmlSchemaLengthFacet", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -3816,13 +3816,13 @@ private void Write23_XmlSchemaLengthFacet(string n, string ns, Microsoft.Xml.Sch WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); if (((global::System.Boolean)o.@IsFixed) != false) { - WriteAttribute(@"fixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); + WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion o, bool isNullable, bool needType) + private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeUnion o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3832,7 +3832,7 @@ private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, Microsoft.Xml if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeUnion)) { } else @@ -3845,24 +3845,24 @@ private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, Microsoft.Xml if (needType) WriteXsiType(@"XmlSchemaSimpleTypeUnion", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } { - Microsoft.Xml.XmlQualifiedName[] a = (Microsoft.Xml.XmlQualifiedName[])o.@MemberTypes; + System.Xml.XmlQualifiedName[] a = (System.Xml.XmlQualifiedName[])o.@MemberTypes; if (a != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlQualifiedName ai = (Microsoft.Xml.XmlQualifiedName)a[i]; + System.Xml.XmlQualifiedName ai = (System.Xml.XmlQualifiedName)a[i]; if (i != 0) sb.Append(" "); sb.Append(FromXmlQualifiedName(ai)); } @@ -3872,32 +3872,32 @@ private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, Microsoft.Xml } } } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)a[ia]), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)a[ia]), false, false); } } } WriteEndElement(o); } - private string Write7_XmlSchemaDerivationMethod(Microsoft.Xml.Schema.XmlSchemaDerivationMethod v) + private string Write7_XmlSchemaDerivationMethod(System.Xml.Schema.XmlSchemaDerivationMethod v) { string s = null; switch (v) { - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Empty: s = @""; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Substitution: s = @"substitution"; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Extension: s = @"extension"; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Restriction: s = @"restriction"; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@List: s = @"list"; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Union: s = @"union"; break; - case Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@All: s = @"#all"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@Empty: s = @""; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution: s = @"substitution"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@Extension: s = @"extension"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction: s = @"restriction"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@List: s = @"list"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@Union: s = @"union"; break; + case System.Xml.Schema.XmlSchemaDerivationMethod.@All: s = @"#all"; break; default: s = FromEnum(((System.Int64)v), new string[] { @"", @"substitution", @@ -3905,18 +3905,18 @@ private string Write7_XmlSchemaDerivationMethod(Microsoft.Xml.Schema.XmlSchemaDe @"restriction", @"list", @"union", - @"#all" }, new System.Int64[] { (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Empty, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Substitution, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Extension, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Restriction, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@List, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Union, - (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@All }, @"System.Xml.Schema.XmlSchemaDerivationMethod"); break; + @"#all" }, new System.Int64[] { (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Empty, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Extension, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@List, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Union, + (long)System.Xml.Schema.XmlSchemaDerivationMethod.@All }, @"System.Xml.Schema.XmlSchemaDerivationMethod"); break; } return s; } - private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Schema.XmlSchemaComplexType o, bool isNullable, bool needType) + private void Write62_XmlSchemaComplexType(string n, string ns, System.Xml.Schema.XmlSchemaComplexType o, bool isNullable, bool needType) { if ((object)o == null) { @@ -3926,7 +3926,7 @@ private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Sch if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaComplexType)) + if (t == typeof(System.Xml.Schema.XmlSchemaComplexType)) { } else @@ -3939,42 +3939,42 @@ private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Sch if (needType) WriteXsiType(@"XmlSchemaComplexType", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); + WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); } if (((global::System.Boolean)o.@IsAbstract) != false) { - WriteAttribute(@"abstract", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); + WriteAttribute(@"abstract", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); } - if (((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@None)) + if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) { - WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((Microsoft.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); + WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); } if (((global::System.Boolean)o.@IsMixed) != false) { - WriteAttribute(@"mixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); + WriteAttribute(@"mixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@ContentModel is Microsoft.Xml.Schema.XmlSchemaSimpleContent) + if (o.@ContentModel is System.Xml.Schema.XmlSchemaSimpleContent) { - Write61_XmlSchemaSimpleContent(@"simpleContent", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleContent)o.@ContentModel), false, false); + Write61_XmlSchemaSimpleContent(@"simpleContent", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContent)o.@ContentModel), false, false); } - else if (o.@ContentModel is Microsoft.Xml.Schema.XmlSchemaComplexContent) + else if (o.@ContentModel is System.Xml.Schema.XmlSchemaComplexContent) { - Write58_XmlSchemaComplexContent(@"complexContent", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexContent)o.@ContentModel), false, false); + Write58_XmlSchemaComplexContent(@"complexContent", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContent)o.@ContentModel), false, false); } else { @@ -3985,21 +3985,21 @@ private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Sch } } { - if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaChoice) + if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaAll) + else if (o.@Particle is System.Xml.Schema.XmlSchemaAll) { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); + Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaSequence) + else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaGroupRef) + else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); + Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); } else { @@ -4010,20 +4010,20 @@ private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Sch } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + else if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } else { @@ -4036,11 +4036,11 @@ private void Write62_XmlSchemaComplexType(string n, string ns, Microsoft.Xml.Sch } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write39_XmlSchemaAnyAttribute(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAnyAttribute o, bool isNullable, bool needType) + private void Write39_XmlSchemaAnyAttribute(string n, string ns, System.Xml.Schema.XmlSchemaAnyAttribute o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4050,7 +4050,7 @@ private void Write39_XmlSchemaAnyAttribute(string n, string ns, Microsoft.Xml.Sc if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAnyAttribute)) + if (t == typeof(System.Xml.Schema.XmlSchemaAnyAttribute)) { } else @@ -4063,26 +4063,26 @@ private void Write39_XmlSchemaAnyAttribute(string n, string ns, Microsoft.Xml.Sc if (needType) WriteXsiType(@"XmlSchemaAnyAttribute", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if (((Microsoft.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != Microsoft.Xml.Schema.XmlSchemaContentProcessing.@None) + if (((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != System.Xml.Schema.XmlSchemaContentProcessing.@None) { - WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((Microsoft.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); + WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write36_XmlSchemaAttribute(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAttribute o, bool isNullable, bool needType) + private void Write36_XmlSchemaAttribute(string n, string ns, System.Xml.Schema.XmlSchemaAttribute o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4092,7 +4092,7 @@ private void Write36_XmlSchemaAttribute(string n, string ns, Microsoft.Xml.Schem if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAttribute)) + if (t == typeof(System.Xml.Schema.XmlSchemaAttribute)) { } else @@ -4105,60 +4105,60 @@ private void Write36_XmlSchemaAttribute(string n, string ns, Microsoft.Xml.Schem if (needType) WriteXsiType(@"XmlSchemaAttribute", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"default", @"", ((global::System.String)o.@DefaultValue)); WriteAttribute(@"fixed", @"", ((global::System.String)o.@FixedValue)); - if (((Microsoft.Xml.Schema.XmlSchemaForm)o.@Form) != Microsoft.Xml.Schema.XmlSchemaForm.@None) + if (((System.Xml.Schema.XmlSchemaForm)o.@Form) != System.Xml.Schema.XmlSchemaForm.@None) { - WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((Microsoft.Xml.Schema.XmlSchemaForm)o.@Form))); + WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@Form))); } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@RefName))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@SchemaTypeName))); - if (((Microsoft.Xml.Schema.XmlSchemaUse)o.@Use) != Microsoft.Xml.Schema.XmlSchemaUse.@None) + WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); + WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SchemaTypeName))); + if (((System.Xml.Schema.XmlSchemaUse)o.@Use) != System.Xml.Schema.XmlSchemaUse.@None) { - WriteAttribute(@"use", @"", Write35_XmlSchemaUse(((Microsoft.Xml.Schema.XmlSchemaUse)o.@Use))); + WriteAttribute(@"use", @"", Write35_XmlSchemaUse(((System.Xml.Schema.XmlSchemaUse)o.@Use))); } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); WriteEndElement(o); } - private string Write35_XmlSchemaUse(Microsoft.Xml.Schema.XmlSchemaUse v) + private string Write35_XmlSchemaUse(System.Xml.Schema.XmlSchemaUse v) { string s = null; switch (v) { - case Microsoft.Xml.Schema.XmlSchemaUse.@Optional: s = @"optional"; break; - case Microsoft.Xml.Schema.XmlSchemaUse.@Prohibited: s = @"prohibited"; break; - case Microsoft.Xml.Schema.XmlSchemaUse.@Required: s = @"required"; break; + case System.Xml.Schema.XmlSchemaUse.@Optional: s = @"optional"; break; + case System.Xml.Schema.XmlSchemaUse.@Prohibited: s = @"prohibited"; break; + case System.Xml.Schema.XmlSchemaUse.@Required: s = @"required"; break; default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaUse"); } return s; } - private string Write6_XmlSchemaForm(Microsoft.Xml.Schema.XmlSchemaForm v) + private string Write6_XmlSchemaForm(System.Xml.Schema.XmlSchemaForm v) { string s = null; switch (v) { - case Microsoft.Xml.Schema.XmlSchemaForm.@Qualified: s = @"qualified"; break; - case Microsoft.Xml.Schema.XmlSchemaForm.@Unqualified: s = @"unqualified"; break; + case System.Xml.Schema.XmlSchemaForm.@Qualified: s = @"qualified"; break; + case System.Xml.Schema.XmlSchemaForm.@Unqualified: s = @"unqualified"; break; default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaForm"); } return s; } - private void Write37_XmlSchemaAttributeGroupRef(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef o, bool isNullable, bool needType) + private void Write37_XmlSchemaAttributeGroupRef(string n, string ns, System.Xml.Schema.XmlSchemaAttributeGroupRef o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4168,7 +4168,7 @@ private void Write37_XmlSchemaAttributeGroupRef(string n, string ns, Microsoft.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)) + if (t == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) { } else @@ -4181,22 +4181,22 @@ private void Write37_XmlSchemaAttributeGroupRef(string n, string ns, Microsoft.X if (needType) WriteXsiType(@"XmlSchemaAttributeGroupRef", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@RefName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write44_XmlSchemaGroupRef(string n, string ns, Microsoft.Xml.Schema.XmlSchemaGroupRef o, bool isNullable, bool needType) + private void Write44_XmlSchemaGroupRef(string n, string ns, System.Xml.Schema.XmlSchemaGroupRef o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4206,7 +4206,7 @@ private void Write44_XmlSchemaGroupRef(string n, string ns, Microsoft.Xml.Schema if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaGroupRef)) + if (t == typeof(System.Xml.Schema.XmlSchemaGroupRef)) { } else @@ -4219,24 +4219,24 @@ private void Write44_XmlSchemaGroupRef(string n, string ns, Microsoft.Xml.Schema if (needType) WriteXsiType(@"XmlSchemaGroupRef", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@RefName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write55_XmlSchemaAll(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAll o, bool isNullable, bool needType) + private void Write55_XmlSchemaAll(string n, string ns, System.Xml.Schema.XmlSchemaAll o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4246,7 +4246,7 @@ private void Write55_XmlSchemaAll(string n, string ns, Microsoft.Xml.Schema.XmlS if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAll)) + if (t == typeof(System.Xml.Schema.XmlSchemaAll)) { } else @@ -4259,33 +4259,33 @@ private void Write55_XmlSchemaAll(string n, string ns, Microsoft.Xml.Schema.XmlS if (needType) WriteXsiType(@"XmlSchemaAll", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaElement)a[ia]), false, false); + Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)a[ia]), false, false); } } } WriteEndElement(o); } - private void Write54_XmlSchemaChoice(string n, string ns, Microsoft.Xml.Schema.XmlSchemaChoice o, bool isNullable, bool needType) + private void Write54_XmlSchemaChoice(string n, string ns, System.Xml.Schema.XmlSchemaChoice o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4295,7 +4295,7 @@ private void Write54_XmlSchemaChoice(string n, string ns, Microsoft.Xml.Schema.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaChoice)) + if (t == typeof(System.Xml.Schema.XmlSchemaChoice)) { } else @@ -4308,46 +4308,46 @@ private void Write54_XmlSchemaChoice(string n, string ns, Microsoft.Xml.Schema.X if (needType) WriteXsiType(@"XmlSchemaChoice", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaSequence) + if (ai is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)ai), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaChoice) + else if (ai is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)ai), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaGroupRef) { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroupRef)ai), false, false); + Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaElement) + else if (ai is System.Xml.Schema.XmlSchemaElement) { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaElement)ai), false, false); + Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAny) + else if (ai is System.Xml.Schema.XmlSchemaAny) { - Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAny)ai), false, false); + Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAny)ai), false, false); } else { @@ -4363,7 +4363,7 @@ private void Write54_XmlSchemaChoice(string n, string ns, Microsoft.Xml.Schema.X WriteEndElement(o); } - private void Write58_XmlSchemaComplexContent(string n, string ns, Microsoft.Xml.Schema.XmlSchemaComplexContent o, bool isNullable, bool needType) + private void Write58_XmlSchemaComplexContent(string n, string ns, System.Xml.Schema.XmlSchemaComplexContent o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4373,7 +4373,7 @@ private void Write58_XmlSchemaComplexContent(string n, string ns, Microsoft.Xml. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaComplexContent)) + if (t == typeof(System.Xml.Schema.XmlSchemaComplexContent)) { } else @@ -4386,26 +4386,26 @@ private void Write58_XmlSchemaComplexContent(string n, string ns, Microsoft.Xml. if (needType) WriteXsiType(@"XmlSchemaComplexContent", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"mixed", @"", Microsoft.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"mixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Content is Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction) + if (o.@Content is System.Xml.Schema.XmlSchemaComplexContentRestriction) { - Write57_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction)o.@Content), false, false); + Write57_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContentRestriction)o.@Content), false, false); } - else if (o.@Content is Microsoft.Xml.Schema.XmlSchemaComplexContentExtension) + else if (o.@Content is System.Xml.Schema.XmlSchemaComplexContentExtension) { - Write56_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexContentExtension)o.@Content), false, false); + Write56_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContentExtension)o.@Content), false, false); } else { @@ -4418,7 +4418,7 @@ private void Write58_XmlSchemaComplexContent(string n, string ns, Microsoft.Xml. WriteEndElement(o); } - private void Write56_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaComplexContentExtension o, bool isNullable, bool needType) + private void Write56_Item(string n, string ns, System.Xml.Schema.XmlSchemaComplexContentExtension o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4428,7 +4428,7 @@ private void Write56_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaComplexContentExtension)) + if (t == typeof(System.Xml.Schema.XmlSchemaComplexContentExtension)) { } else @@ -4441,34 +4441,34 @@ private void Write56_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom if (needType) WriteXsiType(@"XmlSchemaComplexContentExtension", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaAll) + if (o.@Particle is System.Xml.Schema.XmlSchemaAll) { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); + Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaSequence) + else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaChoice) + else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaGroupRef) + else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); + Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); } else { @@ -4479,20 +4479,20 @@ private void Write56_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } else { @@ -4505,11 +4505,11 @@ private void Write56_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write57_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction o, bool isNullable, bool needType) + private void Write57_Item(string n, string ns, System.Xml.Schema.XmlSchemaComplexContentRestriction o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4519,7 +4519,7 @@ private void Write57_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction)) + if (t == typeof(System.Xml.Schema.XmlSchemaComplexContentRestriction)) { } else @@ -4532,34 +4532,34 @@ private void Write57_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom if (needType) WriteXsiType(@"XmlSchemaComplexContentRestriction", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaAll) + if (o.@Particle is System.Xml.Schema.XmlSchemaAll) { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); + Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaSequence) + else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); + Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaChoice) + else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); + Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); } - else if (o.@Particle is Microsoft.Xml.Schema.XmlSchemaGroupRef) + else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); + Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); } else { @@ -4570,20 +4570,20 @@ private void Write57_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } else { @@ -4596,11 +4596,11 @@ private void Write57_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaCom } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write61_XmlSchemaSimpleContent(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleContent o, bool isNullable, bool needType) + private void Write61_XmlSchemaSimpleContent(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContent o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4610,7 +4610,7 @@ private void Write61_XmlSchemaSimpleContent(string n, string ns, Microsoft.Xml.S if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleContent)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContent)) { } else @@ -4623,25 +4623,25 @@ private void Write61_XmlSchemaSimpleContent(string n, string ns, Microsoft.Xml.S if (needType) WriteXsiType(@"XmlSchemaSimpleContent", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - if (o.@Content is Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension) + if (o.@Content is System.Xml.Schema.XmlSchemaSimpleContentExtension) { - Write60_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension)o.@Content), false, false); + Write60_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContentExtension)o.@Content), false, false); } - else if (o.@Content is Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction) + else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleContentRestriction) { - Write59_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction)o.@Content), false, false); + Write59_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContentRestriction)o.@Content), false, false); } else { @@ -4654,7 +4654,7 @@ private void Write61_XmlSchemaSimpleContent(string n, string ns, Microsoft.Xml.S WriteEndElement(o); } - private void Write59_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction o, bool isNullable, bool needType) + private void Write59_Item(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContentRestriction o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4664,7 +4664,7 @@ private void Write59_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContentRestriction)) { } else @@ -4677,74 +4677,74 @@ private void Write59_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim if (needType) WriteXsiType(@"XmlSchemaSimpleContentRestriction", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); + WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaMinLengthFacet) + if (ai is System.Xml.Schema.XmlSchemaMinLengthFacet) { - Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); + Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxLengthFacet) { - Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); + Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaLengthFacet) + else if (ai is System.Xml.Schema.XmlSchemaLengthFacet) { - Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); + Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet) + else if (ai is System.Xml.Schema.XmlSchemaFractionDigitsFacet) { - Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); + Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet) + else if (ai is System.Xml.Schema.XmlSchemaTotalDigitsFacet) { - Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); + Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMinExclusiveFacet) { - Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); + Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxInclusiveFacet) { - Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); + Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMaxExclusiveFacet) { - Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); + Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet) + else if (ai is System.Xml.Schema.XmlSchemaMinInclusiveFacet) { - Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); + Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet) + else if (ai is System.Xml.Schema.XmlSchemaWhiteSpaceFacet) { - Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); + Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaEnumerationFacet) + else if (ai is System.Xml.Schema.XmlSchemaEnumerationFacet) { - Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); + Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaPatternFacet) + else if (ai is System.Xml.Schema.XmlSchemaPatternFacet) { - Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); + Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); } else { @@ -4758,20 +4758,20 @@ private void Write59_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } else { @@ -4784,11 +4784,11 @@ private void Write59_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write60_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension o, bool isNullable, bool needType) + private void Write60_Item(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContentExtension o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4798,7 +4798,7 @@ private void Write60_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension)) + if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContentExtension)) { } else @@ -4811,33 +4811,33 @@ private void Write60_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim if (needType) WriteXsiType(@"XmlSchemaSimpleContentExtension", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((Microsoft.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } else { @@ -4850,11 +4850,11 @@ private void Write60_Item(string n, string ns, Microsoft.Xml.Schema.XmlSchemaSim } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write65_XmlSchemaNotation(string n, string ns, Microsoft.Xml.Schema.XmlSchemaNotation o, bool isNullable, bool needType) + private void Write65_XmlSchemaNotation(string n, string ns, System.Xml.Schema.XmlSchemaNotation o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4864,7 +4864,7 @@ private void Write65_XmlSchemaNotation(string n, string ns, Microsoft.Xml.Schema if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaNotation)) + if (t == typeof(System.Xml.Schema.XmlSchemaNotation)) { } else @@ -4877,12 +4877,12 @@ private void Write65_XmlSchemaNotation(string n, string ns, Microsoft.Xml.Schema if (needType) WriteXsiType(@"XmlSchemaNotation", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } @@ -4890,11 +4890,11 @@ private void Write65_XmlSchemaNotation(string n, string ns, Microsoft.Xml.Schema WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); WriteAttribute(@"public", @"", ((global::System.String)o.@Public)); WriteAttribute(@"system", @"", ((global::System.String)o.@System)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write40_XmlSchemaAttributeGroup(string n, string ns, Microsoft.Xml.Schema.XmlSchemaAttributeGroup o, bool isNullable, bool needType) + private void Write40_XmlSchemaAttributeGroup(string n, string ns, System.Xml.Schema.XmlSchemaAttributeGroup o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4904,7 +4904,7 @@ private void Write40_XmlSchemaAttributeGroup(string n, string ns, Microsoft.Xml. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaAttributeGroup)) + if (t == typeof(System.Xml.Schema.XmlSchemaAttributeGroup)) { } else @@ -4917,33 +4917,33 @@ private void Write40_XmlSchemaAttributeGroup(string n, string ns, Microsoft.Xml. if (needType) WriteXsiType(@"XmlSchemaAttributeGroup", @"http://www.w3.org/2001/XMLSchema"); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef) + if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); + Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttribute) + else if (ai is System.Xml.Schema.XmlSchemaAttribute) { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttribute)ai), false, false); + Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); } else { @@ -4956,11 +4956,11 @@ private void Write40_XmlSchemaAttributeGroup(string n, string ns, Microsoft.Xml. } } } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); + Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); WriteEndElement(o); } - private void Write12_XmlSchemaInclude(string n, string ns, Microsoft.Xml.Schema.XmlSchemaInclude o, bool isNullable, bool needType) + private void Write12_XmlSchemaInclude(string n, string ns, System.Xml.Schema.XmlSchemaInclude o, bool isNullable, bool needType) { if ((object)o == null) { @@ -4970,7 +4970,7 @@ private void Write12_XmlSchemaInclude(string n, string ns, Microsoft.Xml.Schema. if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaInclude)) + if (t == typeof(System.Xml.Schema.XmlSchemaInclude)) { } else @@ -4984,21 +4984,21 @@ private void Write12_XmlSchemaInclude(string n, string ns, Microsoft.Xml.Schema. WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write13_XmlSchemaImport(string n, string ns, Microsoft.Xml.Schema.XmlSchemaImport o, bool isNullable, bool needType) + private void Write13_XmlSchemaImport(string n, string ns, System.Xml.Schema.XmlSchemaImport o, bool isNullable, bool needType) { if ((object)o == null) { @@ -5008,7 +5008,7 @@ private void Write13_XmlSchemaImport(string n, string ns, Microsoft.Xml.Schema.X if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaImport)) + if (t == typeof(System.Xml.Schema.XmlSchemaImport)) { } else @@ -5022,22 +5022,22 @@ private void Write13_XmlSchemaImport(string n, string ns, Microsoft.Xml.Schema.X WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); WriteEndElement(o); } - private void Write64_XmlSchemaRedefine(string n, string ns, Microsoft.Xml.Schema.XmlSchemaRedefine o, bool isNullable, bool needType) + private void Write64_XmlSchemaRedefine(string n, string ns, System.Xml.Schema.XmlSchemaRedefine o, bool isNullable, bool needType) { if ((object)o == null) { @@ -5047,7 +5047,7 @@ private void Write64_XmlSchemaRedefine(string n, string ns, Microsoft.Xml.Schema if (!needType) { System.Type t = o.GetType(); - if (t == typeof(Microsoft.Xml.Schema.XmlSchemaRedefine)) + if (t == typeof(System.Xml.Schema.XmlSchemaRedefine)) { } else @@ -5061,43 +5061,43 @@ private void Write64_XmlSchemaRedefine(string n, string ns, Microsoft.Xml.Schema WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@UnhandledAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } { - Microsoft.Xml.Schema.XmlSchemaObjectCollection a = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; if (a != null) { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - Microsoft.Xml.Schema.XmlSchemaObject ai = (Microsoft.Xml.Schema.XmlSchemaObject)a[ia]; + System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; { - if (ai is Microsoft.Xml.Schema.XmlSchemaSimpleType) + if (ai is System.Xml.Schema.XmlSchemaSimpleType) { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaSimpleType)ai), false, false); + Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaComplexType) + else if (ai is System.Xml.Schema.XmlSchemaComplexType) { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaComplexType)ai), false, false); + Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaGroup) + else if (ai is System.Xml.Schema.XmlSchemaGroup) { - Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaGroup)ai), false, false); + Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroup)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAttributeGroup) + else if (ai is System.Xml.Schema.XmlSchemaAttributeGroup) { - Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); + Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); } - else if (ai is Microsoft.Xml.Schema.XmlSchemaAnnotation) + else if (ai is System.Xml.Schema.XmlSchemaAnnotation) { - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((Microsoft.Xml.Schema.XmlSchemaAnnotation)ai), false, false); + Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)ai), false, false); } else { @@ -5134,21 +5134,21 @@ private void Write4_Import(string n, string ns, global::System.Web.Services.Desc WriteStartElement(n, ns, o, false, o.@Namespaces); if (needType) WriteXsiType(@"Import", @"http://schemas.xmlsoap.org/wsdl/"); { - Microsoft.Xml.XmlAttribute[] a = (Microsoft.Xml.XmlAttribute[])o.@ExtensibleAttributes; + System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; if (a != null) { for (int i = 0; i < a.Length; i++) { - Microsoft.Xml.XmlAttribute ai = (Microsoft.Xml.XmlAttribute)a[i]; + System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; WriteXmlAttribute(ai, o); } } } WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - if ((o.@DocumentationElement) is Microsoft.Xml.XmlNode || o.@DocumentationElement == null) + if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); + WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); } else { @@ -5160,9 +5160,9 @@ private void Write4_Import(string n, string ns, global::System.Web.Services.Desc { for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) { - if ((a[ia]) is Microsoft.Xml.XmlNode || a[ia] == null) + if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) { - WriteElementLiteral((Microsoft.Xml.XmlNode)a[ia], @"", null, false, true); + WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); } else { @@ -5178,13 +5178,13 @@ protected override void InitCallbacks() { } } - internal class ServiceDescriptionSerializationReader : Microsoft.Xml.Serialization.XmlSerializationReader + internal class ServiceDescriptionSerializationReader : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationReader { public object Read125_definitions() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id1_definitions && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -5204,21 +5204,21 @@ public object Read125_definitions() private global::System.Web.Services.Description.ServiceDescription Read124_ServiceDescription(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id3_ServiceDescription && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id3_ServiceDescription && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.ServiceDescription o; o = new global::System.Web.Services.Description.ServiceDescription(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.ImportCollection a_5 = (global::System.Web.Services.Description.ImportCollection)o.@Imports; @@ -5241,35 +5241,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations0 = 0; int readerCount0 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id8_import && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -5299,7 +5299,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5309,28 +5309,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations0, ref readerCount0); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Service Read123_Service(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id14_Service && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id14_Service && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Service o; o = new global::System.Web.Services.Description.Service(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.PortCollection a_5 = (global::System.Web.Services.Description.PortCollection)o.@Ports; @@ -5344,35 +5344,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations1 = 0; int readerCount1 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id15_port && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -5381,7 +5381,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5391,28 +5391,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations1, ref readerCount1); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Port Read122_Port(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id16_Port && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id16_Port && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Port o; o = new global::System.Web.Services.Description.Port(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[6]; @@ -5430,35 +5430,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations2 = 0; int readerCount2 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id17_address && (object)Reader.NamespaceURI == (object)_id18_Item)) @@ -5475,7 +5475,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5485,23 +5485,23 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations2, ref readerCount2); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Soap12AddressBinding Read121_Soap12AddressBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id21_Soap12AddressBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id21_Soap12AddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12AddressBinding o; @@ -5511,7 +5511,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -5534,9 +5534,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations3 = 0; int readerCount3 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -5553,16 +5553,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapAddressBinding Read119_SoapAddressBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id24_SoapAddressBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id24_SoapAddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapAddressBinding o; @@ -5572,7 +5572,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -5595,9 +5595,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations4 = 0; int readerCount4 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -5614,16 +5614,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.HttpAddressBinding Read118_HttpAddressBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id25_HttpAddressBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id25_HttpAddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.HttpAddressBinding o; @@ -5633,7 +5633,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -5656,9 +5656,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations5 = 0; int readerCount5 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -5675,21 +5675,21 @@ public object Read125_definitions() private global::System.Web.Services.Description.Binding Read117_Binding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id26_Binding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id26_Binding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Binding o; o = new global::System.Web.Services.Description.Binding(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.OperationBindingCollection a_5 = (global::System.Web.Services.Description.OperationBindingCollection)o.@Operations; @@ -5708,35 +5708,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations6 = 0; int readerCount6 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id18_Item)) @@ -5757,7 +5757,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5767,28 +5767,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations6, ref readerCount6); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.OperationBinding Read116_OperationBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id29_OperationBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id29_OperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.OperationBinding o; o = new global::System.Web.Services.Description.OperationBinding(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.FaultBindingCollection a_7 = (global::System.Web.Services.Description.FaultBindingCollection)o.@Faults; @@ -5802,35 +5802,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations7 = 0; int readerCount7 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id18_Item)) @@ -5861,7 +5861,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5871,28 +5871,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations7, ref readerCount7); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.FaultBinding Read115_FaultBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id33_FaultBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id33_FaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.FaultBinding o; o = new global::System.Web.Services.Description.FaultBinding(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[5]; @@ -5905,35 +5905,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations8 = 0; int readerCount8 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id32_fault && (object)Reader.NamespaceURI == (object)_id19_Item)) @@ -5946,7 +5946,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -5956,23 +5956,23 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations8, ref readerCount8); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Soap12FaultBinding Read114_Soap12FaultBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id34_Soap12FaultBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id34_Soap12FaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12FaultBinding o; @@ -5982,7 +5982,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6020,9 +6020,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations9 = 0; int readerCount9 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6049,16 +6049,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapFaultBinding Read112_SoapFaultBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id38_SoapFaultBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id38_SoapFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapFaultBinding o; @@ -6068,7 +6068,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6106,9 +6106,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations10 = 0; int readerCount10 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6135,21 +6135,21 @@ public object Read125_definitions() private global::System.Web.Services.Description.OutputBinding Read111_OutputBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id39_OutputBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id39_OutputBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.OutputBinding o; o = new global::System.Web.Services.Description.OutputBinding(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[5]; @@ -6162,35 +6162,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations11 = 0; int readerCount11 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id40_content && (object)Reader.NamespaceURI == (object)_id41_Item)) @@ -6227,7 +6227,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -6237,23 +6237,23 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations11, ref readerCount11); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Soap12HeaderBinding Read109_Soap12HeaderBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id48_Soap12HeaderBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id48_Soap12HeaderBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12HeaderBinding o; @@ -6263,7 +6263,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6306,9 +6306,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations12 = 0; int readerCount12 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id50_headerfault && (object)Reader.NamespaceURI == (object)_id20_Item)) { @@ -6333,16 +6333,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapHeaderFaultBinding Read107_SoapHeaderFaultBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapHeaderFaultBinding o; @@ -6352,7 +6352,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6395,9 +6395,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations13 = 0; int readerCount13 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6414,16 +6414,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.Soap12BodyBinding Read102_Soap12BodyBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id52_Soap12BodyBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id52_Soap12BodyBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12BodyBinding o; @@ -6433,7 +6433,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6471,9 +6471,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations14 = 0; int readerCount14 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6490,16 +6490,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapHeaderBinding Read106_SoapHeaderBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id54_SoapHeaderBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id54_SoapHeaderBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapHeaderBinding o; @@ -6509,7 +6509,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6552,9 +6552,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations15 = 0; int readerCount15 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id50_headerfault && (object)Reader.NamespaceURI == (object)_id19_Item)) { @@ -6579,16 +6579,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapHeaderFaultBinding Read105_SoapHeaderFaultBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapHeaderFaultBinding o; @@ -6598,7 +6598,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6641,9 +6641,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations16 = 0; int readerCount16 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6660,16 +6660,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapBodyBinding Read99_SoapBodyBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id55_SoapBodyBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id55_SoapBodyBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapBodyBinding o; @@ -6679,7 +6679,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6717,9 +6717,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations17 = 0; int readerCount17 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -6736,16 +6736,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimeTextBinding Read97_MimeTextBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id56_MimeTextBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id56_MimeTextBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimeTextBinding o; @@ -6756,7 +6756,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -6774,9 +6774,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations18 = 0; int readerCount18 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id57_match && (object)Reader.NamespaceURI == (object)_id45_Item)) { @@ -6800,16 +6800,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimeTextMatch Read96_MimeTextMatch(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id58_MimeTextMatch && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id58_MimeTextMatch && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimeTextMatch o; @@ -6830,12 +6830,12 @@ public object Read125_definitions() } else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@Group = Microsoft.Xml.XmlConvert.ToInt32(Reader.Value); + o.@Group = System.Xml.XmlConvert.ToInt32(Reader.Value); paramsRead[2] = true; } else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id60_capture && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@Capture = Microsoft.Xml.XmlConvert.ToInt32(Reader.Value); + o.@Capture = System.Xml.XmlConvert.ToInt32(Reader.Value); paramsRead[3] = true; } else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id61_repeats && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -6850,7 +6850,7 @@ public object Read125_definitions() } else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id63_ignoreCase && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IgnoreCase = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IgnoreCase = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[6] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -6868,9 +6868,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations19 = 0; int readerCount19 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id57_match && (object)Reader.NamespaceURI == (object)_id45_Item)) { @@ -6894,16 +6894,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimeMultipartRelatedBinding Read104_MimeMultipartRelatedBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id64_MimeMultipartRelatedBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id64_MimeMultipartRelatedBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimeMultipartRelatedBinding o; @@ -6914,7 +6914,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -6932,9 +6932,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations20 = 0; int readerCount20 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id41_Item)) { @@ -6958,16 +6958,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimePart Read103_MimePart(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id65_MimePart && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id65_MimePart && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimePart o; @@ -6978,7 +6978,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -6996,9 +6996,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations21 = 0; int readerCount21 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id40_content && (object)Reader.NamespaceURI == (object)_id41_Item)) { @@ -7022,7 +7022,7 @@ public object Read125_definitions() } else { - a_1.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_1.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -7038,16 +7038,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimeXmlBinding Read94_MimeXmlBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id66_MimeXmlBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id66_MimeXmlBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimeXmlBinding o; @@ -7057,7 +7057,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7080,9 +7080,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations22 = 0; int readerCount22 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7099,16 +7099,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.MimeContentBinding Read93_MimeContentBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id67_MimeContentBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id67_MimeContentBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MimeContentBinding o; @@ -7118,7 +7118,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7146,9 +7146,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations23 = 0; int readerCount23 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7165,21 +7165,21 @@ public object Read125_definitions() private global::System.Web.Services.Description.InputBinding Read110_InputBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id68_InputBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id68_InputBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.InputBinding o; o = new global::System.Web.Services.Description.InputBinding(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[5]; @@ -7192,35 +7192,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations24 = 0; int readerCount24 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id69_urlEncoded && (object)Reader.NamespaceURI == (object)_id18_Item)) @@ -7265,7 +7265,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -7275,23 +7275,23 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations24, ref readerCount24); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.HttpUrlReplacementBinding Read91_HttpUrlReplacementBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id71_HttpUrlReplacementBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id71_HttpUrlReplacementBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.HttpUrlReplacementBinding o; @@ -7301,7 +7301,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -7319,9 +7319,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations25 = 0; int readerCount25 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7338,16 +7338,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.HttpUrlEncodedBinding Read90_HttpUrlEncodedBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id72_HttpUrlEncodedBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id72_HttpUrlEncodedBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.HttpUrlEncodedBinding o; @@ -7357,7 +7357,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -7375,9 +7375,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations26 = 0; int readerCount26 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7394,16 +7394,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.Soap12OperationBinding Read88_Soap12OperationBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id73_Soap12OperationBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id73_Soap12OperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12OperationBinding o; @@ -7413,7 +7413,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id74_soapAction && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7428,7 +7428,7 @@ public object Read125_definitions() } else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id76_soapActionRequired && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@SoapActionRequired = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@SoapActionRequired = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[3] = true; } else if (!IsXmlnsAttribute(Reader.Name)) @@ -7446,9 +7446,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations27 = 0; int readerCount27 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7475,16 +7475,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapOperationBinding Read86_SoapOperationBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id77_SoapOperationBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id77_SoapOperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapOperationBinding o; @@ -7494,7 +7494,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id74_soapAction && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7522,9 +7522,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations28 = 0; int readerCount28 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7551,16 +7551,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.HttpOperationBinding Read85_HttpOperationBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id78_HttpOperationBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id78_HttpOperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.HttpOperationBinding o; @@ -7570,7 +7570,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7593,9 +7593,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations29 = 0; int readerCount29 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7612,16 +7612,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.Soap12Binding Read84_Soap12Binding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id79_Soap12Binding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id79_Soap12Binding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Soap12Binding o; @@ -7631,7 +7631,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id80_transport && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7659,9 +7659,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations30 = 0; int readerCount30 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7678,16 +7678,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.SoapBinding Read80_SoapBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id81_SoapBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id81_SoapBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.SoapBinding o; @@ -7697,7 +7697,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id80_transport && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7725,9 +7725,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations31 = 0; int readerCount31 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7744,16 +7744,16 @@ public object Read125_definitions() private global::System.Web.Services.Description.HttpBinding Read77_HttpBinding(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id82_HttpBinding && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id82_HttpBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.HttpBinding o; @@ -7763,7 +7763,7 @@ public object Read125_definitions() { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@Required = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[0] = true; } else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id83_verb && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -7786,9 +7786,9 @@ public object Read125_definitions() Reader.MoveToContent(); int whileIterations32 = 0; int readerCount32 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o, @""); } @@ -7805,21 +7805,21 @@ public object Read125_definitions() private global::System.Web.Services.Description.PortType Read75_PortType(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id84_PortType && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id84_PortType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.PortType o; o = new global::System.Web.Services.Description.PortType(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.OperationCollection a_5 = (global::System.Web.Services.Description.OperationCollection)o.@Operations; @@ -7833,35 +7833,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations33 = 0; int readerCount33 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -7870,7 +7870,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -7880,28 +7880,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations33, ref readerCount33); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Operation Read74_Operation(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id85_Operation && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id85_Operation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Operation o; o = new global::System.Web.Services.Description.Operation(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.OperationMessageCollection a_6 = (global::System.Web.Services.Description.OperationMessageCollection)o.@Messages; @@ -7921,35 +7921,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations34 = 0; int readerCount34 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id30_input && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -7966,7 +7966,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -7976,28 +7976,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations34, ref readerCount34); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.OperationFault Read73_OperationFault(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id87_OperationFault && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id87_OperationFault && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.OperationFault o; o = new global::System.Web.Services.Description.OperationFault(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[6]; @@ -8015,40 +8015,40 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations35 = 0; int readerCount35 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else { - a_5.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8058,28 +8058,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations35, ref readerCount35); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.OperationOutput Read72_OperationOutput(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id88_OperationOutput && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id88_OperationOutput && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.OperationOutput o; o = new global::System.Web.Services.Description.OperationOutput(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[6]; @@ -8097,40 +8097,40 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations36 = 0; int readerCount36 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else { - a_5.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8140,28 +8140,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations36, ref readerCount36); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.OperationInput Read71_OperationInput(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id89_OperationInput && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id89_OperationInput && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.OperationInput o; o = new global::System.Web.Services.Description.OperationInput(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[6]; @@ -8179,40 +8179,40 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations37 = 0; int readerCount37 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else { - a_5.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8222,28 +8222,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations37, ref readerCount37); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Message Read69_Message(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id90_Message && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id90_Message && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Message o; o = new global::System.Web.Services.Description.Message(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; global::System.Web.Services.Description.MessagePartCollection a_5 = (global::System.Web.Services.Description.MessagePartCollection)o.@Parts; @@ -8257,35 +8257,35 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations38 = 0; int readerCount38 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id2_Item)) @@ -8294,7 +8294,7 @@ public object Read125_definitions() } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8304,28 +8304,28 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations38, ref readerCount38); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.MessagePart Read68_MessagePart(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id91_MessagePart && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id91_MessagePart && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.MessagePart o; o = new global::System.Web.Services.Description.MessagePart(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[7]; @@ -8348,40 +8348,40 @@ public object Read125_definitions() } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations39 = 0; int readerCount39 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else { - a_4.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8391,65 +8391,65 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations39, ref readerCount39); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Types Read67_Types(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id93_Types && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id93_Types && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Types o; o = new global::System.Web.Services.Description.Types(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_3 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - Microsoft.Xml.Serialization.XmlSchemas a_4 = (Microsoft.Xml.Serialization.XmlSchemas)o.@Schemas; + Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSchemas a_4 = o.@Schemas; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) { if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations40 = 0; int readerCount40 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else if (((object)Reader.LocalName == (object)_id94_schema && (object)Reader.NamespaceURI == (object)_id95_Item)) @@ -8458,7 +8458,7 @@ public object Read125_definitions() } else { - a_3.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_3.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -8468,31 +8468,31 @@ public object Read125_definitions() Reader.MoveToContent(); CheckReaderCount(ref whileIterations40, ref readerCount40); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchema Read66_XmlSchema(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchema Read66_XmlSchema(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id96_XmlSchema && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id96_XmlSchema && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchema o; - o = new Microsoft.Xml.Schema.XmlSchema(); - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_7 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_8 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - Microsoft.Xml.XmlAttribute[] a_10 = null; + System.Xml.Schema.XmlSchema o; + o = new System.Xml.Schema.XmlSchema(); + System.Xml.Schema.XmlSchemaObjectCollection a_7 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; + System.Xml.Schema.XmlSchemaObjectCollection a_8 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.XmlAttribute[] a_10 = null; int ca_10 = 0; bool[] paramsRead = new bool[11]; while (Reader.MoveToNextAttribute()) @@ -8534,31 +8534,31 @@ private Microsoft.Xml.Schema.XmlSchema Read66_XmlSchema(bool isNullable, bool ch } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_10 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_10, ca_10, typeof(Microsoft.Xml.XmlAttribute)); a_10[ca_10++] = attr; + a_10 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_10, ca_10, typeof(System.Xml.XmlAttribute)); a_10[ca_10++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations41 = 0; int readerCount41 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id103_include && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -8616,31 +8616,31 @@ private Microsoft.Xml.Schema.XmlSchema Read66_XmlSchema(bool isNullable, bool ch Reader.MoveToContent(); CheckReaderCount(ref whileIterations41, ref readerCount41); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAttributeGroup Read40_XmlSchemaAttributeGroup(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAttributeGroup Read40_XmlSchemaAttributeGroup(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id111_XmlSchemaAttributeGroup && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id111_XmlSchemaAttributeGroup && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAttributeGroup o; - o = new Microsoft.Xml.Schema.XmlSchemaAttributeGroup(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAttributeGroup o; + o = new System.Xml.Schema.XmlSchemaAttributeGroup(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_5 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_5 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -8656,31 +8656,31 @@ private Microsoft.Xml.Schema.XmlSchemaAttributeGroup Read40_XmlSchemaAttributeGr } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations42 = 0; int readerCount42 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -8712,29 +8712,29 @@ private Microsoft.Xml.Schema.XmlSchemaAttributeGroup Read40_XmlSchemaAttributeGr Reader.MoveToContent(); CheckReaderCount(ref whileIterations42, ref readerCount42); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAnyAttribute Read39_XmlSchemaAnyAttribute(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAnyAttribute Read39_XmlSchemaAnyAttribute(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id113_XmlSchemaAnyAttribute && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id113_XmlSchemaAnyAttribute && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAnyAttribute o; - o = new Microsoft.Xml.Schema.XmlSchemaAnyAttribute(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAnyAttribute o; + o = new System.Xml.Schema.XmlSchemaAnyAttribute(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -8756,31 +8756,31 @@ private Microsoft.Xml.Schema.XmlSchemaAnyAttribute Read39_XmlSchemaAnyAttribute( } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations43 = 0; int readerCount43 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -8799,30 +8799,30 @@ private Microsoft.Xml.Schema.XmlSchemaAnyAttribute Read39_XmlSchemaAnyAttribute( Reader.MoveToContent(); CheckReaderCount(ref whileIterations43, ref readerCount43); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAnnotation Read11_XmlSchemaAnnotation(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAnnotation Read11_XmlSchemaAnnotation(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id115_XmlSchemaAnnotation && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id115_XmlSchemaAnnotation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAnnotation o; - o = new Microsoft.Xml.Schema.XmlSchemaAnnotation(); - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_2 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAnnotation o; + o = new System.Xml.Schema.XmlSchemaAnnotation(); + System.Xml.Schema.XmlSchemaObjectCollection a_2 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[4]; while (Reader.MoveToNextAttribute()) @@ -8834,31 +8834,31 @@ private Microsoft.Xml.Schema.XmlSchemaAnnotation Read11_XmlSchemaAnnotation(bool } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations44 = 0; int readerCount44 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -8880,29 +8880,29 @@ private Microsoft.Xml.Schema.XmlSchemaAnnotation Read11_XmlSchemaAnnotation(bool Reader.MoveToContent(); CheckReaderCount(ref whileIterations44, ref readerCount44); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id117_XmlSchemaAppInfo && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id117_XmlSchemaAppInfo && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAppInfo o; - o = new Microsoft.Xml.Schema.XmlSchemaAppInfo(); - Microsoft.Xml.XmlNode[] a_2 = null; + System.Xml.Schema.XmlSchemaAppInfo o; + o = new System.Xml.Schema.XmlSchemaAppInfo(); + System.Xml.XmlNode[] a_2 = null; int ca_2 = 0; bool[] paramsRead = new bool[3]; while (Reader.MoveToNextAttribute()) @@ -8914,8 +8914,8 @@ private Microsoft.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNul } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { @@ -8926,25 +8926,25 @@ private Microsoft.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNul if (Reader.IsEmptyElement) { Reader.Skip(); - o.@Markup = (Microsoft.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(Microsoft.Xml.XmlNode), true); + o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(System.Xml.XmlNode), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations45 = 0; int readerCount45 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - a_2 = (Microsoft.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(Microsoft.Xml.XmlNode)); a_2[ca_2++] = (Microsoft.Xml.XmlNode)ReadXmlNode(false); + a_2 = (System.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(System.Xml.XmlNode)); a_2[ca_2++] = (System.Xml.XmlNode)ReadXmlNode(false); } - else if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Text || - Reader.NodeType == Microsoft.Xml.XmlNodeType.CDATA || - Reader.NodeType == Microsoft.Xml.XmlNodeType.Whitespace || - Reader.NodeType == Microsoft.Xml.XmlNodeType.SignificantWhitespace) + else if (Reader.NodeType == System.Xml.XmlNodeType.Text || + Reader.NodeType == System.Xml.XmlNodeType.CDATA || + Reader.NodeType == System.Xml.XmlNodeType.Whitespace || + Reader.NodeType == System.Xml.XmlNodeType.SignificantWhitespace) { - a_2 = (Microsoft.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(Microsoft.Xml.XmlNode)); a_2[ca_2++] = (Microsoft.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); + a_2 = (System.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(System.Xml.XmlNode)); a_2[ca_2++] = (System.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); } else { @@ -8953,29 +8953,29 @@ private Microsoft.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNul Reader.MoveToContent(); CheckReaderCount(ref whileIterations45, ref readerCount45); } - o.@Markup = (Microsoft.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(Microsoft.Xml.XmlNode), true); + o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(System.Xml.XmlNode), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id119_XmlSchemaDocumentation && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id119_XmlSchemaDocumentation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaDocumentation o; - o = new Microsoft.Xml.Schema.XmlSchemaDocumentation(); - Microsoft.Xml.XmlNode[] a_3 = null; + System.Xml.Schema.XmlSchemaDocumentation o; + o = new System.Xml.Schema.XmlSchemaDocumentation(); + System.Xml.XmlNode[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[4]; while (Reader.MoveToNextAttribute()) @@ -8992,8 +8992,8 @@ private Microsoft.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { @@ -9004,25 +9004,25 @@ private Microsoft.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation if (Reader.IsEmptyElement) { Reader.Skip(); - o.@Markup = (Microsoft.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlNode), true); + o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlNode), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations46 = 0; int readerCount46 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { - a_3 = (Microsoft.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlNode)); a_3[ca_3++] = (Microsoft.Xml.XmlNode)ReadXmlNode(false); + a_3 = (System.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlNode)); a_3[ca_3++] = (System.Xml.XmlNode)ReadXmlNode(false); } - else if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Text || - Reader.NodeType == Microsoft.Xml.XmlNodeType.CDATA || - Reader.NodeType == Microsoft.Xml.XmlNodeType.Whitespace || - Reader.NodeType == Microsoft.Xml.XmlNodeType.SignificantWhitespace) + else if (Reader.NodeType == System.Xml.XmlNodeType.Text || + Reader.NodeType == System.Xml.XmlNodeType.CDATA || + Reader.NodeType == System.Xml.XmlNodeType.Whitespace || + Reader.NodeType == System.Xml.XmlNodeType.SignificantWhitespace) { - a_3 = (Microsoft.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlNode)); a_3[ca_3++] = (Microsoft.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); + a_3 = (System.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlNode)); a_3[ca_3++] = (System.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); } else { @@ -9031,40 +9031,40 @@ private Microsoft.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation Reader.MoveToContent(); CheckReaderCount(ref whileIterations46, ref readerCount46); } - o.@Markup = (Microsoft.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlNode), true); + o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlNode), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaContentProcessing Read38_XmlSchemaContentProcessing(string s) + private System.Xml.Schema.XmlSchemaContentProcessing Read38_XmlSchemaContentProcessing(string s) { switch (s) { - case @"skip": return Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Skip; - case @"lax": return Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Lax; - case @"strict": return Microsoft.Xml.Schema.XmlSchemaContentProcessing.@Strict; - default: throw CreateUnknownConstantException(s, typeof(Microsoft.Xml.Schema.XmlSchemaContentProcessing)); + case @"skip": return System.Xml.Schema.XmlSchemaContentProcessing.@Skip; + case @"lax": return System.Xml.Schema.XmlSchemaContentProcessing.@Lax; + case @"strict": return System.Xml.Schema.XmlSchemaContentProcessing.@Strict; + default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaContentProcessing)); } } - private Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef Read37_XmlSchemaAttributeGroupRef(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAttributeGroupRef Read37_XmlSchemaAttributeGroupRef(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id122_XmlSchemaAttributeGroupRef && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id122_XmlSchemaAttributeGroupRef && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef o; - o = new Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAttributeGroupRef o; + o = new System.Xml.Schema.XmlSchemaAttributeGroupRef(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) @@ -9081,31 +9081,31 @@ private Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef Read37_XmlSchemaAttribut } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations47 = 0; int readerCount47 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9124,29 +9124,29 @@ private Microsoft.Xml.Schema.XmlSchemaAttributeGroupRef Read37_XmlSchemaAttribut Reader.MoveToContent(); CheckReaderCount(ref whileIterations47, ref readerCount47); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAttribute Read36_XmlSchemaAttribute(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAttribute Read36_XmlSchemaAttribute(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id124_XmlSchemaAttribute && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id124_XmlSchemaAttribute && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAttribute o; - o = new Microsoft.Xml.Schema.XmlSchemaAttribute(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAttribute o; + o = new System.Xml.Schema.XmlSchemaAttribute(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[12]; while (Reader.MoveToNextAttribute()) @@ -9193,31 +9193,31 @@ private Microsoft.Xml.Schema.XmlSchemaAttribute Read36_XmlSchemaAttribute(bool i } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations48 = 0; int readerCount48 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9241,29 +9241,29 @@ private Microsoft.Xml.Schema.XmlSchemaAttribute Read36_XmlSchemaAttribute(bool i Reader.MoveToContent(); CheckReaderCount(ref whileIterations48, ref readerCount48); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleType Read34_XmlSchemaSimpleType(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleType Read34_XmlSchemaSimpleType(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id128_XmlSchemaSimpleType && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id128_XmlSchemaSimpleType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleType o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleType(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleType o; + o = new System.Xml.Schema.XmlSchemaSimpleType(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) @@ -9285,31 +9285,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleType Read34_XmlSchemaSimpleType(bool } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations49 = 0; int readerCount49 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9343,32 +9343,32 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleType Read34_XmlSchemaSimpleType(bool Reader.MoveToContent(); CheckReaderCount(ref whileIterations49, ref readerCount49); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion Read33_XmlSchemaSimpleTypeUnion(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleTypeUnion Read33_XmlSchemaSimpleTypeUnion(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id133_XmlSchemaSimpleTypeUnion && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id133_XmlSchemaSimpleTypeUnion && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleTypeUnion o; + o = new System.Xml.Schema.XmlSchemaSimpleTypeUnion(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_4 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; - Microsoft.Xml.XmlQualifiedName[] a_5 = null; + System.Xml.Schema.XmlSchemaObjectCollection a_4 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; + System.Xml.XmlQualifiedName[] a_5 = null; int ca_5 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9384,38 +9384,38 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion Read33_XmlSchemaSimpleType string[] vals = listValues.Split(null); for (int i = 0; i < vals.Length; i++) { - a_5 = (Microsoft.Xml.XmlQualifiedName[])EnsureArrayIndex(a_5, ca_5, typeof(Microsoft.Xml.XmlQualifiedName)); a_5[ca_5++] = ToXmlQualifiedName(vals[i]); + a_5 = (System.Xml.XmlQualifiedName[])EnsureArrayIndex(a_5, ca_5, typeof(System.Xml.XmlQualifiedName)); a_5[ca_5++] = ToXmlQualifiedName(vals[i]); } } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); - o.@MemberTypes = (Microsoft.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(Microsoft.Xml.XmlQualifiedName), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); + o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); - o.@MemberTypes = (Microsoft.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(Microsoft.Xml.XmlQualifiedName), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); + o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations50 = 0; int readerCount50 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9438,32 +9438,32 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeUnion Read33_XmlSchemaSimpleType Reader.MoveToContent(); CheckReaderCount(ref whileIterations50, ref readerCount50); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); - o.@MemberTypes = (Microsoft.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(Microsoft.Xml.XmlQualifiedName), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); + o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction Read32_XmlSchemaSimpleTypeRestriction(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleTypeRestriction Read32_XmlSchemaSimpleTypeRestriction(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id135_XmlSchemaSimpleTypeRestriction && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id135_XmlSchemaSimpleTypeRestriction && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleTypeRestriction o; + o = new System.Xml.Schema.XmlSchemaSimpleTypeRestriction(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -9479,31 +9479,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction Read32_XmlSchemaSimp } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations51 = 0; int readerCount51 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9575,29 +9575,29 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeRestriction Read32_XmlSchemaSimp Reader.MoveToContent(); CheckReaderCount(ref whileIterations51, ref readerCount51); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMinLengthFacet Read31_XmlSchemaMinLengthFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMinLengthFacet Read31_XmlSchemaMinLengthFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id148_XmlSchemaMinLengthFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id148_XmlSchemaMinLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMinLengthFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMinLengthFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMinLengthFacet o; + o = new System.Xml.Schema.XmlSchemaMinLengthFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9614,36 +9614,36 @@ private Microsoft.Xml.Schema.XmlSchemaMinLengthFacet Read31_XmlSchemaMinLengthFa } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations52 = 0; int readerCount52 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9662,29 +9662,29 @@ private Microsoft.Xml.Schema.XmlSchemaMinLengthFacet Read31_XmlSchemaMinLengthFa Reader.MoveToContent(); CheckReaderCount(ref whileIterations52, ref readerCount52); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet Read30_XmlSchemaMinExclusiveFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMinExclusiveFacet Read30_XmlSchemaMinExclusiveFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id150_XmlSchemaMinExclusiveFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id150_XmlSchemaMinExclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMinExclusiveFacet o; + o = new System.Xml.Schema.XmlSchemaMinExclusiveFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9701,36 +9701,36 @@ private Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet Read30_XmlSchemaMinExclu } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations53 = 0; int readerCount53 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9749,29 +9749,29 @@ private Microsoft.Xml.Schema.XmlSchemaMinExclusiveFacet Read30_XmlSchemaMinExclu Reader.MoveToContent(); CheckReaderCount(ref whileIterations53, ref readerCount53); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet Read29_XmlSchemaWhiteSpaceFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaWhiteSpaceFacet Read29_XmlSchemaWhiteSpaceFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id151_XmlSchemaWhiteSpaceFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id151_XmlSchemaWhiteSpaceFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaWhiteSpaceFacet o; + o = new System.Xml.Schema.XmlSchemaWhiteSpaceFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9788,36 +9788,36 @@ private Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet Read29_XmlSchemaWhiteSpace } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations54 = 0; int readerCount54 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9836,29 +9836,29 @@ private Microsoft.Xml.Schema.XmlSchemaWhiteSpaceFacet Read29_XmlSchemaWhiteSpace Reader.MoveToContent(); CheckReaderCount(ref whileIterations54, ref readerCount54); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet Read28_XmlSchemaMaxExclusiveFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMaxExclusiveFacet Read28_XmlSchemaMaxExclusiveFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id152_XmlSchemaMaxExclusiveFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id152_XmlSchemaMaxExclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMaxExclusiveFacet o; + o = new System.Xml.Schema.XmlSchemaMaxExclusiveFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9875,36 +9875,36 @@ private Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet Read28_XmlSchemaMaxExclu } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations55 = 0; int readerCount55 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -9923,29 +9923,29 @@ private Microsoft.Xml.Schema.XmlSchemaMaxExclusiveFacet Read28_XmlSchemaMaxExclu Reader.MoveToContent(); CheckReaderCount(ref whileIterations55, ref readerCount55); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet Read27_XmlSchemaMaxInclusiveFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMaxInclusiveFacet Read27_XmlSchemaMaxInclusiveFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id153_XmlSchemaMaxInclusiveFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id153_XmlSchemaMaxInclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMaxInclusiveFacet o; + o = new System.Xml.Schema.XmlSchemaMaxInclusiveFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -9962,36 +9962,36 @@ private Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet Read27_XmlSchemaMaxInclu } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations56 = 0; int readerCount56 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10010,29 +10010,29 @@ private Microsoft.Xml.Schema.XmlSchemaMaxInclusiveFacet Read27_XmlSchemaMaxInclu Reader.MoveToContent(); CheckReaderCount(ref whileIterations56, ref readerCount56); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaEnumerationFacet Read26_XmlSchemaEnumerationFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaEnumerationFacet Read26_XmlSchemaEnumerationFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id154_XmlSchemaEnumerationFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id154_XmlSchemaEnumerationFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaEnumerationFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaEnumerationFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaEnumerationFacet o; + o = new System.Xml.Schema.XmlSchemaEnumerationFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10049,36 +10049,36 @@ private Microsoft.Xml.Schema.XmlSchemaEnumerationFacet Read26_XmlSchemaEnumerati } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations57 = 0; int readerCount57 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10097,29 +10097,29 @@ private Microsoft.Xml.Schema.XmlSchemaEnumerationFacet Read26_XmlSchemaEnumerati Reader.MoveToContent(); CheckReaderCount(ref whileIterations57, ref readerCount57); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaPatternFacet Read25_XmlSchemaPatternFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaPatternFacet Read25_XmlSchemaPatternFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id155_XmlSchemaPatternFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id155_XmlSchemaPatternFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaPatternFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaPatternFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaPatternFacet o; + o = new System.Xml.Schema.XmlSchemaPatternFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10136,36 +10136,36 @@ private Microsoft.Xml.Schema.XmlSchemaPatternFacet Read25_XmlSchemaPatternFacet( } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations58 = 0; int readerCount58 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10184,29 +10184,29 @@ private Microsoft.Xml.Schema.XmlSchemaPatternFacet Read25_XmlSchemaPatternFacet( Reader.MoveToContent(); CheckReaderCount(ref whileIterations58, ref readerCount58); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet Read24_XmlSchemaTotalDigitsFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaTotalDigitsFacet Read24_XmlSchemaTotalDigitsFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id156_XmlSchemaTotalDigitsFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id156_XmlSchemaTotalDigitsFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaTotalDigitsFacet o; + o = new System.Xml.Schema.XmlSchemaTotalDigitsFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10223,36 +10223,36 @@ private Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet Read24_XmlSchemaTotalDigi } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations59 = 0; int readerCount59 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10271,29 +10271,29 @@ private Microsoft.Xml.Schema.XmlSchemaTotalDigitsFacet Read24_XmlSchemaTotalDigi Reader.MoveToContent(); CheckReaderCount(ref whileIterations59, ref readerCount59); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaLengthFacet Read23_XmlSchemaLengthFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaLengthFacet Read23_XmlSchemaLengthFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id157_XmlSchemaLengthFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id157_XmlSchemaLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaLengthFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaLengthFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaLengthFacet o; + o = new System.Xml.Schema.XmlSchemaLengthFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10310,36 +10310,36 @@ private Microsoft.Xml.Schema.XmlSchemaLengthFacet Read23_XmlSchemaLengthFacet(bo } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations60 = 0; int readerCount60 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10358,29 +10358,29 @@ private Microsoft.Xml.Schema.XmlSchemaLengthFacet Read23_XmlSchemaLengthFacet(bo Reader.MoveToContent(); CheckReaderCount(ref whileIterations60, ref readerCount60); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet Read22_XmlSchemaMaxLengthFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMaxLengthFacet Read22_XmlSchemaMaxLengthFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id158_XmlSchemaMaxLengthFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id158_XmlSchemaMaxLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMaxLengthFacet o; + o = new System.Xml.Schema.XmlSchemaMaxLengthFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10397,36 +10397,36 @@ private Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet Read22_XmlSchemaMaxLengthFa } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations61 = 0; int readerCount61 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10445,29 +10445,29 @@ private Microsoft.Xml.Schema.XmlSchemaMaxLengthFacet Read22_XmlSchemaMaxLengthFa Reader.MoveToContent(); CheckReaderCount(ref whileIterations61, ref readerCount61); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet Read21_XmlSchemaMinInclusiveFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaMinInclusiveFacet Read21_XmlSchemaMinInclusiveFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id159_XmlSchemaMinInclusiveFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id159_XmlSchemaMinInclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaMinInclusiveFacet o; + o = new System.Xml.Schema.XmlSchemaMinInclusiveFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10484,36 +10484,36 @@ private Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet Read21_XmlSchemaMinInclu } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations62 = 0; int readerCount62 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10532,29 +10532,29 @@ private Microsoft.Xml.Schema.XmlSchemaMinInclusiveFacet Read21_XmlSchemaMinInclu Reader.MoveToContent(); CheckReaderCount(ref whileIterations62, ref readerCount62); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet Read20_XmlSchemaFractionDigitsFacet(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaFractionDigitsFacet Read20_XmlSchemaFractionDigitsFacet(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id160_XmlSchemaFractionDigitsFacet && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id160_XmlSchemaFractionDigitsFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet o; - o = new Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaFractionDigitsFacet o; + o = new System.Xml.Schema.XmlSchemaFractionDigitsFacet(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10571,36 +10571,36 @@ private Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet Read20_XmlSchemaFracti } else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsFixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[5] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations63 = 0; int readerCount63 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10619,29 +10619,29 @@ private Microsoft.Xml.Schema.XmlSchemaFractionDigitsFacet Read20_XmlSchemaFracti Reader.MoveToContent(); CheckReaderCount(ref whileIterations63, ref readerCount63); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleTypeList Read17_XmlSchemaSimpleTypeList(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleTypeList Read17_XmlSchemaSimpleTypeList(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id161_XmlSchemaSimpleTypeList && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id161_XmlSchemaSimpleTypeList && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleTypeList o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleTypeList(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleTypeList o; + o = new System.Xml.Schema.XmlSchemaSimpleTypeList(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -10658,31 +10658,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeList Read17_XmlSchemaSimpleTypeL } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations64 = 0; int readerCount64 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10706,7 +10706,7 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleTypeList Read17_XmlSchemaSimpleTypeL Reader.MoveToContent(); CheckReaderCount(ref whileIterations64, ref readerCount64); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } @@ -10720,65 +10720,65 @@ internal System.Collections.Hashtable XmlSchemaDerivationMethodValues if ((object)_XmlSchemaDerivationMethodValues == null) { System.Collections.Hashtable h = new System.Collections.Hashtable(); - h.Add(@"", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Empty); - h.Add(@"substitution", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Substitution); - h.Add(@"extension", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Extension); - h.Add(@"restriction", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Restriction); - h.Add(@"list", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@List); - h.Add(@"union", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@Union); - h.Add(@"#all", (long)Microsoft.Xml.Schema.XmlSchemaDerivationMethod.@All); + h.Add(@"", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Empty); + h.Add(@"substitution", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution); + h.Add(@"extension", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Extension); + h.Add(@"restriction", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction); + h.Add(@"list", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@List); + h.Add(@"union", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Union); + h.Add(@"#all", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@All); _XmlSchemaDerivationMethodValues = h; } return _XmlSchemaDerivationMethodValues; } } - private Microsoft.Xml.Schema.XmlSchemaDerivationMethod Read7_XmlSchemaDerivationMethod(string s) + private System.Xml.Schema.XmlSchemaDerivationMethod Read7_XmlSchemaDerivationMethod(string s) { - return (Microsoft.Xml.Schema.XmlSchemaDerivationMethod)ToEnum(s, XmlSchemaDerivationMethodValues, @"System.Xml.Schema.XmlSchemaDerivationMethod"); + return (System.Xml.Schema.XmlSchemaDerivationMethod)ToEnum(s, XmlSchemaDerivationMethodValues, @"System.Xml.Schema.XmlSchemaDerivationMethod"); } - private Microsoft.Xml.Schema.XmlSchemaUse Read35_XmlSchemaUse(string s) + private System.Xml.Schema.XmlSchemaUse Read35_XmlSchemaUse(string s) { switch (s) { - case @"optional": return Microsoft.Xml.Schema.XmlSchemaUse.@Optional; - case @"prohibited": return Microsoft.Xml.Schema.XmlSchemaUse.@Prohibited; - case @"required": return Microsoft.Xml.Schema.XmlSchemaUse.@Required; - default: throw CreateUnknownConstantException(s, typeof(Microsoft.Xml.Schema.XmlSchemaUse)); + case @"optional": return System.Xml.Schema.XmlSchemaUse.@Optional; + case @"prohibited": return System.Xml.Schema.XmlSchemaUse.@Prohibited; + case @"required": return System.Xml.Schema.XmlSchemaUse.@Required; + default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaUse)); } } - private Microsoft.Xml.Schema.XmlSchemaForm Read6_XmlSchemaForm(string s) + private System.Xml.Schema.XmlSchemaForm Read6_XmlSchemaForm(string s) { switch (s) { - case @"qualified": return Microsoft.Xml.Schema.XmlSchemaForm.@Qualified; - case @"unqualified": return Microsoft.Xml.Schema.XmlSchemaForm.@Unqualified; - default: throw CreateUnknownConstantException(s, typeof(Microsoft.Xml.Schema.XmlSchemaForm)); + case @"qualified": return System.Xml.Schema.XmlSchemaForm.@Qualified; + case @"unqualified": return System.Xml.Schema.XmlSchemaForm.@Unqualified; + default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaForm)); } } - private Microsoft.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id163_XmlSchemaElement && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id163_XmlSchemaElement && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaElement o; - o = new Microsoft.Xml.Schema.XmlSchemaElement(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaElement o; + o = new System.Xml.Schema.XmlSchemaElement(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_18 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; + System.Xml.Schema.XmlSchemaObjectCollection a_18 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; bool[] paramsRead = new bool[19]; while (Reader.MoveToNextAttribute()) { @@ -10799,7 +10799,7 @@ private Microsoft.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNul } else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id166_abstract && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsAbstract = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsAbstract = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[6] = true; } else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id167_block && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -10834,7 +10834,7 @@ private Microsoft.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNul } else if (!paramsRead[13] && ((object)Reader.LocalName == (object)_id168_nillable && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsNillable = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsNillable = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[13] = true; } else if (!paramsRead[14] && ((object)Reader.LocalName == (object)_id123_ref && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -10854,31 +10854,31 @@ private Microsoft.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNul } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations65 = 0; int readerCount65 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -10919,31 +10919,31 @@ private Microsoft.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNul Reader.MoveToContent(); CheckReaderCount(ref whileIterations65, ref readerCount65); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaKeyref Read51_XmlSchemaKeyref(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaKeyref Read51_XmlSchemaKeyref(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id173_XmlSchemaKeyref && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id173_XmlSchemaKeyref && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaKeyref o; - o = new Microsoft.Xml.Schema.XmlSchemaKeyref(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaKeyref o; + o = new System.Xml.Schema.XmlSchemaKeyref(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; bool[] paramsRead = new bool[8]; while (Reader.MoveToNextAttribute()) { @@ -10964,31 +10964,31 @@ private Microsoft.Xml.Schema.XmlSchemaKeyref Read51_XmlSchemaKeyref(bool isNulla } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations66 = 0; int readerCount66 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11016,29 +11016,29 @@ private Microsoft.Xml.Schema.XmlSchemaKeyref Read51_XmlSchemaKeyref(bool isNulla Reader.MoveToContent(); CheckReaderCount(ref whileIterations66, ref readerCount66); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaXPath Read47_XmlSchemaXPath(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaXPath Read47_XmlSchemaXPath(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id177_XmlSchemaXPath && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id177_XmlSchemaXPath && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaXPath o; - o = new Microsoft.Xml.Schema.XmlSchemaXPath(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaXPath o; + o = new System.Xml.Schema.XmlSchemaXPath(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) @@ -11055,31 +11055,31 @@ private Microsoft.Xml.Schema.XmlSchemaXPath Read47_XmlSchemaXPath(bool isNullabl } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations67 = 0; int readerCount67 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11098,31 +11098,31 @@ private Microsoft.Xml.Schema.XmlSchemaXPath Read47_XmlSchemaXPath(bool isNullabl Reader.MoveToContent(); CheckReaderCount(ref whileIterations67, ref readerCount67); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaUnique Read50_XmlSchemaUnique(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaUnique Read50_XmlSchemaUnique(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id179_XmlSchemaUnique && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id179_XmlSchemaUnique && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaUnique o; - o = new Microsoft.Xml.Schema.XmlSchemaUnique(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaUnique o; + o = new System.Xml.Schema.XmlSchemaUnique(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -11138,31 +11138,31 @@ private Microsoft.Xml.Schema.XmlSchemaUnique Read50_XmlSchemaUnique(bool isNulla } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations68 = 0; int readerCount68 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11190,31 +11190,31 @@ private Microsoft.Xml.Schema.XmlSchemaUnique Read50_XmlSchemaUnique(bool isNulla Reader.MoveToContent(); CheckReaderCount(ref whileIterations68, ref readerCount68); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaKey Read49_XmlSchemaKey(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaKey Read49_XmlSchemaKey(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id180_XmlSchemaKey && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id180_XmlSchemaKey && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaKey o; - o = new Microsoft.Xml.Schema.XmlSchemaKey(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaKey o; + o = new System.Xml.Schema.XmlSchemaKey(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -11230,31 +11230,31 @@ private Microsoft.Xml.Schema.XmlSchemaKey Read49_XmlSchemaKey(bool isNullable, b } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations69 = 0; int readerCount69 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11282,31 +11282,31 @@ private Microsoft.Xml.Schema.XmlSchemaKey Read49_XmlSchemaKey(bool isNullable, b Reader.MoveToContent(); CheckReaderCount(ref whileIterations69, ref readerCount69); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id181_XmlSchemaComplexType && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id181_XmlSchemaComplexType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaComplexType o; - o = new Microsoft.Xml.Schema.XmlSchemaComplexType(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaComplexType o; + o = new System.Xml.Schema.XmlSchemaComplexType(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_11 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_11 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[13]; while (Reader.MoveToNextAttribute()) { @@ -11327,7 +11327,7 @@ private Microsoft.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bo } else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id166_abstract && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsAbstract = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsAbstract = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[6] = true; } else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id167_block && (object)Reader.NamespaceURI == (object)_id5_Item)) @@ -11337,36 +11337,36 @@ private Microsoft.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bo } else if (!paramsRead[8] && ((object)Reader.LocalName == (object)_id182_mixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsMixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsMixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[8] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations70 = 0; int readerCount70 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11428,31 +11428,31 @@ private Microsoft.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bo Reader.MoveToContent(); CheckReaderCount(ref whileIterations70, ref readerCount70); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAll Read55_XmlSchemaAll(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAll Read55_XmlSchemaAll(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id188_XmlSchemaAll && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id188_XmlSchemaAll && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAll o; - o = new Microsoft.Xml.Schema.XmlSchemaAll(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAll o; + o = new System.Xml.Schema.XmlSchemaAll(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -11473,31 +11473,31 @@ private Microsoft.Xml.Schema.XmlSchemaAll Read55_XmlSchemaAll(bool isNullable, b } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations71 = 0; int readerCount71 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11520,31 +11520,31 @@ private Microsoft.Xml.Schema.XmlSchemaAll Read55_XmlSchemaAll(bool isNullable, b Reader.MoveToContent(); CheckReaderCount(ref whileIterations71, ref readerCount71); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaChoice Read54_XmlSchemaChoice(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaChoice Read54_XmlSchemaChoice(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id189_XmlSchemaChoice && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id189_XmlSchemaChoice && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaChoice o; - o = new Microsoft.Xml.Schema.XmlSchemaChoice(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaChoice o; + o = new System.Xml.Schema.XmlSchemaChoice(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -11565,31 +11565,31 @@ private Microsoft.Xml.Schema.XmlSchemaChoice Read54_XmlSchemaChoice(bool isNulla } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations72 = 0; int readerCount72 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11628,29 +11628,29 @@ private Microsoft.Xml.Schema.XmlSchemaChoice Read54_XmlSchemaChoice(bool isNulla Reader.MoveToContent(); CheckReaderCount(ref whileIterations72, ref readerCount72); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaGroupRef Read44_XmlSchemaGroupRef(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaGroupRef Read44_XmlSchemaGroupRef(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id191_XmlSchemaGroupRef && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id191_XmlSchemaGroupRef && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaGroupRef o; - o = new Microsoft.Xml.Schema.XmlSchemaGroupRef(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaGroupRef o; + o = new System.Xml.Schema.XmlSchemaGroupRef(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) @@ -11677,31 +11677,31 @@ private Microsoft.Xml.Schema.XmlSchemaGroupRef Read44_XmlSchemaGroupRef(bool isN } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations73 = 0; int readerCount73 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11720,31 +11720,31 @@ private Microsoft.Xml.Schema.XmlSchemaGroupRef Read44_XmlSchemaGroupRef(bool isN Reader.MoveToContent(); CheckReaderCount(ref whileIterations73, ref readerCount73); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSequence Read53_XmlSchemaSequence(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSequence Read53_XmlSchemaSequence(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id192_XmlSchemaSequence && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id192_XmlSchemaSequence && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSequence o; - o = new Microsoft.Xml.Schema.XmlSchemaSequence(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSequence o; + o = new System.Xml.Schema.XmlSchemaSequence(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -11765,31 +11765,31 @@ private Microsoft.Xml.Schema.XmlSchemaSequence Read53_XmlSchemaSequence(bool isN } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations74 = 0; int readerCount74 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11828,29 +11828,29 @@ private Microsoft.Xml.Schema.XmlSchemaSequence Read53_XmlSchemaSequence(bool isN Reader.MoveToContent(); CheckReaderCount(ref whileIterations74, ref readerCount74); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaAny Read46_XmlSchemaAny(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaAny Read46_XmlSchemaAny(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id193_XmlSchemaAny && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id193_XmlSchemaAny && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaAny o; - o = new Microsoft.Xml.Schema.XmlSchemaAny(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaAny o; + o = new System.Xml.Schema.XmlSchemaAny(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[8]; while (Reader.MoveToNextAttribute()) @@ -11882,31 +11882,31 @@ private Microsoft.Xml.Schema.XmlSchemaAny Read46_XmlSchemaAny(bool isNullable, b } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations75 = 0; int readerCount75 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -11925,29 +11925,29 @@ private Microsoft.Xml.Schema.XmlSchemaAny Read46_XmlSchemaAny(bool isNullable, b Reader.MoveToContent(); CheckReaderCount(ref whileIterations75, ref readerCount75); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleContent Read61_XmlSchemaSimpleContent(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleContent Read61_XmlSchemaSimpleContent(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id194_XmlSchemaSimpleContent && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id194_XmlSchemaSimpleContent && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleContent o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleContent(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleContent o; + o = new System.Xml.Schema.XmlSchemaSimpleContent(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) @@ -11959,31 +11959,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContent Read61_XmlSchemaSimpleConten } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations76 = 0; int readerCount76 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12012,31 +12012,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContent Read61_XmlSchemaSimpleConten Reader.MoveToContent(); CheckReaderCount(ref whileIterations76, ref readerCount76); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension Read60_Item(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleContentExtension Read60_Item(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id196_Item && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id196_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleContentExtension o; + o = new System.Xml.Schema.XmlSchemaSimpleContentExtension(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_5 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_5 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) { @@ -12052,31 +12052,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension Read60_Item(bool is } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations77 = 0; int readerCount77 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12108,32 +12108,32 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContentExtension Read60_Item(bool is Reader.MoveToContent(); CheckReaderCount(ref whileIterations77, ref readerCount77); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction Read59_Item(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaSimpleContentRestriction Read59_Item(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id197_Item && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id197_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction o; - o = new Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaSimpleContentRestriction o; + o = new System.Xml.Schema.XmlSchemaSimpleContentRestriction(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_7 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; + System.Xml.Schema.XmlSchemaObjectCollection a_7 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[9]; while (Reader.MoveToNextAttribute()) { @@ -12149,31 +12149,31 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction Read59_Item(bool } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations78 = 0; int readerCount78 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12258,29 +12258,29 @@ private Microsoft.Xml.Schema.XmlSchemaSimpleContentRestriction Read59_Item(bool Reader.MoveToContent(); CheckReaderCount(ref whileIterations78, ref readerCount78); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaComplexContent Read58_XmlSchemaComplexContent(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaComplexContent Read58_XmlSchemaComplexContent(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id198_XmlSchemaComplexContent && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id198_XmlSchemaComplexContent && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaComplexContent o; - o = new Microsoft.Xml.Schema.XmlSchemaComplexContent(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaComplexContent o; + o = new System.Xml.Schema.XmlSchemaComplexContent(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -12292,36 +12292,36 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContent Read58_XmlSchemaComplexCont } else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id182_mixed && (object)Reader.NamespaceURI == (object)_id5_Item)) { - o.@IsMixed = Microsoft.Xml.XmlConvert.ToBoolean(Reader.Value); + o.@IsMixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); paramsRead[4] = true; } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations79 = 0; int readerCount79 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12350,31 +12350,31 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContent Read58_XmlSchemaComplexCont Reader.MoveToContent(); CheckReaderCount(ref whileIterations79, ref readerCount79); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction Read57_Item(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaComplexContentRestriction Read57_Item(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id199_Item && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id199_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction o; - o = new Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaComplexContentRestriction o; + o = new System.Xml.Schema.XmlSchemaComplexContentRestriction(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[8]; while (Reader.MoveToNextAttribute()) { @@ -12390,31 +12390,31 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction Read57_Item(bool } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations80 = 0; int readerCount80 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12466,31 +12466,31 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContentRestriction Read57_Item(bool Reader.MoveToContent(); CheckReaderCount(ref whileIterations80, ref readerCount80); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaComplexContentExtension Read56_Item(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaComplexContentExtension Read56_Item(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id200_Item && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id200_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaComplexContentExtension o; - o = new Microsoft.Xml.Schema.XmlSchemaComplexContentExtension(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaComplexContentExtension o; + o = new System.Xml.Schema.XmlSchemaComplexContentExtension(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_6 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; + System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; bool[] paramsRead = new bool[8]; while (Reader.MoveToNextAttribute()) { @@ -12506,31 +12506,31 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContentExtension Read56_Item(bool i } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations81 = 0; int readerCount81 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12582,29 +12582,29 @@ private Microsoft.Xml.Schema.XmlSchemaComplexContentExtension Read56_Item(bool i Reader.MoveToContent(); CheckReaderCount(ref whileIterations81, ref readerCount81); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaGroup Read63_XmlSchemaGroup(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaGroup Read63_XmlSchemaGroup(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id201_XmlSchemaGroup && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id201_XmlSchemaGroup && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaGroup o; - o = new Microsoft.Xml.Schema.XmlSchemaGroup(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaGroup o; + o = new System.Xml.Schema.XmlSchemaGroup(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -12621,31 +12621,31 @@ private Microsoft.Xml.Schema.XmlSchemaGroup Read63_XmlSchemaGroup(bool isNullabl } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations82 = 0; int readerCount82 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12679,29 +12679,29 @@ private Microsoft.Xml.Schema.XmlSchemaGroup Read63_XmlSchemaGroup(bool isNullabl Reader.MoveToContent(); CheckReaderCount(ref whileIterations82, ref readerCount82); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaNotation Read65_XmlSchemaNotation(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaNotation Read65_XmlSchemaNotation(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id202_XmlSchemaNotation && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id202_XmlSchemaNotation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaNotation o; - o = new Microsoft.Xml.Schema.XmlSchemaNotation(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaNotation o; + o = new System.Xml.Schema.XmlSchemaNotation(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[7]; while (Reader.MoveToNextAttribute()) @@ -12728,31 +12728,31 @@ private Microsoft.Xml.Schema.XmlSchemaNotation Read65_XmlSchemaNotation(bool isN } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations83 = 0; int readerCount83 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12771,31 +12771,31 @@ private Microsoft.Xml.Schema.XmlSchemaNotation Read65_XmlSchemaNotation(bool isN Reader.MoveToContent(); CheckReaderCount(ref whileIterations83, ref readerCount83); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaRedefine Read64_XmlSchemaRedefine(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaRedefine Read64_XmlSchemaRedefine(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id205_XmlSchemaRedefine && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id205_XmlSchemaRedefine && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaRedefine o; - o = new Microsoft.Xml.Schema.XmlSchemaRedefine(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaRedefine o; + o = new System.Xml.Schema.XmlSchemaRedefine(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; - Microsoft.Xml.Schema.XmlSchemaObjectCollection a_4 = (Microsoft.Xml.Schema.XmlSchemaObjectCollection)o.@Items; + System.Xml.Schema.XmlSchemaObjectCollection a_4 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) { @@ -12811,31 +12811,31 @@ private Microsoft.Xml.Schema.XmlSchemaRedefine Read64_XmlSchemaRedefine(bool isN } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations84 = 0; int readerCount84 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12869,29 +12869,29 @@ private Microsoft.Xml.Schema.XmlSchemaRedefine Read64_XmlSchemaRedefine(bool isN Reader.MoveToContent(); CheckReaderCount(ref whileIterations84, ref readerCount84); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaImport Read13_XmlSchemaImport(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaImport Read13_XmlSchemaImport(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id207_XmlSchemaImport && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id207_XmlSchemaImport && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaImport o; - o = new Microsoft.Xml.Schema.XmlSchemaImport(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaImport o; + o = new System.Xml.Schema.XmlSchemaImport(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[6]; while (Reader.MoveToNextAttribute()) @@ -12913,31 +12913,31 @@ private Microsoft.Xml.Schema.XmlSchemaImport Read13_XmlSchemaImport(bool isNulla } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations85 = 0; int readerCount85 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -12956,29 +12956,29 @@ private Microsoft.Xml.Schema.XmlSchemaImport Read13_XmlSchemaImport(bool isNulla Reader.MoveToContent(); CheckReaderCount(ref whileIterations85, ref readerCount85); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } - private Microsoft.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNullable, bool checkType) + private System.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id208_XmlSchemaInclude && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id208_XmlSchemaInclude && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; DecodeName = false; - Microsoft.Xml.Schema.XmlSchemaInclude o; - o = new Microsoft.Xml.Schema.XmlSchemaInclude(); - Microsoft.Xml.XmlAttribute[] a_3 = null; + System.Xml.Schema.XmlSchemaInclude o; + o = new System.Xml.Schema.XmlSchemaInclude(); + System.Xml.XmlAttribute[] a_3 = null; int ca_3 = 0; bool[] paramsRead = new bool[5]; while (Reader.MoveToNextAttribute()) @@ -12995,31 +12995,31 @@ private Microsoft.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNul } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_3 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute)); a_3[ca_3++] = attr; + a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; } } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations86 = 0; int readerCount86 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) { @@ -13038,28 +13038,28 @@ private Microsoft.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNul Reader.MoveToContent(); CheckReaderCount(ref whileIterations86, ref readerCount86); } - o.@UnhandledAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(Microsoft.Xml.XmlAttribute), true); + o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } private global::System.Web.Services.Description.Import Read4_Import(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id209_Import && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id209_Import && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; global::System.Web.Services.Description.Import o; o = new global::System.Web.Services.Description.Import(); - Microsoft.Xml.XmlAttribute[] a_1 = null; + System.Xml.XmlAttribute[] a_1 = null; int ca_1 = 0; global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_3 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; bool[] paramsRead = new bool[6]; @@ -13077,40 +13077,40 @@ private Microsoft.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNul } else if (IsXmlnsAttribute(Reader.Name)) { - if (o.@Namespaces == null) o.@Namespaces = new Microsoft.Xml.Serialization.XmlSerializerNamespaces(); - ((Microsoft.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); + if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); + ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); } else { - Microsoft.Xml.XmlAttribute attr = (Microsoft.Xml.XmlAttribute)Document.ReadNode(Reader); + System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); - a_1 = (Microsoft.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute)); a_1[ca_1++] = attr; + a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; } } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); int whileIterations87 = 0; int readerCount87 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) { - o.@DocumentationElement = (Microsoft.Xml.XmlElement)ReadXmlNode(false); + o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); paramsRead[0] = true; } else { - a_3.Add((Microsoft.Xml.XmlElement)ReadXmlNode(false)); + a_3.Add((System.Xml.XmlElement)ReadXmlNode(false)); } } else @@ -13120,7 +13120,7 @@ private Microsoft.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNul Reader.MoveToContent(); CheckReaderCount(ref whileIterations87, ref readerCount87); } - o.@ExtensibleAttributes = (Microsoft.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(Microsoft.Xml.XmlAttribute), true); + o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); ReadEndElement(); return o; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs index 08565ab9618..47fde06f7b2 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs @@ -5,7 +5,7 @@ namespace System.Web.Services.Description { using System; - using Microsoft.Xml; + using System.Xml; /// /// diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs index d45b6ed1d3c..cec0f0a803d 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs @@ -6,8 +6,8 @@ namespace System.Web.Services.Description { using System.ComponentModel; using System.Web.Services.Configuration; - using Microsoft.Xml; - using Microsoft.Xml.Serialization; + using System.Xml; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; /// [XmlFormatExtension("binding", Soap12Binding.Namespace, typeof(Binding))] diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs index b80fc99893c..2e5bf033ff1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs @@ -4,10 +4,10 @@ namespace System.Web.Services.Description { - using Microsoft.Xml; + using System.Xml; using System.IO; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.ComponentModel; using System.Text; using System.Web.Services.Configuration; diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs index 7dcfa6cb482..dc1d32b5aba 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs @@ -8,9 +8,9 @@ namespace System.Web.Services.Description using System.Globalization; using System.IO; using System.ComponentModel; - using Microsoft.Xml; - using Microsoft.Xml.Schema; - using Microsoft.Xml.Serialization; + using System.Xml; + using System.Xml.Schema; + using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System.Collections; using System.Collections.Specialized; @@ -182,26 +182,26 @@ private static void SchemaValidationHandler(object sender, ValidationEventArgs a internal class WebReferenceOptionsSerializationWriter : XmlSerializationWriter { - private string Write1_CodeGenerationOptions(Microsoft.Xml.Serialization.CodeGenerationOptions v) + private string Write1_CodeGenerationOptions(System.Xml.Serialization.CodeGenerationOptions v) { string s = null; switch (v) { - case Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateProperties: s = @"properties"; break; - case Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync: s = @"newAsync"; break; - case Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync: s = @"oldAsync"; break; - case Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOrder: s = @"order"; break; - case Microsoft.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding: s = @"enableDataBinding"; break; + case System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties: s = @"properties"; break; + case System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync: s = @"newAsync"; break; + case System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync: s = @"oldAsync"; break; + case System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder: s = @"order"; break; + case System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding: s = @"enableDataBinding"; break; default: s = FromEnum(((System.Int64)v), new string[] { @"properties", @"newAsync", @"oldAsync", @"order", - @"enableDataBinding" }, new System.Int64[] { (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateProperties, - (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync, - (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync, - (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOrder, - (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding }, @"System.Xml.Serialization.CodeGenerationOptions"); break; + @"enableDataBinding" }, new System.Int64[] { (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties, + (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync, + (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync, + (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder, + (long)System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding }, @"System.Xml.Serialization.CodeGenerationOptions"); break; } return s; } @@ -242,7 +242,7 @@ private void Write4_WebReferenceOptions(string n, string ns, WebReferenceOptions if (needType) WriteXsiType(@"webReferenceOptions", @"http://microsoft.com/webReference/"); if (((CodeGenerationOptions)o.@CodeGenerationOptions) != (CodeGenerationOptions.@GenerateOldAsync)) { - WriteElementString(@"codeGenerationOptions", @"http://microsoft.com/webReference/", Write1_CodeGenerationOptions(((CodeGenerationOptions)o.@CodeGenerationOptions))); + WriteElementString(@"codeGenerationOptions", @"http://microsoft.com/webReference/", Write1_CodeGenerationOptions((System.Xml.Serialization.CodeGenerationOptions)(long)o.@CodeGenerationOptions)); } { System.Collections.Specialized.StringCollection a = (System.Collections.Specialized.StringCollection)((System.Collections.Specialized.StringCollection)o.@SchemaImporterExtensions); @@ -260,7 +260,7 @@ private void Write4_WebReferenceOptions(string n, string ns, WebReferenceOptions { WriteElementString(@"style", @"http://microsoft.com/webReference/", Write2_ServiceDescriptionImportStyle(((System.Web.Services.Description.ServiceDescriptionImportStyle)o.@Style))); } - WriteElementStringRaw(@"verbose", @"http://microsoft.com/webReference/", Microsoft.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o.@Verbose))); + WriteElementStringRaw(@"verbose", @"http://microsoft.com/webReference/", System.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o.@Verbose))); WriteEndElement(o); } @@ -292,20 +292,20 @@ internal System.Collections.Hashtable CodeGenerationOptionsValues if ((object)_CodeGenerationOptionsValues == null) { System.Collections.Hashtable h = new System.Collections.Hashtable(); - h.Add(@"properties", (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateProperties); - h.Add(@"newAsync", (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync); - h.Add(@"oldAsync", (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync); - h.Add(@"order", (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@GenerateOrder); - h.Add(@"enableDataBinding", (long)Microsoft.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding); + h.Add(@"properties", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties); + h.Add(@"newAsync", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync); + h.Add(@"oldAsync", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync); + h.Add(@"order", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder); + h.Add(@"enableDataBinding", (long)System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding); _CodeGenerationOptionsValues = h; } return _CodeGenerationOptionsValues; } } - private Microsoft.Xml.Serialization.CodeGenerationOptions Read1_CodeGenerationOptions(string s) + private System.Xml.Serialization.CodeGenerationOptions Read1_CodeGenerationOptions(string s) { - return (Microsoft.Xml.Serialization.CodeGenerationOptions)ToEnum(s, CodeGenerationOptionsValues, @"System.Xml.Serialization.CodeGenerationOptions"); + return (System.Xml.Serialization.CodeGenerationOptions)ToEnum(s, CodeGenerationOptionsValues, @"System.Xml.Serialization.CodeGenerationOptions"); } private System.Web.Services.Description.ServiceDescriptionImportStyle Read2_ServiceDescriptionImportStyle(string s) @@ -321,16 +321,16 @@ private System.Web.Services.Description.ServiceDescriptionImportStyle Read2_Serv private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOptions(bool isNullable, bool checkType) { - Microsoft.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; bool isNull = false; if (isNullable) isNull = ReadNull(); if (checkType) { - if (xsiType == null || ((object)((Microsoft.Xml.XmlQualifiedName)xsiType).Name == (object)_id1_webReferenceOptions && (object)((Microsoft.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) + if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id1_webReferenceOptions && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) { } else - throw CreateUnknownTypeException((Microsoft.Xml.XmlQualifiedName)xsiType); + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); } if (isNull) return null; System.Web.Services.Description.WebReferenceOptions o; @@ -354,9 +354,9 @@ private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOp Reader.MoveToContent(); int whileIterations0 = 0; int readerCount0 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id3_codeGenerationOptions && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -366,7 +366,7 @@ private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOp } else { - o.@CodeGenerationOptions = Read1_CodeGenerationOptions(Reader.ReadElementString()); + o.@CodeGenerationOptions = (CodeGenerationOptions)(long)Read1_CodeGenerationOptions(Reader.ReadElementString()); } paramsRead[0] = true; } @@ -385,9 +385,9 @@ private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOp Reader.MoveToContent(); int whileIterations1 = 0; int readerCount1 = ReaderCount; - while (Reader.NodeType != Microsoft.Xml.XmlNodeType.EndElement && Reader.NodeType != Microsoft.Xml.XmlNodeType.None) + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id5_type && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -431,7 +431,7 @@ private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOp else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id7_verbose && (object)Reader.NamespaceURI == (object)_id2_Item)) { { - o.@Verbose = Microsoft.Xml.XmlConvert.ToBoolean(Reader.ReadElementString()); + o.@Verbose = System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString()); } paramsRead[3] = true; } @@ -459,7 +459,7 @@ internal object Read5_webReferenceOptions() { object o = null; Reader.MoveToContent(); - if (Reader.NodeType == Microsoft.Xml.XmlNodeType.Element) + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object)Reader.LocalName == (object)_id1_webReferenceOptions && (object)Reader.NamespaceURI == (object)_id2_Item)) { @@ -507,7 +507,7 @@ protected override XmlSerializationWriter CreateWriter() { return new WebReferenceOptionsSerializationWriter(); } - public override System.Boolean CanDeserialize(Microsoft.Xml.XmlReader xmlReader) + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { return true; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs index 95f858b068a..964f7cbca0e 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs @@ -5,7 +5,7 @@ namespace System.Web.Services { using System; - using Microsoft.Xml; + using System.Xml; internal class Soap { diff --git a/src/dotnet-svcutil/lib/src/ImportModule.cs b/src/dotnet-svcutil/lib/src/ImportModule.cs index 9d16b29dcb1..57dbce7619c 100644 --- a/src/dotnet-svcutil/lib/src/ImportModule.cs +++ b/src/dotnet-svcutil/lib/src/ImportModule.cs @@ -4,9 +4,9 @@ using Microsoft.CodeDom; using Microsoft.Tools.ServiceModel.Svcutil.Metadata; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.Serialization; +using System.Xml; +using System.Xml.Schema; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; using System; using System.Collections.Generic; diff --git a/src/dotnet-svcutil/lib/src/Metadata/MetadataConstants.cs b/src/dotnet-svcutil/lib/src/Metadata/MetadataConstants.cs index 98901defe4b..af2d24f2a12 100644 --- a/src/dotnet-svcutil/lib/src/Metadata/MetadataConstants.cs +++ b/src/dotnet-svcutil/lib/src/Metadata/MetadataConstants.cs @@ -4,7 +4,7 @@ using System; #if PRIVATE_RTLIB -using XmlNs = Microsoft.Xml; +using XmlNs = System.Xml; #else using XmlNs = System.Xml; #endif diff --git a/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentLoader.cs b/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentLoader.cs index 79a4c035e1b..a52c6d23e9b 100644 --- a/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentLoader.cs +++ b/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentLoader.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; using System.Text; #if PRIVATE_RTLIB -using XmlNS = Microsoft.Xml; +using XmlNS = System.Xml; #else using System.Reflection; using System.Xml.Schema; diff --git a/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentSaver.cs b/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentSaver.cs index ddb5c0d349e..e21e2459444 100644 --- a/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentSaver.cs +++ b/src/dotnet-svcutil/lib/src/Metadata/MetadataDocumentSaver.cs @@ -12,8 +12,8 @@ using System.Threading.Tasks; using System.ServiceModel.Description; #if PRIVATE_RTLIB -using Microsoft.Xml.Schema; -using XmlNS = Microsoft.Xml; +using System.Xml.Schema; +using XmlNS = System.Xml; #else using System.Xml.Schema; using XmlNS = System.Xml; diff --git a/src/dotnet-svcutil/lib/src/Metadata/MetadataFileInfo.cs b/src/dotnet-svcutil/lib/src/Metadata/MetadataFileInfo.cs index d6d20da1d75..ab1e308807e 100644 --- a/src/dotnet-svcutil/lib/src/Metadata/MetadataFileInfo.cs +++ b/src/dotnet-svcutil/lib/src/Metadata/MetadataFileInfo.cs @@ -5,7 +5,7 @@ using System; using System.Diagnostics; #if PRIVATE_RTLIB -using XmlNS = Microsoft.Xml; +using XmlNS = System.Xml; #else using XmlNS = System.Xml; #endif diff --git a/src/dotnet-svcutil/lib/src/Metadata/ServiceDescriptor.cs b/src/dotnet-svcutil/lib/src/Metadata/ServiceDescriptor.cs index e28101e07a9..1a7ed7c643c 100644 --- a/src/dotnet-svcutil/lib/src/Metadata/ServiceDescriptor.cs +++ b/src/dotnet-svcutil/lib/src/Metadata/ServiceDescriptor.cs @@ -14,7 +14,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Microsoft.Xml; +using System.Xml; using WsdlNS = System.Web.Services.Description; namespace Microsoft.Tools.ServiceModel.Svcutil.Metadata diff --git a/src/dotnet-svcutil/lib/src/XmlStrings.cs b/src/dotnet-svcutil/lib/src/XmlStrings.cs index fbda8b1e8db..83fb0297b0f 100644 --- a/src/dotnet-svcutil/lib/src/XmlStrings.cs +++ b/src/dotnet-svcutil/lib/src/XmlStrings.cs @@ -27,7 +27,7 @@ public static class Elements public static class XmlSchema { public const string Prefix = "xsd"; - public const string NamespaceUri = Microsoft.Xml.Schema.XmlSchema.Namespace; + public const string NamespaceUri = System.Xml.Schema.XmlSchema.Namespace; public static class Elements { public const string Root = "schema"; diff --git a/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj b/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj index a2e76c50f57..13552156ae9 100644 --- a/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj +++ b/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj @@ -82,6 +82,7 @@ true false ResXml + Microsoft.Tools.ServiceModel.Svcutil.FrameworkFork.Microsoft.Xml.ResXml.resources true From b6a08aff726216677c41dd525fb79b74da0bc605 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Tue, 24 Feb 2026 18:13:17 +0800 Subject: [PATCH 2/4] Replace System.Web.Services fork with System.Web.Services.Description Nuget package --- eng/Versions.props | 1 + .../Channels/XmlSerializerImportOptions.cs | 18 +- .../Description/MessageContractImporter.cs | 14 +- .../XmlSerializerOperationGenerator.cs | 4 +- .../Configuration/WebServicesSection.cs | 140 - .../FrameworkFork/System.Web.Services/Fx.cs | 14 - .../System.Web.Services/ResWebServices.resx | 267 - .../Description/HttpFormatExtensions.cs | 71 - .../Description/MimeFormatExtensions.cs | 298 - .../Description/ServiceDescription.cs | 4202 ----- .../Description/ServiceDescriptionImporter.cs | 48 - .../ServiceDescriptionSerializer.cs | 13556 ---------------- .../Description/ServiceDescriptions.cs | 216 - .../Description/Soap12FormatExtensions.cs | 61 - .../Description/SoapFormatExtensions.cs | 357 - .../Description/WebReferenceOptions.cs | 525 - .../Services/Description/WsiProfiles.cs | 29 - .../XmlFormatExtensionAttribute.cs | 87 - .../XmlFormatExtensionPointAttribute.cs | 49 - .../XmlFormatExtensionPrefixAttribute.cs | 58 - .../System.Web.Services/Services/Soap.cs | 109 - .../xlf/ResWebServices.cs.xlf | 252 - .../xlf/ResWebServices.de.xlf | 252 - .../xlf/ResWebServices.es.xlf | 252 - .../xlf/ResWebServices.fr.xlf | 252 - .../xlf/ResWebServices.it.xlf | 252 - .../xlf/ResWebServices.ja.xlf | 252 - .../xlf/ResWebServices.ko.xlf | 252 - .../xlf/ResWebServices.pl.xlf | 252 - .../xlf/ResWebServices.pt-BR.xlf | 252 - .../xlf/ResWebServices.ru.xlf | 252 - .../xlf/ResWebServices.tr.xlf | 252 - .../xlf/ResWebServices.zh-Hans.xlf | 252 - .../xlf/ResWebServices.zh-Hant.xlf | 252 - src/dotnet-svcutil/lib/src/ImportModule.cs | 13 +- .../lib/src/dotnet-svcutil-lib.csproj | 6 +- 36 files changed, 18 insertions(+), 23401 deletions(-) delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Fx.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/ResWebServices.resx delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WsiProfiles.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPointAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPrefixAttribute.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.cs.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.de.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.es.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.fr.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.it.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ja.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ko.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pl.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pt-BR.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ru.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.tr.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hans.xlf delete mode 100644 src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hant.xlf diff --git a/eng/Versions.props b/eng/Versions.props index 750811dc013..24b4075b39d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -68,6 +68,7 @@ 4.7.0 4.7.0 4.3.0 + 8.1.2 6.2.0 8.1.2 8.1.2 diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs index 142b9ead1e7..335bd35844c 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs @@ -18,15 +18,13 @@ namespace System.ServiceModel.Channels using System.Xml; using System.Xml.Schema; using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using WsdlNS = System.Web.Services.Description; public class XmlSerializerImportOptions { private CodeCompileUnit _codeCompileUnit; private CodeDomProvider _codeProvider; private string _clrNamespace; - private WsdlNS.WebReferenceOptions _webReferenceOptions; - private static CodeGenerationOptions s_defaultCodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder; + private CodeGenerationOptions _codeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder; public XmlSerializerImportOptions() : this(new CodeCompileUnit()) @@ -65,18 +63,10 @@ public string ClrNamespace set { _clrNamespace = value; } } - public WsdlNS.WebReferenceOptions WebReferenceOptions + public CodeGenerationOptions CodeGenerationOptions { - get - { - if (_webReferenceOptions == null) - { - _webReferenceOptions = new WsdlNS.WebReferenceOptions(); - _webReferenceOptions.CodeGenerationOptions = s_defaultCodeGenerationOptions; - } - return _webReferenceOptions; - } - set { _webReferenceOptions = value; } + get { return _codeGenerationOptions; } + set { _codeGenerationOptions = value; } } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs index 269db62d772..2a7d533f6ff 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs @@ -864,7 +864,6 @@ private static XmlSchemaSet GatherSchemas(WsdlImporter importer) { if (include.Schema != null) { - Console.WriteLine("DEBUG: Adding Included Schema: " + include.Schema.TargetNamespace); schemaSet.Add(include.Schema); } } @@ -1924,7 +1923,7 @@ public XmlSerializerSchemaImporter(WsdlImporter importer) options = new XmlSerializerImportOptions((CodeCompileUnit)compileUnit); importer.State.Add(typeof(XmlSerializerImportOptions), options); } - WsdlNS.WebReferenceOptions webReferenceOptions = options.WebReferenceOptions; + CodeGenerationOptions codeGenerationOptions = options.CodeGenerationOptions; _codeProvider = options.CodeProvider; _encodedSchemas = new XmlSchemas(); @@ -1936,20 +1935,13 @@ public XmlSerializerSchemaImporter(WsdlImporter importer) //SchemaImporter.ctor is not thread safe: MB49115, VSWhidbey580396 lock (s_schemaImporterLock) { - _xmlImporter = new XmlSchemaImporter(_literalSchemas, webReferenceOptions.CodeGenerationOptions, options.CodeProvider, new ImportContext(codeIdentifiers, false)); + _xmlImporter = new XmlSchemaImporter(_literalSchemas, codeGenerationOptions, options.CodeProvider, new ImportContext(codeIdentifiers, false)); } - if (webReferenceOptions != null) - { - foreach (string extTypeName in webReferenceOptions.SchemaImporterExtensions) - { - _xmlImporter.Extensions.Add(extTypeName, Type.GetType(extTypeName, true /*throwOnError*/)); - } - } //SchemaImporter.ctor is not thread safe: MB49115, VSWhidbey580396 lock (s_schemaImporterLock) { - _soapImporter = new SoapSchemaImporter(_encodedSchemas, webReferenceOptions.CodeGenerationOptions, options.CodeProvider, new ImportContext(codeIdentifiers, false)); + _soapImporter = new SoapSchemaImporter(_encodedSchemas, codeGenerationOptions, options.CodeProvider, new ImportContext(codeIdentifiers, false)); } _xmlSerializerOperationGenerator = new XmlSerializerOperationGenerator(options); } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs index 70c2169015e..2ca956d4c85 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/XmlSerializerOperationGenerator.cs @@ -70,7 +70,7 @@ public XmlCodeExporter XmlExporter if (_xmlExporter == null) { _xmlExporter = new XmlCodeExporter(_codeNamespace, _options.CodeCompileUnit, _options.CodeProvider, - _options.WebReferenceOptions.CodeGenerationOptions, null); + _options.CodeGenerationOptions, null); } return _xmlExporter; } @@ -83,7 +83,7 @@ public SoapCodeExporter SoapExporter if (_soapExporter == null) { _soapExporter = new SoapCodeExporter(_codeNamespace, _options.CodeCompileUnit, _options.CodeProvider, - _options.WebReferenceOptions.CodeGenerationOptions, null); + _options.CodeGenerationOptions, null); } return _soapExporter; } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs deleted file mode 100644 index 3262069fc87..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Configuration/WebServicesSection.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Configuration -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Reflection; - using System.Web.Services.Description; - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - - public sealed class WebServicesSection - { - public WebServicesSection() - { - } - - - public static WebServicesSection Current - { - get - { - WebServicesSection retval = new WebServicesSection(); - return retval; - } - } - - internal static void LoadXmlFormatExtensions(Type[] extensionTypes, XmlAttributeOverrides overrides, XmlSerializerNamespaces namespaces) - { - Hashtable table = new Hashtable(); - table.Add(typeof(ServiceDescription), new XmlAttributes()); - table.Add(typeof(Import), new XmlAttributes()); - table.Add(typeof(Port), new XmlAttributes()); - table.Add(typeof(Service), new XmlAttributes()); - table.Add(typeof(FaultBinding), new XmlAttributes()); - table.Add(typeof(InputBinding), new XmlAttributes()); - table.Add(typeof(OutputBinding), new XmlAttributes()); - table.Add(typeof(OperationBinding), new XmlAttributes()); - table.Add(typeof(Binding), new XmlAttributes()); - table.Add(typeof(OperationFault), new XmlAttributes()); - table.Add(typeof(OperationInput), new XmlAttributes()); - table.Add(typeof(OperationOutput), new XmlAttributes()); - table.Add(typeof(Operation), new XmlAttributes()); - table.Add(typeof(PortType), new XmlAttributes()); - table.Add(typeof(Message), new XmlAttributes()); - table.Add(typeof(MessagePart), new XmlAttributes()); - table.Add(typeof(Types), new XmlAttributes()); - Hashtable extensions = new Hashtable(); - foreach (Type extensionType in extensionTypes) - { - if (extensions[extensionType] != null) - { - continue; - } - extensions.Add(extensionType, extensionType); - object[] attrs = new List(extensionType.GetTypeInfo().GetCustomAttributes(typeof(XmlFormatExtensionAttribute), false)).ToArray(); - if (attrs.Length == 0) - { - throw new ArgumentException(string.Format(ResWebServices.RequiredXmlFormatExtensionAttributeIsMissing1, extensionType.FullName), "extensionTypes"); - } - XmlFormatExtensionAttribute extensionAttr = (XmlFormatExtensionAttribute)attrs[0]; - foreach (Type extensionPointType in extensionAttr.ExtensionPoints) - { - XmlAttributes xmlAttrs = (XmlAttributes)table[extensionPointType]; - if (xmlAttrs == null) - { - xmlAttrs = new XmlAttributes(); - table.Add(extensionPointType, xmlAttrs); - } - XmlElementAttribute xmlAttr = new XmlElementAttribute(extensionAttr.ElementName, extensionType); - xmlAttr.Namespace = extensionAttr.Namespace; - xmlAttrs.XmlElements.Add(xmlAttr); - } - attrs = new List(extensionType.GetTypeInfo().GetCustomAttributes(typeof(XmlFormatExtensionPrefixAttribute), false)).ToArray(); - string[] prefixes = new string[attrs.Length]; - Hashtable nsDefs = new Hashtable(); - for (int i = 0; i < attrs.Length; i++) - { - XmlFormatExtensionPrefixAttribute prefixAttr = (XmlFormatExtensionPrefixAttribute)attrs[i]; - prefixes[i] = prefixAttr.Prefix; - nsDefs.Add(prefixAttr.Prefix, prefixAttr.Namespace); - } - Array.Sort(prefixes); - for (int i = 0; i < prefixes.Length; i++) - { - namespaces.Add(prefixes[i], (string)nsDefs[prefixes[i]]); - } - } - foreach (Type extensionPointType in table.Keys) - { - XmlFormatExtensionPointAttribute attr = GetExtensionPointAttribute(extensionPointType); - XmlAttributes xmlAttrs = (XmlAttributes)table[extensionPointType]; - if (attr.AllowElements) - { - xmlAttrs.XmlAnyElements.Add(new XmlAnyElementAttribute()); - } - overrides.Add(extensionPointType, attr.MemberName, xmlAttrs); - } - } - - internal Type[] GetAllFormatExtensionTypes() - { - return _defaultFormatTypes; - } - - - private static XmlFormatExtensionPointAttribute GetExtensionPointAttribute(Type type) - { - object[] attrs = new List(type.GetTypeInfo().GetCustomAttributes(typeof(XmlFormatExtensionPointAttribute), false)).ToArray(); - if (attrs.Length == 0) - throw new ArgumentException(string.Format(ResWebServices.TheSyntaxOfTypeMayNotBeExtended1, type.FullName), "type"); - return (XmlFormatExtensionPointAttribute)attrs[0]; - } - - private Type[] _defaultFormatTypes = new Type[] { - typeof(HttpAddressBinding), - typeof(HttpBinding), - typeof(HttpOperationBinding), - typeof(HttpUrlEncodedBinding), - typeof(HttpUrlReplacementBinding), - typeof(MimeContentBinding), - typeof(MimeXmlBinding), - typeof(MimeMultipartRelatedBinding), - typeof(MimeTextBinding), - typeof(System.Web.Services.Description.SoapBinding), - typeof(SoapOperationBinding), - typeof(SoapBodyBinding), - typeof(SoapFaultBinding), - typeof(SoapHeaderBinding), - typeof(SoapAddressBinding), - typeof(Soap12Binding), - typeof(Soap12OperationBinding), - typeof(Soap12BodyBinding), - typeof(Soap12FaultBinding), - typeof(Soap12HeaderBinding), - typeof(Soap12AddressBinding) }; - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Fx.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Fx.cs deleted file mode 100644 index 90ed61b39ad..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Fx.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Protocols -{ - internal class Fx - { - internal static bool IsFatal(Exception e) - { - return e is OutOfMemoryException; - } - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/ResWebServices.resx b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/ResWebServices.resx deleted file mode 100644 index f9bc8ff3e7f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/ResWebServices.resx +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Only objects of type OperationInput or OperationOutput may be added. - - - CODEGEN: {0} - - - Element {0} named {1} from namespace {2} is missing. - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - - - Binding '{0}' from namespace '{1}'. - - - More than one import named '{0}' was specified. Each import must have a unique name. - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - - - The value for '{0}' cannot be negative. - - - Warning: {0} - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - - - Error: {0} Line {1}, position {2}. - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - - - Schema item '{1}' from namespace '{0}'. {2} - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - - - More than one message named '{0}' was specified. Each message must have a unique name. - - - Warning: {0} Line {1}, position {2}. - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - - - More than one port named '{0}' was specified. Each port must have a unique name. - - - {0} from service description with targetNamespace='{1}'. - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - - - Protocol with name '{0}' is not recognized. - - - No more than one input and one output message may be specified. - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - - - The syntax of type {0} may not be extended. - - - en - - - Required XmlFormatExtension attribute is missing on class {0}. - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - - - Message '{0}' from service description with targetNamespace='{1}'. - - - Service description with targetNamespace='{0}'. - - - More than one service named '{0}' was specified. Each service must have a unique name. - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - - - Schema validation error: {0} - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - - - Port '{0}' on service {1} from namespace='{2}'. - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs deleted file mode 100644 index c19adcd1812..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/HttpFormatExtensions.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using System.Web.Services.Configuration; - - /// - [XmlFormatExtension("address", HttpBinding.Namespace, typeof(Port))] - public sealed class HttpAddressBinding : ServiceDescriptionFormatExtension - { - private string _location; - - /// - [XmlAttribute("location")] - public string Location - { - get { return _location == null ? string.Empty : _location; } - set { _location = value; } - } - } - - /// - [XmlFormatExtension("binding", HttpBinding.Namespace, typeof(Binding))] - [XmlFormatExtensionPrefix("http", HttpBinding.Namespace)] - public sealed class HttpBinding : ServiceDescriptionFormatExtension - { - private string _verb; - - /// - public const string Namespace = "http://schemas.xmlsoap.org/wsdl/http/"; - - /// - [XmlAttribute("verb")] - public string Verb - { - get { return _verb; } - set { _verb = value; } - } - } - - /// - [XmlFormatExtension("operation", HttpBinding.Namespace, typeof(OperationBinding))] - public sealed class HttpOperationBinding : ServiceDescriptionFormatExtension - { - private string _location; - - /// - [XmlAttribute("location")] - public string Location - { - get { return _location == null ? string.Empty : _location; } - set { _location = value; } - } - } - - /// - [XmlFormatExtension("urlEncoded", HttpBinding.Namespace, typeof(InputBinding))] - public sealed class HttpUrlEncodedBinding : ServiceDescriptionFormatExtension - { - } - - /// - [XmlFormatExtension("urlReplacement", HttpBinding.Namespace, typeof(InputBinding))] - public sealed class HttpUrlReplacementBinding : ServiceDescriptionFormatExtension - { - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs deleted file mode 100644 index 5ec42c806db..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/MimeFormatExtensions.cs +++ /dev/null @@ -1,298 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using System.Collections; - using System.ComponentModel; - using System.Web.Services.Configuration; - using System.Globalization; - - /// - [XmlFormatExtension("content", MimeContentBinding.Namespace, typeof(MimePart), typeof(InputBinding), typeof(OutputBinding))] - [XmlFormatExtensionPrefix("mime", MimeContentBinding.Namespace)] - public sealed class MimeContentBinding : ServiceDescriptionFormatExtension - { - private string _type; - private string _part; - - /// - [XmlAttribute("part")] - public string Part - { - get { return _part; } - set { _part = value; } - } - - /// - [XmlAttribute("type")] - public string Type - { - get { return _type == null ? string.Empty : _type; } - set { _type = value; } - } - - /// - public const string Namespace = "http://schemas.xmlsoap.org/wsdl/mime/"; - } - - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class MimePart : ServiceDescriptionFormatExtension - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - [XmlIgnore] - public ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - [XmlFormatExtension("multipartRelated", MimeContentBinding.Namespace, typeof(InputBinding), typeof(OutputBinding))] - public sealed class MimeMultipartRelatedBinding : ServiceDescriptionFormatExtension - { - private MimePartCollection _parts = new MimePartCollection(); - - /// - [XmlElement("part")] - public MimePartCollection Parts - { - get { return _parts; } - } - } - - /// - [XmlFormatExtension("mimeXml", MimeContentBinding.Namespace, typeof(MimePart), typeof(InputBinding), typeof(OutputBinding))] - public sealed class MimeXmlBinding : ServiceDescriptionFormatExtension - { - private string _part; - - /// - [XmlAttribute("part")] - public string Part - { - get { return _part; } - set { _part = value; } - } - } - - /// - public sealed class MimePartCollection : CollectionBase - { - /// - public MimePart this[int index] - { - get { return (MimePart)List[index]; } - set { List[index] = value; } - } - - /// - public int Add(MimePart mimePart) - { - return List.Add(mimePart); - } - - /// - public void Insert(int index, MimePart mimePart) - { - List.Insert(index, mimePart); - } - - /// - public int IndexOf(MimePart mimePart) - { - return List.IndexOf(mimePart); - } - - /// - public bool Contains(MimePart mimePart) - { - return List.Contains(mimePart); - } - - /// - public void Remove(MimePart mimePart) - { - List.Remove(mimePart); - } - - /// - public void CopyTo(MimePart[] array, int index) - { - List.CopyTo(array, index); - } - } - - /// - [XmlFormatExtension("text", MimeTextBinding.Namespace, typeof(InputBinding), typeof(OutputBinding), typeof(MimePart))] - [XmlFormatExtensionPrefix("tm", MimeTextBinding.Namespace)] - public sealed class MimeTextBinding : ServiceDescriptionFormatExtension - { - private MimeTextMatchCollection _matches = new MimeTextMatchCollection(); - - /// - public const string Namespace = "http://microsoft.com/wsdl/mime/textMatching/"; - - /// - [XmlElement("match", typeof(MimeTextMatch))] - public MimeTextMatchCollection Matches - { - get { return _matches; } - } - } - - /// - public sealed class MimeTextMatch - { - private string _name; - private string _type; - private int _repeats = 1; - private string _pattern; - private int _group = 1; - private int _capture = 0; - private bool _ignoreCase = false; - private MimeTextMatchCollection _matches = new MimeTextMatchCollection(); - - /// - [XmlAttribute("name")] - public string Name - { - get { return _name == null ? string.Empty : _name; } - set { _name = value; } - } - - /// - [XmlAttribute("type")] - public string Type - { - get { return _type == null ? string.Empty : _type; } - set { _type = value; } - } - - /// - [XmlAttribute("group"), DefaultValue(1)] - public int Group - { - get { return _group; } - set - { - if (value < 0) throw new ArgumentException(string.Format(ResWebServices.WebNegativeValue, "group")); - _group = value; - } - } - - /// - [XmlAttribute("capture"), DefaultValue(0)] - public int Capture - { - get { return _capture; } - set - { - if (value < 0) throw new ArgumentException(string.Format(ResWebServices.WebNegativeValue, "capture")); - _capture = value; - } - } - - /// - [XmlIgnore()] - public int Repeats - { - get { return _repeats; } - set - { - if (value < 0) throw new ArgumentException(string.Format(ResWebServices.WebNegativeValue, "repeats")); - _repeats = value; - } - } - - /// - [XmlAttribute("repeats"), DefaultValue("1")] - public string RepeatsString - { - get { return _repeats == int.MaxValue ? "*" : _repeats.ToString(CultureInfo.InvariantCulture); } - set - { - if (value == "*") - _repeats = int.MaxValue; - else - Repeats = int.Parse(value, CultureInfo.InvariantCulture); // pass through our setter for arg checking - } - } - - /// - [XmlAttribute("pattern")] - public string Pattern - { - get { return _pattern == null ? string.Empty : _pattern; } - set { _pattern = value; } - } - - /// - [XmlAttribute("ignoreCase")] - public bool IgnoreCase - { - get { return _ignoreCase; } - set { _ignoreCase = value; } - } - - /// - [XmlElement("match")] - public MimeTextMatchCollection Matches - { - get { return _matches; } - } - } - - /// - public sealed class MimeTextMatchCollection : CollectionBase - { - /// - public MimeTextMatch this[int index] - { - get { return (MimeTextMatch)List[index]; } - set { List[index] = value; } - } - - /// - public int Add(MimeTextMatch match) - { - return List.Add(match); - } - - /// - public void Insert(int index, MimeTextMatch match) - { - List.Insert(index, match); - } - - /// - public int IndexOf(MimeTextMatch match) - { - return List.IndexOf(match); - } - - /// - public bool Contains(MimeTextMatch match) - { - return List.Contains(match); - } - - /// - public void Remove(MimeTextMatch match) - { - List.Remove(match); - } - - /// - public void CopyTo(MimeTextMatch[] array, int index) - { - List.CopyTo(array, index); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs deleted file mode 100644 index 6cd6c90deee..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescription.cs +++ /dev/null @@ -1,4202 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; -using System.Xml.Schema; -using System.Collections; -using System.Collections.Specialized; -using System; -using System.Xml; -using System.IO; -using System.Reflection; -using System.ComponentModel; -using Microsoft.CodeDom; -using System.Text; -using System.Web.Services.Configuration; -using System.Diagnostics; -using System.Threading; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Web.Services.Protocols; - -namespace System.Web.Services.Description -{ - /// - /// - /// - /// - [XmlRoot("definitions", Namespace = ServiceDescription.Namespace)] - [XmlFormatExtensionPoint("Extensions")] - public sealed class ServiceDescription : NamedItem - { - /// - /// - /// [To be supplied.] - /// - public const string Namespace = "http://schemas.xmlsoap.org/wsdl/"; - internal const string Prefix = "wsdl"; - private Types _types; - private ImportCollection _imports; - private MessageCollection _messages; - private PortTypeCollection _portTypes; - private BindingCollection _bindings; - private ServiceCollection _services; - private string _targetNamespace; - private ServiceDescriptionFormatExtensionCollection _extensions; - private ServiceDescriptionCollection _parent; - private string _appSettingUrlKey; - private string _appSettingBaseUrl; - private string _retrievalUrl; - private static XmlSerializer s_serializer; - private static XmlSerializerNamespaces s_namespaces; - private const WsiProfiles SupportedClaims = WsiProfiles.BasicProfile1_1; - private static XmlSchema s_schema = null; - private static XmlSchema s_soapEncodingSchema = null; - private StringCollection _validationWarnings; - private static StringCollection s_warnings = new StringCollection(); - private ServiceDescription _next; - - private static void InstanceValidation(object sender, ValidationEventArgs args) - { - s_warnings.Add(string.Format(ResWebServices.WsdlInstanceValidationDetails, args.Message, args.Exception.LineNumber.ToString(CultureInfo.InvariantCulture), args.Exception.LinePosition.ToString(CultureInfo.InvariantCulture))); - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public string RetrievalUrl - { - get { return _retrievalUrl == null ? string.Empty : _retrievalUrl; } - set { _retrievalUrl = value; } - } - - internal void SetParent(ServiceDescriptionCollection parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public ServiceDescriptionCollection ServiceDescriptions - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("import")] - public ImportCollection Imports - { - get { if (_imports == null) _imports = new ImportCollection(this); return _imports; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("types")] - public Types Types - { - get { if (_types == null) _types = new Types(); return _types; } - set { _types = value; } - } - - private bool ShouldSerializeTypes() { return Types.HasItems(); } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("message")] - public MessageCollection Messages - { - get { if (_messages == null) _messages = new MessageCollection(this); return _messages; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("portType")] - public PortTypeCollection PortTypes - { - get { if (_portTypes == null) _portTypes = new PortTypeCollection(this); return _portTypes; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("binding")] - public BindingCollection Bindings - { - get { if (_bindings == null) _bindings = new BindingCollection(this); return _bindings; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("service")] - public ServiceCollection Services - { - get { if (_services == null) _services = new ServiceCollection(this); return _services; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("targetNamespace")] - public string TargetNamespace - { - get { return _targetNamespace; } - set { _targetNamespace = value; } - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Schema - { - get - { - if (s_schema == null) - { - s_schema = XmlSchema.Read(new StringReader(Schemas.Wsdl), null); - } - return s_schema; - } - } - - internal static XmlSchema SoapEncodingSchema - { - get - { - if (s_soapEncodingSchema == null) - { - s_soapEncodingSchema = XmlSchema.Read(new StringReader(Schemas.SoapEncoding), null); - } - return s_soapEncodingSchema; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public StringCollection ValidationWarnings - { - get - { - if (_validationWarnings == null) - { - _validationWarnings = new StringCollection(); - } - return _validationWarnings; - } - } - - internal void SetWarnings(StringCollection warnings) - { - _validationWarnings = warnings; - } - - // This is a special serializer that hardwires to the generated - // ServiceDescriptionSerializer. To regenerate the serializer - // Turn on KEEPTEMPFILES - // Restart server - // Run wsdl as follows - // wsdl ?wsdl - // Goto windows temp dir (usually \winnt\temp) - // and get the latest generated .cs file - // Change namespace to 'System.Web.Services.Description' - // Change class names to ServiceDescriptionSerializationWriter - // and ServiceDescriptionSerializationReader - // Make the classes internal - // Ensure the public Write method is Write125_definitions (If not - // change Serialize to call the new one) - // Ensure the public Read method is Read126_definitions (If not - // change Deserialize to call the new one) - internal class ServiceDescriptionSerializer : XmlSerializer - { - protected override XmlSerializationReader CreateReader() - { - return new ServiceDescriptionSerializationReader(); - } - protected override XmlSerializationWriter CreateWriter() - { - return new ServiceDescriptionSerializationWriter(); - } - public override bool CanDeserialize(System.Xml.XmlReader xmlReader) - { - return xmlReader.IsStartElement("definitions", ServiceDescription.Namespace); - } - protected override void Serialize(Object objectToSerialize, XmlSerializationWriter writer) - { - ((ServiceDescriptionSerializationWriter)writer).Write125_definitions(objectToSerialize); - } - protected override object Deserialize(XmlSerializationReader reader) - { - return ((ServiceDescriptionSerializationReader)reader).Read125_definitions(); - } - } - /// - /// - /// Returns the serializer for processing web service calls. The serializer is customized according - /// to settings in config.web. - /// - /// - /// - [XmlIgnore] - public static XmlSerializer Serializer - { - get - { - if (s_serializer == null) - { - WebServicesSection config = WebServicesSection.Current; - XmlAttributeOverrides overrides = new XmlAttributeOverrides(); - XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); - ns.Add("s", XmlSchema.Namespace); - WebServicesSection.LoadXmlFormatExtensions(config.GetAllFormatExtensionTypes(), overrides, ns); - s_namespaces = ns; - s_serializer = new ServiceDescriptionSerializer(); - } - return s_serializer; - } - } - - internal string AppSettingBaseUrl - { - get { return _appSettingBaseUrl; } - set { _appSettingBaseUrl = value; } - } - - internal string AppSettingUrlKey - { - get { return _appSettingUrlKey; } - set { _appSettingUrlKey = value; } - } - - internal ServiceDescription Next - { - get { return _next; } - set { _next = value; } - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(TextReader textReader) - { - return Read(textReader, false); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(Stream stream) - { - return Read(stream, false); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(XmlReader reader) - { - return Read(reader, false); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(string fileName) - { - return Read(fileName, false); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(TextReader textReader, bool validate) - { - XmlTextReader reader = new XmlTextReader(textReader); - reader.WhitespaceHandling = WhitespaceHandling.Significant; - reader.XmlResolver = null; - reader.DtdProcessing = DtdProcessing.Prohibit; - return Read(reader, validate); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(Stream stream, bool validate) - { - XmlTextReader reader = new XmlTextReader(stream); - reader.WhitespaceHandling = WhitespaceHandling.Significant; - reader.XmlResolver = null; - reader.DtdProcessing = DtdProcessing.Prohibit; - return Read(reader, validate); - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(string fileName, bool validate) - { - StreamReader reader = new StreamReader(File.OpenRead(fileName), detectEncodingFromByteOrderMarks: true); - try - { - return Read(reader, validate); - } - finally - { - reader.Dispose(); - } - } - - /// - /// - /// [To be supplied.] - /// - public static ServiceDescription Read(XmlReader reader, bool validate) - { - if (validate) - { - XmlReaderSettings readerSettings = new XmlReaderSettings(); - - readerSettings.ValidationType = ValidationType.Schema; - readerSettings.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints; - - readerSettings.Schemas.Add(Schema); - readerSettings.Schemas.Add(SoapBinding.Schema); - readerSettings.ValidationEventHandler += new ValidationEventHandler(InstanceValidation); - s_warnings.Clear(); - XmlReader validatingReader = XmlReader.Create(reader, readerSettings); - if (reader.ReadState != ReadState.Initial) - { - //underlying reader has moved, so move validatingreader as well - validatingReader.Read(); - } - ServiceDescription sd = (ServiceDescription)Serializer.Deserialize(validatingReader); - sd.SetWarnings(s_warnings); - return sd; - } - else - { - return (ServiceDescription)Serializer.Deserialize(reader); - } - } - - /// - /// - /// [To be supplied.] - /// - public static bool CanRead(XmlReader reader) - { - return Serializer.CanDeserialize(reader); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(string fileName) - { - StreamWriter writer = new StreamWriter(File.OpenWrite(fileName)); - try - { - Write(writer); - } - finally - { - writer.Dispose(); - } - } - - /// - /// - /// [To be supplied.] - /// - public void Write(TextWriter writer) - { - XmlTextWriter xmlWriter = new XmlTextWriter(writer); - xmlWriter.Formatting = Formatting.Indented; - xmlWriter.Indentation = 2; - Write(xmlWriter); - } - - /// - /// - /// [To be supplied.] - /// - public void Write(Stream stream) - { - TextWriter writer = new StreamWriter(stream); - Write(writer); - writer.Flush(); - } - - - /// - /// - /// [To be supplied.] - /// - public void Write(XmlWriter writer) - { - XmlSerializer serializer = Serializer; - XmlSerializerNamespaces ns; - if (Namespaces == null || Namespaces.Count == 0) - { - ns = new XmlSerializerNamespaces(s_namespaces); - ns.Add(ServiceDescription.Prefix, ServiceDescription.Namespace); - if (this.TargetNamespace != null && this.TargetNamespace.Length != 0) - { - ns.Add("tns", this.TargetNamespace); - } - for (int i = 0; i < Types.Schemas.Count; i++) - { - string tns = Types.Schemas[i].TargetNamespace; - if (tns != null && tns.Length > 0 && tns != this.TargetNamespace && tns != ServiceDescription.Namespace) - { - ns.Add("s" + i.ToString(CultureInfo.InvariantCulture), tns); - } - } - for (int i = 0; i < Imports.Count; i++) - { - Import import = Imports[i]; - if (import.Namespace.Length > 0) - { - ns.Add("i" + i.ToString(CultureInfo.InvariantCulture), import.Namespace); - } - } - } - else - { - ns = Namespaces; - } - serializer.Serialize(writer, this, ns); - } - - internal static WsiProfiles GetConformanceClaims(XmlElement documentation) - { - if (documentation == null) - return WsiProfiles.None; - - WsiProfiles existingClaims = WsiProfiles.None; - - XmlNode child = documentation.FirstChild; - while (child != null) - { - XmlNode sibling = child.NextSibling; - if (child is XmlElement) - { - XmlElement element = (XmlElement)child; - if (element.LocalName == Soap.Element.Claim && element.NamespaceURI == Soap.ConformanceClaim) - { - if (Soap.BasicProfile1_1 == element.GetAttribute(Soap.Attribute.ConformsTo)) - { - existingClaims |= WsiProfiles.BasicProfile1_1; - } - } - } - child = sibling; - } - return existingClaims; - } - - internal static void AddConformanceClaims(XmlElement documentation, WsiProfiles claims) - { - //CONSIDER throw if we encouner an unsupported claim - claims &= SupportedClaims; - if (claims == WsiProfiles.None) - return; - - // check already presend claims - WsiProfiles existingClaims = GetConformanceClaims(documentation); - claims &= ~existingClaims; - if (claims == WsiProfiles.None) - return; - - XmlDocument d = documentation.OwnerDocument; - if ((claims & WsiProfiles.BasicProfile1_1) != 0) - { - XmlElement claim = d.CreateElement(Soap.ClaimPrefix, Soap.Element.Claim, Soap.ConformanceClaim); - claim.SetAttribute(Soap.Attribute.ConformsTo, Soap.BasicProfile1_1); - documentation.InsertBefore(claim, null); - } - } - } - - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Import : DocumentableItem - { - private string _ns; - private string _location; - private ServiceDescription _parent; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal void SetParent(ServiceDescription parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription ServiceDescription - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("namespace")] - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("location")] - public string Location - { - get { return _location == null ? string.Empty : _location; } - set { _location = value; } - } - } - - - /// - /// - /// [To be supplied.] - /// - public abstract class DocumentableItem - { - private XmlDocument _parent; - private string _documentation; - private XmlElement _documentationElement; - private XmlAttribute[] _anyAttribute; - private XmlSerializerNamespaces _namespaces; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public string Documentation - { - get - { - if (_documentation != null) - return _documentation; - if (_documentationElement == null) - return string.Empty; - return _documentationElement.InnerXml; - } - set - { - _documentation = value; - StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); - XmlTextWriter xmlWriter = new XmlTextWriter(writer); - xmlWriter.WriteElementString(ServiceDescription.Prefix, "documentation", ServiceDescription.Namespace, value); - Parent.LoadXml(writer.ToString()); - _documentationElement = _parent.DocumentElement; - xmlWriter.Close(); - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAnyElement("documentation", Namespace = ServiceDescription.Namespace)] - [ComVisible(false)] - public XmlElement DocumentationElement - { - get { return _documentationElement; } - set - { - _documentationElement = value; - _documentation = null; - } - } - - [XmlAnyAttribute] - public System.Xml.XmlAttribute[] ExtensibleAttributes - { - get - { - return _anyAttribute; - } - set - { - _anyAttribute = value; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlNamespaceDeclarations] - public XmlSerializerNamespaces Namespaces - { - get - { - if (_namespaces == null) - _namespaces = new XmlSerializerNamespaces(); - return _namespaces; - } - set { _namespaces = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public abstract ServiceDescriptionFormatExtensionCollection Extensions { get; } - - internal XmlDocument Parent - { - get - { - if (_parent == null) - _parent = new XmlDocument(); - return _parent; - } - } - - internal XmlElement GetDocumentationElement() - { - if (_documentationElement == null) - { - _documentationElement = Parent.CreateElement(ServiceDescription.Prefix, "documentation", ServiceDescription.Namespace); - Parent.InsertBefore(_documentationElement, null); - } - return _documentationElement; - } - } - - /// - /// - /// [To be supplied.] - /// - public abstract class NamedItem : DocumentableItem - { - private string _name; - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Port : NamedItem - { - private ServiceDescriptionFormatExtensionCollection _extensions; - private XmlQualifiedName _binding = XmlQualifiedName.Empty; - private Service _parent; - - internal void SetParent(Service parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public Service Service - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("binding")] - public XmlQualifiedName Binding - { - get { return _binding; } - set { _binding = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Service : NamedItem - { - private ServiceDescriptionFormatExtensionCollection _extensions; - private PortCollection _ports; - private ServiceDescription _parent; - - internal void SetParent(ServiceDescription parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription ServiceDescription - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("port")] - public PortCollection Ports - { - get { if (_ports == null) _ports = new PortCollection(this); return _ports; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class FaultBinding : MessageBinding - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - public abstract class MessageBinding : NamedItem - { - private OperationBinding _parent; - - internal void SetParent(OperationBinding parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public OperationBinding OperationBinding - { - get { return _parent; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class InputBinding : MessageBinding - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class OutputBinding : MessageBinding - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class OperationBinding : NamedItem - { - private ServiceDescriptionFormatExtensionCollection _extensions; - private FaultBindingCollection _faults; - private InputBinding _input; - private OutputBinding _output; - private Binding _parent; - - internal void SetParent(Binding parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public Binding Binding - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("input")] - public InputBinding Input - { - get { return _input; } - set - { - if (_input != null) - { - _input.SetParent(null); - } - _input = value; - if (_input != null) - { - _input.SetParent(this); - } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("output")] - public OutputBinding Output - { - get { return _output; } - set - { - if (_output != null) - { - _output.SetParent(null); - } - _output = value; - if (_output != null) - { - _output.SetParent(this); - } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("fault")] - public FaultBindingCollection Faults - { - get { if (_faults == null) _faults = new FaultBindingCollection(this); return _faults; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Binding : NamedItem - { - private ServiceDescriptionFormatExtensionCollection _extensions; - private OperationBindingCollection _operations; - private XmlQualifiedName _type = XmlQualifiedName.Empty; - private ServiceDescription _parent; - - internal void SetParent(ServiceDescription parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription ServiceDescription - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("operation")] - public OperationBindingCollection Operations - { - get { if (_operations == null) _operations = new OperationBindingCollection(this); return _operations; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("type")] - public XmlQualifiedName Type - { - get - { - if ((object)_type == null) return XmlQualifiedName.Empty; - return _type; - } - set { _type = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - public abstract class OperationMessage : NamedItem - { - private XmlQualifiedName _message = XmlQualifiedName.Empty; - private Operation _parent; - - internal void SetParent(Operation parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public Operation Operation - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("message")] - public XmlQualifiedName Message - { - get { return _message; } - set { _message = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class OperationFault : OperationMessage - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class OperationInput : OperationMessage - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class OperationOutput : OperationMessage - { - private ServiceDescriptionFormatExtensionCollection _extensions; - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Operation : NamedItem - { - private string[] _parameters; - private OperationMessageCollection _messages; - private OperationFaultCollection _faults; - private PortType _parent; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal void SetParent(PortType parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - public PortType PortType - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("parameterOrder"), DefaultValue("")] - public string ParameterOrderString - { - get - { - if (_parameters == null) return string.Empty; - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < _parameters.Length; i++) - { - if (i > 0) builder.Append(' '); - builder.Append(_parameters[i]); - } - return builder.ToString(); - } - set - { - if (value == null) - _parameters = null; - else - _parameters = value.Split(new char[] { ' ' }); - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public string[] ParameterOrder - { - get { return _parameters; } - set { _parameters = value; } - } - - - /// - /// - /// [To be supplied.] - /// - [XmlElement("input", typeof(OperationInput)), - XmlElement("output", typeof(OperationOutput))] - public OperationMessageCollection Messages - { - get { if (_messages == null) _messages = new OperationMessageCollection(this); return _messages; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("fault")] - public OperationFaultCollection Faults - { - get { if (_faults == null) _faults = new OperationFaultCollection(this); return _faults; } - } - - /// - /// - /// [To be supplied.] - /// - public bool IsBoundBy(OperationBinding operationBinding) - { - if (operationBinding.Name != Name) return false; - OperationMessage input = Messages.Input; - if (input != null) - { - if (operationBinding.Input == null) return false; - - string portTypeInputName = GetMessageName(Name, input.Name, true); - string bindingInputName = GetMessageName(operationBinding.Name, operationBinding.Input.Name, true); - if (bindingInputName != portTypeInputName) return false; - } - else if (operationBinding.Input != null) - return false; - - OperationMessage output = Messages.Output; - if (output != null) - { - if (operationBinding.Output == null) return false; - - string portTypeOutputName = GetMessageName(Name, output.Name, false); - string bindingOutputName = GetMessageName(operationBinding.Name, operationBinding.Output.Name, false); - if (bindingOutputName != portTypeOutputName) return false; - } - else if (operationBinding.Output != null) - return false; - return true; - } - - private string GetMessageName(string operationName, string messageName, bool isInput) - { - if (messageName != null && messageName.Length > 0) - return messageName; - - switch (Messages.Flow) - { - case OperationFlow.RequestResponse: - if (isInput) - return operationName + "Request"; - return operationName + "Response"; - case OperationFlow.OneWay: - if (isInput) - return operationName; - Debug.Assert(isInput == true, "Oneway flow cannot have an output message"); - return null; - // Cases not supported - case OperationFlow.SolicitResponse: - return null; - case OperationFlow.Notification: - return null; - } - Debug.Assert(false, "Unknown message flow"); - return null; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class PortType : NamedItem - { - private OperationCollection _operations; - private ServiceDescription _parent; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal void SetParent(ServiceDescription parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription ServiceDescription - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("operation")] - public OperationCollection Operations - { - get { if (_operations == null) _operations = new OperationCollection(this); return _operations; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Message : NamedItem - { - private MessagePartCollection _parts; - private ServiceDescription _parent; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal void SetParent(ServiceDescription parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription ServiceDescription - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("part")] - public MessagePartCollection Parts - { - get { if (_parts == null) _parts = new MessagePartCollection(this); return _parts; } - } - - /// - /// - /// [To be supplied.] - /// - public MessagePart[] FindPartsByName(string[] partNames) - { - MessagePart[] partArray = new MessagePart[partNames.Length]; - for (int i = 0; i < partNames.Length; i++) - { - partArray[i] = FindPartByName(partNames[i]); - } - return partArray; - } - - /// - /// - /// [To be supplied.] - /// - public MessagePart FindPartByName(string partName) - { - for (int i = 0; i < _parts.Count; i++) - { - MessagePart part = _parts[i]; - if (part.Name == partName) return part; - } - throw new ArgumentException(string.Format(ResWebServices.MissingMessagePartForMessageFromNamespace3, partName, Name, ServiceDescription.TargetNamespace), "partName"); - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class MessagePart : NamedItem - { - private XmlQualifiedName _type = XmlQualifiedName.Empty; - private XmlQualifiedName _element = XmlQualifiedName.Empty; - private Message _parent; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal void SetParent(Message parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - public Message Message - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("element")] - public XmlQualifiedName Element - { - get { return _element; } - set { _element = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("type")] - public XmlQualifiedName Type - { - get - { - if ((object)_type == null) return XmlQualifiedName.Empty; - return _type; - } - set { _type = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlFormatExtensionPoint("Extensions")] - public sealed class Types : DocumentableItem - { - private XmlSchemas _schemas; - private ServiceDescriptionFormatExtensionCollection _extensions; - - internal bool HasItems() - { - return (_schemas != null && _schemas.Count > 0) || - (_extensions != null && _extensions.Count > 0); - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public override ServiceDescriptionFormatExtensionCollection Extensions - { - get { if (_extensions == null) _extensions = new ServiceDescriptionFormatExtensionCollection(this); return _extensions; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("schema", typeof(XmlSchema), Namespace = XmlSchema.Namespace)] - public XmlSchemas Schemas - { - get { if (_schemas == null) _schemas = new XmlSchemas(); return _schemas; } - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection - { - /// - /// - /// [To be supplied.] - /// - public ServiceDescriptionFormatExtensionCollection(object parent) : base(parent) { } - - private ArrayList _handledElements; - - /// - /// - /// [To be supplied.] - /// - public object this[int index] - { - get { return (object)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(object extension) - { - return List.Add(extension); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, object extension) - { - List.Insert(index, extension); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(object extension) - { - return List.IndexOf(extension); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(object extension) - { - return List.Contains(extension); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(object extension) - { - List.Remove(extension); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(object[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public object Find(Type type) - { - for (int i = 0; i < List.Count; i++) - { - object item = List[i]; - if (type.IsAssignableFrom(item.GetType())) - { - ((ServiceDescriptionFormatExtension)item).Handled = true; - return item; - } - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public object[] FindAll(Type type) - { - ArrayList list = new ArrayList(); - for (int i = 0; i < List.Count; i++) - { - object item = List[i]; - if (type.IsAssignableFrom(item.GetType())) - { - ((ServiceDescriptionFormatExtension)item).Handled = true; - list.Add(item); - } - } - return (object[])list.ToArray(type); - } - - /// - /// - /// [To be supplied.] - /// - public XmlElement Find(string name, string ns) - { - for (int i = 0; i < List.Count; i++) - { - XmlElement element = List[i] as XmlElement; - if (element != null && element.LocalName == name && element.NamespaceURI == ns) - { - SetHandled(element); - return element; - } - } - return null; - } - - /// - /// - /// [To be supplied.] - /// - public XmlElement[] FindAll(string name, string ns) - { - ArrayList list = new ArrayList(); - for (int i = 0; i < List.Count; i++) - { - XmlElement element = List[i] as XmlElement; - if (element != null && element.LocalName == name && element.NamespaceURI == ns) - { - SetHandled(element); - list.Add(element); - } - } - return (XmlElement[])list.ToArray(typeof(XmlElement)); - } - - private void SetHandled(XmlElement element) - { - if (_handledElements == null) - _handledElements = new ArrayList(); - if (!_handledElements.Contains(element)) - _handledElements.Add(element); - } - - /// - /// - /// [To be supplied.] - /// - public bool IsHandled(object item) - { - if (item is XmlElement) - return IsHandled((XmlElement)item); - else - return ((ServiceDescriptionFormatExtension)item).Handled; - } - - /// - /// - /// [To be supplied.] - /// - public bool IsRequired(object item) - { - if (item is XmlElement) - return IsRequired((XmlElement)item); - else - return ((ServiceDescriptionFormatExtension)item).Required; - } - - private bool IsHandled(XmlElement element) - { - if (_handledElements == null) return false; - return _handledElements.Contains(element); - } - - private bool IsRequired(XmlElement element) - { - XmlAttribute requiredAttr = element.Attributes["required", ServiceDescription.Namespace]; - if (requiredAttr == null || requiredAttr.Value == null) - { - requiredAttr = element.Attributes["required"]; - if (requiredAttr == null || requiredAttr.Value == null) return false; // not required, by default - } - return XmlConvert.ToBoolean(requiredAttr.Value); - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - if (value is ServiceDescriptionFormatExtension) ((ServiceDescriptionFormatExtension)value).SetParent(parent); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnValidate(object value) - { - if (!(value is XmlElement || value is ServiceDescriptionFormatExtension)) - throw new ArgumentException(string.Format(ResWebServices.OnlyXmlElementsOrTypesDerivingFromServiceDescriptionFormatExtension0), "value"); - base.OnValidate(value); - } - } - - /// - /// - /// [To be supplied.] - /// - public abstract class ServiceDescriptionFormatExtension - { - private object _parent; - private bool _required; - private bool _handled; - - internal void SetParent(object parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - public object Parent - { - get { return _parent; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlAttribute("required", Namespace = ServiceDescription.Namespace), DefaultValue(false)] - public bool Required - { - get { return _required; } - set { _required = value; } - } - - /// - /// - /// [To be supplied.] - /// - [XmlIgnore] - public bool Handled - { - get { return _handled; } - set { _handled = value; } - } - } - - /// - /// - /// [To be supplied.] - /// - public enum OperationFlow - { - /// - /// - /// [To be supplied.] - /// - None, - /// - /// - /// [To be supplied.] - /// - OneWay, - /// - /// - /// [To be supplied.] - /// - Notification, - /// - /// - /// [To be supplied.] - /// - RequestResponse, - /// - /// - /// [To be supplied.] - /// - SolicitResponse, - } - - /// - /// - /// [To be supplied.] - /// - public sealed class OperationMessageCollection : ServiceDescriptionBaseCollection - { - internal OperationMessageCollection(Operation operation) : base(operation) { } - - /// - /// - /// [To be supplied.] - /// - public OperationMessage this[int index] - { - get { return (OperationMessage)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(OperationMessage operationMessage) - { - return List.Add(operationMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, OperationMessage operationMessage) - { - List.Insert(index, operationMessage); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(OperationMessage operationMessage) - { - return List.IndexOf(operationMessage); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(OperationMessage operationMessage) - { - return List.Contains(operationMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(OperationMessage operationMessage) - { - List.Remove(operationMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(OperationMessage[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public OperationInput Input - { - get - { - for (int i = 0; i < List.Count; i++) - { - OperationInput input = List[i] as OperationInput; - if (input != null) - { - return input; - } - } - return null; - } - } - - /// - /// - /// [To be supplied.] - /// - public OperationOutput Output - { - get - { - for (int i = 0; i < List.Count; i++) - { - OperationOutput output = List[i] as OperationOutput; - if (output != null) - { - return output; - } - } - return null; - } - } - - /// - /// - /// [To be supplied.] - /// - public OperationFlow Flow - { - get - { - if (List.Count == 0) - { - return OperationFlow.None; - } - else if (List.Count == 1) - { - if (List[0] is OperationInput) - { - return OperationFlow.OneWay; - } - else - { - return OperationFlow.Notification; - } - } - else - { - if (List[0] is OperationInput) - { - return OperationFlow.RequestResponse; - } - else - { - return OperationFlow.SolicitResponse; - } - } - } - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((OperationMessage)value).SetParent((Operation)parent); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnInsert(int index, object value) - { - if (Count > 1 || (Count == 1 && value.GetType() == List[0].GetType())) - throw new InvalidOperationException(string.Format(ResWebServices.WebDescriptionTooManyMessages)); - - base.OnInsert(index, value); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnSet(int index, object oldValue, object newValue) - { - if (oldValue.GetType() != newValue.GetType()) throw new InvalidOperationException(string.Format(ResWebServices.WebDescriptionTooManyMessages)); - base.OnSet(index, oldValue, newValue); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnValidate(object value) - { - if (!(value is OperationInput || value is OperationOutput)) - throw new ArgumentException(string.Format(ResWebServices.OnlyOperationInputOrOperationOutputTypes), "value"); - base.OnValidate(value); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class ImportCollection : ServiceDescriptionBaseCollection - { - internal ImportCollection(ServiceDescription serviceDescription) : base(serviceDescription) { } - - /// - /// - /// [To be supplied.] - /// - public Import this[int index] - { - get { return (Import)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Import import) - { - return List.Add(import); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Import import) - { - List.Insert(index, import); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Import import) - { - return List.IndexOf(import); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Import import) - { - return List.Contains(import); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Import import) - { - List.Remove(import); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Import[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Import)value).SetParent((ServiceDescription)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class MessageCollection : ServiceDescriptionBaseCollection - { - internal MessageCollection(ServiceDescription serviceDescription) : base(serviceDescription) { } - - /// - /// - /// [To be supplied.] - /// - public Message this[int index] - { - get { return (Message)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Message message) - { - return List.Add(message); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Message message) - { - List.Insert(index, message); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Message message) - { - return List.IndexOf(message); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Message message) - { - return List.Contains(message); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Message message) - { - List.Remove(message); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Message[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public Message this[string name] - { - get { return (Message)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((Message)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Message)value).SetParent((ServiceDescription)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class PortCollection : ServiceDescriptionBaseCollection - { - internal PortCollection(Service service) : base(service) { } - - /// - /// - /// [To be supplied.] - /// - public Port this[int index] - { - get { return (Port)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Port port) - { - return List.Add(port); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Port port) - { - List.Insert(index, port); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Port port) - { - return List.IndexOf(port); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Port port) - { - return List.Contains(port); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Port port) - { - List.Remove(port); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Port[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public Port this[string name] - { - get { return (Port)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((Port)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Port)value).SetParent((Service)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class PortTypeCollection : ServiceDescriptionBaseCollection - { - internal PortTypeCollection(ServiceDescription serviceDescription) : base(serviceDescription) { } - - /// - /// - /// [To be supplied.] - /// - public PortType this[int index] - { - get { return (PortType)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(PortType portType) - { - return List.Add(portType); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, PortType portType) - { - List.Insert(index, portType); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(PortType portType) - { - return List.IndexOf(portType); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(PortType portType) - { - return List.Contains(portType); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(PortType portType) - { - List.Remove(portType); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(PortType[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public PortType this[string name] - { - get { return (PortType)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((PortType)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((PortType)value).SetParent((ServiceDescription)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class BindingCollection : ServiceDescriptionBaseCollection - { - internal BindingCollection(ServiceDescription serviceDescription) : base(serviceDescription) { } - - /// - /// - /// [To be supplied.] - /// - public Binding this[int index] - { - get { return (Binding)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Binding binding) - { - return List.Add(binding); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Binding binding) - { - List.Insert(index, binding); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Binding binding) - { - return List.IndexOf(binding); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Binding binding) - { - return List.Contains(binding); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Binding binding) - { - List.Remove(binding); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Binding[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public Binding this[string name] - { - get { return (Binding)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((Binding)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Binding)value).SetParent((ServiceDescription)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class ServiceCollection : ServiceDescriptionBaseCollection - { - internal ServiceCollection(ServiceDescription serviceDescription) : base(serviceDescription) { } - - /// - /// - /// [To be supplied.] - /// - public Service this[int index] - { - get { return (Service)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Service service) - { - return List.Add(service); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Service service) - { - List.Insert(index, service); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Service service) - { - return List.IndexOf(service); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Service service) - { - return List.Contains(service); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Service service) - { - List.Remove(service); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Service[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public Service this[string name] - { - get { return (Service)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((Service)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Service)value).SetParent((ServiceDescription)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class MessagePartCollection : ServiceDescriptionBaseCollection - { - internal MessagePartCollection(Message message) : base(message) { } - - /// - /// - /// [To be supplied.] - /// - public MessagePart this[int index] - { - get { return (MessagePart)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(MessagePart messagePart) - { - return List.Add(messagePart); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, MessagePart messagePart) - { - List.Insert(index, messagePart); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(MessagePart messagePart) - { - return List.IndexOf(messagePart); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(MessagePart messagePart) - { - return List.Contains(messagePart); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(MessagePart messagePart) - { - List.Remove(messagePart); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(MessagePart[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public MessagePart this[string name] - { - get { return (MessagePart)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((MessagePart)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((MessagePart)value).SetParent((Message)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class OperationBindingCollection : ServiceDescriptionBaseCollection - { - internal OperationBindingCollection(Binding binding) : base(binding) { } - - /// - /// - /// [To be supplied.] - /// - public OperationBinding this[int index] - { - get { return (OperationBinding)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(OperationBinding bindingOperation) - { - return List.Add(bindingOperation); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, OperationBinding bindingOperation) - { - List.Insert(index, bindingOperation); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(OperationBinding bindingOperation) - { - return List.IndexOf(bindingOperation); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(OperationBinding bindingOperation) - { - return List.Contains(bindingOperation); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(OperationBinding bindingOperation) - { - List.Remove(bindingOperation); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(OperationBinding[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((OperationBinding)value).SetParent((Binding)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class FaultBindingCollection : ServiceDescriptionBaseCollection - { - internal FaultBindingCollection(OperationBinding operationBinding) : base(operationBinding) { } - - /// - /// - /// [To be supplied.] - /// - public FaultBinding this[int index] - { - get { return (FaultBinding)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(FaultBinding bindingOperationFault) - { - return List.Add(bindingOperationFault); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, FaultBinding bindingOperationFault) - { - List.Insert(index, bindingOperationFault); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(FaultBinding bindingOperationFault) - { - return List.IndexOf(bindingOperationFault); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(FaultBinding bindingOperationFault) - { - return List.Contains(bindingOperationFault); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(FaultBinding bindingOperationFault) - { - List.Remove(bindingOperationFault); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(FaultBinding[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public FaultBinding this[string name] - { - get { return (FaultBinding)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((FaultBinding)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((FaultBinding)value).SetParent((OperationBinding)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class OperationCollection : ServiceDescriptionBaseCollection - { - internal OperationCollection(PortType portType) : base(portType) { } - - /// - /// - /// [To be supplied.] - /// - public Operation this[int index] - { - get { return (Operation)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(Operation operation) - { - return List.Add(operation); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, Operation operation) - { - List.Insert(index, operation); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(Operation operation) - { - return List.IndexOf(operation); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(Operation operation) - { - return List.Contains(operation); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(Operation operation) - { - List.Remove(operation); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(Operation[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((Operation)value).SetParent((PortType)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public sealed class OperationFaultCollection : ServiceDescriptionBaseCollection - { - internal OperationFaultCollection(Operation operation) : base(operation) { } - - /// - /// - /// [To be supplied.] - /// - public OperationFault this[int index] - { - get { return (OperationFault)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(OperationFault operationFaultMessage) - { - return List.Add(operationFaultMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, OperationFault operationFaultMessage) - { - List.Insert(index, operationFaultMessage); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(OperationFault operationFaultMessage) - { - return List.IndexOf(operationFaultMessage); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(OperationFault operationFaultMessage) - { - return List.Contains(operationFaultMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(OperationFault operationFaultMessage) - { - List.Remove(operationFaultMessage); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(OperationFault[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - public OperationFault this[string name] - { - get { return (OperationFault)Table[name]; } - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - return ((OperationFault)value).Name; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((OperationFault)value).SetParent((Operation)parent); - } - } - - /// - /// - /// [To be supplied.] - /// - public abstract class ServiceDescriptionBaseCollection : CollectionBase - { - private Hashtable _table; // CONSIDER, better implementation - private object _parent; - - internal ServiceDescriptionBaseCollection(object parent) - { - _parent = parent; - } - - /// - /// - /// [To be supplied.] - /// - protected virtual IDictionary Table - { - get { if (_table == null) _table = new Hashtable(); return _table; } - } - - /// - /// - /// [To be supplied.] - /// - protected virtual string GetKey(object value) - { - return null; // returning null means there is no key - } - - /// - /// - /// [To be supplied.] - /// - protected virtual void SetParent(object value, object parent) - { - // default is that the item has no parent - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnInsertComplete(int index, object value) - { - AddValue(value); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnRemove(int index, object value) - { - RemoveValue(value); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnClear() - { - for (int i = 0; i < List.Count; i++) - { - RemoveValue(List[i]); - } - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnSet(int index, object oldValue, object newValue) - { - RemoveValue(oldValue); - AddValue(newValue); - } - - private void AddValue(object value) - { - string key = GetKey(value); - if (key != null) - { - try - { - Table.Add(key, value); - } - catch (Exception e) - { - if (e is OutOfMemoryException) - { - throw; - } - if (Table[key] != null) - { - throw new ArgumentException(GetDuplicateMessage(value.GetType(), key), e.InnerException); - } - else - { - throw e; - } - } - } - SetParent(value, _parent); - } - - private void RemoveValue(object value) - { - string key = GetKey(value); - if (key != null) Table.Remove(key); - SetParent(value, null); - } - - private static string GetDuplicateMessage(Type type, string elemName) - { - string message = null; - if (type == typeof(ServiceDescriptionFormatExtension)) - message = string.Format(ResWebServices.WebDuplicateFormatExtension, elemName); - else if (type == typeof(OperationMessage)) - message = string.Format(ResWebServices.WebDuplicateOperationMessage, elemName); - else if (type == typeof(Import)) - message = string.Format(ResWebServices.WebDuplicateImport, elemName); - else if (type == typeof(Message)) - message = string.Format(ResWebServices.WebDuplicateMessage, elemName); - else if (type == typeof(Port)) - message = string.Format(ResWebServices.WebDuplicatePort, elemName); - else if (type == typeof(PortType)) - message = string.Format(ResWebServices.WebDuplicatePortType, elemName); - else if (type == typeof(Binding)) - message = string.Format(ResWebServices.WebDuplicateBinding, elemName); - else if (type == typeof(Service)) - message = string.Format(ResWebServices.WebDuplicateService, elemName); - else if (type == typeof(MessagePart)) - message = string.Format(ResWebServices.WebDuplicateMessagePart, elemName); - else if (type == typeof(OperationBinding)) - message = string.Format(ResWebServices.WebDuplicateOperationBinding, elemName); - else if (type == typeof(FaultBinding)) - message = string.Format(ResWebServices.WebDuplicateFaultBinding, elemName); - else if (type == typeof(Operation)) - message = string.Format(ResWebServices.WebDuplicateOperation, elemName); - else if (type == typeof(OperationFault)) - message = string.Format(ResWebServices.WebDuplicateOperationFault, elemName); - else - message = string.Format(ResWebServices.WebDuplicateUnknownElement, type, elemName); - - return message; - } - } - - internal class Schemas - { - private Schemas() { } - internal const string Wsdl = @" - - - - - - - - - - - - This type is extended by component types to allow them to be documented - - - - - - - - - - - - - This type is extended by component types to allow attributes from other namespaces to be added. - - - - - - - - - - - - - - - This type is extended by component types to allow elements from other namespaces to be added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Any top level optional element allowed to appear more then once - any child of definitions element except wsdl:types. Any extensibility element is allowed in any place. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - - internal const string Soap = @" - - - - - - 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - - internal const string WebRef = @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - - internal const string SoapEncoding = @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs deleted file mode 100644 index f9157fb5e23..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionImporter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using System.Web.Services; - using System.Web.Services.Protocols; - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using System.Xml.Schema; - using System.Collections; - using System.Collections.Specialized; - using System.Collections.Generic; - using System; - using System.Reflection; - using Microsoft.CodeDom.Compiler; - using System.Web.Services.Configuration; - using System.Xml; - using Microsoft.CodeDom; - using System.Globalization; - using System.Runtime.InteropServices; - - /// - /// - /// [To be supplied.] - /// - public enum ServiceDescriptionImportStyle - { - /// - /// - /// [To be supplied.] - /// - [XmlEnum("client")] - Client, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("server")] - Server, - /// - /// - /// [To be supplied.] - /// - [XmlEnum("serverInterface")] - ServerInterface, - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs deleted file mode 100644 index 9d0371a593c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptionSerializer.cs +++ /dev/null @@ -1,13556 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - internal class ServiceDescriptionSerializationWriter : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationWriter - { - public void Write125_definitions(object o) - { - WriteStartDocument(); - if (o == null) - { - WriteNullTagLiteral(@"definitions", @"http://schemas.xmlsoap.org/wsdl/"); - return; - } - TopLevelElement(); - Write124_ServiceDescription(@"definitions", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.ServiceDescription)o), true, false); - } - - private void Write124_ServiceDescription(string n, string ns, global::System.Web.Services.Description.ServiceDescription o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.ServiceDescription)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"ServiceDescription", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"targetNamespace", @"", ((global::System.String)o.@TargetNamespace)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - global::System.Web.Services.Description.ImportCollection a = (global::System.Web.Services.Description.ImportCollection)o.@Imports; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write4_Import(@"import", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Import)a[ia]), false, false); - } - } - } - Write67_Types(@"types", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Types)o.@Types), false, false); - { - global::System.Web.Services.Description.MessageCollection a = (global::System.Web.Services.Description.MessageCollection)o.@Messages; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write69_Message(@"message", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Message)a[ia]), false, false); - } - } - } - { - global::System.Web.Services.Description.PortTypeCollection a = (global::System.Web.Services.Description.PortTypeCollection)o.@PortTypes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write75_PortType(@"portType", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.PortType)a[ia]), false, false); - } - } - } - { - global::System.Web.Services.Description.BindingCollection a = (global::System.Web.Services.Description.BindingCollection)o.@Bindings; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write117_Binding(@"binding", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Binding)a[ia]), false, false); - } - } - } - { - global::System.Web.Services.Description.ServiceCollection a = (global::System.Web.Services.Description.ServiceCollection)o.@Services; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write123_Service(@"service", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Service)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write123_Service(string n, string ns, global::System.Web.Services.Description.Service o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Service)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Service", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - global::System.Web.Services.Description.PortCollection a = (global::System.Web.Services.Description.PortCollection)o.@Ports; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write122_Port(@"port", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Port)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write122_Port(string n, string ns, global::System.Web.Services.Description.Port o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Port)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Port", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"binding", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Binding))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12AddressBinding) - { - Write121_Soap12AddressBinding(@"address", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12AddressBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.HttpAddressBinding) - { - Write118_HttpAddressBinding(@"address", @"http://schemas.xmlsoap.org/wsdl/http/", ((global::System.Web.Services.Description.HttpAddressBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapAddressBinding) - { - Write119_SoapAddressBinding(@"address", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapAddressBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write119_SoapAddressBinding(string n, string ns, global::System.Web.Services.Description.SoapAddressBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapAddressBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapAddressBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - WriteEndElement(o); - } - - private void Write118_HttpAddressBinding(string n, string ns, global::System.Web.Services.Description.HttpAddressBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.HttpAddressBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"HttpAddressBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - WriteEndElement(o); - } - - private void Write121_Soap12AddressBinding(string n, string ns, global::System.Web.Services.Description.Soap12AddressBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12AddressBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12AddressBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - WriteEndElement(o); - } - - private void Write117_Binding(string n, string ns, global::System.Web.Services.Description.Binding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Binding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Binding", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Type))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12Binding) - { - Write84_Soap12Binding(@"binding", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12Binding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.HttpBinding) - { - Write77_HttpBinding(@"binding", @"http://schemas.xmlsoap.org/wsdl/http/", ((global::System.Web.Services.Description.HttpBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapBinding) - { - Write80_SoapBinding(@"binding", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - { - global::System.Web.Services.Description.OperationBindingCollection a = (global::System.Web.Services.Description.OperationBindingCollection)o.@Operations; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write116_OperationBinding(@"operation", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.OperationBinding)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write116_OperationBinding(string n, string ns, global::System.Web.Services.Description.OperationBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.OperationBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"OperationBinding", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12OperationBinding) - { - Write88_Soap12OperationBinding(@"operation", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12OperationBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.HttpOperationBinding) - { - Write85_HttpOperationBinding(@"operation", @"http://schemas.xmlsoap.org/wsdl/http/", ((global::System.Web.Services.Description.HttpOperationBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapOperationBinding) - { - Write86_SoapOperationBinding(@"operation", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapOperationBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write110_InputBinding(@"input", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.InputBinding)o.@Input), false, false); - Write111_OutputBinding(@"output", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.OutputBinding)o.@Output), false, false); - { - global::System.Web.Services.Description.FaultBindingCollection a = (global::System.Web.Services.Description.FaultBindingCollection)o.@Faults; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write115_FaultBinding(@"fault", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.FaultBinding)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write115_FaultBinding(string n, string ns, global::System.Web.Services.Description.FaultBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.FaultBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"FaultBinding", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12FaultBinding) - { - Write114_Soap12FaultBinding(@"fault", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12FaultBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapFaultBinding) - { - Write112_SoapFaultBinding(@"fault", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapFaultBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write112_SoapFaultBinding(string n, string ns, global::System.Web.Services.Description.SoapFaultBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapFaultBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write98_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - WriteEndElement(o); - } - - private string Write98_SoapBindingUse(global::System.Web.Services.Description.SoapBindingUse v) - { - string s = null; - switch (v) - { - case global::System.Web.Services.Description.SoapBindingUse.@Encoded: s = @"encoded"; break; - case global::System.Web.Services.Description.SoapBindingUse.@Literal: s = @"literal"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Web.Services.Description.SoapBindingUse"); - } - return s; - } - - private void Write114_Soap12FaultBinding(string n, string ns, global::System.Web.Services.Description.Soap12FaultBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12FaultBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12FaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write100_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - WriteEndElement(o); - } - - private string Write100_SoapBindingUse(global::System.Web.Services.Description.SoapBindingUse v) - { - string s = null; - switch (v) - { - case global::System.Web.Services.Description.SoapBindingUse.@Encoded: s = @"encoded"; break; - case global::System.Web.Services.Description.SoapBindingUse.@Literal: s = @"literal"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Web.Services.Description.SoapBindingUse"); - } - return s; - } - - private void Write111_OutputBinding(string n, string ns, global::System.Web.Services.Description.OutputBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.OutputBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"OutputBinding", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12BodyBinding) - { - Write102_Soap12BodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12BodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.Soap12HeaderBinding) - { - Write109_Soap12HeaderBinding(@"header", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12HeaderBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapHeaderBinding) - { - Write106_SoapHeaderBinding(@"header", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapHeaderBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapBodyBinding) - { - Write99_SoapBodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapBodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeXmlBinding) - { - Write94_MimeXmlBinding(@"mimeXml", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeXmlBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeContentBinding) - { - Write93_MimeContentBinding(@"content", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeContentBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeTextBinding) - { - Write97_MimeTextBinding(@"text", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeMultipartRelatedBinding) - { - Write104_MimeMultipartRelatedBinding(@"multipartRelated", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeMultipartRelatedBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write104_MimeMultipartRelatedBinding(string n, string ns, global::System.Web.Services.Description.MimeMultipartRelatedBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimeMultipartRelatedBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimeMultipartRelatedBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - { - global::System.Web.Services.Description.MimePartCollection a = (global::System.Web.Services.Description.MimePartCollection)o.@Parts; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write103_MimePart(@"part", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimePart)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write103_MimePart(string n, string ns, global::System.Web.Services.Description.MimePart o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimePart)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimePart", @"http://schemas.xmlsoap.org/wsdl/mime/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12BodyBinding) - { - Write102_Soap12BodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12BodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapBodyBinding) - { - Write99_SoapBodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapBodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeContentBinding) - { - Write93_MimeContentBinding(@"content", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeContentBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeXmlBinding) - { - Write94_MimeXmlBinding(@"mimeXml", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeXmlBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeTextBinding) - { - Write97_MimeTextBinding(@"text", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write97_MimeTextBinding(string n, string ns, global::System.Web.Services.Description.MimeTextBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimeTextBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimeTextBinding", @"http://microsoft.com/wsdl/mime/textMatching/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - { - global::System.Web.Services.Description.MimeTextMatchCollection a = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write96_MimeTextMatch(@"match", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextMatch)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write96_MimeTextMatch(string n, string ns, global::System.Web.Services.Description.MimeTextMatch o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimeTextMatch)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimeTextMatch", @"http://microsoft.com/wsdl/mime/textMatching/"); - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"type", @"", ((global::System.String)o.@Type)); - if (((global::System.Int32)o.@Group) != 1) - { - WriteAttribute(@"group", @"", System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Group))); - } - if (((global::System.Int32)o.@Capture) != 0) - { - WriteAttribute(@"capture", @"", System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Capture))); - } - if (((global::System.String)o.@RepeatsString) != @"1") - { - WriteAttribute(@"repeats", @"", ((global::System.String)o.@RepeatsString)); - } - WriteAttribute(@"pattern", @"", ((global::System.String)o.@Pattern)); - WriteAttribute(@"ignoreCase", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IgnoreCase))); - { - global::System.Web.Services.Description.MimeTextMatchCollection a = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write96_MimeTextMatch(@"match", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextMatch)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write94_MimeXmlBinding(string n, string ns, global::System.Web.Services.Description.MimeXmlBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimeXmlBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimeXmlBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - WriteEndElement(o); - } - - private void Write93_MimeContentBinding(string n, string ns, global::System.Web.Services.Description.MimeContentBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MimeContentBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"MimeContentBinding", @"http://schemas.xmlsoap.org/wsdl/mime/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - WriteAttribute(@"type", @"", ((global::System.String)o.@Type)); - WriteEndElement(o); - } - - private void Write99_SoapBodyBinding(string n, string ns, global::System.Web.Services.Description.SoapBodyBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapBodyBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapBodyBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write98_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - WriteAttribute(@"parts", @"", ((global::System.String)o.@PartsString)); - WriteEndElement(o); - } - - private void Write102_Soap12BodyBinding(string n, string ns, global::System.Web.Services.Description.Soap12BodyBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12BodyBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12BodyBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write100_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - WriteAttribute(@"parts", @"", ((global::System.String)o.@PartsString)); - WriteEndElement(o); - } - - private void Write106_SoapHeaderBinding(string n, string ns, global::System.Web.Services.Description.SoapHeaderBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapHeaderBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapHeaderBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write98_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - Write105_SoapHeaderFaultBinding(@"headerfault", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapHeaderFaultBinding)o.@Fault), false, false); - WriteEndElement(o); - } - - private void Write105_SoapHeaderFaultBinding(string n, string ns, global::System.Web.Services.Description.SoapHeaderFaultBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapHeaderFaultBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapHeaderFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write98_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - WriteEndElement(o); - } - - private void Write109_Soap12HeaderBinding(string n, string ns, global::System.Web.Services.Description.Soap12HeaderBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12HeaderBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12HeaderBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write100_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - Write107_SoapHeaderFaultBinding(@"headerfault", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.SoapHeaderFaultBinding)o.@Fault), false, false); - WriteEndElement(o); - } - - private void Write107_SoapHeaderFaultBinding(string n, string ns, global::System.Web.Services.Description.SoapHeaderFaultBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapHeaderFaultBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapHeaderFaultBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - WriteAttribute(@"part", @"", ((global::System.String)o.@Part)); - if (((global::System.Web.Services.Description.SoapBindingUse)o.@Use) != global::System.Web.Services.Description.SoapBindingUse.@Default) - { - WriteAttribute(@"use", @"", Write100_SoapBindingUse(((global::System.Web.Services.Description.SoapBindingUse)o.@Use))); - } - if ((((global::System.String)o.@Encoding) != null) && (((global::System.String)o.@Encoding).Length != 0)) - { - WriteAttribute(@"encodingStyle", @"", ((global::System.String)o.@Encoding)); - } - if ((((global::System.String)o.@Namespace) != null) && (((global::System.String)o.@Namespace).Length != 0)) - { - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - } - WriteEndElement(o); - } - - private void Write110_InputBinding(string n, string ns, global::System.Web.Services.Description.InputBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.InputBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"InputBinding", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Object ai = (global::System.Object)a[ia]; - { - if (ai is global::System.Web.Services.Description.Soap12BodyBinding) - { - Write102_Soap12BodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12BodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.Soap12HeaderBinding) - { - Write109_Soap12HeaderBinding(@"header", @"http://schemas.xmlsoap.org/wsdl/soap12/", ((global::System.Web.Services.Description.Soap12HeaderBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapBodyBinding) - { - Write99_SoapBodyBinding(@"body", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapBodyBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.SoapHeaderBinding) - { - Write106_SoapHeaderBinding(@"header", @"http://schemas.xmlsoap.org/wsdl/soap/", ((global::System.Web.Services.Description.SoapHeaderBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeTextBinding) - { - Write97_MimeTextBinding(@"text", @"http://microsoft.com/wsdl/mime/textMatching/", ((global::System.Web.Services.Description.MimeTextBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.HttpUrlReplacementBinding) - { - Write91_HttpUrlReplacementBinding(@"urlReplacement", @"http://schemas.xmlsoap.org/wsdl/http/", ((global::System.Web.Services.Description.HttpUrlReplacementBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.HttpUrlEncodedBinding) - { - Write90_HttpUrlEncodedBinding(@"urlEncoded", @"http://schemas.xmlsoap.org/wsdl/http/", ((global::System.Web.Services.Description.HttpUrlEncodedBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeContentBinding) - { - Write93_MimeContentBinding(@"content", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeContentBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeMultipartRelatedBinding) - { - Write104_MimeMultipartRelatedBinding(@"multipartRelated", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeMultipartRelatedBinding)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.MimeXmlBinding) - { - Write94_MimeXmlBinding(@"mimeXml", @"http://schemas.xmlsoap.org/wsdl/mime/", ((global::System.Web.Services.Description.MimeXmlBinding)ai), false, false); - } - else if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write90_HttpUrlEncodedBinding(string n, string ns, global::System.Web.Services.Description.HttpUrlEncodedBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.HttpUrlEncodedBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"HttpUrlEncodedBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteEndElement(o); - } - - private void Write91_HttpUrlReplacementBinding(string n, string ns, global::System.Web.Services.Description.HttpUrlReplacementBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.HttpUrlReplacementBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"HttpUrlReplacementBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteEndElement(o); - } - - private void Write86_SoapOperationBinding(string n, string ns, global::System.Web.Services.Description.SoapOperationBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapOperationBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapOperationBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"soapAction", @"", ((global::System.String)o.@SoapAction)); - if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Default) - { - WriteAttribute(@"style", @"", Write79_SoapBindingStyle(((global::System.Web.Services.Description.SoapBindingStyle)o.@Style))); - } - WriteEndElement(o); - } - - private string Write79_SoapBindingStyle(global::System.Web.Services.Description.SoapBindingStyle v) - { - string s = null; - switch (v) - { - case global::System.Web.Services.Description.SoapBindingStyle.@Document: s = @"document"; break; - case global::System.Web.Services.Description.SoapBindingStyle.@Rpc: s = @"rpc"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Web.Services.Description.SoapBindingStyle"); - } - return s; - } - - private void Write85_HttpOperationBinding(string n, string ns, global::System.Web.Services.Description.HttpOperationBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.HttpOperationBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"HttpOperationBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - WriteEndElement(o); - } - - private void Write88_Soap12OperationBinding(string n, string ns, global::System.Web.Services.Description.Soap12OperationBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12OperationBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12OperationBinding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"soapAction", @"", ((global::System.String)o.@SoapAction)); - if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Default) - { - WriteAttribute(@"style", @"", Write82_SoapBindingStyle(((global::System.Web.Services.Description.SoapBindingStyle)o.@Style))); - } - if (((global::System.Boolean)o.@SoapActionRequired) != false) - { - WriteAttribute(@"soapActionRequired", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@SoapActionRequired))); - } - WriteEndElement(o); - } - - private string Write82_SoapBindingStyle(global::System.Web.Services.Description.SoapBindingStyle v) - { - string s = null; - switch (v) - { - case global::System.Web.Services.Description.SoapBindingStyle.@Document: s = @"document"; break; - case global::System.Web.Services.Description.SoapBindingStyle.@Rpc: s = @"rpc"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Web.Services.Description.SoapBindingStyle"); - } - return s; - } - - private void Write80_SoapBinding(string n, string ns, global::System.Web.Services.Description.SoapBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.SoapBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"SoapBinding", @"http://schemas.xmlsoap.org/wsdl/soap/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"transport", @"", ((global::System.String)o.@Transport)); - if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Document) - { - WriteAttribute(@"style", @"", Write79_SoapBindingStyle(((global::System.Web.Services.Description.SoapBindingStyle)o.@Style))); - } - WriteEndElement(o); - } - - private void Write77_HttpBinding(string n, string ns, global::System.Web.Services.Description.HttpBinding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.HttpBinding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"HttpBinding", @"http://schemas.xmlsoap.org/wsdl/http/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"verb", @"", ((global::System.String)o.@Verb)); - WriteEndElement(o); - } - - private void Write84_Soap12Binding(string n, string ns, global::System.Web.Services.Description.Soap12Binding o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Soap12Binding)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, null); - if (needType) WriteXsiType(@"Soap12Binding", @"http://schemas.xmlsoap.org/wsdl/soap12/"); - if (((global::System.Boolean)o.@Required) != false) - { - WriteAttribute(@"required", @"http://schemas.xmlsoap.org/wsdl/", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@Required))); - } - WriteAttribute(@"transport", @"", ((global::System.String)o.@Transport)); - if (((global::System.Web.Services.Description.SoapBindingStyle)o.@Style) != global::System.Web.Services.Description.SoapBindingStyle.@Document) - { - WriteAttribute(@"style", @"", Write82_SoapBindingStyle(((global::System.Web.Services.Description.SoapBindingStyle)o.@Style))); - } - WriteEndElement(o); - } - - private void Write75_PortType(string n, string ns, global::System.Web.Services.Description.PortType o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.PortType)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"PortType", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - global::System.Web.Services.Description.OperationCollection a = (global::System.Web.Services.Description.OperationCollection)o.@Operations; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write74_Operation(@"operation", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.Operation)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write74_Operation(string n, string ns, global::System.Web.Services.Description.Operation o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Operation)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Operation", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((((global::System.String)o.@ParameterOrderString) != null) && (((global::System.String)o.@ParameterOrderString).Length != 0)) - { - WriteAttribute(@"parameterOrder", @"", ((global::System.String)o.@ParameterOrderString)); - } - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - global::System.Web.Services.Description.OperationMessageCollection a = (global::System.Web.Services.Description.OperationMessageCollection)o.@Messages; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - global::System.Web.Services.Description.OperationMessage ai = (global::System.Web.Services.Description.OperationMessage)a[ia]; - { - if (ai is global::System.Web.Services.Description.OperationOutput) - { - Write72_OperationOutput(@"output", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.OperationOutput)ai), false, false); - } - else if (ai is global::System.Web.Services.Description.OperationInput) - { - Write71_OperationInput(@"input", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.OperationInput)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - { - global::System.Web.Services.Description.OperationFaultCollection a = (global::System.Web.Services.Description.OperationFaultCollection)o.@Faults; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write73_OperationFault(@"fault", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.OperationFault)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write73_OperationFault(string n, string ns, global::System.Web.Services.Description.OperationFault o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.OperationFault)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"OperationFault", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - WriteEndElement(o); - } - - private void Write71_OperationInput(string n, string ns, global::System.Web.Services.Description.OperationInput o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.OperationInput)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"OperationInput", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - WriteEndElement(o); - } - - private void Write72_OperationOutput(string n, string ns, global::System.Web.Services.Description.OperationOutput o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.OperationOutput)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"OperationOutput", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"message", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Message))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - WriteEndElement(o); - } - - private void Write69_Message(string n, string ns, global::System.Web.Services.Description.Message o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Message)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Message", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - global::System.Web.Services.Description.MessagePartCollection a = (global::System.Web.Services.Description.MessagePartCollection)o.@Parts; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write68_MessagePart(@"part", @"http://schemas.xmlsoap.org/wsdl/", ((global::System.Web.Services.Description.MessagePart)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write68_MessagePart(string n, string ns, global::System.Web.Services.Description.MessagePart o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.MessagePart)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"MessagePart", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"element", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Element))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Type))); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - WriteEndElement(o); - } - - private void Write67_Types(string n, string ns, global::System.Web.Services.Description.Types o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Types)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Types", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - { - System.Xml.Serialization.XmlSchemas a = (System.Xml.Serialization.XmlSchemas)o.@Schemas; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write66_XmlSchema(@"schema", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchema)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write66_XmlSchema(string n, string ns, System.Xml.Schema.XmlSchema o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchema)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchema", @"http://www.w3.org/2001/XMLSchema"); - if (((System.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault) != System.Xml.Schema.XmlSchemaForm.@None) - { - WriteAttribute(@"attributeFormDefault", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@AttributeFormDefault))); - } - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"blockDefault", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@BlockDefault))); - } - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"finalDefault", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@FinalDefault))); - } - if (((System.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault) != System.Xml.Schema.XmlSchemaForm.@None) - { - WriteAttribute(@"elementFormDefault", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@ElementFormDefault))); - } - WriteAttribute(@"targetNamespace", @"", ((global::System.String)o.@TargetNamespace)); - WriteAttribute(@"version", @"", ((global::System.String)o.@Version)); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaRedefine) - { - Write64_XmlSchemaRedefine(@"redefine", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaRedefine)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaImport) - { - Write13_XmlSchemaImport(@"import", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaImport)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaInclude) - { - Write12_XmlSchemaInclude(@"include", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaInclude)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaElement) - { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaComplexType) - { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaSimpleType) - { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroup) - { - Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaNotation) - { - Write65_XmlSchemaNotation(@"notation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaNotation)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaGroup) - { - Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroup)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAnnotation) - { - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write11_XmlSchemaAnnotation(string n, string ns, System.Xml.Schema.XmlSchemaAnnotation o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAnnotation)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAnnotation", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAppInfo) - { - Write10_XmlSchemaAppInfo(@"appinfo", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAppInfo)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaDocumentation) - { - Write9_XmlSchemaDocumentation(@"documentation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaDocumentation)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write9_XmlSchemaDocumentation(string n, string ns, System.Xml.Schema.XmlSchemaDocumentation o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaDocumentation)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaDocumentation", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"source", @"", ((global::System.String)o.@Source)); - WriteAttribute(@"lang", @"http://www.w3.org/XML/1998/namespace", ((global::System.String)o.@Language)); - { - System.Xml.XmlNode[] a = (System.Xml.XmlNode[])o.@Markup; - if (a != null) - { - for (int ia = 0; ia < a.Length; ia++) - { - System.Xml.XmlNode ai = (System.Xml.XmlNode)a[ia]; - { - if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else if (ai is System.Xml.XmlNode) - { - ((System.Xml.XmlNode)ai).WriteTo(Writer); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write10_XmlSchemaAppInfo(string n, string ns, System.Xml.Schema.XmlSchemaAppInfo o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAppInfo)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAppInfo", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"source", @"", ((global::System.String)o.@Source)); - { - System.Xml.XmlNode[] a = (System.Xml.XmlNode[])o.@Markup; - if (a != null) - { - for (int ia = 0; ia < a.Length; ia++) - { - System.Xml.XmlNode ai = (System.Xml.XmlNode)a[ia]; - { - if (ai is System.Xml.XmlElement) - { - System.Xml.XmlElement elem = (System.Xml.XmlElement)ai; - if ((elem) is System.Xml.XmlNode || elem == null) - { - WriteElementLiteral((System.Xml.XmlNode)elem, @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(elem); - } - } - else if (ai is System.Xml.XmlNode) - { - ((System.Xml.XmlNode)ai).WriteTo(Writer); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write63_XmlSchemaGroup(string n, string ns, System.Xml.Schema.XmlSchemaGroup o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaGroup)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaGroup", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Particle is System.Xml.Schema.XmlSchemaAll) - { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); - } - else - { - if (o.@Particle != null) - { - throw CreateUnknownTypeException(o.@Particle); - } - } - } - WriteEndElement(o); - } - - private void Write53_XmlSchemaSequence(string n, string ns, System.Xml.Schema.XmlSchemaSequence o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSequence)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSequence", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaGroupRef) - { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaElement) - { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAny) - { - Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAny)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write46_XmlSchemaAny(string n, string ns, System.Xml.Schema.XmlSchemaAny o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAny)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAny", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if (((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != System.Xml.Schema.XmlSchemaContentProcessing.@None) - { - WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private string Write38_XmlSchemaContentProcessing(System.Xml.Schema.XmlSchemaContentProcessing v) - { - string s = null; - switch (v) - { - case System.Xml.Schema.XmlSchemaContentProcessing.@Skip: s = @"skip"; break; - case System.Xml.Schema.XmlSchemaContentProcessing.@Lax: s = @"lax"; break; - case System.Xml.Schema.XmlSchemaContentProcessing.@Strict: s = @"strict"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaContentProcessing"); - } - return s; - } - - private void Write52_XmlSchemaElement(string n, string ns, System.Xml.Schema.XmlSchemaElement o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaElement)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaElement", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - if (((global::System.Boolean)o.@IsAbstract) != false) - { - WriteAttribute(@"abstract", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); - } - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); - } - WriteAttribute(@"default", @"", ((global::System.String)o.@DefaultValue)); - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); - } - WriteAttribute(@"fixed", @"", ((global::System.String)o.@FixedValue)); - if (((System.Xml.Schema.XmlSchemaForm)o.@Form) != System.Xml.Schema.XmlSchemaForm.@None) - { - WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@Form))); - } - if ((((global::System.String)o.@Name) != null) && (((global::System.String)o.@Name).Length != 0)) - { - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - } - if (((global::System.Boolean)o.@IsNillable) != false) - { - WriteAttribute(@"nillable", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsNillable))); - } - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); - WriteAttribute(@"substitutionGroup", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SubstitutionGroup))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SchemaTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@SchemaType is System.Xml.Schema.XmlSchemaComplexType) - { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)o.@SchemaType), false, false); - } - else if (o.@SchemaType is System.Xml.Schema.XmlSchemaSimpleType) - { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); - } - else - { - if (o.@SchemaType != null) - { - throw CreateUnknownTypeException(o.@SchemaType); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaKeyref) - { - Write51_XmlSchemaKeyref(@"keyref", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaKeyref)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaUnique) - { - Write50_XmlSchemaUnique(@"unique", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaUnique)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaKey) - { - Write49_XmlSchemaKey(@"key", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaKey)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write49_XmlSchemaKey(string n, string ns, System.Xml.Schema.XmlSchemaKey o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaKey)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaKey", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write47_XmlSchemaXPath(string n, string ns, System.Xml.Schema.XmlSchemaXPath o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaXPath)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaXPath", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - if ((((global::System.String)o.@XPath) != null) && (((global::System.String)o.@XPath).Length != 0)) - { - WriteAttribute(@"xpath", @"", ((global::System.String)o.@XPath)); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write50_XmlSchemaUnique(string n, string ns, System.Xml.Schema.XmlSchemaUnique o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaUnique)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaUnique", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write51_XmlSchemaKeyref(string n, string ns, System.Xml.Schema.XmlSchemaKeyref o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaKeyref)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaKeyref", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"refer", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@Refer))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write47_XmlSchemaXPath(@"selector", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)o.@Selector), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write47_XmlSchemaXPath(@"field", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaXPath)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write34_XmlSchemaSimpleType(string n, string ns, System.Xml.Schema.XmlSchemaSimpleType o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleType)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleType", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeUnion) - { - Write33_XmlSchemaSimpleTypeUnion(@"union", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeUnion)o.@Content), false, false); - } - else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeRestriction) - { - Write32_XmlSchemaSimpleTypeRestriction(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeRestriction)o.@Content), false, false); - } - else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleTypeList) - { - Write17_XmlSchemaSimpleTypeList(@"list", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleTypeList)o.@Content), false, false); - } - else - { - if (o.@Content != null) - { - throw CreateUnknownTypeException(o.@Content); - } - } - } - WriteEndElement(o); - } - - private void Write17_XmlSchemaSimpleTypeList(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeList o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeList)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleTypeList", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"itemType", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@ItemTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@ItemType), false, false); - WriteEndElement(o); - } - - private void Write32_XmlSchemaSimpleTypeRestriction(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeRestriction o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeRestriction)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleTypeRestriction", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaLengthFacet) - { - Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaTotalDigitsFacet) - { - Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxLengthFacet) - { - Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaFractionDigitsFacet) - { - Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMinLengthFacet) - { - Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxExclusiveFacet) - { - Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaWhiteSpaceFacet) - { - Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMinExclusiveFacet) - { - Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaPatternFacet) - { - Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMinInclusiveFacet) - { - Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxInclusiveFacet) - { - Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaEnumerationFacet) - { - Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write26_XmlSchemaEnumerationFacet(string n, string ns, System.Xml.Schema.XmlSchemaEnumerationFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaEnumerationFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaEnumerationFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write27_XmlSchemaMaxInclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxInclusiveFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMaxInclusiveFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMaxInclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write21_XmlSchemaMinInclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinInclusiveFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMinInclusiveFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMinInclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write25_XmlSchemaPatternFacet(string n, string ns, System.Xml.Schema.XmlSchemaPatternFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaPatternFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaPatternFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write30_XmlSchemaMinExclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinExclusiveFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMinExclusiveFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMinExclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write29_XmlSchemaWhiteSpaceFacet(string n, string ns, System.Xml.Schema.XmlSchemaWhiteSpaceFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaWhiteSpaceFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaWhiteSpaceFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write28_XmlSchemaMaxExclusiveFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxExclusiveFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMaxExclusiveFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMaxExclusiveFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write31_XmlSchemaMinLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaMinLengthFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMinLengthFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMinLengthFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write20_XmlSchemaFractionDigitsFacet(string n, string ns, System.Xml.Schema.XmlSchemaFractionDigitsFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaFractionDigitsFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaFractionDigitsFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write22_XmlSchemaMaxLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaMaxLengthFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaMaxLengthFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaMaxLengthFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write24_XmlSchemaTotalDigitsFacet(string n, string ns, System.Xml.Schema.XmlSchemaTotalDigitsFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaTotalDigitsFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaTotalDigitsFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write23_XmlSchemaLengthFacet(string n, string ns, System.Xml.Schema.XmlSchemaLengthFacet o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaLengthFacet)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaLengthFacet", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"value", @"", ((global::System.String)o.@Value)); - if (((global::System.Boolean)o.@IsFixed) != false) - { - WriteAttribute(@"fixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsFixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, System.Xml.Schema.XmlSchemaSimpleTypeUnion o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleTypeUnion)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleTypeUnion", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - { - System.Xml.XmlQualifiedName[] a = (System.Xml.XmlQualifiedName[])o.@MemberTypes; - if (a != null) - { - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlQualifiedName ai = (System.Xml.XmlQualifiedName)a[i]; - if (i != 0) sb.Append(" "); - sb.Append(FromXmlQualifiedName(ai)); - } - if (sb.Length != 0) - { - WriteAttribute(@"memberTypes", @"", sb.ToString()); - } - } - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private string Write7_XmlSchemaDerivationMethod(System.Xml.Schema.XmlSchemaDerivationMethod v) - { - string s = null; - switch (v) - { - case System.Xml.Schema.XmlSchemaDerivationMethod.@Empty: s = @""; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution: s = @"substitution"; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@Extension: s = @"extension"; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction: s = @"restriction"; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@List: s = @"list"; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@Union: s = @"union"; break; - case System.Xml.Schema.XmlSchemaDerivationMethod.@All: s = @"#all"; break; - default: - s = FromEnum(((System.Int64)v), new string[] { @"", - @"substitution", - @"extension", - @"restriction", - @"list", - @"union", - @"#all" }, new System.Int64[] { (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Empty, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Extension, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@List, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Union, - (long)System.Xml.Schema.XmlSchemaDerivationMethod.@All }, @"System.Xml.Schema.XmlSchemaDerivationMethod"); break; - } - return s; - } - - private void Write62_XmlSchemaComplexType(string n, string ns, System.Xml.Schema.XmlSchemaComplexType o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaComplexType)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaComplexType", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"final", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Final))); - } - if (((global::System.Boolean)o.@IsAbstract) != false) - { - WriteAttribute(@"abstract", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsAbstract))); - } - if (((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block) != (System.Xml.Schema.XmlSchemaDerivationMethod.@None)) - { - WriteAttribute(@"block", @"", Write7_XmlSchemaDerivationMethod(((System.Xml.Schema.XmlSchemaDerivationMethod)o.@Block))); - } - if (((global::System.Boolean)o.@IsMixed) != false) - { - WriteAttribute(@"mixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@ContentModel is System.Xml.Schema.XmlSchemaSimpleContent) - { - Write61_XmlSchemaSimpleContent(@"simpleContent", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContent)o.@ContentModel), false, false); - } - else if (o.@ContentModel is System.Xml.Schema.XmlSchemaComplexContent) - { - Write58_XmlSchemaComplexContent(@"complexContent", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContent)o.@ContentModel), false, false); - } - else - { - if (o.@ContentModel != null) - { - throw CreateUnknownTypeException(o.@ContentModel); - } - } - } - { - if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaAll) - { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) - { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); - } - else - { - if (o.@Particle != null) - { - throw CreateUnknownTypeException(o.@Particle); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write39_XmlSchemaAnyAttribute(string n, string ns, System.Xml.Schema.XmlSchemaAnyAttribute o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAnyAttribute)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAnyAttribute", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - if (((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents) != System.Xml.Schema.XmlSchemaContentProcessing.@None) - { - WriteAttribute(@"processContents", @"", Write38_XmlSchemaContentProcessing(((System.Xml.Schema.XmlSchemaContentProcessing)o.@ProcessContents))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write36_XmlSchemaAttribute(string n, string ns, System.Xml.Schema.XmlSchemaAttribute o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAttribute)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAttribute", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"default", @"", ((global::System.String)o.@DefaultValue)); - WriteAttribute(@"fixed", @"", ((global::System.String)o.@FixedValue)); - if (((System.Xml.Schema.XmlSchemaForm)o.@Form) != System.Xml.Schema.XmlSchemaForm.@None) - { - WriteAttribute(@"form", @"", Write6_XmlSchemaForm(((System.Xml.Schema.XmlSchemaForm)o.@Form))); - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); - WriteAttribute(@"type", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@SchemaTypeName))); - if (((System.Xml.Schema.XmlSchemaUse)o.@Use) != System.Xml.Schema.XmlSchemaUse.@None) - { - WriteAttribute(@"use", @"", Write35_XmlSchemaUse(((System.Xml.Schema.XmlSchemaUse)o.@Use))); - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@SchemaType), false, false); - WriteEndElement(o); - } - - private string Write35_XmlSchemaUse(System.Xml.Schema.XmlSchemaUse v) - { - string s = null; - switch (v) - { - case System.Xml.Schema.XmlSchemaUse.@Optional: s = @"optional"; break; - case System.Xml.Schema.XmlSchemaUse.@Prohibited: s = @"prohibited"; break; - case System.Xml.Schema.XmlSchemaUse.@Required: s = @"required"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaUse"); - } - return s; - } - - private string Write6_XmlSchemaForm(System.Xml.Schema.XmlSchemaForm v) - { - string s = null; - switch (v) - { - case System.Xml.Schema.XmlSchemaForm.@Qualified: s = @"qualified"; break; - case System.Xml.Schema.XmlSchemaForm.@Unqualified: s = @"unqualified"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Xml.Schema.XmlSchemaForm"); - } - return s; - } - - private void Write37_XmlSchemaAttributeGroupRef(string n, string ns, System.Xml.Schema.XmlSchemaAttributeGroupRef o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAttributeGroupRef", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write44_XmlSchemaGroupRef(string n, string ns, System.Xml.Schema.XmlSchemaGroupRef o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaGroupRef)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaGroupRef", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - WriteAttribute(@"ref", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@RefName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write55_XmlSchemaAll(string n, string ns, System.Xml.Schema.XmlSchemaAll o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAll)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAll", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)a[ia]), false, false); - } - } - } - WriteEndElement(o); - } - - private void Write54_XmlSchemaChoice(string n, string ns, System.Xml.Schema.XmlSchemaChoice o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaChoice)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaChoice", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"minOccurs", @"", ((global::System.String)o.@MinOccursString)); - WriteAttribute(@"maxOccurs", @"", ((global::System.String)o.@MaxOccursString)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaGroupRef) - { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaElement) - { - Write52_XmlSchemaElement(@"element", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaElement)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAny) - { - Write46_XmlSchemaAny(@"any", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAny)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write58_XmlSchemaComplexContent(string n, string ns, System.Xml.Schema.XmlSchemaComplexContent o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaComplexContent)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaComplexContent", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"mixed", @"", System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsMixed))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Content is System.Xml.Schema.XmlSchemaComplexContentRestriction) - { - Write57_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContentRestriction)o.@Content), false, false); - } - else if (o.@Content is System.Xml.Schema.XmlSchemaComplexContentExtension) - { - Write56_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexContentExtension)o.@Content), false, false); - } - else - { - if (o.@Content != null) - { - throw CreateUnknownTypeException(o.@Content); - } - } - } - WriteEndElement(o); - } - - private void Write56_Item(string n, string ns, System.Xml.Schema.XmlSchemaComplexContentExtension o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaComplexContentExtension)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaComplexContentExtension", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Particle is System.Xml.Schema.XmlSchemaAll) - { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) - { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); - } - else - { - if (o.@Particle != null) - { - throw CreateUnknownTypeException(o.@Particle); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write57_Item(string n, string ns, System.Xml.Schema.XmlSchemaComplexContentRestriction o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaComplexContentRestriction)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaComplexContentRestriction", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Particle is System.Xml.Schema.XmlSchemaAll) - { - Write55_XmlSchemaAll(@"all", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAll)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaSequence) - { - Write53_XmlSchemaSequence(@"sequence", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSequence)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaChoice) - { - Write54_XmlSchemaChoice(@"choice", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaChoice)o.@Particle), false, false); - } - else if (o.@Particle is System.Xml.Schema.XmlSchemaGroupRef) - { - Write44_XmlSchemaGroupRef(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroupRef)o.@Particle), false, false); - } - else - { - if (o.@Particle != null) - { - throw CreateUnknownTypeException(o.@Particle); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write61_XmlSchemaSimpleContent(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContent o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContent)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleContent", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - if (o.@Content is System.Xml.Schema.XmlSchemaSimpleContentExtension) - { - Write60_Item(@"extension", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContentExtension)o.@Content), false, false); - } - else if (o.@Content is System.Xml.Schema.XmlSchemaSimpleContentRestriction) - { - Write59_Item(@"restriction", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleContentRestriction)o.@Content), false, false); - } - else - { - if (o.@Content != null) - { - throw CreateUnknownTypeException(o.@Content); - } - } - } - WriteEndElement(o); - } - - private void Write59_Item(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContentRestriction o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContentRestriction)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleContentRestriction", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)o.@BaseType), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaMinLengthFacet) - { - Write31_XmlSchemaMinLengthFacet(@"minLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxLengthFacet) - { - Write22_XmlSchemaMaxLengthFacet(@"maxLength", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaLengthFacet) - { - Write23_XmlSchemaLengthFacet(@"length", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaLengthFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaFractionDigitsFacet) - { - Write20_XmlSchemaFractionDigitsFacet(@"fractionDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaFractionDigitsFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaTotalDigitsFacet) - { - Write24_XmlSchemaTotalDigitsFacet(@"totalDigits", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaTotalDigitsFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMinExclusiveFacet) - { - Write30_XmlSchemaMinExclusiveFacet(@"minExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinExclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxInclusiveFacet) - { - Write27_XmlSchemaMaxInclusiveFacet(@"maxInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxInclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMaxExclusiveFacet) - { - Write28_XmlSchemaMaxExclusiveFacet(@"maxExclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMaxExclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaMinInclusiveFacet) - { - Write21_XmlSchemaMinInclusiveFacet(@"minInclusive", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaMinInclusiveFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaWhiteSpaceFacet) - { - Write29_XmlSchemaWhiteSpaceFacet(@"whiteSpace", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaWhiteSpaceFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaEnumerationFacet) - { - Write26_XmlSchemaEnumerationFacet(@"enumeration", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaEnumerationFacet)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaPatternFacet) - { - Write25_XmlSchemaPatternFacet(@"pattern", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaPatternFacet)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write60_Item(string n, string ns, System.Xml.Schema.XmlSchemaSimpleContentExtension o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaSimpleContentExtension)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaSimpleContentExtension", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"base", @"", FromXmlQualifiedName(((System.Xml.XmlQualifiedName)o.@BaseTypeName))); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write65_XmlSchemaNotation(string n, string ns, System.Xml.Schema.XmlSchemaNotation o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaNotation)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaNotation", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - WriteAttribute(@"public", @"", ((global::System.String)o.@Public)); - WriteAttribute(@"system", @"", ((global::System.String)o.@System)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write40_XmlSchemaAttributeGroup(string n, string ns, System.Xml.Schema.XmlSchemaAttributeGroup o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaAttributeGroup)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaAttributeGroup", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"name", @"", ((global::System.String)o.@Name)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaAttributeGroupRef) - { - Write37_XmlSchemaAttributeGroupRef(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroupRef)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttribute) - { - Write36_XmlSchemaAttribute(@"attribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttribute)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - Write39_XmlSchemaAnyAttribute(@"anyAttribute", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnyAttribute)o.@AnyAttribute), false, false); - WriteEndElement(o); - } - - private void Write12_XmlSchemaInclude(string n, string ns, System.Xml.Schema.XmlSchemaInclude o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaInclude)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaInclude", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write13_XmlSchemaImport(string n, string ns, System.Xml.Schema.XmlSchemaImport o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaImport)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaImport", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)o.@Annotation), false, false); - WriteEndElement(o); - } - - private void Write64_XmlSchemaRedefine(string n, string ns, System.Xml.Schema.XmlSchemaRedefine o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(System.Xml.Schema.XmlSchemaRedefine)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"XmlSchemaRedefine", @"http://www.w3.org/2001/XMLSchema"); - WriteAttribute(@"schemaLocation", @"", ((global::System.String)o.@SchemaLocation)); - WriteAttribute(@"id", @"", ((global::System.String)o.@Id)); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@UnhandledAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - { - System.Xml.Schema.XmlSchemaObjectCollection a = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - System.Xml.Schema.XmlSchemaObject ai = (System.Xml.Schema.XmlSchemaObject)a[ia]; - { - if (ai is System.Xml.Schema.XmlSchemaSimpleType) - { - Write34_XmlSchemaSimpleType(@"simpleType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaSimpleType)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaComplexType) - { - Write62_XmlSchemaComplexType(@"complexType", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaComplexType)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaGroup) - { - Write63_XmlSchemaGroup(@"group", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaGroup)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAttributeGroup) - { - Write40_XmlSchemaAttributeGroup(@"attributeGroup", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAttributeGroup)ai), false, false); - } - else if (ai is System.Xml.Schema.XmlSchemaAnnotation) - { - Write11_XmlSchemaAnnotation(@"annotation", @"http://www.w3.org/2001/XMLSchema", ((System.Xml.Schema.XmlSchemaAnnotation)ai), false, false); - } - else - { - if (ai != null) - { - throw CreateUnknownTypeException(ai); - } - } - } - } - } - } - WriteEndElement(o); - } - - private void Write4_Import(string n, string ns, global::System.Web.Services.Description.Import o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(global::System.Web.Services.Description.Import)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - WriteStartElement(n, ns, o, false, o.@Namespaces); - if (needType) WriteXsiType(@"Import", @"http://schemas.xmlsoap.org/wsdl/"); - { - System.Xml.XmlAttribute[] a = (System.Xml.XmlAttribute[])o.@ExtensibleAttributes; - if (a != null) - { - for (int i = 0; i < a.Length; i++) - { - System.Xml.XmlAttribute ai = (System.Xml.XmlAttribute)a[i]; - WriteXmlAttribute(ai, o); - } - } - } - WriteAttribute(@"namespace", @"", ((global::System.String)o.@Namespace)); - WriteAttribute(@"location", @"", ((global::System.String)o.@Location)); - if ((o.@DocumentationElement) is System.Xml.XmlNode || o.@DocumentationElement == null) - { - WriteElementLiteral((System.Xml.XmlNode)o.@DocumentationElement, @"documentation", @"http://schemas.xmlsoap.org/wsdl/", false, true); - } - else - { - throw CreateInvalidAnyTypeException(o.@DocumentationElement); - } - { - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - if (a != null) - { - for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++) - { - if ((a[ia]) is System.Xml.XmlNode || a[ia] == null) - { - WriteElementLiteral((System.Xml.XmlNode)a[ia], @"", null, false, true); - } - else - { - throw CreateInvalidAnyTypeException(a[ia]); - } - } - } - } - WriteEndElement(o); - } - - protected override void InitCallbacks() - { - } - } - internal class ServiceDescriptionSerializationReader : Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSerializationReader - { - public object Read125_definitions() - { - object o = null; - Reader.MoveToContent(); - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id1_definitions && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o = Read124_ServiceDescription(true, true); - } - else - { - throw CreateUnknownNodeException(); - } - } - else - { - UnknownNode(null, @"http://schemas.xmlsoap.org/wsdl/:definitions"); - } - return (object)o; - } - - private global::System.Web.Services.Description.ServiceDescription Read124_ServiceDescription(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id3_ServiceDescription && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.ServiceDescription o; - o = new global::System.Web.Services.Description.ServiceDescription(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.ImportCollection a_5 = (global::System.Web.Services.Description.ImportCollection)o.@Imports; - global::System.Web.Services.Description.MessageCollection a_7 = (global::System.Web.Services.Description.MessageCollection)o.@Messages; - global::System.Web.Services.Description.PortTypeCollection a_8 = (global::System.Web.Services.Description.PortTypeCollection)o.@PortTypes; - global::System.Web.Services.Description.BindingCollection a_9 = (global::System.Web.Services.Description.BindingCollection)o.@Bindings; - global::System.Web.Services.Description.ServiceCollection a_10 = (global::System.Web.Services.Description.ServiceCollection)o.@Services; - bool[] paramsRead = new bool[12]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[11] && ((object)Reader.LocalName == (object)_id6_targetNamespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@TargetNamespace = Reader.Value; - paramsRead[11] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations0 = 0; - int readerCount0 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id8_import && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read4_Import(false, true)); - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id9_types && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Types = Read67_Types(false, true); - paramsRead[6] = true; - } - else if (((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read69_Message(false, true)); - } - else if (((object)Reader.LocalName == (object)_id11_portType && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read75_PortType(false, true)); - } - else if (((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_9) == null) Reader.Skip(); else a_9.Add(Read117_Binding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id13_service && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_10) == null) Reader.Skip(); else a_10.Add(Read123_Service(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/:import, http://schemas.xmlsoap.org/wsdl/:types, http://schemas.xmlsoap.org/wsdl/:message, http://schemas.xmlsoap.org/wsdl/:portType, http://schemas.xmlsoap.org/wsdl/:binding, http://schemas.xmlsoap.org/wsdl/:service"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations0, ref readerCount0); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Service Read123_Service(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id14_Service && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Service o; - o = new global::System.Web.Services.Description.Service(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.PortCollection a_5 = (global::System.Web.Services.Description.PortCollection)o.@Ports; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations1 = 0; - int readerCount1 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id15_port && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read122_Port(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/:port"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations1, ref readerCount1); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Port Read122_Port(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id16_Port && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Port o; - o = new global::System.Web.Services.Description.Port(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Binding = ToXmlQualifiedName(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations2 = 0; - int readerCount2 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id17_address && (object)Reader.NamespaceURI == (object)_id18_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read118_HttpAddressBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id17_address && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read119_SoapAddressBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id17_address && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read121_Soap12AddressBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/http/:address, http://schemas.xmlsoap.org/wsdl/soap/:address, http://schemas.xmlsoap.org/wsdl/soap12/:address"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations2, ref readerCount2); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12AddressBinding Read121_Soap12AddressBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id21_Soap12AddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12AddressBinding o; - o = new global::System.Web.Services.Description.Soap12AddressBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Location = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :location"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations3 = 0; - int readerCount3 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations3, ref readerCount3); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapAddressBinding Read119_SoapAddressBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id24_SoapAddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapAddressBinding o; - o = new global::System.Web.Services.Description.SoapAddressBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Location = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :location"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations4 = 0; - int readerCount4 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations4, ref readerCount4); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.HttpAddressBinding Read118_HttpAddressBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id25_HttpAddressBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.HttpAddressBinding o; - o = new global::System.Web.Services.Description.HttpAddressBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Location = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :location"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations5 = 0; - int readerCount5 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations5, ref readerCount5); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Binding Read117_Binding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id26_Binding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Binding o; - o = new global::System.Web.Services.Description.Binding(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.OperationBindingCollection a_5 = (global::System.Web.Services.Description.OperationBindingCollection)o.@Operations; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Type = ToXmlQualifiedName(Reader.Value); - paramsRead[6] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations6 = 0; - int readerCount6 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id18_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read77_HttpBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read80_SoapBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id12_binding && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read84_Soap12Binding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read116_OperationBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/http/:binding, http://schemas.xmlsoap.org/wsdl/soap/:binding, http://schemas.xmlsoap.org/wsdl/soap12/:binding, http://schemas.xmlsoap.org/wsdl/:operation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations6, ref readerCount6); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.OperationBinding Read116_OperationBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id29_OperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.OperationBinding o; - o = new global::System.Web.Services.Description.OperationBinding(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.FaultBindingCollection a_7 = (global::System.Web.Services.Description.FaultBindingCollection)o.@Faults; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations7 = 0; - int readerCount7 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id18_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read85_HttpOperationBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read86_SoapOperationBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read88_Soap12OperationBinding(false, true)); - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id30_input && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Input = Read110_InputBinding(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id31_output && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Output = Read111_OutputBinding(false, true); - paramsRead[6] = true; - } - else if (((object)Reader.LocalName == (object)_id32_fault && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read115_FaultBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/http/:operation, http://schemas.xmlsoap.org/wsdl/soap/:operation, http://schemas.xmlsoap.org/wsdl/soap12/:operation, http://schemas.xmlsoap.org/wsdl/:input, http://schemas.xmlsoap.org/wsdl/:output, http://schemas.xmlsoap.org/wsdl/:fault"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations7, ref readerCount7); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.FaultBinding Read115_FaultBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id33_FaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.FaultBinding o; - o = new global::System.Web.Services.Description.FaultBinding(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations8 = 0; - int readerCount8 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id32_fault && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read112_SoapFaultBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id32_fault && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read114_Soap12FaultBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/soap/:fault, http://schemas.xmlsoap.org/wsdl/soap12/:fault"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations8, ref readerCount8); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12FaultBinding Read114_Soap12FaultBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id34_Soap12FaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12FaultBinding o; - o = new global::System.Web.Services.Description.Soap12FaultBinding(); - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read100_SoapBindingUse(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :use, :name, :namespace, :encodingStyle"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations9 = 0; - int readerCount9 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations9, ref readerCount9); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBindingUse Read100_SoapBindingUse(string s) - { - switch (s) - { - case @"encoded": return global::System.Web.Services.Description.SoapBindingUse.@Encoded; - case @"literal": return global::System.Web.Services.Description.SoapBindingUse.@Literal; - default: throw CreateUnknownConstantException(s, typeof(global::System.Web.Services.Description.SoapBindingUse)); - } - } - - private global::System.Web.Services.Description.SoapFaultBinding Read112_SoapFaultBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id38_SoapFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapFaultBinding o; - o = new global::System.Web.Services.Description.SoapFaultBinding(); - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read98_SoapBindingUse(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :use, :name, :namespace, :encodingStyle"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations10 = 0; - int readerCount10 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations10, ref readerCount10); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBindingUse Read98_SoapBindingUse(string s) - { - switch (s) - { - case @"encoded": return global::System.Web.Services.Description.SoapBindingUse.@Encoded; - case @"literal": return global::System.Web.Services.Description.SoapBindingUse.@Literal; - default: throw CreateUnknownConstantException(s, typeof(global::System.Web.Services.Description.SoapBindingUse)); - } - } - - private global::System.Web.Services.Description.OutputBinding Read111_OutputBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id39_OutputBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.OutputBinding o; - o = new global::System.Web.Services.Description.OutputBinding(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations11 = 0; - int readerCount11 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id40_content && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read93_MimeContentBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id42_mimeXml && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read94_MimeXmlBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id43_multipartRelated && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read104_MimeMultipartRelatedBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id44_text && (object)Reader.NamespaceURI == (object)_id45_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read97_MimeTextBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read99_SoapBodyBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id47_header && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read106_SoapHeaderBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read102_Soap12BodyBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id47_header && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read109_Soap12HeaderBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/mime/:content, http://schemas.xmlsoap.org/wsdl/mime/:mimeXml, http://schemas.xmlsoap.org/wsdl/mime/:multipartRelated, http://microsoft.com/wsdl/mime/textMatching/:text, http://schemas.xmlsoap.org/wsdl/soap/:body, http://schemas.xmlsoap.org/wsdl/soap/:header, http://schemas.xmlsoap.org/wsdl/soap12/:body, http://schemas.xmlsoap.org/wsdl/soap12/:header"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations11, ref readerCount11); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12HeaderBinding Read109_Soap12HeaderBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id48_Soap12HeaderBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12HeaderBinding o; - o = new global::System.Web.Services.Description.Soap12HeaderBinding(); - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read100_SoapBindingUse(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[5] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :message, :part, :use, :encodingStyle, :namespace"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations12 = 0; - int readerCount12 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id50_headerfault && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - o.@Fault = Read107_SoapHeaderFaultBinding(false, true); - paramsRead[6] = true; - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/soap12/:headerfault"); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/soap12/:headerfault"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations12, ref readerCount12); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapHeaderFaultBinding Read107_SoapHeaderFaultBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapHeaderFaultBinding o; - o = new global::System.Web.Services.Description.SoapHeaderFaultBinding(); - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read100_SoapBindingUse(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[5] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :message, :part, :use, :encodingStyle, :namespace"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations13 = 0; - int readerCount13 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations13, ref readerCount13); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12BodyBinding Read102_Soap12BodyBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id52_Soap12BodyBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12BodyBinding o; - o = new global::System.Web.Services.Description.Soap12BodyBinding(); - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read100_SoapBindingUse(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id53_parts && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@PartsString = Reader.Value; - paramsRead[4] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :use, :namespace, :encodingStyle, :parts"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations14 = 0; - int readerCount14 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations14, ref readerCount14); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapHeaderBinding Read106_SoapHeaderBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id54_SoapHeaderBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapHeaderBinding o; - o = new global::System.Web.Services.Description.SoapHeaderBinding(); - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read98_SoapBindingUse(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[5] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :message, :part, :use, :encodingStyle, :namespace"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations15 = 0; - int readerCount15 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id50_headerfault && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - o.@Fault = Read105_SoapHeaderFaultBinding(false, true); - paramsRead[6] = true; - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/soap/:headerfault"); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/soap/:headerfault"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations15, ref readerCount15); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapHeaderFaultBinding Read105_SoapHeaderFaultBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id51_SoapHeaderFaultBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapHeaderFaultBinding o; - o = new global::System.Web.Services.Description.SoapHeaderFaultBinding(); - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read98_SoapBindingUse(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[5] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :message, :part, :use, :encodingStyle, :namespace"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations16 = 0; - int readerCount16 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations16, ref readerCount16); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBodyBinding Read99_SoapBodyBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id55_SoapBodyBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapBodyBinding o; - o = new global::System.Web.Services.Description.SoapBodyBinding(); - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read98_SoapBindingUse(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id37_encodingStyle && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Encoding = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id53_parts && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@PartsString = Reader.Value; - paramsRead[4] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :use, :namespace, :encodingStyle, :parts"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations17 = 0; - int readerCount17 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations17, ref readerCount17); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimeTextBinding Read97_MimeTextBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id56_MimeTextBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimeTextBinding o; - o = new global::System.Web.Services.Description.MimeTextBinding(); - global::System.Web.Services.Description.MimeTextMatchCollection a_1 = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations18 = 0; - int readerCount18 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id57_match && (object)Reader.NamespaceURI == (object)_id45_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read96_MimeTextMatch(false, true)); - } - else - { - UnknownNode((object)o, @"http://microsoft.com/wsdl/mime/textMatching/:match"); - } - } - else - { - UnknownNode((object)o, @"http://microsoft.com/wsdl/mime/textMatching/:match"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations18, ref readerCount18); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimeTextMatch Read96_MimeTextMatch(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id58_MimeTextMatch && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id45_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimeTextMatch o; - o = new global::System.Web.Services.Description.MimeTextMatch(); - global::System.Web.Services.Description.MimeTextMatchCollection a_7 = (global::System.Web.Services.Description.MimeTextMatchCollection)o.@Matches; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Type = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Group = System.Xml.XmlConvert.ToInt32(Reader.Value); - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id60_capture && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Capture = System.Xml.XmlConvert.ToInt32(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id61_repeats && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@RepeatsString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id62_pattern && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Pattern = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id63_ignoreCase && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IgnoreCase = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[6] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @":name, :type, :group, :capture, :repeats, :pattern, :ignoreCase"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations19 = 0; - int readerCount19 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id57_match && (object)Reader.NamespaceURI == (object)_id45_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read96_MimeTextMatch(false, true)); - } - else - { - UnknownNode((object)o, @"http://microsoft.com/wsdl/mime/textMatching/:match"); - } - } - else - { - UnknownNode((object)o, @"http://microsoft.com/wsdl/mime/textMatching/:match"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations19, ref readerCount19); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimeMultipartRelatedBinding Read104_MimeMultipartRelatedBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id64_MimeMultipartRelatedBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimeMultipartRelatedBinding o; - o = new global::System.Web.Services.Description.MimeMultipartRelatedBinding(); - global::System.Web.Services.Description.MimePartCollection a_1 = (global::System.Web.Services.Description.MimePartCollection)o.@Parts; - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations20 = 0; - int readerCount20 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read103_MimePart(false, true)); - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/mime/:part"); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/mime/:part"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations20, ref readerCount20); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimePart Read103_MimePart(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id65_MimePart && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimePart o; - o = new global::System.Web.Services.Description.MimePart(); - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_1 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations21 = 0; - int readerCount21 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id40_content && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read93_MimeContentBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id42_mimeXml && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read94_MimeXmlBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id44_text && (object)Reader.NamespaceURI == (object)_id45_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read97_MimeTextBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read99_SoapBodyBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_1) == null) Reader.Skip(); else a_1.Add(Read102_Soap12BodyBinding(false, true)); - } - else - { - a_1.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/mime/:content, http://schemas.xmlsoap.org/wsdl/mime/:mimeXml, http://microsoft.com/wsdl/mime/textMatching/:text, http://schemas.xmlsoap.org/wsdl/soap/:body, http://schemas.xmlsoap.org/wsdl/soap12/:body"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations21, ref readerCount21); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimeXmlBinding Read94_MimeXmlBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id66_MimeXmlBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimeXmlBinding o; - o = new global::System.Web.Services.Description.MimeXmlBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :part"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations22 = 0; - int readerCount22 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations22, ref readerCount22); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MimeContentBinding Read93_MimeContentBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id67_MimeContentBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id41_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MimeContentBinding o; - o = new global::System.Web.Services.Description.MimeContentBinding(); - bool[] paramsRead = new bool[3]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Part = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Type = Reader.Value; - paramsRead[2] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :part, :type"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations23 = 0; - int readerCount23 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations23, ref readerCount23); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.InputBinding Read110_InputBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id68_InputBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.InputBinding o; - o = new global::System.Web.Services.Description.InputBinding(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations24 = 0; - int readerCount24 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id69_urlEncoded && (object)Reader.NamespaceURI == (object)_id18_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read90_HttpUrlEncodedBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id70_urlReplacement && (object)Reader.NamespaceURI == (object)_id18_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read91_HttpUrlReplacementBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id40_content && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read93_MimeContentBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id42_mimeXml && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read94_MimeXmlBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id43_multipartRelated && (object)Reader.NamespaceURI == (object)_id41_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read104_MimeMultipartRelatedBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id44_text && (object)Reader.NamespaceURI == (object)_id45_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read97_MimeTextBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read99_SoapBodyBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id47_header && (object)Reader.NamespaceURI == (object)_id19_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read106_SoapHeaderBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id46_body && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read102_Soap12BodyBinding(false, true)); - } - else if (((object)Reader.LocalName == (object)_id47_header && (object)Reader.NamespaceURI == (object)_id20_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read109_Soap12HeaderBinding(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/http/:urlEncoded, http://schemas.xmlsoap.org/wsdl/http/:urlReplacement, http://schemas.xmlsoap.org/wsdl/mime/:content, http://schemas.xmlsoap.org/wsdl/mime/:mimeXml, http://schemas.xmlsoap.org/wsdl/mime/:multipartRelated, http://microsoft.com/wsdl/mime/textMatching/:text, http://schemas.xmlsoap.org/wsdl/soap/:body, http://schemas.xmlsoap.org/wsdl/soap/:header, http://schemas.xmlsoap.org/wsdl/soap12/:body, http://schemas.xmlsoap.org/wsdl/soap12/:header"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations24, ref readerCount24); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.HttpUrlReplacementBinding Read91_HttpUrlReplacementBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id71_HttpUrlReplacementBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.HttpUrlReplacementBinding o; - o = new global::System.Web.Services.Description.HttpUrlReplacementBinding(); - bool[] paramsRead = new bool[1]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations25 = 0; - int readerCount25 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations25, ref readerCount25); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.HttpUrlEncodedBinding Read90_HttpUrlEncodedBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id72_HttpUrlEncodedBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.HttpUrlEncodedBinding o; - o = new global::System.Web.Services.Description.HttpUrlEncodedBinding(); - bool[] paramsRead = new bool[1]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations26 = 0; - int readerCount26 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations26, ref readerCount26); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12OperationBinding Read88_Soap12OperationBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id73_Soap12OperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12OperationBinding o; - o = new global::System.Web.Services.Description.Soap12OperationBinding(); - bool[] paramsRead = new bool[4]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id74_soapAction && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SoapAction = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id75_style && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Style = Read82_SoapBindingStyle(Reader.Value); - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id76_soapActionRequired && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SoapActionRequired = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[3] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :soapAction, :style, :soapActionRequired"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations27 = 0; - int readerCount27 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations27, ref readerCount27); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBindingStyle Read82_SoapBindingStyle(string s) - { - switch (s) - { - case @"document": return global::System.Web.Services.Description.SoapBindingStyle.@Document; - case @"rpc": return global::System.Web.Services.Description.SoapBindingStyle.@Rpc; - default: throw CreateUnknownConstantException(s, typeof(global::System.Web.Services.Description.SoapBindingStyle)); - } - } - - private global::System.Web.Services.Description.SoapOperationBinding Read86_SoapOperationBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id77_SoapOperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapOperationBinding o; - o = new global::System.Web.Services.Description.SoapOperationBinding(); - bool[] paramsRead = new bool[3]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id74_soapAction && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SoapAction = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id75_style && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Style = Read79_SoapBindingStyle(Reader.Value); - paramsRead[2] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :soapAction, :style"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations28 = 0; - int readerCount28 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations28, ref readerCount28); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBindingStyle Read79_SoapBindingStyle(string s) - { - switch (s) - { - case @"document": return global::System.Web.Services.Description.SoapBindingStyle.@Document; - case @"rpc": return global::System.Web.Services.Description.SoapBindingStyle.@Rpc; - default: throw CreateUnknownConstantException(s, typeof(global::System.Web.Services.Description.SoapBindingStyle)); - } - } - - private global::System.Web.Services.Description.HttpOperationBinding Read85_HttpOperationBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id78_HttpOperationBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.HttpOperationBinding o; - o = new global::System.Web.Services.Description.HttpOperationBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Location = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :location"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations29 = 0; - int readerCount29 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations29, ref readerCount29); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Soap12Binding Read84_Soap12Binding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id79_Soap12Binding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id20_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Soap12Binding o; - o = new global::System.Web.Services.Description.Soap12Binding(); - bool[] paramsRead = new bool[3]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id80_transport && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Transport = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id75_style && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Style = Read82_SoapBindingStyle(Reader.Value); - paramsRead[2] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :transport, :style"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations30 = 0; - int readerCount30 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations30, ref readerCount30); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.SoapBinding Read80_SoapBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id81_SoapBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id19_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.SoapBinding o; - o = new global::System.Web.Services.Description.SoapBinding(); - bool[] paramsRead = new bool[3]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id80_transport && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Transport = Reader.Value; - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id75_style && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Style = Read79_SoapBindingStyle(Reader.Value); - paramsRead[2] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :transport, :style"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations31 = 0; - int readerCount31 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations31, ref readerCount31); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.HttpBinding Read77_HttpBinding(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id82_HttpBinding && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id18_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.HttpBinding o; - o = new global::System.Web.Services.Description.HttpBinding(); - bool[] paramsRead = new bool[2]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id22_required && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@Required = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[0] = true; - } - else if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id83_verb && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Verb = Reader.Value; - paramsRead[1] = true; - } - else if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:required, :verb"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations32 = 0; - int readerCount32 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - UnknownNode((object)o, @""); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations32, ref readerCount32); - } - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.PortType Read75_PortType(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id84_PortType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.PortType o; - o = new global::System.Web.Services.Description.PortType(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.OperationCollection a_5 = (global::System.Web.Services.Description.OperationCollection)o.@Operations; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations33 = 0; - int readerCount33 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id28_operation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read74_Operation(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/:operation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations33, ref readerCount33); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Operation Read74_Operation(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id85_Operation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Operation o; - o = new global::System.Web.Services.Description.Operation(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.OperationMessageCollection a_6 = (global::System.Web.Services.Description.OperationMessageCollection)o.@Messages; - global::System.Web.Services.Description.OperationFaultCollection a_7 = (global::System.Web.Services.Description.OperationFaultCollection)o.@Faults; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id86_parameterOrder && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@ParameterOrderString = Reader.Value; - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations34 = 0; - int readerCount34 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id30_input && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read71_OperationInput(false, true)); - } - else if (((object)Reader.LocalName == (object)_id31_output && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read72_OperationOutput(false, true)); - } - else if (((object)Reader.LocalName == (object)_id32_fault && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read73_OperationFault(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/:input, http://schemas.xmlsoap.org/wsdl/:output, http://schemas.xmlsoap.org/wsdl/:fault"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations34, ref readerCount34); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.OperationFault Read73_OperationFault(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id87_OperationFault && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.OperationFault o; - o = new global::System.Web.Services.Description.OperationFault(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations35 = 0; - int readerCount35 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else - { - a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations35, ref readerCount35); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.OperationOutput Read72_OperationOutput(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id88_OperationOutput && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.OperationOutput o; - o = new global::System.Web.Services.Description.OperationOutput(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations36 = 0; - int readerCount36 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else - { - a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations36, ref readerCount36); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.OperationInput Read71_OperationInput(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id89_OperationInput && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.OperationInput o; - o = new global::System.Web.Services.Description.OperationInput(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_5 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id10_message && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Message = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations37 = 0; - int readerCount37 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else - { - a_5.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations37, ref readerCount37); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Message Read69_Message(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id90_Message && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Message o; - o = new global::System.Web.Services.Description.Message(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - global::System.Web.Services.Description.MessagePartCollection a_5 = (global::System.Web.Services.Description.MessagePartCollection)o.@Parts; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations38 = 0; - int readerCount38 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id49_part && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read68_MessagePart(false, true)); - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://schemas.xmlsoap.org/wsdl/:part"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations38, ref readerCount38); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.MessagePart Read68_MessagePart(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id91_MessagePart && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.MessagePart o; - o = new global::System.Web.Services.Description.MessagePart(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_4 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[3] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id92_element && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Element = ToXmlQualifiedName(Reader.Value); - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Type = ToXmlQualifiedName(Reader.Value); - paramsRead[6] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations39 = 0; - int readerCount39 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else - { - a_4.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations39, ref readerCount39); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Types Read67_Types(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id93_Types && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Types o; - o = new global::System.Web.Services.Description.Types(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_3 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.XmlSchemas a_4 = o.@Schemas; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations40 = 0; - int readerCount40 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id94_schema && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read66_XmlSchema(false, true)); - } - else - { - a_3.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation, http://www.w3.org/2001/XMLSchema:schema"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations40, ref readerCount40); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchema Read66_XmlSchema(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id96_XmlSchema && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchema o; - o = new System.Xml.Schema.XmlSchema(); - System.Xml.Schema.XmlSchemaObjectCollection a_7 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Includes; - System.Xml.Schema.XmlSchemaObjectCollection a_8 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - System.Xml.XmlAttribute[] a_10 = null; - int ca_10 = 0; - bool[] paramsRead = new bool[11]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id97_attributeFormDefault && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@AttributeFormDefault = Read6_XmlSchemaForm(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id98_blockDefault && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BlockDefault = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id99_finalDefault && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@FinalDefault = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[3] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id100_elementFormDefault && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@ElementFormDefault = Read6_XmlSchemaForm(Reader.Value); - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id6_targetNamespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@TargetNamespace = CollapseWhitespace(Reader.Value); - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id101_version && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Version = CollapseWhitespace(Reader.Value); - paramsRead[6] = true; - } - else if (!paramsRead[9] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[9] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_10 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_10, ca_10, typeof(System.Xml.XmlAttribute)); a_10[ca_10++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations41 = 0; - int readerCount41 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id103_include && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read12_XmlSchemaInclude(false, true)); - } - else if (((object)Reader.LocalName == (object)_id8_import && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read13_XmlSchemaImport(false, true)); - } - else if (((object)Reader.LocalName == (object)_id104_redefine && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read64_XmlSchemaRedefine(false, true)); - } - else if (((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read34_XmlSchemaSimpleType(false, true)); - } - else if (((object)Reader.LocalName == (object)_id106_complexType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read62_XmlSchemaComplexType(false, true)); - } - else if (((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read11_XmlSchemaAnnotation(false, true)); - } - else if (((object)Reader.LocalName == (object)_id108_notation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read65_XmlSchemaNotation(false, true)); - } - else if (((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read63_XmlSchemaGroup(false, true)); - } - else if (((object)Reader.LocalName == (object)_id92_element && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read52_XmlSchemaElement(false, true)); - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_8) == null) Reader.Skip(); else a_8.Add(Read40_XmlSchemaAttributeGroup(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:include, http://www.w3.org/2001/XMLSchema:import, http://www.w3.org/2001/XMLSchema:redefine, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:notation, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:include, http://www.w3.org/2001/XMLSchema:import, http://www.w3.org/2001/XMLSchema:redefine, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:notation, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations41, ref readerCount41); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_10, ca_10, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAttributeGroup Read40_XmlSchemaAttributeGroup(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id111_XmlSchemaAttributeGroup && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAttributeGroup o; - o = new System.Xml.Schema.XmlSchemaAttributeGroup(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_5 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations42 = 0; - int readerCount42 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[6] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations42, ref readerCount42); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAnyAttribute Read39_XmlSchemaAnyAttribute(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id113_XmlSchemaAnyAttribute && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAnyAttribute o; - o = new System.Xml.Schema.XmlSchemaAnyAttribute(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id114_processContents && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@ProcessContents = Read38_XmlSchemaContentProcessing(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations43 = 0; - int readerCount43 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations43, ref readerCount43); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAnnotation Read11_XmlSchemaAnnotation(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id115_XmlSchemaAnnotation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAnnotation o; - o = new System.Xml.Schema.XmlSchemaAnnotation(); - System.Xml.Schema.XmlSchemaObjectCollection a_2 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[4]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations44 = 0; - int readerCount44 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_2) == null) Reader.Skip(); else a_2.Add(Read9_XmlSchemaDocumentation(false, true)); - } - else if (((object)Reader.LocalName == (object)_id116_appinfo && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_2) == null) Reader.Skip(); else a_2.Add(Read10_XmlSchemaAppInfo(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:documentation, http://www.w3.org/2001/XMLSchema:appinfo"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:documentation, http://www.w3.org/2001/XMLSchema:appinfo"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations44, ref readerCount44); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAppInfo Read10_XmlSchemaAppInfo(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id117_XmlSchemaAppInfo && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAppInfo o; - o = new System.Xml.Schema.XmlSchemaAppInfo(); - System.Xml.XmlNode[] a_2 = null; - int ca_2 = 0; - bool[] paramsRead = new bool[3]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id118_source && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Source = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - UnknownNode((object)o, @":source"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(System.Xml.XmlNode), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations45 = 0; - int readerCount45 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - a_2 = (System.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(System.Xml.XmlNode)); a_2[ca_2++] = (System.Xml.XmlNode)ReadXmlNode(false); - } - else if (Reader.NodeType == System.Xml.XmlNodeType.Text || - Reader.NodeType == System.Xml.XmlNodeType.CDATA || - Reader.NodeType == System.Xml.XmlNodeType.Whitespace || - Reader.NodeType == System.Xml.XmlNodeType.SignificantWhitespace) - { - a_2 = (System.Xml.XmlNode[])EnsureArrayIndex(a_2, ca_2, typeof(System.Xml.XmlNode)); a_2[ca_2++] = (System.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations45, ref readerCount45); - } - o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_2, ca_2, typeof(System.Xml.XmlNode), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaDocumentation Read9_XmlSchemaDocumentation(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id119_XmlSchemaDocumentation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaDocumentation o; - o = new System.Xml.Schema.XmlSchemaDocumentation(); - System.Xml.XmlNode[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[4]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id118_source && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Source = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id120_lang && (object)Reader.NamespaceURI == (object)_id121_Item)) - { - o.@Language = Reader.Value; - paramsRead[2] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - UnknownNode((object)o, @":source, http://www.w3.org/XML/1998/namespace"); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlNode), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations46 = 0; - int readerCount46 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - a_3 = (System.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlNode)); a_3[ca_3++] = (System.Xml.XmlNode)ReadXmlNode(false); - } - else if (Reader.NodeType == System.Xml.XmlNodeType.Text || - Reader.NodeType == System.Xml.XmlNodeType.CDATA || - Reader.NodeType == System.Xml.XmlNodeType.Whitespace || - Reader.NodeType == System.Xml.XmlNodeType.SignificantWhitespace) - { - a_3 = (System.Xml.XmlNode[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlNode)); a_3[ca_3++] = (System.Xml.XmlNode)Document.CreateTextNode(Reader.ReadString()); - } - else - { - UnknownNode((object)o, @""); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations46, ref readerCount46); - } - o.@Markup = (System.Xml.XmlNode[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlNode), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaContentProcessing Read38_XmlSchemaContentProcessing(string s) - { - switch (s) - { - case @"skip": return System.Xml.Schema.XmlSchemaContentProcessing.@Skip; - case @"lax": return System.Xml.Schema.XmlSchemaContentProcessing.@Lax; - case @"strict": return System.Xml.Schema.XmlSchemaContentProcessing.@Strict; - default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaContentProcessing)); - } - } - - private System.Xml.Schema.XmlSchemaAttributeGroupRef Read37_XmlSchemaAttributeGroupRef(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id122_XmlSchemaAttributeGroupRef && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAttributeGroupRef o; - o = new System.Xml.Schema.XmlSchemaAttributeGroupRef(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id123_ref && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@RefName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations47 = 0; - int readerCount47 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations47, ref readerCount47); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAttribute Read36_XmlSchemaAttribute(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id124_XmlSchemaAttribute && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAttribute o; - o = new System.Xml.Schema.XmlSchemaAttribute(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[12]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id125_default && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@DefaultValue = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@FixedValue = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id127_form && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Form = Read6_XmlSchemaForm(Reader.Value); - paramsRead[6] = true; - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[7] = true; - } - else if (!paramsRead[8] && ((object)Reader.LocalName == (object)_id123_ref && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@RefName = ToXmlQualifiedName(Reader.Value); - paramsRead[8] = true; - } - else if (!paramsRead[9] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SchemaTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[9] = true; - } - else if (!paramsRead[11] && ((object)Reader.LocalName == (object)_id35_use && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Use = Read35_XmlSchemaUse(Reader.Value); - paramsRead[11] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations48 = 0; - int readerCount48 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@SchemaType = Read34_XmlSchemaSimpleType(false, true); - paramsRead[10] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations48, ref readerCount48); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleType Read34_XmlSchemaSimpleType(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id128_XmlSchemaSimpleType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleType o; - o = new System.Xml.Schema.XmlSchemaSimpleType(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id129_final && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Final = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations49 = 0; - int readerCount49 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id130_list && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read17_XmlSchemaSimpleTypeList(false, true); - paramsRead[6] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id131_restriction && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read32_XmlSchemaSimpleTypeRestriction(false, true); - paramsRead[6] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id132_union && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read33_XmlSchemaSimpleTypeUnion(false, true); - paramsRead[6] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:list, http://www.w3.org/2001/XMLSchema:restriction, http://www.w3.org/2001/XMLSchema:union"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:list, http://www.w3.org/2001/XMLSchema:restriction, http://www.w3.org/2001/XMLSchema:union"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations49, ref readerCount49); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleTypeUnion Read33_XmlSchemaSimpleTypeUnion(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id133_XmlSchemaSimpleTypeUnion && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleTypeUnion o; - o = new System.Xml.Schema.XmlSchemaSimpleTypeUnion(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_4 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@BaseTypes; - System.Xml.XmlQualifiedName[] a_5 = null; - int ca_5 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (((object)Reader.LocalName == (object)_id134_memberTypes && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - string listValues = Reader.Value; - string[] vals = listValues.Split(null); - for (int i = 0; i < vals.Length; i++) - { - a_5 = (System.Xml.XmlQualifiedName[])EnsureArrayIndex(a_5, ca_5, typeof(System.Xml.XmlQualifiedName)); a_5[ca_5++] = ToXmlQualifiedName(vals[i]); - } - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations50 = 0; - int readerCount50 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read34_XmlSchemaSimpleType(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations50, ref readerCount50); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - o.@MemberTypes = (System.Xml.XmlQualifiedName[])ShrinkArray(a_5, ca_5, typeof(System.Xml.XmlQualifiedName), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleTypeRestriction Read32_XmlSchemaSimpleTypeRestriction(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id135_XmlSchemaSimpleTypeRestriction && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleTypeRestriction o; - o = new System.Xml.Schema.XmlSchemaSimpleTypeRestriction(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id136_base && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BaseTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations51 = 0; - int readerCount51 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@BaseType = Read34_XmlSchemaSimpleType(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id137_fractionDigits && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read20_XmlSchemaFractionDigitsFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id138_minInclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read21_XmlSchemaMinInclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id139_maxLength && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read22_XmlSchemaMaxLengthFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id140_length && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read23_XmlSchemaLengthFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id141_totalDigits && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read24_XmlSchemaTotalDigitsFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id62_pattern && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read25_XmlSchemaPatternFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id142_enumeration && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read26_XmlSchemaEnumerationFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id143_maxInclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read27_XmlSchemaMaxInclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id144_maxExclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read28_XmlSchemaMaxExclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id145_whiteSpace && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read29_XmlSchemaWhiteSpaceFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id146_minExclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read30_XmlSchemaMinExclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id147_minLength && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read31_XmlSchemaMinLengthFacet(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:fractionDigits, http://www.w3.org/2001/XMLSchema:minInclusive, http://www.w3.org/2001/XMLSchema:maxLength, http://www.w3.org/2001/XMLSchema:length, http://www.w3.org/2001/XMLSchema:totalDigits, http://www.w3.org/2001/XMLSchema:pattern, http://www.w3.org/2001/XMLSchema:enumeration, http://www.w3.org/2001/XMLSchema:maxInclusive, http://www.w3.org/2001/XMLSchema:maxExclusive, http://www.w3.org/2001/XMLSchema:whiteSpace, http://www.w3.org/2001/XMLSchema:minExclusive, http://www.w3.org/2001/XMLSchema:minLength"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:fractionDigits, http://www.w3.org/2001/XMLSchema:minInclusive, http://www.w3.org/2001/XMLSchema:maxLength, http://www.w3.org/2001/XMLSchema:length, http://www.w3.org/2001/XMLSchema:totalDigits, http://www.w3.org/2001/XMLSchema:pattern, http://www.w3.org/2001/XMLSchema:enumeration, http://www.w3.org/2001/XMLSchema:maxInclusive, http://www.w3.org/2001/XMLSchema:maxExclusive, http://www.w3.org/2001/XMLSchema:whiteSpace, http://www.w3.org/2001/XMLSchema:minExclusive, http://www.w3.org/2001/XMLSchema:minLength"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations51, ref readerCount51); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMinLengthFacet Read31_XmlSchemaMinLengthFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id148_XmlSchemaMinLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMinLengthFacet o; - o = new System.Xml.Schema.XmlSchemaMinLengthFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations52 = 0; - int readerCount52 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations52, ref readerCount52); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMinExclusiveFacet Read30_XmlSchemaMinExclusiveFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id150_XmlSchemaMinExclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMinExclusiveFacet o; - o = new System.Xml.Schema.XmlSchemaMinExclusiveFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations53 = 0; - int readerCount53 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations53, ref readerCount53); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaWhiteSpaceFacet Read29_XmlSchemaWhiteSpaceFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id151_XmlSchemaWhiteSpaceFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaWhiteSpaceFacet o; - o = new System.Xml.Schema.XmlSchemaWhiteSpaceFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations54 = 0; - int readerCount54 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations54, ref readerCount54); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMaxExclusiveFacet Read28_XmlSchemaMaxExclusiveFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id152_XmlSchemaMaxExclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMaxExclusiveFacet o; - o = new System.Xml.Schema.XmlSchemaMaxExclusiveFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations55 = 0; - int readerCount55 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations55, ref readerCount55); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMaxInclusiveFacet Read27_XmlSchemaMaxInclusiveFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id153_XmlSchemaMaxInclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMaxInclusiveFacet o; - o = new System.Xml.Schema.XmlSchemaMaxInclusiveFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations56 = 0; - int readerCount56 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations56, ref readerCount56); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaEnumerationFacet Read26_XmlSchemaEnumerationFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id154_XmlSchemaEnumerationFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaEnumerationFacet o; - o = new System.Xml.Schema.XmlSchemaEnumerationFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations57 = 0; - int readerCount57 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations57, ref readerCount57); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaPatternFacet Read25_XmlSchemaPatternFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id155_XmlSchemaPatternFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaPatternFacet o; - o = new System.Xml.Schema.XmlSchemaPatternFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations58 = 0; - int readerCount58 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations58, ref readerCount58); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaTotalDigitsFacet Read24_XmlSchemaTotalDigitsFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id156_XmlSchemaTotalDigitsFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaTotalDigitsFacet o; - o = new System.Xml.Schema.XmlSchemaTotalDigitsFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations59 = 0; - int readerCount59 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations59, ref readerCount59); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaLengthFacet Read23_XmlSchemaLengthFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id157_XmlSchemaLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaLengthFacet o; - o = new System.Xml.Schema.XmlSchemaLengthFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations60 = 0; - int readerCount60 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations60, ref readerCount60); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMaxLengthFacet Read22_XmlSchemaMaxLengthFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id158_XmlSchemaMaxLengthFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMaxLengthFacet o; - o = new System.Xml.Schema.XmlSchemaMaxLengthFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations61 = 0; - int readerCount61 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations61, ref readerCount61); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaMinInclusiveFacet Read21_XmlSchemaMinInclusiveFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id159_XmlSchemaMinInclusiveFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaMinInclusiveFacet o; - o = new System.Xml.Schema.XmlSchemaMinInclusiveFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations62 = 0; - int readerCount62 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations62, ref readerCount62); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaFractionDigitsFacet Read20_XmlSchemaFractionDigitsFacet(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id160_XmlSchemaFractionDigitsFacet && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaFractionDigitsFacet o; - o = new System.Xml.Schema.XmlSchemaFractionDigitsFacet(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id149_value && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Value = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsFixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations63 = 0; - int readerCount63 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations63, ref readerCount63); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleTypeList Read17_XmlSchemaSimpleTypeList(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id161_XmlSchemaSimpleTypeList && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleTypeList o; - o = new System.Xml.Schema.XmlSchemaSimpleTypeList(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id162_itemType && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@ItemTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations64 = 0; - int readerCount64 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@ItemType = Read34_XmlSchemaSimpleType(false, true); - paramsRead[5] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations64, ref readerCount64); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Collections.Hashtable _XmlSchemaDerivationMethodValues; - - internal System.Collections.Hashtable XmlSchemaDerivationMethodValues - { - get - { - if ((object)_XmlSchemaDerivationMethodValues == null) - { - System.Collections.Hashtable h = new System.Collections.Hashtable(); - h.Add(@"", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Empty); - h.Add(@"substitution", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Substitution); - h.Add(@"extension", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Extension); - h.Add(@"restriction", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Restriction); - h.Add(@"list", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@List); - h.Add(@"union", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@Union); - h.Add(@"#all", (long)System.Xml.Schema.XmlSchemaDerivationMethod.@All); - _XmlSchemaDerivationMethodValues = h; - } - return _XmlSchemaDerivationMethodValues; - } - } - - private System.Xml.Schema.XmlSchemaDerivationMethod Read7_XmlSchemaDerivationMethod(string s) - { - return (System.Xml.Schema.XmlSchemaDerivationMethod)ToEnum(s, XmlSchemaDerivationMethodValues, @"System.Xml.Schema.XmlSchemaDerivationMethod"); - } - - private System.Xml.Schema.XmlSchemaUse Read35_XmlSchemaUse(string s) - { - switch (s) - { - case @"optional": return System.Xml.Schema.XmlSchemaUse.@Optional; - case @"prohibited": return System.Xml.Schema.XmlSchemaUse.@Prohibited; - case @"required": return System.Xml.Schema.XmlSchemaUse.@Required; - default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaUse)); - } - } - - private System.Xml.Schema.XmlSchemaForm Read6_XmlSchemaForm(string s) - { - switch (s) - { - case @"qualified": return System.Xml.Schema.XmlSchemaForm.@Qualified; - case @"unqualified": return System.Xml.Schema.XmlSchemaForm.@Unqualified; - default: throw CreateUnknownConstantException(s, typeof(System.Xml.Schema.XmlSchemaForm)); - } - } - - private System.Xml.Schema.XmlSchemaElement Read52_XmlSchemaElement(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id163_XmlSchemaElement && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaElement o; - o = new System.Xml.Schema.XmlSchemaElement(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_18 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Constraints; - bool[] paramsRead = new bool[19]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id166_abstract && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsAbstract = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[6] = true; - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id167_block && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Block = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[7] = true; - } - else if (!paramsRead[8] && ((object)Reader.LocalName == (object)_id125_default && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@DefaultValue = Reader.Value; - paramsRead[8] = true; - } - else if (!paramsRead[9] && ((object)Reader.LocalName == (object)_id129_final && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Final = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[9] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id126_fixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@FixedValue = Reader.Value; - paramsRead[10] = true; - } - else if (!paramsRead[11] && ((object)Reader.LocalName == (object)_id127_form && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Form = Read6_XmlSchemaForm(Reader.Value); - paramsRead[11] = true; - } - else if (!paramsRead[12] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[12] = true; - } - else if (!paramsRead[13] && ((object)Reader.LocalName == (object)_id168_nillable && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsNillable = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[13] = true; - } - else if (!paramsRead[14] && ((object)Reader.LocalName == (object)_id123_ref && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@RefName = ToXmlQualifiedName(Reader.Value); - paramsRead[14] = true; - } - else if (!paramsRead[15] && ((object)Reader.LocalName == (object)_id169_substitutionGroup && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SubstitutionGroup = ToXmlQualifiedName(Reader.Value); - paramsRead[15] = true; - } - else if (!paramsRead[16] && ((object)Reader.LocalName == (object)_id27_type && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SchemaTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[16] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations65 = 0; - int readerCount65 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[17] && ((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@SchemaType = Read34_XmlSchemaSimpleType(false, true); - paramsRead[17] = true; - } - else if (!paramsRead[17] && ((object)Reader.LocalName == (object)_id106_complexType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@SchemaType = Read62_XmlSchemaComplexType(false, true); - paramsRead[17] = true; - } - else if (((object)Reader.LocalName == (object)_id170_key && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_18) == null) Reader.Skip(); else a_18.Add(Read49_XmlSchemaKey(false, true)); - } - else if (((object)Reader.LocalName == (object)_id171_unique && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_18) == null) Reader.Skip(); else a_18.Add(Read50_XmlSchemaUnique(false, true)); - } - else if (((object)Reader.LocalName == (object)_id172_keyref && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_18) == null) Reader.Skip(); else a_18.Add(Read51_XmlSchemaKeyref(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:key, http://www.w3.org/2001/XMLSchema:unique, http://www.w3.org/2001/XMLSchema:keyref"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:key, http://www.w3.org/2001/XMLSchema:unique, http://www.w3.org/2001/XMLSchema:keyref"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations65, ref readerCount65); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaKeyref Read51_XmlSchemaKeyref(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id173_XmlSchemaKeyref && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaKeyref o; - o = new System.Xml.Schema.XmlSchemaKeyref(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id174_refer && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Refer = ToXmlQualifiedName(Reader.Value); - paramsRead[7] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations66 = 0; - int readerCount66 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id175_selector && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Selector = Read47_XmlSchemaXPath(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id176_field && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read47_XmlSchemaXPath(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations66, ref readerCount66); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaXPath Read47_XmlSchemaXPath(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id177_XmlSchemaXPath && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaXPath o; - o = new System.Xml.Schema.XmlSchemaXPath(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id178_xpath && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@XPath = Reader.Value; - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations67 = 0; - int readerCount67 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations67, ref readerCount67); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaUnique Read50_XmlSchemaUnique(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id179_XmlSchemaUnique && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaUnique o; - o = new System.Xml.Schema.XmlSchemaUnique(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations68 = 0; - int readerCount68 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id175_selector && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Selector = Read47_XmlSchemaXPath(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id176_field && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read47_XmlSchemaXPath(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations68, ref readerCount68); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaKey Read49_XmlSchemaKey(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id180_XmlSchemaKey && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaKey o; - o = new System.Xml.Schema.XmlSchemaKey(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Fields; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations69 = 0; - int readerCount69 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id175_selector && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Selector = Read47_XmlSchemaXPath(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id176_field && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read47_XmlSchemaXPath(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:selector, http://www.w3.org/2001/XMLSchema:field"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations69, ref readerCount69); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaComplexType Read62_XmlSchemaComplexType(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id181_XmlSchemaComplexType && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaComplexType o; - o = new System.Xml.Schema.XmlSchemaComplexType(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_11 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[13]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id129_final && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Final = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id166_abstract && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsAbstract = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[6] = true; - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id167_block && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Block = Read7_XmlSchemaDerivationMethod(Reader.Value); - paramsRead[7] = true; - } - else if (!paramsRead[8] && ((object)Reader.LocalName == (object)_id182_mixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsMixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[8] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations70 = 0; - int readerCount70 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[9] && ((object)Reader.LocalName == (object)_id183_complexContent && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@ContentModel = Read58_XmlSchemaComplexContent(false, true); - paramsRead[9] = true; - } - else if (!paramsRead[9] && ((object)Reader.LocalName == (object)_id184_simpleContent && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@ContentModel = Read61_XmlSchemaSimpleContent(false, true); - paramsRead[9] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read44_XmlSchemaGroupRef(false, true); - paramsRead[10] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read53_XmlSchemaSequence(false, true); - paramsRead[10] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read54_XmlSchemaChoice(false, true); - paramsRead[10] = true; - } - else if (!paramsRead[10] && ((object)Reader.LocalName == (object)_id187_all && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read55_XmlSchemaAll(false, true); - paramsRead[10] = true; - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_11) == null) Reader.Skip(); else a_11.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_11) == null) Reader.Skip(); else a_11.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (!paramsRead[12] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[12] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:complexContent, http://www.w3.org/2001/XMLSchema:simpleContent, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:complexContent, http://www.w3.org/2001/XMLSchema:simpleContent, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations70, ref readerCount70); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAll Read55_XmlSchemaAll(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id188_XmlSchemaAll && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAll o; - o = new System.Xml.Schema.XmlSchemaAll(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations71 = 0; - int readerCount71 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id92_element && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read52_XmlSchemaElement(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:element"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:element"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations71, ref readerCount71); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaChoice Read54_XmlSchemaChoice(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id189_XmlSchemaChoice && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaChoice o; - o = new System.Xml.Schema.XmlSchemaChoice(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations72 = 0; - int readerCount72 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id190_any && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read46_XmlSchemaAny(false, true)); - } - else if (((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read54_XmlSchemaChoice(false, true)); - } - else if (((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read53_XmlSchemaSequence(false, true)); - } - else if (((object)Reader.LocalName == (object)_id92_element && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read52_XmlSchemaElement(false, true)); - } - else if (((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read44_XmlSchemaGroupRef(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:any, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:group"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:any, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:group"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations72, ref readerCount72); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaGroupRef Read44_XmlSchemaGroupRef(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id191_XmlSchemaGroupRef && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaGroupRef o; - o = new System.Xml.Schema.XmlSchemaGroupRef(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id123_ref && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@RefName = ToXmlQualifiedName(Reader.Value); - paramsRead[6] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations73 = 0; - int readerCount73 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations73, ref readerCount73); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSequence Read53_XmlSchemaSequence(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id192_XmlSchemaSequence && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSequence o; - o = new System.Xml.Schema.XmlSchemaSequence(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations74 = 0; - int readerCount74 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id92_element && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read52_XmlSchemaElement(false, true)); - } - else if (((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read53_XmlSchemaSequence(false, true)); - } - else if (((object)Reader.LocalName == (object)_id190_any && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read46_XmlSchemaAny(false, true)); - } - else if (((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read54_XmlSchemaChoice(false, true)); - } - else if (((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read44_XmlSchemaGroupRef(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:any, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:group"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:element, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:any, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:group"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations74, ref readerCount74); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaAny Read46_XmlSchemaAny(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id193_XmlSchemaAny && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaAny o; - o = new System.Xml.Schema.XmlSchemaAny(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id164_minOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MinOccursString = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id165_maxOccurs && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@MaxOccursString = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[6] = true; - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id114_processContents && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@ProcessContents = Read38_XmlSchemaContentProcessing(Reader.Value); - paramsRead[7] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations75 = 0; - int readerCount75 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations75, ref readerCount75); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleContent Read61_XmlSchemaSimpleContent(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id194_XmlSchemaSimpleContent && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleContent o; - o = new System.Xml.Schema.XmlSchemaSimpleContent(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations76 = 0; - int readerCount76 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id131_restriction && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read59_Item(false, true); - paramsRead[4] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id195_extension && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read60_Item(false, true); - paramsRead[4] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:restriction, http://www.w3.org/2001/XMLSchema:extension"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:restriction, http://www.w3.org/2001/XMLSchema:extension"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations76, ref readerCount76); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleContentExtension Read60_Item(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id196_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleContentExtension o; - o = new System.Xml.Schema.XmlSchemaSimpleContentExtension(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_5 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id136_base && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BaseTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations77 = 0; - int readerCount77 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_5) == null) Reader.Skip(); else a_5.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[6] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations77, ref readerCount77); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaSimpleContentRestriction Read59_Item(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id197_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaSimpleContentRestriction o; - o = new System.Xml.Schema.XmlSchemaSimpleContentRestriction(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Facets; - System.Xml.Schema.XmlSchemaObjectCollection a_7 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[9]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id136_base && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BaseTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations78 = 0; - int readerCount78 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@BaseType = Read34_XmlSchemaSimpleType(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id138_minInclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read21_XmlSchemaMinInclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id144_maxExclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read28_XmlSchemaMaxExclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id145_whiteSpace && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read29_XmlSchemaWhiteSpaceFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id147_minLength && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read31_XmlSchemaMinLengthFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id62_pattern && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read25_XmlSchemaPatternFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id142_enumeration && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read26_XmlSchemaEnumerationFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id143_maxInclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read27_XmlSchemaMaxInclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id140_length && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read23_XmlSchemaLengthFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id139_maxLength && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read22_XmlSchemaMaxLengthFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id146_minExclusive && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read30_XmlSchemaMinExclusiveFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id141_totalDigits && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read24_XmlSchemaTotalDigitsFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id137_fractionDigits && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read20_XmlSchemaFractionDigitsFacet(false, true)); - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_7) == null) Reader.Skip(); else a_7.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (!paramsRead[8] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[8] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:minInclusive, http://www.w3.org/2001/XMLSchema:maxExclusive, http://www.w3.org/2001/XMLSchema:whiteSpace, http://www.w3.org/2001/XMLSchema:minLength, http://www.w3.org/2001/XMLSchema:pattern, http://www.w3.org/2001/XMLSchema:enumeration, http://www.w3.org/2001/XMLSchema:maxInclusive, http://www.w3.org/2001/XMLSchema:length, http://www.w3.org/2001/XMLSchema:maxLength, http://www.w3.org/2001/XMLSchema:minExclusive, http://www.w3.org/2001/XMLSchema:totalDigits, http://www.w3.org/2001/XMLSchema:fractionDigits, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:minInclusive, http://www.w3.org/2001/XMLSchema:maxExclusive, http://www.w3.org/2001/XMLSchema:whiteSpace, http://www.w3.org/2001/XMLSchema:minLength, http://www.w3.org/2001/XMLSchema:pattern, http://www.w3.org/2001/XMLSchema:enumeration, http://www.w3.org/2001/XMLSchema:maxInclusive, http://www.w3.org/2001/XMLSchema:length, http://www.w3.org/2001/XMLSchema:maxLength, http://www.w3.org/2001/XMLSchema:minExclusive, http://www.w3.org/2001/XMLSchema:totalDigits, http://www.w3.org/2001/XMLSchema:fractionDigits, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations78, ref readerCount78); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaComplexContent Read58_XmlSchemaComplexContent(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id198_XmlSchemaComplexContent && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaComplexContent o; - o = new System.Xml.Schema.XmlSchemaComplexContent(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id182_mixed && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@IsMixed = System.Xml.XmlConvert.ToBoolean(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations79 = 0; - int readerCount79 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id195_extension && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read56_Item(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id131_restriction && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Content = Read57_Item(false, true); - paramsRead[5] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:extension, http://www.w3.org/2001/XMLSchema:restriction"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:extension, http://www.w3.org/2001/XMLSchema:restriction"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations79, ref readerCount79); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaComplexContentRestriction Read57_Item(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id199_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaComplexContentRestriction o; - o = new System.Xml.Schema.XmlSchemaComplexContentRestriction(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id136_base && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BaseTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations80 = 0; - int readerCount80 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read54_XmlSchemaChoice(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read44_XmlSchemaGroupRef(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id187_all && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read55_XmlSchemaAll(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read53_XmlSchemaSequence(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[7] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations80, ref readerCount80); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaComplexContentExtension Read56_Item(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id200_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaComplexContentExtension o; - o = new System.Xml.Schema.XmlSchemaComplexContentExtension(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_6 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Attributes; - bool[] paramsRead = new bool[8]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id136_base && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@BaseTypeName = ToXmlQualifiedName(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations81 = 0; - int readerCount81 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read44_XmlSchemaGroupRef(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read54_XmlSchemaChoice(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id187_all && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read55_XmlSchemaAll(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read53_XmlSchemaSequence(false, true); - paramsRead[5] = true; - } - else if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read37_XmlSchemaAttributeGroupRef(false, true)); - } - else if (((object)Reader.LocalName == (object)_id109_attribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_6) == null) Reader.Skip(); else a_6.Add(Read36_XmlSchemaAttribute(false, true)); - } - else if (!paramsRead[7] && ((object)Reader.LocalName == (object)_id112_anyAttribute && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@AnyAttribute = Read39_XmlSchemaAnyAttribute(false, true); - paramsRead[7] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations81, ref readerCount81); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaGroup Read63_XmlSchemaGroup(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id201_XmlSchemaGroup && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaGroup o; - o = new System.Xml.Schema.XmlSchemaGroup(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations82 = 0; - int readerCount82 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id185_sequence && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read53_XmlSchemaSequence(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id186_choice && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read54_XmlSchemaChoice(false, true); - paramsRead[5] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id187_all && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Particle = Read55_XmlSchemaAll(false, true); - paramsRead[5] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:all"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations82, ref readerCount82); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaNotation Read65_XmlSchemaNotation(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id202_XmlSchemaNotation && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaNotation o; - o = new System.Xml.Schema.XmlSchemaNotation(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[7]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id4_name && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Name = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id203_public && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Public = Reader.Value; - paramsRead[5] = true; - } - else if (!paramsRead[6] && ((object)Reader.LocalName == (object)_id204_system && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@System = Reader.Value; - paramsRead[6] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations83 = 0; - int readerCount83 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[2] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations83, ref readerCount83); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaRedefine Read64_XmlSchemaRedefine(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id205_XmlSchemaRedefine && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaRedefine o; - o = new System.Xml.Schema.XmlSchemaRedefine(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - System.Xml.Schema.XmlSchemaObjectCollection a_4 = (System.Xml.Schema.XmlSchemaObjectCollection)o.@Items; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id206_schemaLocation && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SchemaLocation = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[2] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations84 = 0; - int readerCount84 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id110_attributeGroup && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read40_XmlSchemaAttributeGroup(false, true)); - } - else if (((object)Reader.LocalName == (object)_id106_complexType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read62_XmlSchemaComplexType(false, true)); - } - else if (((object)Reader.LocalName == (object)_id105_simpleType && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read34_XmlSchemaSimpleType(false, true)); - } - else if (((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read11_XmlSchemaAnnotation(false, true)); - } - else if (((object)Reader.LocalName == (object)_id59_group && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - if ((object)(a_4) == null) Reader.Skip(); else a_4.Add(Read63_XmlSchemaGroup(false, true)); - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:group"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:complexType, http://www.w3.org/2001/XMLSchema:simpleType, http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:group"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations84, ref readerCount84); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaImport Read13_XmlSchemaImport(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id207_XmlSchemaImport && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaImport o; - o = new System.Xml.Schema.XmlSchemaImport(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id206_schemaLocation && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SchemaLocation = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[2] = true; - } - else if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = CollapseWhitespace(Reader.Value); - paramsRead[4] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations85 = 0; - int readerCount85 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[5] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations85, ref readerCount85); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private System.Xml.Schema.XmlSchemaInclude Read12_XmlSchemaInclude(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id208_XmlSchemaInclude && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id95_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - DecodeName = false; - System.Xml.Schema.XmlSchemaInclude o; - o = new System.Xml.Schema.XmlSchemaInclude(); - System.Xml.XmlAttribute[] a_3 = null; - int ca_3 = 0; - bool[] paramsRead = new bool[5]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[1] && ((object)Reader.LocalName == (object)_id206_schemaLocation && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@SchemaLocation = CollapseWhitespace(Reader.Value); - paramsRead[1] = true; - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id102_id && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Id = CollapseWhitespace(Reader.Value); - paramsRead[2] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_3 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_3, ca_3, typeof(System.Xml.XmlAttribute)); a_3[ca_3++] = attr; - } - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations86 = 0; - int readerCount86 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id107_annotation && (object)Reader.NamespaceURI == (object)_id95_Item)) - { - o.@Annotation = Read11_XmlSchemaAnnotation(false, true); - paramsRead[4] = true; - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - } - else - { - UnknownNode((object)o, @"http://www.w3.org/2001/XMLSchema:annotation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations86, ref readerCount86); - } - o.@UnhandledAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_3, ca_3, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - private global::System.Web.Services.Description.Import Read4_Import(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id209_Import && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - global::System.Web.Services.Description.Import o; - o = new global::System.Web.Services.Description.Import(); - System.Xml.XmlAttribute[] a_1 = null; - int ca_1 = 0; - global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection a_3 = (global::System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection)o.@Extensions; - bool[] paramsRead = new bool[6]; - while (Reader.MoveToNextAttribute()) - { - if (!paramsRead[4] && ((object)Reader.LocalName == (object)_id36_namespace && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Namespace = Reader.Value; - paramsRead[4] = true; - } - else if (!paramsRead[5] && ((object)Reader.LocalName == (object)_id23_location && (object)Reader.NamespaceURI == (object)_id5_Item)) - { - o.@Location = Reader.Value; - paramsRead[5] = true; - } - else if (IsXmlnsAttribute(Reader.Name)) - { - if (o.@Namespaces == null) o.@Namespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); - ((System.Xml.Serialization.XmlSerializerNamespaces)o.@Namespaces).Add(Reader.Name.Length == 5 ? "" : Reader.LocalName, Reader.Value); - } - else - { - System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)Document.ReadNode(Reader); - ParseWsdlArrayType(attr); - a_1 = (System.Xml.XmlAttribute[])EnsureArrayIndex(a_1, ca_1, typeof(System.Xml.XmlAttribute)); a_1[ca_1++] = attr; - } - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations87 = 0; - int readerCount87 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id7_documentation && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o.@DocumentationElement = (System.Xml.XmlElement)ReadXmlNode(false); - paramsRead[0] = true; - } - else - { - a_3.Add((System.Xml.XmlElement)ReadXmlNode(false)); - } - } - else - { - UnknownNode((object)o, @"http://schemas.xmlsoap.org/wsdl/:documentation"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations87, ref readerCount87); - } - o.@ExtensibleAttributes = (System.Xml.XmlAttribute[])ShrinkArray(a_1, ca_1, typeof(System.Xml.XmlAttribute), true); - ReadEndElement(); - return o; - } - - protected override void InitCallbacks() - { - } - - private string _id133_XmlSchemaSimpleTypeUnion; - private string _id143_maxInclusive; - private string _id46_body; - private string _id190_any; - private string _id88_OperationOutput; - private string _id6_targetNamespace; - private string _id158_XmlSchemaMaxLengthFacet; - private string _id11_portType; - private string _id182_mixed; - private string _id172_keyref; - private string _id187_all; - private string _id162_itemType; - private string _id68_InputBinding; - private string _id25_HttpAddressBinding; - private string _id82_HttpBinding; - private string _id17_address; - private string _id3_ServiceDescription; - private string _id38_SoapFaultBinding; - private string _id123_ref; - private string _id198_XmlSchemaComplexContent; - private string _id53_parts; - private string _id35_use; - private string _id157_XmlSchemaLengthFacet; - private string _id207_XmlSchemaImport; - private string _id44_text; - private string _id117_XmlSchemaAppInfo; - private string _id203_public; - private string _id69_urlEncoded; - private string _id7_documentation; - private string _id19_Item; - private string _id129_final; - private string _id163_XmlSchemaElement; - private string _id60_capture; - private string _id37_encodingStyle; - private string _id185_sequence; - private string _id166_abstract; - private string _id23_location; - private string _id111_XmlSchemaAttributeGroup; - private string _id192_XmlSchemaSequence; - private string _id33_FaultBinding; - private string _id153_XmlSchemaMaxInclusiveFacet; - private string _id201_XmlSchemaGroup; - private string _id43_multipartRelated; - private string _id168_nillable; - private string _id149_value; - private string _id64_MimeMultipartRelatedBinding; - private string _id193_XmlSchemaAny; - private string _id191_XmlSchemaGroupRef; - private string _id74_soapAction; - private string _id63_ignoreCase; - private string _id101_version; - private string _id47_header; - private string _id195_extension; - private string _id48_Soap12HeaderBinding; - private string _id134_memberTypes; - private string _id121_Item; - private string _id146_minExclusive; - private string _id84_PortType; - private string _id42_mimeXml; - private string _id138_minInclusive; - private string _id118_source; - private string _id73_Soap12OperationBinding; - private string _id131_restriction; - private string _id152_XmlSchemaMaxExclusiveFacet; - private string _id135_XmlSchemaSimpleTypeRestriction; - private string _id188_XmlSchemaAll; - private string _id116_appinfo; - private string _id86_parameterOrder; - private string _id147_minLength; - private string _id78_HttpOperationBinding; - private string _id161_XmlSchemaSimpleTypeList; - private string _id205_XmlSchemaRedefine; - private string _id194_XmlSchemaSimpleContent; - private string _id91_MessagePart; - private string _id92_element; - private string _id114_processContents; - private string _id18_Item; - private string _id50_headerfault; - private string _id154_XmlSchemaEnumerationFacet; - private string _id96_XmlSchema; - private string _id127_form; - private string _id176_field; - private string _id49_part; - private string _id5_Item; - private string _id57_match; - private string _id52_Soap12BodyBinding; - private string _id104_redefine; - private string _id20_Item; - private string _id21_Soap12AddressBinding; - private string _id142_enumeration; - private string _id24_SoapAddressBinding; - private string _id103_include; - private string _id139_maxLength; - private string _id165_maxOccurs; - private string _id65_MimePart; - private string _id102_id; - private string _id196_Item; - private string _id140_length; - private string _id27_type; - private string _id106_complexType; - private string _id31_output; - private string _id1_definitions; - private string _id4_name; - private string _id132_union; - private string _id29_OperationBinding; - private string _id170_key; - private string _id45_Item; - private string _id95_Item; - private string _id169_substitutionGroup; - private string _id178_xpath; - private string _id9_types; - private string _id97_attributeFormDefault; - private string _id62_pattern; - private string _id58_MimeTextMatch; - private string _id180_XmlSchemaKey; - private string _id10_message; - private string _id8_import; - private string _id148_XmlSchemaMinLengthFacet; - private string _id105_simpleType; - private string _id181_XmlSchemaComplexType; - private string _id164_minOccurs; - private string _id144_maxExclusive; - private string _id160_XmlSchemaFractionDigitsFacet; - private string _id124_XmlSchemaAttribute; - private string _id209_Import; - private string _id206_schemaLocation; - private string _id179_XmlSchemaUnique; - private string _id75_style; - private string _id119_XmlSchemaDocumentation; - private string _id136_base; - private string _id66_MimeXmlBinding; - private string _id30_input; - private string _id40_content; - private string _id93_Types; - private string _id94_schema; - private string _id200_Item; - private string _id67_MimeContentBinding; - private string _id59_group; - private string _id32_fault; - private string _id80_transport; - private string _id98_blockDefault; - private string _id13_service; - private string _id54_SoapHeaderBinding; - private string _id204_system; - private string _id16_Port; - private string _id108_notation; - private string _id186_choice; - private string _id110_attributeGroup; - private string _id79_Soap12Binding; - private string _id77_SoapOperationBinding; - private string _id115_XmlSchemaAnnotation; - private string _id83_verb; - private string _id72_HttpUrlEncodedBinding; - private string _id39_OutputBinding; - private string _id183_complexContent; - private string _id202_XmlSchemaNotation; - private string _id81_SoapBinding; - private string _id199_Item; - private string _id28_operation; - private string _id122_XmlSchemaAttributeGroupRef; - private string _id155_XmlSchemaPatternFacet; - private string _id76_soapActionRequired; - private string _id90_Message; - private string _id159_XmlSchemaMinInclusiveFacet; - private string _id208_XmlSchemaInclude; - private string _id85_Operation; - private string _id130_list; - private string _id14_Service; - private string _id22_required; - private string _id174_refer; - private string _id71_HttpUrlReplacementBinding; - private string _id56_MimeTextBinding; - private string _id87_OperationFault; - private string _id125_default; - private string _id15_port; - private string _id51_SoapHeaderFaultBinding; - private string _id128_XmlSchemaSimpleType; - private string _id36_namespace; - private string _id175_selector; - private string _id150_XmlSchemaMinExclusiveFacet; - private string _id100_elementFormDefault; - private string _id26_Binding; - private string _id197_Item; - private string _id126_fixed; - private string _id107_annotation; - private string _id99_finalDefault; - private string _id137_fractionDigits; - private string _id70_urlReplacement; - private string _id189_XmlSchemaChoice; - private string _id2_Item; - private string _id112_anyAttribute; - private string _id89_OperationInput; - private string _id141_totalDigits; - private string _id61_repeats; - private string _id184_simpleContent; - private string _id55_SoapBodyBinding; - private string _id145_whiteSpace; - private string _id167_block; - private string _id151_XmlSchemaWhiteSpaceFacet; - private string _id12_binding; - private string _id109_attribute; - private string _id171_unique; - private string _id120_lang; - private string _id173_XmlSchemaKeyref; - private string _id177_XmlSchemaXPath; - private string _id34_Soap12FaultBinding; - private string _id41_Item; - private string _id156_XmlSchemaTotalDigitsFacet; - private string _id113_XmlSchemaAnyAttribute; - - protected override void InitIDs() - { - _id133_XmlSchemaSimpleTypeUnion = Reader.NameTable.Add(@"XmlSchemaSimpleTypeUnion"); - _id143_maxInclusive = Reader.NameTable.Add(@"maxInclusive"); - _id46_body = Reader.NameTable.Add(@"body"); - _id190_any = Reader.NameTable.Add(@"any"); - _id88_OperationOutput = Reader.NameTable.Add(@"OperationOutput"); - _id6_targetNamespace = Reader.NameTable.Add(@"targetNamespace"); - _id158_XmlSchemaMaxLengthFacet = Reader.NameTable.Add(@"XmlSchemaMaxLengthFacet"); - _id11_portType = Reader.NameTable.Add(@"portType"); - _id182_mixed = Reader.NameTable.Add(@"mixed"); - _id172_keyref = Reader.NameTable.Add(@"keyref"); - _id187_all = Reader.NameTable.Add(@"all"); - _id162_itemType = Reader.NameTable.Add(@"itemType"); - _id68_InputBinding = Reader.NameTable.Add(@"InputBinding"); - _id25_HttpAddressBinding = Reader.NameTable.Add(@"HttpAddressBinding"); - _id82_HttpBinding = Reader.NameTable.Add(@"HttpBinding"); - _id17_address = Reader.NameTable.Add(@"address"); - _id3_ServiceDescription = Reader.NameTable.Add(@"ServiceDescription"); - _id38_SoapFaultBinding = Reader.NameTable.Add(@"SoapFaultBinding"); - _id123_ref = Reader.NameTable.Add(@"ref"); - _id198_XmlSchemaComplexContent = Reader.NameTable.Add(@"XmlSchemaComplexContent"); - _id53_parts = Reader.NameTable.Add(@"parts"); - _id35_use = Reader.NameTable.Add(@"use"); - _id157_XmlSchemaLengthFacet = Reader.NameTable.Add(@"XmlSchemaLengthFacet"); - _id207_XmlSchemaImport = Reader.NameTable.Add(@"XmlSchemaImport"); - _id44_text = Reader.NameTable.Add(@"text"); - _id117_XmlSchemaAppInfo = Reader.NameTable.Add(@"XmlSchemaAppInfo"); - _id203_public = Reader.NameTable.Add(@"public"); - _id69_urlEncoded = Reader.NameTable.Add(@"urlEncoded"); - _id7_documentation = Reader.NameTable.Add(@"documentation"); - _id19_Item = Reader.NameTable.Add(@"http://schemas.xmlsoap.org/wsdl/soap/"); - _id129_final = Reader.NameTable.Add(@"final"); - _id163_XmlSchemaElement = Reader.NameTable.Add(@"XmlSchemaElement"); - _id60_capture = Reader.NameTable.Add(@"capture"); - _id37_encodingStyle = Reader.NameTable.Add(@"encodingStyle"); - _id185_sequence = Reader.NameTable.Add(@"sequence"); - _id166_abstract = Reader.NameTable.Add(@"abstract"); - _id23_location = Reader.NameTable.Add(@"location"); - _id111_XmlSchemaAttributeGroup = Reader.NameTable.Add(@"XmlSchemaAttributeGroup"); - _id192_XmlSchemaSequence = Reader.NameTable.Add(@"XmlSchemaSequence"); - _id33_FaultBinding = Reader.NameTable.Add(@"FaultBinding"); - _id153_XmlSchemaMaxInclusiveFacet = Reader.NameTable.Add(@"XmlSchemaMaxInclusiveFacet"); - _id201_XmlSchemaGroup = Reader.NameTable.Add(@"XmlSchemaGroup"); - _id43_multipartRelated = Reader.NameTable.Add(@"multipartRelated"); - _id168_nillable = Reader.NameTable.Add(@"nillable"); - _id149_value = Reader.NameTable.Add(@"value"); - _id64_MimeMultipartRelatedBinding = Reader.NameTable.Add(@"MimeMultipartRelatedBinding"); - _id193_XmlSchemaAny = Reader.NameTable.Add(@"XmlSchemaAny"); - _id191_XmlSchemaGroupRef = Reader.NameTable.Add(@"XmlSchemaGroupRef"); - _id74_soapAction = Reader.NameTable.Add(@"soapAction"); - _id63_ignoreCase = Reader.NameTable.Add(@"ignoreCase"); - _id101_version = Reader.NameTable.Add(@"version"); - _id47_header = Reader.NameTable.Add(@"header"); - _id195_extension = Reader.NameTable.Add(@"extension"); - _id48_Soap12HeaderBinding = Reader.NameTable.Add(@"Soap12HeaderBinding"); - _id134_memberTypes = Reader.NameTable.Add(@"memberTypes"); - _id121_Item = Reader.NameTable.Add(@"http://www.w3.org/XML/1998/namespace"); - _id146_minExclusive = Reader.NameTable.Add(@"minExclusive"); - _id84_PortType = Reader.NameTable.Add(@"PortType"); - _id42_mimeXml = Reader.NameTable.Add(@"mimeXml"); - _id138_minInclusive = Reader.NameTable.Add(@"minInclusive"); - _id118_source = Reader.NameTable.Add(@"source"); - _id73_Soap12OperationBinding = Reader.NameTable.Add(@"Soap12OperationBinding"); - _id131_restriction = Reader.NameTable.Add(@"restriction"); - _id152_XmlSchemaMaxExclusiveFacet = Reader.NameTable.Add(@"XmlSchemaMaxExclusiveFacet"); - _id135_XmlSchemaSimpleTypeRestriction = Reader.NameTable.Add(@"XmlSchemaSimpleTypeRestriction"); - _id188_XmlSchemaAll = Reader.NameTable.Add(@"XmlSchemaAll"); - _id116_appinfo = Reader.NameTable.Add(@"appinfo"); - _id86_parameterOrder = Reader.NameTable.Add(@"parameterOrder"); - _id147_minLength = Reader.NameTable.Add(@"minLength"); - _id78_HttpOperationBinding = Reader.NameTable.Add(@"HttpOperationBinding"); - _id161_XmlSchemaSimpleTypeList = Reader.NameTable.Add(@"XmlSchemaSimpleTypeList"); - _id205_XmlSchemaRedefine = Reader.NameTable.Add(@"XmlSchemaRedefine"); - _id194_XmlSchemaSimpleContent = Reader.NameTable.Add(@"XmlSchemaSimpleContent"); - _id91_MessagePart = Reader.NameTable.Add(@"MessagePart"); - _id92_element = Reader.NameTable.Add(@"element"); - _id114_processContents = Reader.NameTable.Add(@"processContents"); - _id18_Item = Reader.NameTable.Add(@"http://schemas.xmlsoap.org/wsdl/http/"); - _id50_headerfault = Reader.NameTable.Add(@"headerfault"); - _id154_XmlSchemaEnumerationFacet = Reader.NameTable.Add(@"XmlSchemaEnumerationFacet"); - _id96_XmlSchema = Reader.NameTable.Add(@"XmlSchema"); - _id127_form = Reader.NameTable.Add(@"form"); - _id176_field = Reader.NameTable.Add(@"field"); - _id49_part = Reader.NameTable.Add(@"part"); - _id5_Item = Reader.NameTable.Add(@""); - _id57_match = Reader.NameTable.Add(@"match"); - _id52_Soap12BodyBinding = Reader.NameTable.Add(@"Soap12BodyBinding"); - _id104_redefine = Reader.NameTable.Add(@"redefine"); - _id20_Item = Reader.NameTable.Add(@"http://schemas.xmlsoap.org/wsdl/soap12/"); - _id21_Soap12AddressBinding = Reader.NameTable.Add(@"Soap12AddressBinding"); - _id142_enumeration = Reader.NameTable.Add(@"enumeration"); - _id24_SoapAddressBinding = Reader.NameTable.Add(@"SoapAddressBinding"); - _id103_include = Reader.NameTable.Add(@"include"); - _id139_maxLength = Reader.NameTable.Add(@"maxLength"); - _id165_maxOccurs = Reader.NameTable.Add(@"maxOccurs"); - _id65_MimePart = Reader.NameTable.Add(@"MimePart"); - _id102_id = Reader.NameTable.Add(@"id"); - _id196_Item = Reader.NameTable.Add(@"XmlSchemaSimpleContentExtension"); - _id140_length = Reader.NameTable.Add(@"length"); - _id27_type = Reader.NameTable.Add(@"type"); - _id106_complexType = Reader.NameTable.Add(@"complexType"); - _id31_output = Reader.NameTable.Add(@"output"); - _id1_definitions = Reader.NameTable.Add(@"definitions"); - _id4_name = Reader.NameTable.Add(@"name"); - _id132_union = Reader.NameTable.Add(@"union"); - _id29_OperationBinding = Reader.NameTable.Add(@"OperationBinding"); - _id170_key = Reader.NameTable.Add(@"key"); - _id45_Item = Reader.NameTable.Add(@"http://microsoft.com/wsdl/mime/textMatching/"); - _id95_Item = Reader.NameTable.Add(@"http://www.w3.org/2001/XMLSchema"); - _id169_substitutionGroup = Reader.NameTable.Add(@"substitutionGroup"); - _id178_xpath = Reader.NameTable.Add(@"xpath"); - _id9_types = Reader.NameTable.Add(@"types"); - _id97_attributeFormDefault = Reader.NameTable.Add(@"attributeFormDefault"); - _id62_pattern = Reader.NameTable.Add(@"pattern"); - _id58_MimeTextMatch = Reader.NameTable.Add(@"MimeTextMatch"); - _id180_XmlSchemaKey = Reader.NameTable.Add(@"XmlSchemaKey"); - _id10_message = Reader.NameTable.Add(@"message"); - _id8_import = Reader.NameTable.Add(@"import"); - _id148_XmlSchemaMinLengthFacet = Reader.NameTable.Add(@"XmlSchemaMinLengthFacet"); - _id105_simpleType = Reader.NameTable.Add(@"simpleType"); - _id181_XmlSchemaComplexType = Reader.NameTable.Add(@"XmlSchemaComplexType"); - _id164_minOccurs = Reader.NameTable.Add(@"minOccurs"); - _id144_maxExclusive = Reader.NameTable.Add(@"maxExclusive"); - _id160_XmlSchemaFractionDigitsFacet = Reader.NameTable.Add(@"XmlSchemaFractionDigitsFacet"); - _id124_XmlSchemaAttribute = Reader.NameTable.Add(@"XmlSchemaAttribute"); - _id209_Import = Reader.NameTable.Add(@"Import"); - _id206_schemaLocation = Reader.NameTable.Add(@"schemaLocation"); - _id179_XmlSchemaUnique = Reader.NameTable.Add(@"XmlSchemaUnique"); - _id75_style = Reader.NameTable.Add(@"style"); - _id119_XmlSchemaDocumentation = Reader.NameTable.Add(@"XmlSchemaDocumentation"); - _id136_base = Reader.NameTable.Add(@"base"); - _id66_MimeXmlBinding = Reader.NameTable.Add(@"MimeXmlBinding"); - _id30_input = Reader.NameTable.Add(@"input"); - _id40_content = Reader.NameTable.Add(@"content"); - _id93_Types = Reader.NameTable.Add(@"Types"); - _id94_schema = Reader.NameTable.Add(@"schema"); - _id200_Item = Reader.NameTable.Add(@"XmlSchemaComplexContentExtension"); - _id67_MimeContentBinding = Reader.NameTable.Add(@"MimeContentBinding"); - _id59_group = Reader.NameTable.Add(@"group"); - _id32_fault = Reader.NameTable.Add(@"fault"); - _id80_transport = Reader.NameTable.Add(@"transport"); - _id98_blockDefault = Reader.NameTable.Add(@"blockDefault"); - _id13_service = Reader.NameTable.Add(@"service"); - _id54_SoapHeaderBinding = Reader.NameTable.Add(@"SoapHeaderBinding"); - _id204_system = Reader.NameTable.Add(@"system"); - _id16_Port = Reader.NameTable.Add(@"Port"); - _id108_notation = Reader.NameTable.Add(@"notation"); - _id186_choice = Reader.NameTable.Add(@"choice"); - _id110_attributeGroup = Reader.NameTable.Add(@"attributeGroup"); - _id79_Soap12Binding = Reader.NameTable.Add(@"Soap12Binding"); - _id77_SoapOperationBinding = Reader.NameTable.Add(@"SoapOperationBinding"); - _id115_XmlSchemaAnnotation = Reader.NameTable.Add(@"XmlSchemaAnnotation"); - _id83_verb = Reader.NameTable.Add(@"verb"); - _id72_HttpUrlEncodedBinding = Reader.NameTable.Add(@"HttpUrlEncodedBinding"); - _id39_OutputBinding = Reader.NameTable.Add(@"OutputBinding"); - _id183_complexContent = Reader.NameTable.Add(@"complexContent"); - _id202_XmlSchemaNotation = Reader.NameTable.Add(@"XmlSchemaNotation"); - _id81_SoapBinding = Reader.NameTable.Add(@"SoapBinding"); - _id199_Item = Reader.NameTable.Add(@"XmlSchemaComplexContentRestriction"); - _id28_operation = Reader.NameTable.Add(@"operation"); - _id122_XmlSchemaAttributeGroupRef = Reader.NameTable.Add(@"XmlSchemaAttributeGroupRef"); - _id155_XmlSchemaPatternFacet = Reader.NameTable.Add(@"XmlSchemaPatternFacet"); - _id76_soapActionRequired = Reader.NameTable.Add(@"soapActionRequired"); - _id90_Message = Reader.NameTable.Add(@"Message"); - _id159_XmlSchemaMinInclusiveFacet = Reader.NameTable.Add(@"XmlSchemaMinInclusiveFacet"); - _id208_XmlSchemaInclude = Reader.NameTable.Add(@"XmlSchemaInclude"); - _id85_Operation = Reader.NameTable.Add(@"Operation"); - _id130_list = Reader.NameTable.Add(@"list"); - _id14_Service = Reader.NameTable.Add(@"Service"); - _id22_required = Reader.NameTable.Add(@"required"); - _id174_refer = Reader.NameTable.Add(@"refer"); - _id71_HttpUrlReplacementBinding = Reader.NameTable.Add(@"HttpUrlReplacementBinding"); - _id56_MimeTextBinding = Reader.NameTable.Add(@"MimeTextBinding"); - _id87_OperationFault = Reader.NameTable.Add(@"OperationFault"); - _id125_default = Reader.NameTable.Add(@"default"); - _id15_port = Reader.NameTable.Add(@"port"); - _id51_SoapHeaderFaultBinding = Reader.NameTable.Add(@"SoapHeaderFaultBinding"); - _id128_XmlSchemaSimpleType = Reader.NameTable.Add(@"XmlSchemaSimpleType"); - _id36_namespace = Reader.NameTable.Add(@"namespace"); - _id175_selector = Reader.NameTable.Add(@"selector"); - _id150_XmlSchemaMinExclusiveFacet = Reader.NameTable.Add(@"XmlSchemaMinExclusiveFacet"); - _id100_elementFormDefault = Reader.NameTable.Add(@"elementFormDefault"); - _id26_Binding = Reader.NameTable.Add(@"Binding"); - _id197_Item = Reader.NameTable.Add(@"XmlSchemaSimpleContentRestriction"); - _id126_fixed = Reader.NameTable.Add(@"fixed"); - _id107_annotation = Reader.NameTable.Add(@"annotation"); - _id99_finalDefault = Reader.NameTable.Add(@"finalDefault"); - _id137_fractionDigits = Reader.NameTable.Add(@"fractionDigits"); - _id70_urlReplacement = Reader.NameTable.Add(@"urlReplacement"); - _id189_XmlSchemaChoice = Reader.NameTable.Add(@"XmlSchemaChoice"); - _id2_Item = Reader.NameTable.Add(@"http://schemas.xmlsoap.org/wsdl/"); - _id112_anyAttribute = Reader.NameTable.Add(@"anyAttribute"); - _id89_OperationInput = Reader.NameTable.Add(@"OperationInput"); - _id141_totalDigits = Reader.NameTable.Add(@"totalDigits"); - _id61_repeats = Reader.NameTable.Add(@"repeats"); - _id184_simpleContent = Reader.NameTable.Add(@"simpleContent"); - _id55_SoapBodyBinding = Reader.NameTable.Add(@"SoapBodyBinding"); - _id145_whiteSpace = Reader.NameTable.Add(@"whiteSpace"); - _id167_block = Reader.NameTable.Add(@"block"); - _id151_XmlSchemaWhiteSpaceFacet = Reader.NameTable.Add(@"XmlSchemaWhiteSpaceFacet"); - _id12_binding = Reader.NameTable.Add(@"binding"); - _id109_attribute = Reader.NameTable.Add(@"attribute"); - _id171_unique = Reader.NameTable.Add(@"unique"); - _id120_lang = Reader.NameTable.Add(@"lang"); - _id173_XmlSchemaKeyref = Reader.NameTable.Add(@"XmlSchemaKeyref"); - _id177_XmlSchemaXPath = Reader.NameTable.Add(@"XmlSchemaXPath"); - _id34_Soap12FaultBinding = Reader.NameTable.Add(@"Soap12FaultBinding"); - _id41_Item = Reader.NameTable.Add(@"http://schemas.xmlsoap.org/wsdl/mime/"); - _id156_XmlSchemaTotalDigitsFacet = Reader.NameTable.Add(@"XmlSchemaTotalDigitsFacet"); - _id113_XmlSchemaAnyAttribute = Reader.NameTable.Add(@"XmlSchemaAnyAttribute"); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs deleted file mode 100644 index 47fde06f7b2..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/ServiceDescriptions.cs +++ /dev/null @@ -1,216 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using System; - using System.Xml; - - /// - /// - /// [To be supplied.] - /// - public sealed class ServiceDescriptionCollection : ServiceDescriptionBaseCollection - { - /// - /// - /// [To be supplied.] - /// - public ServiceDescriptionCollection() : base(null) { } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription this[int index] - { - get { return (ServiceDescription)List[index]; } - set { List[index] = value; } - } - - /// - /// - /// [To be supplied.] - /// - public ServiceDescription this[string ns] - { - get { return (ServiceDescription)Table[ns]; } - } - - /// - /// - /// [To be supplied.] - /// - public int Add(ServiceDescription serviceDescription) - { - return List.Add(serviceDescription); - } - - /// - /// - /// [To be supplied.] - /// - public void Insert(int index, ServiceDescription serviceDescription) - { - List.Insert(index, serviceDescription); - } - - /// - /// - /// [To be supplied.] - /// - public int IndexOf(ServiceDescription serviceDescription) - { - return List.IndexOf(serviceDescription); - } - - /// - /// - /// [To be supplied.] - /// - public bool Contains(ServiceDescription serviceDescription) - { - return List.Contains(serviceDescription); - } - - /// - /// - /// [To be supplied.] - /// - public void Remove(ServiceDescription serviceDescription) - { - List.Remove(serviceDescription); - } - - /// - /// - /// [To be supplied.] - /// - public void CopyTo(ServiceDescription[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// - /// [To be supplied.] - /// - protected override string GetKey(object value) - { - string ns = ((ServiceDescription)value).TargetNamespace; - if (ns == null) - return string.Empty; - return ns; - } - - private Exception ItemNotFound(XmlQualifiedName name, string type) - { - return new Exception(string.Format(ResWebServices.WebDescriptionMissingItem, type, name.Name, name.Namespace)); - } - - /// - /// - /// [To be supplied.] - /// - public Message GetMessage(XmlQualifiedName name) - { - ServiceDescription sd = GetServiceDescription(name); - Message message = null; - while (message == null && sd != null) - { - message = sd.Messages[name.Name]; - sd = sd.Next; - } - if (message == null) throw ItemNotFound(name, "message"); - return message; - } - - /// - /// - /// [To be supplied.] - /// - public PortType GetPortType(XmlQualifiedName name) - { - ServiceDescription sd = GetServiceDescription(name); - PortType portType = null; - while (portType == null && sd != null) - { - portType = sd.PortTypes[name.Name]; - sd = sd.Next; - } - if (portType == null) throw ItemNotFound(name, "message"); - return portType; - } - - /// - /// - /// [To be supplied.] - /// - public Service GetService(XmlQualifiedName name) - { - ServiceDescription sd = GetServiceDescription(name); - Service service = null; - while (service == null && sd != null) - { - service = sd.Services[name.Name]; - sd = sd.Next; - } - if (service == null) throw ItemNotFound(name, "service"); - return service; - } - - /// - /// - /// [To be supplied.] - /// - public Binding GetBinding(XmlQualifiedName name) - { - ServiceDescription sd = GetServiceDescription(name); - Binding binding = null; - while (binding == null && sd != null) - { - binding = sd.Bindings[name.Name]; - sd = sd.Next; - } - if (binding == null) throw ItemNotFound(name, "binding"); - return binding; - } - - private ServiceDescription GetServiceDescription(XmlQualifiedName name) - { - ServiceDescription serviceDescription = this[name.Namespace]; - if (serviceDescription == null) - { - throw new ArgumentException(string.Format(ResWebServices.WebDescriptionMissing, name.ToString(), name.Namespace), "name"); - } - return serviceDescription; - } - - /// - /// - /// [To be supplied.] - /// - protected override void SetParent(object value, object parent) - { - ((ServiceDescription)value).SetParent((ServiceDescriptionCollection)parent); - } - - /// - /// - /// [To be supplied.] - /// - protected override void OnInsertComplete(int index, object value) - { - string key = GetKey(value); - if (key != null) - { - ServiceDescription item = (ServiceDescription)Table[key]; - ((ServiceDescription)value).Next = (ServiceDescription)Table[key]; - Table[key] = value; - } - SetParent(value, this); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs deleted file mode 100644 index cec0f0a803d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/Soap12FormatExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using System.ComponentModel; - using System.Web.Services.Configuration; - using System.Xml; - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - - /// - [XmlFormatExtension("binding", Soap12Binding.Namespace, typeof(Binding))] - [XmlFormatExtensionPrefix("soap12", Soap12Binding.Namespace)] - public sealed class Soap12Binding : SoapBinding - { - /// - public new const string Namespace = "http://schemas.xmlsoap.org/wsdl/soap12/"; - /// - public new const string HttpTransport = "http://schemas.xmlsoap.org/soap/http"; - } - - /// - [XmlFormatExtension("operation", Soap12Binding.Namespace, typeof(OperationBinding))] - public sealed class Soap12OperationBinding : SoapOperationBinding - { - private bool _soapActionRequired; - - /// - [XmlAttribute("soapActionRequired"), DefaultValue(false)] - public bool SoapActionRequired - { - get { return _soapActionRequired; } - set { _soapActionRequired = value; } - } - } - - /// - [XmlFormatExtension("body", Soap12Binding.Namespace, typeof(InputBinding), typeof(OutputBinding), typeof(MimePart))] - public sealed class Soap12BodyBinding : SoapBodyBinding - { - } - - /// - [XmlFormatExtension("fault", Soap12Binding.Namespace, typeof(FaultBinding))] - public sealed class Soap12FaultBinding : SoapFaultBinding - { - } - - /// - [XmlFormatExtension("header", Soap12Binding.Namespace, typeof(InputBinding), typeof(OutputBinding))] - public sealed class Soap12HeaderBinding : SoapHeaderBinding - { - } - - /// - [XmlFormatExtension("address", Soap12Binding.Namespace, typeof(Port))] - public sealed class Soap12AddressBinding : SoapAddressBinding - { - } -} diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs deleted file mode 100644 index 2e5bf033ff1..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/SoapFormatExtensions.cs +++ /dev/null @@ -1,357 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using System.Xml; - using System.IO; - using System.Xml.Schema; - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using System.ComponentModel; - using System.Text; - using System.Web.Services.Configuration; - - /// - [XmlFormatExtension("binding", SoapBinding.Namespace, typeof(Binding))] - [XmlFormatExtensionPrefix("soap", SoapBinding.Namespace)] - [XmlFormatExtensionPrefix("soapenc", "http://schemas.xmlsoap.org/soap/encoding/")] - public class SoapBinding : ServiceDescriptionFormatExtension - { - private SoapBindingStyle _style = SoapBindingStyle.Document; - private string _transport; - private static XmlSchema s_schema = null; - - /// - public const string Namespace = "http://schemas.xmlsoap.org/wsdl/soap/"; - /// - public const string HttpTransport = "http://schemas.xmlsoap.org/soap/http"; - - /// - [XmlAttribute("transport")] - public string Transport - { - get { return _transport == null ? string.Empty : _transport; } - set { _transport = value; } - } - - /// - [XmlAttribute("style"), DefaultValue(SoapBindingStyle.Document)] - public SoapBindingStyle Style - { - get { return _style; } - set { _style = value; } - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Schema - { - get - { - if (s_schema == null) - { - s_schema = XmlSchema.Read(new StringReader(Schemas.Soap), null); - } - return s_schema; - } - } - } - - /// - public enum SoapBindingStyle - { - /// - [XmlIgnore] - Default, - /// - [XmlEnum("document")] - Document, - /// - [XmlEnum("rpc")] - Rpc, - } - - /// - [XmlFormatExtension("operation", SoapBinding.Namespace, typeof(OperationBinding))] - public class SoapOperationBinding : ServiceDescriptionFormatExtension - { - private string _soapAction; - private SoapBindingStyle _style; - - /// - [XmlAttribute("soapAction")] - public string SoapAction - { - get { return _soapAction == null ? string.Empty : _soapAction; } - set { _soapAction = value; } - } - - /// - [XmlAttribute("style"), DefaultValue(SoapBindingStyle.Default)] - public SoapBindingStyle Style - { - get { return _style; } - set { _style = value; } - } - } - - /// - [XmlFormatExtension("body", SoapBinding.Namespace, typeof(InputBinding), typeof(OutputBinding), typeof(MimePart))] - public class SoapBodyBinding : ServiceDescriptionFormatExtension - { - private SoapBindingUse _use; - private string _ns; - private string _encoding; - private string[] _parts; - - /// - [XmlAttribute("use"), DefaultValue(SoapBindingUse.Default)] - public SoapBindingUse Use - { - get { return _use; } - set { _use = value; } - } - - /// - [XmlAttribute("namespace"), DefaultValue("")] - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - - /// - [XmlAttribute("encodingStyle"), DefaultValue("")] - public string Encoding - { - get { return _encoding == null ? string.Empty : _encoding; } - set { _encoding = value; } - } - - /// - [XmlAttribute("parts")] - public string PartsString - { - get - { - if (_parts == null) - return null; - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < _parts.Length; i++) - { - if (i > 0) builder.Append(' '); - builder.Append(_parts[i]); - } - return builder.ToString(); - } - set - { - if (value == null) - _parts = null; - else - _parts = value.Split(new char[] { ' ' }); - } - } - - /// - [XmlIgnore] - public string[] Parts - { - get { return _parts; } - set { _parts = value; } - } - } - - /// - public enum SoapBindingUse - { - /// - [XmlIgnore] - Default, - /// - [XmlEnum("encoded")] - Encoded, - /// - [XmlEnum("literal")] - Literal, - } - - /// - [XmlFormatExtension("fault", SoapBinding.Namespace, typeof(FaultBinding))] - public class SoapFaultBinding : ServiceDescriptionFormatExtension - { - private SoapBindingUse _use; - private string _ns; - private string _encoding; - private string _name; - - /// - [XmlAttribute("use"), DefaultValue(SoapBindingUse.Default)] - public SoapBindingUse Use - { - get { return _use; } - set { _use = value; } - } - - /// - [XmlAttribute("name")] - public string Name - { - get { return _name; } - set { _name = value; } - } - /// - [XmlAttribute("namespace")] - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - - /// - [XmlAttribute("encodingStyle"), DefaultValue("")] - public string Encoding - { - get { return _encoding == null ? string.Empty : _encoding; } - set { _encoding = value; } - } - } - - /// - [XmlFormatExtension("header", SoapBinding.Namespace, typeof(InputBinding), typeof(OutputBinding))] - public class SoapHeaderBinding : ServiceDescriptionFormatExtension - { - private XmlQualifiedName _message = XmlQualifiedName.Empty; - private string _part; - private SoapBindingUse _use; - private string _encoding; - private string _ns; - private bool _mapToProperty; - private SoapHeaderFaultBinding _fault; - - /// - [XmlIgnore] - public bool MapToProperty - { - get { return _mapToProperty; } - set { _mapToProperty = value; } - } - - /// - [XmlAttribute("message")] - public XmlQualifiedName Message - { - get { return _message; } - set { _message = value; } - } - - /// - [XmlAttribute("part")] - public string Part - { - get { return _part; } - set { _part = value; } - } - - /// - [XmlAttribute("use"), DefaultValue(SoapBindingUse.Default)] - public SoapBindingUse Use - { - get { return _use; } - set { _use = value; } - } - - /// - [XmlAttribute("encodingStyle"), DefaultValue("")] - public string Encoding - { - get { return _encoding == null ? string.Empty : _encoding; } - set { _encoding = value; } - } - - /// - [XmlAttribute("namespace"), DefaultValue("")] - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - - /// - [XmlElement("headerfault")] - public SoapHeaderFaultBinding Fault - { - get { return _fault; } - set { _fault = value; } - } - } - - /// - public class SoapHeaderFaultBinding : ServiceDescriptionFormatExtension - { - private XmlQualifiedName _message = XmlQualifiedName.Empty; - private string _part; - private SoapBindingUse _use; - private string _encoding; - private string _ns; - - /// - [XmlAttribute("message")] - public XmlQualifiedName Message - { - get { return _message; } - set { _message = value; } - } - - /// - [XmlAttribute("part")] - public string Part - { - get { return _part; } - set { _part = value; } - } - - /// - [XmlAttribute("use"), DefaultValue(SoapBindingUse.Default)] - public SoapBindingUse Use - { - get { return _use; } - set { _use = value; } - } - - /// - [XmlAttribute("encodingStyle"), DefaultValue("")] - public string Encoding - { - get { return _encoding == null ? string.Empty : _encoding; } - set { _encoding = value; } - } - - /// - [XmlAttribute("namespace"), DefaultValue("")] - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - } - - /// - [XmlFormatExtension("address", SoapBinding.Namespace, typeof(Port))] - public class SoapAddressBinding : ServiceDescriptionFormatExtension - { - private string _location; - - /// - [XmlAttribute("location")] - public string Location - { - get { return _location == null ? string.Empty : _location; } - set { _location = value; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs deleted file mode 100644 index dc1d32b5aba..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WebReferenceOptions.cs +++ /dev/null @@ -1,525 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Description -{ - using System; - using System.Globalization; - using System.IO; - using System.ComponentModel; - using System.Xml; - using System.Xml.Schema; - using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; - using System.Collections; - using System.Collections.Specialized; - - /// - /// - /// [To be supplied.] - /// - [XmlType("webReferenceOptions", Namespace = WebReferenceOptions.TargetNamespace)] - [XmlRoot("webReferenceOptions", Namespace = WebReferenceOptions.TargetNamespace)] - public class WebReferenceOptions - { - public const string TargetNamespace = "http://microsoft.com/webReference/"; - private static XmlSchema s_schema = null; - private CodeGenerationOptions _codeGenerationOptions = CodeGenerationOptions.GenerateOldAsync; - private ServiceDescriptionImportStyle _style = ServiceDescriptionImportStyle.Client; - private StringCollection _schemaImporterExtensions; - private bool _verbose; - - /// - /// - /// [To be supplied.] - /// - [XmlElement("codeGenerationOptions")] - [DefaultValue(CodeGenerationOptions.GenerateOldAsync)] - public CodeGenerationOptions CodeGenerationOptions - { - get - { - return _codeGenerationOptions; - } - set - { - _codeGenerationOptions = value; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlArray("schemaImporterExtensions")] - [XmlArrayItem("type")] - public StringCollection SchemaImporterExtensions - { - get - { - if (_schemaImporterExtensions == null) - _schemaImporterExtensions = new StringCollection(); - return _schemaImporterExtensions; - } - } - - /// - /// - /// [To be supplied.] - /// - [DefaultValue(ServiceDescriptionImportStyle.Client)] - [XmlElement("style")] - public ServiceDescriptionImportStyle Style - { - get - { - return _style; - } - set - { - _style = value; - } - } - - /// - /// - /// [To be supplied.] - /// - [XmlElement("verbose")] - public bool Verbose - { - get - { - return _verbose; - } - set - { - _verbose = value; - } - } - - /// - /// - /// [To be supplied.] - /// - public static XmlSchema Schema - { - get - { - if (s_schema == null) - { - s_schema = XmlSchema.Read(new StringReader(Schemas.WebRef), null); - } - return s_schema; - } - } - - /// - /// - /// [To be supplied.] - /// - public static WebReferenceOptions Read(TextReader reader, ValidationEventHandler validationEventHandler) - { - XmlTextReader readerNew = new XmlTextReader(reader); - readerNew.XmlResolver = null; - readerNew.DtdProcessing = DtdProcessing.Prohibit; - return Read(readerNew, validationEventHandler); - } - - /// - /// - /// [To be supplied.] - /// - public static WebReferenceOptions Read(Stream stream, ValidationEventHandler validationEventHandler) - { - XmlTextReader readerNew = new XmlTextReader(stream); - readerNew.XmlResolver = null; - readerNew.DtdProcessing = DtdProcessing.Prohibit; - return Read(readerNew, validationEventHandler); - } - - /// - /// - /// [To be supplied.] - /// - public static WebReferenceOptions Read(XmlReader xmlReader, ValidationEventHandler validationEventHandler) - { -#pragma warning disable 0618 - XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader); -#pragma warning restore 0618 - validatingReader.ValidationType = ValidationType.Schema; - if (validationEventHandler != null) - { - validatingReader.ValidationEventHandler += validationEventHandler; - } - else - { - validatingReader.ValidationEventHandler += new ValidationEventHandler(SchemaValidationHandler); - } - validatingReader.Schemas.Add(Schema); - webReferenceOptionsSerializer ser = new webReferenceOptionsSerializer(); - try - { - return (WebReferenceOptions)ser.Deserialize(validatingReader); - } - catch (Exception e) - { - throw e; - } - finally - { - validatingReader.Close(); - } - } - - private static void SchemaValidationHandler(object sender, ValidationEventArgs args) - { - if (args.Severity != XmlSeverityType.Error) - return; - throw new InvalidOperationException(string.Format(ResWebServices.WsdlInstanceValidationDetails, args.Message, args.Exception.LineNumber.ToString(CultureInfo.InvariantCulture), args.Exception.LinePosition.ToString(CultureInfo.InvariantCulture))); - } - } - - internal class WebReferenceOptionsSerializationWriter : XmlSerializationWriter - { - private string Write1_CodeGenerationOptions(System.Xml.Serialization.CodeGenerationOptions v) - { - string s = null; - switch (v) - { - case System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties: s = @"properties"; break; - case System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync: s = @"newAsync"; break; - case System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync: s = @"oldAsync"; break; - case System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder: s = @"order"; break; - case System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding: s = @"enableDataBinding"; break; - default: - s = FromEnum(((System.Int64)v), new string[] { @"properties", - @"newAsync", - @"oldAsync", - @"order", - @"enableDataBinding" }, new System.Int64[] { (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties, - (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync, - (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync, - (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder, - (long)System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding }, @"System.Xml.Serialization.CodeGenerationOptions"); break; - } - return s; - } - - private string Write2_ServiceDescriptionImportStyle(System.Web.Services.Description.ServiceDescriptionImportStyle v) - { - string s = null; - switch (v) - { - case System.Web.Services.Description.ServiceDescriptionImportStyle.@Client: s = @"client"; break; - case System.Web.Services.Description.ServiceDescriptionImportStyle.@Server: s = @"server"; break; - case System.Web.Services.Description.ServiceDescriptionImportStyle.@ServerInterface: s = @"serverInterface"; break; - default: throw CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture), @"System.Web.Services.Description.ServiceDescriptionImportStyle"); - } - return s; - } - - private void Write4_WebReferenceOptions(string n, string ns, WebReferenceOptions o, bool isNullable, bool needType) - { - if ((object)o == null) - { - if (isNullable) WriteNullTagLiteral(n, ns); - return; - } - if (!needType) - { - System.Type t = o.GetType(); - if (t == typeof(WebReferenceOptions)) - { - } - else - { - throw CreateUnknownTypeException(o); - } - } - EscapeName = false; - WriteStartElement(n, ns, o); - if (needType) WriteXsiType(@"webReferenceOptions", @"http://microsoft.com/webReference/"); - if (((CodeGenerationOptions)o.@CodeGenerationOptions) != (CodeGenerationOptions.@GenerateOldAsync)) - { - WriteElementString(@"codeGenerationOptions", @"http://microsoft.com/webReference/", Write1_CodeGenerationOptions((System.Xml.Serialization.CodeGenerationOptions)(long)o.@CodeGenerationOptions)); - } - { - System.Collections.Specialized.StringCollection a = (System.Collections.Specialized.StringCollection)((System.Collections.Specialized.StringCollection)o.@SchemaImporterExtensions); - if (a != null) - { - WriteStartElement(@"schemaImporterExtensions", @"http://microsoft.com/webReference/"); - for (int ia = 0; ia < a.Count; ia++) - { - WriteNullableStringLiteral(@"type", @"http://microsoft.com/webReference/", ((System.String)a[ia])); - } - WriteEndElement(); - } - } - if (((System.Web.Services.Description.ServiceDescriptionImportStyle)o.@Style) != System.Web.Services.Description.ServiceDescriptionImportStyle.@Client) - { - WriteElementString(@"style", @"http://microsoft.com/webReference/", Write2_ServiceDescriptionImportStyle(((System.Web.Services.Description.ServiceDescriptionImportStyle)o.@Style))); - } - WriteElementStringRaw(@"verbose", @"http://microsoft.com/webReference/", System.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o.@Verbose))); - WriteEndElement(o); - } - - protected override void InitCallbacks() - { - } - - internal void Write5_webReferenceOptions(object o) - { - WriteStartDocument(); - if (o == null) - { - WriteNullTagLiteral(@"webReferenceOptions", @"http://microsoft.com/webReference/"); - return; - } - TopLevelElement(); - Write4_WebReferenceOptions(@"webReferenceOptions", @"http://microsoft.com/webReference/", ((System.Web.Services.Description.WebReferenceOptions)o), true, false); - } - } - - internal class WebReferenceOptionsSerializationReader : XmlSerializationReader - { - private System.Collections.Hashtable _CodeGenerationOptionsValues; - - internal System.Collections.Hashtable CodeGenerationOptionsValues - { - get - { - if ((object)_CodeGenerationOptionsValues == null) - { - System.Collections.Hashtable h = new System.Collections.Hashtable(); - h.Add(@"properties", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties); - h.Add(@"newAsync", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync); - h.Add(@"oldAsync", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync); - h.Add(@"order", (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder); - h.Add(@"enableDataBinding", (long)System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding); - _CodeGenerationOptionsValues = h; - } - return _CodeGenerationOptionsValues; - } - } - - private System.Xml.Serialization.CodeGenerationOptions Read1_CodeGenerationOptions(string s) - { - return (System.Xml.Serialization.CodeGenerationOptions)ToEnum(s, CodeGenerationOptionsValues, @"System.Xml.Serialization.CodeGenerationOptions"); - } - - private System.Web.Services.Description.ServiceDescriptionImportStyle Read2_ServiceDescriptionImportStyle(string s) - { - switch (s) - { - case @"client": return System.Web.Services.Description.ServiceDescriptionImportStyle.@Client; - case @"server": return System.Web.Services.Description.ServiceDescriptionImportStyle.@Server; - case @"serverInterface": return System.Web.Services.Description.ServiceDescriptionImportStyle.@ServerInterface; - default: throw CreateUnknownConstantException(s, typeof(System.Web.Services.Description.ServiceDescriptionImportStyle)); - } - } - - private System.Web.Services.Description.WebReferenceOptions Read4_WebReferenceOptions(bool isNullable, bool checkType) - { - System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; - bool isNull = false; - if (isNullable) isNull = ReadNull(); - if (checkType) - { - if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)_id1_webReferenceOptions && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)_id2_Item)) - { - } - else - throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); - } - if (isNull) return null; - System.Web.Services.Description.WebReferenceOptions o; - o = new System.Web.Services.Description.WebReferenceOptions(); - System.Collections.Specialized.StringCollection a_1 = (System.Collections.Specialized.StringCollection)o.@SchemaImporterExtensions; - bool[] paramsRead = new bool[4]; - while (Reader.MoveToNextAttribute()) - { - if (!IsXmlnsAttribute(Reader.Name)) - { - UnknownNode((object)o); - } - } - Reader.MoveToElement(); - if (Reader.IsEmptyElement) - { - Reader.Skip(); - return o; - } - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations0 = 0; - int readerCount0 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (!paramsRead[0] && ((object)Reader.LocalName == (object)_id3_codeGenerationOptions && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if (Reader.IsEmptyElement) - { - Reader.Skip(); - } - else - { - o.@CodeGenerationOptions = (CodeGenerationOptions)(long)Read1_CodeGenerationOptions(Reader.ReadElementString()); - } - paramsRead[0] = true; - } - else if (((object)Reader.LocalName == (object)_id4_schemaImporterExtensions && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if (!ReadNull()) - { - System.Collections.Specialized.StringCollection a_1_0 = (System.Collections.Specialized.StringCollection)o.@SchemaImporterExtensions; - if (((object)(a_1_0) == null) || (Reader.IsEmptyElement)) - { - Reader.Skip(); - } - else - { - Reader.ReadStartElement(); - Reader.MoveToContent(); - int whileIterations1 = 0; - int readerCount1 = ReaderCount; - while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) - { - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id5_type && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if (ReadNull()) - { - a_1_0.Add(null); - } - else - { - a_1_0.Add(Reader.ReadElementString()); - } - } - else - { - UnknownNode(null, @"http://microsoft.com/webReference/:type"); - } - } - else - { - UnknownNode(null, @"http://microsoft.com/webReference/:type"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations1, ref readerCount1); - } - ReadEndElement(); - } - } - } - else if (!paramsRead[2] && ((object)Reader.LocalName == (object)_id6_style && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - if (Reader.IsEmptyElement) - { - Reader.Skip(); - } - else - { - o.@Style = Read2_ServiceDescriptionImportStyle(Reader.ReadElementString()); - } - paramsRead[2] = true; - } - else if (!paramsRead[3] && ((object)Reader.LocalName == (object)_id7_verbose && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - { - o.@Verbose = System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString()); - } - paramsRead[3] = true; - } - else - { - UnknownNode((object)o, @"http://microsoft.com/webReference/:codeGenerationOptions, http://microsoft.com/webReference/:schemaImporterExtensions, http://microsoft.com/webReference/:style, http://microsoft.com/webReference/:verbose"); - } - } - else - { - UnknownNode((object)o, @"http://microsoft.com/webReference/:codeGenerationOptions, http://microsoft.com/webReference/:schemaImporterExtensions, http://microsoft.com/webReference/:style, http://microsoft.com/webReference/:verbose"); - } - Reader.MoveToContent(); - CheckReaderCount(ref whileIterations0, ref readerCount0); - } - ReadEndElement(); - return o; - } - - protected override void InitCallbacks() - { - } - - internal object Read5_webReferenceOptions() - { - object o = null; - Reader.MoveToContent(); - if (Reader.NodeType == System.Xml.XmlNodeType.Element) - { - if (((object)Reader.LocalName == (object)_id1_webReferenceOptions && (object)Reader.NamespaceURI == (object)_id2_Item)) - { - o = Read4_WebReferenceOptions(true, true); - } - else - { - throw CreateUnknownNodeException(); - } - } - else - { - UnknownNode(null, @"http://microsoft.com/webReference/:webReferenceOptions"); - } - return (object)o; - } - - private string _id2_Item; - private string _id5_type; - private string _id4_schemaImporterExtensions; - private string _id3_codeGenerationOptions; - private string _id6_style; - private string _id7_verbose; - private string _id1_webReferenceOptions; - - protected override void InitIDs() - { - _id2_Item = Reader.NameTable.Add(@"http://microsoft.com/webReference/"); - _id5_type = Reader.NameTable.Add(@"type"); - _id4_schemaImporterExtensions = Reader.NameTable.Add(@"schemaImporterExtensions"); - _id3_codeGenerationOptions = Reader.NameTable.Add(@"codeGenerationOptions"); - _id6_style = Reader.NameTable.Add(@"style"); - _id7_verbose = Reader.NameTable.Add(@"verbose"); - _id1_webReferenceOptions = Reader.NameTable.Add(@"webReferenceOptions"); - } - } - - internal sealed class webReferenceOptionsSerializer : XmlSerializer - { - protected override XmlSerializationReader CreateReader() - { - return new WebReferenceOptionsSerializationReader(); - } - protected override XmlSerializationWriter CreateWriter() - { - return new WebReferenceOptionsSerializationWriter(); - } - public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) - { - return true; - } - - protected override void Serialize(System.Object objectToSerialize, XmlSerializationWriter writer) - { - ((WebReferenceOptionsSerializationWriter)writer).Write5_webReferenceOptions(objectToSerialize); - } - protected override System.Object Deserialize(XmlSerializationReader reader) - { - return ((WebReferenceOptionsSerializationReader)reader).Read5_webReferenceOptions(); - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WsiProfiles.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WsiProfiles.cs deleted file mode 100644 index 82b5d0e186c..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/WsiProfiles.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services -{ - using System; - - /// - /// - /// [To be supplied.] - /// - [Flags] - public enum WsiProfiles - { - /// - /// - /// [To be supplied.] - /// - None = 0x00, - - /// - /// - /// [To be supplied.] - /// - BasicProfile1_1 = 0x01, - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionAttribute.cs deleted file mode 100644 index b53cde6e5e0..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionAttribute.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Configuration -{ - using System; - - /// - /// - /// [To be supplied.] - /// - [AttributeUsage(AttributeTargets.Class)] - public sealed class XmlFormatExtensionAttribute : Attribute - { - private Type[] _types; - private string _name; - private string _ns; - - /// - /// - /// [To be supplied.] - /// - public XmlFormatExtensionAttribute() - { - } - - /// - public XmlFormatExtensionAttribute(string elementName, string ns, Type extensionPoint1) : this(elementName, ns, new Type[] { extensionPoint1 }) - { - } - /// - public XmlFormatExtensionAttribute(string elementName, string ns, Type extensionPoint1, Type extensionPoint2) : this(elementName, ns, new Type[] { extensionPoint1, extensionPoint2 }) - { - } - /// - public XmlFormatExtensionAttribute(string elementName, string ns, Type extensionPoint1, Type extensionPoint2, Type extensionPoint3) : this(elementName, ns, new Type[] { extensionPoint1, extensionPoint2, extensionPoint3 }) - { - } - /// - public XmlFormatExtensionAttribute(string elementName, string ns, Type extensionPoint1, Type extensionPoint2, Type extensionPoint3, Type extensionPoint4) : this(elementName, ns, new Type[] { extensionPoint1, extensionPoint2, extensionPoint3, extensionPoint4 }) - { - } - - /// - /// - /// [To be supplied.] - /// - public XmlFormatExtensionAttribute(string elementName, string ns, Type[] extensionPoints) - { - _name = elementName; - _ns = ns; - _types = extensionPoints; - } - - /// - /// - /// [To be supplied.] - /// - public Type[] ExtensionPoints - { - get { return _types == null ? new Type[0] : _types; } - set { _types = value; } - } - - /// - /// - /// [To be supplied.] - /// - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - - /// - /// - /// [To be supplied.] - /// - public string ElementName - { - get { return _name == null ? string.Empty : _name; } - set { _name = value; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPointAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPointAttribute.cs deleted file mode 100644 index 08b07dcd9ba..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPointAttribute.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Configuration -{ - using System; - - /// - /// - /// [To be supplied.] - /// - [AttributeUsage(AttributeTargets.Class)] - public sealed class XmlFormatExtensionPointAttribute : Attribute - { - private string _name; - private bool _allowElements = true; - - /// - /// - /// [To be supplied.] - /// - public XmlFormatExtensionPointAttribute(string memberName) - { - _name = memberName; - } - - /// - /// - /// [To be supplied.] - /// - public string MemberName - { - get { return _name == null ? string.Empty : _name; } - set { _name = value; } - } - - /// - /// - /// [To be supplied.] - /// - public bool AllowElements - { - get { return _allowElements; } - set { _allowElements = value; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPrefixAttribute.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPrefixAttribute.cs deleted file mode 100644 index 99c53c6cf5a..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Description/XmlFormatExtensionPrefixAttribute.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services.Configuration -{ - using System; - - /// - /// - /// [To be supplied.] - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class XmlFormatExtensionPrefixAttribute : Attribute - { - private string _prefix; - private string _ns; - - /// - /// - /// [To be supplied.] - /// - public XmlFormatExtensionPrefixAttribute() - { - } - - /// - /// - /// [To be supplied.] - /// - public XmlFormatExtensionPrefixAttribute(string prefix, string ns) - { - _prefix = prefix; - _ns = ns; - } - - /// - /// - /// [To be supplied.] - /// - public string Prefix - { - get { return _prefix == null ? string.Empty : _prefix; } - set { _prefix = value; } - } - - /// - /// - /// [To be supplied.] - /// - public string Namespace - { - get { return _ns == null ? string.Empty : _ns; } - set { _ns = value; } - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs deleted file mode 100644 index 964f7cbca0e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/Services/Soap.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Web.Services -{ - using System; - using System.Xml; - - internal class Soap - { - private Soap() { } - internal const string XmlNamespace = "http://www.w3.org/XML/1998/namespace"; - internal const string Encoding = "http://schemas.xmlsoap.org/soap/encoding/"; - internal const string Namespace = "http://schemas.xmlsoap.org/soap/envelope/"; - internal const string ConformanceClaim = "http://ws-i.org/schemas/conformanceClaim/"; - internal const string BasicProfile1_1 = "http://ws-i.org/profiles/basic/1.1"; - - internal const string Action = "SOAPAction"; - internal const string ArrayType = "Array"; - internal const string Prefix = "soap"; - internal const string ClaimPrefix = "wsi"; - internal const string DimeContentType = "application/dime"; - internal const string SoapContentType = "text/xml"; - - internal class Attribute - { - private Attribute() { } - internal const string MustUnderstand = "mustUnderstand"; - internal const string Actor = "actor"; - internal const string EncodingStyle = "encodingStyle"; - internal const string Lang = "lang"; - internal const string ConformsTo = "conformsTo"; - } - - internal class Element - { - private Element() { } - internal const string Envelope = "Envelope"; - internal const string Header = "Header"; - internal const string Body = "Body"; - internal const string Fault = "Fault"; - internal const string FaultActor = "faultactor"; - internal const string FaultCode = "faultcode"; - internal const string FaultDetail = "detail"; - internal const string FaultString = "faultstring"; - internal const string StackTrace = "StackTrace"; - internal const string Message = "Message"; - internal const string Claim = "Claim"; - } - - internal class Code - { - private Code() { } - internal const string Server = "Server"; - internal const string VersionMismatch = "VersionMismatch"; - internal const string MustUnderstand = "MustUnderstand"; - internal const string Client = "Client"; - } - } - - internal sealed class Soap12 - { - private Soap12() { } - internal const string Namespace = "http://www.w3.org/2003/05/soap-envelope"; - internal const string Encoding = "http://www.w3.org/2003/05/soap-encoding"; - internal const string RpcNamespace = "http://www.w3.org/2003/05/soap-rpc"; - internal const string Prefix = "soap12"; - internal class Attribute - { - private Attribute() { } - internal const string UpgradeEnvelopeQname = "qname"; - internal const string Role = "role"; - internal const string Relay = "relay"; - } - - internal sealed class Element - { - private Element() { } - internal const string Upgrade = "Upgrade"; - internal const string UpgradeEnvelope = "SupportedEnvelope"; - internal const string FaultRole = "Role"; - internal const string FaultReason = "Reason"; - internal const string FaultReasonText = "Text"; - internal const string FaultCode = "Code"; - internal const string FaultNode = "Node"; - internal const string FaultCodeValue = "Value"; - internal const string FaultSubcode = "Subcode"; - internal const string FaultDetail = "Detail"; - } - - internal sealed class Code - { - private Code() { } - internal const string VersionMismatch = "VersionMismatch"; - internal const string MustUnderstand = "MustUnderstand"; - internal const string DataEncodingUnknown = "DataEncodingUnknown"; - internal const string Sender = "Sender"; - internal const string Receiver = "Receiver"; - - // Subcodes - internal const string RpcProcedureNotPresentSubcode = "ProcedureNotPresent"; - internal const string RpcBadArgumentsSubcode = "BadArguments"; - internal const string EncodingMissingIDFaultSubcode = "MissingID"; - internal const string EncodingUntypedValueFaultSubcode = "UntypedValue"; - } - } -} - diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.cs.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.cs.xlf deleted file mode 100644 index 8f1f012a98d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.cs.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Vazba {0} z oboru názvů {1} - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - Atribut prvku není povolen v částech kódované zprávy. Zpráva: {1}, chybová část: {0}. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Popis služby s oborem názvů targetNamespace={0} - - - - {0} from service description with targetNamespace='{1}'. - {0} z popisu služby s oborem názvů targetNamespace {1} - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Položka soapbind:fault {0} u operace {1} v oddílu portType {2} z oboru názvů {3}. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Chyba {0} u operace {1} u vazby {2} z oboru názvů {3} - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} u operace {1} v oddílu portType {2} z oboru názvů {3}. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Zpráva {0} z popisu služby s oborem názvů targetNamespace={1} - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Část zprávy {0} pro zprávu {1} z oboru názvů {2} nebyla nalezena. - - - - Only objects of type OperationInput or OperationOutput may be added. - Přidat lze pouze objekty typu OperationInput nebo OperationOutput. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Přidat lze pouze atributy XmlElements nebo typy odvozené od typu ServiceDescriptionFormatExtension. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Operace {0} v oddílu portType {1} z oboru názvů {2} - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Operace {0} u vazby {1} z oboru názvů {2} - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Část {0} zprávy {1} z popisu služby s oborem názvů targetNamespace={2} - - - - Port '{0}' on service {1} from namespace='{2}'. - Port {0} u služby {1} z oboru názvů={2} - - - - Protocol with name '{0}' is not recognized. - Protokol s názvem {0} není rozpoznán. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Povinný atribut XmlFormatExtension nebyl ve třídě {0} nalezen. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - Schéma s oborem názvů targetNamespace={0} má neplatnou syntaxi. {1} řádek {2}, pozice {3} - - - - Schema validation error: {0} - Chyba ověřování schématu: {0} - - - - The syntax of type {0} may not be extended. - Syntaxi typu {0} nelze rozšířit. - - - - Error: {0} Line {1}, position {2}. - Chyba: {0} Řádek {1}, pozice {2} - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Definice {0} nebyla nalezena. Chybí popis služby s oborem názvů {1}. - - - - Element {0} named {1} from namespace {2} is missing. - Prvek {0} s názvem {1} z oboru názvů {2} nebyl nalezen. - - - - No more than one input and one output message may be specified. - Specifikovat lze pouze jednu vstupní a jednu výstupní zprávu. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Bylo určeno více vazeb s názvem {0}. Každá vazba musí mít jedinečný název. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Bylo určeno více chybových vazeb s názvem {0}. Každá chybová vazba musí mít jedinečný název. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Bylo určeno více rozšíření formátu s názvem {0}. Každé rozšíření formátu musí mít jedinečný název. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Bylo určeno více importů s názvem {0}. Každý import musí mít jedinečný název. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Bylo určeno více zpráv s názvem {0}. Každá zpráva musí mít jedinečný název. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Bylo určeno více částí zprávy s názvem {0}. Každá část zprávy musí mít jedinečný název. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Bylo určeno více operací s názvem {0}. Každá operace musí mít jedinečný název. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Bylo určeno více operačních vazeb s názvem {0}. Každá operační vazba musí mít jedinečný název. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Bylo určeno více operačních chyb s názvem {0}. Každá operační chyba musí mít jedinečný název. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Bylo určeno více operačních zpráv s názvem {0}. Každá operační zpráva musí mít jedinečný název. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Bylo určeno více portů s názvem {0}. Každý port musí mít jedinečný název. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Bylo určeno více typů portů s názvem {0}. Každý typ portu musí mít jedinečný název. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Bylo určeno více služeb s názvem {0}. Každá služba musí mít jedinečný název. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Bylo určeno více prvků {0} s názvem {1}. Každý prvek {0} musí mít jedinečný název. - - - - The value for '{0}' cannot be negative. - Hodnota {0} nemůže být záporná. - - - - Warning: {0} - Upozornění: {0} - - - - Warning: {0} Line {1}, position {2}. - Upozornění: {0} Řádek {1}, pozice {2} - - - - en - cs - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - Schéma s oborem názvů targetNamespace={0} má neplatnou syntaxi. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Ve schématu typu {1} z oboru názvů {2} byl deklarován odkaz na atribut {0}. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Zkontrolujte definici obsahu schématu typu {0} z oboru názvů {1}. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Ve schématu typu {1} z oboru názvů {2} byl deklarován odkaz na element {0}. - - - - Schema item '{1}' from namespace '{0}'. {2} - Položka schématu {1} z oboru názvů {0}. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - Položka schématu {1} s názvem {2} z oboru názvů {0} není platná. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.de.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.de.xlf deleted file mode 100644 index 1538f56c35f..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.de.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Bindung "{0}" aus dem Namespace "{1}". - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - Das Elementattribut ist bei codierten Nachrichtenteilen nicht zulässig. Der fehlerhafte Teil in der Nachricht "{1}" hat den Namen "{0}". - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Dienstbeschreibung mit targetNamespace="{0}". - - - - {0} from service description with targetNamespace='{1}'. - {0} aus Dienstbeschreibung mit targetNamespace="{1}". - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - soapbind:fault "{0}" für den Vorgang "{1}" des portType "{2}" aus dem Namespace "{3}". {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Fehler "{0}" für den Vorgang "{1}" der Bindung "{2}" aus dem Namespace "{3}". - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} für den Vorgang "{1}" des portType "{2}" aus dem Namespace "{3}". {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Nachricht "{0}" aus der Dienstbeschreibung mit targetNamespace="{1}". - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Der Nachrichtenteil "{0}" für die Nachricht "{1}" aus dem Namespace "{2}" fehlt. - - - - Only objects of type OperationInput or OperationOutput may be added. - Es können nur Objekte vom Typ OperationInput oder OperationOutput hinzugefügt werden. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Es können nur XmlElements oder Typen hinzugefügt werden, die von ServiceDescriptionFormatExtension abgeleitet sind. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Vorgang "{0}" für portType "{1}" aus Namespace "{2}". - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Vorgang "{0}" für Bindung "{1}" aus Namespace "{2}". - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Teil "{0}" der Nachricht "{1}" der Dienstbeschreibung mit targetNamespace="{2}". - - - - Port '{0}' on service {1} from namespace='{2}'. - Port "{0}" des Diensts {1} aus Namespace="{2}". - - - - Protocol with name '{0}' is not recognized. - Das Protokoll mit dem Namen "{0}" ist unbekannt. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Das für die {0}-Klasse erforderliche XmlFormatExtension-Attribut ist nicht vorhanden. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - Schema mit targetNamespace="{0}" weist eine ungültige Syntax auf. {1} Zeile {2}, Position {3}. - - - - Schema validation error: {0} - Schemavalidierungsfehler: {0} - - - - The syntax of type {0} may not be extended. - Die Syntax des {0}-Typs kann nicht erweitert werden. - - - - Error: {0} Line {1}, position {2}. - Fehler: {0} Zeile {1}, Position {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Die Definition für {0} wurde nicht gefunden. Die Dienstdefinition mit dem Namespace {1} fehlt. - - - - Element {0} named {1} from namespace {2} is missing. - Das {0}-Element mit dem Namen {1} aus dem Namespace {2} fehlt. - - - - No more than one input and one output message may be specified. - Es kann maximal eine Eingabe- und eine Ausgabenachricht angegeben werden. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Es wurden mehrere Bindungen mit dem Namen "{0}" angegeben. Jede Bindung muss einen eindeutigen Namen haben. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Es wurden mehrere Fehlerbindungen mit dem Namen "{0}" angegeben. Jede Fehlerbindung muss einen eindeutigen Namen haben. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Es wurden mehrere Formaterweiterungen mit dem Namen "{0}" angegeben. Jede Formaterweiterung muss einen eindeutigen Namen haben. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Es wurden mehrere Importvorgänge mit dem Namen "{0}" angegeben. Jeder Importvorgang muss einen eindeutigen Namen haben. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Es wurden mehrere Nachrichten mit dem Namen "{0}" angegeben. Jede Nachricht muss einen eindeutigen Namen haben. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Es wurden mehrere Nachrichtenteile mit dem Namen "{0}" angegeben. Jeder Nachrichtenteil muss einen eindeutigen Namen haben. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Es wurden mehrere Vorgänge mit dem Namen "{0}" angegeben. Jeder Vorgang muss einen eindeutigen Namen haben. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Es wurden mehrere Vorgangsbindungen mit dem Namen "{0}" angegeben. Jede Vorgangsbindung muss einen eindeutigen Namen haben. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Es wurden mehrere Vorgangsfehler mit dem Namen "{0}" angegeben. Jeder Vorgangsfehler muss einen eindeutigen Namen haben. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Es wurden mehrere Vorgangsmeldungen mit dem Namen "{0}" angegeben. Jede Vorgangsmeldung muss einen eindeutigen Namen haben. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Es wurden mehrere Ports mit dem Namen "{0}" angegeben. Jeder Port muss einen eindeutigen Namen haben. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Es wurden mehrere Porttypen mit dem Namen "{0}" angegeben. Jeder Porttyp muss einen eindeutigen Namen haben. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Es wurden mehrere Dienste mit dem Namen "{0}" angegeben. Jeder Dienst muss einen eindeutigen Namen haben. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Es wurden mehrere {0}-Elemente mit dem Namen "{1}" angegeben. Jedes {0}-Element muss einen eindeutigen Namen haben. - - - - The value for '{0}' cannot be negative. - Der Wert für "{0}" darf nicht negativ sein. - - - - Warning: {0} - Warnung: {0} - - - - Warning: {0} Line {1}, position {2}. - Warnung: {0}, Zeile {1}, Position {2}. - - - - en - de - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - Das Schema mit targetNamespace="{0}" weist eine ungültige Syntax auf. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Attributverweis "{0}" im Schematyp "{1}" aus dem Namespace "{2}" deklariert. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Überprüfen Sie die Inhaltsdefinition des Schematyps "{0}" aus dem Namespace "{1}". {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Elementverweis "{0}" im Schematyp "{1}" aus dem Namespace "{2}" deklariert. - - - - Schema item '{1}' from namespace '{0}'. {2} - Schemaelement "{1}" aus dem Namespace "{0}". {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - Das Schemaelement "{1}" mit dem Namen "{2}" aus dem Namespace "{0}" ist ungültig. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.es.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.es.xlf deleted file mode 100644 index 31cf0f625ef..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.es.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Enlace "{0}" del espacio de nombres "{1}". - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - El atributo element no se permite en partes de mensaje codificadas. La parte errónea del mensaje "{1}" se denomina "{0}". - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Descripción del servicio con targetNamespace="{0}". - - - - {0} from service description with targetNamespace='{1}'. - {0} de la descripción del servicio con targetNamespace="{1}". - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - El elemento soapbind:fault "{0}" en la operación "{1}" en el objeto portType "{2}" del espacio de nombres "{3}". {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Error "{0}" en la operación "{1}" en el enlace "{2}" del espacio de nombres "{3}". - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} en la operación "{1}" en el objeto portType "{2}" del espacio de nombres "{3}". {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Mensaje "{0}" de la descripción del servicio con targetNamespace="{1}". - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Falta la parte "{0}" del mensaje "{1}" del espacio de nombres "{2}". - - - - Only objects of type OperationInput or OperationOutput may be added. - Solo se pueden agregar objetos de tipo OperationInput u OperationOutput. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Solo se pueden agregar objetos XmlElement o tipos que deriven de ServiceDescriptionFormatExtension. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Operación "{0}" en el objeto portType "{1}" del espacio de nombres "{2}". - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Operación "{0}" en el enlace "{1}" del espacio de nombres "{2}". - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Parte "{0}" del mensaje "{1}" de la descripción del servicio con targetNamespace="{2}". - - - - Port '{0}' on service {1} from namespace='{2}'. - Puerto "{0}" en el servicio {1} del espacio de nombres "{2}". - - - - Protocol with name '{0}' is not recognized. - No se reconoce el protocolo con el nombre "{0}". - - - - Required XmlFormatExtension attribute is missing on class {0}. - El atributo XmlFormatExtension requerido falta en la clase {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - El esquema con targetNamespace="{0}" tiene una sintaxis no válida. {1} Línea {2}, posición {3}. - - - - Schema validation error: {0} - Error de validación de esquema: {0} - - - - The syntax of type {0} may not be extended. - La sintaxis de tipo {0} no se puede extender. - - - - Error: {0} Line {1}, position {2}. - Error: {0} Línea {1}, posición {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - No se puede encontrar la definición para {0}. Falta la descripción de servicios con el espacio de nombres "{1}". - - - - Element {0} named {1} from namespace {2} is missing. - Falta el elemento {0} denominado {1} del espacio de nombres {2}. - - - - No more than one input and one output message may be specified. - No puede especificar más de un mensaje entrante y uno saliente. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Se especificó más de un enlace denominado "{0}". Cada enlace debe tener un nombre único. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Se especificó más de un enlace de error denominado "{0}". Cada enlace de error debe tener un nombre único. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Se especificó más de una extensión de formato denominada "{0}". Cada extensión de formato debe tener un nombre único. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Se especificó más de una importación denominada "{0}". Cada importación debe tener un nombre único. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Se especificó más de un mensaje denominado "{0}". Cada mensaje debe tener un nombre único. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Se especificó más de una parte de mensaje denominada "{0}". Cada parte de mensaje debe tener un nombre único. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Se especificó más de una operación denominada "{0}". Cada operación debe tener un nombre único. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Se especificó más de un enlace de operación denominado "{0}". Cada enlace de operación debe tener un nombre único. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Se especificó más de un error de operación denominado "{0}". Cada error de operación debe tener un nombre único. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Se especificó más de un mensaje de operación denominado "{0}". Cada mensaje de operación debe tener un nombre único. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Se especificó más de un puerto denominado "{0}". Cada puerto debe tener un nombre único. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Se especificó más de un tipo de puerto denominado "{0}". Cada tipo de puerto debe tener un nombre único. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Se especificó más de un servicio denominado "{0}". Cada servicio debe tener un nombre único. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Se especificó más de un {0} denominado "{1}". Cada {0} debe tener un nombre único. - - - - The value for '{0}' cannot be negative. - El valor de "{0}" no puede ser negativo. - - - - Warning: {0} - Advertencia: {0} - - - - Warning: {0} Line {1}, position {2}. - Advertencia: {0} Línea {1}, posición {2}. - - - - en - es - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - El esquema con targetNamespace="{0}" tiene una sintaxis no válida. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Referencia de atributo "{0}" declarada en el tipo de esquema "{1}" del espacio de nombres "{2}". - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Compruebe la definición de contenido del tipo de esquema "{0}" del espacio de nombres "{1}". {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Referencia de elemento "{0}" declarada en el tipo de esquema "{1}" del espacio de nombres "{2}". - - - - Schema item '{1}' from namespace '{0}'. {2} - Elemento de esquema "{1}" del espacio de nombres "{0}". {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - El elemento de esquema "{1}" denominado "{2}" del espacio de nombres "{0}" no es válido. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.fr.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.fr.xlf deleted file mode 100644 index 49335e83ef6..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.fr.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Liaison '{0}' de l'espace de noms '{1}'. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - L'attribut element n'est pas autorisé sur les parties de message encodées. La partie erronée s'appelle '{0}' dans le message '{1}'. - - - - CODEGEN: {0} - CODEGEN : {0} - - - - Service description with targetNamespace='{0}'. - Description de service avec targetNamespace='{0}'. - - - - {0} from service description with targetNamespace='{1}'. - {0} de la description de service avec targetNamespace='{1}'. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - soapbind:fault '{0}' durant l'opération '{1}' sur le portType '{2}' de l'espace de noms '{3}'. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Erreur '{0}' durant l'opération '{1}' sur la liaison '{2}' de l'espace de noms '{3}'. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} durant l'opération '{1}' sur le portType '{2}' de l'espace de noms '{3}'. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Message '{0}' de la description de service avec targetNamespace='{1}'. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Partie du message '{0}' manquante pour le message '{1}' de l'espace de noms '{2}'. - - - - Only objects of type OperationInput or OperationOutput may be added. - Seuls des objets de type OperationInput ou OperationOutput peuvent être ajoutés. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Seuls les XmlElements ou les types dérivant de ServiceDescriptionFormatExtension peuvent être ajoutés. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Opération '{0}' sur le portType '{1}' de l'espace de noms '{2}'. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Opération '{0}' sur la liaison '{1}' de l'espace de noms '{2}'. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Partie '{0}' du message '{1}' de la description de service avec targetNamespace='{2}'. - - - - Port '{0}' on service {1} from namespace='{2}'. - Port '{0}' du service {1} de l'espace de noms='{2}'. - - - - Protocol with name '{0}' is not recognized. - Le protocole portant le nom '{0}' n'est pas reconnu. - - - - Required XmlFormatExtension attribute is missing on class {0}. - L'attribut XmlFormatExtension nécessaire est manquant dans la classe {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - Le schéma avec targetNamespace='{0}' a une syntaxe non valide. {1} Ligne {2}, position {3}. - - - - Schema validation error: {0} - Erreur de validation de schéma : {0} - - - - The syntax of type {0} may not be extended. - La syntaxe du type {0} ne doit pas être étendue. - - - - Error: {0} Line {1}, position {2}. - Erreur : {0} ligne {1}, position {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Impossible de localiser une définition pour {0}. Description du service manquante avec l'espace de noms {1}. - - - - Element {0} named {1} from namespace {2} is missing. - Élément {0} manquant nommé {1} de l'espace de noms {2}. - - - - No more than one input and one output message may be specified. - Seule une entrée et un message d'entrée peuvent être spécifiés. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Plusieurs liaisons nommées '{0}' ont été spécifiées. Chaque liaison doit avoir un nom unique. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Plusieurs liaisons d'erreur nommées '{0}' ont été spécifiées. Chaque liaison d'erreur doit avoir un nom unique. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Plusieurs extensions de format nommées '{0}' ont été spécifiées. Chaque extension de format doit avoir un nom unique. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Plusieurs importations nommées '{0}' ont été spécifiées. Chaque importation doit avoir un nom unique. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Plusieurs messages nommés '{0}' ont été spécifiés. Chaque message doit avoir un nom unique. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Plusieurs parties de message nommées '{0}' ont été spécifiées. Chaque partie de message doit avoir un nom unique. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Plusieurs opérations nommées '{0}' ont été spécifiées. Chaque opération doit avoir un nom unique. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Plusieurs liaisons d'opération nommées '{0}' ont été spécifiées. Chaque liaison d'opération doit avoir un nom unique. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Plusieurs erreurs d'opération nommées '{0}' ont été spécifiées. Chaque erreur d'opération doit avoir un nom unique. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Plusieurs messages d'opération nommés '{0}' ont été spécifiés. Chaque message d'opération doit avoir un nom unique. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Plusieurs ports nommés '{0}' ont été spécifiés. Chaque port doit avoir un nom unique. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Plusieurs types de port nommés '{0}' ont été spécifiés. Chaque type de port doit avoir un nom unique. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Plusieurs services nommés '{0}' ont été spécifiés. Chaque service doit avoir un nom unique. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Plusieurs {0} nommés '{1}' ont été spécifiés. Chaque {0} doit avoir un nom unique. - - - - The value for '{0}' cannot be negative. - La valeur pour '{0}' ne peut pas être négative. - - - - Warning: {0} - Avertissement : {0} - - - - Warning: {0} Line {1}, position {2}. - Avertissement : {0} ligne {1}, position {2}. - - - - en - fr - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - Le schéma avec targetNamespace='{0}' a une syntaxe non valide. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Référence d'attribut '{0}' déclarée dans le type de schéma '{1}' de l'espace de noms '{2}'. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Vérifiez la définition de contenu du type de schéma '{0}' dans l'espace de noms '{1}'. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Référence d'élément '{0}' déclarée dans le type de schéma '{1}' de l'espace de noms '{2}'. - - - - Schema item '{1}' from namespace '{0}'. {2} - Élément de schéma '{1}' de l'espace de noms '{0}'. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - L'élément de schéma '{1}' nommé '{2}' de l'espace de noms '{0}' est non valide. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.it.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.it.xlf deleted file mode 100644 index 45d6d448111..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.it.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Binding '{0}' dello spazio dei nomi '{1}'. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - L'attributo element non è consentito in parti di messaggio codificate. Il nome della parte non corretta è '{0}' nel messaggio '{1}'. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Descrizione del servizio con targetNamespace='{0}'. - - - - {0} from service description with targetNamespace='{1}'. - Elemento {0} della descrizione del servizio con targetNamespace='{1}'. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Elemento soapbind:fault '{0}' per l'operazione '{1}' su portType '{2}' dello spazio dei nomi '{3}'. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Errore '{0}' nell'operazione '{1}' sul binding '{2}' dello spazio dei nomi '{3}'. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Elemento {0} nell'operazione '{1}' su portType '{2}' dello spazio dei nomi '{3}'. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Messaggio '{0}' della descrizione del servizio con targetNamespace='{1}'. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Manca la parte '{0}' del messaggio '{1}' dello spazio dei nomi '{2}'. - - - - Only objects of type OperationInput or OperationOutput may be added. - È possibile aggiungere solo oggetti di tipo OperationInput o OperationOutput. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - È possibile aggiungere solo XmlElement o tipi che derivano da ServiceDescriptionFormatExtension. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Operazione '{0}' su portType '{1}' dello spazio dei nomi '{2}'. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Operazione '{0}' sul binding '{1}' dello spazio dei nomi '{2}'. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Parte '{0}' del messaggio '{1}' della descrizione del servizio con targetNamespace='{2}'. - - - - Port '{0}' on service {1} from namespace='{2}'. - Porta '{0}' sul servizio {1} dello spazio dei nomi '{2}'. - - - - Protocol with name '{0}' is not recognized. - Il protocollo denominato '{0}' non è riconosciuto. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Manca l'attributo obbligatorio XmlFormatExtension per la classe {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - La sintassi dello schema con targetNamespace='{0}' non è valida. {1} Riga {2}, posizione {3}. - - - - Schema validation error: {0} - Errore di convalida dello schema: {0} - - - - The syntax of type {0} may not be extended. - Non è possibile estendere la sintassi di tipo {0}. - - - - Error: {0} Line {1}, position {2}. - Errore: {0} Riga {1}, posizione {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Non è stata trovata alcuna definizione per {0}. Manca la descrizione del servizio con spazio dei nomi {1}. - - - - Element {0} named {1} from namespace {2} is missing. - Manca l'elemento {0} denominato {1} dello spazio dei nomi {2}. - - - - No more than one input and one output message may be specified. - Non è possibile specificare più di un messaggio di input e di un messaggio di output. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Sono stati specificati più binding denominati '{0}'. I nomi dei binding devono essere univoci. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Sono stati specificati più binding di errore denominati '{0}'. I nomi dei binding di errore devono essere univoci. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Sono state specificate più estensioni di formato denominate '{0}'. I nomi delle estensioni di formato devono essere univoci. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Sono state specificate più importazioni denominate '{0}'. I nomi delle importazioni devono essere univoci. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Sono stati specificati più messaggi denominati '{0}'. I nomi dei messaggi devono essere univoci. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Sono state specificate più parti di messaggio denominate '{0}'. I nomi delle parti di messaggio devono essere univoci. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Sono state specificate più operazioni denominate '{0}'. I nomi delle operazioni devono essere univoci. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Sono stati specificati più binding di operazione denominati '{0}'. I nomi dei binding di operazione devono essere univoci. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Sono stati specificati più errori di operazione denominati '{0}'. I nomi degli errori di operazione devono essere univoci. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Sono stati specificati più messaggi di operazione denominati '{0}'. I nomi dei messaggi di operazione devono essere univoci. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Sono state specificate più porte denominate '{0}'. I nomi delle porte devono essere univoci. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Sono stati specificati più tipi di porta denominati '{0}'. I nomi dei tipi di porta devono essere univoci. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Sono stati specificati più servizi denominati '{0}'. I nomi dei servizi devono essere univoci. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Sono stati specificati più elementi {0} denominati '{1}'. I nomi degli elementi {0} devono essere univoci. - - - - The value for '{0}' cannot be negative. - Il valore di '{0}' non può essere negativo. - - - - Warning: {0} - Avviso: {0} - - - - Warning: {0} Line {1}, position {2}. - Avviso: {0} Riga {1}, posizione {2}. - - - - en - it - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - La sintassi dello schema con targetNamespace='{0}' non è valida. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Riferimento di attributo '{0}' dichiarato nel tipo di schema '{1}' dello spazio dei nomi '{2}'. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Controllare la definizione del contenuto del tipo di schema '{0}' dello spazio dei nomi '{1}'. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Riferimento all'elemento '{0}' dichiarato nel tipo di schema '{1}' dello spazio dei nomi '{2}'. - - - - Schema item '{1}' from namespace '{0}'. {2} - Elemento dello schema '{1}' dello spazio dei nomi '{0}'. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - L'elemento dello schema '{1}' denominato '{2}' dello spazio dei nomi '{0}' non è valido. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ja.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ja.xlf deleted file mode 100644 index 45de5098238..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ja.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - 名前空間 '{1}' のバインド '{0}' です。 - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - 要素属性をエンコードされたメッセージ パーツで使用することはできません。エラーを含んだパーツには、メッセージ '{1}' で '{0}' という名前が指定されています。 - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - targetNamespace='{0}' のサービスの説明です。 - - - - {0} from service description with targetNamespace='{1}'. - targetNamespace='{1}' のサービスの説明 {0} です。 - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 名前空間 '{3}' の portType '{2}' にある操作 '{1}' の soapbind:fault '{0}' です。{4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - 名前空間 '{3}' のバインド '{2}' にある操作 '{1}' のフォールト '{0}' です。 - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 名前空間 '{3}' の portType '{2}' にある操作 '{1}' の '{0}' です。{4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - targetNamespace='{1}' のサービスの説明にあるメッセージ '{0}' です。 - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - 名前空間 '{2}' からのメッセージ '{1}' でメッセージ パーツ '{0}' がありません。 - - - - Only objects of type OperationInput or OperationOutput may be added. - 型 OperationInput または OperationOutput のオブジェクトのみを追加できます。 - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - ServiceDescriptionFormatExtension から派生する XmlElements または型のみを追加できます。 - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - 名前空間 '{2}' からの portType '{1}' 上の操作 '{0}' です。 - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - 名前空間 '{2}' からのバインディング '{1}' 上の操作 '{0}' です。 - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - targetNamespace='{2}' を含むサービスの説明の、メッセージ '{1}' のパート '{0}' です。 - - - - Port '{0}' on service {1} from namespace='{2}'. - namespace='{2}' からのサービス {1} 上のポート '{0}' です。 - - - - Protocol with name '{0}' is not recognized. - '{0}' という名前のプロトコルは認識されません。 - - - - Required XmlFormatExtension attribute is missing on class {0}. - 必要な XmlFormatExtension 属性がクラス {0} に見つかりません。 - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - targetNamespace='{0}' を持つスキーマの構文が無効です。{1} 行 {2}、位置 {3}。 - - - - Schema validation error: {0} - スキーマの検証エラー: {0} - - - - The syntax of type {0} may not be extended. - 型 {0} の構文を拡張することはできません。 - - - - Error: {0} Line {1}, position {2}. - エラー: {0} 行 {1}、位置 {2}。 - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - {0} の定義が見つかりません。名前空間 {1} のサービスの説明がありません。 - - - - Element {0} named {1} from namespace {2} is missing. - 名前空間 '{2}' からの '{1}' という名前の要素 {0} がありません。 - - - - No more than one input and one output message may be specified. - 2 つ以上の入力および出力メッセージを指定することはできません。 - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - '{0}' という名前のバインドが 1 つ以上指定されました。各バインドに一意の名前を指定しなければなりません。 - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - '{0}' という名前のフォールト バインドが 1 つ以上指定されました。各フォールト バインドに一意の名前を指定しなければなりません。 - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - '{0}' という名前のフォーマット拡張が 1 つ以上指定されました。各フォーマット拡張には一意の名前を指定しなければなりません。 - - - - More than one import named '{0}' was specified. Each import must have a unique name. - '{0}' という名前のインポートが 1 つ以上指定されました。各インポートに一意の名前の指定しなければなりません。 - - - - More than one message named '{0}' was specified. Each message must have a unique name. - '{0}' という名前のメッセージが 1 つ以上指定されました。各メッセージに一意の名前を指定しなければなりません。 - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - '{0}' という名前のメッセージ パーツが 1 つ以上指定されました。各メッセージ パーツに一意の名前を指定しなければなりません。 - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - '{0}' という名前の操作が 1 つ以上指定されました。各操作に一意の名前を指定しなければなりません。 - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - '{0}' という名前の操作バインドが 1 つ以上指定されました。各操作バインドに一意の名前を指定しなければなりません。 - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - '{0}' という名前の操作フォールトが 1 つ以上指定されました。各操作フォールトに一意の名前を指定しなければなりません。 - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - '{0}' という名前の操作メッセージが 1 つ以上指定されました。各操作メッセージに一意の名前を指定しなければなりません。 - - - - More than one port named '{0}' was specified. Each port must have a unique name. - '{0}' という名前のポートが 1 つ以上指定されました。各ポートに一意の名前を指定しなければなりません。 - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - '{0}' という名前のポートの種類が 1 つ以上指定されました。各ポートの種類に一意の名前を指定しなければなりません。 - - - - More than one service named '{0}' was specified. Each service must have a unique name. - '{0}' という名前のサービスが 1 つ以上指定されました。各サービスに一意の名前を指定しなければなりません。 - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - '{1}' という名前の {0} が 1 つ以上指定されました。各 {0} に一意の名前を指定しなければなりません。 - - - - The value for '{0}' cannot be negative. - '{0}' を負の値にすることはできません。 - - - - Warning: {0} - 警告: {0} - - - - Warning: {0} Line {1}, position {2}. - 警告: {0} 行 {1}、位置 {2}。 - - - - en - ja - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - targetNamespace='{0}' を持つスキーマの構文が無効です。{1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 名前空間 '{2}' のスキーマの型 '{1}' に属性の参照 '{0}' が宣言されています。 - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - 名前空間 '{1}' のスキーマの型 '{0}' のコンテンツの定義を確認してください。{2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 名前空間 '{2}' のスキーマの型 '{1}' に要素の参照 '{0}' が宣言されています。 - - - - Schema item '{1}' from namespace '{0}'. {2} - 名前空間 '{0}' のスキーマ アイテム '{1}'。{2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - 名前空間 '{1}' からの {2} という名前のスキーマ アイテム '{0}' は無効です。{3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ko.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ko.xlf deleted file mode 100644 index c77129e7d13..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ko.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - 네임스페이스 '{1}'의 바인딩 '{0}'입니다. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - 인코딩된 메시지 부분에는 요소 특성을 사용할 수 없습니다. '{1}' 메시지에서 오류 부분은 '{0}'(으)로 명명됩니다. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - targetNamespace='{0}'인 서비스 설명입니다. - - - - {0} from service description with targetNamespace='{1}'. - targetNamespace='{1}'인 서비스 설명의 {0}입니다. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - soapbind: 네임스페이스 '{3}'의 portType '{2}'에 대한 작업 '{1}'의 오류 '{0}'입니다. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - 네임스페이스 '{3}'의 바인딩 '{2}'에 대한 작업 '{1}'의 오류 '{0}'입니다. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 네임스페이스 '{3}'의 portType '{2}'에 대한 작업 '{1}'의 {0}입니다. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - targetNamespace='{1}'인 서비스 설명의 '{0}' 메시지입니다. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - 네임스페이스 '{2}'에서 '{1}' 메시지에 대한 메시지 부분 '{0}'이(가) 없습니다. - - - - Only objects of type OperationInput or OperationOutput may be added. - OperationInput 또는 OperationOutput 형식의 개체만 추가할 수 있습니다. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - XmlElements 또는 ServiceDescriptionFormatExtension에서 파생되는 형식만 추가할 수 있습니다. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - 네임스페이스 '{2}'의 portType '{1}'에 대한 작업 '{0}'입니다. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - 네임스페이스 '{2}'의 바인딩 '{1}'에 대한 작업 '{0}'입니다. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - targetNamespace='{2}'인 서비스 설명자의 '{1}' 메시지 중 '{0}' 부분입니다. - - - - Port '{0}' on service {1} from namespace='{2}'. - namespace='{2}'의 {1} 서비스에 대한 '{0}' 포트입니다. - - - - Protocol with name '{0}' is not recognized. - 이름이 '{0}'인 프로토콜을 인식할 수 없습니다. - - - - Required XmlFormatExtension attribute is missing on class {0}. - 필요한 XmlFormatExtension 특성이 {0} 클래스에 없습니다. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - targetNamespace='{0}'인 스키마에 잘못된 구문이 있습니다. {1} 줄 {2}, 위치 {3}. - - - - Schema validation error: {0} - 스키마 유효성 검사 오류: {0} - - - - The syntax of type {0} may not be extended. - {0} 형식의 구문을 확장할 수 없습니다. - - - - Error: {0} Line {1}, position {2}. - 오류: {0} 줄 {1}, 위치 {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - {0}에 대한 정의를 찾을 수 없습니다. 네임스페이스가 {1}인 서비스 정의가 없습니다. - - - - Element {0} named {1} from namespace {2} is missing. - 네임스페이스 {2}에 이름이 {1}인 {0} 요소가 없습니다. - - - - No more than one input and one output message may be specified. - 입력/출력 메시지를 하나씩만 지정할 수 있습니다. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - 이름이 '{0}'인 바인딩이 두 개 이상 지정되었습니다. 각 바인딩은 고유한 이름을 가져야 합니다. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - 이름이 '{0}'인 오류 바인딩이 두 개 이상 지정되었습니다. 각 오류 바인딩은 고유한 이름을 가져야 합니다. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - 이름이 '{0}'인 형식 확장이 두 개 이상 지정되었습니다. 각 형식 확장은 고유한 이름을 가져야 합니다. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - 이름이 '{0}'인 가져오기가 두 개 이상 지정되었습니다. 각 가져오기는 고유한 이름을 가져야 합니다. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - 이름이 '{0}'인 메시지가 두 개 이상 지정되었습니다. 각 메시지는 고유한 이름을 가져야 합니다. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - 이름이 '{0}'인 메시지 부분이 두 개 이상 지정되었습니다. 각 메시지 부분은 고유한 이름을 가져야 합니다. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - 이름이 '{0}'인 작업이 두 개 이상 지정되었습니다. 각 작업은 고유한 이름을 가져야 합니다. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - 이름이 '{0}'인 작업 바인딩이 두 개 이상 지정되었습니다. 각 작업 바인딩은 고유한 이름을 가져야 합니다. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - 이름이 '{0}'인 작업 오류가 두 개 이상 지정되었습니다. 각 작업 오류는 고유한 이름을 가져야 합니다. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - 이름이 '{0}'인 작업 메시지가 두 개 이상 지정되었습니다. 각 작업 메시지는 고유한 이름을 가져야 합니다. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - 이름이 '{0}'인 포트가 두 개 이상 지정되었습니다. 각 포트는 고유한 이름을 가져야 합니다. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - 이름이 '{0}'인 포트 종류가 두 개 이상 지정되었습니다. 각 포트 종류는 고유한 이름을 가져야 합니다. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - 이름이 '{0}'인 서비스가 두 개 이상 지정되었습니다. 각 서비스는 고유한 이름을 가져야 합니다. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - 이름이 '{1}'인 {0}이(가) 두 개 이상 지정되었습니다. 각 {0}은(는) 고유한 이름을 가져야 합니다. - - - - The value for '{0}' cannot be negative. - '{0}'의 값은 음수일 수 없습니다. - - - - Warning: {0} - 경고: {0} - - - - Warning: {0} Line {1}, position {2}. - 경고: {0} 줄 {1}, 위치 {2}. - - - - en - ko - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - targetNamespace='{0}'인 스키마의 구문이 잘못되었습니다. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 네임스페이스 '{2}'의 스키마 형식 '{1}'에서 특성 참조 '{0}'이(가) 선언되었습니다. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - 네임스페이스 '{1}'에서 스키마 형식 '{0}'의 콘텐츠 정의를 확인하세요. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 네임스페이스 '{2}'의 스키마 테이블 '{1}'에서 요소 참조 '{0}'이(가) 선언되었습니다. - - - - Schema item '{1}' from namespace '{0}'. {2} - 네임스페이스 '{0}'의 스키마 항목 '{1}'입니다. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - 네임스페이스 '{0}'의 '{2}'(이)라는 스키마 항목 '{1}'이(가) 잘못되었습니다. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pl.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pl.xlf deleted file mode 100644 index 28f47d92113..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pl.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Powiązanie „{0}” z przestrzeni nazw „{1}”. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - Atrybut elementu jest niedozwolony w zakodowanych częściach komunikatu. Cześć zawierająca błąd ma nazwę „{0}” i znajduje się w komunikacie „{1}”. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Opis usługi z elementem targetNamespace=„{0}”. - - - - {0} from service description with targetNamespace='{1}'. - Obiekt {0} z opisu usługi z elementem targetNamespace=„{1}”. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Element soapbind:fault „{0}” w operacji „{1}” dotyczącej elementu portType „{2}” z przestrzeni nazw „{3}”. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Błąd „{0}” w operacji „{1}” dotyczącej powiązania „{2}” z przestrzeni nazw „{3}”. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Element {0} w operacji „{1}” dotyczącej elementu portType „{2}” z przestrzeni nazw „{3}”. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Komunikat „{0}” z opisu usługi z elementem targetNamespace=„{1}”. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Brak części „{0}” komunikatu „{1}” z przestrzeni nazw „{2}”. - - - - Only objects of type OperationInput or OperationOutput may be added. - Dodawane mogą być tylko obiekty typu OperationInput lub OperationOutput. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Dodawane mogą być tylko elementy XmlElement lub typy pochodzące od elementu ServiceDescriptionFormatExtension. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Operacja „{0}” dotycząca elementu portType „{1}” z przestrzeni nazw „{2}”. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Operacja „{0}” dotycząca powiązania „{1}” z przestrzeni nazw „{2}”. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Część „{0}” komunikatu „{1}” z opisu usługi z elementem targetNamespace=„{2}”. - - - - Port '{0}' on service {1} from namespace='{2}'. - Port „{0}” dotyczący usługi „{1}” z przestrzeni nazw „{2}”. - - - - Protocol with name '{0}' is not recognized. - Nie rozpoznano protokołu o nazwie „{0}”. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Brak wymaganego atrybutu XmlFormatExtension dla klasy {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - Schemat z elementem targetNamespace=„{0}” ma nieprawidłową składnię. {1} — wiersz: {2}, pozycja: {3}. - - - - Schema validation error: {0} - Błąd weryfikacji schematu: {0} - - - - The syntax of type {0} may not be extended. - Składnia typu {0} nie może zostać rozszerzona. - - - - Error: {0} Line {1}, position {2}. - Błąd: {0}, wiersz {1}, pozycja {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Nie można odnaleźć definicji {0}. Brak opisu usługi z przestrzenią nazw {1}. - - - - Element {0} named {1} from namespace {2} is missing. - Brak elementu {0} o nazwie {1} z przestrzeni nazw {2}. - - - - No more than one input and one output message may be specified. - Nie można określić więcej niż jednego komunikatu wejściowego i jednego komunikatu wyjściowego. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Określono więcej niż jedno powiązanie o nazwie „{0}”. Nazwa każdego powiązania musi być unikatowa. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Określono więcej niż jedno powiązanie błędu o nazwie „{0}”. Nazwa każdego powiązania błędu musi być unikatowa. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Określono więcej niż jedno rozszerzenie formatu o nazwie „{0}”. Nazwa każdego rozszerzenia formatu musi być unikatowa. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Określono więcej niż jedną operację importowania o nazwie „{0}”. Nazwa każdej operacji importowania musi być unikatowa. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Określono więcej niż jeden komunikat o nazwie „{0}”. Nazwa każdego komunikatu musi być unikatowa. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Określono więcej niż jedną część komunikatu o nazwie „{0}”. Nazwa każdej części komunikatu musi być unikatowa. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Określono więcej niż jedną operację o nazwie „{0}”. Nazwa każdej operacji musi być unikatowa. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Określono więcej niż jedno powiązanie operacji o nazwie „{0}”. Nazwa każdego powiązania operacji musi być unikatowa. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Określono więcej niż jeden błąd operacji o nazwie „{0}”. Nazwa każdego błędu operacji musi być unikatowa. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Określono więcej niż jeden komunikat operacji o nazwie „{0}”. Nazwa każdego komunikatu operacji musi być unikatowa. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Określono więcej niż jeden port o nazwie „{0}”. Nazwa każdego portu musi być unikatowa. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Określono więcej niż jeden typ portu o nazwie „{0}”. Nazwa każdego typu portu musi być unikatowa. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Określono więcej niż jedną usługę o nazwie „{0}”. Nazwa każdej usługi musi być unikatowa. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Określono więcej niż jeden element {0} o nazwie „{1}”. Nazwa każdego elementu {0} musi być unikatowa. - - - - The value for '{0}' cannot be negative. - Wartość „{0}” nie może być ujemna. - - - - Warning: {0} - Ostrzeżenie: {0} - - - - Warning: {0} Line {1}, position {2}. - Ostrzeżenie: {0}, wiersz {1}, pozycja {2}. - - - - en - pl - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - Schemat z elementem targetNamespace=„{0}” ma nieprawidłową składnię. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Odwołanie do atrybutu „{0}” zostało zadeklarowane w typie schematu „{1}” z przestrzeni nazw „{2}”. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Sprawdź definicję zawartości typu schematu „{0}” z przestrzeni nazw „{1}”. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Odwołanie do elementu „{0}” zostało zadeklarowane w typie schematu „{1}” z przestrzeni nazw „{2}”. - - - - Schema item '{1}' from namespace '{0}'. {2} - Element schematu „{1}” z przestrzeni nazw „{0}”. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - Element schematu „{1}” o nazwie „{2}” z przestrzeni nazw „{0}” jest nieprawidłowy. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pt-BR.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pt-BR.xlf deleted file mode 100644 index d3285062f3d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.pt-BR.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Associação '{0}' do namespace '{1}'. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - O atributo de elemento não é permitido nas partes da mensagem codificada. A parte incorreta é chamada '{0}' na mensagem '{1}'. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Descrição de serviço com targetNamespace='{0}'. - - - - {0} from service description with targetNamespace='{1}'. - {0} da descrição de serviço com targetNamespace='{1}'. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - soapbind:fault '{0}' na operação '{1}' em portType '{2}' do namespace '{3}'. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Falha '{0}' na operação '{1}' na associação '{2}' do namespace '{3}'. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} na operação '{1}' em portType '{2}' do namespace '{3}'. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Mensagem '{0}' da descrição de serviço com targetNamespace='{1}'. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Parte '{0}' da mensagem '{1}' ausente do namespace '{2}'. - - - - Only objects of type OperationInput or OperationOutput may be added. - Somente objetos do tipo OperationInput ou OperationOutput podem ser adicionados. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Somente XmlElements ou tipos derivados de ServiceDescriptionFormatExtension podem ser adicionados. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Operação '{0}' em portType '{1}' do namespace '{2}'. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Operação '{0}' na associação '{1}' do namespace '{2}'. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Parte '{0}' da mensagem '{1}' da descrição de serviço com targetNamespace='{2}'. - - - - Port '{0}' on service {1} from namespace='{2}'. - Porta '{0}' no serviço {1} do namespace='{2}'. - - - - Protocol with name '{0}' is not recognized. - O protocolo chamado '{0}' não é reconhecido. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Atributo XmlFormatExtension necessário ausente da classe {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - O esquema com targetNamespace='{0}' tem sintaxe inválida. {1} Linha {2}, posição {3}. - - - - Schema validation error: {0} - Erro de validação do esquema: {0} - - - - The syntax of type {0} may not be extended. - A sintaxe do tipo {0} pode não ser estendida. - - - - Error: {0} Line {1}, position {2}. - Erro: {0} Linha {1}, posição {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Não é possível encontrar a definição para {0}. A Descrição de Serviço com namespace {1} está ausente. - - - - Element {0} named {1} from namespace {2} is missing. - O elemento {0} denominado {1} do namespace {2} está ausente. - - - - No more than one input and one output message may be specified. - Não é possível especificar mais de uma mensagem de entrada e uma de saída. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Mais de uma associação denominada '{0}' foi especificada. Cada associação deve ter um nome exclusivo. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Mais de uma associação de falha denominada '{0}' foi especificada. Cada associação de falha deve ter um nome exclusivo. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Mais de uma extensão de formato denominada '{0}' foi especificada. Cada extensão de formato deve ter um nome exclusivo. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Mais de uma importação denominada '{0}' foi especificada. Cada importação deve ter um nome exclusivo. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Mais de uma mensagem denominada '{0}' foi especificada. Cada mensagem deve ter um nome exclusivo. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Mais de uma parte de mensagem denominada '{0}' foi especificada. Cada parte de mensagem deve ter um nome exclusivo. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Mais de uma operação denominada '{0}' foi especificada. Cada operação deve ter um nome exclusivo. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Mais de uma associação de operação denominada '{0}' foi especificada. Cada associação de operação deve ter um nome exclusivo. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Mais de uma falha de operação denominada '{0}' foi especificada. Cada falha de operação deve ter um nome exclusivo. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Mais de uma mensagem de operação denominada '{0}' foi especificada. Cada mensagem de operação deve ter um nome exclusivo. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Mais de uma porta denominada '{0}' foi especificada. Cada porta deve ter um nome exclusivo. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Mais de um tipo de porta denominado '{0}' foi especificado. Cada tipo de porta deve ter um nome exclusivo. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Mais de um serviço denominado '{0}' foi especificado. Cada serviço deve ter um nome exclusivo. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Mais de um {0} denominado '{1}' foi especificado. Cada {0} deve ter um nome exclusivo. - - - - The value for '{0}' cannot be negative. - O valor de '{0}' não pode ser negativo. - - - - Warning: {0} - Aviso: {0} - - - - Warning: {0} Line {1}, position {2}. - Aviso: {0} Linha {1}, posição {2}. - - - - en - pt - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - O esquema com targetNamespace='{0}' tem sintaxe inválida. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Referência de atributo '{0}' declarada no tipo de esquema '{1}' do namespace '{2}'. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Verifique a definição de conteúdo do tipo de esquema'{0}' do namespace '{1}'. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Referência de elemento '{0}' declarada no tipo de esquema '{1}' do namespace '{2}'. - - - - Schema item '{1}' from namespace '{0}'. {2} - Item de esquema '{1}' do namespace '{0}'. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - O item de esquema '{1}' denominado '{2}' do namespace '{0}' é inválido. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ru.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ru.xlf deleted file mode 100644 index 3ed90c4924d..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.ru.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - Привязка "{0}" из пространства имен "{1}". - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - Атрибуты элемента в зашифрованных частях сообщения не разрешены. В сообщении "{1}" ошибочна часть "{0}". - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - Описание службы с targetNamespace="{0}". - - - - {0} from service description with targetNamespace='{1}'. - {0} из описания службы с targetNamespace="{1}". - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - Ошибка soapbind:fault "{0}" при выполнении операции "{1}" с portType "{2}" из пространства имен "{3}". {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - Ошибка "{0}" при выполнении операции "{1}" привязки "{2}" из пространства имен "{3}". - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - {0} при выполнении операции "{1}" с portType "{2}" из пространства имен "{3}". {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - Сообщение "{0}" из описания службы с targetNamespace="{1}". - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - Отсутствует часть "{0}" сообщения "{1}" из пространства имен "{2}". - - - - Only objects of type OperationInput or OperationOutput may be added. - Разрешено добавление только объектов с типами OperationInput и OperationOutput. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Разрешено добавление только XmlElement или типов, производных от ServiceDescriptionFormatExtension. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - Операция "{0}" с portType "{1}" из пространства имен "{2}". - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - Операция "{0}" с привязкой "{1}" из пространства имен "{2}". - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - Часть "{0}" сообщения "{1}" из описания службы с targetNamespace="{2}". - - - - Port '{0}' on service {1} from namespace='{2}'. - Порт "{0}" для службы {1} из пространства имен "{2}". - - - - Protocol with name '{0}' is not recognized. - Протокол с именем "{0}" не распознан. - - - - Required XmlFormatExtension attribute is missing on class {0}. - Отсутствует обязательный атрибут XmlFormatExtension класса {0}. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - Схема с targetNamespace="{0}" имеет недопустимый синтаксис. {1} Строка {2}, позиция {3}. - - - - Schema validation error: {0} - Ошибка при проверке правильности схемы: {0} - - - - The syntax of type {0} may not be extended. - Синтаксис типа {0} не поддается расширению. - - - - Error: {0} Line {1}, position {2}. - Ошибка: {0}. Строка {1}, позиция {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - Невозможно найти определение {0}. Отсутствует описание службы с пространством имен {1}. - - - - Element {0} named {1} from namespace {2} is missing. - Отсутствует элемент {0} с именем {1} из пространства имен {2}. - - - - No more than one input and one output message may be specified. - Возможно задание не более одного входящего и одного исходящего сообщений. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - Задано несколько привязок с именем "{0}". Все привязки должны иметь уникальные имена. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - Задано несколько привязок ошибок с именем "{0}". Все привязки ошибок должны иметь уникальные имена. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - Задано несколько расширений формата с именем "{0}". Все расширения формата должны иметь уникальные имена. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - Задано несколько импортов с именем "{0}". Имя каждого импорта должно быть уникальным. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - Задано несколько сообщений с именем "{0}". Все сообщения должны иметь уникальные имена. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - Задано несколько частей сообщений с именем "{0}". Все части сообщений должны иметь уникальные имена. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - Задано несколько операций с именем "{0}". Все операции должны иметь уникальные имена. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - Задано несколько привязок операций с именем "{0}". Все привязки операций должны иметь уникальные имена. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - Задано несколько ошибок операций с именем "{0}". Все ошибки операций должны иметь уникальные имена. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - Задано несколько сообщений операций с именем "{0}". Все сообщения операций должны иметь уникальные имена. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - Задано несколько портов с именем "{0}". Все порты должны иметь уникальные имена. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - Задано несколько типов портов с именем "{0}". Все типы портов должны иметь уникальные имена. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - Задано несколько служб с именем "{0}". Все службы должны иметь уникальные имена. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - Задано несколько {0} с именем "{1}". Все {0} должны иметь уникальные имена. - - - - The value for '{0}' cannot be negative. - Значение "{0}" не может быть отрицательным. - - - - Warning: {0} - Предупреждение. {0} - - - - Warning: {0} Line {1}, position {2}. - Предупреждение: "{0}". Строка {1}, позиция {2}. - - - - en - ru - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - Схема с targetNamespace="{0}" имеет недопустимый синтаксис. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Ссылка на атрибут "{0}" объявлена в типе схемы "{1}" из пространства имен "{2}". - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - Проверьте определение содержимого для типа схемы "{0}" из пространства имен "{1}". {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - Ссылка на элемент "{0}" объявлена в типе схемы "{1}" из пространства имен "{2}". - - - - Schema item '{1}' from namespace '{0}'. {2} - Элемент схемы "{1}" из пространства имен "{0}". {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - Недопустимый элемент схемы "{1}" с именем "{2}" из пространства имен "{0}". {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.tr.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.tr.xlf deleted file mode 100644 index 49f047b2d5e..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.tr.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - '{1}' ad alanındaki '{0}' bağlaması. - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - Kodlanmış ileti bölümlerinde öğe özniteliğine izin verilmiyor. '{1}' iletisindeki hatalı bölüm '{0}' olarak adlandırılmış. - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - targetNamespace='{0}' içeren hizmet açıklaması. - - - - {0} from service description with targetNamespace='{1}'. - targetNamespace='{1}' içeren hizmet açıklamasından {0}. - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - '{3}' ad alanındaki portType '{2}' üzerindeki '{1}' işleminde soapbind:fault '{0}' var. {4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - '{3}' ad alanındaki '{2}' bağlaması üzerindeki '{1}' işleminde '{0}' hatası var. - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - '{3}' ad alanındaki portType '{2}' üzerindeki '{1}' işleminde '{0}' var. {4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - targetNamespace='{1}' içeren hizmet açıklamasından '{0}' iletisi. - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - '{2}' ad alanındaki '{1}' iletisinin '{0}' parçası yok. - - - - Only objects of type OperationInput or OperationOutput may be added. - Yalnızca OperationInput veya OperationOutput türünde nesneler eklenebilir. - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - Yalnızca XmlElements'ler veya ServiceDescriptionFormatExtension'dan türetilen türler eklenebilir. - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - '{2}' ad alanındaki portType '{1}' üzerindeki '{0}' işlemi. - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - '{2}' ad alanındaki '{1}' bağlaması üzerindeki '{0}' işlemi. - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - targetNamespace='{2}' içeren hizmet açıklamasından '{1}' iletisinin '{0}' bölümü. - - - - Port '{0}' on service {1} from namespace='{2}'. - '{2}' ad alanındaki '{1}' hizmetindeki '{0}' bağlantı noktası. - - - - Protocol with name '{0}' is not recognized. - '{0}' adlı protokol tanınmıyor. - - - - Required XmlFormatExtension attribute is missing on class {0}. - {0} sınıfında gerekli XmlFormatExtension özniteliği eksik. - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - targetNamespace='{0}' olan şemanın sözdizimi geçersiz. {1}, Satır {2}, konum {3}. - - - - Schema validation error: {0} - Şema doğrulama hatası: {0} - - - - The syntax of type {0} may not be extended. - {0} türünün sözdizimi genişletilemez. - - - - Error: {0} Line {1}, position {2}. - Hata: {0} Satır {1}, konum {2}. - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - {0} tanımı bulunamadı. {1} ad alanına sahip Hizmet Tanımı yok. - - - - Element {0} named {1} from namespace {2} is missing. - {2} ad alanında {1} adını taşıyan {0} öğesi yok. - - - - No more than one input and one output message may be specified. - Bir giriş ve bir çıkış iletisinden fazlası belirtilemez. - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - '{0}' adlı birden fazla bağlama belirtildi. Bağlama adları benzersiz olmalıdır. - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - '{0}' adlı birden fazla hata bağlama belirtildi. Hata bağlama adları benzersiz olmalıdır. - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - '{0}' adlı birden fazla biçim uzantısı belirtildi. Biçim uzantısı adları benzersiz olmalıdır. - - - - More than one import named '{0}' was specified. Each import must have a unique name. - '{0}' adlı birden fazla içeri aktarma işlemi belirtildi. İçeri aktarma işlemi adları benzersiz olmalıdır. - - - - More than one message named '{0}' was specified. Each message must have a unique name. - '{0}' adlı birden fazla ileti belirtildi. İleti adları benzersiz olmalıdır. - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - '{0}' adlı birden fazla ileti parçası belirtildi. İleti parçası adları benzersiz olmalıdır. - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - '{0}' adlı birden fazla işlem belirtildi. İşlem adları benzersiz olmalıdır. - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - '{0}' adlı birden fazla işlem bağlaması belirtildi. İşlem bağlaması adları benzersiz olmalıdır. - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - '{0}' adlı birden fazla işlem hatası belirtildi. İşlem hatası adları benzersiz olmalıdır. - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - '{0}' adlı birden fazla işlem iletisi belirtildi. İşlem iletisi adları benzersiz olmalıdır. - - - - More than one port named '{0}' was specified. Each port must have a unique name. - '{0}' adlı birden fazla bağlantı noktası belirtildi. Bağlantı noktası adları benzersiz olmalıdır. - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - '{0}' adlı birden fazla bağlantı noktası türü belirtildi. Bağlantı noktası türü adları benzersiz olmalıdır. - - - - More than one service named '{0}' was specified. Each service must have a unique name. - '{0}' adlı birden fazla hizmet belirtildi. Hizmet adları benzersiz olmalıdır. - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - '{1}' adlı birden fazla {0} belirtildi. {0} adları benzersiz olmalıdır. - - - - The value for '{0}' cannot be negative. - '{0}' değeri negatif olamaz. - - - - Warning: {0} - Uyarı: {0} - - - - Warning: {0} Line {1}, position {2}. - Uyarı: {0} Satır {1}, konum {2}. - - - - en - tr - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - targetNamespace='{0}' olan şemanın sözdizimi geçersiz. {1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - '{0}' öznitelik başvurusu, '{2}' ad alanındaki '{1}' şema türünde bildirildi. - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - '{1}' ad alanındaki '{0}' şema türünün içerik tanımını denetleyin. {2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - '{0}' öğe başvurusu '{2}' ad alanındaki '{1}' şema türünde bildirildi. - - - - Schema item '{1}' from namespace '{0}'. {2} - '{0}' ad alanındaki '{1}' şema öğesi. {2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - '{0}' ad alanındaki '{2}' adlı '{1}' şema öğesi geçersiz. {3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hans.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hans.xlf deleted file mode 100644 index 845478e7db7..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hans.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - 来自命名空间“{1}”的绑定“{0}”。 - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - 编码的消息部分不能使用元素属性。消息“{1}”中不正确部分的名称是“{0}”。 - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - targetNamespace='{0}' 的服务说明。 - - - - {0} from service description with targetNamespace='{1}'. - {0} 来自具有 targetNamespace='{1}' 的服务说明。 - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 来自命名空间“{3}”的 portType“{2}”上的操作“{1}”出现 soapbind:fault“{0}”。{4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - 来自命名空间“{3}”的绑定“{2}”上的操作“{1}”出现错误“{0}”。 - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 来自命名空间“{3}”的 portType“{2}”上的操作“{1}”出现“{0}”。{4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - 来自 targetNamespace='{1}' 的服务说明的消息“{0}”。 - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - 命名空间“{2}”中的消息“{1}”缺少消息部分“{0}”。 - - - - Only objects of type OperationInput or OperationOutput may be added. - 只能添加 OperationInput 或 OperationOutput 类型的对象。 - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - 只能添加 XmlElements 或从 ServiceDescriptionFormatExtension 派生的类型。 - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - 来自命名空间“{2}”的 portType“{1}”上的操作“{0}”。 - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - 来自命名空间“{2}”的绑定“{1}”上的操作“{0}”。 - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - 来自 targetNamespace='{2}' 的服务描述的消息“{1}”的部分“{0}”。 - - - - Port '{0}' on service {1} from namespace='{2}'. - 来自 namespace='{2}' 的服务 {1} 上的端口“{0}”。 - - - - Protocol with name '{0}' is not recognized. - 无法识别名称为“{0}”的协议。 - - - - Required XmlFormatExtension attribute is missing on class {0}. - 类 {0} 上缺少所需的 XmlFormatExtension 属性。 - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - targetNamespace='{0}' 的架构具有无效的语法。{1} 行 {2},位置 {3}。 - - - - Schema validation error: {0} - 架构验证错误: {0} - - - - The syntax of type {0} may not be extended. - 类型 {0} 的语法不可以扩展。 - - - - Error: {0} Line {1}, position {2}. - 错误: {0} 行 {1},位置 {2}。 - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - 找不到 {0} 的定义。缺少命名空间为 {1} 的服务说明。 - - - - Element {0} named {1} from namespace {2} is missing. - 命名空间 {2} 中缺少名为 {1} 的元素 {0}。 - - - - No more than one input and one output message may be specified. - 不能指定一个以上的输入消息和输出消息。 - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - 指定了多个名为“{0}”的绑定。每个绑定必须具有唯一的名称。 - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - 指定了多个名为“{0}”的错误绑定。每个错误绑定必须具有唯一的名称。 - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - 指定了多个名为“{0}”的格式扩展。每个格式扩展必须具有唯一的名称。 - - - - More than one import named '{0}' was specified. Each import must have a unique name. - 指定了多个名为“{0}”的导入。每个导入必须具有唯一的名称。 - - - - More than one message named '{0}' was specified. Each message must have a unique name. - 指定了多条名为“{0}”的消息。每条消息必须具有唯一的名称。 - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - 指定了多个名为“{0}”的消息部分。每个消息部分必须具有唯一的名称。 - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - 指定了多个名为“{0}”的操作。每个操作必须具有唯一的名称。 - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - 指定了多个名为“{0}”的操作绑定。每个操作绑定必须具有唯一的名称。 - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - 指定了多个名为“{0}”的操作错误。每个操作错误必须具有唯一的名称。 - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - 指定了多条名为“{0}”的操作消息。每条操作消息必须具有唯一的名称。 - - - - More than one port named '{0}' was specified. Each port must have a unique name. - 指定了多个名为“{0}”的端口。每个端口必须具有唯一的名称。 - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - 指定了多个名为“{0}”的端口类型。每个端口类型必须具有唯一的名称。 - - - - More than one service named '{0}' was specified. Each service must have a unique name. - 指定了多个名为“{0}”的服务。每个服务必须具有唯一的名称。 - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - 指定了多个名为“{1}”的 {0}。每个 {0} 必须具有唯一的名称。 - - - - The value for '{0}' cannot be negative. - “{0}”的值不能为负。 - - - - Warning: {0} - 警告: {0} - - - - Warning: {0} Line {1}, position {2}. - 警告: {0} 行 {1},位置 {2}。 - - - - en - zh - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - targetNamespace='{0}' 的架构具有无效的语法。{1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 特性引用“{0}”在来自命名空间“{2}”的架构类型“{1}”中声明。 - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - 检查来自命名空间“{1}”的架构类型“{0}”的内容定义。{2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 元素引用“{0}”在来自命名空间“{2}”的架构类型“{1}”中声明。 - - - - Schema item '{1}' from namespace '{0}'. {2} - 来自命名空间“{0}”的架构项“{1}”。{2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - 来自命名空间“{0}”、名为“{2}”的架构项“{1}”无效。{3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hant.xlf b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hant.xlf deleted file mode 100644 index 458d38080c5..00000000000 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Web.Services/xlf/ResWebServices.zh-Hant.xlf +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - Binding '{0}' from namespace '{1}'. - 命名空間 '{1}' 的繫結 '{0}'。 - - - - The element attribute is not allowed on encoded message parts. The erroneous part is named '{0}' in message '{1}'. - 編碼的訊息組件不允許有元素屬性。訊息 {1} 中錯誤的組件名稱為 {0}。 - - - - CODEGEN: {0} - CODEGEN: {0} - - - - Service description with targetNamespace='{0}'. - 具有 targetNamespace={0} 的服務描述。 - - - - {0} from service description with targetNamespace='{1}'. - 來自 targetNamespace='{1}' 的服務描述之 {0}。 - - - - soapbind:fault '{0}' on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 命名空間 '{3}' portType '{2}' 上作業 '{1}' 的 soapbind:fault '{0}'。{4} - - - - Fault '{0}' on operation '{1}' on binding '{2}' from namespace '{3}'. - 命名空間 {3} 的繫結 {2} 上之作業 {1},出現錯誤 {0}。 - - - - {0} on operation '{1}' on portType '{2}' from namespace '{3}'. {4} - 命名空間 '{3}' portType '{2}' 上作業 '{1}' 的 {0}。{4} - - - - Message '{0}' from service description with targetNamespace='{1}'. - 來自 targetNamespace='{1}' 的服務描述之訊息 {0}。 - - - - Missing message part '{0}' for message '{1}' from namespace '{2}'. - 遺漏命名空間 '{2}' 的訊息 '{1}' 之訊息組件 '{0}'。 - - - - Only objects of type OperationInput or OperationOutput may be added. - 只能新增類型 OperationInput 或 OperationOutput 的物件。 - - - - Only XmlElements or types deriving from ServiceDescriptionFormatExtension may be added. - 只可新增 XmlElements 或衍生自 ServiceDescriptionFormatExtension 的類型。 - - - - Operation '{0}' on portType '{1}' from namespace '{2}'. - 命名空間 {2} 的 portType {1} 的作業 {0}。 - - - - Operation '{0}' on binding '{1}' from namespace '{2}'. - 命名空間 '{2}' 繫結 '{1}' 上的作業 '{0}'。 - - - - Part '{0}' of message '{1}' from service description with targetNamespace='{2}'. - 來自 targetNamespace='{2}' 之服務描述的訊息 '{1}' 之組件 '{0}'。 - - - - Port '{0}' on service {1} from namespace='{2}'. - 命名空間 {2} 的服務 {1} 的連接埠 {0}。 - - - - Protocol with name '{0}' is not recognized. - 無法辨識名稱為 {0} 的通訊協定。 - - - - Required XmlFormatExtension attribute is missing on class {0}. - 在類別 {0} 上遺漏必要的 XmlFormatExtension 屬性。 - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} Line {2}, position {3}. - 包含 targetNamespace='{0}' 的結構描述有無效的語法。{1} 行 {2},位置 {3}。 - - - - Schema validation error: {0} - 結構描述驗證錯誤: {0} - - - - The syntax of type {0} may not be extended. - 類型 {0} 的語法無法擴充。 - - - - Error: {0} Line {1}, position {2}. - 錯誤: {0} 行 {1},位置 {2}。 - - - - Cannot find definition for {0}. Service Description with namespace {1} is missing. - 找不到 {0} 的定義。遺漏命名空間為 {1} 的服務描述。 - - - - Element {0} named {1} from namespace {2} is missing. - 遺漏來自命名空間 {2} 且名為 {1} 的元素 {0}。 - - - - No more than one input and one output message may be specified. - 不可指定多個輸入與輸出訊息。 - - - - More than one binding named '{0}' was specified. Each binding must have a unique name. - 已指定多個名為 {0} 的繫結。每個繫結都必須要有唯一的名稱。 - - - - More than one fault binding named '{0}' was specified. Each fault binding must have a unique name. - 已指定多個名為 {0} 的錯誤繫結。每個錯誤繫結都必須要有唯一的名稱。 - - - - More than one format extension named '{0}' was specified. Each format extension must have a unique name. - 已指定多個名為 {0} 的格式延伸。每個格式延伸都必須要有唯一的名稱。 - - - - More than one import named '{0}' was specified. Each import must have a unique name. - 已指定多個名為 {0} 的匯入。每個匯入都必須要有唯一的名稱。 - - - - More than one message named '{0}' was specified. Each message must have a unique name. - 已指定多個名為 {0} 的訊息。每個訊息都必須要有唯一的名稱。 - - - - More than one message part named '{0}' was specified. Each message part must have a unique name. - 已指定多個名為 {0} 的訊息組件。每個訊息組件都必須要有唯一的名稱。 - - - - More than one operation named '{0}' was specified. Each operation must have a unique name. - 已指定多個名為 {0} 的作業。每個作業都必須要有唯一的名稱。 - - - - More than one operation binding named '{0}' was specified. Each operation binding must have a unique name. - 已指定多個名為 {0} 的作業繫結。每個作業繫結都必須要有唯一的名稱。 - - - - More than one operation fault named '{0}' was specified. Each operation fault must have a unique name. - 已指定多個名為 {0} 的作業錯誤。每個作業錯誤都必須要有唯一的名稱。 - - - - More than one operation message named '{0}' was specified. Each operation message must have a unique name. - 已指定多個名為 {0} 的作業訊息。每個作業訊息都必須要有唯一的名稱。 - - - - More than one port named '{0}' was specified. Each port must have a unique name. - 已指定多個名為 {0} 的連接埠。每個連接埠都必須要有唯一的名稱。 - - - - More than one port type named '{0}' was specified. Each port type must have a unique name. - 已指定多個名為 {0} 的連接埠類型。每個連接埠類型都必須要有唯一的名稱。 - - - - More than one service named '{0}' was specified. Each service must have a unique name. - 已指定多個名為 {0} 的服務。每個服務都必須要有唯一的名稱。 - - - - More than one {0} named '{1}' was specified. Each {0} must have a unique name. - 已指定多個名為 {1} 的 {0}。每個 {0} 都必須要有唯一的名稱。 - - - - The value for '{0}' cannot be negative. - {0} 的值不能為負。 - - - - Warning: {0} - 警告: {0} - - - - Warning: {0} Line {1}, position {2}. - 警告: {0} 行 {1},位置 {2}。 - - - - en - zh-Hant - - - - Schema with targetNamespace='{0}' has invalid syntax. {1} - 包含 targetNamespace='{0}' 的結構描述有無效的語法。{1} - - - - Attribute reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 已在命名空間 '{2}' 的結構描述類型 '{1}' 中,宣告屬性參考 '{0}'。 - - - - Check content definition of schema type '{0}' from namespace '{1}'. {2} - 請檢查命名空間 '{1}' 結構描述類型 '{0}' 的內容定義。{2} - - - - Element reference '{0}' declared in schema type '{1}' from namespace '{2}'. - 已在命名空間 '{2}' 的結構描述類型 '{1}' 中,宣告了元素參考 '{0}'。 - - - - Schema item '{1}' from namespace '{0}'. {2} - 命名空間 '{0}' 的結構描述項目 '{1}'。{2} - - - - Schema item '{1}' named '{2}' from namespace '{0}' is invalid. {3} - 命名空間 {0} 中,名為 {2} 的結構描述項目 {1} 無效。{3} - - - - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/ImportModule.cs b/src/dotnet-svcutil/lib/src/ImportModule.cs index 57dbce7619c..08ecdc4156f 100644 --- a/src/dotnet-svcutil/lib/src/ImportModule.cs +++ b/src/dotnet-svcutil/lib/src/ImportModule.cs @@ -379,18 +379,19 @@ private static DcNS.ImportOptions CreateDCImportOptions(CommandProcessorOptions private static void AddStateForXmlSerializerImport(CommandProcessorOptions options, WsdlImporter importer, CodeCompileUnit codeCompileUnit) { - XmlSerializerImportOptions importOptions = new XmlSerializerImportOptions(codeCompileUnit) - { - WebReferenceOptions = new WsdlNS.WebReferenceOptions() - }; - importOptions.WebReferenceOptions.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder; + XmlSerializerImportOptions importOptions = new XmlSerializerImportOptions(codeCompileUnit); + importOptions.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder; if (options.EnableDataBinding == true) - importOptions.WebReferenceOptions.CodeGenerationOptions |= CodeGenerationOptions.EnableDataBinding; + importOptions.CodeGenerationOptions |= CodeGenerationOptions.EnableDataBinding; // Enable a minimal schema importer extension for DataSet/DataTable. // This avoids generating placeholder IXmlSerializable + ArrayOfXElement types for common DataSet wrapper patterns. importOptions.WebReferenceOptions.SchemaImporterExtensions.Add(typeof(DataSetSchemaImporterExtension).AssemblyQualifiedName); + // This avoids generating placeholder IXmlSerializable + ArrayOfXElement types for common DataSet wrapper patterns. + importOptions.WebReferenceOptions.SchemaImporterExtensions.Add(typeof(DataSetSchemaImporterExtension).AssemblyQualifiedName); + + importOptions.CodeProvider = options.CodeProvider; importOptions.ClrNamespace = options.NamespaceMappings.FirstOrDefault(m => m.Key == "*").Value; diff --git a/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj b/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj index 13552156ae9..79756b14073 100644 --- a/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj +++ b/src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj @@ -59,6 +59,7 @@ + @@ -114,10 +115,5 @@ false Microsoft.Tools.ServiceModel.Svcutil.SR - - true - false - System.Web.Services.ResWebServices - \ No newline at end of file From f2896064f05ea7fd3a48afa59d4917c4d913c3fc Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Thu, 16 Apr 2026 10:33:10 +0800 Subject: [PATCH 3/4] Follow up DataSetSchemaImporterExtension changes after rebase --- .../Channels/XmlSerializerImportOptions.cs | 15 +++++++++++++++ .../Description/MessageContractImporter.cs | 5 +++++ src/dotnet-svcutil/lib/src/ImportModule.cs | 6 +----- .../DataSetSchemaImporterExtension.cs | 8 ++++---- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs index 335bd35844c..4056d49f5f1 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Channels/XmlSerializerImportOptions.cs @@ -5,6 +5,7 @@ namespace System.ServiceModel.Channels { using System; + using System.Collections.Specialized; using Microsoft.CodeDom.Compiler; using Microsoft.CodeDom; using System.Collections; @@ -25,6 +26,7 @@ public class XmlSerializerImportOptions private CodeDomProvider _codeProvider; private string _clrNamespace; private CodeGenerationOptions _codeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder; + private StringCollection _schemaImporterExtensions; public XmlSerializerImportOptions() : this(new CodeCompileUnit()) @@ -68,6 +70,19 @@ public CodeGenerationOptions CodeGenerationOptions get { return _codeGenerationOptions; } set { _codeGenerationOptions = value; } } + + public StringCollection SchemaImporterExtensions + { + get + { + if (_schemaImporterExtensions == null) + { + _schemaImporterExtensions = new StringCollection(); + } + + return _schemaImporterExtensions; + } + } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs index 2a7d533f6ff..4850eb25b70 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.ServiceModel/System/ServiceModel/Description/MessageContractImporter.cs @@ -1938,6 +1938,11 @@ public XmlSerializerSchemaImporter(WsdlImporter importer) _xmlImporter = new XmlSchemaImporter(_literalSchemas, codeGenerationOptions, options.CodeProvider, new ImportContext(codeIdentifiers, false)); } + foreach (string extTypeName in options.SchemaImporterExtensions) + { + _xmlImporter.Extensions.Add(extTypeName, Type.GetType(extTypeName, true /*throwOnError*/)); + } + //SchemaImporter.ctor is not thread safe: MB49115, VSWhidbey580396 lock (s_schemaImporterLock) { diff --git a/src/dotnet-svcutil/lib/src/ImportModule.cs b/src/dotnet-svcutil/lib/src/ImportModule.cs index 08ecdc4156f..aa949d99aff 100644 --- a/src/dotnet-svcutil/lib/src/ImportModule.cs +++ b/src/dotnet-svcutil/lib/src/ImportModule.cs @@ -386,11 +386,7 @@ private static void AddStateForXmlSerializerImport(CommandProcessorOptions optio // Enable a minimal schema importer extension for DataSet/DataTable. // This avoids generating placeholder IXmlSerializable + ArrayOfXElement types for common DataSet wrapper patterns. - importOptions.WebReferenceOptions.SchemaImporterExtensions.Add(typeof(DataSetSchemaImporterExtension).AssemblyQualifiedName); - - // This avoids generating placeholder IXmlSerializable + ArrayOfXElement types for common DataSet wrapper patterns. - importOptions.WebReferenceOptions.SchemaImporterExtensions.Add(typeof(DataSetSchemaImporterExtension).AssemblyQualifiedName); - + importOptions.SchemaImporterExtensions.Add(typeof(DataSetSchemaImporterExtension).AssemblyQualifiedName); importOptions.CodeProvider = options.CodeProvider; diff --git a/src/dotnet-svcutil/lib/src/SchemaImporterExtensions/DataSetSchemaImporterExtension.cs b/src/dotnet-svcutil/lib/src/SchemaImporterExtensions/DataSetSchemaImporterExtension.cs index f7bd0f154e0..88e699b119b 100644 --- a/src/dotnet-svcutil/lib/src/SchemaImporterExtensions/DataSetSchemaImporterExtension.cs +++ b/src/dotnet-svcutil/lib/src/SchemaImporterExtensions/DataSetSchemaImporterExtension.cs @@ -4,12 +4,12 @@ using Microsoft.CodeDom; using Microsoft.CodeDom.Compiler; -using Microsoft.Xml; -using Microsoft.Xml.Schema; -using Microsoft.Xml.Serialization; -using Microsoft.Xml.Serialization.Advanced; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer.Advanced; using System; +using System.Xml; +using System.Xml.Schema; namespace Microsoft.Tools.ServiceModel.Svcutil { From 4fa400e267a2d6599a24ad449b0a988dbbd711d7 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Thu, 23 Apr 2026 17:44:10 +0800 Subject: [PATCH 4/4] Fix wildcard importer regression after System.Xml.Schema migration --- .../Xml/Serialization/XmlSchemaImporter.cs | 34 ++++-- .../lib/tests/src/XmlSchemaImporterTests.cs | 103 ++++++++++++++++++ 2 files changed, 127 insertions(+), 10 deletions(-) create mode 100644 src/dotnet-svcutil/lib/tests/src/XmlSchemaImporterTests.cs diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs index 5e40793fbee..d8ec4cfe2d7 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.Xml/Xml/Serialization/XmlSchemaImporter.cs @@ -1360,20 +1360,31 @@ private ElementAccessor ImportArray(XmlSchemaElement element, string identifier, return arrayAccessor; } + // Extension and restriction are explicit inheritance; implicit anyType is not. + private static bool HasExplicitContentModelInheritance(XmlSchemaType type) + { + if (!(type is XmlSchemaComplexType complexType) || complexType.ContentModel == null) + { + return false; + } + + XmlSchemaContent content = complexType.ContentModel.Content; + return content is XmlSchemaComplexContentExtension + || content is XmlSchemaSimpleContentExtension + || content is XmlSchemaComplexContentRestriction + || content is XmlSchemaSimpleContentRestriction; + } + private ArrayMapping ImportArrayMapping(XmlSchemaType type, string identifier, string ns, bool repeats) { if (!(type is XmlSchemaComplexType)) return null; // [Fix: Polymorphism/Inheritance] - // We only disqualify the type from being an Array if it *explicitly* extends another type via ContentModel. - // Implicit inheritance from 'anyType' (where BaseXmlSchemaType is non-null but ContentModel is null) - // is standard for Arrays and must be allowed. - if (type is XmlSchemaComplexType complexType && complexType.ContentModel != null) + // We only disqualify the type from special array handling if it explicitly derives from another type + // through a content model. Implicit inheritance from 'anyType' (where BaseXmlSchemaType is non-null but + // ContentModel is null) is standard and must remain eligible for special handling. + if (HasExplicitContentModelInheritance(type)) { - if (complexType.ContentModel.Content is XmlSchemaComplexContentExtension || - complexType.ContentModel.Content is XmlSchemaSimpleContentExtension) - { - return null; - } + return null; } if (IsMixed(type)) return null; @@ -1479,7 +1490,10 @@ private bool IsCyclicReferencedType(XmlSchemaElement element, List ident private SpecialMapping ImportAnyMapping(XmlSchemaType type, string identifier, string ns, bool repeats) { if (type == null) return null; - if (type.BaseXmlSchemaType != null) return null; + // BaseXmlSchemaType != null is too broad here: under System.Xml.Schema it can represent either + // an implicit xsd:anyType base or an explicit schema derivation. For special importer handling, + // only explicit content-model inheritance (extension/restriction) should disqualify the type. + if (HasExplicitContentModelInheritance(type)) return null; bool mixed = IsMixed(type); TypeItems items = GetTypeItems(type); diff --git a/src/dotnet-svcutil/lib/tests/src/XmlSchemaImporterTests.cs b/src/dotnet-svcutil/lib/tests/src/XmlSchemaImporterTests.cs new file mode 100644 index 00000000000..cbd62a5eb43 --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/src/XmlSchemaImporterTests.cs @@ -0,0 +1,103 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Xml; +using System.Xml.Schema; +using Microsoft.Tools.ServiceModel.Svcutil.XmlSerializer; +using Xunit; + +namespace SvcutilTest +{ + public class XmlSchemaImporterTests + { + [Fact] + public void ImportSchemaType_UsesSpecialMapping_ForWildcardTypeWithImplicitAnyTypeBase() + { + XmlSchema schema = LoadSchema(@" + + + + + + +"); + + XmlSchemas schemas = CreateSchemas(schema); + XmlSchemaComplexType type = GetComplexType(schemas, "FlexibleContentType", "urn:repro:wildcard"); + Assert.NotNull(type); + Assert.NotNull(type.BaseXmlSchemaType); + Assert.Null(type.ContentModel); + + XmlSchemaImporter importer = new XmlSchemaImporter(schemas); + + XmlTypeMapping mapping = importer.ImportSchemaType(new XmlQualifiedName("FlexibleContentType", "urn:repro:wildcard")); + + Assert.IsType(mapping.Accessor.Mapping); + } + + [Fact] + public void ImportSchemaType_DoesNotUseSpecialMapping_ForWildcardTypeWithExplicitInheritance() + { + XmlSchema schema = LoadSchema(@" + + + + + + + + + + + + + + +"); + + XmlSchemas schemas = CreateSchemas(schema); + XmlSchemaComplexType type = GetComplexType(schemas, "DerivedWildcardType", "urn:repro:wildcard"); + Assert.NotNull(type); + Assert.NotNull(type.ContentModel); + XmlSchemaImporter importer = new XmlSchemaImporter(schemas); + + XmlTypeMapping mapping = importer.ImportSchemaType(new XmlQualifiedName("DerivedWildcardType", "urn:repro:wildcard")); + + Assert.IsNotType(mapping.Accessor.Mapping); + Assert.IsType(mapping.Accessor.Mapping); + } + + private static XmlSchemas CreateSchemas(XmlSchema schema) + { + XmlSchemas schemas = new XmlSchemas(); + schemas.Add(schema); + schemas.Compile(null, true); + return schemas; + } + + private static XmlSchemaComplexType GetComplexType(XmlSchemas schemas, string typeName, string typeNamespace) + { + return (XmlSchemaComplexType)schemas.Find(new XmlQualifiedName(typeName, typeNamespace), typeof(XmlSchemaType)); + } + + private static XmlSchema LoadSchema(string schemaText) + { + using (StringReader reader = new StringReader(schemaText)) + { + return XmlSchema.Read(reader, ValidationCallback); + } + } + + private static void ValidationCallback(object sender, ValidationEventArgs e) + { + throw new InvalidOperationException(e.Message, e.Exception); + } + } +}