Export (0) Print
Expand All

ServiceDescriptionFormatExtensionCollection Class

Represents the collection of extensibility elements used by the XML Web service. This class cannot be inherited.

System.Object
  System.Collections.CollectionBase
    System.Web.Services.Description.ServiceDescriptionBaseCollection
      System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection

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

public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection

The ServiceDescriptionFormatExtensionCollection type exposes the following members.

  NameDescription
Public methodServiceDescriptionFormatExtensionCollectionInitializes a new instance of the ServiceDescriptionFormatExtensionCollection class.
Top

  NameDescription
Public propertyCapacityGets or sets the number of elements that the CollectionBase can contain. (Inherited from CollectionBase.)
Public propertyCountGets the number of elements contained in the CollectionBase instance. This property cannot be overridden. (Inherited from CollectionBase.)
Public propertyItemGets or sets the value of a member of the ServiceDescriptionFormatExtensionCollection.
Top

  NameDescription
Public methodAddAdds the specified ServiceDescriptionFormatExtension to the end of the ServiceDescriptionFormatExtensionCollection.
Public methodClearRemoves all objects from the CollectionBase instance. This method cannot be overridden. (Inherited from CollectionBase.)
Public methodContainsReturns a value indicating whether the specified ServiceDescriptionFormatExtension is a member of the ServiceDescriptionFormatExtensionCollection.
Public methodCopyToCopies the entire ServiceDescriptionFormatExtensionCollection into a one-dimensional array of type ServiceDescriptionFormatExtension, starting at the specified zero-based index of the target array.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodFind(Type)Searches the ServiceDescriptionFormatExtensionCollection and returns the first element of the specified derived Type.
Public methodFind(String, String)Searches the ServiceDescriptionFormatExtensionCollection for a member with the specified name and namespace URI.
Public methodFindAll(Type)Searches the ServiceDescriptionFormatExtensionCollection and returns an array of all elements of the specified Type.
Public methodFindAll(String, String)Searches the ServiceDescriptionFormatExtensionCollection and returns an array of all members with the specified name and namespace URI.
Public methodGetEnumeratorReturns an enumerator that iterates through the CollectionBase instance. (Inherited from CollectionBase.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfSearches for the specified ServiceDescriptionFormatExtension and returns the zero-based index of the first instance with the collection.
Public methodInsertAdds the specified ServiceDescriptionFormatExtension to the ServiceDescriptionFormatExtensionCollection at the specified zero-based index.
Public methodIsHandledReturns a value indicating whether the specified object is used by the import process when the extensibility element is imported into the XML Web service.
Public methodIsRequiredReturns a value indicating whether the specified object is necessary for the operation of the XML Web service.
Public methodRemoveRemoves the first occurrence of the specified ServiceDescriptionFormatExtension from the ServiceDescriptionFormatExtensionCollection.
Public methodRemoveAtRemoves the element at the specified index of the CollectionBase instance. This method is not overridable. (Inherited from CollectionBase.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the entire CollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the CollectionBase is synchronized (thread safe). (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.AddAdds an object to the end of the CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the CollectionBase contains a specific element. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.IndexOfSearches for the specified Object and returns the zero-based index of the first occurrence within the entire CollectionBase. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.InsertInserts an element into the CollectionBase at the specified index. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeGets a value indicating whether the CollectionBase has a fixed size. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyGets a value indicating whether the CollectionBase is read-only. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate propertyIList.ItemGets or sets the element at the specified index. (Inherited from CollectionBase.)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of a specific object from the CollectionBase. (Inherited from CollectionBase.)
Top

This collection can either contain instances of classes deriving from ServiceDescriptionFormatExtension, or instances of the XmlElement class. In a derived class, ServiceDescriptionFormatExtension class allows users to define extensibility elements in addition to those defined in the Web Services Description Language (WSDL) specification. Use these in your ServiceDescriptionFormatExtensionCollection if you know in advance the type of extensibility element you want to make. Use an XmlElement when you do not know the format of an element in advance.

using System;
using System.Web.Services.Description;
using System.Collections;

class MyFormatExtension : ServiceDescriptionFormatExtension 
{
   public MyFormatExtension()
   {
      // Set the properties. 
      this.Handled  = true;
      this.Required = true;
   }
}
class myCollectionSample
{
   static void Main()
   {
      try
      {
         ServiceDescription myServiceDescription = 
            ServiceDescription.Read("Sample_CS.wsdl");
         ServiceDescriptionFormatExtensionCollection  myCollection = 
            new ServiceDescriptionFormatExtensionCollection(myServiceDescription);
         SoapBinding mySoapBinding1 = new SoapBinding();
         SoapBinding mySoapBinding2 = new SoapBinding();
         SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
         MyFormatExtension  myFormatExtensionObject = new MyFormatExtension();
         // Add elements to collection.
         myCollection.Add(mySoapBinding1);
         myCollection.Add(mySoapAddressBinding);
         myCollection.Add(mySoapBinding2);
         myCollection.Add(myFormatExtensionObject);
         Console.WriteLine("Collection contains following types of elements: ");
         // Display the 'Type' of the elements in collection. 
         for(int i = 0;i< myCollection.Count;i++) 
         {
            Console.WriteLine(myCollection[i].GetType().ToString()); 
         }
         // Check element of type 'SoapAddressBinding' in collection.
         Object   myObj = myCollection.Find(mySoapAddressBinding.GetType());
         if(myObj == null)
         {
            Console.WriteLine("Element of type '{0}' not found in collection.",
               mySoapAddressBinding.GetType().ToString());
         }
         else
         {
            Console.WriteLine("Element of type '{0}' found in collection.",
               mySoapAddressBinding.GetType().ToString());
         }
         // Check all elements of type 'SoapBinding' in collection.
         Object[] myObjectArray1 = new Object[myCollection.Count];
         myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType());
         int myNumberOfElements = 0;
         IEnumerator myIEnumerator  = myObjectArray1.GetEnumerator();

         // Calculate number of elements of type 'SoapBinding'. 
         while(myIEnumerator.MoveNext())
         {
            if(mySoapBinding1.GetType() == myIEnumerator.Current.GetType())
               myNumberOfElements++;
         }
         Console.WriteLine("Collection contains {0} objects of type '{1}'.", 
                           myNumberOfElements.ToString(),
                           mySoapBinding1.GetType().ToString());
         // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsHandled' status for {0} object is {1}.",
                  myFormatExtensionObject.ToString(), 
                  myCollection.IsHandled(myFormatExtensionObject).ToString());
         // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
         Console.WriteLine("'IsRequired' status for {0} object is {1}.",
                  myFormatExtensionObject.ToString(),
                  myCollection.IsRequired(myFormatExtensionObject).ToString());
         // Copy elements of collection to an Object array.
         Object[] myObjectArray2 = new Object[myCollection.Count];
         myCollection.CopyTo(myObjectArray2,0);
         Console.WriteLine("Collection elements are copied to an object array.");
         // Check for 'myFormatExtension' object in collection. 
         if(myCollection.Contains(myFormatExtensionObject))
         {
            // Get index of a 'myFormatExtension' object in collection.
            Console.WriteLine("Index of 'myFormatExtensionObject' is "+
               "{0} in collection.",
               myCollection.IndexOf(myFormatExtensionObject).ToString());
            // Remove 'myFormatExtensionObject' element from collection.
            myCollection.Remove(myFormatExtensionObject);
            Console.WriteLine("'myFormatExtensionObject' is removed"+
                              " from collection.");
         }
         // Insert 'MyFormatExtension' object.
         myCollection.Insert(0,myFormatExtensionObject);
         Console.WriteLine("'myFormatExtensionObject' is inserted to collection.");

      }
      catch(Exception e)
      {
         Console.WriteLine("The following exception was raised: {0}", e.Message);
      }
   }
}

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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