public static string GetString <T>(string name, Cultures culture)
        {
            Type resourcesType = typeof(T);
            var  manager       = new ResourceManager(resourcesType);

            return(manager.GetString(name, new System.Globalization.CultureInfo(culture.ToString())));
        }
Exemplo n.º 2
0
        private static void UpdateCulture(Cultures name)
        {
            using (CustomConfigSectionManager customConfigManager = new CustomConfigSectionManager())
            {
                customConfigManager.UpdateCulture(new CultureElement {
                    Name = name
                });
            }

            CultureInfo culture = new CultureInfo(Convert.ToInt32(name.ToString("d")));

            Thread.CurrentThread.CurrentUICulture = culture;
        }
Exemplo n.º 3
0
        private static void Watcher_Changed(object sender, FileSystemEventArgs args)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Convert.ToInt32(currentCulture.ToString("D")));

            // Игнорирование папок.
            if (Directory.Exists(args.FullPath))
            {
                return;
            }
            bool   hasMoved   = false;
            string folderName = "Other";

            if (args.ChangeType == WatcherChangeTypes.Created)
            {
                foreach (RuleElement item in Rules)
                {
                    if (Regex.IsMatch(args.Name, item.RegexPattern))
                    {
                        folderName = item.DestinationFolder;
                        MoveTo(args.FullPath, folderName, item.IsAutoIncrementId, item.IsAppendDate);
                        hasMoved = true;
                        break;
                    }
                }
            }
            if (!hasMoved)
            {
                MoveTo(args.FullPath, folderName, false, false);
            }
            // задание 3
            StringBuilder logMessage = new StringBuilder(DialogStrings.LogMessage);

            logMessage
            .Replace("{fileName}", args.Name)
            .Replace("{datetime}", DateTime.Now.ToString())
            .Replace("{folderName}", folderName);

            Console.WriteLine("id: " + Id.ToString() + " " + logMessage.ToString());
        }