当前位置: 首页>>代码示例>>C#>>正文


C# PropertyCollection.AddFromString方法代码示例

本文整理汇总了C#中PropertyCollection.AddFromString方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyCollection.AddFromString方法的具体用法?C# PropertyCollection.AddFromString怎么用?C# PropertyCollection.AddFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyCollection的用法示例。


在下文中一共展示了PropertyCollection.AddFromString方法的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();
        }
开发者ID:jlyonsmith,项目名称:Playroom,代码行数:76,代码来源:BuildContext.cs


注:本文中的PropertyCollection.AddFromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。