Restrict DependencyMap#Get to reference types
It's impossible to add non-reference types to the map, so why allow pulling them out of it.
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Discord.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public T Get<T>()
|
public T Get<T>() where T : class
|
||||||
{
|
{
|
||||||
return (T)Get(typeof(T));
|
return (T)Get(typeof(T));
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace Discord.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool TryGet<T>(out T result)
|
public bool TryGet<T>(out T result) where T : class
|
||||||
{
|
{
|
||||||
object untypedResult;
|
object untypedResult;
|
||||||
if (TryGet(typeof(T), out untypedResult))
|
if (TryGet(typeof(T), out untypedResult))
|
||||||
|
|||||||
@@ -63,14 +63,14 @@ namespace Discord.Commands
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of service.</typeparam>
|
/// <typeparam name="T">The type of service.</typeparam>
|
||||||
/// <returns>An instance of this service.</returns>
|
/// <returns>An instance of this service.</returns>
|
||||||
T Get<T>();
|
T Get<T>() where T : class;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to pull an object from the map.
|
/// Try to pull an object from the map.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of service.</typeparam>
|
/// <typeparam name="T">The type of service.</typeparam>
|
||||||
/// <param name="result">The instance of this service.</param>
|
/// <param name="result">The instance of this service.</param>
|
||||||
/// <returns>Whether or not this object could be found in the map.</returns>
|
/// <returns>Whether or not this object could be found in the map.</returns>
|
||||||
bool TryGet<T>(out T result);
|
bool TryGet<T>(out T result) where T : class;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pull an object from the map.
|
/// Pull an object from the map.
|
||||||
|
|||||||
Reference in New Issue
Block a user