Exemplo n.º 1
0
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedListPatterns">The child object</param>
        /// <param name="parentListPatterns">The parent object</param>
        /// <returns>The combined object</returns>
        public static ListPattern[] Combine(ListPattern[] combinedListPatterns, ListPattern[] parentListPatterns)
        {
            if (combinedListPatterns == null && parentListPatterns == null)
            {
                return null;
            }
            else if (combinedListPatterns == null)
            {
                return (ListPattern[])parentListPatterns.Clone();
            }
            else if (parentListPatterns == null)
            {
                return combinedListPatterns;
            }

            List<ListPattern> combinedListPattern = new List<ListPattern>(combinedListPatterns);
            foreach (ListPattern parentListPattern in parentListPatterns)
            {
                if (!(from ups in combinedListPatterns
                      where string.Compare(ups.Id, parentListPattern.Id, StringComparison.InvariantCulture) == 0
                      select ups).Any())
                {
                    // this unit pattern set does not exist in the combined list
                    combinedListPattern.Add(parentListPattern);
                }
            }

            return combinedListPattern.ToArray();
        }
Exemplo n.º 2
0
        /// <summary>
        /// GetListPatterns gets the resolved ListPatterns
        /// </summary>
        /// <returns>The resolved ListPatterns</returns>
        private ListPattern[] GetListPatterns()
        {
            ListPattern[] listPatterns = null;
            if (this.listPatternsNoParents != null)
            {
                listPatterns = (ListPattern[])this.listPatternsNoParents.Clone();
            }

            Culture[] parentCultures = this.GetParents();
            foreach (Culture parentCulture in parentCultures)
            {
                listPatterns = ListPattern.Combine(listPatterns, parentCulture.listPatternsNoParents);
            }

            return(listPatterns);
        }