#20: add method to check if type is installed

pull/32/head
Simon Gockner 6 years ago
parent 6ce2878817
commit d91392e382
  1. 7
      LightweightIocContainer/Interfaces/IIocContainer.cs
  2. 7
      LightweightIocContainer/IocContainer.cs
  3. 14
      LightweightIocContainer/LightweightIocContainer.xml
  4. 9
      Test.LightweightIocContainer/IocContainerTest.cs

@ -57,5 +57,12 @@ namespace LightweightIocContainer.Interfaces
/// </summary>
/// <typeparam name="T">The <see cref="Type"/> to clear the multiton instances</typeparam>
void ClearMultitonInstances<T>();
/// <summary>
/// Is the given <see cref="Type"/> registered with this <see cref="IIocContainer"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>True if the given <see cref="Type"/> is registered with this <see cref="IIocContainer"/>, false if not</returns>
bool IsTypeRegistered<T>();
}
}

@ -284,6 +284,13 @@ namespace LightweightIocContainer
_multitons.Remove(multitonInstance);
}
/// <summary>
/// Is the given <see cref="Type"/> registered with this <see cref="IocContainer"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>True if the given <see cref="Type"/> is registered with this <see cref="IocContainer"/>, false if not</returns>
public bool IsTypeRegistered<T>() => _registrations.Any(registration => registration.InterfaceType == typeof(T));
/// <summary>
/// The <see cref="IDisposable.Dispose"/> method
/// </summary>

@ -254,6 +254,13 @@
</summary>
<typeparam name="T">The <see cref="T:System.Type"/> to clear the multiton instances</typeparam>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.IsTypeRegistered``1">
<summary>
Is the given <see cref="T:System.Type"/> registered with this <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<returns>True if the given <see cref="T:System.Type"/> is registered with this <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/>, false if not</returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Installers.IAssemblyInstaller">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> that installs all <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/>s for its given <see cref="T:System.Reflection.Assembly"/>
@ -437,6 +444,13 @@
</summary>
<typeparam name="T">The <see cref="T:System.Type"/> to clear the multiton instances</typeparam>
</member>
<member name="M:LightweightIocContainer.IocContainer.IsTypeRegistered``1">
<summary>
Is the given <see cref="T:System.Type"/> registered with this <see cref="T:LightweightIocContainer.IocContainer"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<returns>True if the given <see cref="T:System.Type"/> is registered with this <see cref="T:LightweightIocContainer.IocContainer"/>, false if not</returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Dispose">
<summary>
The <see cref="M:System.IDisposable.Dispose"/> method

@ -355,5 +355,14 @@ namespace Test.LightweightIocContainer
Assert.AreNotSame(resolvedTest2, resolvedTest4);
Assert.AreNotSame(resolvedTest3, resolvedTest5);
}
[Test]
public void TestIsTypeRegistered()
{
Assert.False(_iocContainer.IsTypeRegistered<ITest>());
_iocContainer.Register(RegistrationFactory.Register<ITest, Test>());
Assert.True(_iocContainer.IsTypeRegistered<ITest>());
}
}
}
Loading…
Cancel
Save