ILogicalThreadAffinative 인터페이스

정의

에서 외부로 전파할 수 있는 개체를 AppDomain 표시합니다 LogicalCallContext.

public interface class ILogicalThreadAffinative
public interface ILogicalThreadAffinative
[System.Runtime.InteropServices.ComVisible(true)]
public interface ILogicalThreadAffinative
type ILogicalThreadAffinative = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type ILogicalThreadAffinative = interface
Public Interface ILogicalThreadAffinative
특성

예제

다음 코드 예제에서는 식별을 위해 ILogicalThreadAffinative를 원격 위치로 전송하는 인터페이스를 사용하는 방법을 보여 줍니다. 샘플에서 사용되는 클래스의 HelloServiceClass 코드를 보려면 메서드의 예제를 GetData 참조하세요. 이 샘플에서 사용되는 서버 클래스의 코드를 보려면 클래스에 대한 예제를 RegisterActivatedServiceType 참조하세요. 샘플에서 사용되는 클라이언트 클래스의 코드를 보려면 클래스의 예제를 CallContext 참조하세요.

[Serializable]
public ref class LogicalCallContextData: public ILogicalThreadAffinative
{
private:
   int _nAccesses;
   IPrincipal^ _principal;

public:

   property String^ numOfAccesses 
   {
      String^ get()
      {
         return String::Format( "The identity of {0} has been accessed {1} times.", _principal->Identity->Name, _nAccesses );
      }
   }

   property IPrincipal^ Principal 
   {
      IPrincipal^ get()
      {
         _nAccesses++;
         return _principal;
      }
   }

   LogicalCallContextData( IPrincipal^ p )
   {
      _nAccesses = 0;
      _principal = p;
   }

};
[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;
   }
}
<Serializable()> Public Class LogicalCallContextData
   Implements ILogicalThreadAffinative

   Private _nAccesses As Integer
   Private _principal As IPrincipal
   
   
   Public ReadOnly Property numOfAccesses() As String
      Get
         Return [String].Format("The identity of {0} has been accessed {1} times.", _principal.Identity.Name, _nAccesses)
      End Get
   End Property
   
   
   Public ReadOnly Property Principal() As IPrincipal
      Get
         _nAccesses += 1
         Return _principal
      End Get
   End Property
   
   
   Public Sub New(p As IPrincipal)
      _nAccesses = 0
      _principal = p
   End Sub

End Class

설명

다른 AppDomain개체에 대한 원격 메서드 호출이 수행되면 현재 CallContext 클래스는 원격 위치에 대한 호출과 함께 이동하는 메서드를 생성 LogicalCallContext 합니다. 인터페이스를 ILogicalThreadAffinative 노출하고 이 인터페이스에 CallContext 저장된 개체만 외부 AppDomain로 전파됩니다. 이 인터페이스를 지원하지 않는 개체는 원격 메서드 호출이 있는 인스턴스에서 LogicalCallContext 전송되지 않습니다.

적용 대상