internal SimpleTypeValidator(XmlSchemaDatatypeVariety variety, XmlSchemaSimpleType type, Xml.Schema.Linq.FacetsChecker facetsChecker, Xml.Schema.Linq.RestrictionFacets facets) { this.restrictionFacets = facets; this.facetsChecker = facetsChecker; this.dataType = type.Datatype; this.variety = variety; }
private static Type GetEffectiveType(XmlTypeCode typeCode, XmlSchemaDatatypeVariety variety, GeneratorConfiguration configuration) { Type result; switch (typeCode) { case XmlTypeCode.AnyAtomicType: // union result = typeof(string); break; case XmlTypeCode.AnyUri: case XmlTypeCode.Duration: case XmlTypeCode.GDay: case XmlTypeCode.GMonth: case XmlTypeCode.GMonthDay: case XmlTypeCode.GYear: case XmlTypeCode.GYearMonth: result = variety == XmlSchemaDatatypeVariety.List ? typeof(string[]) : typeof(string); break; case XmlTypeCode.Time: if (configuration.TimeDataType == null || configuration.TimeDataType == typeof(string)) { // default to string result = typeof(string); } else { // otherwise, use the specified type result = configuration.TimeDataType; } break; case XmlTypeCode.Integer: case XmlTypeCode.NegativeInteger: case XmlTypeCode.NonNegativeInteger: case XmlTypeCode.NonPositiveInteger: case XmlTypeCode.PositiveInteger: if (configuration.IntegerDataType == null || configuration.IntegerDataType == typeof(string)) { result = typeof(string); } else { result = configuration.IntegerDataType; } break; default: result = null; break; } return(result); }
private void SetVariety(XmlSchemaDatatype datatype) { XmlSchemaDatatypeVariety variety = datatype.Variety; if (variety == XmlSchemaDatatypeVariety.List) { typeRefFlags |= ClrTypeRefFlags.IsSchemaList; } else if (variety == XmlSchemaDatatypeVariety.Union) { typeRefFlags |= ClrTypeRefFlags.IsUnion; } }
private static Type GetEffectiveType(XmlTypeCode typeCode, XmlSchemaDatatypeVariety variety, GeneratorConfiguration configuration) { Type result; switch (typeCode) { case XmlTypeCode.AnyAtomicType: // union result = typeof(string); break; case XmlTypeCode.AnyUri: case XmlTypeCode.Duration: case XmlTypeCode.GDay: case XmlTypeCode.GMonth: case XmlTypeCode.GMonthDay: case XmlTypeCode.GYear: case XmlTypeCode.GYearMonth: case XmlTypeCode.Time: result = variety == XmlSchemaDatatypeVariety.List ? typeof(string[]) : typeof(string); break; case XmlTypeCode.Integer: case XmlTypeCode.NegativeInteger: case XmlTypeCode.NonNegativeInteger: case XmlTypeCode.NonPositiveInteger: case XmlTypeCode.PositiveInteger: if (configuration.IntegerDataType == null || configuration.IntegerDataType == typeof(string)) result = typeof(string); else { result = configuration.IntegerDataType; } break; default: result = null; break; } return result; }
internal SimpleTypeValidator(XmlSchemaDatatypeVariety variety, XmlSchemaSimpleType type, FacetsChecker facetsChecker, RestrictionFacets facets) { this.restrictionFacets = facets; this.facetsChecker = facetsChecker; this.dataType = type.Datatype; this.variety = variety; }
internal ClrSimpleTypeInfo(XmlSchemaType innerType) { this.innerType = innerType; this.variety = innerType.Datatype.Variety; }
private static void Binarize(CompoundField compilerInfo, string prefix, XmlSchemaElement elem, uint index, uint cardinality) { XmlSchemaDatatypeVariety dataType = elem.ElementSchemaType.Datatype.Variety; string name = prefix + elem.Name; if (cardinality > 1) { throw new XmlBinaryConverterException("cardinality greater than 1 is not supported"); //name += "[" + index + "]"; } ACompilerInfoField cif = null; IEnumerable <XmlSchemaLengthFacet> lengthFacets; IEnumerable <XmlSchemaMaxLengthFacet> maxLengthFacet; IEnumerable <XmlSchemaEnumerationFacet> enumerationFacets; switch (elem.ElementSchemaType.TypeCode) { case XmlTypeCode.String: try { var simpleType = elem.ElementSchemaType as XmlSchemaSimpleType; var restriction = simpleType.Content as XmlSchemaSimpleTypeRestriction; maxLengthFacet = restriction.Facets.OfType <XmlSchemaMaxLengthFacet>(); enumerationFacets = restriction.Facets.OfType <XmlSchemaEnumerationFacet>(); } catch (Exception e) { throw new XmlBinaryConverterException($"Unexpected exception while processing element {name}"); } if (maxLengthFacet.Count() != 0) { cif = new StringField(name, uint.Parse(maxLengthFacet.ElementAt(0).Value)); } else if (enumerationFacets.Count() != 0) { List <string> values = enumerationFacets.Select(e => e.Value).ToList(); cif = new StringEnumField(name, values); } else { throw new XmlBinaryConverterException( $"String {name} have unrestricted length and thus is not supported for schema generation"); } break; case XmlTypeCode.Int: cif = new Int32Field(name); break; case XmlTypeCode.UnsignedInt: cif = new UInt32Field(name); break; case XmlTypeCode.Short: cif = new Int16Field(name); break; case XmlTypeCode.UnsignedShort: cif = new UInt16Field(name); break; case XmlTypeCode.Byte: cif = new SByteField(name); break; case XmlTypeCode.UnsignedByte: cif = new ByteField(name); break; case XmlTypeCode.UnsignedLong: cif = new UInt64Field(name); break; case XmlTypeCode.Boolean: cif = new BooleanField(name); break; case XmlTypeCode.HexBinary: try { var simpleType = elem.ElementSchemaType as XmlSchemaSimpleType; var restriction = simpleType.Content as XmlSchemaSimpleTypeRestriction; lengthFacets = restriction.Facets.OfType <XmlSchemaLengthFacet>(); } catch (Exception e) { throw new XmlBinaryConverterException($"Unexpected exception while processing element {name}"); } if (lengthFacets.Count() != 0) { uint size = uint.Parse(lengthFacets.ElementAt(0).Value); cif = new HexBinaryField(name, size); } else { throw new XmlBinaryConverterException( $"HexBinary {name} have unrestricted length and thus is not supported for schema generation"); } break; case XmlTypeCode.DateTime: cif = new DateTimeField(name, "yyyyMMddHHmmss"); break; default: { throw new XmlBinaryConverterException($"{name} have unsupported type {elem.ElementSchemaType.TypeCode}"); } } if (cif == null) { throw new XmlBinaryConverterException($"Internal error: unable to create a conversion structure for {name}"); } compilerInfo.AddField(cif); }
internal ClrSimpleTypeInfo(XmlSchemaType innerType) { this.innerType = innerType; this.variety = innerType.Datatype.Variety; }