Ejemplo n.º 1
0
        void IConfigurable.Configure(IConfiguration configuration, string path)
        {
            _configurationRegistration = configuration.Register(
                path,
                cfg =>
            {
                _configuration = cfg;

                if (cfg.Enabled && !string.IsNullOrEmpty(cfg.Path))
                {
                    _visualizationPath = new PathString(cfg.Path);
                }
                else
                {
                    _visualizationPath = new PathString();
                }

                if (cfg.Enabled && !string.IsNullOrEmpty(cfg.DocumentationRootUrl))
                {
                    _documentationPath = new PathString(cfg.DocumentationRootUrl);
                }
                else
                {
                    _documentationPath = new PathString();
                }
            },
                new RouteVisualizerConfiguration());
        }
Ejemplo n.º 2
0
        private Task DocumentConfiguration(IOwinContext context)
        {
            var document = GetScriptResource("configuration.html");

            document = document.Replace("{path}", _configuration.Path);
            document = document.Replace("{enabled}", _configuration.Enabled.ToString());
            document = document.Replace("{requiredPermission}", _configuration.RequiredPermission ?? "<none>");
            document = document.Replace("{analyticsEnabled}", _configuration.AnalyticsEnabled.ToString());
            document = document.Replace("{documentationRootUrl}", _configuration.DocumentationRootUrl);

            var defaultConfiguration = new RouteVisualizerConfiguration();

            document = document.Replace("{path.default}", defaultConfiguration.Path);
            document = document.Replace("{enabled.default}", defaultConfiguration.Enabled.ToString());
            document = document.Replace("{requiredPermission.default}", defaultConfiguration.RequiredPermission ?? "<none>");
            document = document.Replace("{analyticsEnabled.default}", defaultConfiguration.AnalyticsEnabled.ToString());
            document = document.Replace("{documentationRootUrl.default}", defaultConfiguration.DocumentationRootUrl);

            context.Response.ContentType = "text/html";
            return(context.Response.WriteAsync(document));
        }