Поделиться через


TcpServerChannel.GetUrlsForUri(String) Метод

Определение

Возвращает массив всех URL-адресов объекта с указанным универсальным кодом ресурса (URI), находящимся в текущем экземпляре TcpChannel.

public:
 virtual cli::array <System::String ^> ^ GetUrlsForUri(System::String ^ objectUri);
public virtual string[] GetUrlsForUri (string objectUri);
abstract member GetUrlsForUri : string -> string[]
override this.GetUrlsForUri : string -> string[]
Public Overridable Function GetUrlsForUri (objectUri As String) As String()

Параметры

objectUri
String

URI объекта, для которого требуются URL-адреса.

Возвращаемое значение

String[]

Массив всех URL-адресов объекта с указанным URI, находящимся в текущем экземпляре TcpChannel.

Реализации

Примеры

В следующем примере кода показано использование GetUrlsForUri метода .

#using <system.dll>
#using <system.runtime.remoting.dll>
#using "service.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels::Tcp;
using namespace System::Collections;

int main()
{
   // Create a remotable object.
   TcpServerChannel^ tcpChannel = gcnew TcpServerChannel( 8085 );

   WellKnownServiceTypeEntry^ WKSTE =
      gcnew WellKnownServiceTypeEntry( HelloService::typeid,
         "Service",
         WellKnownObjectMode::Singleton );
   RemotingConfiguration::RegisterWellKnownServiceType( WKSTE );

   RemotingConfiguration::ApplicationName = "HelloServer";
   
   // Print out the urls for the HelloServer.
   array<String^>^ urls = tcpChannel->GetUrlsForUri( "HelloServer" );

   for each ( String^ url in urls )
   {
      System::Console::WriteLine( "{0}", url );
   }
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;

class Class1 {
   public static void Main() {

      // Create a remotable object.
      TcpServerChannel tcpChannel = new TcpServerChannel(8085);

      WellKnownServiceTypeEntry WKSTE = 
         new WellKnownServiceTypeEntry(typeof(HelloService),
                                       "Service", 
                                       WellKnownObjectMode.Singleton);
      RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

      RemotingConfiguration.ApplicationName = "HelloServer";

      // Print out the urls for the HelloServer.
      string[] urls = tcpChannel.GetUrlsForUri("HelloServer");
      
      foreach (string url in urls)
         System.Console.WriteLine("{0}", url);
   }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Tcp


Class SampleClass
   
   Public Shared Sub Main()
      ' Create a remotable object.
      Dim tcpChannel As New TcpServerChannel(8085)
      
      Dim WKSTE As New WellKnownServiceTypeEntry(GetType(HelloService), "Service", WellKnownObjectMode.Singleton)
      RemotingConfiguration.RegisterWellKnownServiceType(WKSTE)
      
      RemotingConfiguration.ApplicationName = "HelloServer"
      
      ' Print out the urls for the HelloServer.
      Dim urls As String() = tcpChannel.GetUrlsForUri("HelloServer")
      Dim url As String
      
      For Each url In  urls
         System.Console.WriteLine("{0}", url)
      Next url 
   End Sub
   
End Class

Комментарии

Этот метод используется в ChannelServices.GetUrlsForObject.

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