private (object Service, bool?Save) ResolveService(KeyedServiceInfo info, IServiceProvider provider, object args, bool required) { if (_service != null) { return(_service, false); } (Type KeyedType, Type Type, Func <IServiceProvider, object> Factory)typeInfo; if (!info.Types.TryGetValue(args, out typeInfo)) { if (!required) { return(default);
public object GetService(KeyedServiceInfo info, IServiceProvider provider, object args, bool required) { var result = ResolveService(info, provider, args, required); if (result.Service == null) { throw new Exception("Can not resolve service"); } if (result.Save == true) { _service = result.Service; } return(result.Service); }