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).Holds values for an object type registered on the client as a server-activated type (single call or 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
- 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 para o servidor podem ser de chamada única ou singleton.Server-activated types can be either single call or singleton. Se uma classe for registrada como um tipo de chamada única, uma nova instância será criada cada vez que uma chamada do cliente chegar.If a class is registered as a single call type, a new instance is created each time a call from the client arrives. Todas as chamadas para um objeto singleton são tratadas por uma instância desse objeto, a menos que esse objeto tenha sido coletado.All calls to a singleton object are handled by one instance of that object, unless that object has been collected.
Qualquer cliente que conheça o URI de um objeto ativado pelo servidor registrado pode obter um proxy para esse objeto registrando o canal com o qual prefere ChannelServices e ativando o objeto chamando new ou Activator.GetObject .Any client that knows the URI of a registered server-activated object can obtain a proxy for this object by registering the channel it prefers with ChannelServices and activating the object by calling new or Activator.GetObject. Para ativar um objeto ativado pelo servidor com new o, você deve primeiro registrar o tipo de objeto ativado pelo servidor no cliente usando RegisterWellKnownClientType o método.To activate a server-activated object with new, you must first register the server-activated object type on the client using the RegisterWellKnownClientType method. Ao chamar RegisterWellKnownClientType , você está dando à infraestrutura de comunicação remota o local do objeto remoto, que permite que a new palavra-chave o crie.By calling RegisterWellKnownClientType, you are giving the remoting infrastructure the location of the remote object, which allows the new keyword to create it. 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.If, on the other hand, you use the Activator.GetObject method to activate a server-activated object, you must supply it with the object's URL as an argument, so no prior registration on the client is necessary.
Para obter uma descrição detalhada dos objetos ativados pelo servidor e da ativação remota de objeto, consulte ativação de objetos remotos.For a detailed description of server-activated objects and remote object activation, see Activation of Remote Objects.
Construtores
| WellKnownClientTypeEntry(String, String, String) |
Inicializa uma nova instância da classe WellKnownClientTypeEntry com o tipo, o nome do assembly e a URL especificados.Initializes a new instance of the WellKnownClientTypeEntry class with the given type, assembly name, and URL. |
| WellKnownClientTypeEntry(Type, String) |
Inicializa uma nova instância da classe WellKnownClientTypeEntry com o tipo e a URL determinados.Initializes a new instance of the WellKnownClientTypeEntry class with the given type and URL. |
Propriedades
| ApplicationUrl |
Obtém ou define a URL do aplicativo no qual o tipo será ativado.Gets or sets the URL of the application to activate the type in. |
| AssemblyName |
Obtém o nome do assembly do tipo de objeto configurado para ser um tipo de ativação remota.Gets the assembly name of the object type configured to be a remote-activated type. (Herdado de TypeEntry) |
| ObjectType |
Obtém o Type do tipo de cliente ativado pelo servidor.Gets the Type of the server-activated client type. |
| ObjectUrl |
Obtém a URL do objeto de cliente ativado pelo servidor.Gets the URL of the server-activated client object. |
| TypeName |
Obtém o nome de tipo completo do tipo de objeto configurado para ser um tipo de ativação remota.Gets the full type name of the object type configured to be a remote-activated type. (Herdado de TypeEntry) |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (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.Returns the full type name, assembly name, and object URL of the server-activated client type as a String. |