diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 107022ba5..f2dd7f294 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -25,7 +25,7 @@ - + diff --git a/src/Splat.Prism/SplatContainerExtension.cs b/src/Splat.Prism/SplatContainerExtension.cs index d91db1041..a4ba65b9a 100644 --- a/src/Splat.Prism/SplatContainerExtension.cs +++ b/src/Splat.Prism/SplatContainerExtension.cs @@ -44,11 +44,6 @@ public void Dispose() GC.SuppressFinalize(this); } - /// - public void FinalizeExtension() - { - } - /// public IContainerRegistry RegisterScoped(Type type, Func factoryMethod) => throw new NotSupportedException(); @@ -208,28 +203,28 @@ public IContainerRegistry RegisterSingleton(Type from, Type to, string name) public IContainerRegistry RegisterSingleton(Type type, Func factoryMethod) => throw new NotSupportedException(); /// - public object? Resolve(Type type) => Instance.GetService(type); + public object Resolve(Type type) => Instance.GetService(type) ?? throw new InvalidOperationException("Must be a valid value"); /// [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:Tuple element names should use correct casing", Justification = "Defined by outside interface not in Splat")] - public object? Resolve(Type type, params (Type Type, object Instance)[] parameters) => - _types.TryGetValue((type, null), out var resolvedType) + public object Resolve(Type type, params (Type Type, object Instance)[] parameters) => + (_types.TryGetValue((type, null), out var resolvedType) ? Activator.CreateInstance(resolvedType, parameters.Select(x => x.Instance)) ?? throw new InvalidOperationException("Could not create type") - : default; + : default) ?? throw new InvalidOperationException("Must be a valid value"); /// - public object? Resolve(Type type, string name) => Instance.GetService(type, name); + public object Resolve(Type type, string name) => Instance.GetService(type, name) ?? throw new InvalidOperationException("Must be a valid value"); /// [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:Tuple element names should use correct casing", Justification = "Defined by outside interface not in Splat")] - public object? Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) => - !_types.TryGetValue((type, name), out var resolvedType) + public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters) => + (!_types.TryGetValue((type, name), out var resolvedType) ? resolvedType switch { null => default, _ => Activator.CreateInstance(resolvedType, parameters.Select(x => x.Instance)) } - : default; + : default) ?? throw new InvalidOperationException("Must be a valid value"); /// /// Disposes data associated with the extension.