Beispiel #1
0
        static void Main(string[] args)
        {
            var builder = GetBuilder();

            using (var container = builder.Build())
            {
                IPetOwnerApiClientFactory factory = container.Resolve <IPetOwnerApiClientFactory>();
                IPetOwnerApiClient        client  = container.Resolve <IPetOwnerApiClient>();
                factory.RegisterApiClient(ApiClientType.Default, client);

                var defaultClient      = factory.GetApiClient(ApiClientType.Default);
                var petsByGenderResult = defaultClient.GetPetsByPetOwnerGender().Result;
                if (!string.IsNullOrEmpty(petsByGenderResult.Error))
                {
                    Console.WriteLine("There were errors while consuming the API.");
                    Console.WriteLine(petsByGenderResult.Error);
                }
                else
                {
                    foreach (var group in petsByGenderResult.PetsByGender)
                    {
                        Console.WriteLine("Gender: " + group.Gender);
                        Console.WriteLine("----------------------");
                        foreach (var name in group.PetNames)
                        {
                            Console.WriteLine(name);
                        }
                        Console.WriteLine("");
                    }
                }
            }
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
 public void RegisterApiClient(ApiClientType apiClientType, IPetOwnerApiClient apiClient)
 {
     apiClients.Add(new KeyValuePair <ApiClientType, IPetOwnerApiClient>(apiClientType, apiClient));
 }