示例#1
0
        private static void ReadFunc(string[] obj)
        {
            logger.Log("Read function invoked.", LogLevel.INFO);

            if (obj.Length != 1)
            {
                logger.Log("No PATH argument provided to Read function", LogLevel.WARNING);

                Console.WriteLine("You have to provide PATH to .dll file");
                Console.WriteLine("If you're having issues with the program type 'help' for more instructions.");
                return;
            }
            DataContext.InjectOpenFilePathService(CommandLineOpenFilePathService.Create(obj[0]));
            DataContext.LoadFromFileDataCommand.Execute("Load");
            DataContext.ReadDataCommand.Execute("Read");
            Console.WriteLine("Read: " + DataContext.ReadFileName);
            try
            {
                rootItem = DataContext.HierarchicalAreas[0];
            }
            catch (ArgumentOutOfRangeException e)
            {
                logger.Log("Wrong PATH argument provided to Read function\n" + e, LogLevel.WARNING);

                Console.WriteLine("You have to provide correct PATH to .dll file. Your PATH is wrong or file doesn't exist.");
                Console.WriteLine("If you're having issues with the program type 'help' for more instructions.");
                return;
            }

            logger.Log("Correctly read " + rootItem.ToString(), LogLevel.INFO);
        }
        public static CommandLineOpenFilePathService Create(string filePath)
        {
            CommandLineOpenFilePathService commandLineOpenFilePathService = new CommandLineOpenFilePathService
            {
                _filePath = filePath
            };

            return(commandLineOpenFilePathService);
        }