Skip to content

Instantly share code, notes, and snippets.

Created December 17, 2012 17:43
Show Gist options
  • Save anonymous/4320254 to your computer and use it in GitHub Desktop.
Save anonymous/4320254 to your computer and use it in GitHub Desktop.
Resolving tokens
public IEnumerable<ITokenResolver> Resolvers {get;set;}
public ICheckSheetTokenCache CheckSheetTokenCache {get;set;}
public void ProcessCheckSheet(int tagId, int checksheetId, Doc doc)
{
if(CheckSheetTokenCache.Any(x=>x.CheckSheetId == checkSheetId))
{
CheckSheetTokenCache.Add(BuildCacheEntry(checksheetId));
}
var tokens = CheckSheetTokenCache.Where(x=>x.CheckSheetId == checkSheetId).Single();
foreach(var resolver in Resolvers)
foreach(var token in tokens)
{
var resolvedToken = resolver.TryResolve(token);
if(resolvedToken != null)
doc.ReplaceAll(token, resolvedToken);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment