public static void AddHystrixCollapser <TService>(this IServiceCollection services, IHystrixCollapserKey collapserKey, RequestCollapserScope scope, IConfiguration config)
            where TService : class
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

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

            var strategy = HystrixPlugins.OptionsStrategy;
            var dynOpts  = strategy.GetDynamicOptions(config);

            var opts = new HystrixCollapserOptions(collapserKey, scope, null, dynOpts);

            services.AddTransient <TService>((p) => (TService)ActivatorUtilities.CreateInstance(p, typeof(TService), opts));
        }
        public static void RegisterHystrixCollapser <TService>(this ContainerBuilder container, IHystrixCollapserKey collapserKey, RequestCollapserScope scope, IConfiguration config)
            where TService : class
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

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

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

            var strategy = HystrixPlugins.OptionsStrategy;
            var dynOpts  = strategy.GetDynamicOptions(config);

            HystrixCollapserOptions opts = new HystrixCollapserOptions(collapserKey, scope, null, dynOpts);

            container.RegisterType <TService>().WithParameter(new TypedParameter(typeof(IHystrixCollapserOptions), opts)).InstancePerDependency();
        }