Exemple #1
0
 public static LanguagePack CreateFromXml(XElement root)
 {
     if (root == null)
       {
     throw new ArgumentNullException("root");
       }
       if (root.Name != "pack")
       {
     return null;
       }
       LanguagePack pack = new LanguagePack
       {
     Language = root.Attribute("language").Value
       };
       XAttribute attribute = root.Attribute("default");
       bool result = false;
       if (attribute != null)
       {
     bool.TryParse(attribute.Value, out result);
       }
       pack.IsDefault = result;
       var enumerable = from item in root.Elements("item") select new { Key = ReadAttribute(item, "key"), Value = ReadAttribute(item, "value") };
       try
       {
     foreach (var type in enumerable)
     {
       if (!string.IsNullOrEmpty(type.Key))
       {
     pack.StringResources.Add(type.Key, type.Value);
       }
     }
       }
       catch (Exception)
       {
     throw;
       }
       return pack;
 }
Exemple #2
0
 public void AddLanguagePack(LanguagePack pack)
 {
     string str = pack.Language.ToLower();
     this.stringDictionary[str] = new Dictionary<string, string>(pack.StringResources);
     if (pack.IsDefault)
     {
       this.DefaultLanguage = str;
       this.OnPropertyChanged(null);
     }
     else if (this.container.Language == str)
     {
       this.OnPropertyChanged(null);
     }
 }