This documentation is archived and is not being maintained.

SinkProviderData Class

Stores sink provider data for sink providers.

For a list of all members of this type, see SinkProviderData Members.


[Visual Basic]
Public Class SinkProviderData
public class SinkProviderData
public __gc class SinkProviderData
public class SinkProviderData

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The sink provider data is a tree structure of configuration information stored in the <provider> Element (Template) configuration nodes. All sink providers must have a constructor that accepts an IDictionary of properties and an ICollection of these structures if they want to be used from a configuration file.


[Visual Basic] 

   Public Class MySinkProviderData
      Implements IServerChannelSinkProvider
      Private myIServerChannelSinkProviderNew As IServerChannelSinkProvider

      Private myAcceptMode As Boolean = True
      Private myCollectionData As ICollection = Nothing

      Public Sub New()
      End Sub 'New

      Public Sub New(properties As IDictionary, providerData As ICollection)
         Dim myMode As String = CType(properties("mode"), String)
         If String.Compare(myMode, "accept", True) = 0 Then
            myAcceptMode = True
            If String.Compare(myMode, "reject", True) = 0 Then
               myAcceptMode = False
            End If
         End If
         myCollectionData = providerData
      End Sub 'New

      Public Sub GetChannelData(myLocalChannelData As IChannelDataStore) Implements _
      End Sub 'GetChannelData

      Public Function CreateSink(myChannel As IChannelReceiver) As IServerChannelSink Implements _
         Dim myIServerChannelSink_nextSink As IServerChannelSink = Nothing
         If Not (myIServerChannelSinkProviderNew Is Nothing) Then
            myIServerChannelSink_nextSink = myIServerChannelSinkProviderNew.CreateSink(myChannel)
         End If
         Dim mySink As New MyIPFilterChannelSink(myAcceptMode, myIServerChannelSink_nextSink)
         ' Create and initialize a new ArrayList.
         Dim myArrayList As New ArrayList()

         ' Add filters.
         Dim mySinkData As SinkProviderData
         For Each mySinkData In  myCollectionData
            ' The SinkProviderData properties are added to the ArrayList.

            Dim myMaskString As String = CType(mySinkData.Properties("mask"), String)
            Dim myIPString As String = CType(mySinkData.Properties("ip"), String)
            Dim myMachineString As String = CType(mySinkData.Properties("machine"), String)

            Dim mask As IPAddress = Nothing
            Dim ip As IPAddress = Nothing

            If Not (myIPString Is Nothing) Then
               mask = IPAddress.Parse(myMaskString)
               ip = IPAddress.Parse(myIPString)
               mask = IPAddress.Parse("")
               ip = Dns.Resolve(myMachineString).AddressList(0)
            End If

            mySink.AddFilter(mask, ip)
         Next mySinkData
         Console.WriteLine("The Count of the ArrayList is  :" + myArrayList.Count.ToString())
         Console.WriteLine("The values in the SinkProviderData collection are:")

         ' Call the PrintValues function to enumerate and print values to the console.

         Return mySink
      End Function 'CreateSink

      Public Property [Next]() As IServerChannelSinkProvider Implements _
            Return myIServerChannelSinkProviderNew
         End Get
            myIServerChannelSinkProviderNew = value
         End Set
      End Property

      Public Property Mode() As FilterMode
            Return(IIf(myAcceptMode ,FilterMode.Accept ,FilterMode.Reject))
         End Get
         Set(ByVal Value As FilterMode)
             If Value = FilterMode.Accept Then
                 myAcceptMode = Value
             End If
         End Set
      End Property

      Public Shared Sub PrintValues(myList As IEnumerable)
         Dim myEnumerator As IEnumerator = myList.GetEnumerator()
         While myEnumerator.MoveNext()
            Console.Write(ControlChars.Tab + "{0}", myEnumerator.Current)
         End While
      End Sub 'PrintValues
   End Class 'MySinkProviderData
     ' class MySinkProviderData

public class MySinkProviderData : IServerChannelSinkProvider
   private IServerChannelSinkProvider myIServerChannelSinkProviderNew;

   private bool myAcceptMode = true;
   private ICollection myCollectionData = null;

   public MySinkProviderData()

   public MySinkProviderData(IDictionary properties, ICollection providerData)
      String myMode = (String)properties["mode"];
      if (String.Compare(myMode, "accept", true) == 0)
         myAcceptMode = true;
         if (String.Compare(myMode, "reject", true) == 0)
         myAcceptMode = false;
      myCollectionData = providerData;

   public void GetChannelData(IChannelDataStore myLocalChannelData)
   public IServerChannelSink CreateSink(IChannelReceiver myChannel)
      IServerChannelSink myIServerChannelSink_nextSink = null;
      if (myIServerChannelSinkProviderNew != null)
         myIServerChannelSink_nextSink = myIServerChannelSinkProviderNew.CreateSink(myChannel);
      MyIPFilterChannelSink mySink = new MyIPFilterChannelSink(myAcceptMode,
      // Create and initialize a new ArrayList.
      ArrayList myArrayList = new ArrayList();

      // Add filters.
      foreach (SinkProviderData mySinkData in myCollectionData)
         // The SinkProviderData properties are added to the ArrayList.

         String myMaskString = (String)mySinkData.Properties["mask"];
         String myIPString = (String)mySinkData.Properties["ip"];
         String myMachineString = (String)mySinkData.Properties["machine"];

         IPAddress mask = null;
         IPAddress ip = null;

         if (myIPString != null)
            mask = IPAddress.Parse(myMaskString);
            ip = IPAddress.Parse(myIPString);
            mask = IPAddress.Parse("");
            ip = Dns.Resolve(myMachineString).AddressList[0];

         mySink.AddFilter(mask, ip);
      Console.WriteLine("The Count of the ArrayList is  :"+ myArrayList.Count);
      Console.WriteLine("The values in the SinkProviderData collection are:");

      // Call the PrintValues function to enumerate and print values to the console.
      PrintValues( myArrayList );

      return mySink;

   public IServerChannelSinkProvider Next
         return myIServerChannelSinkProviderNew;
         myIServerChannelSinkProviderNew = value;

   public FilterMode Mode
         return (myAcceptMode ? FilterMode.Accept : FilterMode.Reject);
         myAcceptMode = (value == FilterMode.Accept);

   public static void PrintValues( IEnumerable myList )
      IEnumerator myEnumerator = myList.GetEnumerator();
      while ( myEnumerator.MoveNext() )
      Console.Write( "\t{0}", myEnumerator.Current );
} // class MySinkProviderData

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Runtime.Remoting.Channels

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

SinkProviderData Members | System.Runtime.Remoting.Channels Namespace