Reputation: 1795
In asp.net mvc 2 I need to get programatically all the views thar are strongly typed, and show a list for views that are not strongly typed.
How can I do that?
Thanks In Advance.
Upvotes: 0
Views: 66
Reputation: 11661
Strongly-typed views inherit from System.Web.Mvc.ViewPage. Untyped views inherit from System.Web.Mvc.ViewPage. N.B. ViewPage inherits from ViewPage. You would have to load up the compiled assembly containing the views (generated via aspnet_compiler.exe) and then run the following LINQ-to-Objects queries:
var stronglyTypedViews = from type in assemblyContainingViews.GetTypes()
where typeof(ViewPage<>).IsAssignableFrom(type)
select type;
var weaklyTypedViews = from type in assemblyContainingViews.GetTypes()
where typeof(ViewPage).IsAssignableFrom(type)
&& !typeof(ViewPage<>).IsAssignableFrom(type)
select type;
Upvotes: 1