public Persona(CORE core) { _CORE = core; ConfigPair pair = _CORE.Entitron.GetStaticTables().ConfigPairs.SingleOrDefault(c => c.Key == "UserCacheExpirationHours"); _expirationTime = TimeSpan.FromHours(pair != null ? Convert.ToInt32(pair.Value) : 24); // default 24h _autoLogoffAfter = TimeSpan.FromHours(10); }
private static List <ConfigPair> BuildPipelineFromString(List <string> pipelineArgs, Dictionary <string, Type> pipelineComponents) { for (int i = 0; i < pipelineArgs.Count; i++) { pipelineArgs[i] = pipelineArgs[i].Trim(); } List <ConfigPair> results = new List <ConfigPair>(pipelineArgs.Count); foreach (string componentString in pipelineArgs) { ConfigPair config = ConfigUtil.ParseComponentConfig(pipelineComponents, componentString); results.Add(config); } return(results); }
public static ConfigPair ParseComponentConfig(Dictionary <string, Type> pipelineComponents, string componentString) { ConfigPair config = new ConfigPair(); string componentName; string configString; int pPos = componentString.IndexOf('('); if (pPos < 0) { componentName = componentString; configString = ""; } else { componentName = componentString.Substring(0, pPos).Trim(); if (componentString.Substring(componentString.Length - 1, 1) != ")") { throw new ArgumentException(string.Format("Invalid pipeline. The closing parenthesis not found: {0}", componentString)); } configString = componentString.Substring(pPos + 1, componentString.Length - pPos - 2); } Type foundType; if (pipelineComponents.TryGetValue(componentName.ToLowerInvariant(), out foundType)) { config.Parameters = ParseArrayConfig(configString); config.TransformationType = foundType; } else { throw new ArgumentException(string.Format("Plugin not found: {0}", componentName)); } return(config); }
/// <summary> /// This method gets the next name and value pair for iteration. /// The scope of the name and value are the life of the Config object, or until the next GetNext() call. /// </summary> /// /// <param name="cp">Structure containing name/value pair</param> /// /// <returns>Status as to whether name/value pair are available.</returns> /// /// <seealso cref="ConfigPair"/> /// <seealso cref="GetFirst"/> public bool GetNext(ConfigPair cp) { }
/// <summary> /// This method gets the first name and value pair for iteration. /// The scope of the name and value are the life of the Config object, or until the next GetFirst() call. /// </summary> /// /// <param name="cp">Structure containing name/value pair</param> /// /// <returns>Status as to whether name/value pair are available.</returns> /// /// <seealso cref="ConfigPair"/> /// <seealso cref="GetNext"/> public bool GetFirst(ConfigPair cp) { }
private static List <ConfigPair> ParseBackupOrRestoreArgs(List <string> args, bool isBackup, Dictionary <string, Type> pipelineComponents, Dictionary <string, Type> databaseComponents, Dictionary <string, Type> storageComponents, out ConfigPair databaseConfig, out ConfigPair storageConfig) { if (args.Count < 2) { throw new ArgumentException("Please provide both the database and storage plugins after the backup subcommand."); } string databaseArg; string storageArg; if (isBackup) { databaseArg = args[0]; storageArg = args[args.Count - 1]; } else { databaseArg = args[args.Count - 1]; storageArg = args[0]; } if (databaseArg.Contains("://")) { throw new ArgumentException("The first sub argument must be the name of the database."); } if (databaseArg[0] == '[' && databaseArg[databaseArg.Length - 1] == ']') { databaseArg = string.Format("db(database={0})", databaseArg.Substring(1, databaseArg.Length - 2).Replace(";", ";;")); } databaseConfig = ConfigUtil.ParseComponentConfig(databaseComponents, databaseArg); if (storageArg[0] == '[' && storageArg[databaseArg.Length - 1] == ']') { throw new ArgumentException("The last sub argument must be a storage plugin."); } if (storageArg.StartsWith("file://")) { Uri uri = new Uri(storageArg); storageArg = string.Format("local(path={0})", uri.LocalPath.Replace(";", ";;")); } storageConfig = ConfigUtil.ParseComponentConfig(storageComponents, storageArg); List <string> pipelineArgs = new List <string>(); for (int i = 1; i < args.Count - 1; i++) { pipelineArgs.Add(args[i]); } List <ConfigPair> pipeline = BuildPipelineFromString(pipelineArgs, pipelineComponents); return(pipeline); }