Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public void Add(Type type, object instance, bool includeInManifest)
 {
     _entries[type] = new ServiceEntry
     {
         Instance = instance,
         IncludeInManifest = includeInManifest
     };
 }
 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);
         }
     }
 }
 public ClosedIEnumerableService(Type itemType, ServiceEntry entry)
 {
     _itemType = itemType;
     _serviceEntry = entry;
 }
Exemplo n.º 5
0
 public ClosedIEnumerableService(Type itemType, ServiceEntry entry)
 {
     _itemType     = itemType;
     _serviceEntry = entry;
 }