Пример #1
0
        public static Task <Stream> GetStreamAsync(this AbstractStreamSource source)
        {
            if (source is null)
            {
                throw new System.ArgumentNullException(nameof(source));
            }

            return(source.GetStreamAsync(null));
        }
Пример #2
0
        public static async Task <ResultT> DecodeAsync <ResultT>(this AbstractStreamSource source, IDeserializer <ResultT> deserializer, IProgress prog = null)
        {
            if (source is null)
            {
                throw new System.ArgumentNullException(nameof(source));
            }

            if (deserializer is null)
            {
                throw new System.ArgumentNullException(nameof(deserializer));
            }

            prog.Report(0);
            using var stream = await source
                               .GetStreamAsync(prog)
                               .ConfigureAwait(false);

            var value = deserializer.Deserialize(stream);

            prog.Report(1);
            return(value);
        }