PostSharp 2023.0 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Extensibility Namespace / IService­Locator Interface / IService­Locator Methods / IService­Locator.​Get­Service(T) Method

IServiceLocator.GetService<T> Method

Gets a build-time service exposed by PostSharp.

Namespace:  PostSharp.Extensibility
Assembly:  PostSharp (in PostSharp.dll) Version: 2023.0.3.0 (2023.0.3.0)
T GetService<T>(
	bool throwing = true
where T : class, IService


throwing (Optional)
Type: System.Boolean
true whether an exception should be thrown in case the service cannot be acquired, otherwise false. The default value is true.

Type Parameters

An interface derived from IService.

Return Value

Type: T
The service T, or null if the service could not be acquired and throwing was set to false.
See Also