Inheritance: ICloneable
Esempio n. 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 MessageSet Combine(MessageSet combinedMessages, MessageSet parentMessages)
        {
            if (combinedMessages == null && parentMessages == null)
            {
                return(null);
            }
            else if (combinedMessages == null)
            {
                return((MessageSet)parentMessages.Clone());
            }
            else if (parentMessages == null)
            {
                return(combinedMessages);
            }

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

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

                combinedMessages.Messages = combinedMessagesList.ToArray();
            }

            return(combinedMessages);
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the Culture class
 /// </summary>
 /// <param name="cultureData">The CultureData for this language/script/region/variant</param>
 public Culture(CultureData cultureData)
 {
     this.casingNoParents                    = cultureData.Casing;
     this.charactersNoParents                = cultureData.Characters;
     this.datesNoParents                     = cultureData.Dates;
     this.delimitersNoParents                = cultureData.Delimiters;
     this.Identity                           = cultureData.Identity;
     this.languageDisplayNamesNoParents      = cultureData.LanguageDisplayNames;
     this.layoutNoParents                    = cultureData.Layout;
     this.listPatternsNoParents              = cultureData.ListPatterns;
     this.messagesNoParents                  = cultureData.Messages;
     this.numbersNoParents                   = cultureData.Numbers;
     this.regionDisplayNamesNoParents        = cultureData.RegionDisplayNames;
     this.ruleBasedNumberFormattingNoParents = cultureData.RuleBasedNumberFormatting;
     this.scriptDisplayNamesNoParents        = cultureData.ScriptDisplayNames;
     this.unitPatternSetsNoParents           = cultureData.UnitPatternSets;
 }
Esempio n. 3
0
        /// <summary>
        /// GetMessages gets the resolved Messages
        /// </summary>
        /// <returns>The resolved Messages</returns>
        private MessageSet GetMessages()
        {
            MessageSet messages = null;

            if (this.messagesNoParents != null)
            {
                messages = (MessageSet)this.messagesNoParents.Clone();
            }

            Culture[] parentCultures = this.GetParents();
            foreach (Culture parentCulture in parentCultures)
            {
                messages = MessageSet.Combine(messages, parentCulture.messagesNoParents);
            }

            return(messages);
        }
Esempio n. 4
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 MessageSet Combine(MessageSet combinedMessages, MessageSet parentMessages)
        {
            if (combinedMessages == null && parentMessages == null)
            {
                return null;
            }
            else if (combinedMessages == null)
            {
                return (MessageSet)parentMessages.Clone();
            }
            else if (parentMessages == null)
            {
                return combinedMessages;
            }

            List<Message> combinedMessagesList = new List<Message>(combinedMessages.Messages);

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

            combinedMessages.Messages = combinedMessagesList.ToArray();

            return combinedMessages;
        }