Beispiel #1
0
        public object GetInstance(Type serviceType)
        {
            assertNotDisposed();
            var resolver = ServiceGraph.FindResolver(serviceType);

            if (resolver == null)
            {
                throw new LamarMissingRegistrationException(serviceType);
            }

            return(resolver(this));
        }
Beispiel #2
0
        public object GetInstance(Type serviceType)
        {
            assertNotDisposed();
            var resolver = ServiceGraph.FindResolver(serviceType);

            if (resolver == null)
            {
                if (ServiceGraph.Families.TryGetValue(serviceType, out var family))
                {
                    if (family.CannotBeResolvedMessage.IsNotEmpty())
                    {
                        throw new LamarMissingRegistrationException(family);
                    }
                }

                throw new LamarMissingRegistrationException(serviceType);
            }

            return(resolver(this));
        }
Beispiel #3
0
 public object TryGetInstance(Type serviceType)
 {
     assertNotDisposed();
     return(ServiceGraph.FindResolver(serviceType)?.Invoke(this));
 }