ActivatedServiceTypeEntry Classe

Definição

Contém valores para um tipo de objeto registrado no lado do servidor como um que pode ser ativado na solicitação de um cliente.

public ref class ActivatedServiceTypeEntry : System::Runtime::Remoting::TypeEntry
public class ActivatedServiceTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class ActivatedServiceTypeEntry : System.Runtime.Remoting.TypeEntry
type ActivatedServiceTypeEntry = class
    inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type ActivatedServiceTypeEntry = class
    inherit TypeEntry
Public Class ActivatedServiceTypeEntry
Inherits TypeEntry
Herança
ActivatedServiceTypeEntry
Atributos

Exemplos

#using <System.Runtime.Remoting.dll>
#using <ActivatedServiceTypeEntry_ObjectType_Share.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
void main()
{
   ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) );
   
   // Create an instance of 'ActivatedServiceTypeEntry' class
   // which holds the values for 'HelloServer' type.
   ActivatedServiceTypeEntry^ myActivatedServiceTypeEntry =
      gcnew ActivatedServiceTypeEntry( HelloServer::typeid );
   
   // Register an object Type on the service end so that 
   // it can be activated on request from a client.
   RemotingConfiguration::RegisterActivatedServiceType(
      myActivatedServiceTypeEntry );
   
   // Get the registered activated service types.
   array<ActivatedServiceTypeEntry^>^ activatedServiceEntries =
      RemotingConfiguration::GetRegisteredActivatedServiceTypes();
   Console::WriteLine( "Information of first registered activated" +
     " service type :" );
   Console::WriteLine( "Object type: {0}",
      activatedServiceEntries[ 0 ]->ObjectType->ToString() );
   Console::WriteLine( "Description: {0}",
      activatedServiceEntries[ 0 ]->ToString() );

   Console::WriteLine( "Press enter to stop this process" );
   Console::ReadLine();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class MyClient
{
   public static void Main()
   {
      ChannelServices.RegisterChannel(new TcpChannel(8082));
      // Create an instance of 'ActivatedServiceTypeEntry' class
      // which holds the values for 'HelloServer' type.
      ActivatedServiceTypeEntry myActivatedServiceTypeEntry =
                   new ActivatedServiceTypeEntry(typeof(HelloServer));
      // Register an object Type on the service end so that
      // it can be activated on request from a client.
      RemotingConfiguration.RegisterActivatedServiceType(
                                         myActivatedServiceTypeEntry);
      // Get the registered activated service types .
      ActivatedServiceTypeEntry[] myActivatedServiceEntries =
          RemotingConfiguration.GetRegisteredActivatedServiceTypes();
      Console.WriteLine("Information of first registered activated "
                             +" service type :");
      Console.WriteLine("Object type: "
                       +myActivatedServiceEntries[0].ObjectType);
      Console.WriteLine("Description: "
                           +myActivatedServiceEntries[0].ToString());
      Console.WriteLine("Press enter to stop this process");
      Console.ReadLine();
   }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp

Public Class MyClient
   
   Public Shared Sub Main()
      ChannelServices.RegisterChannel(New TcpChannel(8082))
      ' Create an instance of 'ActivatedServiceTypeEntry' class
      ' which holds the values for 'HelloServer' type.
      Dim myActivatedServiceTypeEntry As New ActivatedServiceTypeEntry(GetType(HelloServer))
      ' Register an object Type on the service end so that 
      ' it can be activated on request from a client.
      RemotingConfiguration.RegisterActivatedServiceType(myActivatedServiceTypeEntry)
      ' Get the registered activated service types .
      Dim myActivatedServiceEntries As ActivatedServiceTypeEntry() = RemotingConfiguration. _
                                                         GetRegisteredActivatedServiceTypes()
      Console.WriteLine("Information of first registered activated " + " service type :")
      Console.WriteLine("Object type: " + myActivatedServiceEntries(0).ObjectType.ToString())
      Console.WriteLine("Description: " + myActivatedServiceEntries(0).ToString())
      Console.WriteLine("Press enter to stop this process")
      Console.ReadLine()
   End Sub
End Class

Comentários

A classe atual é usada pelo RemotingConfiguration.RegisterActivatedServiceType método , que é o equivalente do lado do servidor do RemotingConfiguration.RegisterActivatedClientType método . O RegisterActivatedServiceType método é usado no servidor para permitir a ativação remota por clientes de tipos de objeto especificados.

Para criar um objeto ativado pelo cliente no servidor, você deve conhecer seu Typee ele deve ser registrado na extremidade do servidor usando o RegisterActivatedServiceType método . Para obter um proxy para um novo objeto ativado pelo cliente, o cliente deve primeiro registrar um canal com ChannelServices e, em seguida, ativar o objeto chamando new ou Activator.CreateInstance.

Para ativar um tipo de objeto ativado pelo cliente com o new palavra-chave, primeiro você deve registrar o tipo de objeto no cliente usando o RegisterActivatedClientType método . Ao chamar RegisterActivatedClientType , você está dando à infraestrutura de comunicação remota o local do aplicativo remoto em new que tenta criá-la. Se, por outro lado, você usar o CreateInstance método para criar uma nova instância do objeto ativado pelo cliente, deverá fornecer a URL do aplicativo remoto como um parâmetro, portanto, nenhum registro anterior no cliente será necessário. Para fornecer o CreateInstance método com a URL do servidor no qual você deseja criar o objeto, você deve encapsular a URL em uma instância da UrlAttribute classe .

Para obter uma descrição detalhada de objetos ativados pelo cliente e ativação de objeto remoto, consulte Ativação de objetos remotos.

Construtores

ActivatedServiceTypeEntry(String, String)

Inicializa uma nova instância da classe ActivatedServiceTypeEntry com o nome do tipo e o nome do assembly especificados.

ActivatedServiceTypeEntry(Type)

Inicializa uma nova instância da classe ActivatedServiceTypeEntry com o Type determinado.

Propriedades

AssemblyName

Obtém o nome do assembly do tipo de objeto configurado para ser um tipo de ativação remota.

(Herdado de TypeEntry)
ContextAttributes

Obtém ou define os atributos de contexto para o tipo de serviço ativado pelo cliente.

ObjectType

Obtém Type do tipo de serviço ativado pelo cliente.

TypeName

Obtém o nome de tipo completo do tipo de objeto configurado para ser um tipo de ativação remota.

(Herdado de TypeEntry)

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna o nome do tipo e do assembly do tipo de serviço ativado pelo cliente como String.

Aplica-se a

Confira também