Created
December 17, 2012 17:43
-
-
Save anonymous/4320254 to your computer and use it in GitHub Desktop.
Resolving tokens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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