QuickOPC User's Guide and Reference
GetRequiredService0<TService>(IServiceProvider) Method



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.Extensions Namespace > IServiceProviderExtension Class > GetRequiredService0 Method : GetRequiredService0<TService>(IServiceProvider) Method
The type of service object to get.
The service provider.
Gets the required service object of the specified type, casting it to the same type.
Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function GetRequiredService0(Of TService)( _
   ByVal serviceProvider As IServiceProvider _
) As TService
'Usage
 
Dim serviceProvider As IServiceProvider
Dim value As TService
 
value = IServiceProviderExtension.GetRequiredService0(Of TService)(serviceProvider)
[Extension()]
[NotNull()]
public static TService GetRequiredService0<TService>( 
   IServiceProvider serviceProvider
)
[Extension()]
[NotNull()]
public:
static TService^ GetRequiredService0generic<typename TService>
( 
   IServiceProvider^ serviceProvider
) 

Parameters

serviceProvider
The service provider.

Type Parameters

TService
The type of service object to get.

Return Value

A service object of type TService.
Remarks

This is functionally based on the GetRequiredService0(IServiceProvider,Type), but provides a strongly typed result, while removing the need to specify the type using the typeof keyword at the same time.

Requirements

Target Platforms: .NET Framework: Windows 7 with SP1, Windows Server 2012; .NET Core: Linux, Microsoft Windows

See Also

Reference

IServiceProviderExtension Class
IServiceProviderExtension Members
Overload List