ServiceDescriptionFormatExtensionCollection クラス
XML Web サービスで使用される機能拡張要素のコレクションを表します。このクラスは継承できません。
この型のすべてのメンバの一覧については、ServiceDescriptionFormatExtensionCollection メンバ を参照してください。
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection
NotInheritable Public Class _
ServiceDescriptionFormatExtensionCollection
Inherits ServiceDescriptionBaseCollection
[C#]
public sealed class ServiceDescriptionFormatExtensionCollection :
ServiceDescriptionBaseCollection
[C++]
public __gc __sealed class
ServiceDescriptionFormatExtensionCollection : public
ServiceDescriptionBaseCollection
[JScript]
public class ServiceDescriptionFormatExtensionCollection extends
ServiceDescriptionBaseCollection
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
このコレクションには、 ServiceDescriptionFormatExtension の派生クラスのインスタンス、または XmlElement クラスのインスタンスのいずれかを含めることができます。派生クラスでは、 ServiceDescriptionFormatExtension クラスを使用して、Web サービス記述言語 (WSDL: Web Services Description Language) の仕様で定義された機能拡張要素を定義できます。作成する機能拡張の要素の種類があらかじめわかっている場合は、定義されたこれらの要素を ServiceDescriptionFormatExtensionCollection で使用してください。要素の書式があらかじめわからない場合は、 XmlElement を使用してください。
使用例
Imports System
Imports System.Web.Services.Description
Imports System.Collections
Class MyFormatExtension
Inherits ServiceDescriptionFormatExtension
Public Sub New()
' Set the properties.
Me.Handled = True
Me.Required = True
End Sub 'New
End Class 'MyFormatExtension
Class myCollectionSample
Shared Sub Main()
Try
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("Sample_VB.wsdl")
Dim myCollection As New ServiceDescriptionFormatExtensionCollection(myServiceDescription)
Dim mySoapBinding1 As New SoapBinding()
Dim mySoapBinding2 As New SoapBinding()
Dim mySoapAddressBinding As New SoapAddressBinding()
Dim myFormatExtensionObject As 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.
Dim i As Integer
For i = 0 To myCollection.Count - 1
Console.WriteLine(myCollection(i).GetType().ToString())
Next i
' Check element of type 'SoapAddressBinding' in collection.
Dim myObj As Object = myCollection.Find(mySoapAddressBinding.GetType())
If myObj Is Nothing Then
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())
End If
' Check all elements of type 'SoapBinding' in collection.
Dim myObjectArray1(myCollection.Count -1 ) As Object
myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType())
Dim myNumberOfElements As Integer = 0
Dim myIEnumerator As IEnumerator = myObjectArray1.GetEnumerator()
' Calculate number of elements of type 'SoapBinding'.
While myIEnumerator.MoveNext()
If mySoapBinding1.GetType() Is myIEnumerator.Current.GetType() Then
myNumberOfElements += 1
End If
End While
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.
Dim myObjectArray2(myCollection.Count -1 ) As Object
myCollection.CopyTo(myObjectArray2, 0)
Console.WriteLine("Collection elements are copied to an object array.")
' Check for 'myFormatExtension' object in collection.
If myCollection.Contains(myFormatExtensionObject) Then
' 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.")
End If
' Insert 'MyFormatExtension' object.
myCollection.Insert(0, myFormatExtensionObject)
Console.WriteLine("'myFormatExtensionObject' is inserted to collection.")
Catch e As Exception
Console.WriteLine("The following exception was raised: {0}", e.Message.ToString())
End Try
End Sub 'Main
End Class 'myCollectionSample
[C#]
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);
}
}
}
[C++]
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
__gc class MyFormatExtension : public ServiceDescriptionFormatExtension
{
public:
MyFormatExtension()
{
// Set the properties.
this->Handled = true;
this->Required = true;
}
};
int main()
{
try
{
ServiceDescription* myServiceDescription =
ServiceDescription::Read(S"Sample_cpp.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(S"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->Item[i]->GetType());
// Check element of type 'SoapAddressBinding' in collection.
Object* myObj = myCollection->Find(mySoapAddressBinding->GetType());
if (myObj == 0)
Console::WriteLine(S"Element of type ' {0}' not found in collection.",
mySoapAddressBinding->GetType());
else
Console::WriteLine(S"Element of type ' {0}' found in collection.",
mySoapAddressBinding->GetType());
// 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(S"Collection contains {0} objects of type ' {1}'.",
__box(myNumberOfElements),
mySoapBinding1->GetType());
// Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
Console::WriteLine(S"'IsHandled' status for {0} object is {1}.",
myFormatExtensionObject,
__box(myCollection->IsHandled(myFormatExtensionObject)));
// Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
Console::WriteLine(S"'IsRequired' status for {0} object is {1}.",
myFormatExtensionObject,
__box(myCollection->IsRequired(myFormatExtensionObject)));
// Copy elements of collection to an Object array.
Object* myObjectArray2[] = new Object*[myCollection->Count];
myCollection->CopyTo(myObjectArray2, 0);
Console::WriteLine(S"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(S"Index of 'myFormatExtensionObject' is {0} in collection.",
__box(myCollection->IndexOf(myFormatExtensionObject)));
// Remove 'myFormatExtensionObject' element from collection.
myCollection->Remove(myFormatExtensionObject);
Console::WriteLine(S"'myFormatExtensionObject' is removed from collection.");
}
// Insert 'MyFormatExtension' object.
myCollection->Insert(0, myFormatExtensionObject);
Console::WriteLine(S"'myFormatExtensionObject' is inserted to collection.");
}
catch (Exception* e)
{
Console::WriteLine(S"The following exception was raised: {0}", e->Message);
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Web.Services.Description
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Web.Services (System.Web.Services.dll 内)
参照
ServiceDescriptionFormatExtensionCollection メンバ | System.Web.Services.Description 名前空間