ProxyAttribute 클래스

정의

사용자 지정 프록시가 필요한 개체 형식을 나타냅니다.

public ref class ProxyAttribute : Attribute, System::Runtime::Remoting::Contexts::IContextAttribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public class ProxyAttribute : Attribute, System.Runtime.Remoting.Contexts.IContextAttribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ProxyAttribute : Attribute, System.Runtime.Remoting.Contexts.IContextAttribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public class ProxyAttribute : Attribute, System.Runtime.Remoting.Contexts.IContextAttribute
[System.Runtime.InteropServices.ComVisible(true)]
[System.AttributeUsage(System.AttributeTargets.Class)]
public class ProxyAttribute : Attribute, System.Runtime.Remoting.Contexts.IContextAttribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
type ProxyAttribute = class
    inherit Attribute
    interface IContextAttribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ProxyAttribute = class
    inherit Attribute
    interface IContextAttribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type ProxyAttribute = class
    inherit Attribute
    interface IContextAttribute
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type ProxyAttribute = class
    inherit Attribute
    interface IContextAttribute
Public Class ProxyAttribute
Inherits Attribute
Implements IContextAttribute
상속
ProxyAttribute
특성
구현

예제

[AttributeUsageAttribute(AttributeTargets::Class)]
[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::LinkDemand,
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]
[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::InheritanceDemand,
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]
public ref class MyProxyAttribute: public ProxyAttribute
{
public:
   MyProxyAttribute(){}

   // Create an instance of ServicedComponentProxy
   virtual MarshalByRefObject^ CreateInstance( Type^ serverType ) override
   {
      return ProxyAttribute::CreateInstance( serverType );
   }

   virtual RealProxy^ CreateProxy( ObjRef^ objRef1, Type^ serverType, Object^ serverObject, Context^ serverContext ) override
   {
      MyProxy^ myCustomProxy = gcnew MyProxy( serverType );
      if ( serverContext != nullptr )
      {
         RealProxy::SetStubData( myCustomProxy, serverContext );
      }

      if ( ( !serverType->IsMarshalByRef) && (serverContext == nullptr) )
      {
         throw gcnew RemotingException( "Bad Type for CreateProxy" );
      }

      return myCustomProxy;
   }
};

[MyProxyAttribute]
ref class CustomServer: public ContextBoundObject
{
public:
   CustomServer()
   {
      Console::WriteLine( "CustomServer Base Class constructor called" );
   }

   void HelloMethod( String^ str )
   {
      Console::WriteLine( "HelloMethod of Server is invoked with message : {0}", str );
   }
};
[AttributeUsage(AttributeTargets.Class)]
public class MyProxyAttribute : ProxyAttribute
{
   public MyProxyAttribute()
   {
   }
   // Create an instance of ServicedComponentProxy
   public override MarshalByRefObject CreateInstance(Type serverType)
   {
      return base.CreateInstance(serverType);
   }
   public override RealProxy CreateProxy(ObjRef objRef1,
      Type serverType,
      object serverObject,
      Context serverContext)
   {
      MyProxy myCustomProxy = new MyProxy(serverType);
      if(serverContext != null)
      {
         RealProxy.SetStubData(myCustomProxy,serverContext);
      }
      if((!serverType.IsMarshalByRef)&&(serverContext == null))
      {
         throw new RemotingException("Bad Type for CreateProxy");
      }
      return myCustomProxy;
   }
}
[MyProxyAttribute]
public class CustomServer :ContextBoundObject
{
   public CustomServer()
   {
      Console.WriteLine("CustomServer Base Class constructor called");
   }
   public void HelloMethod(string str)
   {
      Console.WriteLine("HelloMethod of Server is invoked with message : " + str);
   }
}
<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.Infrastructure), _
AttributeUsage(AttributeTargets.Class)>  _
Public Class MyProxyAttribute
   Inherits ProxyAttribute

   Public Sub New()
   End Sub

   ' Create an instance of ServicedComponentProxy
   Public Overrides Function CreateInstance(serverType As Type) As MarshalByRefObject
      Return MyBase.CreateInstance(serverType)
   End Function 'CreateInstance

   Public Overrides Function CreateProxy(objRef1 As ObjRef, serverType As Type, _
               serverObject As Object, serverContext As Context) As RealProxy
      Dim myCustomProxy As New MyProxy(serverType)
      If Not (serverContext Is Nothing) Then
         RealProxy.SetStubData(myCustomProxy, serverContext)
      End If
      If Not serverType.IsMarshalByRef And serverContext Is Nothing Then
         Throw New RemotingException("Bad Type for CreateProxy")
      End If
      Return myCustomProxy
   End Function 'CreateProxy
End Class

<MyProxyAttribute()> _
Public Class CustomServer
   Inherits ContextBoundObject

   Public Sub New()
      Console.WriteLine("CustomServer Base Class constructor called")
   End Sub

   Public Sub HelloMethod(str As String)
      Console.WriteLine("HelloMethod of Server is invoked with message : " + str)
   End Sub
End Class

설명

사용자 지정 프록시를 필요로 하는 형식에 현재 특성을 적용 합니다. ProxyAttribute 클래스를 사용 하 여 가로챌 합니다 new (New Visual Basic의)는 ProxyAttribute에서 파생 하 고 자식에 특성을 배치 하 여 문을 ContextBoundObject. (자식에 프록시 특성을 배치 MarshalByRefObject 지원 되지 않습니다.)

참고

이 클래스는 클래스 수준에서 상속 요청과 링크 요청을 만듭니다. SecurityException 직접 실행 호출자 또는 파생된 클래스 중 하나에 인프라 권한이 없는 경우 throw 됩니다. 보안 요청에 대 한 자세한 내용은 참조 하세요 링크 요청 하 고 상속 요청합니다.

생성자

ProxyAttribute()

기본값을 사용하여 ProxyAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

CreateInstance(Type)

지정된 형식이 현재 컨텍스트에 있는지 여부에 따라 초기화되지 않은 MarshalByRefObject나 투명 프록시를 만듭니다.

CreateProxy(ObjRef, Type, Object, Context)

지정된 ObjRef에 설명된 서버에 있는 원격 개체에 대한 원격 프록시의 인스턴스를 만듭니다.

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetPropertiesForNewContext(IConstructionCallMessage)

새 컨텍스트의 속성을 가져옵니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsContextOK(Context, IConstructionCallMessage)

지정된 컨텍스트를 확인합니다.

IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보