diff --git a/Assets/UIComponents/Core/DependencyInjection/DependencyInjector.cs b/Assets/UIComponents/Core/DependencyInjection/DependencyInjector.cs index 6842cec6..d8589721 100644 --- a/Assets/UIComponents/Core/DependencyInjection/DependencyInjector.cs +++ b/Assets/UIComponents/Core/DependencyInjection/DependencyInjector.cs @@ -239,6 +239,24 @@ public DependencyInjector(IEnumerable dependencyAttributes) return (T) DependencyDictionary[type]; } + /// + /// Returns a dependency. Throws a + /// if the dependency can not be provided. + /// + /// Dependency type + /// Dependency instance + /// + /// Thrown if the dependency can not be provided + /// + [NotNull] + public object Provide(Type type) + { + if (!DependencyDictionary.ContainsKey(type)) + throw new MissingProviderException(type); + + return DependencyDictionary[type]; + } + /// /// Attempts to fetch a dependency. Returns whether /// the dependency could be fetched.