/// <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="options">The options.</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, params Assembly[] assemblys) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var sources = KFrameRepository.FindSourcesFromAssembly(assemblys); return(app.UseMiddleware <KFrameMiddleware>(options, sources)); }
/// <summary> /// Initializes a new instance of the <see cref="KFrameRepository" /> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="options">The options.</param> /// <param name="assemblys">The assemblys.</param> public KFrameRepository(IMemoryCache cache, KFrameOptions options, IEnumerable <Assembly> assemblys) : this(cache, options, FindSourcesFromAssembly(assemblys)) { }
/// <summary> /// Initializes a new instance of the <see cref="KFrameRepository"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="options">The options.</param> /// <param name="sources">The sources.</param> public KFrameRepository(IMemoryCache cache, KFrameOptions options, IKFrameSource[] sources) { _cache = cache ?? throw new ArgumentNullException(nameof(cache)); Options = options ?? throw new ArgumentNullException(nameof(options)); Sources = sources ?? throw new ArgumentNullException(nameof(sources)); }