Пример #1
0
        static void Main(string[] args)
        {
            // Reading command-line arguments

            var options = new Options();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                Environment.ExitCode = 2;
                return;
            }

            // Reading settings (given via command-line or configuration file)

            List<WarmUpContext> contexts;

            try
            {
                if (options.UseConfig)
                {
                    // Taking parameters from configuration file

                    contexts = ConfigContextReader.Read();
                }
                else
                {
                    // Taking parameters from command-line

                    contexts = CommandLineContextReader.Read(options);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Application settings are incorrect.");
                Console.WriteLine(ex.Message);

                Environment.ExitCode = 2;
                return;
            }

            // Performing warm up

            try
            {
                _logger.Info("Starting warm up...");

                foreach (var context in contexts)
                {
                    new ProjectCollectionWarmUp(context).Run();
                }

                _logger.Info("Done.");
            }
            catch (Exception ex)
            {
                _logger.ErrorException(string.Format("The program failed with error: {0}", ex.Message), ex);
                Environment.ExitCode = 1;
            }
        }
        public static List<WarmUpContext> Read(Options options)
        {
            if (options.ItemSpecs.Count == 0)
                throw new Exception("At least one ItemSpec should be specified.");

            List<WarmUpContext> contexts = new List<WarmUpContext>();
            contexts.Add(new WarmUpContext(new Uri(options.ProjectCollectionUrl), new Uri(options.ProxyUrl), options.ItemSpecs));

            return contexts;
        }