public static IEdmComplexTypeReference AsComplex(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmComplexTypeReference edmComplexTypeReference = type as IEdmComplexTypeReference; if (edmComplexTypeReference == null) { IEdmType definition = type.Definition; if (definition.TypeKind != EdmTypeKind.Complex) { string str = type.FullName(); List <EdmError> edmErrors = new List <EdmError>(type.Errors()); if (edmErrors.Count == 0) { edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), str, "Complex")); } return(new BadComplexTypeReference(str, type.IsNullable, edmErrors)); } else { return(new EdmComplexTypeReference((IEdmComplexType)definition, type.IsNullable)); } } else { return(edmComplexTypeReference); } }
public static IEdmRowTypeReference AsRow(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmRowTypeReference edmRowTypeReference = type as IEdmRowTypeReference; if (edmRowTypeReference == null) { IEdmType definition = type.Definition; if (definition.TypeKind != EdmTypeKind.Row) { List <EdmError> edmErrors = new List <EdmError>(type.Errors()); if (edmErrors.Count == 0) { edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), type.FullName(), "Row")); } return(new EdmRowTypeReference(new BadRowType(edmErrors), type.IsNullable)); } else { return(new EdmRowTypeReference((IEdmRowType)definition, type.IsNullable)); } } else { return(edmRowTypeReference); } }
public static IEdmStructuredTypeReference AsStructured(this IEdmTypeReference type) { string str; List <EdmError> edmErrors; EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmStructuredTypeReference edmStructuredTypeReference = type as IEdmStructuredTypeReference; if (edmStructuredTypeReference == null) { EdmTypeKind edmTypeKind = type.TypeKind(); switch (edmTypeKind) { case EdmTypeKind.Entity: { return(type.AsEntity()); } case EdmTypeKind.Complex: { return(type.AsComplex()); } case EdmTypeKind.Row: { return(type.AsRow()); } default: { str = type.FullName(); edmErrors = new List <EdmError>(type.TypeErrors()); if (edmErrors.Count != 0) { break; } edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), str, "Structured")); break; } } return(new BadEntityTypeReference(str, type.IsNullable, edmErrors)); } else { return(edmStructuredTypeReference); } }
public static IEdmDecimalTypeReference AsDecimal(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmDecimalTypeReference edmDecimalTypeReference = type as IEdmDecimalTypeReference; if (edmDecimalTypeReference == null) { string str = type.FullName(); List <EdmError> edmErrors = new List <EdmError>(type.Errors()); if (edmErrors.Count == 0) { edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), str, "Decimal")); } return(new BadDecimalTypeReference(str, type.IsNullable, edmErrors)); } else { return(edmDecimalTypeReference); } }
public static IEdmEnumTypeReference AsEnum(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmEnumTypeReference edmEnumTypeReference = type as IEdmEnumTypeReference; if (edmEnumTypeReference == null) { IEdmType definition = type.Definition; if (definition.TypeKind != EdmTypeKind.Enum) { string str = type.FullName(); return(new EdmEnumTypeReference(new BadEnumType(str, EdmTypeSemantics.ConversionError(type.Location(), str, "Enum")), type.IsNullable)); } else { return(new EdmEnumTypeReference((IEdmEnumType)definition, type.IsNullable)); } } else { return(edmEnumTypeReference); } }
public static IEdmPrimitiveTypeReference AsPrimitive(this IEdmTypeReference type) { string str; List <EdmError> edmErrors; EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type"); IEdmPrimitiveTypeReference edmPrimitiveTypeReference = type as IEdmPrimitiveTypeReference; if (edmPrimitiveTypeReference == null) { IEdmType definition = type.Definition; if (definition.TypeKind == EdmTypeKind.Primitive) { IEdmPrimitiveType edmPrimitiveType = definition as IEdmPrimitiveType; if (edmPrimitiveType != null) { EdmPrimitiveTypeKind primitiveKind = edmPrimitiveType.PrimitiveKind; if (primitiveKind == EdmPrimitiveTypeKind.None) { str = type.FullName(); edmErrors = new List <EdmError>(type.Errors()); if (edmErrors.Count == 0) { edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), str, "Primitive")); } return(new BadPrimitiveTypeReference(str, type.IsNullable, edmErrors)); } else if (primitiveKind == EdmPrimitiveTypeKind.Binary) { return(type.AsBinary()); } else if (primitiveKind == EdmPrimitiveTypeKind.Boolean || primitiveKind == EdmPrimitiveTypeKind.Byte || primitiveKind == EdmPrimitiveTypeKind.Double || primitiveKind == EdmPrimitiveTypeKind.Guid || primitiveKind == EdmPrimitiveTypeKind.Int16 || primitiveKind == EdmPrimitiveTypeKind.Int32 || primitiveKind == EdmPrimitiveTypeKind.Int64 || primitiveKind == EdmPrimitiveTypeKind.SByte || primitiveKind == EdmPrimitiveTypeKind.Single || primitiveKind == EdmPrimitiveTypeKind.Stream) { return(new EdmPrimitiveTypeReference(edmPrimitiveType, type.IsNullable)); } else if (primitiveKind == EdmPrimitiveTypeKind.DateTime || primitiveKind == EdmPrimitiveTypeKind.DateTimeOffset || primitiveKind == EdmPrimitiveTypeKind.Time) { return(type.AsTemporal()); } else if (primitiveKind == EdmPrimitiveTypeKind.Decimal) { return(type.AsDecimal()); } else if (primitiveKind == EdmPrimitiveTypeKind.String) { return(type.AsString()); } else if (primitiveKind == EdmPrimitiveTypeKind.Geography || primitiveKind == EdmPrimitiveTypeKind.GeographyPoint || primitiveKind == EdmPrimitiveTypeKind.GeographyLineString || primitiveKind == EdmPrimitiveTypeKind.GeographyPolygon || primitiveKind == EdmPrimitiveTypeKind.GeographyCollection || primitiveKind == EdmPrimitiveTypeKind.GeographyMultiPolygon || primitiveKind == EdmPrimitiveTypeKind.GeographyMultiLineString || primitiveKind == EdmPrimitiveTypeKind.GeographyMultiPoint || primitiveKind == EdmPrimitiveTypeKind.Geometry || primitiveKind == EdmPrimitiveTypeKind.GeometryPoint || primitiveKind == EdmPrimitiveTypeKind.GeometryLineString || primitiveKind == EdmPrimitiveTypeKind.GeometryPolygon || primitiveKind == EdmPrimitiveTypeKind.GeometryCollection || primitiveKind == EdmPrimitiveTypeKind.GeometryMultiPolygon || primitiveKind == EdmPrimitiveTypeKind.GeometryMultiLineString || primitiveKind == EdmPrimitiveTypeKind.GeometryMultiPoint) { return(type.AsSpatial()); } } } str = type.FullName(); edmErrors = new List <EdmError>(type.Errors()); if (edmErrors.Count == 0) { edmErrors.AddRange(EdmTypeSemantics.ConversionError(type.Location(), str, "Primitive")); } return(new BadPrimitiveTypeReference(str, type.IsNullable, edmErrors)); } else { return(edmPrimitiveTypeReference); } }