public object GetService(Type type) { try { ServiceEntry se; if (services.TryGetValue(type, out se)) { return(se.Service); } else { throw new KeyNotFoundException(); } } catch (KeyNotFoundException) { throw new ApplicationException("The requested service is not registered"); } }
private object GetServiceInternal(Type abstraction, Type requester, object requesterObject) { object result = null; var requesterType = requesterObject == null ? requester : requesterObject.GetType(); if (requesterType != null) { ISafeDictionary <Type, LifeTimeManager> resolvers; if (services.TryGetValue(abstraction, out resolvers)) { LifeTimeManager entry; if (resolvers.TryGetValue(requesterType, out entry)) { result = entry.GetInstance(); } } } return(result); }