/// <summary> /// 生成语句 /// </summary> private string BuildStrings(string str) { string source = str; //转换默认的 foreach (var item in DataLibrary.DefaultFlag) { if (source.Contains(item.Key)) { source = source.Replace(item.Key, AutoDataHelp.GetData(item.Value)); } } //转换定义的 foreach (var item in Config.Flags) { if (source.Contains(item.Key)) { source = source.Replace(item.Key, AutoDataHelp.GetData(item.Value, item.Key)); } //CR:item.key 2013年10月14日10:09:06 后加上去的表示自定义数据的Key } //生成String.Format() 以免反复调用此语句 看看这个和String.Format(那个快); return(source); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string source = value.ToString(); MainWindow mw = (MainWindow)Application.Current.MainWindow; foreach (var item in DataLibrary.DefaultFlag) { if (source.Contains(item.Key)) { source = source.Replace(item.Key, AutoDataHelp.GetData(item.Value)); } } Dictionary <string, Flag> Flags = (Dictionary <string, Flag>)parameter; foreach (var item in mw.Config.Flags) { if (source.Contains(item.Key)) { source = source.Replace(item.Key, AutoDataHelp.GetData(item.Value, item.Key)); } } return(source); }