コード例 #1
0
        public void Start()
        {
            TextFormater tf = new TextFormater();
            String       config;

            config = ConfigurationManager.AppSettings["config"];

            // choose from where take text
            if (config.Equals("file"))
            {
                String path;
                String pattern = @"^(?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+$";
                Console.WriteLine("Enter path to file with text");

                while (!Regex.IsMatch((path = Console.ReadLine()), pattern, RegexOptions.IgnoreCase))
                {
                    Console.WriteLine("Invalid enter");
                }

                tf.FileLogic(path);
            }
            if (config.Equals("console"))
            {
                tf.ConsoleLogic();
            }
            Console.ReadLine();
        }
コード例 #2
0
        // work with console
        public void ConsoleLogic()
        {
            Console.WriteLine("Enter text");
            String       text = Console.ReadLine();
            TextFormater tf   = new TextFormater();

            text = tf.ToLowerCase(text);
            Console.WriteLine(text);
            text = tf.ToLineBreak(text);
            Console.WriteLine(text);
        }
コード例 #3
0
 // work with file
 public void FileLogic(String path)
 {
     try
     {
         String text = File.ReadAllText(path);
         //Console.WriteLine(text);
         TextFormater tf = new TextFormater();
         text = tf.ToLowerCase(text);
         Console.WriteLine(text);
         text = tf.ToLineBreak(text);
         Console.WriteLine(text);
     }
     catch (Exception e)
     {
         Console.WriteLine("File not found");
         //Console.WriteLine(e);
     }
 }