ProxyAttribute.CreateProxy(ObjRef, Type, Object, Context) Método
Definição
public:
virtual System::Runtime::Remoting::Proxies::RealProxy ^ CreateProxy(System::Runtime::Remoting::ObjRef ^ objRef, Type ^ serverType, System::Object ^ serverObject, System::Runtime::Remoting::Contexts::Context ^ serverContext);
public virtual System.Runtime.Remoting.Proxies.RealProxy CreateProxy (System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext);
[System.Security.SecurityCritical]
public virtual System.Runtime.Remoting.Proxies.RealProxy CreateProxy (System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext);
abstract member CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
override this.CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
[<System.Security.SecurityCritical>]
abstract member CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
override this.CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
Public Overridable Function CreateProxy (objRef As ObjRef, serverType As Type, serverObject As Object, serverContext As Context) As RealProxy
Parâmetros
- objRef
- ObjRef
A referência de objeto para o objeto remoto para o qual criar um proxy.The object reference to the remote object for which to create a proxy.
- serverType
- Type
O tipo do servidor em que o objeto remoto está localizado.The type of the server where the remote object is located.
- serverObject
- Object
O objeto de servidor.The server object.
- serverContext
- Context
O contexto no qual o objeto de servidor está localizado.The context in which the server object is located.
Retornos
A nova instância do proxy de comunicação remota para o objeto remoto que está descrito no ObjRef especificado.The new instance of remoting proxy for the remote object that is described in the specified ObjRef.
- Atributos
Exemplos
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;
}
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;
}
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
Comentários
Observação
O método atual é chamado quando um proxy é criado fora de uma ObjRef instância que faz referência a uma classe marcada com o ProxyAttribute atributo.The current method is called when a proxy is created out of a ObjRef instance that references a class that is marked with the ProxyAttribute attribute. Portanto, o método é usado somente quando um ObjRef é recebido de um retorno ou parâmetro em uma chamada, ou durante a ativação de um objeto ativado pelo cliente.Therefore, the method is used only when a ObjRef is received from a return or parameter on a call, or during the activation of a client-activated object. O ProxyAttribute não é usado para tipos de objeto conhecidos.The ProxyAttribute is not used for well-known object types.