Ejemplo n.º 1
0
        private static XmlValueGenerator CreateListGenerator(XmlSchemaDatatype dtype, CompiledFacets facets, int listLength)
        {
            XmlSchemaDatatype itemType  = (XmlSchemaDatatype)dtype.GetType().InvokeMember("itemType", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, dtype, null);
            Generator_List    list_genr = new Generator_List(facets);

            list_genr.ListLength = listLength;
            list_genr.AddGenerator(XmlValueGenerator.CreateGenerator(itemType, listLength));
            return(list_genr);
        }
Ejemplo n.º 2
0
        private static XmlValueGenerator CreateUnionGenerator(XmlSchemaDatatype dtype, CompiledFacets facets, int listLength)
        {
            XmlSchemaSimpleType[] memberTypes = (XmlSchemaSimpleType[])dtype.GetType().InvokeMember("types", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, dtype, null);
            Generator_Union       union_genr  = new Generator_Union(facets);

            foreach (XmlSchemaSimpleType st1 in memberTypes)
            {
                union_genr.AddGenerator(XmlValueGenerator.CreateGenerator(st1.Datatype, listLength));
            }

            return(union_genr);
        }
Ejemplo n.º 3
0
        string [] GetDerived(string target)
        {
            XmlSchemaDatatype strType = GetDatatype(target);
            List <string>     results = new List <string> ();

            foreach (string name in allTypes)
            {
                if (name == target)
                {
                    continue;
                }
                XmlSchemaDatatype deriv = GetDatatype(name);
                if (deriv.IsDerivedFrom(strType))
                {
                    results.Add(name);
                }
                else
                {
                    Console.Error.WriteLine(deriv.GetType() + " is not derived from " + strType.GetType());
                }
            }
            return(results.ToArray());
        }
        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.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 == anySimpleType.Datatype);
            }
            return false;
        }
Ejemplo n.º 5
0
        internal static XmlValueGenerator CreateGenerator(XmlSchemaDatatype datatype, int listLength)
        {
            XmlTypeCode typeCode = datatype.TypeCode;

            object            restriction = datatype.GetType().InvokeMember("Restriction", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, null, datatype, null);
            CompiledFacets    rFacets     = new CompiledFacets(restriction);
            XmlValueGenerator generator;

            if (datatype.Variety == XmlSchemaDatatypeVariety.Union)
            {
                generator = CreateUnionGenerator(datatype, rFacets, listLength);
            }
            else if (datatype.Variety == XmlSchemaDatatypeVariety.List)
            {
                generator = CreateListGenerator(datatype, rFacets, listLength);
            }
            else
            {
                switch (typeCode)
                {
                case XmlTypeCode.None:
                    generator = _anyGenerator;
                    break;

                case XmlTypeCode.Item:
                    generator = _anyGenerator;
                    break;

                case XmlTypeCode.AnyAtomicType:
                    generator = _anySimpleTypeGenerator;
                    break;

                case XmlTypeCode.String:
                    generator = new Generator_string(rFacets);
                    break;

                case XmlTypeCode.Boolean:
                    generator = new Generator_boolean();
                    break;

                case XmlTypeCode.Float:
                    generator = new Generator_float(rFacets);
                    break;

                case XmlTypeCode.Double:
                    generator = new Generator_double(rFacets);
                    break;

                case XmlTypeCode.AnyUri:
                    generator = new Generator_anyURI(rFacets);
                    break;

                case XmlTypeCode.Integer:
                    generator = new Generator_integer(rFacets);
                    break;

                case XmlTypeCode.Decimal:
                    generator = new Generator_decimal(rFacets);
                    break;

                case XmlTypeCode.NonPositiveInteger:
                    generator = new Generator_nonPositiveInteger(rFacets);
                    break;

                case XmlTypeCode.NegativeInteger:
                    generator = new Generator_negativeInteger(rFacets);
                    break;

                case XmlTypeCode.Long:
                    generator = new Generator_long(rFacets);
                    break;

                case XmlTypeCode.Int:
                    generator = new Generator_integer(rFacets);
                    break;

                case XmlTypeCode.Short:
                    generator = new Generator_short(rFacets);
                    break;

                case XmlTypeCode.Byte:
                    generator = new Generator_byte(rFacets);
                    break;

                case XmlTypeCode.NonNegativeInteger:
                    generator = new Generator_nonNegativeInteger(rFacets);
                    break;

                case XmlTypeCode.UnsignedLong:
                    generator = new Generator_unsignedLong(rFacets);
                    break;

                case XmlTypeCode.UnsignedInt:
                    generator = new Generator_unsignedInt(rFacets);
                    break;

                case XmlTypeCode.UnsignedShort:
                    generator = new Generator_unsignedShort(rFacets);
                    break;

                case XmlTypeCode.UnsignedByte:
                    generator = new Generator_unsignedByte(rFacets);
                    break;

                case XmlTypeCode.PositiveInteger:
                    generator = new Generator_positiveInteger(rFacets);
                    break;

                case XmlTypeCode.Duration:
                    generator = new Generator_duration(rFacets);
                    break;

                case XmlTypeCode.DateTime:
                    generator = new Generator_dateTime(rFacets);
                    break;

                case XmlTypeCode.Date:
                    generator = new Generator_date(rFacets);
                    break;

                case XmlTypeCode.GYearMonth:
                    generator = new Generator_gYearMonth(rFacets);
                    break;

                case XmlTypeCode.GYear:
                    generator = new Generator_gYear(rFacets);
                    break;

                case XmlTypeCode.GMonthDay:
                    generator = new Generator_gMonthDay(rFacets);
                    break;

                case XmlTypeCode.GDay:
                    generator = new Generator_gDay(rFacets);
                    break;

                case XmlTypeCode.GMonth:
                    generator = new Generator_gMonth(rFacets);
                    break;

                case XmlTypeCode.Time:
                    generator = new Generator_time(rFacets);
                    break;

                case XmlTypeCode.HexBinary:
                    generator = new Generator_hexBinary(rFacets);
                    break;

                case XmlTypeCode.Base64Binary:
                    generator = new Generator_base64Binary(rFacets);
                    break;

                case XmlTypeCode.QName:
                    generator = new Generator_QName(rFacets);
                    break;

                case XmlTypeCode.Notation:
                    generator = new Generator_Notation(rFacets);
                    break;

                case XmlTypeCode.NormalizedString:
                    generator = new Generator_string(rFacets);
                    break;

                case XmlTypeCode.Token:
                case XmlTypeCode.NmToken:
                    generator = new Generator_token(rFacets);
                    break;

                case XmlTypeCode.Language:
                    generator = new Generator_language(rFacets);
                    break;

                case XmlTypeCode.Name:
                    generator = new Generator_Name(rFacets);
                    break;

                case XmlTypeCode.NCName:
                    generator = new Generator_NCName(rFacets);
                    break;

                case XmlTypeCode.Id:
                    _g_ID.CheckFacets(rFacets);
                    generator = _g_ID;
                    break;

                case XmlTypeCode.Idref:
                    _g_IDREF.CheckFacets(rFacets);
                    generator = _g_IDREF;
                    break;

                default:
                    generator = _anyGenerator;
                    break;
                }
            }

            generator.SetDatatype(datatype);

            return(generator);
        }
Ejemplo n.º 6
0
 private static XmlValueGenerator CreateUnionGenerator(XmlSchemaDatatype dtype, CompiledFacets facets, int listLength)
 {
     XmlSchemaSimpleType[] memberTypes = (XmlSchemaSimpleType[])dtype.GetType().InvokeMember("types", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, dtype, null);
     Generator_Union union_genr = new Generator_Union(facets);
     foreach(XmlSchemaSimpleType st1 in memberTypes) {
         union_genr.AddGenerator(XmlValueGenerator.CreateGenerator(st1.Datatype, listLength));
     }
     return union_genr;
 }
Ejemplo n.º 7
0
 private static XmlValueGenerator CreateListGenerator(XmlSchemaDatatype dtype, CompiledFacets facets, int listLength)
 {
     XmlSchemaDatatype itemType = (XmlSchemaDatatype)dtype.GetType().InvokeMember("itemType", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, dtype, null);
     Generator_List list_genr = new Generator_List(facets);
     list_genr.ListLength = listLength;
     list_genr.AddGenerator(XmlValueGenerator.CreateGenerator(itemType, listLength));
     return list_genr;
 }
Ejemplo n.º 8
0
        internal static XmlValueGenerator CreateGenerator(XmlSchemaDatatype datatype, int listLength)
        {
            XmlTypeCode typeCode = datatype.TypeCode;

            object restriction = datatype.GetType().InvokeMember("Restriction", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, null, datatype, null);
            CompiledFacets rFacets = new CompiledFacets(restriction);
            XmlValueGenerator generator;

            if (datatype.Variety == XmlSchemaDatatypeVariety.Union) {
                generator = CreateUnionGenerator(datatype, rFacets, listLength);
            }
            else if (datatype.Variety == XmlSchemaDatatypeVariety.List) {
                generator = CreateListGenerator(datatype, rFacets, listLength);
            }
            else {
                switch (typeCode) {
                    case XmlTypeCode.None:
                        generator = AnyGenerator;
                        break;
                    case XmlTypeCode.Item:
                        generator = AnyGenerator;
                        break;
                    case XmlTypeCode.AnyAtomicType:
                        generator = AnySimpleTypeGenerator;
                        break;
                    case XmlTypeCode.String:
                        generator = new Generator_string(rFacets);
                        break;
                    case XmlTypeCode.Boolean:
                        generator = new Generator_boolean();
                        break;
                    case XmlTypeCode.Float:
                        generator = new Generator_float(rFacets);
                        break;
                    case XmlTypeCode.Double:
                        generator = new Generator_double(rFacets);
                        break;
                    case XmlTypeCode.AnyUri:
                        generator = new Generator_anyURI(rFacets);
                        break;
                    case XmlTypeCode.Integer:
                        generator = new Generator_integer(rFacets);
                        break;
                    case XmlTypeCode.Decimal:
                        generator = new Generator_decimal(rFacets);
                        break;
                    case XmlTypeCode.NonPositiveInteger:
                        generator = new Generator_nonPositiveInteger(rFacets);
                        break;
                    case XmlTypeCode.NegativeInteger:
                        generator = new Generator_negativeInteger(rFacets);
                        break;
                    case XmlTypeCode.Long:
                        generator = new Generator_long(rFacets);
                        break;
                    case XmlTypeCode.Int:
                        generator = new Generator_int(rFacets);
                        break;
                    case XmlTypeCode.Short:
                        generator = new Generator_short(rFacets);
                        break;
                    case XmlTypeCode.Byte:
                        generator = new Generator_byte(rFacets);
                        break;
                    case XmlTypeCode.NonNegativeInteger:
                        generator = new Generator_nonNegativeInteger(rFacets);
                        break;
                    case XmlTypeCode.UnsignedLong:
                        generator = new Generator_unsignedLong(rFacets);
                        break;
                    case XmlTypeCode.UnsignedInt:
                        generator = new Generator_unsignedInt(rFacets);
                        break;
                    case XmlTypeCode.UnsignedShort:
                        generator = new Generator_unsignedShort(rFacets);
                        break;
                    case XmlTypeCode.UnsignedByte:
                        generator = new Generator_unsignedByte(rFacets);
                        break;
                    case XmlTypeCode.PositiveInteger:
                        generator = new Generator_positiveInteger(rFacets);
                        break;
                    case XmlTypeCode.Duration:
                        generator = new Generator_duration(rFacets);
                        break;
                    case XmlTypeCode.DateTime:
                        generator = new Generator_dateTime(rFacets);
                        break;
                    case XmlTypeCode.Date:
                        generator = new Generator_date(rFacets);
                        break;
                    case XmlTypeCode.GYearMonth:
                        generator = new Generator_gYearMonth(rFacets);
                        break;
                    case XmlTypeCode.GYear:
                        generator = new Generator_gYear(rFacets);
                        break;
                    case XmlTypeCode.GMonthDay:
                        generator = new Generator_gMonthDay(rFacets);
                        break;
                    case XmlTypeCode.GDay:
                        generator = new Generator_gDay(rFacets);
                        break;
                    case XmlTypeCode.GMonth:
                        generator = new Generator_gMonth(rFacets);
                        break;
                    case XmlTypeCode.Time:
                        generator = new Generator_time(rFacets);
                        break;
                    case XmlTypeCode.HexBinary:
                        generator = new Generator_hexBinary(rFacets);
                        break;
                    case XmlTypeCode.Base64Binary:
                        generator = new Generator_base64Binary(rFacets);
                        break;
                    case XmlTypeCode.QName:
                        generator = new Generator_QName(rFacets);
                        break;
                    case XmlTypeCode.Notation:
                        generator = new Generator_Notation(rFacets);
                        break;
                    case XmlTypeCode.NormalizedString:
                        generator = new Generator_normalizedString(rFacets);
                        break;
                    case XmlTypeCode.Token:
                        generator = new Generator_token(rFacets);
                        break;
                    case XmlTypeCode.Language:
                        generator = new Generator_language(rFacets);
                        break;
                    case XmlTypeCode.NmToken:
                        generator = new Generator_NMTOKEN(rFacets);
                        break;
                    case XmlTypeCode.Name:
                        generator = new Generator_Name(rFacets);
                        break;
                    case XmlTypeCode.NCName:
                        generator = new Generator_NCName(rFacets);
                        break;
                    case XmlTypeCode.Id:
                        g_ID.CheckFacets(rFacets);
                        generator = g_ID;
                        break;
                    case XmlTypeCode.Idref:
                        g_IDREF.CheckFacets(rFacets);
                        generator = g_IDREF;
                        break;
                    default:
                        generator = AnyGenerator;
                        break;
                }
            }
            generator.SetDatatype(datatype);
            return generator;
        }
Ejemplo n.º 9
0
 internal new bool IsDerivedFrom(XmlSchemaDatatype dtype) {
     if (variety == XmlSchemaDatatypeVariety.Union) {
         return ((Datatype_union)this).IsDerivedFromUnion(dtype);
     }
     else if (((DatatypeImplementation)dtype).baseType == null) {
         Type derivedType = this.GetType();
         Type baseType = dtype.GetType();
         return baseType == derivedType || derivedType.IsSubclassOf(baseType);
     }
     else {
         for(DatatypeImplementation dt = this; dt != null; dt = dt.baseType) {
             if (dt == dtype) {
                 return true;
             }
         }
     }
     return false;
 }
 public override bool IsDerivedFrom(XmlSchemaDatatype datatype)
 {
     if (datatype == null)
     {
         return false;
     }
     for (DatatypeImplementation implementation = this; implementation != null; implementation = implementation.baseType)
     {
         if (implementation == datatype)
         {
             return true;
         }
     }
     if (((DatatypeImplementation) datatype).baseType == null)
     {
         Type type = base.GetType();
         Type c = datatype.GetType();
         if (!(c == type))
         {
             return type.IsSubclassOf(c);
         }
         return true;
     }
     if (((datatype.Variety == XmlSchemaDatatypeVariety.Union) && !datatype.HasLexicalFacets) && (!datatype.HasValueFacets && (this.variety != XmlSchemaDatatypeVariety.Union)))
     {
         return ((Datatype_union) datatype).IsUnionBaseOf(this);
     }
     return ((((this.variety == XmlSchemaDatatypeVariety.Union) || (this.variety == XmlSchemaDatatypeVariety.List)) && (this.restriction == null)) && (datatype == anySimpleType.Datatype));
 }