Example #1
0
        /// <summary>
        /// Load resource from XML
        /// </summary>
        /// <param name="resourceElement">resource XML element</param>
        /// <param name="localeManager">locale manager</param>
        /// <param name="colorManager">color manager</param>
        /// <returns>resource instance</returns>
        private static IReadOnlyList <Text> LoadTextFromXml(
            XmlElement resourceElement,
            LocaleManager localeManager,
            ColorManager colorManager)
        {
            List <Text> textList = null;

            foreach (XmlElement contentElement in resourceElement.SelectNodes(ContentElementName))
            {
                var text = new Text(contentElement, localeManager, colorManager);
                if (textList == null)
                {
                    textList = new List <Text>();
                }

                textList.Add(text);
            }

            return((textList == null) || (textList.Count < 1) ? Empty <Text> .Array : textList.ToArray());
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Text" /> structure.
 /// </summary>
 /// <param name="contentElement">content XML element</param>
 /// <param name="localeManager">locale manager</param>
 /// <param name="colorManager">color manager</param>
 /// <example>
 /// <![CDATA[
 /// XML:
 /// <content locale="en-us">this is my content</content>
 /// ]]>
 /// </example>
 public Text(XmlElement contentElement, LocaleManager localeManager, ColorManager colorManager)
     : this(
         localeManager.GetLocaleId(contentElement.GetAttribute(LocaleAttributeName)),
         new Content(contentElement.InnerText, colorManager))
 {
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Resource" /> struct.
 /// </summary>
 /// <param name="resourceElement">resource element</param>
 /// <param name="localeManager">locale manager</param>
 /// <param name="colorManager">color manager</param>
 public Resource(XmlElement resourceElement, LocaleManager localeManager, ColorManager colorManager)
     : this(LoadTextFromXml(resourceElement, localeManager, colorManager))
 {
 }