| ServiceProviderExtensionsTryGetGlobalServiceTServiceClass, TServiceInterface Method |
Get an instance of TServiceInterface by requesting an
instance of TServiceClass from the specified OLE service
provider.
Namespace: Tvl.VisualStudio.ShellAssembly: Tvl.VisualStudio.ShellServices.10 (in Tvl.VisualStudio.ShellServices.10.dll) Version: 2.0.0.0
Syntax public static TServiceInterface TryGetGlobalService<TServiceClass, TServiceInterface>(
this IServiceProvider serviceProvider
)
where TServiceInterface : class
<ExtensionAttribute>
Public Shared Function TryGetGlobalService(Of TServiceClass, TServiceInterface As Class) (
serviceProvider As IServiceProvider
) As TServiceInterface
public:
[ExtensionAttribute]
generic<typename TServiceClass, typename TServiceInterface>
where TServiceInterface : ref class
static TServiceInterface TryGetGlobalService(
IServiceProvider^ serviceProvider
)
static member TryGetGlobalService :
serviceProvider : IServiceProvider -> 'TServiceInterface when 'TServiceInterface : not struct
Parameters
- serviceProvider
- Type: Microsoft.VisualStudio.OLE.InteropIServiceProvider
The OLE service provider.
Type Parameters
- TServiceClass
- The type of service to request from the service provider.
- TServiceInterface
- The type to cast the resulting service object to.
Return Value
Type:
TServiceInterfaceAn instance of the service, or
if the service provider was unable to provide the service.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IServiceProvider. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions See Also