ActivatedServiceTypeEntry 类
定义
将在服务端注册的对象类型的值保存为可以应客户端请求激活的类型。Holds values for an object type registered on the service end as one that can be activated on request from a client.
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
- 继承
- 属性
示例
#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
注解
当前类由方法使用,该 RemotingConfiguration.RegisterActivatedServiceType 方法是方法的服务器端对应项 RemotingConfiguration.RegisterActivatedClientType 。The current class is used by the RemotingConfiguration.RegisterActivatedServiceType method, which is the server-side counterpart of the RemotingConfiguration.RegisterActivatedClientType method. 在 RegisterActivatedServiceType 服务器上使用方法可允许指定对象类型的客户端进行远程激活。The RegisterActivatedServiceType method is used on the server to allow remote activation by clients of specified object types.
若要在服务器上创建客户端激活的对象,您必须知道其 Type ,并且必须通过使用方法在服务器端上注册它 RegisterActivatedServiceType 。To create a client-activated object on the server, you must know its Type, and it must be registered on the server end by using the RegisterActivatedServiceType method. 若要为新的客户端激活对象获取代理,客户端必须首先向注册通道 ChannelServices ,然后通过调用或激活该对象 new Activator.CreateInstance 。To obtain a proxy for a new client-activated object, the client must first register a channel with ChannelServices and then activate the object by calling new or Activator.CreateInstance.
若要使用关键字激活客户端激活的对象类型 new ,必须先使用方法在客户端上注册对象类型 RegisterActivatedClientType 。To activate a client-activated object type with the new keyword, you must first register the object type on the client using the RegisterActivatedClientType method. 调用时, RegisterActivatedClientType 将为远程处理基础结构提供尝试创建远程应用程序的位置 new 。By calling RegisterActivatedClientType you are giving the remoting infrastructure the location of the remote application where new attempts to create it. 另一方面,如果使用 CreateInstance 方法创建客户端激活对象的新实例,则必须提供远程应用程序的 URL 作为参数,因此,不需要在客户端上进行注册。If, on the other hand, you use the CreateInstance method to create a new instance of the client-activated object, you must supply the remote application's URL as a parameter, so no prior registration on the client is necessary. 若要为该 CreateInstance 方法提供要在其上创建对象的服务器的 url,则必须将该 url 封装在类的实例中 UrlAttribute 。To supply the CreateInstance method with the URL of the server on which you want to create the object, you must encapsulate the URL in an instance of the UrlAttribute class.
有关客户端激活的对象和远程对象激活的详细说明,请参阅 激活远程对象。For a detailed description of client-activated objects and remote object activation, see Activation of Remote Objects.
构造函数
| ActivatedServiceTypeEntry(String, String) |
用给定的类型名称和程序集名称初始化 ActivatedServiceTypeEntry 类的新实例。Initializes a new instance of the ActivatedServiceTypeEntry class with the given type name and assembly name. |
| ActivatedServiceTypeEntry(Type) |
用给定的 ActivatedServiceTypeEntry 初始化 Type 类的新实例。Initializes a new instance of the ActivatedServiceTypeEntry class with the given Type. |
属性
| AssemblyName |
获取配置为远程激活类型的对象类型的程序集名称。Gets the assembly name of the object type configured to be a remote-activated type. (继承自 TypeEntry) |
| ContextAttributes |
获取或设置客户端激活服务类型的上下文特性。Gets or sets the context attributes for the client-activated service type. |
| ObjectType |
获取客户端激活服务类型的 Type。Gets the Type of the client-activated service type. |
| TypeName |
获取配置为远程激活类型的对象类型的完整类型名。Gets the full type name of the object type configured to be a remote-activated type. (继承自 TypeEntry) |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
以 String 的形式返回客户端激活服务类型的类型名称和程序集名称。Returns the type and assembly name of the client-activated service type as a String. |