Re: Автоматическое определение CultureInfo для сателитных сб
От: Аноним  
Дата: 22.03.10 14:53
Оценка:
Сам написал. Может кому понадобиться

private List<CultureInfo> GetInstalledCultures() {
            // declare result
            List<CultureInfo> result = new List<CultureInfo>();
            // define paths
            String rootPath = Path.GetDirectoryName(this.GetType().Assembly.Location);
            String assemblyName = this.GetType().Assembly.GetName().Name;
            String satAssemblyName = assemblyName + ".resources.dll";
            // scan directory for sat assemblies
            DirectoryInfo root_di = new DirectoryInfo(rootPath);
            foreach (DirectoryInfo di in root_di.GetDirectories()) {
                String satAssemblyPath = Path.Combine(di.FullName, satAssemblyName);
                if (File.Exists(satAssemblyPath)) {
                    try {
                        // check that folder contains the correct data
                        CultureInfo ci = new CultureInfo(di.Name);
                        Assembly satAssembly = this.GetType().Assembly.GetSatelliteAssembly(ci);
                        // successful
                        result.Add(ci);
                    }
                    catch {
                        // Nothing. Test for the creating the CultureInfo and Assembly objects;
                    }
                }
            }
            // result
            return result;
        }
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.