Esempio n. 1
0
        /// <inheritdoc />
        public override async Task <object> ReadAsync(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
        {
            if (messageReader == null)
            {
                throw Error.ArgumentNull("messageReader");
            }

            if (readContext == null)
            {
                throw new ArgumentNullException(nameof(readContext));
            }

            IEdmTypeReference edmType = readContext.GetEdmType(type);

            Contract.Assert(edmType != null);

            if (!edmType.IsCollection())
            {
                throw Error.Argument("type", SRResources.ArgumentMustBeOfType, EdmTypeKind.Collection);
            }

            IEdmCollectionTypeReference collectionType = edmType.AsCollection();
            IEdmTypeReference           elementType    = collectionType.ElementType();
            ODataCollectionReader       reader         = await messageReader.CreateODataCollectionReaderAsync(elementType).ConfigureAwait(false);

            return(ReadInline(await ReadCollectionAsync(reader).ConfigureAwait(false), edmType, readContext));
        }
        /// <inheritdoc />
        public override async Task <object> ReadAsync(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
        {
            if (messageReader == null)
            {
                throw Error.ArgumentNull("messageReader");
            }

            IEdmTypeReference     edmType     = GetElementType(type, readContext);
            IEdmTypeReference     elementType = edmType.AsCollection().ElementType();
            ODataCollectionReader reader      = await messageReader.CreateODataCollectionReaderAsync(elementType);

            return(ReadInline(await ReadCollectionAsync(reader), edmType, readContext));
        }