/// <summary> /// 测试 RunCompile 方法(弱类型模型) /// </summary> /// <param name="name"></param> /// <returns></returns> public async Task <string> TestRunCompile(string name) { var runCompileTemplate = "Hello @Model.Name"; var model = new { Name = name }; var str1 = _viewEngine.RunCompile(runCompileTemplate, model); var str2 = runCompileTemplate.RunCompile(model); var str3 = await _viewEngine.RunCompileAsync(runCompileTemplate, model); var str4 = await runCompileTemplate.RunCompileAsync(model); var isEqual = (str1 == str2) && (str3 == str4) && (str1 == str4); if (!isEqual) { throw new Exception("多次编译之后模板内容相等"); } return(str1); }