本文整理汇总了C#中IEdmType.ODataFullName方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmType.ODataFullName方法的具体用法?C# IEdmType.ODataFullName怎么用?C# IEdmType.ODataFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmType
的用法示例。
在下文中一共展示了IEdmType.ODataFullName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertyType
private static IEdmTypeReference GetPropertyType(IEdmType type, string propertyName)
{
IEdmStructuredType type2 = type as IEdmStructuredType;
IEdmProperty property = (type2 == null) ? null : type2.FindProperty(propertyName);
if (property != null)
{
IEdmTypeReference typeReference = property.Type;
if (typeReference.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(Microsoft.Data.OData.Strings.EpmSourceTree_CollectionPropertyCannotBeMapped(propertyName, type.ODataFullName()));
}
if (typeReference.IsStream())
{
throw new ODataException(Microsoft.Data.OData.Strings.EpmSourceTree_StreamPropertyCannotBeMapped(propertyName, type.ODataFullName()));
}
if (typeReference.IsSpatial())
{
throw new ODataException(Microsoft.Data.OData.Strings.EpmSourceTree_SpatialTypeCannotBeMapped(propertyName, type.ODataFullName()));
}
return property.Type;
}
if ((type != null) && !type.IsOpenType())
{
throw new ODataException(Microsoft.Data.OData.Strings.EpmSourceTree_MissingPropertyOnType(propertyName, type.ODataFullName()));
}
return null;
}
示例2: CheckRelatedTo
/// <summary>
/// Check whether the parent and child are properly related types
/// </summary>
/// <param name="parentType">the parent type</param>
/// <param name="childType">the child type</param>
/// <exception cref="ODataException">Throws if the two types are not related.</exception>
public static void CheckRelatedTo(IEdmType parentType, IEdmType childType)
{
if (!IsRelatedTo(parentType, childType))
{
// If the parentType is an open property, parentType will be null and can't have an ODataFullName.
string parentTypeName = (parentType != null) ? parentType.ODataFullName() : "<null>";
throw new ODataException(OData.Core.Strings.MetadataBinder_HierarchyNotFollowed(childType.FullTypeName(), parentTypeName));
}
}
示例3: ResolveAndValidateTargetTypeStrictValidationEnabled
/// <summary>
/// Resolves the payload type versus the expected type and validates that such combination is allowed when strict validation is enabled.
/// </summary>
/// <param name="expectedTypeKind">The expected type kind for the value.</param>
/// <param name="expectedTypeReference">The expected type reference, or null if no expected type is available.</param>
/// <param name="payloadType">The payload type, or null if the payload type was not specified, or it didn't resolve against the model.</param>
/// <returns>The target type reference to use for parsing the value.</returns>
private static IEdmTypeReference ResolveAndValidateTargetTypeStrictValidationEnabled(
EdmTypeKind expectedTypeKind,
IEdmTypeReference expectedTypeReference,
IEdmType payloadType)
{
// Strict validation logic
switch (expectedTypeKind)
{
case EdmTypeKind.Complex:
if (payloadType != null)
{
// The payload type must be compatible to the expected type.
VerifyComplexType(expectedTypeReference, payloadType, /* failIfNotRelated */ true);
// Use the payload type
return payloadType.ToTypeReference(/*nullable*/ true);
}
break;
case EdmTypeKind.Entity:
if (payloadType != null)
{
// The payload type must be assignable to the expected type.
IEdmTypeReference payloadTypeReference = payloadType.ToTypeReference(/*nullable*/ true);
ValidationUtils.ValidateEntityTypeIsAssignable((IEdmEntityTypeReference)expectedTypeReference, (IEdmEntityTypeReference)payloadTypeReference);
// Use the payload type
return payloadTypeReference;
}
break;
case EdmTypeKind.Enum:
if (payloadType != null && string.CompareOrdinal(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()) != 0)
{
throw new ODataException(Strings.ValidationUtils_IncompatibleType(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()));
}
break;
case EdmTypeKind.Collection:
// The type must be exactly equal - note that we intentionally ignore nullability of the items here, since the payload type
// can't specify that.
if (payloadType != null && !payloadType.IsElementTypeEquivalentTo(expectedTypeReference.Definition))
{
VerifyCollectionComplexItemType(expectedTypeReference, payloadType);
throw new ODataException(Strings.ValidationUtils_IncompatibleType(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()));
}
break;
case EdmTypeKind.TypeDefinition:
if (payloadType != null && !expectedTypeReference.Definition.IsAssignableFrom(payloadType))
{
throw new ODataException(Strings.ValidationUtils_IncompatibleType(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()));
}
break;
default:
throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ReaderValidationUtils_ResolveAndValidateTypeName_Strict_TypeKind));
}
// Either there's no payload type, in which case use the expected one, or the payload one and the expected one are equal.
return expectedTypeReference;
}
示例4: ResolveType
/// <summary>
/// Resolves the given type if a client type resolver is available.
/// </summary>
/// <param name="typeToResolve">Type to resolve.</param>
/// <returns>The resolved type.</returns>
private IEdmType ResolveType(IEdmType typeToResolve)
{
Debug.Assert(typeToResolve != null, "typeToResolve != null");
Debug.Assert(this.model != null, "model != null");
Debug.Assert(this.readerBehavior != null, "readerBehavior != null");
Func<IEdmType, string, IEdmType> customTypeResolver = this.readerBehavior.TypeResolver;
if (customTypeResolver == null)
{
return typeToResolve;
}
Debug.Assert(this.readerBehavior.ApiBehaviorKind == ODataBehaviorKind.WcfDataServicesClient, "Custom type resolver can only be specified in WCF DS Client behavior.");
EdmTypeKind typeKind;
// MetadataUtils.ResolveTypeName() does not allow entity collection types however both operationImport.ReturnType and operationParameter.Type can be of entity collection types.
// We don't want to relax MetadataUtils.ResolveTypeName() since the rest of ODL only allows primitive and complex collection types and is currently relying on the method to
// enforce this. So if typeToResolve is an entity collection type, we will resolve the item type and reconstruct the collection type from the resolved item type.
IEdmCollectionType collectionTypeToResolve = typeToResolve as IEdmCollectionType;
if (collectionTypeToResolve != null && collectionTypeToResolve.ElementType.IsEntity())
{
IEdmTypeReference itemTypeReferenceToResolve = collectionTypeToResolve.ElementType;
IEdmType resolvedItemType = MetadataUtils.ResolveTypeName(this.model, null /*expectedType*/, itemTypeReferenceToResolve.FullName(), customTypeResolver, out typeKind);
return new EdmCollectionType(resolvedItemType.ToTypeReference(itemTypeReferenceToResolve.IsNullable));
}
return MetadataUtils.ResolveTypeName(this.model, null /*expectedType*/, typeToResolve.ODataFullName(), customTypeResolver, out typeKind);
}
示例5: ValidateTypeKind
internal static void ValidateTypeKind(IEdmType actualType, EdmTypeKind expectedTypeKind)
{
ValidateTypeKind(actualType.TypeKind, expectedTypeKind, actualType.ODataFullName());
}
示例6: ParseLevels
/// <summary>
/// Parse from levelsOption token to LevelsClause.
/// Negative value would be treated as max.
/// </summary>
/// <param name="levelsOption">The levelsOption for current expand.</param>
/// <param name="sourceType">The type of current level navigation source.</param>
/// <param name="property">Navigation property for current expand.</param>
/// <returns>The LevelsClause parsed, null if levelsOption is null</returns>
private LevelsClause ParseLevels(long? levelsOption, IEdmType sourceType, IEdmNavigationProperty property)
{
if (!levelsOption.HasValue)
{
return null;
}
IEdmType relatedType = property.ToEntityType();
if (sourceType != null && relatedType != null && !UriEdmHelpers.IsRelatedTo(sourceType, relatedType))
{
throw new ODataException(ODataErrorStrings.ExpandItemBinder_LevelsNotAllowedOnIncompatibleRelatedType(property.Name, relatedType.ODataFullName(), sourceType.ODataFullName()));
}
return new LevelsClause(levelsOption.Value < 0, levelsOption.Value);
}
示例7: TryCreateTypeNameSegment
private bool TryCreateTypeNameSegment(ODataPathSegment previous, string identifier, string parenthesisExpression, IEdmType targetEdmType)
{
if (previous.TargetEdmType == null || targetEdmType == null)
{
return false;
}
// if the new type segment prevents any results from possibly being returned, then short-circuit and throw a 404.
IEdmType previousEdmType = previous.TargetEdmType;
Debug.Assert(previousEdmType != null, "previous.TargetEdmType != null");
if (previousEdmType.TypeKind == EdmTypeKind.Collection)
{
previousEdmType = ((IEdmCollectionType)previousEdmType).ElementType.Definition;
}
if (!targetEdmType.IsOrInheritsFrom(previousEdmType) && !previousEdmType.IsOrInheritsFrom(targetEdmType))
{
throw ExceptionUtil.CreateBadRequestError(ODataErrorStrings.RequestUriProcessor_InvalidTypeIdentifier_UnrelatedType(targetEdmType.ODataFullName(), previousEdmType.ODataFullName()));
}
// We want the type of the type segment to be a collection if the previous segment was a collection
IEdmType actualTypeOfTheTypeSegment = targetEdmType;
if (previous.EdmType.TypeKind == EdmTypeKind.Collection)
{
// creating a new collection type here because the type in the request is just the item type, there is no user-provided collection type.
var actualEntityTypeOfTheTypeSegment = actualTypeOfTheTypeSegment as IEdmEntityType;
if (actualEntityTypeOfTheTypeSegment != null)
{
actualTypeOfTheTypeSegment = new EdmCollectionType(new EdmEntityTypeReference(actualEntityTypeOfTheTypeSegment, false));
}
else
{
throw new ODataException(Strings.PathParser_TypeCastOnlyAllowedAfterEntityCollection(identifier));
}
}
var typeNameSegment = (ODataPathSegment)new TypeSegment(actualTypeOfTheTypeSegment, previous.TargetEdmNavigationSource)
{
Identifier = identifier,
TargetKind = previous.TargetKind,
SingleResult = previous.SingleResult,
TargetEdmType = targetEdmType
};
this.parsedSegments.Add(typeNameSegment);
// Key expressions are allowed on Type segments
this.TryBindKeyFromParentheses(parenthesisExpression);
return true;
}
示例8: ValidateTypeKind
/// <summary>
/// Validates that the specified type is of the requested kind.
/// </summary>
/// <param name="actualType">The type to validate.</param>
/// <param name="expectedTypeKind">The type kind from the value.</param>
/// <remarks>This override of the method will not create the type name unless it fails.</remarks>
internal static void ValidateTypeKind(IEdmType actualType, EdmTypeKind expectedTypeKind)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(actualType != null, "actualType != null");
ValidationUtils.ValidateTypeKind(actualType.TypeKind, expectedTypeKind, actualType.ODataFullName());
}
示例9: ResolveAndValidateTargetTypeStrictValidationEnabled
private static IEdmTypeReference ResolveAndValidateTargetTypeStrictValidationEnabled(EdmTypeKind expectedTypeKind, IEdmTypeReference expectedTypeReference, IEdmType payloadType, string payloadTypeName, out SerializationTypeNameAnnotation serializationTypeNameAnnotation)
{
switch (expectedTypeKind)
{
case EdmTypeKind.Entity:
{
if (payloadType == null)
{
break;
}
IEdmTypeReference targetTypeReference = payloadType.ToTypeReference(true);
ValidationUtils.ValidateEntityTypeIsAssignable((IEdmEntityTypeReference) expectedTypeReference, (IEdmEntityTypeReference) targetTypeReference);
serializationTypeNameAnnotation = CreateSerializationTypeNameAnnotation(payloadTypeName, targetTypeReference);
return targetTypeReference;
}
case EdmTypeKind.Complex:
if (payloadType != null)
{
VerifyComplexType(expectedTypeReference, payloadType, true);
}
break;
case EdmTypeKind.Collection:
if ((payloadType != null) && (string.CompareOrdinal(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()) != 0))
{
VerifyCollectionComplexItemType(expectedTypeReference, payloadType);
throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_IncompatibleType(payloadType.ODataFullName(), expectedTypeReference.ODataFullName()));
}
break;
default:
throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ReaderValidationUtils_ResolveAndValidateTypeName_Strict_TypeKind));
}
serializationTypeNameAnnotation = CreateSerializationTypeNameAnnotation(payloadTypeName, expectedTypeReference);
return expectedTypeReference;
}
示例10: GetPropertyType
/// <summary>
/// Returns the type of the property on the specified type.
/// </summary>
/// <param name="type">The type to look for the property on.</param>
/// <param name="propertyName">The name of the property to look for.</param>
/// <returns>The type of the property specified.</returns>
private static IEdmTypeReference GetPropertyType(IEdmType type, string propertyName)
{
Debug.Assert(propertyName != null, "propertyName != null");
IEdmStructuredType structuredType = type as IEdmStructuredType;
IEdmProperty property = structuredType == null ? null : structuredType.FindProperty(propertyName);
if (property != null)
{
IEdmTypeReference propertyType = property.Type;
if (propertyType.IsNonEntityODataCollectionTypeKind())
{
throw new ODataException(o.Strings.EpmSourceTree_CollectionPropertyCannotBeMapped(propertyName, type.ODataFullName()));
}
if (propertyType.IsStream())
{
throw new ODataException(o.Strings.EpmSourceTree_StreamPropertyCannotBeMapped(propertyName, type.ODataFullName()));
}
if (propertyType.IsSpatial())
{
throw new ODataException(o.Strings.EpmSourceTree_SpatialTypeCannotBeMapped(propertyName, type.ODataFullName()));
}
return property.Type;
}
if (type != null && !type.IsOpenType())
{
throw new ODataException(o.Strings.EpmSourceTree_MissingPropertyOnType(propertyName, type.ODataFullName()));
}
return null;
}