public static RFMonitoredFile ReadFromConfig(RFEnum fileKey, IRFUserConfig config, Func <string, string> nameTransform = null, bool throwIfFail = true) { try { var m = new RFMonitoredFile { FileKey = fileKey, FileNameWildcard = config.GetString(CONFIG_SECTION, fileKey, false, "FileNameWildcard"), FileNameRegex = config.GetString(CONFIG_SECTION, fileKey, false, "FileNameRegex"), GetSubDirectory = config.GetString(CONFIG_SECTION, fileKey, false, "GetSubDirectory") ?? config.GetString(CONFIG_SECTION, fileKey, false, "SubDirectory"), PutSubDirectory = config.GetString(CONFIG_SECTION, fileKey, false, "PutSubDirectory"), NameTransform = nameTransform, Recursive = config.GetBool(CONFIG_SECTION, fileKey, false, false, "RecursiveSearch"), RemoveExpired = config.GetBool(CONFIG_SECTION, fileKey, false, false, "RemoveExpired"), LatestOnly = config.GetBool(CONFIG_SECTION, fileKey, false, false, "LatestOnly"), ContentPasswords = config.GetString(CONFIG_SECTION, fileKey, false, "ContentPasswords"), }; if (string.IsNullOrWhiteSpace(m.FileNameWildcard) && string.IsNullOrWhiteSpace(m.FileNameRegex) && throwIfFail) { throw new RFSystemException(typeof(RFMonitoredFile), "Invalid monitored file {0} configuration: missing file name.", fileKey.ToString()); } return(m); } catch (Exception) { if (throwIfFail) { throw; } } return(null); }
public static RFLocalFileSite ReadFromConfig(RFEnum siteKey, IRFUserConfig userConfig) { return(new RFLocalFileSite(siteKey, userConfig, userConfig.GetString(CONFIG_SECTION, siteKey, true, "RootDirectory")) { SiteKey = siteKey, PreserveModifiedDate = userConfig.GetBool(CONFIG_SECTION, siteKey, false, true, "PreserveModifiedDate"), CacheDirectoryList = userConfig.GetBool(CONFIG_SECTION, siteKey, false, false, "CacheDirectoryList") }); }
public static RFEmailConfig ReadFromConfig(IRFUserConfig config, string section, string emailName) { return(new RFEmailConfig { Enabled = config.GetBool(section, emailName, true, true, "Enabled"), To = config.GetString(section, emailName, true, "To"), Cc = config.GetString(section, emailName, false, "Cc"), Bcc = config.GetString(section, emailName, false, "Bcc"), SendAsImage = config.GetBool(section, emailName, false, false, "Send as Image") }); }
protected RFFileSite(RFEnum siteKey, string configSection, IRFUserConfig userConfig) { SiteKey = siteKey; Enabled = true; MaxAge = null; if (userConfig != null) { MaxAge = userConfig.GetDecimal(configSection, siteKey, false, null, "MaxAge"); Enabled = userConfig.GetBool(configSection, siteKey, false, true, "Enabled"); PGPSuffixes = userConfig.GetString(configSection, siteKey, false, "PGPSuffixes"); PGPKeyPath = userConfig.GetString(configSection, siteKey, false, "PGPKeyPath"); PGPKeyPassword = userConfig.GetString(configSection, siteKey, false, "PGPKeyPassword"); WriteCooldown = userConfig.GetInt(configSection, siteKey, false, null, "WriteCooldown"); ScanArchives = userConfig.GetBool(configSection, siteKey, false, false, "ScanArchives"); ArchivePath = userConfig.GetString(configSection, siteKey, false, "ArchivePath"); UseTemporaryName = userConfig.GetBool(configSection, siteKey, false, false, "UseTemporaryName"); } }