本文整理汇总了C#中XmlTypeCode类的典型用法代码示例。如果您正苦于以下问题:C# XmlTypeCode类的具体用法?C# XmlTypeCode怎么用?C# XmlTypeCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTypeCode类属于命名空间,在下文中一共展示了XmlTypeCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGetBuiltInSimpleType
internal static CodeExpression CreateGetBuiltInSimpleType(XmlTypeCode typeCode) {
return CodeDomHelper.CreateMethodCall(
new CodeTypeReferenceExpression("XmlSchemaType"),
Constants.GetBuiltInSimpleType,
CodeDomHelper.CreateFieldReference(Constants.XmlTypeCode, typeCode.ToString()));
}
示例2: IsDataTypeAttributeAllowed
private static bool? IsDataTypeAttributeAllowed(XmlTypeCode typeCode, GeneratorConfiguration configuration)
{
bool? result;
switch (typeCode)
{
case XmlTypeCode.AnyAtomicType:
// union
result = false;
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 = false;
else
result = null;
break;
case XmlTypeCode.Base64Binary:
case XmlTypeCode.HexBinary:
result = true;
break;
default:
result = null;
break;
}
return result;
}
示例3: Init
private void Init (DateTime value, XmlSchemaType xmlType)
{
if (xmlType == null)
throw new ArgumentNullException ("xmlType");
xmlTypeCode = XmlTypeCode.DateTime;
this.dateTimeValue = value;
schemaType = xmlType;
}
示例4: GetBuiltInComplexType
public static XmlSchemaComplexType GetBuiltInComplexType(XmlTypeCode typeCode)
{
if (typeCode == XmlTypeCode.Item)
{
return XmlSchemaComplexType.AnyType;
}
return null;
}
示例5: Init
private void Init (byte [] value, XmlSchemaType xmlType)
{
if (xmlType == null)
throw new ArgumentNullException ("xmlType");
xmlTypeCode = XmlTypeCode.Base64Binary;
this.bytesValue = value;
schemaType = xmlType;
}
示例6: GetFacetsChecker
internal static FacetsChecker GetFacetsChecker(XmlTypeCode typeCode)
{
if (FacetsCheckerMapping == null)
{
InitMapping();
}
return FacetsCheckerMapping[typeCode];
}
示例7: FacetsCompiler
public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction) {
firstPattern = true;
regStr = null;
pattern_facet = null;
datatype = baseDatatype;
derivedRestriction = restriction;
baseFlags = datatype.Restriction != null ? datatype.Restriction.Flags : 0;
baseFixedFlags = datatype.Restriction != null ? datatype.Restriction.FixedFlags : 0;
validRestrictionFlags = datatype.ValidRestrictionFlags;
nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
builtInEnum = !(datatype is Datatype_union || datatype is Datatype_List) ? datatype.TypeCode : 0;
builtInType = (int)builtInEnum > 0 ? DatatypeImplementation.GetSimpleTypeFromTypeCode(builtInEnum).Datatype : datatype;
}
示例8: FacetsCompiler
public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction)
{
_firstPattern = true;
_regStr = null;
_pattern_facet = null;
_datatype = baseDatatype;
_derivedRestriction = restriction;
_baseFlags = _datatype.Restriction != null ? _datatype.Restriction.Flags : 0;
_baseFixedFlags = _datatype.Restriction != null ? _datatype.Restriction.FixedFlags : 0;
_validRestrictionFlags = _datatype.ValidRestrictionFlags;
_nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
_builtInEnum = !(_datatype is Datatype_union || _datatype is Datatype_List) ? _datatype.TypeCode : 0;
_builtInType = (int)_builtInEnum > 0 ? DatatypeImplementation.GetSimpleTypeFromTypeCode(_builtInEnum).Datatype : _datatype;
}
示例9: CheckBuiltInFacets
private Exception CheckBuiltInFacets(string s, XmlTypeCode typeCode, bool verifyUri)
{
Exception exception = null;
switch (typeCode)
{
case XmlTypeCode.AnyUri:
if (verifyUri)
{
Uri uri;
exception = XmlConvert.TryToUri(s, out uri);
}
return exception;
case XmlTypeCode.QName:
case XmlTypeCode.Notation:
return exception;
case XmlTypeCode.NormalizedString:
return XmlConvert.TryVerifyNormalizedString(s);
case XmlTypeCode.Token:
return XmlConvert.TryVerifyTOKEN(s);
case XmlTypeCode.Language:
if ((s != null) && (s.Length != 0))
{
if (!LanguagePattern.IsMatch(s))
{
return new XmlSchemaException("Sch_InvalidLanguageId", string.Empty);
}
return exception;
}
return new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
case XmlTypeCode.NmToken:
return XmlConvert.TryVerifyNMTOKEN(s);
case XmlTypeCode.Name:
return XmlConvert.TryVerifyName(s);
case XmlTypeCode.NCName:
case XmlTypeCode.Id:
case XmlTypeCode.Idref:
case XmlTypeCode.Entity:
return XmlConvert.TryVerifyNCName(s);
}
return exception;
}
示例10: GetFallbackType
public static XmlTypeCode GetFallbackType (XmlTypeCode type)
{
switch (type) {
case XmlTypeCode.AnyAtomicType:
return XmlTypeCode.Item;
case XmlTypeCode.UntypedAtomic:
return XmlTypeCode.String;
case XmlTypeCode.Notation:
return XmlTypeCode.QName;
case XmlTypeCode.NormalizedString:
case XmlTypeCode.Token:
case XmlTypeCode.Language:
case XmlTypeCode.NmToken:
case XmlTypeCode.Name:
case XmlTypeCode.NCName:
case XmlTypeCode.Id:
case XmlTypeCode.Idref:
case XmlTypeCode.Entity:
return XmlTypeCode.String;
case XmlTypeCode.NonPositiveInteger:
return XmlTypeCode.Decimal;
case XmlTypeCode.NegativeInteger:
return XmlTypeCode.NonPositiveInteger;
case XmlTypeCode.Long:
return XmlTypeCode.Integer;
case XmlTypeCode.Short:
return XmlTypeCode.Int;
case XmlTypeCode.Byte:
return XmlTypeCode.Int;
case XmlTypeCode.NonNegativeInteger:
return XmlTypeCode.Decimal;
case XmlTypeCode.UnsignedLong:
return XmlTypeCode.NonNegativeInteger;
case XmlTypeCode.UnsignedInt:
return XmlTypeCode.Integer;
case XmlTypeCode.UnsignedShort:
return XmlTypeCode.Int;
case XmlTypeCode.UnsignedByte:
return XmlTypeCode.UnsignedShort;
case XmlTypeCode.PositiveInteger:
return XmlTypeCode.NonNegativeInteger;
default:
return XmlTypeCode.None;
}
}
示例11: GetEffectiveType
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;
}
示例12: CheckBuiltInFacets
private Exception CheckBuiltInFacets(string s, XmlTypeCode typeCode, bool verifyUri) {
Exception exception = null;
switch (typeCode) {
case XmlTypeCode.AnyUri:
if (verifyUri) {
Uri uri;
exception = XmlConvert.TryToUri(s, out uri);
}
break;
case XmlTypeCode.NormalizedString:
exception = XmlConvert.TryVerifyNormalizedString(s);
break;
case XmlTypeCode.Token:
exception = XmlConvert.TryVerifyTOKEN(s);
break;
case XmlTypeCode.Language:
if (s == null || s.Length == 0) {
return new XmlSchemaException(Res.Sch_EmptyAttributeValue, string.Empty);
}
if (!LanguagePattern.IsMatch(s)) {
return new XmlSchemaException(Res.Sch_InvalidLanguageId, string.Empty);
}
break;
case XmlTypeCode.NmToken:
exception = XmlConvert.TryVerifyNMTOKEN(s);
break;
case XmlTypeCode.Name:
exception = XmlConvert.TryVerifyName(s);
break;
case XmlTypeCode.NCName:
case XmlTypeCode.Id:
case XmlTypeCode.Idref:
case XmlTypeCode.Entity:
exception = XmlConvert.TryVerifyNCName(s);
break;
default:
break;
}
return exception;
}
示例13: ConvertToType
public QilNode ConvertToType(XmlTypeCode requiredType, QilNode n) {
switch (requiredType) {
case XmlTypeCode.String : return ConvertToString(n);
case XmlTypeCode.Double : return ConvertToNumber(n);
case XmlTypeCode.Boolean : return ConvertToBoolean(n);
case XmlTypeCode.Node : return EnsureNodeSet(n);
case XmlTypeCode.Item : return n;
default : Debug.Fail("Unexpected XmlTypeCode: " + requiredType); return null;
}
}
示例14: GetPrimitiveTypeCode
internal static XmlTypeCode GetPrimitiveTypeCode(XmlTypeCode typeCode) {
XmlSchemaSimpleType currentType = enumToTypeCode[(int)typeCode];
while (currentType.BaseXmlSchemaType != DatatypeImplementation.AnySimpleType) {
currentType = currentType.BaseXmlSchemaType as XmlSchemaSimpleType;
Debug.Assert(currentType != null);
}
return currentType.TypeCode;
}
示例15: GetSimpleTypeFromTypeCode
internal static XmlSchemaSimpleType GetSimpleTypeFromTypeCode(XmlTypeCode typeCode) {
return enumToTypeCode[(int) typeCode];
}