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;
}