Exemplo n.º 1
0
 public DrapoMiddleware(RequestDelegate next, IHostingEnvironment env, DrapoMiddlewareOptions options)
 {
     this._next         = next;
     this._options      = options ?? new DrapoMiddlewareOptions();
     this._webRootPath  = env.WebRootPath;
     this._urlActivator = string.Format("/{0}", ACTIVATORJS);
     this._urlConfig    = string.Format("/{0}", ACTIVATORJSON);
     Initialize();
 }
Exemplo n.º 2
0
 public static void AddDrapo(this IServiceCollection services, DrapoMiddlewareOptions options = null)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     //Prerequisites for Drapo here
     services.Add(new ServiceDescriptor(typeof(DrapoMiddlewareOptions), options ?? new DrapoMiddlewareOptions()));
     services.Add(new ServiceDescriptor(typeof(IDrapoRequestHeaderReader), typeof(DrapoRequestHeaderReader), ServiceLifetime.Transient));
     services.Add(new ServiceDescriptor(typeof(IDrapoUserConfig), typeof(DrapoUserConfig), ServiceLifetime.Transient));
     services.Add(new ServiceDescriptor(typeof(IDrapoPlumber), typeof(DrapoPlumber), ServiceLifetime.Transient));
 }
Exemplo n.º 3
0
        public static IApplicationBuilder UseDrapo(this IApplicationBuilder builder, Action <DrapoMiddlewareOptions> configureOptions)
        {
            DrapoMiddlewareOptions options = builder.ApplicationServices.GetService(typeof(DrapoMiddlewareOptions)) as DrapoMiddlewareOptions;

            if (options == null)
            {
                throw new InvalidOperationException("To use Drapo you need to add it first in the Startup");
            }
            configureOptions(options);
            if ((options.Config.UsePipes) && (builder.ApplicationServices.GetService(typeof(IHubContext <DrapoPlumberHub>)) == null))
            {
                throw new InvalidOperationException("To use Drapo pipes you need to add the signalr middleware and add the route for DrapoPlumberHub in the Startup");
            }
            return(builder.UseMiddleware <DrapoMiddleware>());
        }
Exemplo n.º 4
0
 public static void AddDrapo(this IServiceCollection services, DrapoMiddlewareOptions options = null)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     //Prerequisites for Drapo here
     if (options == null)
     {
         options = new DrapoMiddlewareOptions();
     }
     services.Add(new ServiceDescriptor(typeof(DrapoMiddlewareOptions), options));
     services.AddScoped <IDrapoRequestReader, DrapoRequestReader>();
     services.Add(new ServiceDescriptor(typeof(IDrapoUserConfig), typeof(DrapoUserConfig), ServiceLifetime.Transient));
     services.Add(new ServiceDescriptor(typeof(IDrapoPlumber), typeof(DrapoPlumber), ServiceLifetime.Transient));
     if (!string.IsNullOrEmpty(options.BackplaneRedis))
     {
         services.Add(new ServiceDescriptor(typeof(IDrapoConnectionManager), typeof(DrapoConnectionManagerRedis), ServiceLifetime.Singleton));
     }
     else
     {
         services.Add(new ServiceDescriptor(typeof(IDrapoConnectionManager), typeof(DrapoConnectionManagerSingle), ServiceLifetime.Singleton));
     }
 }