static void Run()
    {
        DiscoveryClientProtocol myDiscoveryClientProtocol =
            new DiscoveryClientProtocol();

        myDiscoveryClientProtocol.Credentials =
            CredentialCache.DefaultCredentials;

        // 'dataservice.vsdisco' is a sample discovery document.
        string myStringUrl = "http://localhost/dataservice.vsdisco";

        // Call the Discover method to populate the References property.
        DiscoveryDocument myDiscoveryDocument =
            myDiscoveryClientProtocol.Discover(myStringUrl);

        // Resolve all references found in the discovery document.
        myDiscoveryClientProtocol.ResolveAll();

        DiscoveryClientReferenceCollection myDiscoveryClientReferenceCollection =
            myDiscoveryClientProtocol.References;

        // Retrieve the keys from the collection.
        ICollection myCollection = myDiscoveryClientReferenceCollection.Keys;

        object[] myObjectCollection =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection.CopyTo(myObjectCollection, 0);

        Console.WriteLine("The discovery documents, service descriptions, " +
                          "and XML schema");
        Console.WriteLine(" definitions in the collection are: ");
        for (int i = 0; i < myObjectCollection.Length; i++)
        {
            Console.WriteLine(myObjectCollection[i]);
        }
        Console.WriteLine("");

        // Retrieve the values from the collection.
        ICollection myCollection1 = myDiscoveryClientReferenceCollection.Values;

        object[] myObjectCollection1 =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection1.CopyTo(myObjectCollection1, 0);

        Console.WriteLine("The objects in the collection are: ");
        for (int i = 0; i < myObjectCollection1.Length; i++)
        {
            Console.WriteLine(myObjectCollection1[i]);
        }

        Console.WriteLine("");

        string myStringUrl1 = "http://localhost/dataservice.vsdisco";

        if (myDiscoveryClientReferenceCollection.Contains(myStringUrl1))
        {
            Console.WriteLine("The document reference {0} is part of the collection.",
                              myStringUrl1);
        }
    }
Example #2
0
 void GetServices(DiscoveryClientReferenceCollection references)
 {
     foreach (DictionaryEntry entry in references)
     {
         var contractRef = entry.Value as ContractReference;
         if (contractRef != null)
         {
             services.Add(contractRef.Contract);
         }
     }
 }
Example #3
0
    public static void Main()
    {
// <Snippet5>
// <Snippet2>
// <Snippet1>
        DiscoveryClientReferenceCollection myDiscoveryClientReferenceCollection =
            new DiscoveryClientReferenceCollection();

        ContractReference myContractReference = new ContractReference();
        string            myStringUrl1        = "http://www.contoso.com/service1.disco";

        myContractReference.Ref = myStringUrl1;
        myDiscoveryClientReferenceCollection.Add(myContractReference);

// </Snippet1>
// </Snippet2>
        // myDiscoveryClientReferenceCollection is an instance collection.
        object myObject = myDiscoveryClientReferenceCollection[myStringUrl1];

        Console.WriteLine("Object representing the URL: " + myObject.ToString());
// </Snippet5>
        Console.WriteLine("");
// <Snippet4>
// <Snippet3>
        DiscoveryDocumentReference myDiscoveryDocumentReference =
            new DiscoveryDocumentReference();
        string myStringUrl = "http://www.contoso.com/service.disco";

        myDiscoveryClientReferenceCollection.Add(myStringUrl,
                                                 myDiscoveryDocumentReference);
// </Snippet3>
        myDiscoveryClientReferenceCollection.Remove(myStringUrl);
// </Snippet4>

        // Retrieve the keys in the collection.
        ICollection myCollection = myDiscoveryClientReferenceCollection.Keys;

        object[] myObjectCollection =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection.CopyTo(myObjectCollection, 0);

        Console.WriteLine("The discovery documents, service descriptions, and");
        Console.WriteLine("XML schema definitions in the collection are:");
        for (int iIndex = 0; iIndex < myObjectCollection.Length; iIndex++)
        {
            Console.WriteLine(myObjectCollection[iIndex]);
        }

        Console.WriteLine("");

        // Retrieve the values in the collection.
        ICollection myCollection1 = myDiscoveryClientReferenceCollection.Values;

        object[] myObjectCollection1 =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection1.CopyTo(myObjectCollection1, 0);

        Console.WriteLine("The objects in the collection are:");
        for (int iIndex = 0; iIndex < myObjectCollection1.Length; iIndex++)
        {
            Console.WriteLine(myObjectCollection1[iIndex]);
        }
    }
Example #4
0
 public ServiceReferenceDiscoveryEventArgs(DiscoveryClientReferenceCollection references)
 {
     GetServices(references);
 }