Esempio n. 1
0
 protected virtual void OnAddAttribute(MSBuildAttribute attribute)
 {
 }
Esempio n. 2
0
        internal MSBuildElement(MSBuildElement parent, XElement xelement, ExpressionNode value)
            : base(parent, value)
        {
            XElement = xelement;

            MSBuildElement prevChild = null;

            foreach (var childElement in xelement.Elements)
            {
                var childSyntax = Syntax.GetChild(childElement.Name.FullName);
                if (childSyntax != null)
                {
                    ExpressionNode childValue = null;
                    if (childSyntax.ValueKind != MSBuildValueKind.Nothing && childElement.FirstChild is XText t)
                    {
                        childValue = ExpressionParser.Parse(t.Text, ExpressionOptions.ItemsMetadataAndLists, t.Span.Start);
                    }
                    var child = CreateElement(childSyntax.SyntaxKind, this, childElement, childValue);
                    if (prevChild == null)
                    {
                        firstChild = child;
                    }
                    else
                    {
                        prevChild.nextSibling = child;
                    }
                    prevChild = child;
                }
            }

            MSBuildAttribute prevAttribute = null;

            foreach (var xatt in xelement.Attributes)
            {
                var attributeSyntax = Syntax.GetAttribute(xatt.Name.FullName);
                if (attributeSyntax != null)
                {
                    ExpressionNode attributeValue = null;
                    if (!string.IsNullOrEmpty(xatt.Value))
                    {
                        if (attributeSyntax.ValueKind == MSBuildValueKind.Condition)
                        {
                            attributeValue = ExpressionParser.ParseCondition(xatt.Value, xatt.ValueOffset);
                        }
                        else
                        {
                            attributeValue = ExpressionParser.Parse(xatt.Value, ExpressionOptions.ItemsMetadataAndLists, xatt.ValueOffset);
                        }
                    }

                    var attribute = new MSBuildAttribute(this, xatt, attributeSyntax, attributeValue);
                    if (prevAttribute == null)
                    {
                        firstAttribute = attribute;
                    }
                    else
                    {
                        prevAttribute.nextSibling = attribute;
                    }
                    prevAttribute = attribute;
                }
            }
        }