protected internal override async Task <T> UnpackFromAsyncCore(Unpacker unpacker, CancellationToken cancellationToken) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var buffer = new KeyValuePair <TKey, TValue> [UnpackHelpers.GetItemsCount(unpacker)]; using (var subTreeUnpacker = unpacker.ReadSubtree()) { for (int i = 0; i < buffer.Length; i++) { if (!await subTreeUnpacker.ReadAsync(cancellationToken).ConfigureAwait(false)) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } var key = await this._keySerializer.UnpackFromAsync(unpacker, cancellationToken).ConfigureAwait(false); if (!await subTreeUnpacker.ReadAsync(cancellationToken).ConfigureAwait(false)) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } var value = await this._valueSerializer.UnpackFromAsync(unpacker, cancellationToken).ConfigureAwait(false); buffer[i] = new KeyValuePair <TKey, TValue>(key, value); } } return(this._factory(buffer)); }
protected internal override T UnpackFromCore(Unpacker unpacker) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var buffer = new KeyValuePair <TKey, TValue> [UnpackHelpers.GetItemsCount(unpacker)]; using (var subTreeUnpacker = unpacker.ReadSubtree()) { for (int i = 0; i < buffer.Length; i++) { if (!subTreeUnpacker.Read()) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } var key = this._keySerializer.UnpackFrom(unpacker); if (!subTreeUnpacker.Read()) { SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker); } var value = this._valueSerializer.UnpackFrom(unpacker); buffer[i] = new KeyValuePair <TKey, TValue>(key, value); } } return(this._factory(buffer)); }
protected internal override void UnpackToCore(Unpacker unpacker, Dictionary <TKey, TValue> collection) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } this.UnpackToCore(unpacker, collection, UnpackHelpers.GetItemsCount(unpacker)); }
protected internal override Task UnpackToAsyncCore(Unpacker unpacker, Dictionary <TKey, TValue> collection, CancellationToken cancellationToken) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } return(this.UnpackToAsyncCore(unpacker, collection, UnpackHelpers.GetItemsCount(unpacker), cancellationToken)); }
protected internal override void UnpackToCore(Unpacker unpacker, NameValueCollection collection) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } UnpackToCore(unpacker, collection, UnpackHelpers.GetItemsCount(unpacker)); }
protected internal override Dictionary <TKey, TValue> UnpackFromCore(Unpacker unpacker) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var count = UnpackHelpers.GetItemsCount(unpacker); var collection = new Dictionary <TKey, TValue>(count); this.UnpackToCore(unpacker, collection, count); return(collection); }
protected internal override NameValueCollection UnpackFromCore(Unpacker unpacker) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var count = UnpackHelpers.GetItemsCount(unpacker); var collection = new NameValueCollection(count); UnpackToCore(unpacker, collection, count); return(collection); }
protected internal override MessagePackObjectDictionary UnpackFromCore(Unpacker unpacker) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var count = UnpackHelpers.GetItemsCount(unpacker); var result = new MessagePackObjectDictionary(count); UnpackToCore(unpacker, count, result); return(result); }
protected internal override async Task <Dictionary <TKey, TValue> > UnpackFromAsyncCore(Unpacker unpacker, CancellationToken cancellationToken) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var count = UnpackHelpers.GetItemsCount(unpacker); var collection = new Dictionary <TKey, TValue>(count); await this.UnpackToAsyncCore(unpacker, collection, count, cancellationToken).ConfigureAwait(false); return(collection); }
protected internal override async Task <MessagePackObjectDictionary> UnpackFromAsyncCore(Unpacker unpacker, CancellationToken cancellationToken) { if (!unpacker.IsMapHeader) { SerializationExceptions.ThrowIsNotMapHeader(unpacker); } var count = UnpackHelpers.GetItemsCount(unpacker); var result = new MessagePackObjectDictionary(count); await UnpackToAsyncCore(unpacker, count, result, cancellationToken).ConfigureAwait(false); return(result); }