private static bool ReplaceToken(IChoPropertyReplacer[] propertyReplacers, StringBuilder message, string propertyName, string format, object context) { if (!String.IsNullOrEmpty(propertyName)) { if (propertyName == "@this") { if (context != null) { message.Append(ChoObject.Format(context, format)); } return(true); } foreach (IChoPropertyReplacer propertyReplacer in propertyReplacers) { if (!(propertyReplacer is IChoKeyValuePropertyReplacer)) { continue; } IChoKeyValuePropertyReplacer dictionaryPropertyReplacer = propertyReplacer as IChoKeyValuePropertyReplacer; if (dictionaryPropertyReplacer == null || !dictionaryPropertyReplacer.ContainsProperty(propertyName, context)) { continue; } //if (propertyName.Contains("@this")) //{ // if (context == null) // context = message.ToString(); // message.Clear(); //} message.Append(dictionaryPropertyReplacer.ReplaceProperty(propertyName, format, context)); return(true); } } string propertyValue; bool retValue = ChoApplication.OnPropertyResolve(propertyName, format, context, out propertyValue); if (retValue) { if (propertyValue != null) { message.Append(propertyValue); } return(true); } //if (!format.IsNullOrWhiteSpace()) //{ // message.Append(ChoObject.Format(propertyName, format)); // return true; //} return(false); }
private static bool ReplaceToken(IChoPropertyReplacer[] propertyReplacers, StringBuilder message, string propertyName, string format) { if (!String.IsNullOrEmpty(propertyName)) { foreach (IChoPropertyReplacer propertyReplacer in propertyReplacers) { if (!(propertyReplacer is IChoKeyValuePropertyReplacer)) { continue; } IChoKeyValuePropertyReplacer dictionaryPropertyReplacer = propertyReplacer as IChoKeyValuePropertyReplacer; if (dictionaryPropertyReplacer == null || !dictionaryPropertyReplacer.ContainsProperty(propertyName)) { continue; } message.Append(dictionaryPropertyReplacer.ReplaceProperty(propertyName, format)); return(true); } } string propertyValue; bool retValue = ChoApplication.OnPropertyResolve(propertyName, format, out propertyValue); if (retValue) { if (propertyValue != null) { message.Append(propertyValue); } return(true); } return(false); }