Use 'new' expression in places where the type is evident for the engine (#1415)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
DrSmugleaf
2020-11-26 00:16:55 +01:00
committed by GitHub
parent e82a83223f
commit b8e5b47e7a
242 changed files with 1171 additions and 1174 deletions

View File

@@ -18,18 +18,18 @@ namespace Robust.Shared.IoC
/// <summary>
/// Dictionary that maps the types passed to <see cref="Resolve{T}"/> to their implementation.
/// </summary>
private readonly Dictionary<Type, object> _services = new Dictionary<Type, object>();
private readonly Dictionary<Type, object> _services = new();
/// <summary>
/// The types interface types mapping to their registered implementations.
/// This is pulled from to make a service if it doesn't exist yet.
/// </summary>
private readonly Dictionary<Type, Type> _resolveTypes = new Dictionary<Type, Type>();
private readonly Dictionary<Type, Type> _resolveTypes = new();
// To do injection of common types like components, we make DynamicMethods to do the actual injecting.
// This is way faster than reflection and should be allocation free outside setup.
private readonly Dictionary<Type, (InjectorDelegate? @delegate, object[]? services)> _injectorCache =
new Dictionary<Type, (InjectorDelegate? @delegate, object[]? services)>();
new();
/// <inheritdoc />
public void Register<TInterface, TImplementation>(bool overwrite = false)

View File

@@ -38,7 +38,7 @@ namespace Robust.Shared.IoC
public static class IoCManager
{
private const string NoContextAssert = "IoC has no context on this thread. Are you calling IoC from the wrong thread or did you forget to initialize it?";
private static readonly ThreadLocal<IDependencyCollection> _container = new ThreadLocal<IDependencyCollection>();
private static readonly ThreadLocal<IDependencyCollection> _container = new();
/// <summary>
/// Returns the singleton thread-local instance of the IoCManager's dependency collection.