Example #1
0
        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;
        }
Example #2
0
        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);
            }
        }
Example #3
0
 internal MissingDependencyException(DependencyKey key) : base($"Missing dependency of {key}")
 {
 }