コード例 #1
0
ファイル: Startup.cs プロジェクト: pa-at/aspnetcore
    // Set up application services
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddTransient <ILoggerFactory, LoggerFactory>();

        var wellKnownChangeToken = new WellKnownChangeToken();

        services.AddControllers(options =>
        {
            options.Filters.AddService(typeof(ApiExplorerDataFilter));

            options.Conventions.Add(new ApiExplorerVisibilityEnabledConvention());
            options.Conventions.Add(new ApiExplorerVisibilityDisabledConvention(
                                        typeof(ApiExplorerVisibilityDisabledByConventionController)));
            options.Conventions.Add(new ApiExplorerInboundOutboundConvention(
                                        typeof(ApiExplorerInboundOutBoundController)));
            options.Conventions.Add(new ApiExplorerRouteChangeConvention(wellKnownChangeToken));

            options.OutputFormatters.Clear();
            options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
        })
        .AddNewtonsoftJson();

        services.AddSingleton <ApiExplorerDataFilter>();
        services.AddSingleton <IActionDescriptorChangeProvider, ActionDescriptorChangeProvider>();
        services.AddSingleton(wellKnownChangeToken);
    }
コード例 #2
0
 public ActionDescriptorChangeProvider(WellKnownChangeToken changeToken)
 {
     ChangeToken = changeToken;
 }
コード例 #3
0
 public ApiExplorerRouteChangeConvention(WellKnownChangeToken changeToken)
 {
     ChangeToken = changeToken;
 }
コード例 #4
0
 public IActionResult Reload([FromServices] WellKnownChangeToken changeToken)
 {
     changeToken.TokenSource.Cancel();
     return(Ok());
 }