public static bool TryResolve <T>(this ResolveContext ctx, out T instance) { instance = default; var success = ctx.TryResolve(typeof(T), out var untyped); if (success) { instance = (T)untyped; } return(success); }
public static ProfileResolver Find( Type serviceType) { bool tryResolveDelayed(IDependencyRegistrationCollection registrations, ResolveContext context, out object instance) { var newContext = new ResolveContext(() => registrations); return(newContext.TryResolve(serviceType, out instance)); } return(tryResolveDelayed); }
public bool TryResolve(ResolveContext ctx, Type serviceType, out object instance) { return(ctx.TryResolve(LastRegistrationForService(serviceType), out instance)); }
public static object Resolve(this ResolveContext context, Type serviceType) { return(context.TryResolve(serviceType, out var instance) ? instance : throw new DependencyResolutionException($"Could not find a resolve profile for {serviceType}")); }
public static object Resolve(this ResolveContext ctx, DependencyRegistration registration) { return(ctx.TryResolve(registration, out var instance) ? instance : throw new InvalidOperationException("Recursive dependencies are not allowed.")); }
public bool TryResolve(ResolveContext ctx, Type serviceType, out object instance) { return(_registrations.TryGetValue(serviceType, out var bag) ? ctx.TryResolve(bag.Last, out instance) : _globalRegistrations.TryResolve(ctx, serviceType, out instance)); }