Wednesday, December 07, 2011 8:42 PM
from frederick.chapleau
560 days ago
Viewed 18 times
Revision 2
Tagged as wiki
Printer Friendly Version PDF Version
from frederick.chapleau
560 days ago
Viewed 18 times
Revision 2
Tagged as wiki
Printer Friendly Version PDF Version
Token Replacement
Replace a list of field=value;field=value from the source string and return it.
public string ReplaceTokens(string tokenText, string content)
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
// Split the token list to a list of unified key/value pair
List<string> splittedTokens = tokenText.Split(',').ToList();
// For each token, add it to the key/value pair
splittedTokens.ForEach(p => tokens.Add(p.Split('=')[0], p.Split('=')[1]));
// Replace the all found keys from the source, by the equivalent value
tokens.Keys.ToList().ForEach(key => content = content.Replace(key, tokens[key]));
return content;
}
Copyright © 1996-2013, Chapleau.info (v4.1.0.155)