} // 是否为虚拟值形态。所谓虚拟值就是最外面被 {} 括住 public static OldNewValue Parse(string strValue) { bool bVirtual = strValue.StartsWith("{"); if (bVirtual == true) { strValue = StringUtil.Unquote(strValue, "{}"); } dp2StringUtil.ParseOldNewValue(strValue, out string strOldValue, out string strNewValue); return(new OldNewValue { OldValue = strOldValue, NewValue = strNewValue, IsVirtual = bVirtual }); }
// 能处理 {} 的版本 public static string LinkOldNewValueVirtual(string strOldValue, string strNewValue) { if (String.IsNullOrEmpty(strNewValue) == true) { return(strOldValue); } bool new_virtual = false; if (strNewValue.StartsWith("{")) { strNewValue = StringUtil.Unquote(strNewValue, "{}"); new_virtual = true; } bool old_virtual = false; if (string.IsNullOrEmpty(strOldValue) == false && strOldValue.StartsWith("{")) { strOldValue = StringUtil.Unquote(strOldValue, "{}"); old_virtual = true; } if (strOldValue == strNewValue) { if (String.IsNullOrEmpty(strOldValue) == true) // 新旧均为空 { return(""); } if (new_virtual || old_virtual) { return("{" + strOldValue + "[=]}"); } return(strOldValue + "[=]"); } if (new_virtual || old_virtual) { return("{" + strOldValue + "[" + strNewValue + "]}"); } return(strOldValue + "[" + strNewValue + "]"); }