Asp.Net 核心 RTM StaticFileMiddleware:如何传递 IOptions<StaticFileOptions>?

Asp.Net Core RTM StaticFileMiddleware: how to pass IOptions<StaticFileOptions>?

在我的团队中,我们正在将 ASP.NET 核心 RC1 网络应用程序迁移到 RTM。有一个自定义中间件在内部创建 StaticFileMiddleware 的实例。在 RC1 中它曾经是:

// ctor signature:
StaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv,
  StaticFileOptions options, // <--
  ILoggerFactory loggerFactory);

我们可以轻松创建并传递 StaticFileOptions 的实例。现在在 RTM 中是:

// ctor signature:
StaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv,
  IOptions<StaticFileOptions> options, // <--
  ILoggerFactory loggerFactory);

而且我不知道如何创建 IOptions<StaticFileOptions>。实际上我不知道如何创建一个 IOptions<T> ,有一个 T 实例。

Latest reference 文档页面,尚未在 Google 结果的顶部,不提供任何提示。 StaticFileMiddleware 上的搜索结果总体上非常稀缺。

有人知道如何进行吗?这实际上阻碍了我们继续迁移。 TA

看起来 Microsoft.Extensions.Options 命名空间中的静态 Options class 提供了一个 IOptions<TOptions> Create<TOptions>(TOptions options) 静态工厂方法。还没有 运行,但至少它不会使构建失败。

顺便说一句,看着 Asp.Net 核心 Options github issues and PRs there's a whole host of discussion that went on around Feb/Mar (2016) about this usage pattern. Just to name a few: Is#122, PR#757, PR#719, PR#124. Issue #105 引导我朝着(希望)正确的方向前进。