ITransportHeaders Interface
.NET Framework 2.0
Stores a collection of headers used in the channel sinks.
Namespace: System.Runtime.Remoting.Channels
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
Imports System Imports System.Collections Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels Imports System.Runtime.Remoting.Channels.Tcp Class MyITransportHeadersClass Implements ITransportHeaders Private myInt As Integer = 0 Private myDictionaryEntry(9) As DictionaryEntry ' Implement the 'Item' property. Property ITransportHeaders(myKey As Object) As Object Implements ITransportHeaders.Item Get If Not (myKey Is Nothing) Then Dim i As Integer For i = 0 To myInt If myDictionaryEntry(i).Key = myKey Then Return myDictionaryEntry(i).Value End If Next i End If Return 0 End Get Set myDictionaryEntry(myInt) = New DictionaryEntry(myKey, value) myInt += 1 End Set End Property ' Implement the 'GetEnumerator' method. Function GetEnumerator() As IEnumerator Implements ITransportHeaders.GetEnumerator Dim myHashtable As New Hashtable() Dim j As Integer For j = 0 To myInt - 1 myHashtable.Add(myDictionaryEntry(j).Key, myDictionaryEntry(j).Value) Next j Return myHashtable.GetEnumerator() End Function 'ITransportHeaders.GetEnumerator Public Shared Sub Main() Try ' Create and register a 'TcpChannel' object. Dim myTcpChannel As New TcpChannel(8085) ChannelServices.RegisterChannel(myTcpChannel) RemotingConfiguration.RegisterWellKnownServiceType(GetType(MyHelloServer), "SayHello", _ WellKnownObjectMode.SingleCall) ' Create an instance of 'myITransportHeadersObj'. Dim myITransportHeadersObj As New MyITransportHeadersClass() Dim myITransportHeaders As ITransportHeaders = _ CType(myITransportHeadersObj, ITransportHeaders) ' Add items to the header list. myITransportHeaders("Header1") = "TransportHeader1" myITransportHeaders("Header2") = "TransportHeader2" ' Get the 'ITranportHeader' item value with key 'Header2'. Console.WriteLine("ITransport Header item value with key 'Header2' is :" + _ myITransportHeaders("Header2")) Dim myEnumerator As IEnumerator = myITransportHeaders.GetEnumerator() Console.WriteLine(" -KEY- -VALUE-") While myEnumerator.MoveNext() ' Display the 'Key' and 'Value' of the current element. Dim myEntry As Object = myEnumerator.Current Dim myDictionaryEntry As DictionaryEntry = CType(myEntry, DictionaryEntry) Console.WriteLine(" {0}: {1}", myDictionaryEntry.Key, myDictionaryEntry.Value) End While Console.WriteLine("Hit <enter> to exit...") Console.ReadLine() Catch ex As Exception Console.WriteLine("The following exception is raised on the server side: " + ex.Message) End Try End Sub 'Main End Class 'MyITransportHeadersClass
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: