示例#1
0
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedMessages">The child object</param>
        /// <param name="parentMessages">The parent object</param>
        /// <returns>The combined object</returns>
        public static MiscellaneousPatternSet Combine(MiscellaneousPatternSet combinedMessages, MiscellaneousPatternSet parentMessages)
        {
            if (combinedMessages == null && parentMessages == null)
            {
                return(null);
            }
            else if (combinedMessages == null)
            {
                return((MiscellaneousPatternSet)parentMessages.Clone());
            }
            else if (parentMessages == null)
            {
                return(combinedMessages);
            }

            if (parentMessages.MiscellaneousPatterns != null)
            {
                List <MiscellaneousPattern> combinedMessagesList = new List <MiscellaneousPattern>(combinedMessages.MiscellaneousPatterns);

                foreach (MiscellaneousPattern parentMessage in parentMessages.MiscellaneousPatterns)
                {
                    if (!(from m in combinedMessages.MiscellaneousPatterns
                          where m.Id == parentMessage.Id
                          select m).Any())
                    {
                        combinedMessagesList.Add(parentMessage);
                    }
                }

                combinedMessages.MiscellaneousPatterns = combinedMessagesList.ToArray();
            }

            return(combinedMessages);
        }
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedMessages">The child object</param>
        /// <param name="parentMessages">The parent object</param>
        /// <returns>The combined object</returns>
        public static MiscellaneousPatternSet Combine(MiscellaneousPatternSet combinedMessages, MiscellaneousPatternSet parentMessages)
        {
            if (combinedMessages == null && parentMessages == null)
            {
                return null;
            }
            else if (combinedMessages == null)
            {
                return (MiscellaneousPatternSet)parentMessages.Clone();
            }
            else if (parentMessages == null)
            {
                return combinedMessages;
            }

            if (parentMessages.MiscellaneousPatterns != null)
            {
                List<MiscellaneousPattern> combinedMessagesList = new List<MiscellaneousPattern>(combinedMessages.MiscellaneousPatterns);

                foreach (MiscellaneousPattern parentMessage in parentMessages.MiscellaneousPatterns)
                {
                    if (!(from m in combinedMessages.MiscellaneousPatterns
                          where m.Id == parentMessage.Id
                          select m).Any())
                    {
                        combinedMessagesList.Add(parentMessage);
                    }
                }

                combinedMessages.MiscellaneousPatterns = combinedMessagesList.ToArray();
            }

            return combinedMessages;
        }