Ejemplo n.º 1
0
        public void Configure(IConfiguration configuration, string path)
        {
            _traceFilter.ConfigureWith(configuration);

            _configurationRegistration = configuration.Register(
                path,
                cfg =>
            {
                _configuration = cfg;

                Func <string, PathString> normalizeUrl = u =>
                {
                    if (u == null)
                    {
                        return(new PathString());
                    }

                    u = u.Replace("\\", "/");

                    if (u.Length > 0 && u.EndsWith("/"))
                    {
                        u = u.Substring(0, u.Length - 1);
                    }

                    if (!u.StartsWith("/"))
                    {
                        u = "/" + u;
                    }

                    return(new PathString(u));
                };

                _rootDartFolder  = normalizeUrl(cfg.DartUiRootUrl);
                _rootBuildFolder = normalizeUrl(cfg.CompiledUiRootUrl);
                _rootUrl         = normalizeUrl(cfg.UiRootUrl);
                _defaultDocument = normalizeUrl(cfg.DefaultDocument);
            },
                new DartConfiguration());
        }
Ejemplo n.º 2
0
        private Task DocumentConfiguration(IOwinContext context)
        {
            var document = GetScriptResource("configuration.html");

            document = document.Replace("{dartUiRootUrl}", _configuration.DartUiRootUrl);
            document = document.Replace("{defaultDocument}", _configuration.DefaultDocument);
            document = document.Replace("{documentationRootUrl}", _configuration.DocumentationRootUrl);
            document = document.Replace("{uiRootUrl}", _configuration.UiRootUrl);
            document = document.Replace("{compiledUiRootUrl}", _configuration.CompiledUiRootUrl);
            document = document.Replace("{analyticsEnabled}", _configuration.AnalyticsEnabled.ToString());

            var defaultConfiguration = new DartConfiguration();

            document = document.Replace("{dartUiRootUrl.default}", defaultConfiguration.DartUiRootUrl);
            document = document.Replace("{defaultDocument.default}", defaultConfiguration.DefaultDocument);
            document = document.Replace("{documentationRootUrl.default}", defaultConfiguration.DocumentationRootUrl);
            document = document.Replace("{uiRootUrl.default}", defaultConfiguration.UiRootUrl);
            document = document.Replace("{compiledUiRootUrl.default}", defaultConfiguration.CompiledUiRootUrl);
            document = document.Replace("{analyticsEnabled.default}", defaultConfiguration.AnalyticsEnabled.ToString());

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