/// <summary> /// Parse XmlNode to UnitList. /// </summary> /// <param name="node">XmlNode to be parsed.</param> /// <param name="nsmgr">XmlNamespaceManager.</param> public void Parse(XmlNode node, XmlNamespaceManager nsmgr) { if (node == null) { throw new ArgumentNullException("node"); } if (node.Attributes == null) { string message = Helper.NeutralFormat("the Attributes of node should not be null."); throw new ArgumentNullException("node", message); } XmlNode languageNode = node.Attributes["language"]; XmlNode typeNode = node.Attributes["type"]; if (languageNode == null || typeNode == null) { throw new InvalidDataException("unitList XmlNode " + "should have the following two properties: language, type."); } _language = Localor.StringToLanguage(languageNode.InnerText); _type = (UnitListType)Enum.Parse(typeof(UnitListType), typeNode.InnerText); XmlNodeList unitNodes = node.SelectNodes(@"tts:units/tts:unit", nsmgr); _units.Clear(); foreach (XmlNode unitNode in unitNodes) { UnitItem item = new UnitItem(); item.Parse(unitNode); _units.Add(item.Id, item); } }
/// <summary> /// Get key of the UnitList. /// </summary> /// <param name="language">Language of the UnitList.</param> /// <param name="type">Type of the UnitList.</param> /// <returns>Key of the UnitList.</returns> public static string GetKey(Language language, UnitListType type) { return Localor.LanguageToString(language) + "_" + type.ToString(); }