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


C# Project.Lookup方法代码示例

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


在下文中一共展示了Project.Lookup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

        public static void Add(View view, Project project)
        {
            var prjPlus = project.Lookup();
            if (prjPlus.View != null) {
                throw new ClrPlusException("Configurations already registered for project");
            }
            prjPlus.View = view;

            var pkgName = view.GetMacroValue("pkgname");

            // add the startup/init tasks
            var task = project.Xml.AddUsingTask(pkgName + "_Contains", @"$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll", null);
            task.TaskFactory = "CodeTaskFactory";
            var pgroup = task.AddParameterGroup();
            pgroup.AddParameter("Text", "false", string.Empty, "System.String");
            pgroup.AddParameter("Library", "false", "true", "System.String");
            pgroup.AddParameter("Value", "false", "true", "System.String");
            pgroup.AddParameter("Result", "true", string.Empty, "System.String");

            var body = task.AddUsingTaskBody(string.Empty, string.Empty);

            // thank you.
            body.XmlElement().Append("Code").InnerText = @"Result = ((Text ?? """").Split(';').Contains(Library) ) ? Value : String.Empty;";

            var initTarget = project.AddInitTarget(pkgName + "_init");

            var pivots = view.GetChildPropertyNames();

            foreach (var pivot in pivots) {
                dynamic cfg = view.GetProperty(pivot);
                IEnumerable<string> choices = cfg.choices;

                if(!((View)cfg).GetChildPropertyNames().Contains("key")) {
                    // add init steps for this.
                    var finalPropName = "{0}-{1}".format(pivot, pkgName);

                    foreach (var choice in choices) {

                        var choicePropName = "{0}-{1}".format(pivot, choice);

                        var tsk = initTarget.AddTask("pkgName_Contains");
                        tsk.SetParameter("Text", choicePropName);
                        tsk.SetParameter("Library", pkgName);
                        tsk.SetParameter("Value", choice);
                        tsk.Condition = @"'$({0})'==''".format(finalPropName);
                        tsk.AddOutputProperty("Result", finalPropName);
                    }

                    project.Xml.AddPropertyGroup().AddProperty(finalPropName, choices.FirstOrDefault()).Condition = @"'$({0})' == ''".format(finalPropName);
                }
            }
        }
开发者ID:virmitio,项目名称:clrplus,代码行数:52,代码来源:Configurations.cs

示例2: GenerateCondition

        public static string GenerateCondition(Project project, string key)
        {
            var view = project.Lookup().View;
            var pivots = view.GetChildPropertyNames();

            var options = key.Replace(",", "\\").Replace("&", "\\").Split(new char[] {
                '\\', ' '
            }, StringSplitOptions.RemoveEmptyEntries).ToList();

            var conditions = new List<string>();

            foreach(var pivot in pivots) {
                foreach(var option in options) {
                    dynamic cfg = view.GetProperty(pivot);
                    IEnumerable<string> choices = cfg.choices;
                    if(choices.Contains(option)) {
                        if(((View)cfg).GetChildPropertyNames().Contains("key")) {
                            // this is a standard property, us
                            conditions.Add("'$({0})' == '{1}'".format((string)cfg.Key, option));
                        } else {
                            conditions.Add("'$({0}-{1})' == '{2}'".format((string)pivot, view.GetMacroValue("pkgname"), option));
                        }

                        options.Remove(option);
                        break;
                    }
                }

            }

            if (options.Any()) {
                throw new ClrPlusException("Unknown configuration choice: {0}".format(options.FirstOrDefault()));
            }

            return conditions.Aggregate((current, each) => (string.IsNullOrEmpty(current) ? current : (current + " and ")) + each);
        }
开发者ID:virmitio,项目名称:clrplus,代码行数:36,代码来源:Configurations.cs

示例3: NormalizeConditionKey

        internal static string NormalizeConditionKey(Project project, string key)
        {
            if(!project.HasProject()) {
                return key;
            }

            return NormalizeConditionKey(key, project.Lookup().View);
        }
开发者ID:virmitio,项目名称:clrplus,代码行数:8,代码来源:Configurations.cs


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