private void LoadSettingsToForm() { // Nice and easy, just get the settings and put them into the form. // Wdc Client Settings var wdcClientConfig = _configProvider.GetSection <WdcClientConfiguration>(); txtWdcUsername.Text = wdcClientConfig.WritingUsername; txtWdcPassword.Text = wdcClientConfig.WritingPassword; }
/// <summary> /// Valida las dimensiones de la imagen /// </summary> /// <param name="file">Imagen</param> /// <returns></returns> public bool ValidateImageDimenensions(IFormFile file) { var image = Image.FromStream(file.OpenReadStream(), true, true); var imageDimensionsConfig = config.GetSection("Appsettings:AllowedImageDimensions:Dimensions") .GetChildren() .Select(x => new { width = x.GetValue <int>("Width"), height = x.GetValue <int>("Height") }); if (!imageDimensionsConfig.Any()) { ImageDispose(image); return(true); } foreach (var item in imageDimensionsConfig) { if (image.Width.IsBetween(item.width - MIN_INTERVAL_DIMENSION, item.width + MAX_INTERVAL_DIMENSION) && image.Height.IsBetween(item.height - MIN_INTERVAL_DIMENSION, item.height + MAX_INTERVAL_DIMENSION)) { ImageDispose(image); return(true); } } ImageDispose(image); return(false); }
public StorySyncWorker(IWdcStoryContainer storyContainer, IWdcReader wdcReader, IWdcClient wdcClient, IConfigProvider configProvider, IFileDumper fileDumper, IGuiContext guiContext ) { _storyContainer = storyContainer; _wdcReader = wdcReader; _wdcClient = wdcClient; _configProvider = configProvider; _fileDumper = fileDumper; _gui = guiContext; SetSettings(configProvider.GetSection <StorySyncWorkerSettings>()); // Init some stuff _storyStatusList = new Dictionary <string, StorySyncWorkerStoryStatus>(); _ctSource = new CancellationTokenSource(); _status = new StorySyncWorkerStatus(); // TODO add functionality to react to configuration changes. E.g. Cancel process, update settings, start again. // Subscribe to some events _storyContainer.OnUpdate += new EventHandler <WdcStoryContainerEventArgs>(OnStoryContainerChanged); _configProvider.OnSectionChanged += new EventHandler <ConfigSectionChangedEventArgs>(OnSettingsChanged); }
private void OnSettingsChanged(object sender, ConfigSectionChangedEventArgs args) { if (args.SectionName == typeof(StorySyncWorkerSettings).Name) { // The sync worker settings have changed. // Update the settings // TODO: should I cancel the worker, and have it start again? _log.Debug("Reacting to a change in settings"); SetSettings(_configProvider.GetSection <StorySyncWorkerSettings>()); } }
private void CheckInitialSetupRequired() { if (!_diContainer.IsVerifying) // Only do this if the container is not doing its verification process { var wdcClientSettings = _configProvider.GetSection <WdcClientConfiguration>(); if (string.IsNullOrEmpty(wdcClientSettings.WritingUsername) || string.IsNullOrEmpty(wdcClientSettings.WritingPassword)) { // Empty username or password, should show alert. MessageBox.Show( "It looks like WritingExporter has not been set up yet.\nPlease provide a Writing.com username and password.", "Setup required", MessageBoxButtons.OK, MessageBoxIcon.Information ); ShowSettingsForm(); } } }
protected ConfigSectionGlimpse RetrieveConfig() { return(_configProvider.GetSection <ConfigSectionGlimpse>("glimpsePackage")); }
private void UpdateSettings() { _log.Debug("Updating settings"); // Grab a new settings object from the config provider settings = _configProvider.GetSection <WdcClientConfiguration>(); }