Delen via


TeamFoundationRequestContext.GetService<T> Method

Get an instance of the class specified by Type T.

This object is the instance associated with this request context.

If an instance is not yet associated with this context, one will be created and will then be returned in the future.

These objects may be associated with the ServiceHost and have a longer life time than the request itself.

Namespace:  Microsoft.TeamFoundation.Framework.Server
Assembly:  Microsoft.TeamFoundation.Framework.Server (in Microsoft.TeamFoundation.Framework.Server.dll)

Syntax

'Declaration
Public Overridable Function GetService(Of T As ITeamFoundationService) As T
public virtual T GetService<T>()
where T : ITeamFoundationService
public:
generic<typename T>
where T : ITeamFoundationService 
virtual T GetService()
abstract GetService : unit -> 'T  when 'T : ITeamFoundationService 
override GetService : unit -> 'T  when 'T : ITeamFoundationService
JScript does not support generic types or methods.

Type Parameters

  • T
    Class type of the object to retrieve. Class must implement ITeamFoundationService, be non-abstract, and have a parameter-less or default constructor.

Return Value

Type: T
Returns an instance of the object specified by Type T associated with this request.

Exceptions

Exception Condition
RequestCanceledException

Remarks

If class type T implements IDisposable, it will be disposed following ServiceEnd or an exception on ServiceStart.

.NET Framework Security

See Also

Reference

TeamFoundationRequestContext Class

Microsoft.TeamFoundation.Framework.Server Namespace