Exemplo n.º 1
0
        public Task Start(ArgMap args)
        {
            if (args == null || args.Count < 1)
            {
                throw new ArgumentException("args");
            }

            var mode = args["-mode"][0];

            if (mode == "s")
            {
                return(new Server(33444).ReceiveLoop());
            }
            else if (mode == "c")
            {
                int.TryParse(args["-mc"][0], out int mc);
                int.TryParse(args["-ms"][0], out int size);
                var rand = args.ContainsKey("-r");
                return(new Client(33444).Send(mc, size, rand));
            }
            else
            {
                throw new ArgumentException("The SocketLoad -mode can only be <s> or <c>");
            }
        }
Exemplo n.º 2
0
        // Main.
        public static void Main(string[] args)
        {
            args = Arrays <string> .Shift(Strings.Split(Environment.CommandLine));

            if (args.Length <= 0)
            {
                Console.WriteLine(GetHelp()); return;
            }
            ListMap <string> argm = new ArgMap(GetOptionTypes(), args);

            if (argm.ContainsKey("_invalid"))
            {
                Console.WriteLine(GetInvalidOptions(argm)); return;
            }
            argm.Set("-r", "System.dll").Set("-r", "System.Core.dll").Set("-r", "Microsoft.CSharp.dll");
            string[] sources = GetSources(argm);
            if (sources == null || sources.Length == 0)
            {
                Console.WriteLine(""); return;
            }
            CompilerResults res = Compile(argm["-r"].ToArray(), GetSources(argm));

            try { if (res != null)
                  {
                      RunCode(res, GetCallArgs(argm));
                  }
            }
            catch (Exception e) { Console.WriteLine(e.ToString() + "\n" + e.StackTrace); }
        }