The following code example demonstrates the use of the ILogicalThreadAffinative interface to transmit the conceptual topic at MSDN: principalidentityobjects to a remote location for identification. To view the code for the HelloServiceClass class used in the sample, see the example for the CallContext.GetData method. To view the code for the server class used in this sample, see example for the RemotingConfiguration.RegisterActivatedServiceType class. To view the code for the client class used in the sample, see the examplefor the CallContext class.
[Serializable]
public class LogicalCallContextData : ILogicalThreadAffinative
{
int _nAccesses;
IPrincipal _principal;
public string numOfAccesses {
get {
return String.Format("The identity of {0} has been accessed {1} times.",
_principal.Identity.Name,
_nAccesses);
}
}
public IPrincipal Principal {
get {
_nAccesses ++;
return _principal;
}
}
public LogicalCallContextData(IPrincipal p) {
_nAccesses = 0;
_principal = p;
}
}