Export (0) Print
Expand All

ServiceDescriptionFormatExtensionCollection Class

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

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

public sealed class ServiceDescriptionFormatExtensionCollection : ServiceDescriptionBaseCollection
public final class ServiceDescriptionFormatExtensionCollection extends ServiceDescriptionBaseCollection
public final class ServiceDescriptionFormatExtensionCollection extends ServiceDescriptionBaseCollection
Not applicable.

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);
      }
   }
}

import System.*;
import System.Web.Services.Description.*;
import System.Collections.*;

class MyFormatExtension extends ServiceDescriptionFormatExtension
{
    public MyFormatExtension()
    {
        // Set the properties.
        this.set_Handled(true);
        this.set_Required(true);
    } //MyFormatExtension
} //MyFormatExtension

class myCollectionSample
{
    public static void main(String[] args)
    {
        try {
            ServiceDescription myServiceDescription = 
                ServiceDescription.Read("Sample_JSL.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.get_Count(); i++) {
                Console.WriteLine(myCollection.get_Item(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.get_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()).Equals(myIEnumerator.get_Current().
                    GetType())) {
                    myNumberOfElements++;
                }
            }
            Console.WriteLine("Collection contains {0} objects of type '{1}'.", 
                System.Convert.ToString(myNumberOfElements), 
                System.Convert.ToString(mySoapBinding1.GetType()));
            
            // Check 'IsHandled' status for 'myFormatExtensionObject' object 
            // in collection.
            Console.WriteLine("'IsHandled' status for {0} object is {1}.", 
                System.Convert.ToString(myFormatExtensionObject), 
                System.Convert.ToString(myCollection.
                IsHandled(myFormatExtensionObject)));
            
            // Check 'IsRequired' status for 'myFormatExtensionObject' object 
            // in collection.
            Console.WriteLine("'IsRequired' status for {0} object is {1}.", 
                System.Convert.ToString(myFormatExtensionObject), 
                System.Convert.ToString(myCollection.
                IsRequired(myFormatExtensionObject)));
            
            // Copy elements of collection to an Object array.
            Object myObjectArray2[] = new Object[myCollection.get_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.", System.Convert.ToString(myCollection.
                    IndexOf(myFormatExtensionObject)));
                
                // 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 (System.Exception e) {
            Console.WriteLine("The following exception was raised: {0}", 
                e.get_Message());
        }
    } //main
} //myCollectionSample

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

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 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft