/// <summary> /// Initializes a new instance of the <see cref="KFrameMiddleware"/> class. /// </summary> /// <param name="next">The next.</param> /// <param name="options">The options.</param> /// <param name="cache">The cache.</param> public KFrameMiddleware(RequestDelegate next, KFrameOptions options, IMemoryCache cache, IKFrameSource[] sources) { _next = next; _options = options; _cache = cache; _repository = new KFrameRepository(_cache, _options, sources); }
/// <summary> /// Uses the k frame. /// </summary> /// <param name="app">The application.</param> /// <param name="assemblys">The assemblys.</param> /// <returns>IApplicationBuilder.</returns> /// <exception cref="System.ArgumentNullException">app</exception> public static IApplicationBuilder UseKFrame(this IApplicationBuilder app, params Assembly[] assemblys) { if (app == null) { throw new ArgumentNullException(nameof(app)); } var sources = KFrameRepository.FindSourcesFromAssembly(assemblys); return(app.UseMiddleware <KFrameMiddleware>(new KFrameOptions { }, sources)); }
/// <summary> /// Uses the k frame. /// </summary> /// <param name="app">The application.</param> /// <param name="requestPath">The request path.</param> /// <param name="log">The logger.</param> /// <param name="assemblies">The assemblies.</param> /// <returns>IApplicationBuilder.</returns> /// <exception cref="System.ArgumentNullException">app</exception> public static IApplicationBuilder UseKFrame(this IApplicationBuilder app, string requestPath, ILogger log, params Assembly[] assemblies) { if (app == null) { throw new ArgumentNullException(nameof(app)); } var sources = KFrameRepository.FindSourcesFromAssembly(assemblies); return(app.UseMiddleware <KFrameMiddleware>(new KFrameOptions { RequestPath = new PathString(requestPath), Log = log, }, sources)); }
/// <summary> /// Uses the k frame. /// </summary> /// <param name="app">The application.</param> /// <param name="options">The options.</param> /// <param name="requestPath">The request path.</param> /// <param name="assemblys">The assemblys.</param> /// <returns>IApplicationBuilder.</returns> /// <exception cref="System.ArgumentNullException">app</exception> /// <exception cref="System.ArgumentNullException">options</exception> public static IApplicationBuilder UseKFrame(this IApplicationBuilder app, KFrameOptions options, string requestPath, params Assembly[] assemblys) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } options.RequestPath = requestPath; var sources = KFrameRepository.FindSourcesFromAssembly(assemblys); return(app.UseMiddleware <KFrameMiddleware>(options, sources)); }