Skip to content

Commit

Permalink
feat(DependencyInjector): add non-generic Provide method
Browse files Browse the repository at this point in the history
  • Loading branch information
jonisavo committed Jun 24, 2022
1 parent 0e8278f commit 891b4cd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Assets/UIComponents/Core/DependencyInjection/DependencyInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ public DependencyInjector(IEnumerable<DependencyAttribute> dependencyAttributes)
return (T) DependencyDictionary[type];
}

/// <summary>
/// Returns a dependency. Throws a <see cref="MissingProviderException"/>
/// if the dependency can not be provided.
/// </summary>
/// <param name="type">Dependency type</param>
/// <returns>Dependency instance</returns>
/// <exception cref="MissingProviderException">
/// Thrown if the dependency can not be provided
/// </exception>
[NotNull]
public object Provide(Type type)
{
if (!DependencyDictionary.ContainsKey(type))
throw new MissingProviderException(type);

return DependencyDictionary[type];
}

/// <summary>
/// Attempts to fetch a dependency. Returns whether
/// the dependency could be fetched.
Expand Down

0 comments on commit 891b4cd

Please sign in to comment.