WellKnownClientTypeEntry Classe

Definição

Contém os valores para um tipo de objeto registrado no cliente como um tipo ativado por servidor (chamada única ou singleton).

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

Exemplos

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

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Http;

int main()
{
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices::RegisterChannel( gcnew HttpChannel );
   Console::WriteLine( " Start calling from Client One......." );
   WellKnownClientTypeEntry^ myWellKnownClientTypeEntry = gcnew WellKnownClientTypeEntry( HelloServer::typeid,"http://localhost:8086/SayHello" );
   myWellKnownClientTypeEntry->ApplicationUrl = "http://localhost:8086/SayHello";
   RemotingConfiguration::RegisterWellKnownClientType( myWellKnownClientTypeEntry );

   // Get the proxy object for the remote object.
   HelloServer^ myHelloServerObject = gcnew HelloServer;

   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   array<WellKnownClientTypeEntry^>^myWellKnownClientTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownClientTypes();
   Console::WriteLine( "The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[ 0 ]->ApplicationUrl );
   Console::WriteLine( "The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[ 0 ] );

   // Make remote method calls.
   for ( int i = 0; i < 5; i++ )
      Console::WriteLine( myHelloServerObject->HelloMethod( " Client One" ) );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class MyClient 
{
   public static void Main()
   {
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices.RegisterChannel(new HttpChannel());
   Console.WriteLine(" Start calling from Client One.......");
   WellKnownClientTypeEntry myWellKnownClientTypeEntry = 
                  new WellKnownClientTypeEntry(typeof(HelloServer),
                                  "http://localhost:8086/SayHello");
   myWellKnownClientTypeEntry.ApplicationUrl="http://localhost:8086/SayHello";
   RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry);
   // Get the proxy object for the remote object.
   HelloServer myHelloServerObject = new HelloServer();
   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   WellKnownClientTypeEntry [] myWellKnownClientTypeEntryCollection = 
          RemotingConfiguration.GetRegisteredWellKnownClientTypes();
   Console.WriteLine("The Application Url to activate the Remote Object :"
        +myWellKnownClientTypeEntryCollection[0].ApplicationUrl);
   Console.WriteLine("The 'WellKnownClientTypeEntry' object :"
            +myWellKnownClientTypeEntryCollection[0].ToString());
   // Make remote method calls.
   for (int i = 0; i < 5; i++)
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"));
   }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http

Public Class MyClient
   
   Public Shared Sub Main()
      ' Create a 'HttpChannel' object and  register with channel services.
      ChannelServices.RegisterChannel(New HttpChannel())
      Console.WriteLine(" Start calling from Client One.......")
      Dim myWellKnownClientTypeEntry As New WellKnownClientTypeEntry(GetType(HelloServer), _ 
                                                  "http://localhost:8086/SayHello")
      myWellKnownClientTypeEntry.ApplicationUrl = "http://localhost:8086/SayHello"
      RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry)
      ' Get the proxy object for the remote object.
      Dim myHelloServerObject As New HelloServer()
      ' Retrieve an array of object types registered on the 
      ' client end as well-known types.
      Dim myWellKnownClientTypeEntryCollection As WellKnownClientTypeEntry() = _ 
                                       RemotingConfiguration.GetRegisteredWellKnownClientTypes()
      Console.WriteLine("The Application Url to activate the Remote Object :" + _ 
                                           myWellKnownClientTypeEntryCollection(0).ApplicationUrl)
      Console.WriteLine("The 'WellKnownClientTypeEntry' object :" + _ 
                                              myWellKnownClientTypeEntryCollection(0).ToString())
      ' Make remote method calls.
      Dim i As Integer
      For i = 0 To 4
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"))
      Next i
   End Sub
End Class

Comentários

Os tipos ativados pelo servidor podem ser de chamada única ou singleton. Se uma classe for registrada como um único tipo de chamada, uma nova instância será criada sempre que uma chamada do cliente chegar. Todas as chamadas para um objeto singleton são tratadas por uma instância desse objeto, a menos que esse objeto tenha sido coletado.

Qualquer cliente que conheça o URI de um objeto registrado ativado pelo servidor pode obter um proxy para esse objeto registrando o canal com ChannelServices o qual prefere e ativando o objeto chamando new ou Activator.GetObject. Para ativar um objeto ativado pelo servidor com new, primeiro você deve registrar o tipo de objeto ativado pelo servidor no cliente usando o RegisterWellKnownClientType método . Ao chamar RegisterWellKnownClientType, você está dando à infraestrutura de comunicação remota a localização do objeto remoto, o que permite que o new palavra-chave criá-lo. Se, por outro lado, você usar o Activator.GetObject método para ativar um objeto ativado pelo servidor, deverá fornecê-lo com a URL do objeto como um argumento, portanto, nenhum registro anterior no cliente será necessário.

Para obter uma descrição detalhada de objetos ativados pelo servidor e ativação remota de objetos, consulte Ativação de objetos remotos.

Construtores

WellKnownClientTypeEntry(String, String, String)

Inicializa uma nova instância da classe WellKnownClientTypeEntry com o tipo, o nome do assembly e a URL especificados.

WellKnownClientTypeEntry(Type, String)

Inicializa uma nova instância da classe WellKnownClientTypeEntry com o tipo e a URL determinados.

Propriedades

ApplicationUrl

Obtém ou define a URL do aplicativo no qual o tipo será ativado.

AssemblyName

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

(Herdado de TypeEntry)
ObjectType

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

ObjectUrl

Obtém a URL do objeto de cliente ativado pelo servidor.

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 completo, o nome do assembly e a URL do objeto do tipo de cliente ativado pelo servidor como uma String.

Aplica-se a

Confira também