상속: ICloneable
예제 #1
0
파일: MessageSet.cs 프로젝트: pifta/NCLDR
        /// <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);
        }
예제 #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;
 }
예제 #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);
        }
예제 #4
0
파일: MessageSet.cs 프로젝트: hmvs/NCLDR
        /// <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;
        }