IsDerivedFrom() public static méthode

public static IsDerivedFrom ( XmlSchemaType derivedType, XmlSchemaType baseType, XmlSchemaDerivationMethod except ) : bool
derivedType XmlSchemaType
baseType XmlSchemaType
except XmlSchemaDerivationMethod
Résultat bool
 /// <summary>Returns a value indicating if the derived schema type specified is derived from the base schema type specified</summary>
 /// <returns>true if the derived type is derived from the base type; otherwise, false.</returns>
 /// <param name="derivedType">The derived <see cref="T:System.Xml.Schema.XmlSchemaType" /> to test.</param>
 /// <param name="baseType">The base <see cref="T:System.Xml.Schema.XmlSchemaType" /> to test the derived <see cref="T:System.Xml.Schema.XmlSchemaType" /> against.</param>
 /// <param name="except">One of the <see cref="T:System.Xml.Schema.XmlSchemaDerivationMethod" /> values representing a type derivation method to exclude from testing.</param>
 public static bool IsDerivedFrom(XmlSchemaType derivedType, XmlSchemaType baseType, XmlSchemaDerivationMethod except)
 {
     return(derivedType.BaseXmlSchemaType != null && (derivedType.DerivedBy & except) == XmlSchemaDerivationMethod.Empty && (derivedType.BaseXmlSchemaType == baseType || XmlSchemaType.IsDerivedFrom(derivedType.BaseXmlSchemaType, baseType, except)));
 }
 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(Res.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
                 elementDecl = null;
             }
         }
         else if (xsiNil != null && xsiNil.Equals("true"))
         {
             SendValidationEvent(Res.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(Res.Sch_XsiTypeNotFound, xsiType.ToString());
                 elementDecl = null;
             }
             else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block))
             {
                 SendValidationEvent(Res.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(Res.Sch_XsiNilAndFixed);
                 }
             }
         }
         else if (xsiNil != null)
         {
             SendValidationEvent(Res.Sch_InvalidXsiNill);
         }
     }
     return(elementDecl);
 }
Exemple #3
0
 private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil)
 {
     if (elementDecl == null)
     {
         elementDecl = base.schemaInfo.GetElementDecl(base.elementName);
     }
     if (elementDecl != null)
     {
         if (xsiType.IsEmpty)
         {
             if (elementDecl.IsAbstract)
             {
                 base.SendValidationEvent("Sch_AbstractElement", XmlSchemaValidator.QNameString(base.context.LocalName, base.context.Namespace));
                 elementDecl = null;
             }
         }
         else if ((xsiNil != null) && xsiNil.Equals("true"))
         {
             base.SendValidationEvent("Sch_XsiNilAndType");
         }
         else
         {
             SchemaElementDecl decl;
             if (!base.schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out decl) && (xsiType.Namespace == this.NsXs))
             {
                 XmlSchemaSimpleType simpleTypeFromXsdType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, this.NsXs));
                 if (simpleTypeFromXsdType != null)
                 {
                     decl = simpleTypeFromXsdType.ElementDecl;
                 }
             }
             if (decl == null)
             {
                 base.SendValidationEvent("Sch_XsiTypeNotFound", xsiType.ToString());
                 elementDecl = null;
             }
             else if (!XmlSchemaType.IsDerivedFrom(decl.SchemaType, elementDecl.SchemaType, elementDecl.Block))
             {
                 base.SendValidationEvent("Sch_XsiTypeBlockedEx", new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(base.context.LocalName, base.context.Namespace) });
                 elementDecl = null;
             }
             else
             {
                 elementDecl = decl;
             }
         }
         if ((elementDecl != null) && elementDecl.IsNillable)
         {
             if (xsiNil != null)
             {
                 base.context.IsNill = XmlConvert.ToBoolean(xsiNil);
                 if (base.context.IsNill && (elementDecl.DefaultValueTyped != null))
                 {
                     base.SendValidationEvent("Sch_XsiNilAndFixed");
                 }
             }
             return(elementDecl);
         }
         if (xsiNil != null)
         {
             base.SendValidationEvent("Sch_InvalidXsiNill");
         }
     }
     return(elementDecl);
 }