public void SaveLearnedData(string configDir) { var valueStore = new ValueStore(); var stepDefStore = new StepDefStore(valueStore); foreach (var stepDefRegex in _stepDefRegexes) { var paramNames = stepDefRegex.Key.GetValidNames(); for (int paramNumber = 0; paramNumber < paramNames.Count; paramNumber++) { var group = new ValueStoreGroup(paramNames[paramNumber]); var tmpItems = new HashSet <ValueStoreItem>(ValueStoreItem.RuValueComparer); foreach (var gherkinStep in stepDefRegex.Value) { var item = ValueStoreItem.FromMacros(gherkinStep.Text, paramNumber); if (item == default(ValueStoreItem)) { continue; } if (!tmpItems.Contains(item)) { tmpItems.Add(item); } } group.Items.AddRange(tmpItems.ToList()); valueStore.AddGroup(group); stepDefStore.AddStepDef(stepDefRegex.Key); } } valueStore.Save(ValueStoreConfigsDir, "learned"); stepDefStore.Save(StepDefStoreConfigsDir, "learned"); }
public void AddGroup(ValueStoreGroup group) { if (!StoreGroups.ContainsKey(group.Name)) { StoreGroups.Add(group.Name, group); } else { group = StoreGroups[group.Name]; group.Items.AddRange(group.Items); } }
public void AddValuesToGroup(string groupName, IEnumerable <ValueStoreItem> valueItems) { ValueStoreGroup group; if (!StoreGroups.ContainsKey(groupName)) { group = new ValueStoreGroup(groupName); StoreGroups.Add(groupName, group); } else { group = StoreGroups[groupName]; } group.Items.AddRange(valueItems); }
public ValueStore(string valueStoresDirectory) : this() { if (!Directory.Exists(valueStoresDirectory)) { return; } _configFilesDir = valueStoresDirectory; foreach (var file in Directory.EnumerateFiles(valueStoresDirectory, "*.xml", SearchOption.AllDirectories)) { var text = File.ReadAllText(file); var xml = XElement.Parse(text); foreach (var group in xml.Descendants("group")) { var g = new ValueStoreGroup(group); AddGroup(g); } } }
public StepDefParameter(ValueStoreGroup valueStoreGroup, UInt16 index) { ValueStoreGroup = valueStoreGroup; Index = index; }