コード例 #1
0
ファイル: Dictionary.cs プロジェクト: KerwinMa/justEdit-
            public static DictionaryItem Import(XmlNode xmlData, DictionaryItem parent)
            {
                string key = xmlData.Attributes["Key"].Value;

                XmlNodeList    values     = xmlData.SelectNodes("./Value");
                XmlNodeList    childItems = xmlData.SelectNodes("./DictionaryItem");
                DictionaryItem newItem;
                bool           retVal = false;

                if (!DictionaryItem.hasKey(key))
                {
                    if (parent != null)
                    {
                        DictionaryItem.addKey(key, " ", parent.key);
                    }
                    else
                    {
                        DictionaryItem.addKey(key, " ");
                    }

                    if (values.Count > 0)
                    {
                        //Set language values on the dictionary item
                        newItem = new DictionaryItem(key);
                        foreach (XmlNode xn in values)
                        {
                            string cA       = xn.Attributes["LanguageCultureAlias"].Value;
                            string keyValue = xmlHelper.GetNodeValue(xn);

                            Language valueLang = Language.GetByCultureCode(cA);

                            if (valueLang != null)
                            {
                                newItem.setValue(valueLang.id, keyValue);
                            }
                        }
                    }

                    if (parent == null)
                    {
                        retVal = true;
                    }
                }

                newItem = new DictionaryItem(key);

                foreach (XmlNode childItem in childItems)
                {
                    Import(childItem, newItem);
                }

                if (retVal)
                {
                    return(newItem);
                }
                else
                {
                    return(null);
                }
            }