public static IWatcherConfig Load() { BclConfigSection config = BclConfigSection.GetConfig(); CultureInfo culture = new CultureInfo(config.CultureInfo.Value); WatcherConfig watcherConfig = new WatcherConfig(culture); WatcherConfig.EnsureDirectoryExist(config.DefaultDestinationFolder.Value); watcherConfig.DefaultDestinationFolder = config.DefaultDestinationFolder.Value; foreach (FolderElement sourceFolder in config.SourceFoldersCollection) { WatcherConfig.EnsureDirectoryExist(sourceFolder.Path); watcherConfig.SourceDirectories.Add(sourceFolder.Path); } foreach (RuleElement ruleElement in config.Rules) { WatcherRule rule = new WatcherRule(ruleElement.Regex, ruleElement.MoveTo); WatcherConfig.EnsureDirectoryExist(rule.DestinationFolder); watcherConfig.WatcherRules.Add(rule); } watcherConfig.IsVerbose = config.IsVerbose.Value; watcherConfig.MustAddDate = config.MustAddDate.Value; watcherConfig.MustAddNumber = config.MustAddNumber.Value; Assembly assembly = typeof(Common.WatcherRuleParams).Assembly; // shit watcherConfig.ResourceManager = new ResourceManager("Bcl.Common.Resources.BclResource", assembly); return(watcherConfig); }
private void Configurate() { this.config = WatcherConfig.Load(); this.logger = WatcherLogger.Load(); this.HandleConfig(); this.ConfigurateLogger(); this.ConfigurateFileSystemWatcher(); this.logger.Write(this.config, this.logger); BclResource.Culture = this.config.CultureInfo; }