Created
May 10, 2016 07:33
-
-
Save cwe1ss/d44f22a4522b74d9c54303d3e417887b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeatureFolderViewLocationExpander : IViewLocationExpander | |
{ | |
public void PopulateValues(ViewLocationExpanderContext context) | |
{ | |
/* no-op */ | |
} | |
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) | |
{ | |
// {0} - Action Name | |
// {1} - Controller Name | |
// {2} - Area name | |
object area; | |
if (context.ActionContext.RouteData.Values.TryGetValue("area", out area)) | |
{ | |
yield return "/Areas/{2}/{1}/{0}.cshtml"; | |
yield return "/Areas/{2}/Shared/{0}.cshtml"; | |
yield return "/Areas/Shared/{0}.cshtml"; | |
} | |
else | |
{ | |
yield return "/Features/{1}/{0}.cshtml"; | |
yield return "/Features/Shared/{0}.cshtml"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment