Init(args)
Scripting Reference
Loading...
Searching...
No Matches

◆ TryGetFor()

static bool Sisus.Init.ServiceUtility.TryGetFor ( object client,
[DisallowNull] Type definingType,
out object service,
Context context = Context::MainThread )
static

Gets the shared service instance of the given serviceType .

The returned object's class will match the provided serviceType , derive from it or implement an interface of the type.

Exceptions
NullReferenceExceptionThrown if no service of type TService is found that is accessible to the client .
Parameters
clientThe client that needs the service.
definingTypeThe defining type of the service; the class or interface type that uniquely defines the service and can be used to retrieve an instance of it.

This must be an interface that the service implement, a base type that the service derives from, or the exact type of the service.

Parameters
serviceWhen this method returns, contains service of type definingType if found; otherwise, null. This parameter is passed uninitialized.
contextThe context from which the request is being made.
Returns
Shared instance of the service of the given type.