本文整理汇总了C#中TemplateService.ParseMany方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateService.ParseMany方法的具体用法?C# TemplateService.ParseMany怎么用?C# TemplateService.ParseMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateService
的用法示例。
在下文中一共展示了TemplateService.ParseMany方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TemplateService_CanParseMultipleTemplatesInParallel_WitNoModels
public void TemplateService_CanParseMultipleTemplatesInParallel_WitNoModels()
{
using (var service = new TemplateService())
{
const string template = "<h1>Hello World</h1>";
var templates = Enumerable.Repeat(template, 10);
var results = service.ParseMany(templates, true);
Assert.That(templates.SequenceEqual(results), "Rendered templates do not match expected.");
}
}
示例2: TemplateService_CanParseMultipleTemplatesInSequence_WithComplexModels
public void TemplateService_CanParseMultipleTemplatesInSequence_WithComplexModels()
{
const int maxTemplates = 10;
using (var service = new TemplateService())
{
const string template = "<h1>Age: @Model.Age</h1>";
var expected = Enumerable.Range(1, maxTemplates).Select(i => string.Format("<h1>Age: {0}</h1>", i));
var templates = Enumerable.Repeat(template, maxTemplates);
var models = Enumerable.Range(1, maxTemplates).Select(i => new Person { Age = i });
var results = service.ParseMany(templates, models, false);
Assert.That(expected.SequenceEqual(results), "Parsed templates do not match expected results.");
}
}
示例3: Main
static void Main(string[] args)
{
CompilerServiceBuilder.SetCompilerServiceFactory(new DefaultCompilerServiceFactory());
using (var service = new TemplateService())
{
const string template = "<h1>Age: @Model.Age</h1>";
var expected = Enumerable.Range(1, 10).Select(i => string.Format("<h1>Age: {0}</h1>", i)).ToList();
var templates = Enumerable.Repeat(template, 10).ToList();
var models = Enumerable.Range(1, 10).Select(i => new Person { Age = i });
var results = service.ParseMany(templates, models, null, null, true).ToList();
for (int i = 0; i < 10; i++)
{
Console.WriteLine(templates[i]);
Console.WriteLine(expected[i]);
Console.WriteLine(results[i]);
}
}
Console.ReadKey();
}
示例4: TemplateService_CanParseSingleTemplateInParallel_WithMultipleModels
public void TemplateService_CanParseSingleTemplateInParallel_WithMultipleModels()
{
const int maxTemplates = 10;
using (var service = new TemplateService(Language.CSharp, Encoding.Raw))
{
const string template = "<h1>Age: @Model.Age</h1>";
var expected = Enumerable.Range(1, maxTemplates).Select(i => string.Format("<h1>Age: {0}</h1>", i));
var models = Enumerable.Range(1, maxTemplates).Select(i => new Person { Age = i });
var results = service.ParseMany(template, models, true /* Parallel */);
Assert.That(expected.SequenceEqual(results), "Parsed templates do not match expected results.");
}
}