ServiceDescriptionBaseCollection 類別

定義

構成為 System.Web.Services.Description 命名空間成員的強類型集合基礎。

public ref class ServiceDescriptionBaseCollection abstract : System::Collections::CollectionBase
public abstract class ServiceDescriptionBaseCollection : System.Collections.CollectionBase
type ServiceDescriptionBaseCollection = class
    inherit CollectionBase
Public MustInherit Class ServiceDescriptionBaseCollection
Inherits CollectionBase
繼承
ServiceDescriptionBaseCollection
衍生

範例

static void MyMethod( ServiceDescriptionBaseCollection^ myServiceCollection )
{
   Type^ myType = myServiceCollection->GetType();
   if ( myType->Equals( System::Web::Services::Description::ServiceCollection::typeid ) )
   {
      // Remove the services at index 0 of the collection.
      (dynamic_cast<ServiceCollection^>(myServiceCollection))->Remove( myServiceDescription->Services[ 0 ] );

      // Build a new Service.
      Service^ myService = gcnew Service;
      myService->Name = "MathService";
      XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" );

      // Build a new Port for SOAP.
      Port^ mySoapPort = gcnew Port;
      mySoapPort->Name = "MathServiceSoap";
      mySoapPort->Binding = myXmlQualifiedName;
      SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding;
      mySoapAddressBinding->Location = "http://localhost/"
      "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      mySoapPort->Extensions->Add( mySoapAddressBinding );

      // Build a new Port for HTTP-GET.
      XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" );
      Port^ myHttpGetPort = gcnew Port;
      myHttpGetPort->Name = "MathServiceHttpGet";
      myHttpGetPort->Binding = myXmlQualifiedName2;
      HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding;
      myHttpAddressBinding->Location = "http://localhost/"
      "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      myHttpGetPort->Extensions->Add( myHttpAddressBinding );

      // Add the ports to the Service.
      myService->Ports->Add( myHttpGetPort );
      myService->Ports->Add( mySoapPort );

      // Add the Service to the ServiceCollection.
      myServiceDescription->Services->Add( myService );
   }
   else
   if ( myType->Equals( System::Web::Services::Description::BindingCollection::typeid ) )
   {
      // Remove the Binding in the BindingCollection at index 0.
      (dynamic_cast<BindingCollection^>(myServiceCollection))->Remove( myServiceDescription->Bindings[ 0 ] );

      // Build a new Binding.
      Binding^ myBinding = gcnew Binding;
      myBinding->Name = "MathServiceSoap";
      XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" );
      myBinding->Type = myXmlQualifiedName;
      SoapBinding^ mySoapBinding = gcnew SoapBinding;
      mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http";
      mySoapBinding->Style = SoapBindingStyle::Document;

      // Create the operations for the binding.
      OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace );
      OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace );

      // Add the operations to the Binding.
      myBinding->Operations->Add( subtractOperationBinding );
      myBinding->Operations->Add( addOperationBinding );
      myBinding->Extensions->Add( mySoapBinding );

      // Add the Binding to the Bindings collection.
      myServiceDescription->Bindings->Add( myBinding );
   }
   else
   if ( myType->Equals( System::Web::Services::Description::PortTypeCollection::typeid ) )
   {
      // Remove the PortType at index 0.
      (dynamic_cast<PortTypeCollection^>(myServiceCollection))->Remove( myServiceDescription->PortTypes[ 0 ] );

      // Build a new PortType.
      PortType^ myPortType = gcnew PortType;
      myPortType->Name = "MathServiceSoap";

      // Build an Add Operation for the PortType.
      Operation^ myAddOperation = gcnew Operation;
      myAddOperation->Name = "Add";

      // Build the Input and Output messages for the Operations.
      OperationInput^ myOperationInputMessage1 = gcnew OperationInput;
      XmlQualifiedName^ myXmlQualifiedName1 = gcnew XmlQualifiedName( "s0:AddSoapIn" );
      myOperationInputMessage1->Message = myXmlQualifiedName1;
      OperationOutput^ myOperationOutputMessage1 = gcnew OperationOutput;
      XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:AddSoapOut" );
      myOperationOutputMessage1->Message = myXmlQualifiedName2;

      // Add the messages to the operations.
      myAddOperation->Messages->Add( myOperationInputMessage1 );
      myAddOperation->Messages->Add( myOperationOutputMessage1 );

      // Build an Add Operation for the PortType.
      Operation^ mySubtractOperation = gcnew Operation;
      mySubtractOperation->Name = "Subtract";

      // Build the Input and Output messages for the operations.
      OperationInput^ myOperationInputMessage2 = gcnew OperationInput;
      XmlQualifiedName^ myXmlQualifiedName3 = gcnew XmlQualifiedName( "s0:SubtractSoapIn" );
      myOperationInputMessage2->Message = myXmlQualifiedName3;
      OperationOutput^ myOperationOutputMessage2 = gcnew OperationOutput;
      XmlQualifiedName^ myXmlQualifiedName4 = gcnew XmlQualifiedName( "s0:SubtractSoapOut" );
      myOperationOutputMessage2->Message = myXmlQualifiedName4;

      // Add the messages to the operations.
      mySubtractOperation->Messages->Add( myOperationInputMessage2 );
      mySubtractOperation->Messages->Add( myOperationOutputMessage2 );

      // Add the operations to the PortType.
      myPortType->Operations->Add( myAddOperation );
      myPortType->Operations->Add( mySubtractOperation );

      // Add the PortType to the collection.
      myServiceDescription->PortTypes->Add( myPortType );
   }
}
public static void MyMethod(
   ServiceDescriptionBaseCollection myServiceCollection)
{
   Type myType = myServiceCollection.GetType();
   if (myType.Equals(
      typeof(System.Web.Services.Description.ServiceCollection)))
   {
      // Remove the services at index 0 of the collection.
      ((ServiceCollection)myServiceCollection).Remove(
         myServiceDescription.Services[0]);

      // Build a new Service.
      Service myService =new Service();
      myService.Name="MathService";
      XmlQualifiedName myXmlQualifiedName =
         new XmlQualifiedName("s0:MathServiceSoap");

      // Build a new Port for SOAP.
      Port mySoapPort= new Port();
      mySoapPort.Name="MathServiceSoap";
      mySoapPort.Binding=myXmlQualifiedName;
      SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
      mySoapAddressBinding.Location = "http://localhost/" +
         "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      mySoapPort.Extensions.Add(mySoapAddressBinding);

      // Build a new Port for HTTP-GET.
      XmlQualifiedName myXmlQualifiedName2 =
         new XmlQualifiedName("s0:MathServiceHttpGet");
      Port myHttpGetPort= new Port();
      myHttpGetPort.Name="MathServiceHttpGet";
      myHttpGetPort.Binding=myXmlQualifiedName2;
      HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
      myHttpAddressBinding.Location = "http://localhost/" +
         "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx";
      myHttpGetPort.Extensions.Add(myHttpAddressBinding);

      // Add the ports to the Service.
      myService.Ports.Add(myHttpGetPort);
      myService.Ports.Add(mySoapPort);

      // Add the Service to the ServiceCollection.
      myServiceDescription.Services.Add(myService);
   }
   else if(myType.Equals(
      typeof(System.Web.Services.Description.BindingCollection)))
   {
      // Remove the Binding in the BindingCollection at index 0.
      ((BindingCollection)myServiceCollection).Remove(
         myServiceDescription.Bindings[0]);

      // Build a new Binding.
      Binding myBinding = new Binding();
      myBinding.Name = "MathServiceSoap";
      XmlQualifiedName myXmlQualifiedName =
         new XmlQualifiedName("s0:MathServiceSoap");
      myBinding.Type=myXmlQualifiedName;
      SoapBinding mySoapBinding = new SoapBinding();
      mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
      mySoapBinding.Style = SoapBindingStyle.Document;

      // Create the operations for the binding.
      OperationBinding addOperationBinding = CreateOperationBinding(
         "Add", myServiceDescription.TargetNamespace);
      OperationBinding subtractOperationBinding = CreateOperationBinding(
         "Subtract",myServiceDescription.TargetNamespace);

      // Add the operations to the Binding.
      myBinding.Operations.Add(subtractOperationBinding);
      myBinding.Operations.Add(addOperationBinding);
      myBinding.Extensions.Add(mySoapBinding);

      // Add the Binding to the Bindings collection.
      myServiceDescription.Bindings.Add(myBinding);
   }
   else if (myType.Equals(
      typeof(System.Web.Services.Description.PortTypeCollection)))
   {
      // Remove the PortType at index 0.
      ((PortTypeCollection)myServiceCollection).Remove(
         myServiceDescription.PortTypes[0]);

      // Build a new PortType.
       PortType myPortType = new PortType();
       myPortType.Name = "MathServiceSoap";

      // Build an Add Operation for the PortType.
       Operation myAddOperation = new Operation();
       myAddOperation.Name="Add";

       // Build the Input and Output messages for the Operations.
       OperationInput myOperationInputMessage1 = new OperationInput();
       XmlQualifiedName myXmlQualifiedName1 =
          new XmlQualifiedName("s0:AddSoapIn");
       myOperationInputMessage1.Message = myXmlQualifiedName1;

       OperationOutput myOperationOutputMessage1 = new OperationOutput();
       XmlQualifiedName myXmlQualifiedName2 =
          new XmlQualifiedName("s0:AddSoapOut");
       myOperationOutputMessage1.Message=myXmlQualifiedName2;

       // Add the messages to the operations.
       myAddOperation.Messages.Add(myOperationInputMessage1);
       myAddOperation.Messages.Add(myOperationOutputMessage1);

       // Build an Add Operation for the PortType.
       Operation mySubtractOperation = new Operation();
       mySubtractOperation.Name = "Subtract";

       // Build the Input and Output messages for the operations.
       OperationInput myOperationInputMessage2 = new OperationInput();
       XmlQualifiedName myXmlQualifiedName3 =
          new XmlQualifiedName("s0:SubtractSoapIn");
       myOperationInputMessage2.Message = myXmlQualifiedName3;
       OperationOutput myOperationOutputMessage2 = new OperationOutput();
       XmlQualifiedName myXmlQualifiedName4 =
          new XmlQualifiedName("s0:SubtractSoapOut");
       myOperationOutputMessage2.Message = myXmlQualifiedName4;

       // Add the messages to the operations.
       mySubtractOperation.Messages.Add(myOperationInputMessage2);
       mySubtractOperation.Messages.Add(myOperationOutputMessage2);

       // Add the operations to the PortType.
       myPortType.Operations.Add(myAddOperation);
       myPortType.Operations.Add(mySubtractOperation);

       // Add the PortType to the collection.
       myServiceDescription.PortTypes.Add(myPortType);
   }
 }
Public Shared Sub MyMethod(myServiceCollection As _
   ServiceDescriptionBaseCollection)
   Dim myType As Type = myServiceCollection.GetType()
   If myType.Equals( _
      GetType(System.Web.Services.Description.ServiceCollection)) Then

      ' Remove the services at index 0 of the collection.
      CType(myServiceCollection, ServiceCollection).Remove( _
         myServiceDescription.Services(0))

      ' Build a new Service.
      Dim myService As New Service()
      myService.Name = "MathService"
      Dim myXmlQualifiedName As _
         New XmlQualifiedName("s0:MathServiceSoap")

      ' Build a new Port for SOAP.
      Dim mySoapPort As New Port()
      mySoapPort.Name = "MathServiceSoap"
      mySoapPort.Binding = myXmlQualifiedName
      Dim mySoapAddressBinding As New SoapAddressBinding()
      mySoapAddressBinding.Location = "http://localhost/" & _
         "ServiceDescriptionBaseCollection_VB/AddSubtractService.VB.asmx"
      mySoapPort.Extensions.Add(mySoapAddressBinding)

      ' Build a new Port for HTTP-GET.
      Dim myXmlQualifiedName2 As _
         New XmlQualifiedName("s0:MathServiceHttpGet")
      Dim myHttpGetPort As New Port()
      myHttpGetPort.Name = "MathServiceHttpGet"
      myHttpGetPort.Binding = myXmlQualifiedName2
      Dim myHttpAddressBinding As New HttpAddressBinding()
      myHttpAddressBinding.Location = "http://localhost/" & _
         "ServiceDescriptionBaseCollection_VB/AddSubtractService.VB.asmx"
      myHttpGetPort.Extensions.Add(myHttpAddressBinding)

      ' Add the ports to the Service.
      myService.Ports.Add(myHttpGetPort)
      myService.Ports.Add(mySoapPort)

      ' Add the Service to the ServiceCollection.
      myServiceDescription.Services.Add(myService)
   Else
      If myType.Equals( _
         GetType(System.Web.Services.Description.BindingCollection)) Then

         ' Remove the Binding in the BindingCollection at index 0.
         CType(myServiceCollection, BindingCollection).Remove( _
            myServiceDescription.Bindings(0))

         ' Build a new Binding.
         Dim myBinding As New Binding()
         myBinding.Name = "MathServiceSoap"
         Dim myXmlQualifiedName As _
            New XmlQualifiedName("s0:MathServiceSoap")
         myBinding.Type = myXmlQualifiedName
         Dim mySoapBinding As New SoapBinding()
         mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"
         mySoapBinding.Style = SoapBindingStyle.Document

         ' Create the operations for the binding.
         Dim addOperationBinding As OperationBinding = _
            CreateOperationBinding("Add", _
            myServiceDescription.TargetNamespace)
         Dim subtractOperationBinding As OperationBinding = _
            CreateOperationBinding("Subtract", _
            myServiceDescription.TargetNamespace)

         ' Add the operations to the Binding.
         myBinding.Operations.Add(subtractOperationBinding)
         myBinding.Operations.Add(addOperationBinding)
         myBinding.Extensions.Add(mySoapBinding)

         ' Add the Binding to the Bindings collection.
         myServiceDescription.Bindings.Add(myBinding)
      Else
         If myType.Equals( _ 
            GetType(System.Web.Services.Description.PortTypeCollection)) Then

            ' Remove the PortType at index 0.
            CType(myServiceCollection, PortTypeCollection).Remove( _ 
               myServiceDescription.PortTypes(0))

            ' Build a new PortType.
            Dim myPortType As New PortType()
            myPortType.Name = "MathServiceSoap"

            ' Build an AddOperation for the PortType.
            Dim myAddOperation As New Operation()
            myAddOperation.Name = "Add"

            ' Build the Input and Output messages for the Operations.
            Dim myOperationInputMessage1 As New OperationInput()
            Dim myXmlQualifiedName1 As New XmlQualifiedName("s0:AddSoapIn")
            myOperationInputMessage1.Message = myXmlQualifiedName1
            
            Dim myOperationOutputMessage1 As New OperationOutput()
            Dim myXmlQualifiedName2 As New XmlQualifiedName("s0:AddSoapOut")
            myOperationOutputMessage1.Message = myXmlQualifiedName2

            ' Add the messages to the operations.
            myAddOperation.Messages.Add(myOperationInputMessage1)
            myAddOperation.Messages.Add(myOperationOutputMessage1)

            ' Build an Add Operation for the PortType.
            Dim mySubtractOperation As New Operation()
            mySubtractOperation.Name = "Subtract"

            ' Build the Input and Output messages for the operations.
            Dim myOperationInputMessage2 As New OperationInput()
            Dim myXmlQualifiedName3 As _
               New XmlQualifiedName("s0:SubtractSoapIn")
            myOperationInputMessage2.Message = myXmlQualifiedName3
            Dim myOperationOutputMessage2 As New OperationOutput()
            Dim myXmlQualifiedName4 As _
               New XmlQualifiedName("s0:SubtractSoapOut")
            myOperationOutputMessage2.Message = myXmlQualifiedName4

            ' Add the messages to the operations.
            mySubtractOperation.Messages.Add(myOperationInputMessage2)
            mySubtractOperation.Messages.Add(myOperationOutputMessage2)

            ' Add the operations to the PortType.
            myPortType.Operations.Add(myAddOperation)
            myPortType.Operations.Add(mySubtractOperation)

            ' Add the PortType to the collection.
            myServiceDescription.PortTypes.Add(myPortType)
         End If
      End If
   End If
End Sub

屬性

Capacity

取得或設定 CollectionBase 可包含的項目數目。

(繼承來源 CollectionBase)
Count

取得 CollectionBase 執行個體中包含的元素數目。 這個屬性無法覆寫。

(繼承來源 CollectionBase)
InnerList

取得包含 ArrayList 執行個體中之元素清單的 CollectionBase

(繼承來源 CollectionBase)
List

取得包含 IList 執行個體中之元素清單的 CollectionBase

(繼承來源 CollectionBase)
Table

取得實作 ServiceDescriptionBaseCollection 中索引鍵和數值關聯的介面。

方法

Clear()

CollectionBase 執行個體移除所有的物件。 無法覆寫這個方法。

(繼承來源 CollectionBase)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回可逐一查看 CollectionBase 執行個體的列舉值。

(繼承來源 CollectionBase)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetKey(Object)

傳回與以傳址 (By Reference) 方式傳遞的數值相關聯的索引鍵名稱。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnClear()

清除 ServiceDescriptionBaseCollection 執行個體的內容。

OnClearComplete()

在清除 CollectionBase 執行個體的內容後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnInsert(Int32, Object)

在將新的元素插入至 CollectionBase 執行個體前,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnInsertComplete(Int32, Object)

當插入新的項目至 ServiceDescriptionBaseCollection 時,執行額外的自訂處理。

OnRemove(Int32, Object)

ServiceDescriptionBaseCollection 移除項目。

OnRemoveComplete(Int32, Object)

在從 CollectionBase 執行個體移除元素後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnSet(Int32, Object, Object)

ServiceDescriptionBaseCollection 內以一個值取代另一個值。

OnSetComplete(Int32, Object, Object)

CollectionBase 執行個體中設定數值後,執行額外的自訂處理序。

(繼承來源 CollectionBase)
OnValidate(Object)

當驗證數值時,執行額外的自訂處理序。

(繼承來源 CollectionBase)
RemoveAt(Int32)

移除 CollectionBase 執行個體之指定索引的元素。 這個方法不可覆寫。

(繼承來源 CollectionBase)
SetParent(Object, Object)

設定 ServiceDescriptionBaseCollection 執行個體的父代 (Parent) 物件。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 CollectionBase 複製到相容的一維 Array

(繼承來源 CollectionBase)
ICollection.IsSynchronized

取得值,這個值表示對 CollectionBase 的存取是否同步 (安全執行緒)。

(繼承來源 CollectionBase)
ICollection.SyncRoot

取得可用以同步存取 CollectionBase 的物件。

(繼承來源 CollectionBase)
IList.Add(Object)

將物件加入至 CollectionBase 的末端。

(繼承來源 CollectionBase)
IList.Contains(Object)

判斷 CollectionBase 是否包含特定項目。

(繼承來源 CollectionBase)
IList.IndexOf(Object)

搜尋指定的 Object,並傳回在整個 CollectionBase 中第一個符合項目之以零為起始的索引。

(繼承來源 CollectionBase)
IList.Insert(Int32, Object)

將項目插入至 CollectionBase 中指定的索引位置。

(繼承來源 CollectionBase)
IList.IsFixedSize

取得值,指出 CollectionBase 是否有固定的大小。

(繼承來源 CollectionBase)
IList.IsReadOnly

取得值,指出 CollectionBase 是否唯讀。

(繼承來源 CollectionBase)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。

(繼承來源 CollectionBase)
IList.Remove(Object)

CollectionBase 移除特定物件之第一個符合的元素。

(繼承來源 CollectionBase)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於