private void AddDefinition <T>(Func <DependencyGetter, object> factory, string name, bool isSingleton) { var definition = new DependencyDefinition(factory, isSingleton); var key = new DependencyKey(name, typeof(T)); definitions[key] = definition; }
public T Get <T>(string name = "", Parameters parameters = default) { var key = new DependencyKey(name, typeof(T)); var getter = new DependencyGetter(this, parameters ?? Parameters.Empty); try { return((T)definitions[key].GetValue(getter)); } catch (KeyNotFoundException) { throw new MissingDependencyException(key); } }
internal MissingDependencyException(DependencyKey key) : base($"Missing dependency of {key}") { }