/// <summary> /// Returns the text representation of the current object. /// </summary> /// <param name="property">Reference to the calling object.</param> /// <returns>The text representation of the current object.</returns> public static string ToTraceString(this IEdmProperty property) { EdmUtil.CheckArgumentNull(property, "property"); return((property.Name != null ? property.Name : "") + ":" + (property.Type != null ? property.Type.ToTraceString() : "")); }
/// <summary> /// Returns true if this reference refers to a row type. /// </summary> /// <param name="type">Type reference.</param> /// <returns>This reference refers to a row type.</returns> public static bool IsRow(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); return(type.TypeKind() == EdmTypeKind.Row); }
/// <summary> /// Returns a reference to this row type definition. /// </summary> /// <param name="rowType">Reference to the calling object.</param> /// <param name="isNullable">Flag specifying if the referenced type should be nullable.</param> /// <returns>A reference to this row type definition.</returns> public static IEdmRowTypeReference ApplyType(this IEdmRowType rowType, bool isNullable) { EdmUtil.CheckArgumentNull(rowType, "type"); return(new EdmRowTypeReference(rowType, isNullable)); }
// The As*** functions never return null -- if the supplied type does not have the appropriate shape, an encoding of a bad type is returned. #region AsPrimitive, AsCollection, AsStructured, AsAssociation, ... /// <summary> /// If this reference is of a primitive type, this will return a valid primitive type reference to the type definition. Otherwise, it will return a bad primitive type reference. /// </summary> /// <param name="type">Reference to the calling object.</param> /// <returns>A valid primitive type reference if the definition of the reference is of a primitive type. Otherwise a bad primitive type reference.</returns> public static IEdmPrimitiveTypeReference AsPrimitive(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); IEdmPrimitiveTypeReference reference = type as IEdmPrimitiveTypeReference; if (reference != null) { return(reference); } IEdmType typeDefinition = type.Definition; if (typeDefinition.TypeKind == EdmTypeKind.Primitive) { var primitiveDefinition = typeDefinition as IEdmPrimitiveType; if (primitiveDefinition != null) { switch (primitiveDefinition.PrimitiveKind) { case EdmPrimitiveTypeKind.Boolean: case EdmPrimitiveTypeKind.Byte: case EdmPrimitiveTypeKind.Double: case EdmPrimitiveTypeKind.Guid: case EdmPrimitiveTypeKind.Int16: case EdmPrimitiveTypeKind.Int32: case EdmPrimitiveTypeKind.Int64: case EdmPrimitiveTypeKind.SByte: case EdmPrimitiveTypeKind.Single: case EdmPrimitiveTypeKind.Stream: return(new EdmPrimitiveTypeReference(primitiveDefinition, type.IsNullable)); case EdmPrimitiveTypeKind.Binary: return(type.AsBinary()); case EdmPrimitiveTypeKind.Decimal: return(type.AsDecimal()); case EdmPrimitiveTypeKind.String: return(type.AsString()); case EdmPrimitiveTypeKind.Time: case EdmPrimitiveTypeKind.DateTime: case EdmPrimitiveTypeKind.DateTimeOffset: return(type.AsTemporal()); case EdmPrimitiveTypeKind.Geography: case EdmPrimitiveTypeKind.GeographyPoint: case EdmPrimitiveTypeKind.GeographyLineString: case EdmPrimitiveTypeKind.GeographyPolygon: case EdmPrimitiveTypeKind.GeographyCollection: case EdmPrimitiveTypeKind.GeographyMultiPolygon: case EdmPrimitiveTypeKind.GeographyMultiLineString: case EdmPrimitiveTypeKind.GeographyMultiPoint: case EdmPrimitiveTypeKind.Geometry: case EdmPrimitiveTypeKind.GeometryPoint: case EdmPrimitiveTypeKind.GeometryLineString: case EdmPrimitiveTypeKind.GeometryPolygon: case EdmPrimitiveTypeKind.GeometryCollection: case EdmPrimitiveTypeKind.GeometryMultiPolygon: case EdmPrimitiveTypeKind.GeometryMultiLineString: case EdmPrimitiveTypeKind.GeometryMultiPoint: return(type.AsSpatial()); case EdmPrimitiveTypeKind.None: break; } } } string typeFullName = type.FullName(); List <EdmError> errors = new List <EdmError>(type.Errors()); if (errors.Count == 0) { errors.AddRange(ConversionError(type.Location(), typeFullName, EdmConstants.Type_Primitive)); } return(new BadPrimitiveTypeReference(typeFullName, type.IsNullable, errors)); }
/// <summary> /// Returns true if this reference refers to a spatial type. /// </summary> /// <param name="type">Type reference.</param> /// <returns>This reference refers to a spatial type.</returns> public static bool IsSpatial(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); return(IsSpatial(type.Definition)); }
/// <summary> /// Returns true if this reference refers to a stream type. /// </summary> /// <param name="type">Type reference.</param> /// <returns>This reference refers to a stream type.</returns> public static bool IsStream(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); return(type.PrimitiveKind() == EdmPrimitiveTypeKind.Stream); }
/// <summary> /// Returns true if this reference refers to a DateTimeOffset type. /// </summary> /// <param name="type">Type reference.</param> /// <returns>This reference refers to a DateTimeOffset type.</returns> public static bool IsDateTimeOffset(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); return(type.PrimitiveKind() == EdmPrimitiveTypeKind.DateTimeOffset); }
/// <summary> /// Returns true if this reference refers to a temporal type. /// </summary> /// <param name="type">Type reference.</param> /// <returns>This reference refers to a temporal type.</returns> public static bool IsTemporal(this IEdmTypeReference type) { EdmUtil.CheckArgumentNull(type, "type"); return(type.PrimitiveKind().IsTemporal()); }