Register<T> extension for IDependencyCollection.

This commit is contained in:
Pieter-Jan Briers
2022-11-12 12:12:05 +01:00
parent 2f22de4eff
commit 2fe0c94d84
2 changed files with 21 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ Template for new versions:
* `IClyde.TextInputStart()`, `IClyde.TextInputStop()`, `IClyde.TextInputSetRect()` APIs to control text input behavior.
* `TextEditing` events for reporting in-progress IME compositions.
* `LineEdit` and `TextEdit` have functional IME support when the game is running on SDL2. If you provide a font file with the relevant glyphs, CJK text input should now be usable.
* `Register<T>` (single type parameter) extension method for `IDependencyCollection`.
### Bugfixes

View File

@@ -0,0 +1,20 @@
using JetBrains.Annotations;
namespace Robust.Shared.IoC;
/// <summary>
/// Extension methods for <see cref="IDependencyCollection"/>.
/// </summary>
public static class DependencyCollectionExt
{
/// <summary>
/// Register a type as both implementation and interface.
/// This is equivalent to calling <see cref="IDependencyCollection.Register{TInterface, TImplementation}(bool)"/> with both type args set to <typeparamref name="T"/>.
/// </summary>
/// <param name="deps">The dependency collection to register into.</param>
public static void Register<[MeansImplicitUse] T>(this IDependencyCollection deps)
where T : class
{
deps.Register<T, T>();
}
}