Beispiel #1
0
        public T Get <T>(Identifier id)
        {
            var type = typeof(T);

            object instance = null;

            if (classFactories.ContainsKey(type) && classFactories[type].ContainsKey(id))
            {
                instance = classFactories[type][id]();
            }
            else if (services.ContainsKey(type) && services[type].ContainsKey(id))
            {
                instance = services[type][id];
            }

            if (instance == null)
            {
                throw new NullReferenceException($"No class of type '{type.GetFriendlyName()}' with id '{id}' found");
            }

            return((T)instance);
        }