Partager via


DiscoveryExceptionDictionary Classe

Définition

Collecte les exceptions qui se sont produites pendant la découverte des services Web XML. Cette classe ne peut pas être héritée.

public ref class DiscoveryExceptionDictionary sealed : System::Collections::DictionaryBase
public sealed class DiscoveryExceptionDictionary : System.Collections.DictionaryBase
type DiscoveryExceptionDictionary = class
    inherit DictionaryBase
Public NotInheritable Class DiscoveryExceptionDictionary
Inherits DictionaryBase
Héritage
DiscoveryExceptionDictionary

Exemples

#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web::Services::Discovery;
using namespace System::Xml;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Net;

int main()
{
   String^ myDiscoFile = "http://localhost/MathService_cs.disco";
   String^ myUrlKey = "http://localhost/MathService_cs.asmx?wsdl";
   DiscoveryClientProtocol^ myDiscoveryClientProtocol1 = gcnew DiscoveryClientProtocol;
   DiscoveryDocument^ myDiscoveryDocument = myDiscoveryClientProtocol1->Discover( myDiscoFile );
   IEnumerator^ myEnumerator = myDiscoveryDocument->References->GetEnumerator();
   while ( myEnumerator->MoveNext() )
   {
      ContractReference^ myContractReference = dynamic_cast<ContractReference^>(myEnumerator->Current);
      DiscoveryClientProtocol^ myDiscoveryClientProtocol2 = myContractReference->ClientProtocol;
      myDiscoveryClientProtocol2->ResolveAll();
      
      DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol2->Errors;
      if ( myExceptionDictionary->Contains( myUrlKey ))
      {
         Console::WriteLine( "'myExceptionDictionary' contains a discovery exception for the key '{0}'", myUrlKey );
      }
      else
      {
         Console::WriteLine( "'myExceptionDictionary' does not contain a discovery exception for the key '{0}'", myUrlKey );
      }
      if ( myExceptionDictionary->Contains( myUrlKey ) )
      {
         Console::WriteLine( "System generated exceptions." );
         
         Exception^ myException = myExceptionDictionary[ myUrlKey ];
         Console::WriteLine( " Source : {0}", myException->Source );
         Console::WriteLine( " Exception : {0}", myException->Message );

         Console::WriteLine();
         
         // Remove the discovery exception.for the key 'myUrlKey'.
         myExceptionDictionary->Remove( myUrlKey );

         DiscoveryExceptionDictionary^ myNewExceptionDictionary = gcnew DiscoveryExceptionDictionary;
         
         // Add an exception with the custom error message.
         Exception^ myNewException = gcnew Exception( "The requested service is not available." );
         myNewExceptionDictionary->Add( myUrlKey, myNewException );
         myExceptionDictionary = myNewExceptionDictionary;

         Console::WriteLine( "Added exceptions." );
         
         array<Object^>^myArray = gcnew array<Object^>(myExceptionDictionary->Count);
         myExceptionDictionary->Keys->CopyTo( (Array^)myArray, 0 );
         Console::WriteLine( " Keys are :" );

         for each(Object^ myObj in myArray)
         {
            Console::WriteLine(" " + myObj->ToString());
         }

         Console::WriteLine();
         
         array<Object^>^myCollectionArray = gcnew array<Object^>(myExceptionDictionary->Count);
         myExceptionDictionary->Values->CopyTo( (Array^)myCollectionArray, 0 );
         Console::WriteLine( " Values are :" );
         for each(Object^ myObj in myCollectionArray)
         {
            Console::WriteLine(" " + myObj->ToString());
         }
      }
   }
}
using System;
using System.Web.Services.Discovery;
using System.Xml;
using System.Collections;
using System.Runtime.Remoting;
using System.Net;

public class MySample
{
   static void Main()
   {
      string myDiscoFile = "http://localhost/MathService_cs.disco";
      string myUrlKey = "http://localhost/MathService_cs.asmx?wsdl";
      DiscoveryClientProtocol myDiscoveryClientProtocol1 =
                                            new DiscoveryClientProtocol();
      DiscoveryDocument myDiscoveryDocument =
                         myDiscoveryClientProtocol1.Discover(myDiscoFile);
      IEnumerator myEnumerator =
                           myDiscoveryDocument.References.GetEnumerator();
      while ( myEnumerator.MoveNext() )
      {
         ContractReference myContractReference =
                                  (ContractReference)myEnumerator.Current;
         DiscoveryClientProtocol myDiscoveryClientProtocol2 =
                                       myContractReference.ClientProtocol;
         myDiscoveryClientProtocol2.ResolveAll();
         DiscoveryExceptionDictionary myExceptionDictionary
                                      = myDiscoveryClientProtocol2.Errors;
         if ( myExceptionDictionary.Contains(myUrlKey))
         {
            Console.WriteLine("'myExceptionDictionary' contains " +
                      " a discovery exception for the key '" + myUrlKey + "'");
         }
         else
         {
            Console.WriteLine("'myExceptionDictionary' does not contain" +
                      " a discovery exception for the key '" + myUrlKey + "'");
         }
         if (myExceptionDictionary.Contains(myUrlKey))
         {
            Console.WriteLine("System generated exceptions.");

            Exception myException = myExceptionDictionary[myUrlKey];
            Console.WriteLine(" Source : " + myException.Source);
            Console.WriteLine(" Exception : " + myException.Message);

            Console.WriteLine();

            // Remove the discovery exception.for the key 'myUrlKey'.
            myExceptionDictionary.Remove(myUrlKey);

            DiscoveryExceptionDictionary myNewExceptionDictionary =
                                       new DiscoveryExceptionDictionary();
            // Add an exception with the custom error message.
            Exception myNewException =
                 new Exception("The requested service is not available.");
            myNewExceptionDictionary.Add(myUrlKey, myNewException);
            myExceptionDictionary = myNewExceptionDictionary;

            Console.WriteLine("Added exceptions.");

            object[] myArray = new object[myExceptionDictionary.Count];
            myExceptionDictionary.Keys.CopyTo((Array)myArray,0);
            Console.WriteLine(" Keys are :");
            foreach(object myObj in myArray)
            {
               Console.WriteLine(" " + myObj.ToString());
            }

            Console.WriteLine();

            object[] myCollectionArray = new object[myExceptionDictionary.Count];
            myExceptionDictionary.Values.CopyTo((Array)myCollectionArray,0);
            Console.WriteLine(" Values are :");
            foreach(object myObj in myCollectionArray)
            {
               Console.WriteLine(" " + myObj.ToString());
            }
         }
      }
   }
}
Imports System.Web.Services.Discovery
Imports System.Xml
Imports System.Collections
Imports System.Runtime.Remoting
Imports System.Net

Public Class MySample
   
   Shared Sub Main()
      Dim myDiscoFile As String = "http://localhost/MathService_vb.disco"
      Dim myUrlKey As String = "http://localhost/MathService_vb.asmx?wsdl"
      Dim myDiscoveryClientProtocol1 As New DiscoveryClientProtocol()
      Dim myDiscoveryDocument As DiscoveryDocument = myDiscoveryClientProtocol1.Discover(myDiscoFile)
      Dim myEnumerator As IEnumerator = myDiscoveryDocument.References.GetEnumerator()
      While myEnumerator.MoveNext()
         Dim myContractReference As ContractReference = CType(myEnumerator.Current, ContractReference)
         Dim myDiscoveryClientProtocol2 As DiscoveryClientProtocol = myContractReference.ClientProtocol
         myDiscoveryClientProtocol2.ResolveAll()
         Dim myExceptionDictionary As DiscoveryExceptionDictionary = myDiscoveryClientProtocol2.Errors
         If myExceptionDictionary.Contains(myUrlKey) = True Then
            Console.WriteLine("'myExceptionDictionary' contains " + _
                 "a discovery exception for the key '" + myUrlKey + "'")
         Else
            Console.WriteLine("'myExceptionDictionary' does not contain" + _
                 " a discovery exception for the key '" + myUrlKey + "'")
         End If
         If myExceptionDictionary.Contains(myUrlKey) = True Then
            Console.WriteLine("System generated exceptions.")
            
            Dim myException As Exception = myExceptionDictionary(myUrlKey)
            Console.WriteLine(" Source : " + myException.Source)
            Console.WriteLine(" Exception : " + myException.Message)
            Console.WriteLine()
            
            ' Remove the discovery exception.for the key 'myUrlKey'.
            myExceptionDictionary.Remove(myUrlKey)
            Dim myNewExceptionDictionary As New DiscoveryExceptionDictionary()
            ' Add an exception with the custom error message.
            Dim myNewException As New Exception("The requested service is not available.")
            myNewExceptionDictionary.Add(myUrlKey, myNewException)
            myExceptionDictionary = myNewExceptionDictionary
            Console.WriteLine("Added exceptions.")
            
            Dim myArray(myExceptionDictionary.Count -1 ) As Object
            myExceptionDictionary.Keys.CopyTo(CType(myArray, Array), 0)
            Console.WriteLine(" Keys are :")
            Dim myObj As Object
            For Each myObj In  myArray
               Console.WriteLine(" " + myObj.ToString())
            Next myObj
            Console.WriteLine()
            
            Dim myCollectionArray(myExceptionDictionary.Count -1 ) As Object
            myExceptionDictionary.Values.CopyTo(CType(myCollectionArray, Array), 0)
            Console.WriteLine(" Values are :")
            For Each myObj In  myCollectionArray
               Console.WriteLine(" " + myObj.ToString())
            Next myObj
         End If 
      End While
   End Sub
End Class

Remarques

La Errors propriété de DiscoveryClientProtocol type est de type DiscoveryExceptionDictionary.

Constructeurs

Nom Description
DiscoveryExceptionDictionary()

Initialise une nouvelle instance de la classe DiscoveryExceptionDictionary.

Propriétés

Nom Description
Count

Obtient le nombre d’éléments contenus dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
Dictionary

Obtient la liste des éléments contenus dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
InnerHashtable

Obtient la liste des éléments contenus dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
Item[String]

Obtient ou définit l’url Exception spécifiée lors de la découverte de l’URL spécifiée à partir du DiscoveryExceptionDictionary.

Keys

Obtient un ICollection objet avec toutes les clés dans le DiscoveryExceptionDictionary.

Values

Obtient un ICollection objet contenant toutes les valeurs dans le DiscoveryExceptionDictionary.

Méthodes

Nom Description
Add(String, Exception)

Ajoute une Exception clé avec la DiscoveryExceptionDictionaryvaleur url .

Clear()

Efface le contenu de l’instance de DictionaryBase.

(Hérité de DictionaryBase)
Contains(String)

Détermine si le DiscoveryExceptionDictionary contient avec Exception l’URL spécifiée.

CopyTo(Array, Int32)

Copie les DictionaryBase éléments dans une dimension Array à l’index spécifié.

(Hérité de DictionaryBase)
Equals(Object)

Détermine si l’objet spécifié est égal à l’objet actuel.

(Hérité de Object)
GetEnumerator()

Retourne une IDictionaryEnumerator itération au sein de l’instance DictionaryBase .

(Hérité de DictionaryBase)
GetHashCode()

Sert de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient la Type de l’instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Objectactuel.

(Hérité de Object)
OnClear()

Effectue des processus personnalisés supplémentaires avant d’effacer le contenu de l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnClearComplete()

Effectue des processus personnalisés supplémentaires après l’effacement du contenu de l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnGet(Object, Object)

Obtient l’élément avec la clé et la valeur spécifiées dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnInsert(Object, Object)

Effectue des processus personnalisés supplémentaires avant d’insérer un nouvel élément dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnInsertComplete(Object, Object)

Effectue des processus personnalisés supplémentaires après l’insertion d’un nouvel élément dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnRemove(Object, Object)

Effectue des processus personnalisés supplémentaires avant de supprimer un élément de l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnRemoveComplete(Object, Object)

Effectue des processus personnalisés supplémentaires après avoir supprimé un élément de l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnSet(Object, Object, Object)

Effectue des processus personnalisés supplémentaires avant de définir une valeur dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnSetComplete(Object, Object, Object)

Effectue des processus personnalisés supplémentaires après avoir défini une valeur dans l’instance DictionaryBase .

(Hérité de DictionaryBase)
OnValidate(Object, Object)

Effectue des processus personnalisés supplémentaires lors de la validation de l’élément avec la clé et la valeur spécifiées.

(Hérité de DictionaryBase)
Remove(String)

Supprime une Exception URL avec l’URL spécifiée du DiscoveryExceptionDictionary.

ToString()

Retourne une chaîne qui représente l’objet actuel.

(Hérité de Object)

Implémentations d’interfaces explicites

Nom Description
ICollection.IsSynchronized

Obtient une valeur indiquant si l’accès à un DictionaryBase objet est synchronisé (thread safe).

(Hérité de DictionaryBase)
ICollection.SyncRoot

Obtient un objet qui peut être utilisé pour synchroniser l’accès à un DictionaryBase objet.

(Hérité de DictionaryBase)
IDictionary.Add(Object, Object)

Ajoute un élément avec la clé et la valeur spécifiées dans le DictionaryBase.

(Hérité de DictionaryBase)
IDictionary.Contains(Object)

Détermine si le DictionaryBase contient une clé spécifique.

(Hérité de DictionaryBase)
IDictionary.IsFixedSize

Obtient une valeur indiquant si un DictionaryBase objet a une taille fixe.

(Hérité de DictionaryBase)
IDictionary.IsReadOnly

Obtient une valeur indiquant si un DictionaryBase objet est en lecture seule.

(Hérité de DictionaryBase)
IDictionary.Item[Object]

Obtient ou définit la valeur associée à la clé spécifiée.

(Hérité de DictionaryBase)
IDictionary.Keys

Obtient un ICollection objet contenant les clés de l’objet DictionaryBase .

(Hérité de DictionaryBase)
IDictionary.Remove(Object)

Supprime l’élément avec la clé spécifiée du DictionaryBase.

(Hérité de DictionaryBase)
IDictionary.Values

Obtient un ICollection objet contenant les valeurs de l’objet DictionaryBase .

(Hérité de DictionaryBase)
IEnumerable.GetEnumerator()

Retourne un itération qui effectue une IEnumerator itération dans le DictionaryBase.

(Hérité de DictionaryBase)

Méthodes d’extension

Nom Description
AsParallel(IEnumerable)

Active la parallélisation d’une requête.

AsQueryable(IEnumerable)

Convertit un IEnumerable en IQueryable.

Cast<TResult>(IEnumerable)

Convertit les éléments d’un IEnumerable en type spécifié.

OfType<TResult>(IEnumerable)

Filtre les éléments d’une IEnumerable en fonction d’un type spécifié.

S’applique à

Voir aussi