Example #1
0
        internal static IEdmTypeReference GetTypeReference(this IEdmType type, bool isNullable)
        {
            IEdmPrimitiveType primitiveType = type as IEdmPrimitiveType;

            if (primitiveType != null)
            {
                return(primitiveType.GetPrimitiveTypeReference(isNullable));
            }

            IEdmComplexType complexType = type as IEdmComplexType;

            if (complexType != null)
            {
                return(new EdmComplexTypeReference(complexType, isNullable));
            }

            IEdmEntityType entityType = type as IEdmEntityType;

            if (entityType != null)
            {
                return(new EdmEntityTypeReference(entityType, isNullable));
            }

            IEdmEnumType enumType = type as IEdmEnumType;

            if (enumType != null)
            {
                return(new EdmEnumTypeReference(enumType, isNullable));
            }

            throw new InvalidOperationException(Edm.Strings.EdmType_UnexpectedEdmType);
        }
Example #2
0
 /// <summary>
 /// Gets a reference to a primitive type of the specified kind.
 /// </summary>
 /// <param name="kind">Primitive kind of the type reference being created.</param>
 /// <param name="isNullable">Flag specifying if the referenced type should be nullable.</param>
 /// <returns>A new primitive type reference.</returns>
 public IEdmPrimitiveTypeReference GetPrimitive(EdmPrimitiveTypeKind kind, bool isNullable)
 {
     IEdmPrimitiveType primitiveDefinition = this.GetCoreModelPrimitiveType(kind);
     if (primitiveDefinition != null)
     {
         return primitiveDefinition.GetPrimitiveTypeReference(isNullable);
     }
     else
     {
         throw new InvalidOperationException(Edm.Strings.EdmPrimitive_UnexpectedKind);
     }
 }
Example #3
0
        public IEdmPrimitiveTypeReference GetPrimitive(EdmPrimitiveTypeKind kind, bool isNullable)
        {
            IEdmPrimitiveType coreModelPrimitiveType = this.GetCoreModelPrimitiveType(kind);

            if (coreModelPrimitiveType == null)
            {
                throw new InvalidOperationException(Strings.EdmPrimitive_UnexpectedKind);
            }
            else
            {
                return(coreModelPrimitiveType.GetPrimitiveTypeReference(isNullable));
            }
        }