Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
 public IActionResult Reload([FromServices] WellKnownChangeToken changeToken)
 {
     changeToken.TokenSource.Cancel();
     return(Ok());
 }
 public ApiExplorerRouteChangeConvention(WellKnownChangeToken changeToken)
 {
     ChangeToken = changeToken;
 }
 public ActionDescriptorChangeProvider(WellKnownChangeToken changeToken)
 {
     ChangeToken = changeToken;
 }