This documentation is archived and is not being maintained.

DiscoveryReferenceCollection Class

A collection of discovery references. This class cannot be inherited.

Namespace:  System.Web.Services.Discovery
Assembly:  System.Web.Services (in System.Web.Services.dll)

public sealed class DiscoveryReferenceCollection : CollectionBase

using System;
using System.IO;
using System.Web.Services.Discovery;

class MyDiscoveryDocumentClass
{
   static void Main()
   {
      DiscoveryDocumentReference myDiscoveryDocReference1 = 
         new DiscoveryDocumentReference();
      DiscoveryDocumentReference myDiscoveryDocReference2 = 
         new DiscoveryDocumentReference();
      DiscoveryReference myDiscoveryReference;

      Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.");

      // Create new DiscoveryReferenceCollection.
      DiscoveryReferenceCollection myDiscoveryReferenceCollection = 
         new DiscoveryReferenceCollection();

      // Access the Count method.
      Console.WriteLine("The number of elements in the collection is: " 
         + myDiscoveryReferenceCollection.Count.ToString());

      // Add elements to the collection.
      myDiscoveryReferenceCollection.Add(myDiscoveryDocReference1);
      myDiscoveryReferenceCollection.Add(myDiscoveryDocReference2);

      Console.WriteLine("The number of elements in the collection "
         + "after adding two elements to the collection: " 
         + myDiscoveryReferenceCollection.Count.ToString());

      // Call the Contains method. 
      if (myDiscoveryReferenceCollection.Contains(myDiscoveryDocReference1) 
         != true)
      {
         throw new Exception("Element not found in collection.");
      }

      // Access the indexed member.
      myDiscoveryReference = 
         (DiscoveryReference)myDiscoveryReferenceCollection[0];
      if (myDiscoveryReference == null)
      {
         throw new Exception("Element not found in collection.");
      }

      // Remove one element from collection.
      myDiscoveryReferenceCollection.Remove(myDiscoveryDocReference1);
      Console.WriteLine("The number of elements in the collection "
         + "after removing one element is: " 
         + myDiscoveryReferenceCollection.Count.ToString());
   }
}
#using <mscorlib.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::IO;
using namespace System::Web::Services::Discovery;

int main() {
   DiscoveryDocumentReference* myDiscoveryDocReference1 =
      new DiscoveryDocumentReference();
   DiscoveryDocumentReference* myDiscoveryDocReference2 =
      new DiscoveryDocumentReference();
   DiscoveryReference* myDiscoveryReference;

   Console::WriteLine(S"Demonstrating DiscoveryReferenceCollection class.");

   // Create new DiscoveryReferenceCollection.
   DiscoveryReferenceCollection* myDiscoveryReferenceCollection =
      new DiscoveryReferenceCollection();

   // Access the Count method.
   Console::WriteLine(S"The number of elements in the collection is: {0}", 
      __box(myDiscoveryReferenceCollection->Count));

   // Add elements to the collection.
   myDiscoveryReferenceCollection->Add(myDiscoveryDocReference1);
   myDiscoveryReferenceCollection->Add(myDiscoveryDocReference2);

   Console::WriteLine(S"The number of elements in the collection after adding two elements to the collection: {0}", 
      __box(myDiscoveryReferenceCollection->Count));

   // Call the Contains method.
   if (myDiscoveryReferenceCollection->Contains(myDiscoveryDocReference1)
      != true) {
         throw new Exception(S"Element not found in collection.");
      }

      // Access the indexed member.
      myDiscoveryReference =
         dynamic_cast<DiscoveryReference*>(myDiscoveryReferenceCollection->Item[0]);
      if (myDiscoveryReference == 0) {
         throw new Exception(S"Element not found in collection.");
      }

      // Remove one element from collection.
      myDiscoveryReferenceCollection->Remove(myDiscoveryDocReference1);
      Console::WriteLine(S"The number of elements in the collection after removing one element is: {0}", 
         __box(myDiscoveryReferenceCollection->Count));
}

System.Object
  System.Collections.CollectionBase
    System.Web.Services.Discovery.DiscoveryReferenceCollection

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: