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 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()); }