コード例 #1
0
        private string RenderResources()
        {
            StringBuilder sb        = new StringBuilder();
            var           resources = SampleUtils.GetDynamicResources(UriHelper, SampleService);

            foreach (var resource in resources)
            {
                sb.Append(Environment.NewLine);
                if (resource.EndsWith(".css"))
                {
                    sb.Append($"    <link");
                    sb.Append($" href=\"" + resource + "\"");
                    sb.Append($" rel=\"stylesheet\"");
                    sb.Append(" />");
                }
                else
                {
                    sb.Append($"    <script");
                    sb.Append($" src=\"" + resource + "\"");
                    if (resource.IndexOf("/common/lodash") < 0)
                    {
                        sb.Append($" async");
                    }
                    sb.Append(" ></script>");
                }
            }
            sb.Append(Environment.NewLine);
            return(sb.ToString());
        }
コード例 #2
0
        private string RenderStyles()
        {
            var           themeName = SampleUtils.GetThemeName(UriHelper.Uri);
            StringBuilder sb        = new StringBuilder();

            sb.Append(Environment.NewLine);
            sb.Append($"    <link");
            sb.Append($" href=\"{ stylePath + themeName + ".css"}\"");
            sb.Append($" rel=\"stylesheet\"");
            sb.Append(" />");
            sb.Append(Environment.NewLine);
            return(sb.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Returns list of resources need to be loaded.
        /// </summary>
        /// <returns></returns>
        public static List <string> GetDynamicResources(NavigationManager uriHelper, SampleService sampleService)
        {
            var resourceList = new List <string>();

            if (!sampleService.IsHomeLoaded && SampleUtils.IsHomePage(uriHelper))
            {
                sampleService.IsHomeLoaded = true;
#if DEBUG
                resourceList = new List <string> {
                    "styles/common/home.css"
                };
#else
                resourceList = new List <string> {
                    "styles/common/home.min.css"
                };
#endif
            }
            else if (!sampleService.IsDemoLoaded)
            {
                sampleService.IsDemoLoaded = true;
#if DEBUG
                resourceList = new List <string>
                {
                    "styles/common/roboto.css",
                    "styles/common/highlight.css",
                    "styles/common/demos.css",
                    // "scripts/common/lodash.min.js",
                    "scripts/common/highlight.min.js"
                };
                if (uriHelper.Uri.Contains("theme=highcontrast"))
                {
                    resourceList.Add("styles/common/highcontrast.css");
                }
                if (new Regex(@"theme=.*-dark").IsMatch(uriHelper.Uri))
                {
                    resourceList.Add("styles/common/dark-theme.css");
                }
#else
                resourceList = new List <string>
                {
                    "styles/common/demos.min.css",
                    "scripts/common/demos.min.js"
                };
                if (uriHelper.Uri.Contains("theme=highcontrast") || new Regex(@"theme=.*-dark").IsMatch(uriHelper.Uri))
                {
                    resourceList.Add("styles/common/dark-theme.min.css");
                }
#endif
            }
            return(resourceList);
        }
コード例 #4
0
        /// <summary>
        /// Returns list of resources need to be loaded.
        /// </summary>
        /// <returns></returns>
        public static List <string> GetDynamicResources(NavigationManager uriHelper, SampleService sampleService)
        {
            var resourceList = new List <string>();

            if (!sampleService.IsHomeLoaded && SampleUtils.IsHomePage(uriHelper))
            {
                sampleService.IsHomeLoaded = true;
#if DEBUG
                resourceList = new List <string> {
                    "styles/common/home.css"
                };
#else
                resourceList = new List <string> {
                    "styles/common/home.min.css"
                };
#endif
            }
            else if (!sampleService.IsDemoLoaded)
            {
                sampleService.IsDemoLoaded = true;
#if DEBUG || STAGING
                resourceList = new List <string>
                {
                    "scripts/common/lodash.min.js",
                    "_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js",
                    "styles/common/roboto.css",
                    "styles/common/highlight.css",
                    "styles/common/demos.css",
                    "scripts/common/highlight.min.js"
                };
                if (uriHelper.Uri.Contains("theme=highcontrast"))
                {
                    resourceList.Add("styles/common/highcontrast.css");
                }
                if (new Regex(@"theme=.*-dark").IsMatch(uriHelper.Uri))
                {
                    resourceList.Add("styles/common/dark-theme.css");
                }
#else
                resourceList = new List <string>
                {
                    $"scripts/common/lodash.min.js",
                    $"https://cdn.syncfusion.com/blazor/19.3.43/syncfusion-blazor.min.js",
                    $"styles/common/demos.min.css",
                    $"scripts/common/demos.min.js"
                };
                if (uriHelper.Uri.Contains("theme=highcontrast") || new Regex(@"theme=.*-dark").IsMatch(uriHelper.Uri))
                {
                    resourceList.Add("styles/common/dark-theme.min.css");
                }
#endif
                if (sampleService.ComponentName.Equals("PDF Viewer") && !sampleService.IsPdfScriptLoaded)
                {
                    sampleService.IsPdfScriptLoaded = true;
                    resourceList.Add(sampleService.PdfScriptPath + "/syncfusion-blazor-pdfviewer.min.js");
                }
                if (sampleService.ComponentName.Equals("Word Processor") && !sampleService.IsDocScriptLoaded)
                {
                    sampleService.IsDocScriptLoaded = true;
                    resourceList.Add(sampleService.DocScriptPath + "/syncfusion-blazor-documenteditor.min.js");
                }
                if (sampleService.ComponentName.Equals("Diagram") && !sampleService.IsDiagramScriptLoaded)
                {
                    sampleService.IsDiagramScriptLoaded = true;
#if DEBUG || STAGING
                    resourceList.Add("scripts/diagram/interop.js");
#else
                    resourceList.Add("scripts/diagram/interop.min.js");
#endif
                }
            }
            return(resourceList);
        }