Skip to content

Instantly share code, notes, and snippets.

@rohits79
Created June 7, 2016 09:25
Show Gist options
  • Select an option

  • Save rohits79/a55bd1123185bfbae31e9d70a0460360 to your computer and use it in GitHub Desktop.

Select an option

Save rohits79/a55bd1123185bfbae31e9d70a0460360 to your computer and use it in GitHub Desktop.
static Func<Type, Type> _defaultViewTypeToViewModelTypeResolver =
viewType =>
{
var viewName = viewType.FullName;
viewName = viewName.Replace(".Views.", ".ViewModels.");
var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
var suffix = viewName.EndsWith("View") ? "Model" : "ViewModel";
var viewModelName = String.Format(CultureInfo.InvariantCulture, "{0}{1}, {2}", viewName, suffix, viewAssemblyName);
return Type.GetType(viewModelName);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment