private static ViewLoader RegisterViewModelsAndTypes() { ViewLoader viewLoader = new ViewLoader(); Assembly assembly = Assembly.GetExecutingAssembly(); List <Type> types = new List <Type>(assembly.GetTypes()); Attribute[] attributes; foreach (Type type in types) { attributes = Attribute.GetCustomAttributes(type); foreach (ViewModelAttribute attribute in attributes.Where(attr => attr is ViewModelAttribute)) { viewLoader.Register(attribute.ViewModelType, type); } } return(viewLoader); }