Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
                return;
            var dispatcher = new Dispatcher();
            configureHandlers(dispatcher);
            var handler = dispatcher.GetHandler(args[0]);
            if (handler == null)
                return;

            try {
                handler.Execute(getParameters(args));
            } catch (Exception ex) {
                var builder = new OutputWriter();
                builder.Error(ex.Message.Replace(Environment.NewLine, ""));
                if (ex.StackTrace != null) {
                    ex.StackTrace
                        .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList()
                        .ForEach(line => builder.Error(line));
                }
            }
        }
Exemplo n.º 2
0
 private static void handleMessage(CommandMessage msg, IResponseWriter writer, bool serverMode)
 {
     if (msg == null)
         return;
     Logger.Write("Handling message: " + msg);
     var handler = _dispatcher.GetHandler(msg.Command);
     if (handler == null) {
         writer.Write("error|" + msg.Command + " is not a valid C# plugin command. For a list of commands type oi.");
         return;
     }
     try {
         if (handler == null)
             return;
         handler.Execute(writer, msg.Arguments.ToArray());
     } catch (Exception ex) {
         var builder = new OutputWriter(writer);
         writeException(builder, ex);
     }
     Logger.Write("Done handling message");
 }
Exemplo n.º 3
0
 static void writeException(OutputWriter builder, Exception ex)
 {
     if (ex == null)
         return;
     builder.WriteError(ex.Message.Replace(Environment.NewLine, ""));
     if (ex.StackTrace != null) {
         ex.StackTrace
             .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList()
             .ForEach(line => builder.WriteError(line));
     }
     writeException(builder, ex.InnerException);
 }
Exemplo n.º 4
0
 public void Setup()
 {
     _cache = new OutputWriter(new NullResponseWriter());
     _parser = new AssemblyParser(_cache);
 }