System.Xml.Tests.TCXmlResolver.UsingCustomXmlResolverWith_SchemaLocation_NoNamespaceSchemaLocation C# (CSharp) Méthode

UsingCustomXmlResolverWith_SchemaLocation_NoNamespaceSchemaLocation() private méthode

private UsingCustomXmlResolverWith_SchemaLocation_NoNamespaceSchemaLocation ( bool schemaLocation ) : void
schemaLocation bool
Résultat void
        public void UsingCustomXmlResolverWith_SchemaLocation_NoNamespaceSchemaLocation(bool schemaLocation)
        {
            CXmlTestResolver res = new CXmlTestResolver();
            CResolverHolder holder = new CResolverHolder();

            res.CalledResolveUri += new XmlTestResolverEventHandler(holder.CallBackResolveUri);
            res.CalledGetEntity += new XmlTestResolverEventHandler(holder.CallBackGetEntity);

            XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
            XmlSchemaValidator val = new XmlSchemaValidator(new NameTable(),
                                                            new XmlSchemaSet(),
                                                            manager,
                                                            AllFlags);
            val.XmlResolver = res;
            val.Initialize();

            if (schemaLocation)
            {
                manager.AddNamespace("t", "uri:tempuri");
                val.ValidateElement("foo", "", null, "t:type1", null, "uri:tempuri " + Path.Combine(TestData, XSDFILE_TARGET_NAMESPACE), null);
            }
            else
            {
                val.ValidateElement("foo", "", null, "type1", null, null, XSDFILE_NO_TARGET_NAMESPACE);
            }

            Assert.True(holder.IsCalledResolveUri);
            Assert.True(holder.IsCalledGetEntity);

            return;
        }