LocalizationData ReadAssemblyLocalization(String assemblyName)
        {
            var xmlPath = GetXmlFilePath(assemblyName);

            if (System.IO.File.Exists(xmlPath))
            {
                try
                {
                    using (var fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (var xr = new XmlTextReader(fs))
                        {
                            var data = LocalizationData.ReadXml(xr);
                            Logger.InfoFormat("Localization '{1}' for assembly '{0}' successfully loaded.", assemblyName, LangCode);
                            return(data);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Exception("Read Xml localization data error.", ex);
                }
            }
            return(new LocalizationData());
        }
 public EmbeddedXmlLocalizationStore(String langCode)
 {
     LangCode         = langCode;
     cache            = new Dictionary <Type, object>();
     loadedAssemblies = new HashSet <Assembly>();
     localizationData = new LocalizationData();
 }
        public LocalizationData GetLocalizationData(Assembly assembly)
        {
            var embeddedPath = String.Format(@"Localization\{0}.xml", LangCode);

            try
            {
                using (var fs = AssemblyHelper.ReadEmbeddedFile(assembly, embeddedPath))
                {
                    if (fs == null)
                    {
                        return(new LocalizationData());
                    }
                    using (var xr = new XmlTextReader(fs))
                    {
                        var data = LocalizationData.ReadXml(xr);
                        Debug.WriteLine("Embedded Localization '{1}' for assembly '{0}' successfully loaded.", assembly, LangCode);
                        return(data);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Read Xml localization data error: {0}", ex);
            }
            return(new LocalizationData());
        }
 public void SetLocalizationData(String assemblyName, LocalizationData data)
 {
     using (var xw = new XmlTextWriter(GetXmlFilePath(assemblyName), Encoding.UTF8))
     {
         xw.Formatting = Formatting.Indented;
         data.WriteXml(xw);
     }
 }
 public XmlLocalizationStore(String langCode, String path, IEnumerable <ILocalizationDataProvider> providers)
 {
     Path             = path;
     LangCode         = langCode;
     cache            = new Dictionary <Type, object>();
     loadedAssemblies = new HashSet <string>();
     localizationData = new LocalizationData();
     this.providers   = providers;
 }
 public static LocalizationData GetDefaultLocalizationData(Assembly assembly, IEnumerable<ILocalizationDataProvider> providers)
 {
     LocalizationData res = new LocalizationData();
     foreach (var p in providers)
     {
         var data = p.ReadDefaultData(assembly);
         res.Include(data);
     }
     return res;
 }
示例#7
0
        public static LocalizationData GetDefaultLocalizationData(Assembly assembly, IEnumerable <ILocalizationDataProvider> providers)
        {
            LocalizationData res = new LocalizationData();

            foreach (var p in providers)
            {
                var data = p.ReadDefaultData(assembly);
                res.Include(data);
            }
            return(res);
        }
示例#8
0
 public void Override(LocalizationData d)
 {
     foreach (var od in d.Data)
     {
         Field[] data;
         if (Data.TryGetValue(od.Key, out data))
         {
             foreach (var f in data)
                 foreach (var nf in od.Value)
                     if (f.FieldName == nf.FieldName)
                         f.LocalizedText = nf.LocalizedText;
         }
     }
 }
示例#9
0
 public void Override(LocalizationData d)
 {
     foreach (var od in d.Data)
     {
         Field[] data;
         if (Data.TryGetValue(od.Key, out data))
         {
             foreach (var f in data)
             {
                 foreach (var nf in od.Value)
                 {
                     if (f.FieldName == nf.FieldName)
                     {
                         f.LocalizedText = nf.LocalizedText;
                     }
                 }
             }
         }
     }
 }
示例#10
0
 public void Include(LocalizationData d)
 {
     Include(d.Data);
 }
示例#11
0
 public void Include(LocalizationData d)
 {
     Include(d.Data);
 }