Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TeamFoundationRequestContext Class

All Requests in a Team Foundation application create a TeamFoundationRequestContext and the context is available from the application or one of the framework base classes.


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

public class TeamFoundationRequestContext : RequestContextBase

The TeamFoundationRequestContext type exposes the following members.

Public propertyActivityIdThe Activity ID of the thread used to create this request context.
Public propertyAuthenticatedUserNameThis gives the name of the user making the request. If there was not an authenticated user the username is returned as Empty.
Public propertyAuthenticationTypeThis gives the authentication type of the request (e.g. Basic, Federated).
Public propertyCommandThis is a string that is supplied by the client that defines the intent of the user's command. For example, when you do a Get, you send Command = Get for all the downloads and UpdateLocalVersion calls. This lets you group calls together to determine all calls associated with a user action.
Public propertyContextIdThis is a unique Identifier that is assigned to each RequestContextBase as it is created. This identifier is never changed throughout the request execution. (Inherited from RequestContextBase.)
Public propertyDomainUserNameThis should not be used. It is only here to allow for backcompat for existing services.
Public propertyEndTimeThis is the time the request ended. If the request is still active, EndTime will be equal to DateTime.MinValue.
Public propertyExecutionEnvironment
Public propertyIsServicingContextGets a value indicating whether this request context is being used in a servicing context.
Public propertyIsSystemContextWill return true when the context is being run as part of a system request and not associated with a client.
Public propertyIsTrackedWhether or not to track this request's performance (Inherited from RequestContextBase.)
Public propertyIsUserContextGets a value indicating whether this request context is being used as a user context.
Public propertyItemsA property bag for storing items on the request context. Words that start with '$' are reserved.
Public propertyMethodRetrieve the method information for this request. If the method has not started, or this is not a web method, this will return null.
Public propertyQueuedA queued request is a request that is not currently processing. This means that its being held for one reason or another, for example, the server is too busy and is holding the request until the load lightens.
Public propertyQueuedTimeIf the request is currently queued, this will return the time that the request has been in the queue. Once the request leaves the queue, this will return the time that is spent in the queue.
Public propertyRecursiveSqlCallsUsed to capture the individual SQL Server calls.
Protected propertyRequestRestrictions
Public propertyRootContextGets the root context associated with this request context.
Public propertyServiceHostRetrieves the ServiceHost this request is part of.
Public propertyServiceNameThis property represents the Web service or application that is answering this request. The handling service can optionally set this property.
Public propertySqlCallsUsed to capture the individual SQL Server calls.
Public propertyStartTimeThis is the point that the request was started.
Public propertyStatusRead and Write the current status of the request by setting an exception for this request.
Public propertyUniqueAgentIdentifierReturns an option agent identifier string specified by the client. The value is similar to both UniqueIdentifier and UserAgent and will be used to uniquely correlate requests coming from an application on a machine even if the process restarts formatted: X-VSS-Agent: SomeUniqueAgentIdString
Public propertyUniqueIdentifierReturns the optional command identifier specified by the client.This identifier is passed by the client in an HTTP Header in the formatted: X-TFS-Instance: <Guid>[,<Command>]
Public propertyUserAgentThis gives the application string supplied to the server through the Http UserAgent Header.
Public propertyUserContextSurface the user associated with this Web request.

Public methodBuildHyperlink(String)
Public methodBuildHyperlink(String, Guid)
Public methodCancelSynchronously cancels a request. (Overrides RequestContextBase.Cancel(String).)
Public methodCreateComponent<TComponent>()Creates a component that can be used to communicate to the current version of the database.
Public methodCreateComponent<TComponent>(String)Creates a component that can be used to communicate to the current version of the database.
Public methodCreateImpersonationContextImpersonates the target identity on the current service host. The authenticated user will be the service account running the method.
Public methodDispose() (Inherited from RequestContextBase.)
Protected methodDispose(Boolean) (Overrides RequestContextBase.Dispose(Boolean).)
Public methodElevate()Returns a SystemRequestContext. If the current context is a system context, it will return itself.
Public methodElevate(Boolean)Returns a SystemRequestContext.If the current context is a system context, it will return itself.This RequestContext is managed by the owning context and should not be disposed after the caller is finished, this will be done when the root context is disposed.
Public methodEnterCancelableRegionAssociates a cancelable object together with this request.
Public methodEnterMethodEnterMethod is called at the start of execution of a WebMethod, HttpHandler or background job.EnterMethod should be called on the thread that is executing the request.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodExitCancelableRegionRemoves an association of a cancelable object from this request.
Protected methodFinalizeMake sure to release the locks when you are finalized even if you were not disposed. Normally this is considered an error caused by not disposing the object, but timing issues may prevent you from ever retrieving a reference to a newly created context. This finalizer will release the resources in this case. (Overrides Object.Finalize().)
Public methodGetAuthenticatedIdentityThe Authenticated identity is the identity of the user/service that is making this request. In the case of impersonation, this identity will be the one impersonating the UserContext. When impersonation is not being used, this identity will be the same as the one from the UserContext. The reason this is a function with an out parameter instead of a property is because it should not be easily confused with the UserContext which is the identity callers will be looking for a majority of the time.
Public methodGetClient<T>()Get an instance of the client specified by Type T.
Public methodGetClient<T>(Uri, String, Guid, Boolean)
Public methodGetHashCodeBuild a custom hash code for this object based on the primary values in the record. (Overrides Object.GetHashCode().)
Public methodGetReplicaAwareService<T>Get an instance of the class specified by Type T, corresponding to the replica where this request context is mapped to. This object is the instance associated with this request context. If T factory instance service doesn't exist, it is created and initialized with T instance for each available replica. This function is deterministic per user (as long as replica count doesn't change). Requests from same user will return the same T instance. Note these objects may be associated with the ServiceHost and have a longer life time than the request itself.
Public methodGetService<T>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.
Public methodGetSessionValueGetSessionValue will examine the current request context and return the value for the supplied sessionKey. Sessions may be supported by the specific type of request context. This means that the caller must work even when sessions are not supported.If the request context supports sessions, it will maintain the values between calls for a given session. A session is often a process run by a single user where the server wants to allow the client to re-use a value for the duration of the process.
Public methodGetSummaryA summary of the Team Foundation request context in string format.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeRecursiveSqlCallsUsed to capture the individual SQL Server calls on the current context and also to all associated System and User contexts.
Public methodIsCanceledDetermines if the current request has been canceled.
Public methodIsTracingReturns true if tracing is enabled for the supplied arguments.
Public methodLeaveMethodLeaveMethod is called when the scope of the method is being left. This enables the tracking of the scope of the method.
Public methodLogItemLogs a key/value pair to the request context Items bag.
Public methodLogSqlCallAdd a SQL Server call to the SQL Server calls logs.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodPartialResultsReadyPartialResultsReady is called when the command is executing and the command has determined that enough of the result is ready but not all of it. This implies that the caller may start accessing data but there is more data for the response than is currently available.
Public methodSetMethodNameSets the current method but does not call enter method - this is meant to help diagnosing commands that fail before they get to EnterMethod. We do not expect the parameters to be set at this point.
Public methodSetSessionValueSetSessionValue is used to add a name/value to the current requests session.
Public methodThrowIfCanceledThrows an exception if the current request has been canceled.
Public methodToTo is used to retrieve a requestContext that can be used to execute in a different service host. The root requestContext owns this context; therefore, the requestContext should not be disposed when the caller has finished with it. It will be disposed when the owning context is disposed.
Public methodToString (Overrides Object.ToString().)
Public methodTrace(Int32, TraceLevel, String, String, String, Object[])Trace without specific user-defined tags applied. (Overrides RequestContextBase.Trace(Int32, TraceLevel, String, String, String, Object[]).)
Public methodTrace(Int32, TraceLevel, String, String, String[], String, Object[])
Public methodTraceEnterTrace on entry of a method.
Public methodTraceException(Int32, String, String, Exception)Trace an exception.
Public methodTraceException(Int32, TraceLevel, String, String, Exception)Trace an exception with an explicit level.
Public methodTraceLeaveTrace on exit of a method.
Public methodTraceSql
Public methodTryGetItem<T>

Public Extension MethodCreateComponent<TInterface, TComponent>()Overloaded. Creates a component that can be used to communicate to the current version of the database. Construct via an interface so that it is more trivially mock/stubbable using Fakes. (Defined by RequestContextExtensions.)
Public Extension MethodCreateComponent<TInterface, TComponent>(String)Overloaded. Creates a component that can be used to communicate to the current version of the database. Construct via an interface so that it is more trivially mock/stubbable using Fakes. (Defined by RequestContextExtensions.)
Public Extension MethodGetNameToDisplay (Defined by Extensions.)
Public Extension MethodIsFeatureEnabledChecks the TeamFoundationFeatureAvailabilityService to detect if feature is enabled. The request context is elevated to bypass security checks which is permitted here since the request is initiated on the server side. (Defined by FeatureAvailabilityExtensionMethods.)
Public Extension MethodTraceBlock(Int32, Int32, String, String, String)Overloaded. Calls requestContext.TraceEnter method and returns an IDisposable instance for the requestContext.TraceLeave call. This method call must be wrapped with a using statement. IDisposable.Dispose method is not thread safe. The caller needs to do synchronization if it wants to share IDisposable isntance with other threads. (Defined by TeamFoundationTracingExtensionMethods.)
Public Extension MethodTraceBlock(Int32, Int32, Int32, String, String, String, Action)Overloaded. Wraps an action with TraceEnter and TraceLeave methods. When there is an exception it TraceException too. (Defined by TeamFoundationTracingExtensionMethods.)

Protected fieldm_activityId

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft