Пример #1
0
        public static HtmlString GetRefFooter()
        {
            var refFooter = new RefFooter
            {
                IsApplication = true
            };

            return(JsonSerializationHelper.SerializeToJson(refFooter));
        }
Пример #2
0
        public static HtmlString GetRefTop()
        {
            var refTop = new RefTop
            {
                IsApplication = true
            };

            return(JsonSerializationHelper.SerializeToJson(refTop));
        }
Пример #3
0
        public static HtmlString GetAppFooter()
        {
            var appFooter = new AppFooter
            {
                ShowFeatures = false,
                ShowFooter   = false
            };

            return(JsonSerializationHelper.SerializeToJson(appFooter));
        }
Пример #4
0
        public static HtmlString GetDefPreFooter()
        {
            var preFooter = new PreFooter
            {
                CdnEnv       = "prod",
                DateModified = "2020-05-05",
                ShowFeedback = false,
                ShowShare    = false
            };

            return(JsonSerializationHelper.SerializeToJson(preFooter));
        }
Пример #5
0
        public static HtmlString GetAppTop(string url, string applicationName)
        {
            var currentCulture   = url.Contains("/en/") ? "en" : "fr";
            var alternateCulture = currentCulture.Equals("en") ? "/fr/" : "/en/";

            //https://stackoverflow.com/questions/60376576/blazor-how-get-all-route-urls-from-razor-pages-in-blazor-server-side-project
            //get @page values from a page and get alternate language.
            var routeAttributes = Assembly.GetExecutingAssembly().ExportedTypes
                                  .Where(t => t.IsSubclassOf(typeof(ComponentBase)))
                                  .Where(x => x.Name.Length > 1)
                                  .Select(s => new { RouteAttributes = s.GetCustomAttributes(inherit: true).OfType <RouteAttribute>() });

            //get route values for the current page and get the alternate language.
            var alternateRoute = routeAttributes
                                 .SingleOrDefault(x => x.RouteAttributes.Any(a => a.Template.Contains(url)))?.RouteAttributes
                                 .SingleOrDefault(s => s.Template.Contains(alternateCulture))?.Template;

            var appTop = new AppTop
            {
                AppName = new List <Link> {
                    new Link {
                        Href = "#", Text = applicationName
                    }
                },
                LngLinks = new List <LanguageLink> {
                    new LanguageLink {
                        Href = alternateRoute
                    }
                },
                MenuLinks = new List <MenuLink> {
                    new MenuLink {
                        Href = "#", Text = "Nav 1"
                    }, new MenuLink {
                        Href = "#", Text = "Nav 2"
                    }, new MenuLink {
                        Href = "#", Text = "Nav 3"
                    }, new MenuLink {
                        Href = "#", Text = "Nav 4"
                    }
                }
            };

            return(JsonSerializationHelper.SerializeToJson(appTop));
        }