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.

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

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