ServiceDescriptionFormatExtensionCollection Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Представляет коллекцию элементов расширяемости, используемых веб-службой XML. Этот класс не наследуется.
public ref class ServiceDescriptionFormatExtensionCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class ServiceDescriptionFormatExtensionCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type ServiceDescriptionFormatExtensionCollection = class
inherit ServiceDescriptionBaseCollection
Public NotInheritable Class ServiceDescriptionFormatExtensionCollection
Inherits ServiceDescriptionBaseCollection
- Наследование
Примеры
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
ref class MyFormatExtension: public ServiceDescriptionFormatExtension
{
public:
MyFormatExtension()
{
// Set the properties.
this->Handled = true;
this->Required = true;
}
};
int main()
{
try
{
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "Sample_cpp.wsdl" );
ServiceDescriptionFormatExtensionCollection^ myCollection = gcnew ServiceDescriptionFormatExtensionCollection( myServiceDescription );
SoapBinding^ mySoapBinding1 = gcnew SoapBinding;
SoapBinding^ mySoapBinding2 = gcnew SoapBinding;
SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding;
MyFormatExtension^ myFormatExtensionObject = gcnew 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() );
// Check element of type 'SoapAddressBinding' in collection.
Object^ myObj = myCollection->Find( mySoapAddressBinding->GetType() );
if ( myObj == nullptr )
Console::WriteLine( "Element of type ' {0}' not found in collection.", mySoapAddressBinding->GetType() );
else
Console::WriteLine( "Element of type ' {0}' found in collection.", mySoapAddressBinding->GetType() );
// Check all elements of type 'SoapBinding' in collection.
array<Object^>^myObjectArray1 = gcnew array<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, mySoapBinding1->GetType() );
// Check 'IsHandled' status for 'myFormatExtensionObject' object in collection.
Console::WriteLine( "'IsHandled' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsHandled( myFormatExtensionObject ) );
// Check 'IsRequired' status for 'myFormatExtensionObject' object in collection.
Console::WriteLine( "'IsRequired' status for {0} object is {1}.", myFormatExtensionObject, myCollection->IsRequired( myFormatExtensionObject ) );
// Copy elements of collection to an Object array.
array<Object^>^myObjectArray2 = gcnew array<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 ) );
// 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 );
}
}
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);
}
}
}
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
End Class
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
End Class
Комментарии
Эта коллекция может содержать экземпляры классов, производных от ServiceDescriptionFormatExtensionкласса или экземпляров XmlElement класса. В производном классе класс позволяет пользователям определять элементы расширяемости в дополнение к элементам, ServiceDescriptionFormatExtension определенным в спецификации языка описания веб-служб (WSDL). Используйте их в вашем ServiceDescriptionFormatExtensionCollection случае, если вы заранее знаете тип элемента расширяемости, который вы хотите сделать. Используйте, XmlElement когда вы заранее не знаете формат элемента.
Конструкторы
| Имя | Описание |
|---|---|
| ServiceDescriptionFormatExtensionCollection(Object) |
Инициализирует новый экземпляр класса ServiceDescriptionFormatExtensionCollection. |
Свойства
| Имя | Описание |
|---|---|
| Capacity |
Возвращает или задает количество элементов, которые CollectionBase могут содержаться. (Унаследовано от CollectionBase) |
| Count |
Возвращает количество элементов, содержащихся в экземпляре CollectionBase . Это свойство нельзя переопределить. (Унаследовано от CollectionBase) |
| InnerList |
ArrayList Возвращает список элементов в экземпляреCollectionBase. (Унаследовано от CollectionBase) |
| Item[Int32] |
Возвращает или задает значение элемента ServiceDescriptionFormatExtensionCollectionэлемента . |
| List |
IList Возвращает список элементов в экземпляреCollectionBase. (Унаследовано от CollectionBase) |
| Table |
Возвращает интерфейс, реализующий связь ключей и значений в объекте ServiceDescriptionBaseCollection. (Унаследовано от ServiceDescriptionBaseCollection) |
Методы
| Имя | Описание |
|---|---|
| Add(Object) |
Добавляет указанный ServiceDescriptionFormatExtension в конец ServiceDescriptionFormatExtensionCollection. |
| Clear() |
Удаляет все объекты из экземпляра CollectionBase . Этот метод не может быть переопределен. (Унаследовано от CollectionBase) |
| Contains(Object) |
Возвращает значение, указывающее, является ли указанный ServiceDescriptionFormatExtension элементом ServiceDescriptionFormatExtensionCollection. |
| CopyTo(Object[], Int32) |
Копирует весь массив ServiceDescriptionFormatExtensionCollection в одномерный массив типа ServiceDescriptionFormatExtension, начиная с указанного отсчитываемого от нуля индекса целевого массива. |
| Equals(Object) |
Определяет, равен ли указанный объект текущему объекту. (Унаследовано от Object) |
| Find(String, String) |
ServiceDescriptionFormatExtensionCollection Выполняет поиск элемента с указанным именем и универсальным кодом ресурса (URI) пространства имен. |
| Find(Type) |
ServiceDescriptionFormatExtensionCollection Выполняет поиск и возвращает первый элемент указанного производногоType. |
| FindAll(String, String) |
ServiceDescriptionFormatExtensionCollection Выполняет поиск и возвращает массив всех элементов с указанным именем и универсальным кодом ресурса (URI) пространства имен. |
| FindAll(Type) |
ServiceDescriptionFormatExtensionCollection Выполняет поиск и возвращает массив всех элементов указанного объектаType. |
| GetEnumerator() |
Возвращает перечислитель, который выполняет итерацию по экземпляру CollectionBase . (Унаследовано от CollectionBase) |
| GetHashCode() |
Служит хэш-функцией по умолчанию. (Унаследовано от Object) |
| GetKey(Object) |
Возвращает имя ключа, связанного со значением, переданным по ссылке. (Унаследовано от ServiceDescriptionBaseCollection) |
| GetType() |
Возвращает Type текущего экземпляра. (Унаследовано от Object) |
| IndexOf(Object) |
Выполняет поиск указанного ServiceDescriptionFormatExtension и возвращает отсчитываемый от нуля индекс первого экземпляра с коллекцией. |
| Insert(Int32, Object) |
Добавляет указанный ServiceDescriptionFormatExtensionServiceDescriptionFormatExtensionCollection в указанный отсчитываемый от нуля индекс. |
| IsHandled(Object) |
Возвращает значение, указывающее, используется ли указанный объект процессом импорта при импорте элемента расширяемости в веб-службу XML. |
| IsRequired(Object) |
Возвращает значение, указывающее, необходим ли указанный объект для работы веб-службы XML. |
| MemberwiseClone() |
Создает неглубокую копию текущей Object. (Унаследовано от Object) |
| OnClear() |
Очищает содержимое экземпляра ServiceDescriptionBaseCollection . (Унаследовано от ServiceDescriptionBaseCollection) |
| OnClearComplete() |
Выполняет дополнительные пользовательские процессы после очистки содержимого экземпляра CollectionBase . (Унаследовано от CollectionBase) |
| OnInsert(Int32, Object) |
Выполняет дополнительные пользовательские процессы перед вставкой нового элемента в CollectionBase экземпляр. (Унаследовано от CollectionBase) |
| OnInsertComplete(Int32, Object) |
Выполняет дополнительные пользовательские процессы после вставки нового элемента в объект ServiceDescriptionBaseCollection. (Унаследовано от ServiceDescriptionBaseCollection) |
| OnRemove(Int32, Object) |
Удаляет элемент из элемента ServiceDescriptionBaseCollection. (Унаследовано от ServiceDescriptionBaseCollection) |
| OnRemoveComplete(Int32, Object) |
Выполняет дополнительные пользовательские процессы после удаления элемента из экземпляра CollectionBase . (Унаследовано от CollectionBase) |
| OnSet(Int32, Object, Object) |
Заменяет одно значение другим в пределах ServiceDescriptionBaseCollection. (Унаследовано от ServiceDescriptionBaseCollection) |
| OnSetComplete(Int32, Object, Object) |
Выполняет дополнительные пользовательские процессы после задания значения в экземпляре CollectionBase . (Унаследовано от CollectionBase) |
| OnValidate(Object) |
Выполняет дополнительные пользовательские процессы при проверке значения. (Унаследовано от CollectionBase) |
| Remove(Object) |
Удаляет первое вхождение указанного ServiceDescriptionFormatExtension из него ServiceDescriptionFormatExtensionCollection. |
| RemoveAt(Int32) |
Удаляет элемент по указанному индексу экземпляра CollectionBase . Этот метод не переопределяется. (Унаследовано от CollectionBase) |
| SetParent(Object, Object) |
Задает родительский объект экземпляра ServiceDescriptionBaseCollection . (Унаследовано от ServiceDescriptionBaseCollection) |
| 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) |
Методы расширения
| Имя | Описание |
|---|---|
| AsParallel(IEnumerable) |
Включает параллелизацию запроса. |
| AsQueryable(IEnumerable) |
Преобразует IEnumerable в IQueryable. |
| Cast<TResult>(IEnumerable) |
Приведение элементов IEnumerable к указанному типу. |
| OfType<TResult>(IEnumerable) |
Фильтрует элементы IEnumerable на основе указанного типа. |