public ProviderResponse<Cloud> Connect(Cloud cloud) { ProviderResponse<Cloud> response = new ProviderResponse<Cloud>(); Cloud local = cloud.DeepCopy(); IVcapClient client = new VcapClient(local); try { VcapClientResult result = client.Login(); if (!result.Success) throw new Exception(result.Message); local.AccessToken = client.CurrentToken; var applications = client.GetApplications(); var provisionedServices = client.GetProvisionedServices(); var availableServices = client.GetSystemServices(); local.Applications.Synchronize(new SafeObservableCollection<Application>(applications), new ApplicationEqualityComparer()); local.Services.Synchronize(new SafeObservableCollection<ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer()); local.AvailableServices.Synchronize(new SafeObservableCollection<SystemService>(availableServices), new SystemServiceEqualityComparer()); foreach (Application app in local.Applications) { var instances = GetInstances(local, app); if (instances.Response != null) app.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instances.Response), new InstanceEqualityComparer()); } response.Response = local; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<SafeObservableCollection<ProvisionedService>> GetProvisionedServices(Cloud cloud) { ProviderResponse<SafeObservableCollection<ProvisionedService>> response = new ProviderResponse<SafeObservableCollection<ProvisionedService>>(); try { IVcapClient client = new VcapClient(cloud); response.Response = new SafeObservableCollection<ProvisionedService>(client.GetProvisionedServices()); } catch (Exception ex) { response.Message = ex.Message; } return response; }