Share via


DependencyResolverExtensions.GetService<TService> Method

Resolves singly registered services that support arbitrary object creation.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function GetService(Of TService) ( _
    resolver As IDependencyResolver _
) As TService
'Usage
Dim resolver As IDependencyResolver
Dim returnValue As TService

returnValue = resolver.GetService()
public static TService GetService<TService>(
    this IDependencyResolver resolver
)
[ExtensionAttribute]
public:
generic<typename TService>
static TService GetService(
    IDependencyResolver^ resolver
)
JScript does not support generic types or methods.

Type Parameters

  • TService
    The type of the requested service or object.

Parameters

Return Value

Type: TService
The requested service or object.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IDependencyResolver. When you use instance method syntax to call this method, omit the first parameter. For more information, see b8020aae-374d-46a9-bcb7-8cc2390b93b6 or 175ce3ff-9bbf-4e64-8421-faeb81a0bb51.

Remarks

For more information about this method, see the entry ASP.NET MVC 3 Service Location on Brad Wilson's blog.

See Also

Reference

DependencyResolverExtensions Class

System.Web.Mvc Namespace