public static void Main(string[] args)
        {
            // Configure paramters
            var shouldShowHelp = false;
            var fType          = "";
            var fPath          = "";

            var p = new OptionSet {
                { "type|file_type=", "the type of the file to read.", type => fType = type },
                { "path|file_path=", "the file path.", path => fPath = path },
                { "sh|show_help", "show help message and exit.", sh => shouldShowHelp = sh != null },
            };

            List <string> extra;

            try
            {
                extra = p.Parse(args);
                fType = fType.ToLower();

                // Check whether file exists
                if (!File.Exists(fPath))
                {
                    Console.WriteLine("The file does not exist.");
                }

                // Check whether file type is the same as type given
                if (!fPath.ToLower().Contains(fType))
                {
                    Console.WriteLine("The type of input file should be the same as the type given.");
                }
                else
                {
                    if (fType == "lp")
                    {
                        LPService.PrintLP(fPath);
                    }
                    else if (fType == "tou")
                    {
                        TOUService.PrintTOU(fPath);
                    }
                    else
                    {
                        Console.WriteLine("The file type can only be 'LP' or 'TOU'");
                    }
                }
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `--sh' for more information.");
                return;
            }

            if (shouldShowHelp)
            {
                ShowHelp(p);
                return;
            }
        }
Example #2
0
        public FileTest(string lpPath, string touPath)
        {
            ConsoleOutputService svc = new ConsoleOutputService();

            this._lpPath  = lpPath;
            this._touPath = touPath;
            _lpService    = new LPService(svc);
            _touService   = new TOUService(svc);
        }
Example #3
0
 public EnergyWorker(LPService lpService, TOUService touService, IOutputService outputService)
 {
     _lpService  = lpService;
     _touService = touService;
 }