/// <summary> /// Gets the list of currently supported match strategies. /// </summary> /// <returns>A list of currently supported match strategies as <see cref="StrategyCollection" />.</returns> public StrategyCollection GetMatchStrategies() { lock (cachedStrategies) { if (cachedStrategies.Count == 0) { // -------------------------------------------------------- // Read a list of available databases and cache them // -------------------------------------------------------- string strategies = ExecuteCommand("SHOW STRAT"); StringReader rdr = new StringReader(strategies); string strategy = null; string description = null; string entry = null; Match m = null; try { // Parse each line and extract dictionary name and description while ((entry = rdr.ReadLine()) != null) { m = reStrategyAndDescription.Match(entry); if (!m.Success) { continue; } strategy = m.Groups[1].Value; description = m.Groups[2].Value; cachedStrategies.Add(new Strategy(strategy, description)); } } finally { if (rdr != null) { rdr.Close(); } } } } return(cachedStrategies); }
public void AddStrategy() { if (string.IsNullOrEmpty(Name)) { return; } // Save to DB using (var context = new QTSDbContext()) { var strategy = new EntityFramework.Strategy(); strategy.Name = Name; strategy.Type = Type; context.Strategies.Add(strategy); context.SaveChanges(); StrategyCollection.Add(strategy); _events.PublishOnUIThread(new ModelEvents(new List <object>(new object[] { "Add strategy to DB: name = " + Name }))); } }