当前位置: 首页>>代码示例>>C#>>正文


C# Type.EdmFullName方法代码示例

本文整理汇总了C#中Type.EdmFullName方法的典型用法代码示例。如果您正苦于以下问题:C# Type.EdmFullName方法的具体用法?C# Type.EdmFullName怎么用?C# Type.EdmFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Type的用法示例。


在下文中一共展示了Type.EdmFullName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEdmType

        private static IEdmType GetEdmType(IEdmModel edmModel, Type clrType, bool testCollections)
        {
            Contract.Assert(edmModel != null);
            Contract.Assert(clrType != null);

            IEdmPrimitiveType primitiveType = GetEdmPrimitiveTypeOrNull(clrType);
            if (primitiveType != null)
            {
                return primitiveType;
            }
            else
            {
                if (testCollections)
                {
                    Type enumerableOfT = ExtractGenericInterface(clrType, typeof(IEnumerable<>));
                    if (enumerableOfT != null)
                    {
                        Type elementClrType = enumerableOfT.GetGenericArguments()[0];

                        // IEnumerable<SelectExpandWrapper<T>> is a collection of T.
                        Type entityType;
                        if (IsSelectExpandWrapper(elementClrType, out entityType))
                        {
                            elementClrType = entityType;
                        }

                        IEdmType elementType = GetEdmType(edmModel, elementClrType, testCollections: false);
                        if (elementType != null)
                        {
                            return new EdmCollectionType(elementType.ToEdmTypeReference(IsNullable(elementClrType)));
                        }
                    }
                }

                Type underlyingType = TypeHelper.GetUnderlyingTypeOrSelf(clrType);

                if (underlyingType.IsEnum)
                {
                    clrType = underlyingType;
                }

                // search for the ClrTypeAnnotation and return it if present
                IEdmType returnType =
                    edmModel
                    .SchemaElements
                    .OfType<IEdmType>()
                    .Select(edmType => new { EdmType = edmType, Annotation = edmModel.GetAnnotationValue<ClrTypeAnnotation>(edmType) })
                    .Where(tuple => tuple.Annotation != null && tuple.Annotation.ClrType == clrType)
                    .Select(tuple => tuple.EdmType)
                    .SingleOrDefault();

                // default to the EdmType with the same name as the ClrType name 
                returnType = returnType ?? edmModel.FindType(clrType.EdmFullName());

                if (clrType.BaseType != null)
                {
                    // go up the inheritance tree to see if we have a mapping defined for the base type.
                    returnType = returnType ?? GetEdmType(edmModel, clrType.BaseType, testCollections);
                }
                return returnType;
            }
        }
开发者ID:BarclayII,项目名称:WebApi,代码行数:62,代码来源:EdmLibHelpers.cs

示例2: ModelBuilder_AnyType_QueryComposition

        public void ModelBuilder_AnyType_QueryComposition(Type type)
        {
            var modelBuilder = new ODataConventionModelBuilder(isQueryCompositionMode: true);
            modelBuilder.AddEntity(type);

            IEdmModel model = modelBuilder.GetEdmModel();
            Assert.True(model.SchemaElements.Count() > 0);
            IEdmEntityType entityType = Assert.IsAssignableFrom<IEdmEntityType>(model.FindType(type.EdmFullName()));
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:9,代码来源:ODataConventionModelBuilderTests.cs

示例3: GetEdmType

        public static IEdmType GetEdmType(this IEdmModel edmModel, Type clrType)
        {
            if (edmModel == null)
            {
                throw Error.ArgumentNull("edmModel");
            }

            if (clrType == null)
            {
                throw Error.ArgumentNull("clrType");
            }

            IEdmPrimitiveType primitiveType = GetEdmPrimitiveTypeOrNull(clrType);
            if (primitiveType != null)
            {
                return primitiveType;
            }
            else
            {
                Type enumerableOfT = ExtractGenericInterface(clrType, typeof(IEnumerable<>));
                if (enumerableOfT != null)
                {
                    Type elementClrType = enumerableOfT.GetGenericArguments()[0];

                    // IEnumerable<SelectExpandWrapper<T>> is a collection of T.
                    if (elementClrType.IsGenericType && elementClrType.GetGenericTypeDefinition() == typeof(SelectExpandWrapper<>))
                    {
                        elementClrType = elementClrType.GetGenericArguments()[0];
                    }

                    IEdmTypeReference elementType = GetEdmTypeReference(edmModel, elementClrType);
                    if (elementType != null)
                    {
                        return new EdmCollectionType(elementType);
                    }
                }

                // search for the ClrTypeAnnotation and return it if present
                IEdmType returnType =
                    edmModel
                    .SchemaElements
                    .OfType<IEdmType>()
                    .Select(edmType => new { EdmType = edmType, Annotation = edmModel.GetAnnotationValue<ClrTypeAnnotation>(edmType) })
                    .Where(tuple => tuple.Annotation != null && tuple.Annotation.ClrType == clrType)
                    .Select(tuple => tuple.EdmType)
                    .SingleOrDefault();

                // default to the EdmType with the same name as the ClrType name 
                returnType = returnType ?? edmModel.FindType(clrType.EdmFullName());

                if (clrType.BaseType != null)
                {
                    // go up the inheritance tree to see if we have a mapping defined for the base type.
                    returnType = returnType ?? edmModel.GetEdmType(clrType.BaseType);
                }
                return returnType;
            }
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:58,代码来源:EdmLibHelpers.cs

示例4: GetEdmType

        public static IEdmType GetEdmType(this IEdmModel edmModel, Type clrType)
        {
            if (edmModel == null)
            {
                throw Error.ArgumentNull("edmModel");
            }

            IEdmPrimitiveType primitiveType = GetEdmPrimitiveTypeOrNull(clrType);
            if (primitiveType != null)
            {
                return primitiveType;
            }
            else
            {
                Type enumerableOfT = ExtractGenericInterface(clrType, typeof(IEnumerable<>));
                if (enumerableOfT != null)
                {
                    IEdmTypeReference elementType = GetEdmTypeReference(edmModel, enumerableOfT.GetGenericArguments()[0]);
                    if (elementType != null)
                    {
                        return new EdmCollectionType(elementType);
                    }
                }

                // search for the ClrTypeAnnotation and return it if present
                IEdmType returnType =
                    edmModel
                    .SchemaElements
                    .OfType<IEdmType>()
                    .Select(edmType => new { EdmType = edmType, Annotation = edmModel.GetAnnotationValue<ClrTypeAnnotation>(edmType) })
                    .Where(tuple => tuple.Annotation != null && tuple.Annotation.ClrType == clrType)
                    .Select(tuple => tuple.EdmType)
                    .SingleOrDefault();

                // default to the EdmType with the same name as the ClrType name 
                returnType = returnType ?? edmModel.FindType(clrType.EdmFullName());
                return returnType;
            }
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:39,代码来源:EdmLibHelpers.cs


注:本文中的Type.EdmFullName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。