Caching of the registered types in unity
コード例 #1
0
 /// <summary>
 /// Resolve multiple types
 /// </summary>
 public IEnumerable <object> GetServices(Type serviceType)
 {
     if (UnityRegistrationCache.IsRegistered(container, serviceType))
     {
         return(container.ResolveAll(serviceType));
     }
     return(new List <object>());
 }
コード例 #2
0
 /// <summary>
 /// Resolve a type
 /// </summary>
 public object GetService(Type serviceType)
 {
     if (!UnityRegistrationCache.IsRegistered(container, serviceType))
     {
         if (serviceType.IsAbstract || serviceType.IsInterface)
         {
             return(null);
         }
     }
     return(container.Resolve(serviceType));
 }