ActivatedServiceTypeEntry Класс

Определение

Содержит значения для типа объекта, зарегистрированного в конце службы, как один, который можно активировать по запросу от клиента.

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
Наследование
ActivatedServiceTypeEntry
Атрибуты

Примеры

#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 метода. Метод RegisterActivatedServiceType используется на сервере, чтобы разрешить удаленную активацию клиентами указанных типов объектов.

Чтобы создать на сервере объект, активируемый клиентом, необходимо знать его Typeи зарегистрировать его на сервере RegisterActivatedServiceType с помощью метода. Чтобы получить прокси-сервер для нового объекта, активированного клиентом, клиент должен сначала зарегистрировать канал, ChannelServices а затем активировать объект путем вызова new или Activator.CreateInstance.

Чтобы активировать тип объекта, активированного клиентом, с new ключевым словом, необходимо сначала зарегистрировать тип объекта на клиенте RegisterActivatedClientType с помощью метода. Вызывая RegisterActivatedClientType инфраструктуру удаленного взаимодействия, вы отправляете расположение удаленного приложения, где new пытается создать его. Если, с другой стороны, вы используете CreateInstance метод для создания нового экземпляра объекта, активированного клиентом, необходимо указать URL-адрес удаленного приложения в качестве параметра, поэтому предварительная регистрация на клиенте не требуется. Чтобы предоставить CreateInstance метод с URL-адресом сервера, на котором требуется создать объект, необходимо инкапсулировать URL-адрес в экземпляре UrlAttribute класса.

Конструкторы

Имя Описание
ActivatedServiceTypeEntry(String, String)

Инициализирует новый экземпляр ActivatedServiceTypeEntry класса с заданным именем типа и именем сборки.

ActivatedServiceTypeEntry(Type)

Инициализирует новый экземпляр ActivatedServiceTypeEntry класса с заданным Type.

Свойства

Имя Описание
AssemblyName

Возвращает имя сборки типа объекта, настроенного для удаленной активации.

(Унаследовано от TypeEntry)
ContextAttributes

Возвращает или задает атрибуты контекста для типа службы, активируемого клиентом.

ObjectType

Type Возвращает тип службы, активируемый клиентом.

TypeName

Возвращает полное имя типа объекта, настроенного для удаленно активированного типа.

(Унаследовано от TypeEntry)

Методы

Имя Описание
Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит в качестве хэш-функции по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает Type текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неглубокую копию текущей Object.

(Унаследовано от Object)
ToString()

Возвращает имя типа и сборки типа службы, активируемого клиентом String, в качестве.

Применяется к

См. также раздел