IChannelDataStore Interfejs

Definicja

Przechowuje dane kanału dla kanałów komunikacji zdalniej.

C#
public interface IChannelDataStore
C#
[System.Runtime.InteropServices.ComVisible(true)]
public interface IChannelDataStore
Pochodne
Atrybuty

Przykłady

C#
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Services;
using System.Security.Permissions;

public class ServerProcess
{
   public static void Main()
   {

      TcpChannel myChannel = new TcpChannel(8085);
      ChannelServices.RegisterChannel(myChannel);

      MyServiceClass myService  = new MyServiceClass();

      // After the channel is registered, register the object
      // with remoting infrastructure by calling Marshal method.
      ObjRef myObjRef = RemotingServices.Marshal(myService,"TcpService");

      // Get the information contributed by active channel.
      IChannelInfo myChannelInfo = myObjRef.ChannelInfo;
      IChannelDataStore myIChannelData;
      foreach(object myChannelData in myChannelInfo.ChannelData)
      {
         if(myChannelData is IChannelDataStore)
         {
            myIChannelData = (IChannelDataStore)myChannelData;
            foreach(string myUri in myIChannelData.ChannelUris)
               Console.WriteLine("Channel Uris are -> " + myUri);
            // Add custom data.
            string myKey = "Key1";
            myIChannelData[myKey] = "My Data";
            Console.WriteLine(myIChannelData[myKey].ToString());
         }
      }

   }
}

// Marshal ByRef Object class.
public class MyServiceClass : MarshalByRefObject
{
   public string HelloWorld()
   {
      return "Hello World";
   }
}

Uwagi

Kanały, które chcą używać architektury ujścia kanału, muszą zaimplementować ten interfejs w swoim ChannelData obiekcie.

Właściwości

ChannelUris

Pobiera tablicę identyfikatorów URI kanału, do których mapuje bieżący kanał.

Item[Object]

Pobiera lub ustawia obiekt danych skojarzony z określonym kluczem dla kanału implementowania.

Dotyczy

Produkt Wersje
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1