本文整理汇总了C#中ParserContext.Set方法的典型用法代码示例。如果您正苦于以下问题:C# ParserContext.Set方法的具体用法?C# ParserContext.Set怎么用?C# ParserContext.Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserContext
的用法示例。
在下文中一共展示了ParserContext.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override CommandExecutionResult Execute()
{
AskSingleValue environmentAsk = new AskSingleValue();
environmentAsk.Text = Resources.EnvironmentAsk;
environmentAsk.Prefix = Resources.EnvironmentName;
if (environmentAsk.ShowDialog() != DialogResult.OK)
{
return new CommandExecutionResult(this);
}
DirectoryInfo envDir = new DirectoryInfo(Path.Combine(project.BuildFile.DirectoryName, EnvIncludeConstants.ENV_FOLDER_NAME));
if (!envDir.Exists)
{
envDir.Create();
}
string targetFileName = string.Format("{0}.{1}.config", project.ProjectName, environmentAsk.Value);
FileInfo targetFileInfo = new FileInfo(Path.Combine(envDir.FullName, targetFileName));
if (targetFileInfo.Exists)
{
CommandExecutionResult result = new CommandExecutionResult(this);
result.Error = new ApplicationException(string.Format(Resources.EnvironmnentFileExists, targetFileInfo.FullName));
return result;
}
ParserContext context = new ParserContext();
context.Set("projectName", project.ProjectName);
TemplateHelper.GenerateFile(targetFileInfo, @"EnvFile\env.config", context, Encoding.UTF8);
return new CommandExecutionResult(this);
}
示例2: Execute
public override CommandExecutionResult Execute()
{
string projectName = Path.GetFileNameWithoutExtension(filename);
ParserContext context = new ParserContext();
context.Set("projectName", projectName);
FileInfo targetFile = new FileInfo(filename);
TemplateHelper.GenerateFile(targetFile, @"NAntFile\nantfile.nant", context, Encoding.UTF8);
CommandExecutionResult result = new CommandExecutionResult(this);
result.NewProjectFile = targetFile;
return result;
}
示例3: SetupFalsyContext
private static ParserContext SetupFalsyContext(ParserContextBehavior behavior)
{
ParserContext context = new ParserContext(behavior);
context.Set<object>("NullValue", null);
context.Set<object>("RandomObject",new object());
context.Set("EmptyString", "");
context.Set("NonEmptyString", "x");
return context;
}