예제 #1
0
        private void AddProperties(TreeNode parent, IEnumerable <KeyValuePair <string, string> > properties, IProjectOrEvaluation project = null)
        {
            if (properties == null)
            {
                return;
            }

            if (properties is ICollection collection)
            {
                parent.EnsureChildrenCapacity(collection.Count);
            }

            foreach (var kvp in properties)
            {
                var property = new Property
                {
                    Name  = SoftIntern(kvp.Key),
                    Value = SoftIntern(kvp.Value)
                };
                parent.Children.Add(property); // don't use AddChild for performance
                property.Parent = parent;

                if (project != null)
                {
                    if (string.Equals(kvp.Key, Strings.TargetFramework, StringComparison.OrdinalIgnoreCase))
                    {
                        project.TargetFramework = kvp.Value;
                    }
                    else if (string.Equals(kvp.Key, Strings.TargetFrameworks, StringComparison.OrdinalIgnoreCase))
                    {
                        // we want TargetFramework to take precedence over TargetFrameworks when both are present
                        if (string.IsNullOrEmpty(project.TargetFramework) && !string.IsNullOrEmpty(kvp.Value))
                        {
                            project.TargetFramework = kvp.Value;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void AddProperties(TreeNode parent, IEnumerable <KeyValuePair <string, string> > properties, IProjectOrEvaluation project = null)
        {
            if (properties == null)
            {
                return;
            }

            foreach (var kvp in properties)
            {
                var property = new Property
                {
                    Name  = Intern(kvp.Key),
                    Value = Intern(kvp.Value)
                };
                parent.AddChild(property);

                if (project != null)
                {
                    if (kvp.Key == Strings.TargetFramework)
                    {
                        project.TargetFramework = kvp.Value;
                    }
                    else if (kvp.Key == Strings.TargetFrameworks)
                    {
                        // we want TargetFramework to take precedence over TargetFrameworks when both are present
                        if (string.IsNullOrEmpty(project.TargetFramework) && !string.IsNullOrEmpty(kvp.Value))
                        {
                            project.TargetFramework = kvp.Value;
                        }
                    }
                }
            }
        }