Ejemplo n.º 1
0
        public void PopulateValues(ViewLocationExpanderContext context)
        {
            var themeContext = (IThemeProvider)context.ActionContext.HttpContext.RequestServices.GetService(typeof(IThemeProvider));

            context.Values[ThemeKey] = themeContext.GetWorkingThemeDirPath(context.ActionContext.HttpContext.Request.Host.Host, context.ActionContext.HttpContext.Request.IsMobileDevice());
        }
 public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
                                                IEnumerable<string> viewLocations)
 {
     throw new NotImplementedException();
 }
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     // The old locations are /Views/{1}/{0}.cshtml and /Views/Shared/{0}.cshtml where {1} is the controller and {0} is the name of the View
     // Replace /Views with /Features
     return(new string[] { "/Features/{1}/{0}.cshtml", "/Features/Shared/{0}.cshtml" });
 }
Ejemplo n.º 4
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     // do nothing - not required
 }
Ejemplo n.º 6
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     //nothing to do here.
 }
Ejemplo n.º 7
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations) =>
 new List <string>
 {
     "/Infrastructure/Email/Views/{0}.cshtml"
 };
Ejemplo n.º 8
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     // do nothing.. not entirely needed for this
 }
Ejemplo n.º 9
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     context.Values["QuartzViewLocations"] = nameof(HybridQuartzViewLocationExpander);
 }
Ejemplo n.º 10
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     this._service = context.ActionContext.HttpContext.RequestServices.GetService <ITenantService>();
     this._tenant  = this._service.GetCurrentTenant();
 }
Ejemplo n.º 11
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context,
                                                 IEnumerable <string> viewLocations)
 {
     return(viewLocations.MoveViewsIntoFeaturesFolder().CutomizeSharedWithUnderScore());
 }
Ejemplo n.º 12
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     context.Values["customviewlocation"] = nameof(ViewLocationExpander);
 }
Ejemplo n.º 13
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     return(_directoryLocations.Union(viewLocations));
 }
        /// <inheritdoc />
        public virtual IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context,
                                                                IEnumerable <string> viewLocations)
        {
            if (!context.Values.ContainsKey("Theme"))
            {
                return(viewLocations);
            }

            var currentThemeId = context.Values["Theme"];

            var currentThemeAndBaseThemesOrdered = _extensionManager
                                                   .GetFeatures(new[] { currentThemeId })
                                                   .Where(x => x.Extension.IsTheme())
                                                   .Reverse();

            if (context.ActionContext.ActionDescriptor is PageActionDescriptor page)
            {
                var pageViewLocations = PageViewLocations().ToList();
                pageViewLocations.AddRange(viewLocations);
                return(pageViewLocations);

                IEnumerable <string> PageViewLocations()
                {
                    if (page.RelativePath.Contains("/Pages/") && !page.RelativePath.StartsWith("/Pages/"))
                    {
                        var pageIndex    = page.RelativePath.LastIndexOf("/Pages/");
                        var moduleFolder = page.RelativePath.Substring(0, pageIndex);
                        var moduleId     = moduleFolder.Substring(moduleFolder.LastIndexOf("/") + 1);

                        foreach (var theme in currentThemeAndBaseThemesOrdered)
                        {
                            if (moduleId != theme.Id)
                            {
                                var themeViewsPath     = '/' + theme.Extension.SubPath + "/Views";
                                var themeViewsAreaPath = themeViewsPath + '/' + context.AreaName;
                                yield return(themeViewsAreaPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);

                                yield return(themeViewsPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);
                            }
                        }
                    }
                }
            }

            var result = new List <string>();

            if (!String.IsNullOrEmpty(context.AreaName))
            {
                foreach (var theme in currentThemeAndBaseThemesOrdered)
                {
                    if (context.AreaName != theme.Id)
                    {
                        var themeViewsPath     = '/' + theme.Extension.SubPath + "/Views";
                        var themeViewsAreaPath = themeViewsPath + '/' + context.AreaName;
                        result.Add(themeViewsAreaPath + "/{1}/{0}" + RazorViewEngine.ViewExtension);
                        result.Add(themeViewsAreaPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);
                        result.Add(themeViewsPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);
                    }
                }
            }

            result.AddRange(viewLocations);
            return(result);
        }
Ejemplo n.º 15
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 16
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     // Don't need anything here, but required by the interface
 }
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     return(viewLocations);
 }
Ejemplo n.º 18
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     context.Values["theme"] = context.ActionContext.HttpContext.Request.Headers["BUSINESS-ID"].ToString();
 }
Ejemplo n.º 19
0
        /// <inheritdoc />
        public virtual IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context,
                                                                IEnumerable <string> viewLocations)
        {
            if (!context.Values.ContainsKey("Theme"))
            {
                return(viewLocations);
            }

            var currentThemeId = context.Values["Theme"];

            var currentThemeAndBaseThemesOrdered = _extensionManager
                                                   .GetFeatures(new[] { currentThemeId })
                                                   .Where(x => x.Extension.IsTheme())
                                                   .Reverse()
                                                   .ToList();

            // let the application acting as a super theme also for mvc views discovering.
            var applicationTheme = _extensionManager
                                   .GetFeatures()
                                   .FirstOrDefault(x => x.Id == _hostingEnvironment.ApplicationName);

            if (applicationTheme != null)
            {
                currentThemeAndBaseThemesOrdered.Insert(0, applicationTheme);
            }

            var result = new List <string>();

            foreach (var theme in currentThemeAndBaseThemesOrdered)
            {
                if (context.AreaName != theme.Id)
                {
                    var themePagesPath = '/' + theme.Extension.SubPath + "/Pages";
                    var themeViewsPath = '/' + theme.Extension.SubPath + "/Views";

                    if (context.AreaName != null)
                    {
                        if (context.PageName != null)
                        {
                            result.Add(themePagesPath + "/{2}/{0}" + RazorViewEngine.ViewExtension);
                        }
                        else
                        {
                            result.Add(themeViewsPath + "/{2}/{1}/{0}" + RazorViewEngine.ViewExtension);
                        }
                    }

                    if (context.PageName != null)
                    {
                        result.Add(themePagesPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);
                    }

                    if (context.AreaName != null)
                    {
                        result.Add(themeViewsPath + "/{2}/Shared/{0}" + RazorViewEngine.ViewExtension);
                    }

                    result.Add(themeViewsPath + "/Shared/{0}" + RazorViewEngine.ViewExtension);
                }
            }

            result.AddRange(viewLocations);
            return(result);
        }
Ejemplo n.º 20
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     return(viewLocations.Select(f => f.Replace("/Views/", $"/Views/{context.Values["theme"]}/"))
            .Append("/Views/Shared/{0}.cshtml")
            .Append("/Views/Shared/{1}/{0}.cshtml"));
 }
Ejemplo n.º 21
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     return(viewLocations.Select(s => s.Replace("/Views/Shared", _theme)));
 }
 /// <inheritdoc/>
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     // The value we care about - 'page' is already part of the system. We don't need to add it manually.
 }
Ejemplo n.º 23
0
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     context.Values[THEME_KEY] = context.ActionContext.HttpContext.RequestServices.GetRequiredService <IOptions <AppSettings> >().Value.ThemeOptions.ThemeName;
 }
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     return(new[] { "/Features/{1}/{0}.cshtml",
                    "/Features/Shared/{0}.cshtml" });
 }
Ejemplo n.º 25
0
 public void PopulateValues(
     ViewLocationExpanderContext context)
 {
 }
Ejemplo n.º 26
0
 public IEnumerable <string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable <string> viewLocations)
 {
     //extend current view locations
     return(viewLocations.Concat(ExtendedLocations));
 }
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     throw new NotImplementedException();
 }
 public void PopulateValues(ViewLocationExpanderContext context)
 {
     // Empty by design
 }