示例#1
0
        /// <summary>
        /// Resolve a resource type name
        /// </summary>
        /// <param name="model">The model to use.</param>
        /// <param name="expectedType">The type inferred from the model or null if the model is not a user model.</param>
        /// <param name="typeName">Name of the type to resolve.</param>
        /// <param name="writerValidator">The writer validator to use for validation.</param>
        /// <returns>A type for primitive value</returns>
        internal static IEdmStructuredType ResolveAndValidateTypeFromTypeName(IEdmModel model, IEdmStructuredType expectedType, string typeName, IWriterValidator writerValidator)
        {
            if (typeName == null && expectedType != null)
            {
                return(expectedType);
            }

            // TODO: Clean up handling of expected types/sets during writing
            var typeFromResource = (IEdmStructuredType)ResolveAndValidateTypeName(model, typeName, EdmTypeKind.None, /* expectStructuredType */ true, writerValidator);
            IEdmTypeReference typeReferenceFromValue = ResolveTypeFromMetadataAndValue(
                expectedType.ToTypeReference(),
                typeFromResource == null ? null : typeFromResource.ToTypeReference(),
                writerValidator);

            return(typeReferenceFromValue == null ? null : typeReferenceFromValue.ToStructuredType());
        }