本文整理汇总了C#中System.Xml.Schema.XmlSchemaSet.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaSet.Contains方法的具体用法?C# XmlSchemaSet.Contains怎么用?C# XmlSchemaSet.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaSet
的用法示例。
在下文中一共展示了XmlSchemaSet.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: v3
//[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again")]
public void v3()
{
XmlSchemaSet sc = new XmlSchemaSet();
XmlSchema Schema = sc.Add("xsdauthor", TestData._XsdAuthor);
Assert.Equal(sc.Contains("xsdauthor"), true);
sc.Remove(Schema);
Assert.Equal(sc.Contains("xsdauthor"), false);
return;
}
示例2: v1
//[Variation(Desc = "v1 - Contains with null")]
public void v1()
{
XmlSchemaSet sc = new XmlSchemaSet();
Assert.Equal(sc.Contains((String)null), false);
return;
}
示例3: v2
//[Variation(Desc = "v2 - Contains with non existing ns", Priority = 0)]
public void v2()
{
XmlSchemaSet sc = new XmlSchemaSet();
sc.Add("xsdauthor", TestData._XsdAuthor);
Assert.Equal(sc.Contains("test"), false);
return;
}
示例4: v2
public void v2()
{
XmlSchemaSet sc = new XmlSchemaSet();
try
{
XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
CError.Compare(sc.Count, 1, "AddCount");
CError.Compare(sc.Contains(Schema1), true, "AddContains");
CError.Compare(sc.IsCompiled, false, "AddIsCompiled");
XmlSchema Schema2 = XmlSchema.Read(new StreamReader(new FileStream(TestData._XsdNoNs, FileMode.Open, FileAccess.Read)), null);
sc.Compile();
CError.Compare(sc.Count, 1, "Compile");
CError.Compare(sc.Contains(Schema1), true, "Contains");
sc.Reprocess(Schema2);
CError.Compare(sc.Count, 1, "Reprocess");
CError.Compare(sc.Contains(Schema2), true, "Contains");
}
catch (ArgumentException e)
{
_output.WriteLine(e.ToString());
CError.Compare(sc.Count, 1, "AE");
return;
}
Assert.True(false);
}
示例5: v3
//[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again", Priority = 0)]
public void v3()
{
XmlSchemaSet sc = new XmlSchemaSet();
#pragma warning disable 0618
XmlSchemaCollection scl = new XmlSchemaCollection();
#pragma warning restore 0618
XmlSchema Schema = scl.Add(null, TestData._XsdAuthor);
sc.Add(Schema);
Assert.Equal(sc.Contains(Schema), true);
sc.Remove(Schema);
Assert.Equal(sc.Contains(Schema), false);
return;
}
示例6: v3
public void v3()
{
XmlSchemaSet sc = new XmlSchemaSet();
XmlSchema Schema = XmlSchema.Read(new StreamReader(new FileStream(TestData._FileXSD1, FileMode.Open, FileAccess.Read)), null);
XmlSchema SchemaNew1 = sc.Add(Schema);
XmlSchema SchemaNew2 = sc.Add(Schema);
Assert.Equal(sc.Count, 1);
Assert.Equal(sc.Contains(SchemaNew1), true);
Assert.Equal(sc.Contains(SchemaNew2), true);
Assert.Equal(sc.IsCompiled, false);
Assert.Equal(Schema == SchemaNew1, true);
Assert.Equal(Schema == SchemaNew2, true);
sc.Compile();
Assert.Equal(sc.Count, 1);
Assert.Equal(sc.Contains(SchemaNew1), true);
Assert.Equal(sc.Contains(SchemaNew2), true);
Assert.Equal(sc.IsCompiled, true);
}
示例7: v1
//[Variation(Desc = "v1 - Contains with null")]
public void v1()
{
try
{
XmlSchemaSet sc = new XmlSchemaSet();
sc.Contains((XmlSchema)null);
}
catch (ArgumentNullException)
{
// GLOBALIZATION
return;
}
Assert.True(false);
}
示例8: v1
public void v1()
{
XmlSchemaSet sc = new XmlSchemaSet();
try
{
sc.Add((XmlSchema)null);
}
catch (ArgumentNullException)
{
try
{
Assert.Equal(sc.Count, 0);
Assert.Equal(sc.Contains((XmlSchema)null), false);
}
catch (ArgumentNullException)
{
Assert.Equal(sc.Contains((string)null), false);
Assert.Equal(sc.IsCompiled, false);
return;
}
}
Assert.True(false);
}
示例9: v3
public void v3()
{
XmlSchemaSet sc = new XmlSchemaSet();
sc.XmlResolver = new XmlUrlResolver();
XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
XmlSchema Schema2 = sc.Add("test", TestData._XsdNoNs);
sc.Compile();
sc.Remove(Schema1);
CError.Compare(sc.Count, 1, "Count");
ICollection Col = sc.Schemas();
CError.Compare(Col.Count, 1, "ICollection.Count");
CError.Compare(sc.Contains("test"), true, "Contains");
return;
}
示例10: LoadSchema
bool LoadSchema(XmlSchemaSet set, SchemaResolver resolver, XmlNode ctx, string nsuri, string filename)
{
try {
Uri baseUri = this.baseUri;
if (!string.IsNullOrEmpty(ctx.BaseURI)) {
baseUri = new Uri(ctx.BaseURI);
}
Uri resolved;
if (baseUri != null) {
resolved = new Uri(baseUri, filename);
} else {
resolved = new Uri(filename, UriKind.RelativeOrAbsolute);
}
XmlSchema s = resolver.GetEntity(resolved, "", typeof(XmlSchema)) as XmlSchema;
if ((s.TargetNamespace+"") != (nsuri+"")) {
ReportError(Severity.Warning, SR.TNSMismatch, ctx);
} else if (!set.Contains(s)) {
set.Add(s);
return true;
}
} catch (Exception e) {
ReportError(Severity.Warning, string.Format(SR.SchemaLoadError, filename, e.Message), ctx);
}
return false;
}
示例11: v3
public void v3()
{
XmlSchemaSet sc = new XmlSchemaSet();
XmlSchema Schema1 = sc.Add(null, TestData._XsdAuthor);
CError.Compare(sc.Count, 1, "AddCount");
CError.Compare(sc.Contains(Schema1), true, "AddContains");
CError.Compare(sc.IsCompiled, false, "AddIsCompiled");
sc.Compile();
CError.Compare(sc.Count, 1, "Compile");
CError.Compare(sc.Contains(Schema1), true, "Compile Contains");
CError.Compare(sc.IsCompiled, true, "Compile IsCompiled");
sc.Reprocess(Schema1);
CError.Compare(sc.Count, 1, "IsCompiled on set");
CError.Compare(sc.IsCompiled, false, "Reprocess IsCompiled");
CError.Compare(sc.Contains(Schema1), true, "Reprocess Contains");
return;
}
示例12: Read
internal ConfigurationElement Read()
{
XmlSchemaSet schemas = new XmlSchemaSet();
// load buit-in schema from resource
schemas.Add(GetSchemaFromResource());
if (this.loader.SchemaFileNames.Any())
{
AddExtensionSchemas(schemas, this.loader);
}
var readerSettings = new XmlReaderSettings()
{
Schemas = schemas,
CloseInput = true,
XmlResolver = new SchemaConfigurationXmlResolver(),
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints |
XmlSchemaValidationFlags.ReportValidationWarnings |
XmlSchemaValidationFlags.ProcessSchemaLocation |
XmlSchemaValidationFlags.ProcessInlineSchema
};
var validationExceptions = new List<Exception>();
readerSettings.ValidationEventHandler += (s, a) =>
{
//// Filter out any missing schema warnings for custom elements and its child sub elements
if (a.Severity == XmlSeverityType.Warning)
{
var reader = (XmlReader)s;
if (!schemas.Contains(reader.NamespaceURI) || reader.NamespaceURI == Constants.Namespace)
{
return;
}
}
//// Collect all schema validation errors
validationExceptions.Add(a.Exception);
};
XDocument doc = null;
using (var reader = XmlReader.Create(this.File, readerSettings))
{
try
{
doc = XDocument.Load(reader, LoadOptions.SetLineInfo);
}
catch (Exception e)
{
validationExceptions.Add(e);
}
}
if (validationExceptions.Count > 0)
{
throw new ConfigurationException(validationExceptions) { ConfigurationFile = this.File };
}
var configuration = new ConfigurationElement();
var tes = doc.Root.Element(this.traceEventServiceName);
configuration.TraceEventService = (tes == null) ? new TraceEventServiceElement() : TraceEventServiceElement.Read(tes);
var sinks = doc.Root.Elements(this.sinksName).Elements();
if (sinks != null)
{
configuration.SinkConfigurationElements = this.LoadSinkConfigurationElements(sinks);
}
return configuration;
}
示例13: DoCompile
void DoCompile (ValidationEventHandler handler, Hashtable handledUris, XmlSchemaSet col, XmlResolver resolver)
{
SetParent ();
CompilationId = col.CompilationId;
schemas = col;
if (!schemas.Contains (this)) // e.g. xs:import
schemas.Add (this);
attributeGroups.Clear ();
attributes.Clear ();
elements.Clear ();
groups.Clear ();
notations.Clear ();
schemaTypes.Clear ();
//1. Union and List are not allowed in block default
if (BlockDefault != XmlSchemaDerivationMethod.All) {
if((BlockDefault & XmlSchemaDerivationMethod.List)!=0 )
error(handler, "list is not allowed in blockDefault attribute");
if((BlockDefault & XmlSchemaDerivationMethod.Union)!=0 )
error(handler, "union is not allowed in blockDefault attribute");
}
//2. Substitution is not allowed in finaldefault.
if (FinalDefault != XmlSchemaDerivationMethod.All) {
if((FinalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )
error(handler, "substitution is not allowed in finalDefault attribute");
}
//3. id must be of type ID
XmlSchemaUtil.CompileID(Id, this, col.IDCollection, handler);
//4. targetNamespace should be of type anyURI or absent
if (TargetNamespace != null) {
if (TargetNamespace.Length == 0)
error (handler, "The targetNamespace attribute cannot have have empty string as its value.");
if(!XmlSchemaUtil.CheckAnyUri (TargetNamespace))
error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");
}
//5. version should be of type normalizedString
if (!XmlSchemaUtil.CheckNormalizedString(Version))
error(handler, Version + "is not a valid value for version attribute of schema");
// Compile the content of this schema
compilationItems = new XmlSchemaObjectCollection ();
for (int i = 0; i < Items.Count; i++) {
compilationItems.Add (Items [i]);
}
// First, we run into inclusion schemas to collect
// compilation target items into compiledItems.
for (int i = 0; i < Includes.Count; i++)
ProcessExternal (handler, handledUris, resolver, Includes [i] as XmlSchemaExternal, col);
// Compilation phase.
// At least each Compile() must give unique (qualified) name for each component.
// It also checks self-resolvable properties correctness.
// Post compilation schema information contribution is not done here.
// It should be done by Validate().
for (int i = 0; i < compilationItems.Count; i++) {
XmlSchemaObject obj = compilationItems [i];
if(obj is XmlSchemaAnnotation) {
int numerr = ((XmlSchemaAnnotation)obj).Compile (handler, this);
errorCount += numerr;
} else if (obj is XmlSchemaAttribute) {
XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
int numerr = attr.Compile (handler, this);
errorCount += numerr;
if(numerr == 0)
{
XmlSchemaUtil.AddToTable (Attributes, attr, attr.QualifiedName, handler);
}
} else if (obj is XmlSchemaAttributeGroup) {
XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;
int numerr = attrgrp.Compile(handler, this);
errorCount += numerr;
if (numerr == 0)
XmlSchemaUtil.AddToTable (
AttributeGroups,
attrgrp,
attrgrp.QualifiedName,
handler);
} else if (obj is XmlSchemaComplexType) {
XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;
int numerr = ctype.Compile (handler, this);
errorCount += numerr;
if (numerr == 0)
XmlSchemaUtil.AddToTable (
schemaTypes,
ctype,
ctype.QualifiedName,
handler);
} else if (obj is XmlSchemaSimpleType) {
XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
stype.islocal = false; //This simple type is toplevel
int numerr = stype.Compile (handler, this);
errorCount += numerr;
//.........这里部分代码省略.........
示例14: v12
public void v12()
{
bWarningCallback = false;
bErrorCallback = false;
XmlSchemaSet sc = new XmlSchemaSet();
sc.XmlResolver = new XmlUrlResolver();
sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
XmlSchema Schema1 = sc.Add(null, TestData._Root + "include_v1_a.xsd");
CError.Compare(sc.Count, 1, "Count after add");
CError.Compare(sc.Contains(Schema1), true, "Contains after add");
sc.Compile();
CError.Compare(sc.Count, 1, "Count after add/comp");
CError.Compare(sc.Contains(Schema1), true, "Contains after add/comp");
///edit
XmlSchemaInclude inc = new XmlSchemaInclude();
inc.SchemaLocation = "include_v2.xsd";
Schema1.Includes.Add(inc);
sc.Reprocess(Schema1);
ValidateSchemaSet(sc, 1, false, 1, 0, 0, "Validation after edit/reprocess");
CError.Compare(bWarningCallback, false, "Warning repr");
CError.Compare(bErrorCallback, true, "Error repr");
sc.Compile();
ValidateSchemaSet(sc, 1, false, 1, 0, 0, "Validation after comp/reprocess");
CError.Compare(bWarningCallback, false, "Warning comp");
CError.Compare(bErrorCallback, true, "Error comp");
CError.Compare(Schema1.IsCompiled, false, "IsCompiled on SOM");
return;
}
示例15: v10
public void v10()
{
XmlCachedSchemaSetResolver resolver = new XmlCachedSchemaSetResolver();
XmlTextReader r = new XmlTextReader(Path.Combine(TestData._Root, @"RedefineEmployee.xsd"));
XmlSchema s = XmlSchema.Read(r, null);
resolver.Add(new Uri(s.SourceUri), s);
XmlTextReader r2 = new XmlTextReader(Path.Combine(TestData._Root, @"BaseEmployee2.xsd"));
XmlSchema s2 = XmlSchema.Read(r2, null);
resolver.Add(new Uri(s2.SourceUri), s2);
XmlSchemaSet set = new XmlSchemaSet();
set.ValidationEventHandler += new ValidationEventHandler(callback);
set.XmlResolver = resolver;
set.Add(s2);
Assert.Equal(set.Count, 1);
Assert.Equal(set.Contains(s2), true);
Assert.Equal(set.IsCompiled, false);
set.Add(s);
Assert.Equal(set.Count, 2);
Assert.Equal(set.Contains(s), true);
Assert.Equal(set.IsCompiled, false);
set.Compile();
Assert.Equal(set.Count, 2);
Assert.Equal(set.Contains(s2), true);
Assert.Equal(set.Contains(s), true);
Assert.Equal(set.IsCompiled, true);
XmlTextReader r3 = new XmlTextReader(Path.Combine(TestData._Root, @"BaseEmployee2.xsd"));
XmlSchema s3 = XmlSchema.Read(r3, null);
resolver.Add(new Uri(s3.SourceUri), s3);
//Clear includes in S
foreach (XmlSchemaExternal ext in s.Includes)
{
ext.Schema = null;
}
XmlSchemaSet set2 = new XmlSchemaSet();
set2.ValidationEventHandler += new ValidationEventHandler(callback);
set2.XmlResolver = resolver;
set2.Add(s3);
Assert.Equal(set2.Count, 1);
Assert.Equal(set2.Contains(s2), false);
Assert.Equal(set2.Contains(s), false);
Assert.Equal(set2.Contains(s3), true);
Assert.Equal(set2.IsCompiled, false);
set2.Add(s);
Assert.Equal(set2.Count, 2);
Assert.Equal(set2.Contains(s2), false);
Assert.Equal(set2.Contains(s), true);
Assert.Equal(set2.Contains(s3), true);
Assert.Equal(set2.IsCompiled, false);
set2.Compile();
Assert.Equal(set2.Count, 2);
Assert.Equal(set2.Contains(s2), false);
Assert.Equal(set2.Contains(s), true);
Assert.Equal(set2.Contains(s3), true);
Assert.Equal(set2.IsCompiled, true);
Assert.Equal(errorCount, 0);
}