Class SplatContainerExtension
Provides an implementation of the Prism container extension using the Splat dependency resolver. Enables registration and resolution of services and types for dependency injection within Prism applications.
public class SplatContainerExtension : IContainerExtension<IDependencyResolver>, IContainerExtension, IContainerProvider, IContainerRegistry, IDisposable
- Inheritance
-
SplatContainerExtension
- Implements
- Extension Methods
Remarks
This extension integrates the Splat dependency resolver with the Prism container abstraction, allowing Prism-based applications to use Splat for service registration and resolution. Most scoped and advanced registration features are not supported and will throw exceptions if used. The container is primarily intended for simple singleton and transient registrations. Thread safety is provided for registration mappings. Disposing the extension resets the global Splat locator to its default state.
Constructors
SplatContainerExtension()
Initializes a new instance of the SplatContainerExtension class.
public SplatContainerExtension()
Properties
CurrentScope
public IScopedProvider CurrentScope { get; }
Property Value
Instance
Gets the dependency resolver.
public IDependencyResolver Instance { get; }
Property Value
Methods
CreateScope()
public IScopedProvider CreateScope()
Returns
Dispose()
public void Dispose()
Dispose(bool)
Disposes data associated with the extension.
protected virtual void Dispose(bool isDisposing)
Parameters
isDisposingboolIf we are getting called by the Dispose() method rather than a finalizer.
IsRegistered(Type)
public bool IsRegistered(Type type)
Parameters
typeType
Returns
IsRegistered(Type, string)
public bool IsRegistered(Type type, string name)
Parameters
Returns
Register(Type, Func<IContainerProvider, object>)
public IContainerRegistry Register(Type type, Func<IContainerProvider, object> factoryMethod)
Parameters
typeTypefactoryMethodFunc<IContainerProvider, object>
Returns
Register(Type, Func<object>)
public IContainerRegistry Register(Type type, Func<object> factoryMethod)
Parameters
Returns
Register(Type, Type)
public IContainerRegistry Register(Type from, Type to)
Parameters
Returns
Register(Type, Type, Func<object>)
Registers an object with the default registration func.
public IContainerRegistry Register(Type from, Type to, Func<object> defaultCreationFunc)
Parameters
fromTypeThe type to transform from.
toTypeThe type to transform to.
defaultCreationFuncFunc<object>A creation func for generating the type.
Returns
- IContainerRegistry
The container registry for builder operations.
Register(Type, Type, string)
public IContainerRegistry Register(Type from, Type to, string name)
Parameters
Returns
Register(Type, Type, string, Func<object>)
Registers an object with the default registration func.
public IContainerRegistry Register(Type from, Type to, string name, Func<object> defaultCreationFunc)
Parameters
fromTypeThe type to transform from.
toTypeThe type to transform to.
namestringThe contract name.
defaultCreationFuncFunc<object>A creation func for generating the type.
Returns
- IContainerRegistry
The container registry for builder operations.
RegisterInstance(Type, object)
public IContainerRegistry RegisterInstance(Type type, object instance)
Parameters
Returns
RegisterInstance(Type, object, string)
public IContainerRegistry RegisterInstance(Type type, object instance, string name)
Parameters
Returns
RegisterMany(Type, params Type[])
public IContainerRegistry RegisterMany(Type type, params Type[] serviceTypes)
Parameters
Returns
RegisterManySingleton(Type, params Type[])
public IContainerRegistry RegisterManySingleton(Type type, params Type[] serviceTypes)
Parameters
Returns
RegisterScoped(Type, Func<IContainerProvider, object>)
public IContainerRegistry RegisterScoped(Type type, Func<IContainerProvider, object> factoryMethod)
Parameters
typeTypefactoryMethodFunc<IContainerProvider, object>
Returns
RegisterScoped(Type, Func<object>)
public IContainerRegistry RegisterScoped(Type type, Func<object> factoryMethod)
Parameters
Returns
RegisterScoped(Type, Type)
public IContainerRegistry RegisterScoped(Type from, Type to)
Parameters
Returns
RegisterSingleton(Type, Func<IContainerProvider, object>)
public IContainerRegistry RegisterSingleton(Type type, Func<IContainerProvider, object> factoryMethod)
Parameters
typeTypefactoryMethodFunc<IContainerProvider, object>
Returns
RegisterSingleton(Type, Func<object>)
public IContainerRegistry RegisterSingleton(Type type, Func<object> factoryMethod)
Parameters
Returns
RegisterSingleton(Type, Type)
public IContainerRegistry RegisterSingleton(Type from, Type to)
Parameters
Returns
RegisterSingleton(Type, Type, Func<object>)
Registers an object with the default registration func.
public IContainerRegistry RegisterSingleton(Type from, Type to, Func<object> defaultCreationFunc)
Parameters
fromTypeThe type to transform from.
toTypeThe type to transform to.
defaultCreationFuncFunc<object>A creation func for generating the type.
Returns
- IContainerRegistry
The container registry for builder operations.
RegisterSingleton(Type, Type, string)
public IContainerRegistry RegisterSingleton(Type from, Type to, string name)
Parameters
Returns
RegisterSingleton(Type, Type, string, Func<object>)
Registers an object with the default registration func.
public IContainerRegistry RegisterSingleton(Type from, Type to, string name, Func<object> defaultCreationFunc)
Parameters
fromTypeThe type to transform from.
toTypeThe type to transform to.
namestringThe contract name.
defaultCreationFuncFunc<object>A creation func for generating the type.
Returns
- IContainerRegistry
The container registry for builder operations.
Resolve(Type)
public object Resolve(Type type)
Parameters
typeType
Returns
Resolve(Type, string)
public object Resolve(Type type, string name)
Parameters
Returns
Resolve(Type, string, params (Type Type, object Instance)[])
public object Resolve(Type type, string name, params (Type Type, object Instance)[] parameters)
Parameters
Returns
Resolve(Type, params (Type Type, object Instance)[])
public object Resolve(Type type, params (Type Type, object Instance)[] parameters)