コード例 #1
0
        static void MergeElement(UxElement dst, UxElement src)
        {
            // TODO: This does not retain NameToken trivia, maybe directly modify token instead?
            if (dst.Name != src.Name)
            {
                dst.Name = src.Name;
            }

            MergeAttributes(dst, src);
            MergeChildNodes(dst, src);

            if (dst.IsEmpty != src.IsEmpty)
            {
                dst.IsEmpty = src.IsEmpty;
            }
        }
コード例 #2
0
        static void MergeAttributes(UxElement dst, UxElement src)
        {
            // Since we have better control over ordering of UxAttribute(s) than XAttribute
            // we could change this.

            // However it's not really that bad to say an attribute is removed and added instead
            // of changed after being reordered, since it's not that common.
            var matchCount = 0;

            foreach (var pair in dst.Attributes.Zip(src.Attributes, (dstAttr, srcAttr) => new { dstAttr, srcAttr }))
            {
                var dstAttr = pair.dstAttr;
                var srcAttr = pair.srcAttr;

                if (dstAttr.Name != srcAttr.Name)
                {
                    break;
                }

                if (!dstAttr.Syntax.Equals(srcAttr.Syntax))
                {
                    dstAttr.ReplaceSyntax(srcAttr.Syntax);
                }

                matchCount++;
            }

            // Remove all attributes below the matching ones
            foreach (var dstAttr in dst.Attributes.Skip(matchCount).ToArray())
            {
                dstAttr.Remove();
            }

            foreach (var srcAttr in src.Attributes.Skip(matchCount))
            {
                dst.Attributes.Add(new UxAttribute(srcAttr.Syntax));
            }
        }
コード例 #3
0
            // TODO: IMPLEMENT HERE 😀

            public AttributeList(UxElement container) : base(
                    container,
                    container._syntax.Attributes,
                    syntax => new UxAttribute(syntax))
            {
            }