Exemplo n.º 1
0
        private static ArgsModel ParseArgs(string[] args)
        {
            var result = new ArgsModel();

            if (args.Length > 0)
            {
                foreach (string item in args)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        string[] itemArr   = item.Split('=', 2);
                        string   paramName = itemArr[0];
                        if (String.Equals(paramName, "urls", StringComparison.OrdinalIgnoreCase))
                        {
                            if (itemArr.Length > 1)
                            {
                                string   val  = itemArr[1];
                                string[] urls = val
                                                .Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries)
                                                .Select(x => x.Trim()).Distinct().ToArray();
                                result.ListenUrls = urls;
                            }
                        }
                    }
                }
            }
            if (result.ListenUrls.Length == 0)
            {
                result.ListenUrls = new string[] { "https://localhost:5001", "http://localhost:5000" };
            }
            return(result);
        }
Exemplo n.º 2
0
        public static IHostBuilder CreateHostBuilder(string[] args)
        {
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;

            Directory.SetCurrentDirectory(baseDir);
            ArgsModel argModel = ParseArgs(args);

            return(Host.CreateDefaultBuilder(args)
                   .ConfigureWebHostDefaults(webBuilder =>
            {
                // TODO configure root path
                webBuilder
                .UseContentRoot(baseDir)
                .UseUrls(argModel.ListenUrls)
                .UseStartup <Startup>();
            }));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var config = new ArgsModel(args);

            if (config.Result)
            {
                var colorful = new ColorfulQrCreater(config);
                if (colorful.IsCreated)
                {
                    colorful.ProgressChanged += Colorful_ProgressChanged;
                    switch (config.Mode)
                    {
                    case Mode.Png:
                        colorful.SavePng();
                        ConsoleHelper.WriteLine(ConsoleHelper.Format.Done, config.OutputPath);
                        break;

                    default:
                        colorful.SaveGif();
                        ConsoleHelper.WriteLine(ConsoleHelper.Format.Done, config.OutputPath);
                        break;
                    }
                }
            }
            else
            {
                ConfigModel.CreateDefaultConfig();
                Console.ReadKey();
                //ConsoleHelper.WriteLine(ConsoleHelper.Format.Error, "Args");
            }
            if (config.WaitKey)
            {
                Console.ReadKey();
            }


            //var bitmap = System.Drawing.Image.FromFile("Resources/tank.bmp");
            //bitmap.Save("Resources/tank.png", System.Drawing.Imaging.ImageFormat.Png);
        }