Exemple #1
0
 public Generator_nonPositiveInteger(CompiledFacets rFacets)
 {
     startValue = 0;
         increment = 1;
         maxBound = 0;
         CheckFacets(rFacets);
 }
Exemple #2
0
 public Generator_float(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #3
0
 public Generator_gDay(CompiledFacets rFacets)
     : base(rFacets)
 {
 }
Exemple #4
0
 public void CheckFacets(CompiledFacets genFacets)
 {
     if(genFacets != null) {
             RestrictionFlags flags = genFacets.Flags;
             if ((flags & RestrictionFlags.MaxInclusive) != 0) {
                 maxBound = (TimeSpan)genFacets.MaxInclusive;
             }
             if ((flags & RestrictionFlags.MaxExclusive) != 0) {
                 maxBound = (TimeSpan)genFacets.MaxExclusive - endValue;
             }
             if ((flags & RestrictionFlags.MinInclusive) != 0) {
                 startValue = (TimeSpan)genFacets.MinInclusive;
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.MinExclusive) != 0) {
                 startValue = (TimeSpan)genFacets.MinExclusive + endValue;
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.Enumeration) != 0) {
                 AllowedValues = genFacets.Enumeration;
             }
             if(TimeSpan.Compare(maxBound, TimeSpan.Zero) == -1) {
                 startValue = maxBound;
                 occurNum++;
                 stateStep = 2;
             }
             if (TimeSpan.Compare(minBound, startValue) == 0) {
                 stateStep = 2;
             }
         }
 }
Exemple #5
0
 public Generator_base64Binary(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #6
0
 public Generator_decimal(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #7
0
 public Generator_double(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #8
0
 public Generator_time(CompiledFacets rFacets)
 {
     step = XmlConvert.ToTimeSpan("PT1M30S");
         CheckFacets(rFacets);
 }
Exemple #9
0
 public Generator_token(CompiledFacets rFacets)
 {
     Prefix = "Token";
       CheckFacets(rFacets);
 }
Exemple #10
0
 public Generator_short(CompiledFacets rFacets)
 {
     maxBound = 32767;
         minBound = -32768;
         CheckFacets(rFacets);
 }
Exemple #11
0
 public Generator_string(CompiledFacets rFacets)
 {
     if(rFacets != null) {
             CheckFacets(rFacets);
         }
 }
Exemple #12
0
 public Generator_QName(CompiledFacets rFacets)
 {
     Prefix = "qname";
         CheckFacets(rFacets);
 }
Exemple #13
0
 public Generator_positiveInteger(CompiledFacets rFacets)
 {
     startValue = 1;
         minBound = 1;
         CheckFacets(rFacets);
 }
Exemple #14
0
 public Generator_normalizedString(CompiledFacets rFacets)
     : base(rFacets)
 {
 }
Exemple #15
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;
 }
Exemple #16
0
 public Generator_unsignedByte(CompiledFacets rFacets)
 {
     maxBound = 255;
         CheckFacets(rFacets);
 }
Exemple #17
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;
 }
Exemple #18
0
 public Generator_unsignedInt(CompiledFacets rFacets)
 {
     maxBound = 4294967295;
         CheckFacets(rFacets);
 }
Exemple #19
0
        public void CheckFacets(CompiledFacets genFacets)
        {
            if(genFacets != null) {
                RestrictionFlags flags = genFacets.Flags;
                if ((flags & RestrictionFlags.MaxInclusive) != 0) {
                    maxBound = (decimal)Convert.ChangeType(genFacets.MaxInclusive, typeof(decimal));
                }
                if ((flags & RestrictionFlags.MaxExclusive) != 0) {
                    maxBound = (decimal)Convert.ChangeType(genFacets.MaxExclusive, typeof(decimal)) - 1;
                }
                if ((flags & RestrictionFlags.MinInclusive) != 0) {
                    startValue = (decimal)Convert.ChangeType(genFacets.MinInclusive, typeof(decimal));
                    minBound = startValue;
                }
                if ((flags & RestrictionFlags.MinExclusive) != 0) {
                    startValue = (decimal)Convert.ChangeType(genFacets.MinExclusive, typeof(decimal)) + 1;
                    minBound = startValue;
                }
                if ((flags & RestrictionFlags.Enumeration) != 0) {
                    AllowedValues = genFacets.Enumeration;
                }
                if ((flags & RestrictionFlags.TotalDigits) != 0) {
                    decimal totalDigitsValue = (decimal)Math.Pow(10,genFacets.TotalDigits) - 1;
                    if (totalDigitsValue <= maxBound) { //Use the lower of totalDigits value and maxInc/maxEx
                        maxBound = totalDigitsValue;
                        minBound = 0 - maxBound;
                    }

                }
                if ((flags & RestrictionFlags.FractionDigits) != 0 && genFacets.FractionDigits > 0) {
                    if ((flags & RestrictionFlags.TotalDigits) != 0) {
                        //if (T,F) is (6,3) the max value is not 999.999 but 99999.9d but we are going with the smaller range on the integral part to generate more varied fractional part.
                        int range = genFacets.TotalDigits - genFacets.FractionDigits;
                        double integralPart = Math.Pow(10,range) - 1;
                        double fractionPart = integralPart/Math.Pow(10,range);
                        maxBound = (decimal)(integralPart + fractionPart);
                        minBound = 0 - maxBound;
                        step = (decimal)(1/Math.Pow(10,range));
                    }
                    //If there is no TotalDigits facet, we use the step for decimal as 0.1 anyway which will satisfy fractionDigits >= 1
                }
                if(maxBound <= 0) {
                    startValue = maxBound;
                    occurNum++;
                    stateStep = 2;
                }
                if (startValue == minBound) {
                    stateStep = 2;
                }
              }
        }
Exemple #20
0
 public Generator_dateTime(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #21
0
 public Generator_duration(CompiledFacets rFacets)
 {
     CheckFacets(rFacets);
 }
Exemple #22
0
 public Generator_unsignedLong(CompiledFacets rFacets)
 {
     maxBound = 18446744073709551615;
         CheckFacets(rFacets);
 }
Exemple #23
0
 public Generator_anyURI(CompiledFacets rFacets)
 {
     Prefix = "http://uri";
         CheckFacets(rFacets);
 }
Exemple #24
0
 public Generator_unsignedShort(CompiledFacets rFacets)
 {
     maxBound = 65535;
         CheckFacets(rFacets);
 }
Exemple #25
0
 internal void CheckFacets(CompiledFacets genFacets)
 {
     if(genFacets != null) {
             RestrictionFlags flags = genFacets.Flags;
             if ((flags & RestrictionFlags.Length) != 0) {
                 length = genFacets.Length;
             }
             if ((flags & RestrictionFlags.MinLength) != 0) {
                 minLength = genFacets.MinLength;
             }
             if ((flags & RestrictionFlags.MaxLength) != 0) {
                 maxLength = genFacets.MaxLength;
             }
             if ((flags & RestrictionFlags.Enumeration) != 0) {
                 AllowedValues = genFacets.Enumeration;
             }
           }
 }
Exemple #26
0
 public void CheckFacets(CompiledFacets genFacets)
 {
     if(genFacets != null) {
             RestrictionFlags flags = genFacets.Flags;
             if ((flags & RestrictionFlags.MaxInclusive) != 0) {
                 maxBound = (DateTime)genFacets.MaxInclusive;
             }
             if ((flags & RestrictionFlags.MaxExclusive) != 0) {
                 maxBound = ((DateTime)genFacets.MaxExclusive).Subtract(step);
             }
             if ((flags & RestrictionFlags.MinInclusive) != 0) {
                 startValue = (DateTime)genFacets.MinInclusive;
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.MinExclusive) != 0) {
                 startValue = ((DateTime)genFacets.MinExclusive).Add(step);
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.Enumeration) != 0) {
                 AllowedValues = genFacets.Enumeration;
             }
             if (DateTime.Compare(startValue, maxBound) == 0) {
                 occurNum++;
                 stateStep = 2;
             }
             if (DateTime.Compare(startValue, minBound) == 0) {
                 stateStep = 2;
             }
         }
 }
Exemple #27
0
 public void CheckFacets(CompiledFacets genFacets)
 {
     if(genFacets != null) {
             RestrictionFlags flags = genFacets.Flags;
             if ((flags & RestrictionFlags.MaxInclusive) != 0) {
                 maxBound = (float)genFacets.MaxInclusive;
             }
             if ((flags & RestrictionFlags.MaxExclusive) != 0) {
                 maxBound = (float)genFacets.MaxExclusive - 1;
             }
             if ((flags & RestrictionFlags.MinInclusive) != 0) {
                 startValue = (float)genFacets.MinInclusive;
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.MinExclusive) != 0) {
                 startValue = (float)genFacets.MinExclusive + 1;
                 minBound = startValue;
             }
             if ((flags & RestrictionFlags.Enumeration) != 0) {
                 AllowedValues = genFacets.Enumeration;
             }
             if(maxBound <= 0) {
                 startValue = maxBound;
                 occurNum++;
                 stateStep = 2;
             }
             if (startValue == minBound) {
                 stateStep = 2;
             }
         }
 }
Exemple #28
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;
        }
Exemple #29
0
 public Generator_gMonthDay(CompiledFacets rFacets)
 {
     step = XmlConvert.ToTimeSpan("P1M5D");
         CheckFacets(rFacets);
 }
Exemple #30
0
 public Generator_nonNegativeInteger(CompiledFacets rFacets)
 {
     startValue = 0;
         minBound = 0;
         CheckFacets(rFacets);
 }