/// <summary> /// Retrieves the Edm Type from the given type, using ODataDeserializerContext /// </summary> /// <param name="context">Context with information about current EdmModel</param> /// <param name="type">The type to find an equivalent Edm type to</param> /// <returns>Equivalent EdmType to given Type</returns> private IEdmTypeReference GetEdmType(ODataDeserializerContext context, Type type) { if (context.ResourceEdmType != null) { return(context.ResourceEdmType); } return(EdmExtensions.GetExpectedPayloadType(type, context.Path, context.Model)); }
// Choose deserializer for given type. If the type is already known to be an edm type at this point, // use getEdmTypeDeserializer from the ODataMigrationDeserializerProvider. If not, use getOdataPayloadDeserializer. private static ODataDeserializer GetDeserializer( Type type, ODataPath path, IEdmModel model, Func <IEdmTypeReference, ODataDeserializer> getEdmTypeDeserializer, Func <Type, ODataDeserializer> getODataPayloadDeserializer, out IEdmTypeReference expectedPayloadType) { expectedPayloadType = EdmExtensions.GetExpectedPayloadType(type, path, model); // Get the deserializer using the CLR type first from the deserializer provider. ODataDeserializer deserializer = getODataPayloadDeserializer(type); if (deserializer == null && expectedPayloadType != null) { // we are in typeless mode, get the deserializer using the edm type from the path. deserializer = getEdmTypeDeserializer(expectedPayloadType); } return(deserializer); }
public override ODataPrimitiveValue CreateODataPrimitiveValue(object graph, IEdmPrimitiveTypeReference primitiveType, ODataSerializerContext writeContext) { if (primitiveType.IsInt64()) { IEdmPrimitiveTypeReference convertedType = (IEdmPrimitiveTypeReference)EdmExtensions.GetEdmPrimitiveTypeOrNull(typeof(string)).ToEdmTypeReference(); return(base.CreateODataPrimitiveValue(graph.ToString(), convertedType, writeContext)); } else { return(base.CreateODataPrimitiveValue(graph, primitiveType, writeContext)); } }