System.Xml.Tests.TC_SchemaSet_Misc.v124 C# (CSharp) Method

v124() private method

private v124 ( ) : void
return void
        public void v124()
        {
            Initialize();
            string XamlPresentationNamespace =
        "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
            string XamlToParse =
        "<pfx0:DrawingBrush TileMode=\"Tile\" Viewbox=\"foobar\" />";

            string xml =
        "	<xs:schema " +
        "		xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" +
        "		xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" +
        "		targetNamespace=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" " +
        "		elementFormDefault=\"qualified\" " +
        "		attributeFormDefault=\"unqualified\"" +
        "	>" +
        "" +
        "		<xs:element name=\"DrawingBrush\" type=\"DrawingBrushType\" />" +
        "" +
        "		<xs:complexType name=\"DrawingBrushType\">" +
        "			<xs:attribute name=\"Viewbox\" type=\"xs:string\" />" +
        "			<xs:attribute name=\"TileMode\" type=\"xs:string\" />" +
        "		</xs:complexType>" +
        "	</xs:schema>";

            XmlSchema schema = XmlSchema.Read(new StringReader(xml), null);
            schema.TargetNamespace = XamlPresentationNamespace;
            XmlSchemaSet schemaSet = new XmlSchemaSet();
            schemaSet.XmlResolver = new XmlUrlResolver();
            schemaSet.Add(schema);
            schemaSet.Compile();

            XmlReaderSettings readerSettings = new XmlReaderSettings();
            readerSettings.ConformanceLevel = ConformanceLevel.Fragment;
            readerSettings.ValidationType = ValidationType.Schema;
            readerSettings.Schemas = schemaSet;

            NameTable nameTable = new NameTable();
            XmlNamespaceManager namespaces = new XmlNamespaceManager(nameTable);
            namespaces.AddNamespace("pfx0", XamlPresentationNamespace);
            namespaces.AddNamespace(string.Empty, XamlPresentationNamespace);
            XmlParserContext parserContext = new XmlParserContext(nameTable, namespaces, null, null, null, null, null, null, XmlSpace.None);

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(XamlToParse), readerSettings, parserContext))
            {
                xmlReader.Read();
                xmlReader.MoveToAttribute(0);
                xmlReader.MoveToNextAttribute();
                xmlReader.MoveToNextAttribute();
                xmlReader.MoveToNextAttribute();

                xmlReader.MoveToAttribute(0);
                if (xmlReader.MoveToNextAttribute())
                    return;
            }
            Assert.True(false);
        }