ClrPlus.Scripting.MsBuild.Packaging.ProjectPlus.LookupItem C# (CSharp) Метод

LookupItem() приватный Метод

private LookupItem ( Microsoft.Build.Construction.ProjectItemGroupElement parent, string name, string condition = null ) : Microsoft.Build.Construction.ProjectItemElement
parent Microsoft.Build.Construction.ProjectItemGroupElement
name string
condition string
Результат Microsoft.Build.Construction.ProjectItemElement
        internal ProjectItemElement LookupItem(ProjectItemGroupElement parent, string name, string condition = null)
        {
            ProjectItemElement property = null;

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

            if(string.IsNullOrEmpty(condition)) {
                property = parent.Items.FirstOrDefault(each => name == each.ItemType && string.IsNullOrEmpty(each.Condition));
                if(property != null) {
                    return property;
                }
                return parent.AddItem(name, "UNUSED");
            }

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

            property = parent.AddItem(name, "UNUSED");

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

            return property;
        }