コード例 #1
0
 public ITemplateKey GetKey(string name, ResolveType resolveType, ITemplateKey context)
 {
     // If you can have different templates with the same name depending on the 
     // context or the resolveType you need your own implementation here!
     // Otherwise you can just use NameOnlyTemplateKey.
     ITemplateKey tk = new NameOnlyTemplateKey(name, resolveType, context);
     return tk;
 }
コード例 #2
0
 public void IsolatedRazorEngineService_StaticModel_InSandbox()
 {
     using (var service = IsolatedRazorEngineService.Create(SandboxCreator))
     {
         const string template = "<h1>Hello World @Model.Name</h1>";
         const string expected = "<h1>Hello World TestForename</h1>";
         // We "abuse" NameOnlyTemplateKey because it is SecurityTransparent and serializable.
         var model = new NameOnlyTemplateKey("TestForename", ResolveType.Global, null);
         string result = service.RunCompile(template, "test", typeof(NameOnlyTemplateKey), model);
         Assert.AreEqual(expected, result);
     }
 }