private static object ConvertCollectionValue(ODataCollectionValue collection, IEdmTypeReference propertyType, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext) { IEdmCollectionTypeReference collectionType = propertyType as IEdmCollectionTypeReference; Contract.Assert(collectionType != null, "The type for collection must be a IEdmCollectionType."); ODataEdmTypeDeserializer deserializer = deserializerProvider.GetEdmTypeDeserializer(collectionType); return(deserializer.ReadInline(collection, readContext)); }
private static object ConvertComplexValue(ODataComplexValue complexValue, ref IEdmTypeReference propertyType, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext) { IEdmComplexTypeReference edmComplexType; if (propertyType == null) { // open complex property Contract.Assert(!String.IsNullOrEmpty(complexValue.TypeName), "ODataLib should have verified that open complex value has a type name since we provided metadata."); IEdmModel model = readContext.Model; IEdmType edmType = model.FindType(complexValue.TypeName); Contract.Assert(edmType.TypeKind == EdmTypeKind.Complex, "ODataLib should have verified that complex value has a complex resource type."); edmComplexType = new EdmComplexTypeReference(edmType as IEdmComplexType, isNullable: true); } else { edmComplexType = propertyType.AsComplex(); } ODataEdmTypeDeserializer deserializer = deserializerProvider.GetEdmTypeDeserializer(edmComplexType); return(deserializer.ReadInline(complexValue, readContext)); }
private ODataDeserializer GetDeserializer(Type type, ODataPath path, IEdmModel model, ODataDeserializerProvider deserializerProvider, out IEdmTypeReference expectedPayloadType) { expectedPayloadType = GetExpectedPayloadType(type, path, model); // Get the deserializer using the CLR type first from the deserializer provider. ODataDeserializer deserializer = deserializerProvider.GetODataDeserializer(model, type, Request); if (deserializer == null && expectedPayloadType != null) { // we are in typeless mode, get the deserializer using the edm type from the path. deserializer = deserializerProvider.GetEdmTypeDeserializer(expectedPayloadType); } return deserializer; }
private static object ConvertCollectionValue(ODataCollectionValue collection, IEdmTypeReference propertyType, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext) { IEdmCollectionTypeReference collectionType = propertyType as IEdmCollectionTypeReference; Contract.Assert(collectionType != null, "The type for collection must be a IEdmCollectionType."); ODataEdmTypeDeserializer deserializer = deserializerProvider.GetEdmTypeDeserializer(collectionType); return deserializer.ReadInline(collection, collectionType, readContext); }
private static object ConvertComplexValue(ODataComplexValue complexValue, ref IEdmTypeReference propertyType, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext) { IEdmComplexTypeReference edmComplexType; if (propertyType == null) { // open complex property Contract.Assert(!String.IsNullOrEmpty(complexValue.TypeName), "ODataLib should have verified that open complex value has a type name since we provided metadata."); IEdmModel model = readContext.Model; IEdmType edmType = model.FindType(complexValue.TypeName); Contract.Assert(edmType.TypeKind == EdmTypeKind.Complex, "ODataLib should have verified that complex value has a complex resource type."); edmComplexType = new EdmComplexTypeReference(edmType as IEdmComplexType, isNullable: true); } else { edmComplexType = propertyType.AsComplex(); } ODataEdmTypeDeserializer deserializer = deserializerProvider.GetEdmTypeDeserializer(edmComplexType); return deserializer.ReadInline(complexValue, propertyType, readContext); }
private ODataDeserializer GetDeserializer(Type type, ODataPath path, IEdmModel model, ODataDeserializerProvider deserializerProvider, out IEdmTypeReference expectedPayloadType) { expectedPayloadType = GetExpectedPayloadType(type, path, model); if (expectedPayloadType != null) { return deserializerProvider.GetEdmTypeDeserializer(expectedPayloadType); } else { return deserializerProvider.GetODataDeserializer(model, type, Request); } }
private ODataDeserializer GetDeserializer(Type type, ODataPath path, IEdmModel model, ODataDeserializerProvider deserializerProvider) { if (typeof(IEdmObject).IsAssignableFrom(type)) { // typeless mode. figure out the expected payload type from the OData Path. IEdmType edmType = path.EdmType; if (edmType != null) { IEdmTypeReference expectedPayloadType = EdmLibHelpers.ToEdmTypeReference(edmType, isNullable: false); if (expectedPayloadType.TypeKind() == EdmTypeKind.Collection) { IEdmTypeReference elementType = expectedPayloadType.AsCollection().ElementType(); if (elementType.IsEntity()) { // collection of entities cannot be CREATE/UPDATEd. Instead, the request would contain a single entry. expectedPayloadType = elementType; } } if (expectedPayloadType != null) { return deserializerProvider.GetEdmTypeDeserializer(expectedPayloadType); } } } else { TryGetInnerTypeForDelta(ref type); return deserializerProvider.GetODataDeserializer(model, type, Request); } return null; }