/// <summary>
        /// Adds a service to the ActivationContext. This is resolved and injected to the instantiation of the handlers
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public static IGlobalConfiguration AddService <T>(this IGlobalConfiguration config, Func <T> service)
        {
            var ctx = config.Resolve <IActivationContext>();

            if (ctx == null)
            {
                ctx = new ActivationContext();
                config.Register(ctx);
            }

            ctx.Register(service);

            return(config);
        }
        public static IGlobalConfiguration UseOptions(this IGlobalConfiguration config, Options options)
        {
            var def = config.Resolve <Options>();

            if (def == null)
            {
                config.Register(options);
                def = options;
            }

            def.Merge(options);

            return(config);
        }
        /// <summary>
        /// Adds a service to the ActivationContext. This is resolved and injected to the instantiation of the handlers
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <typeparam name="TImpl"></typeparam>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IGlobalConfiguration AddService <TService, TImpl>(this IGlobalConfiguration config) where TImpl : TService
        {
            var ctx = config.Resolve <IActivationContext>();

            if (ctx == null)
            {
                ctx = new ActivationContext();
                config.Register(ctx);
            }

            ctx.Register <TService, TImpl>();

            return(config);
        }
 /// <summary>
 /// Gets the <see cref="Options"/> from the <see cref="IGlobalConfiguration"/>
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Options GetOptions(this IGlobalConfiguration config)
 {
     return(config.Resolve <Options>());
 }
 /// <summary>
 /// Gets the <see cref="IStorage"/> from the <see cref="IGlobalConfiguration"/>
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IStorage GetStorage(this IGlobalConfiguration config)
 {
     return(config.Resolve <IStorage>());
 }