public static bool SetMaping(string groupName, string source, string replace) { ReplaceGroupSetting setting = ConfigSetting.GroupSettings.Where(p => p.GroupName == groupName).FirstOrDefault(); if (setting != null) { var mapper = setting.GroupReplaceItems.Where(p => p.SourceString == source).FirstOrDefault(); if (mapper != null) { mapper.ReplaceString = replace; return true; } else { mapper = new ReplaceMapper(); mapper.SourceString = source; mapper.ReplaceString = replace; setting.GroupReplaceItems.Add(mapper); } } return false; }
private ReplaceMapper getMapKeyValue(string source) { foreach (var item in this.listGroupSetting.Items) { ListBoxItem lbi = (ListBoxItem)item; StackPanel sp = lbi.Content as StackPanel; if (sp.Name == stpNamePre + getSafeName(source)) { TextBox tb = sp.Children[2] as TextBox; ReplaceMapper mapper = new ReplaceMapper(); mapper.SourceString = source; if (!string.IsNullOrEmpty(tb.Text.Trim())) { mapper.ReplaceString = tb.Text; return mapper; } return null; } } return null; }