protected override object GetInstance(Type serviceType, string key) { if (string.IsNullOrWhiteSpace(key)) { if (container.IsRegistered(serviceType)) { return(container.Resolve(serviceType)); } } else if (container.IsRegisteredWithKey(key, serviceType)) { return(container.ResolveKeyed(key, serviceType)); } throw new Exception($"Could not locate any instances of contract {key ?? serviceType.Name}."); }
protected override object GetInstance(Type service, string key) { if (string.IsNullOrWhiteSpace(key)) { if (_container.IsRegistered(service)) { return(_container.Resolve(service)); } } else { if (_container.IsRegisteredWithKey(key, service)) { return(_container.ResolveKeyed(key, service)); } } var msgFormat = "Could not locate any instances of contract {0}."; var msg = string.Format(msgFormat, key ?? service.Name); throw new Exception(msg); }
public TComponent Resolve <TComponent>(string key) { return(container.ResolveKeyed <TComponent>(key)); }