Example #1
0
        static void Main(string[] args)
        {
            StandardMessage.Welcome();
            StandardMessage.AddLine(1);

            string           data   = SortName.InputFile();
            IList <string>   names  = SortName.ReadData(data);
            List <NameModel> people = new List <NameModel>();

            StandardMessage.Enter();
            StandardMessage.Clear();

            SortName.Sort(names, people);

            StandardMessage.AddLine(1);

            ExportSortedNames.Export(people);
        }
        public static void Export(List <NameModel> people)
        {
            Console.Write("Specify export directory: ");
            string       path       = Console.ReadLine();
            FileStream   stream     = new FileStream(path + "/sorted-names-list.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamWriter writer     = new StreamWriter(stream);
            TextWriter   textWriter = Console.Out;

            Console.SetOut(writer);
            foreach (var sort in people.OrderBy(q => q.IndexName).ThenBy(q => q.FullName))
            {
                Console.WriteLine(sort.FullName);
            }
            Console.SetOut(textWriter);
            writer.Close();
            stream.Close();
            Console.WriteLine("File exported with name sorted-names-list.txt");
            StandardMessage.Enter();
        }