예제 #1
0
 /// <summary>
 /// Loads View Model Types from an Assembly. Use minimally due to reflection overhead.
 /// </summary>
 /// <param name="assembly"></param>
 public void LoadViewModels(params Assembly[] assemblies) //We assume we have a singleton of this instance, otherwise we incur a lot of overhead
 {
     foreach (var assembly in assemblies)
     {
         if (!loadedAssemblies.Contains(assembly))
         {
             //Josh Einhorn - Performance Question: Should we incur the memory overhead of storing Assembly objects in the heap or allow same assembly to get processed multiple times?
             loadedAssemblies.Add(assembly);
             IModelAttribute viewModelAttr;
             foreach (var type in assembly.GetTypes())
             {
                 viewModelAttr = resolver.GetCustomAttribute <IModelAttribute>(type);
                 if (viewModelAttr != null && !viewModels.ContainsKey(viewModelAttr))
                 {
                     viewModels.Add(viewModelAttr, type);
                 }
             }
         }
     }
 }