public CloudServiceClientBase( ILogger logger, IHttpClientFactory clientFactory, IHttpPlatformHelperService http_helper, IToast toast, IAuthHelper authHelper, ICloudServiceSettings settings, IModelValidator validator) : base(logger, http_helper, clientFactory) { this.authHelper = authHelper; this.toast = toast; this.settings = settings; ApiBaseUrl = string.IsNullOrWhiteSpace(settings.ApiBaseUrl) ? throw new ArgumentNullException(nameof(ApiBaseUrl)) : settings.ApiBaseUrl; connection = new ApiConnection(logger, this, http_helper, validator); #region SetClients Account = new AccountClient(connection); Manage = new ManageClient(connection); AuthMessage = new AuthMessageClient(connection); Version = new VersionClient(connection); ActiveUser = new ActiveUserClient(connection); Accelerate = new AccelerateClient(connection); Script = new ScriptClient(connection); DonateRanking = new DonateRankingClient(connection); #endregion }
private void LoadServices() { const string servicesFilePath = "Services\\Services.json"; if (!File.Exists(servicesFilePath)) { return; } var servicesJson = File.ReadAllText(servicesFilePath); var services = JsonConvert.DeserializeObject <ServiceConfig>(servicesJson); if (services == null) { return; } var settingsSerialized = Settings.Default.CloudServiceSettings; var converters = new JsonConverter[] { new GenericJsonConverter <CloudServiceSettings>(), new GenericJsonConverter <CloudServiceSetting>(), new GenericJsonConverter <CloudServiceAuth>() }; if (_settings == null) { _settings = !string.IsNullOrEmpty(settingsSerialized) ? JsonConvert.DeserializeObject <ICloudServiceSettings>(settingsSerialized, converters) : new CloudServiceSettings(); } try { flwServices.SuspendLayout(); dgvLocations.SuspendLayout(); foreach (var disposable in flwServices.Controls.OfType <IDisposable>()) { disposable.Dispose(); } flwServices.Controls.Clear(); _listServices = new List <CloudService>(); foreach (var service in services.Services) { var cloudServices = CreateServiceControl(service, _settings).ToList(); _listServices.AddRange(cloudServices); var controls = cloudServices.Foreach(cs => { cs.PropertyChanged += CloudServiceSettingChanged; cs.ConnectionChanged += (s, e) => { LoadServices(); LoadSettings(); }; }) .Select(cs => cs.CreateControl()); flwServices.Controls.AddRange(controls.ToArray()); } CreateLocationColumns(_listServices); if (_settings.Settings.Count <= 0) { ShowForm(this, EventArgs.Empty); } } finally { dgvLocations.ResumeLayout(); flwServices.ResumeLayout(); } }