/// <inheritdoc /> public override async Task <object> ReadAsync(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext) { if (messageReader == null) { throw Error.ArgumentNull(nameof(messageReader)); } if (readContext == null) { throw Error.ArgumentNull(nameof(readContext)); } // TODO: Need to modify how to get the Edm type for the delta resource set? IEdmTypeReference edmType = readContext.GetEdmType(type); Contract.Assert(edmType != null); // TODO: is it ok to read the top level collection of entity? if (!(edmType.IsCollection() && edmType.AsCollection().ElementType().IsStructured())) { throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, EdmTypeKind.Complex + " or " + EdmTypeKind.Entity); } ODataReader resourceSetReader = await messageReader.CreateODataDeltaResourceSetReaderAsync().ConfigureAwait(false); object deltaResourceSet = await resourceSetReader.ReadResourceOrResourceSetAsync().ConfigureAwait(false); return(ReadInline(deltaResourceSet, edmType, readContext)); }
/// <inheritdoc /> public override async Task <object> ReadAsync(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext) { if (messageReader == null) { throw Error.ArgumentNull(nameof(messageReader)); } if (readContext == null) { throw Error.ArgumentNull(nameof(readContext)); } // TODO: Need to modify how to get the Edm type for the delta resource set? IEdmTypeReference edmType = readContext.GetEdmType(type); Contract.Assert(edmType != null); IEdmEntityType entityType = edmType.Definition as IEdmEntityType; EdmDeltaCollectionType edmCollectionType = new EdmDeltaCollectionType(edmType); edmType = new EdmCollectionTypeReference(edmCollectionType); // TODO: is it ok to read the top level collection of entity? if (!(edmType.IsCollection() && edmType.AsCollection().ElementType().IsStructured())) { throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, EdmTypeKind.Complex + " or " + EdmTypeKind.Entity); } IEdmNavigationSource navigationSource; if (readContext.Path == null) { throw Error.Argument("readContext", SRResources.ODataPathMissing); } navigationSource = readContext.Path.GetNavigationSource(); if (navigationSource == null) { throw new SerializationException(SRResources.NavigationSourceMissingDuringDeserialization); } ODataReader resourceSetReader = await messageReader.CreateODataDeltaResourceSetReaderAsync(navigationSource as IEdmEntitySet, entityType).ConfigureAwait(false); object deltaResourceSet = await resourceSetReader.ReadResourceOrResourceSetAsync().ConfigureAwait(false); return(ReadInline(deltaResourceSet, edmType, readContext)); }