Ejemplo n.º 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);
            }
Ejemplo n.º 2
0
 public FindServiceResult(Dictionary <ServiceManager.InterfaceHolder, ServiceManager.ServiceInstancesHolder> container, ServiceManager.InterfaceHolder key)
 {
     Container = container;
     Key       = key;
     Value     = container[key];
 }