Partager via


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.

Inheritance Hierarchy

System.Object
  Microsoft.TeamFoundation.Framework.Server.RequestContextBase
    Microsoft.TeamFoundation.Framework.Server.TeamFoundationRequestContext

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

Syntax

'Declaration
Public Class TeamFoundationRequestContext _
    Inherits RequestContextBase
public class TeamFoundationRequestContext : RequestContextBase
public ref class TeamFoundationRequestContext : public RequestContextBase
type TeamFoundationRequestContext =  
    class 
        inherit RequestContextBase 
    end
public class TeamFoundationRequestContext extends RequestContextBase

The TeamFoundationRequestContext type exposes the following members.

Properties

  Name Description
Public property ActivityId The Activity ID of the thread used to create this request context.
Public property AuthenticatedUserName This gives the name of the user making the request. If there was not an authenticated user the username is returned as Empty.
Public property AuthenticationType This gives the authentication type of the request (e.g. Basic, Federated).
Public property Command This 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 property ContextId This 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 property DomainUserName This should not be used. It is only here to allow for backcompat for existing services.
Public property EndTime This is the time the request ended. If the request is still active, EndTime will be equal to DateTime.MinValue.
Public property ExecutionEnvironment
Public property IsServicingContext Gets a value indicating whether this request context is being used in a servicing context.
Public property IsSystemContext Will return true when the context is being run as part of a system request and not associated with a client.
Public property IsTracked Whether or not to track this request's performance (Inherited from RequestContextBase.)
Public property IsUserContext Gets a value indicating whether this request context is being used as a user context.
Public property Items A property bag for storing items on the request context. Words that start with '$' are reserved.
Public property Method Retrieve the method information for this request. If the method has not started, or this is not a web method, this will return null.
Public property Queued A 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 property QueuedTime If 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 property RecursiveSqlCalls Used to capture the individual SQL Server calls.
Protected property RequestRestrictions
Public property RootContext Gets the root context associated with this request context.
Public property ServiceHost Retrieves the ServiceHost this request is part of.
Public property ServiceName This property represents the Web service or application that is answering this request. The handling service can optionally set this property.
Public property SqlCalls Used to capture the individual SQL Server calls.
Public property StartTime This is the point that the request was started.
Public property Status Read and Write the current status of the request by setting an exception for this request.
Public property UniqueAgentIdentifier Returns 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 property UniqueIdentifier Returns 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 property UserAgent This gives the application string supplied to the server through the Http UserAgent Header.
Public property UserContext Surface the user associated with this Web request.

Top

Methods

  Name Description
Public method BuildHyperlink(String)
Public method BuildHyperlink(String, Guid)
Public method Cancel Synchronously cancels a request. (Overrides RequestContextBase.Cancel(String).)
Public method CreateComponent<TComponent>() Creates a component that can be used to communicate to the current version of the database.
Public method CreateComponent<TComponent>(String) Creates a component that can be used to communicate to the current version of the database.
Public method CreateImpersonationContext Impersonates the target identity on the current service host. The authenticated user will be the service account running the method.
Public method Dispose() (Inherited from RequestContextBase.)
Protected method Dispose(Boolean) (Overrides RequestContextBase.Dispose(Boolean).)
Public method Elevate() Returns a SystemRequestContext. If the current context is a system context, it will return itself.
Public method Elevate(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 method EnterCancelableRegion Associates a cancelable object together with this request.
Public method EnterMethod EnterMethod 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 method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method ExitCancelableRegion Removes an association of a cancelable object from this request.
Protected method Finalize Make 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 method GetAuthenticatedIdentity The 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 method GetClient<T>() Get an instance of the client specified by Type T.
Public method GetClient<T>(Uri, String, Guid, Boolean)
Public method GetHashCode Build a custom hash code for this object based on the primary values in the record. (Overrides Object.GetHashCode().)
Public method GetReplicaAwareService<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 method GetService<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 method GetSessionValue GetSessionValue 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 method GetSummary A summary of the Team Foundation request context in string format.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InitializeRecursiveSqlCalls Used to capture the individual SQL Server calls on the current context and also to all associated System and User contexts.
Public method IsCanceled Determines if the current request has been canceled.
Public method IsTracing Returns true if tracing is enabled for the supplied arguments.
Public method LeaveMethod LeaveMethod is called when the scope of the method is being left. This enables the tracking of the scope of the method.
Public method LogItem Logs a key/value pair to the request context Items bag.
Public method LogSqlCall Add a SQL Server call to the SQL Server calls logs.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method PartialResultsReady PartialResultsReady 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 method SetMethodName Sets 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 method SetSessionValue SetSessionValue is used to add a name/value to the current requests session.
Public method ThrowIfCanceled Throws an exception if the current request has been canceled.
Public method To To 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 method ToString (Overrides Object.ToString().)
Public method Trace(Int32, TraceLevel, String, String, String, array<Object[]) Trace without specific user-defined tags applied. (Overrides RequestContextBase.Trace(Int32, TraceLevel, String, String, String, array<Object[]).)
Public method Trace(Int32, TraceLevel, String, String, array<String[], String, array<Object[])
Public method TraceEnter Trace on entry of a method.
Public method TraceException(Int32, String, String, Exception) Trace an exception.
Public method TraceException(Int32, TraceLevel, String, String, Exception) Trace an exception with an explicit level.
Public method TraceLeave Trace on exit of a method.
Public method TraceSql
Public method TryGetItem<T>

Top

Extension Methods

  Name Description
Public Extension Method CreateComponent<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 Method CreateComponent<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 Method GetNameToDisplay (Defined by Extensions.)
Public Extension Method IsFeatureEnabled Checks 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 Method TraceBlock(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 Method TraceBlock(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.)

Top

Fields

  Name Description
Protected field m_activityId

Top

Thread Safety

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

See Also

Reference

Microsoft.TeamFoundation.Framework.Server Namespace