Ejemplo n.º 1
0
        public static async Task <T> As <T>(this SolidHttpRequest request, SharpCompressOptions options)
        {
            var factory     = new SharpCompressResponseDeserializerFactory(options);
            var deserialize = factory.CreateDeserializer <T>();

            return(await request.As <T>());
        }
        public static ISolidHttpBuilder AddSharpCompress(this ISolidHttpBuilder builder, SharpCompressOptions options = default(SharpCompressOptions))
        {
            options = options ?? new SharpCompressOptions();
            if (options.MimeTypes.Count < 1)
            {
                throw new ArgumentException("You have to have at least one mimetype specified");
            }
            var provider = new SharpCompressSerializerSettingsProvider(options);

            builder.Services.AddSingleton <ISharpCompressSerializerSettingsProvider>(provider);
            var mimeTypeTail = options.MimeTypes.GetRange(1, options.MimeTypes.Count - 1);

            builder.Services.AddSolidHttpDeserializer <SharpCompressResponseDeserializerFactory>(options.MimeTypes[0], mimeTypeTail.ToArray());
            return(builder);
        }
Ejemplo n.º 3
0
 internal SharpCompressResponseDeserializerFactory(SharpCompressOptions options)
 {
     GetReaderOptions = () => options;
 }