예제 #1
0
        static void Main(string[] args)
        {
            string      FileNamePathToWrite;
            ILogger     logger       = LogFactory.CreatLogger();
            IMessage    errorMessage = MessageFactory.CreatMessage(Message.MessageType.Error);
            IDisplay    display;
            NamesFile   file;
            List <Name> names;

            try
            {
                //
                //Get file name/path from app.config
                //
                FileNamePathToWrite = ConfigurationManager.AppSettings["FileNamePathToWrite"];

                //
                //create screen display object from the factory
                //
                display = DisplayFactory.CreatDisplay();

                //
                //get file name and path for reading names from command parameter; file name and path for writing names to is set by program
                //
                file = FileInfoValidator.GetFile(args, FileNamePathToWrite);

                //
                //only proceed further if file is available
                //
                if (file != null)
                {
                    //
                    // get list of name object by reading
                    //
                    names = ReadNamesHelper.ReadNamesFromStorage(file);

                    //
                    //do sorting on names
                    //
                    names = NameSorter.Sort(names);

                    //
                    //writing sorted names to a storage
                    //
                    WriteNamesHelper.WriteNamesToStorage(file, names);


                    //
                    //display sorted name list on screen
                    //
                    display.DisplayName(names);
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message);
                errorMessage.DisplayMessage(ex.Message);
            }
        }