Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            if (args.Contains("--debug"))
            {
                Debugger.Launch();
            }
            var dict = new ConsoleArgumentHelper().ParseDictionary(args);

            var outstring   = dict.SafeGet("out", "hello");
            var errorstring = dict.SafeGet("error", "");
            var state       = dict.SafeGet("state", 0);
            var throwex     = dict.SafeGet("throwex", false);
            var doreadln    = dict.SafeGet("doreadln", false);
            var timeout     = dict.SafeGet("timeout", 0);
            var interactive = dict.SafeGet("interactive", false);
            var passread    = dict.SafeGet("passread", false);

            if (!string.IsNullOrWhiteSpace(outstring))
            {
                Console.Out.WriteLine(outstring);
                Console.Out.Flush();
            }
            if (doreadln)
            {
                Console.WriteLine(Console.ReadLine());
            }

            if (interactive)
            {
                Console.WriteLine("a");
                var fst = Console.ReadLine();
                Console.WriteLine("b");
                var sec = Console.ReadLine();
                Console.WriteLine(fst.ToInt() + sec.ToInt());
            }

            if (passread)
            {
                Console.Write("Enter login: "******"Password: "******"/{0}:{1}/", user, pass);
            }

            if (!string.IsNullOrWhiteSpace(errorstring))
            {
                Console.Error.WriteLine(errorstring);
            }
            if (timeout != 0)
            {
                Thread.Sleep(timeout * 1000);
            }
            if (throwex)
            {
                throw new Exception("some error");
            }

            return(state);
        }
Ejemplo n.º 2
0
		static int Main(string[] args){
            if (args.Contains("--debug"))
            {
                Debugger.Launch();
            }
			var dict = new ConsoleArgumentHelper().ParseDictionary(args);

			var outstring = dict.SafeGet("out", "hello");
			var errorstring = dict.SafeGet("error", "");
			var state = dict.SafeGet("state", 0);
			var throwex = dict.SafeGet("throwex", false);
			var doreadln = dict.SafeGet("doreadln", false);
			var timeout = dict.SafeGet("timeout", 0);
			var interactive = dict.SafeGet("interactive", false);
			var passread = dict.SafeGet("passread", false);
			
			if (!string.IsNullOrWhiteSpace(outstring)){
				Console.Out.WriteLine(outstring);
                Console.Out.Flush();
			}
			if (doreadln){
				Console.WriteLine(Console.ReadLine());
			}

			if (interactive){
				Console.WriteLine("a");
				var fst = Console.ReadLine();
				Console.WriteLine("b");
				var sec = Console.ReadLine();
				Console.WriteLine(fst.ToInt()+sec.ToInt());
			}

			if (passread){
				Console.Write("Enter login: "******"Password: "******"/{0}:{1}/",user,pass);

			}

			if (!string.IsNullOrWhiteSpace(errorstring)){
				Console.Error.WriteLine(errorstring);	
			}
			if (timeout!=0){
				Thread.Sleep(timeout*1000);
			}
			if (throwex){
				throw new Exception("some error");
			}

			return state;
		}