WellKnownServiceTypeEntry Класс

Определение

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

public ref class WellKnownServiceTypeEntry : System::Runtime::Remoting::TypeEntry
public class WellKnownServiceTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class WellKnownServiceTypeEntry : System.Runtime.Remoting.TypeEntry
type WellKnownServiceTypeEntry = class
    inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type WellKnownServiceTypeEntry = class
    inherit TypeEntry
Public Class WellKnownServiceTypeEntry
Inherits TypeEntry
Наследование
WellKnownServiceTypeEntry
Атрибуты

Примеры

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownServiceTypeEntry_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 it with the 
   // channel services.
   ChannelServices::RegisterChannel( gcnew HttpChannel( 8086 ) );

   // Record the 'HelloServer' type as 'Singleton' well-known type.
   WellKnownServiceTypeEntry^ myWellKnownServiceTypeEntry = gcnew WellKnownServiceTypeEntry( HelloServer::typeid,"SayHello",WellKnownObjectMode::Singleton );

   // Register the remote object as well-known type.
   RemotingConfiguration::RegisterWellKnownServiceType( myWellKnownServiceTypeEntry );

   // Retrieve object types registered on the service end 
   // as well-known types.
   array<WellKnownServiceTypeEntry^>^myWellKnownServiceTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownServiceTypes();
   Console::WriteLine( "The 'WellKnownObjectMode' of the remote object : {0}", myWellKnownServiceTypeEntryCollection[ 0 ]->Mode );
   Console::WriteLine( "The 'WellKnownServiceTypeEntry' object: {0}", myWellKnownServiceTypeEntryCollection[ 0 ] );
   Console::WriteLine( "Started the Server, Hit <enter> to exit..." );
   Console::ReadLine();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class MyServer 
{
   public static void Main() 
   {
      // Create a 'HttpChannel' object and register it with the 
      // channel services.
      ChannelServices.RegisterChannel(new HttpChannel(8086));
      // Record the 'HelloServer' type as 'Singleton' well-known type.
      WellKnownServiceTypeEntry myWellKnownServiceTypeEntry= 
          new WellKnownServiceTypeEntry(typeof(HelloServer),
                                        "SayHello",
                                        WellKnownObjectMode.Singleton);
      // Register the remote object as well-known type.
      RemotingConfiguration.RegisterWellKnownServiceType(
                                          myWellKnownServiceTypeEntry);
      // Retrieve object types registered on the service end 
      // as well-known types.
      WellKnownServiceTypeEntry [] myWellKnownServiceTypeEntryCollection = 
            RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
      Console.WriteLine("The 'WellKnownObjectMode' of the remote object : "
                       +myWellKnownServiceTypeEntryCollection[0].Mode);
      Console.WriteLine("The 'WellKnownServiceTypeEntry' object: "+
                  myWellKnownServiceTypeEntryCollection[0].ToString());
      Console.WriteLine("Started the Server, Hit <enter> to exit...");
      Console.ReadLine();
   }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http

Public Class MyServer
   
   Public Shared Sub Main()
      ' Create a 'HttpChannel' object and register it with the 
      ' channel services.
      ChannelServices.RegisterChannel(New HttpChannel(8086))
      ' Record the 'HelloServer' type as 'Singleton' well-known type.
      Dim myWellKnownServiceTypeEntry As New WellKnownServiceTypeEntry(GetType(HelloServer), _ 
                                                 "SayHello", WellKnownObjectMode.Singleton)
      ' Register the remote object as well-known type.
      RemotingConfiguration.RegisterWellKnownServiceType(myWellKnownServiceTypeEntry)
      ' Retrieve object types registered on the service end 
      ' as well-known types.
      Dim myWellKnownServiceTypeEntryCollection As WellKnownServiceTypeEntry() = _ 
                                      RemotingConfiguration.GetRegisteredWellKnownServiceTypes()
      Console.WriteLine("The 'WellKnownObjectMode' of the remote object : " + _
                                        myWellKnownServiceTypeEntryCollection(0).Mode.ToString())
      Console.WriteLine("The 'WellKnownServiceTypeEntry' object: " + _ 
                                             myWellKnownServiceTypeEntryCollection(0).ToString())
      Console.WriteLine("Started the Server, Hit <enter> to exit...")
      Console.ReadLine()
   End Sub
End Class

Комментарии

Типы объектов, активируемые сервером, могут быть одним вызовом или одноэлементом. Если тип объекта является одним вызовом, при каждом вызове клиента создается новый экземпляр. Все вызовы одного объекта обрабатываются одним экземпляром этого объекта.

Любой клиент, который знает универсальный код ресурса (URI) этого объекта, может получить прокси-сервер для этого объекта, зарегистрировав канал, который он предпочитает, ChannelServices и активировав объект путем вызова new или Activator.GetObject.

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

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

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

Инициализирует новый экземпляр класса с заданным именем типа, именем сборки WellKnownServiceTypeEntry , универсальным кодом ресурса (URI объекта) и WellKnownObjectMode.

WellKnownServiceTypeEntry(Type, String, WellKnownObjectMode)

Инициализирует новый экземпляр WellKnownServiceTypeEntry класса с заданным Type, URI объекта и WellKnownObjectMode.

Свойства

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

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

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

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

Mode

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

ObjectType

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

ObjectUri

Возвращает универсальный код ресурса (URI) известного типа службы.

TypeName

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

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

Методы

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

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

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

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

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

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

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

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

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

Возвращает имя типа, имя сборки, URI объекта и WellKnownObjectMode тип, активируемый сервером Stringв качестве.

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

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