Ejemplo n.º 1
0
        /// <summary>
        /// Настраивает функции обратного вызова Облачной АТС Мегафон
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IServiceCollection AddMegafonCallbacks <THandler>(this IServiceCollection services, Action <MegafonCallbackOptions <THandler> > configure)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            var options = new MegafonCallbackOptions <THandler>();

            configure(options);
            services.AddSingleton(options);
            services.AddTransient <ICallbackMiddleware, BoundCallbackMiddleware <THandler> >();

            return(services);
        }
 protected override Task InvokeOnHistory(MegafonCallbackOptions <THandler> options, HistoryRequest request)
 {
     return(options.InvokeOnHistory(_handler, request));
 }
 protected override Task InvokeOnEvent(MegafonCallbackOptions <THandler> options, EventRequest request)
 {
     return(options.InvokeOnEvent(_handler, request));
 }
 protected override Task <MegafonContact> InvokeOnContact(MegafonCallbackOptions <THandler> options, ContactRequest request)
 {
     return(options.InvokeOnContact(_handler, request));
 }
 public BoundCallbackMiddleware(THandler handler, MegafonCallbackOptions <THandler> options, ILogger <BoundCallbackMiddleware <THandler> > logger = null) : base(options, logger)
 {
     _handler = handler;
 }