public bool TryGetEntry(Type serviceType, out ServiceEntry entry)
        {
            lock (_sync)
            {
                if (_services.TryGetValue(serviceType, out entry))
                {
                    return true;
                }
                else if (serviceType.GetTypeInfo().IsGenericType)
                {
                    var openServiceType = serviceType.GetGenericTypeDefinition();

                    List<IGenericService> genericEntry;
                    if (_genericServices.TryGetValue(openServiceType, out genericEntry))
                    {
                        foreach (var genericService in genericEntry)
                        {
                            var closedService = genericService.GetService(serviceType);
                            if (closedService != null)
                            {
                                Add(serviceType, closedService);
                            }
                        }

                        return _services.TryGetValue(serviceType, out entry);
                    }
                }
            }
            return false;
        }
 public ClosedIEnumerableService(Type itemType, ServiceEntry entry)
 {
     _itemType = itemType;
     _serviceEntry = entry;
 }
Exemplo n.º 3
0
 public ClosedIEnumerableService(Type itemType, ServiceEntry entry)
 {
     ServiceType        = itemType;
     _serviceEntry      = entry;
     ImplementationType = itemType.MakeArrayType();
 }
Exemplo n.º 4
0
 public ClosedIEnumerableService(Type itemType, ServiceEntry entry)
 {
     _itemType     = itemType;
     _serviceEntry = entry;
 }
 public void Add(Type serviceType, IService service)
 {
     lock (_sync)
     {
         ServiceEntry entry;
         if (_services.TryGetValue(serviceType, out entry))
         {
             entry.Add(service);
         }
         else
         {
             _services[serviceType] = new ServiceEntry(service);
         }
     }
 }