示例#1
0
        /// <summary>
        ///  Copies common properties when evaluating multiple nodes into one
        /// </summary>
        /// <typeparam name="T">Type to return - for convenience</typeparam>
        /// <param name="nodes">The nodes this new node is derived from</param>
        /// <returns>The new node</returns>
        public T ReducedFrom <T>(params Node[] nodes) where T : Node
        {
            foreach (var node in nodes)
            {
                if (node == this)
                {
                    continue;
                }

                Location = node.Location;

                if (node.PreComments)
                {
                    if (PreComments)
                    {
                        PreComments.AddRange(node.PreComments);
                    }
                    else
                    {
                        PreComments = node.PreComments;
                    }
                }

                if (node.PostComments)
                {
                    if (PostComments)
                    {
                        PostComments.AddRange(node.PostComments);
                    }
                    else
                    {
                        PostComments = node.PostComments;
                    }
                }

                IsReference = node.IsReference;
            }

            return((T)this);
        }
示例#2
0
文件: Node.cs 项目: everlive/cassette
        /// <summary>
        ///  Copies common properties when evaluating multiple nodes into one
        /// </summary>
        /// <typeparam name="TN1">Type to return - for convenience</typeparam>
        /// <param name="nodes">The nodes this new node is derived from</param>
        /// <returns>The new node</returns>
        public TN1 ReducedFrom <TN1>(params Node[] nodes) where TN1 : Node
        {
            foreach (Node node in nodes)
            {
                if (node == this)
                {
                    continue;
                }

                Index = node.Index;

                if (node.PreComments)
                {
                    if (PreComments)
                    {
                        PreComments.AddRange(node.PreComments);
                    }
                    else
                    {
                        PreComments = node.PreComments;
                    }
                }

                if (node.PostComments)
                {
                    if (PostComments)
                    {
                        PostComments.AddRange(node.PostComments);
                    }
                    else
                    {
                        PostComments = node.PostComments;
                    }
                }
            }

            return((TN1)this);
        }