本文整理汇总了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;
}
}
示例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()));
}
示例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;
}
}
示例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;
}
}