本文整理汇总了C#中IEdmTypeReference类的典型用法代码示例。如果您正苦于以下问题:C# IEdmTypeReference类的具体用法?C# IEdmTypeReference怎么用?C# IEdmTypeReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEdmTypeReference类属于命名空间,在下文中一共展示了IEdmTypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EdmCollectionExpression
/// <summary>
/// Initializes a new instance of the <see cref="EdmCollectionExpression"/> class.
/// </summary>
/// <param name="declaredType">Declared type of the collection.</param>
/// <param name="elements">The constructed element values.</param>
public EdmCollectionExpression(IEdmTypeReference declaredType, IEnumerable<IEdmExpression> elements)
{
EdmUtil.CheckArgumentNull(elements, "elements");
this.declaredType = declaredType;
this.elements = elements;
}
示例2: ShouldBeEquivalentTo
public static AndConstraint<IEdmTypeReference> ShouldBeEquivalentTo(this IEdmTypeReference typeReference, IEdmTypeReference expectedTypeReference)
{
typeReference.IsEquivalentTo(expectedTypeReference).Should().BeTrue();
////typeReference.Should().BeSameAs(expectedTypeReference.Definition);
////typeReference.IsNullable.Should().Be(expectedTypeReference.IsNullable);
return new AndConstraint<IEdmTypeReference>(typeReference);
}
示例3: CreateEdmTypeSerializer
/// <summary>
/// Creates a new instance of the <see cref="ODataEdmTypeSerializer"/> for the given edm type.
/// </summary>
/// <param name="edmType">The <see cref="IEdmTypeReference"/>.</param>
/// <returns>The constructed <see cref="ODataEdmTypeSerializer"/>.</returns>
public virtual ODataEdmTypeSerializer CreateEdmTypeSerializer(IEdmTypeReference edmType)
{
if (edmType == null)
{
throw Error.ArgumentNull("edmType");
}
switch (edmType.TypeKind())
{
case EdmTypeKind.Primitive:
return new ODataPrimitiveSerializer(edmType.AsPrimitive());
case EdmTypeKind.Collection:
IEdmCollectionTypeReference collectionType = edmType.AsCollection();
if (collectionType.ElementType().IsEntity())
{
return new ODataFeedSerializer(collectionType, this);
}
else
{
return new ODataCollectionSerializer(collectionType, this);
}
case EdmTypeKind.Complex:
return new ODataComplexTypeSerializer(edmType.AsComplex(), this);
case EdmTypeKind.Entity:
return new ODataEntityTypeSerializer(edmType.AsEntity(), this);
default:
return null;
}
}
示例4: WriteObjectInline
/// <inheritdoc />
public override void WriteObjectInline(object graph, IEdmTypeReference expectedType, ODataWriter writer,
ODataSerializerContext writeContext)
{
if (writer == null)
{
throw Error.ArgumentNull("writer");
}
if (writeContext == null)
{
throw Error.ArgumentNull("writeContext");
}
if (expectedType == null)
{
throw Error.ArgumentNull("expectedType");
}
if (graph == null)
{
throw new SerializationException(Error.Format(SRResources.CannotSerializerNull, Feed));
}
IEnumerable enumerable = graph as IEnumerable; // Data to serialize
if (enumerable == null)
{
throw new SerializationException(
Error.Format(SRResources.CannotWriteType, GetType().Name, graph.GetType().FullName));
}
WriteFeed(enumerable, expectedType, writer, writeContext);
}
示例5: ReadInline
/// <inheritdoc />
public sealed override object ReadInline(object item, IEdmTypeReference edmType, ODataDeserializerContext readContext)
{
if (item == null)
{
throw Error.ArgumentNull("item");
}
if (edmType == null)
{
throw Error.ArgumentNull("edmType");
}
if (!edmType.IsEntity())
{
throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, EdmTypeKind.Entity);
}
ODataEntryWithNavigationLinks entryWrapper = item as ODataEntryWithNavigationLinks;
if (entryWrapper == null)
{
throw Error.Argument("item", SRResources.ArgumentMustBeOfType, typeof(ODataEntry).Name);
}
// Recursion guard to avoid stack overflows
RuntimeHelpers.EnsureSufficientExecutionStack();
return ReadEntry(entryWrapper, edmType.AsEntity(), readContext);
}
示例6: GetEdmTypeDeserializer
/// <inheritdoc />
public override ODataEdmTypeDeserializer GetEdmTypeDeserializer(IEdmTypeReference edmType)
{
if (edmType == null)
{
throw Error.ArgumentNull("edmType");
}
switch (edmType.TypeKind())
{
case EdmTypeKind.Entity:
return _entityDeserializer;
case EdmTypeKind.Primitive:
return _primitiveDeserializer;
case EdmTypeKind.Complex:
return _complexDeserializer;
case EdmTypeKind.Collection:
IEdmCollectionTypeReference collectionType = edmType.AsCollection();
if (collectionType.ElementType().IsEntity())
{
return _feedDeserializer;
}
else
{
return _collectionDeserializer;
}
default:
return null;
}
}
示例7: EdmIsTypeExpression
public EdmIsTypeExpression(IEdmExpression operand, IEdmTypeReference type)
{
EdmUtil.CheckArgumentNull<IEdmExpression>(operand, "operand");
EdmUtil.CheckArgumentNull<IEdmTypeReference>(type, "type");
this.operand = operand;
this.type = type;
}
示例8: EdmFunction
public EdmFunction(string namespaceName, string name, IEdmTypeReference returnType, string definingExpression) : base(name, returnType)
{
EdmUtil.CheckArgumentNull<string>(namespaceName, "namespaceName");
EdmUtil.CheckArgumentNull<IEdmTypeReference>(returnType, "returnType");
this.namespaceName = namespaceName;
this.definingExpression = definingExpression;
}
示例9: IsEquivalentTo
/// <summary>
/// Returns true if the compared type reference is semantically equivalent to this type reference.
/// Schema types (<see cref="IEdmSchemaType"/>) are compared by their object refs.
/// </summary>
/// <param name="thisType">Type reference being compared.</param>
/// <param name="otherType">Type referenced being compared to.</param>
/// <returns>Equivalence of the two type references.</returns>
public static bool IsEquivalentTo(this IEdmTypeReference thisType, IEdmTypeReference otherType)
{
if (thisType == otherType)
{
return true;
}
if (thisType == null || otherType == null)
{
return false;
}
EdmTypeKind typeKind = thisType.TypeKind();
if (typeKind != otherType.TypeKind())
{
return false;
}
if (typeKind == EdmTypeKind.Primitive)
{
return ((IEdmPrimitiveTypeReference)thisType).IsEquivalentTo((IEdmPrimitiveTypeReference)otherType);
}
else
{
return thisType.IsNullable == otherType.IsNullable &&
thisType.Definition.IsEquivalentTo(otherType.Definition);
}
}
示例10: ComputeTargetTypeKind
private static EdmTypeKind ComputeTargetTypeKind(IEdmTypeReference expectedTypeReference, bool forEntityValue, string payloadTypeName, EdmTypeKind payloadTypeKind, ODataMessageReaderSettings messageReaderSettings, Func<EdmTypeKind> typeKindFromPayloadFunc)
{
EdmTypeKind kind;
bool flag = (messageReaderSettings.ReaderBehavior.TypeResolver != null) && (payloadTypeKind != EdmTypeKind.None);
if (((expectedTypeReference != null) && !flag) && (!expectedTypeReference.IsODataPrimitiveTypeKind() || !messageReaderSettings.DisablePrimitiveTypeConversion))
{
kind = expectedTypeReference.TypeKind();
}
else if (payloadTypeKind != EdmTypeKind.None)
{
if (!forEntityValue)
{
ValidationUtils.ValidateValueTypeKind(payloadTypeKind, payloadTypeName);
}
kind = payloadTypeKind;
}
else
{
kind = typeKindFromPayloadFunc();
}
if (ShouldValidatePayloadTypeKind(messageReaderSettings, expectedTypeReference, payloadTypeKind))
{
ValidationUtils.ValidateTypeKind(kind, expectedTypeReference.TypeKind(), payloadTypeName);
}
return kind;
}
示例11: ResolveAndValidateNonPrimitiveTargetType
internal static IEdmTypeReference ResolveAndValidateNonPrimitiveTargetType(EdmTypeKind expectedTypeKind, IEdmTypeReference expectedTypeReference, EdmTypeKind payloadTypeKind, IEdmType payloadType, string payloadTypeName, IEdmModel model, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, out SerializationTypeNameAnnotation serializationTypeNameAnnotation)
{
bool flag = (messageReaderSettings.ReaderBehavior.TypeResolver != null) && (payloadType != null);
if (!flag)
{
ValidateTypeSupported(expectedTypeReference, version);
if (model.IsUserModel() && ((expectedTypeReference == null) || !messageReaderSettings.DisableStrictMetadataValidation))
{
VerifyPayloadTypeDefined(payloadTypeName, payloadType);
}
}
else
{
ValidateTypeSupported((payloadType == null) ? null : payloadType.ToTypeReference(true), version);
}
if ((payloadTypeKind != EdmTypeKind.None) && (!messageReaderSettings.DisableStrictMetadataValidation || (expectedTypeReference == null)))
{
ValidationUtils.ValidateTypeKind(payloadTypeKind, expectedTypeKind, payloadTypeName);
}
serializationTypeNameAnnotation = null;
if (!model.IsUserModel())
{
return null;
}
if ((expectedTypeReference == null) || flag)
{
return ResolveAndValidateTargetTypeWithNoExpectedType(expectedTypeKind, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
}
if (messageReaderSettings.DisableStrictMetadataValidation)
{
return ResolveAndValidateTargetTypeStrictValidationDisabled(expectedTypeKind, expectedTypeReference, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
}
return ResolveAndValidateTargetTypeStrictValidationEnabled(expectedTypeKind, expectedTypeReference, payloadType, payloadTypeName, out serializationTypeNameAnnotation);
}
示例12: ParseUriStringToType
/// <summary>
/// Try to parse the given text by each parser.
/// </summary>
/// <param name="text">Part of the Uri which has to be parsed to a value of EdmType <paramref name="targetType"/></param>
/// <param name="targetType">The type which the uri text has to be parsed to</param>
/// <param name="parsingException">Assign the exception only in case the text could be parsed to the <paramref name="targetType"/> but failed during the parsing process</param>
/// <returns>If the parsing proceess has succeeded, returns the parsed object, otherwise returns 'Null'</returns>
public object ParseUriStringToType(string text, IEdmTypeReference targetType, out UriLiteralParsingException parsingException)
{
parsingException = null;
object targetValue;
// Try to parse the uri text with each parser
foreach (IUriLiteralParser uriTypeParser in uriTypeParsers)
{
targetValue = uriTypeParser.ParseUriStringToType(text, targetType, out parsingException);
// Stop in case the parser has returned an excpetion
if (parsingException != null)
{
return null;
}
// In case of no exception and no value - The parse cannot parse the given text
if (targetValue != null)
{
return targetValue;
}
}
return null;
}
示例13: WriteDeltaFeedInlineAsync
/// <summary>
/// Writes the given object specified by the parameter graph as a part of an existing OData message using the given
/// messageWriter and the writeContext.
/// </summary>
/// <param name="graph">The object to be written.</param>
/// <param name="expectedType">The expected EDM type of the object represented by <paramref name="graph"/>.</param>
/// <param name="writer">The <see cref="ODataDeltaWriter" /> to be used for writing.</param>
/// <param name="writeContext">The <see cref="ODataSerializerContext"/>.</param>
public virtual async Task WriteDeltaFeedInlineAsync(object graph, IEdmTypeReference expectedType, ODataDeltaWriter writer,
ODataSerializerContext writeContext)
{
if (writer == null)
{
throw Error.ArgumentNull("writer");
}
if (writeContext == null)
{
throw Error.ArgumentNull("writeContext");
}
if (expectedType == null)
{
throw Error.ArgumentNull("expectedType");
}
if (graph == null)
{
throw new SerializationException(Error.Format(SRResources.CannotSerializerNull, DeltaFeed));
}
IEnumerable enumerable = graph as IEnumerable; // Data to serialize
if (enumerable == null)
{
throw new SerializationException(
Error.Format(SRResources.CannotWriteType, GetType().Name, graph.GetType().FullName));
}
await WriteFeedAsync(enumerable, expectedType, writer, writeContext);
}
示例14: ConvertValue
internal static object ConvertValue(
object odataValue,
string parameterName,
Type expectedReturnType,
IEdmTypeReference propertyType,
IEdmModel model,
HttpRequestMessage request,
IServiceProvider serviceProvider)
{
var readContext = new ODataDeserializerContext
{
Model = model,
Request = request
};
// Enum logic can be removed after RestierEnumDeserializer extends ODataEnumDeserializer
var deserializerProvider = serviceProvider.GetService<ODataDeserializerProvider>();
var enumValue = odataValue as ODataEnumValue;
if (enumValue != null)
{
ODataEdmTypeDeserializer deserializer
= deserializerProvider.GetEdmTypeDeserializer(propertyType.AsEnum());
return deserializer.ReadInline(enumValue, propertyType, readContext);
}
var returnValue = ODataModelBinderConverter.Convert(
odataValue, propertyType, expectedReturnType, parameterName, readContext, serviceProvider);
if (!propertyType.IsCollection())
{
return returnValue;
}
return ConvertCollectionType(returnValue, expectedReturnType);
}
示例15: CreateDeserializer
protected override ODataEntryDeserializer CreateDeserializer(IEdmTypeReference edmType)
{
if (edmType != null)
{
switch (edmType.TypeKind())
{
case EdmTypeKind.Entity:
return new ODataEntityDeserializer(edmType.AsEntity(), this);
case EdmTypeKind.Primitive:
return new ODataPrimitiveDeserializer(edmType.AsPrimitive());
case EdmTypeKind.Complex:
return new ODataComplexTypeDeserializer(edmType.AsComplex(), this);
case EdmTypeKind.Collection:
IEdmCollectionTypeReference collectionType = edmType.AsCollection();
if (collectionType.ElementType().IsEntity())
{
return new ODataFeedDeserializer(collectionType, this);
}
else
{
return new ODataCollectionDeserializer(collectionType, this);
}
}
}
return null;
}