本文整理汇总了C#中PropertyCollection.GetRequiredValue方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyCollection.GetRequiredValue方法的具体用法?C# PropertyCollection.GetRequiredValue怎么用?C# PropertyCollection.GetRequiredValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyCollection
的用法示例。
在下文中一共展示了PropertyCollection.GetRequiredValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildContext
public BuildContext(String properties, ParsedPath contentFilePath)
{
ContentFilePath = contentFilePath;
ContentFile = new ContentFileV4();
ContentFile.Load(ContentFilePath);
WriteMessage("Read content file '{0}'", ContentFilePath);
Properties = new PropertyCollection();
// Start with the environment
Properties.AddFromEnvironment();
// Set defaults for important locations
Properties.Set("BuildContentDir", new ParsedPath(Assembly.GetExecutingAssembly().Location, PathType.File).VolumeAndDirectory.ToString());
Properties.Set("ContentFileDir", contentFilePath.VolumeAndDirectory);
Properties.Set("InputDir", contentFilePath.VolumeAndDirectory);
Properties.Set("OutputDir", contentFilePath.VolumeAndDirectory);
// Now override with from content file
Properties.AddFromList(ContentFile.Properties.Select(nv => new KeyValuePair<string, string>(nv.Name.Value, nv.Value.Value)));
// Now override with command line
Properties.AddFromString(properties);
// Add content file hash location if not set already
if (!Properties.Contains("ContentFileHashes"))
{
ParsedPath path = new ParsedPath(Properties.GetRequiredValue("OutputDir"), PathType.Directory);
Properties.Set("ContentHashesFile", path.Append(ContentFilePath.FileAndExtension + ".hashes", PathType.File));
}
ContentFileHashesPath = new ParsedPath(Properties.GetRequiredValue("ContentHashesFile"), PathType.File).MakeFullPath();
ContentFileWriteTime = File.GetLastWriteTime(this.ContentFilePath);
// Create a hash of all the things than can affect the build
SHA1 sha1 = SHA1.Create();
StringBuilder sb = new StringBuilder();
foreach (var rawAssembly in ContentFile.CompilerAssemblies)
{
sb.Append(rawAssembly.Value);
}
foreach (var rawProperty in ContentFile.Properties)
{
sb.Append(rawProperty.Name.Value);
sb.Append(rawProperty.Value.Value);
}
foreach (var rawCompilerSettings in this.ContentFile.CompilerSettings)
{
sb.Append(rawCompilerSettings.Name);
foreach (var extension in rawCompilerSettings.CompilerExtensions)
{
foreach (var input in extension.Inputs)
sb.Append(input.Value);
foreach (var output in extension.Outputs)
sb.Append(output.Value);
}
foreach (var parameter in rawCompilerSettings.Parameters.KeyValues)
{
sb.Append(parameter.Key.Value);
sb.Append(parameter.Value.ToString());
}
}
GlobalHash = BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()))).Replace("-", "");
LoadCompilerClasses();
}