Exemple #1
0
            private T Find <T>(Func <ServiceManager.InterfaceHolder, bool> comparer, Func <ServiceManager.InterfaceHolder> creator, Func <ServiceManager.FindServiceResult, T> func)
            {
                T result;

                using (DictionaryLocker <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> dictionaryLocker = CreateLocker())
                {
                    foreach (KeyValuePair <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> current in dictionaryLocker)
                    {
                        if (comparer(current.Key) && func != null)
                        {
                            result = func(new ServiceManager.FindServiceResult(base.Container, current.Key));
                            return(result);
                        }
                    }
                    if (creator != null)
                    {
                        AssertUtility.ArgumentNotNull(creator, "creator");
                        ServiceManager.InterfaceHolder key = creator();
                        dictionaryLocker[key] = new ServiceManager.ServiceInstancesHolder();
                        if (func != null)
                        {
                            result = func(new ServiceManager.FindServiceResult(base.Container, key));
                            return(result);
                        }
                    }
                    result = default(T);
                }
                return(result);
            }
Exemple #2
0
 public List <object> GetService(Type serviceType)
 {
     ServiceManager.ServiceInstancesHolder orCreateInstanceCollection = GetOrCreateInstanceCollection(serviceType);
     if (orCreateInstanceCollection == null)
     {
         return(new List <object>());
     }
     return(new List <object>(orCreateInstanceCollection.GetServiceInstances()));
 }
Exemple #3
0
 public FindServiceResult(Dictionary <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> container, ServiceManager.InterfaceHolder key)
 {
     Container = container;
     Key       = key;
     Value     = container[key];
 }