Пример #1
0
 public static Configuration FromProgramOptions(ProgramOptions options)
 {
     return new Configuration
         {
             DumpFile = options.DumpFile,
             DumpsFolder = options.DumpsFolder,
             RecursiveSearch = options.RecursiveSearch,
             Filters = options.Filters.Select(filter => new Filter {ModuleName = filter}).ToList()
         };
 }
Пример #2
0
        private static void Main(string[] args)
        {
            var sw = Stopwatch.StartNew();
            var options = new ProgramOptions();
            if (!Parser.Default.ParseArguments(args, options))
            {
                Environment.Exit(1);
            }
            if (!options.IsValid)
            {
                Console.Error.WriteLine("The options are invalid");
                Environment.Exit(1);
            }

            options.Normalize();

            Configuration configuration;
            if (!string.IsNullOrEmpty(options.ConfigFile))
            {
                // load config from file
                var xs = new XmlSerializer(typeof(Configuration));
                using (var fs = new FileStream(options.ConfigFile, FileMode.Open))
                {
                    configuration = (Configuration)xs.Deserialize(fs);
                }
            }
            else
            {
                configuration = Configuration.FromProgramOptions(options);
            }

            while (!GetCredentialsIfNeeded(configuration))
            {
                Console.WriteLine("The credentials you supplied were wrong...");
                Console.WriteLine();
            }

            if (!GetProjectDetailsIfNeeded(configuration))
            {
                Console.WriteLine("The project details you supplied were wrong...");
                Environment.Exit(1);
            }

            Process(configuration);

            Console.WriteLine("Time to process: {0}", sw.Elapsed);
        }