ClrPlus.Scripting.MsBuild.Packaging.ProjectPlus.LookupProperty C# (CSharp) Method

LookupProperty() private method

private LookupProperty ( Microsoft.Build.Construction.ProjectPropertyGroupElement parent, string name, string condition = null ) : Microsoft.Build.Construction.ProjectPropertyElement
parent Microsoft.Build.Construction.ProjectPropertyGroupElement
name string
condition string
return Microsoft.Build.Construction.ProjectPropertyElement
        internal ProjectPropertyElement LookupProperty(ProjectPropertyGroupElement parent, string name, string condition = null)
        {
            ProjectPropertyElement property = null;

            var label = Pivots.GetExpressionLabel(condition);
            name = name.Replace(".", "_");

            if(string.IsNullOrEmpty(condition)) {
                property = parent.Properties.FirstOrDefault(each => name == each.Name && string.IsNullOrEmpty(each.Condition));
                if(property != null) {
                    return property;
                }
                return parent.AddProperty(name, "");
            }

            var conditionExpression = Pivots.GetMSBuildCondition(Name, condition);
            property = parent.Properties.FirstOrDefault(each => name == each.Name && each.Condition == conditionExpression);
            if(property != null) {
                return property;
            }

            property = parent.AddProperty(name, "");

            property.Label = label;
            property.Condition = conditionExpression;
            return property;
        }

Same methods

ProjectPlus::LookupProperty ( string name, string condition = null ) : Microsoft.Build.Construction.ProjectPropertyElement