Inheritance: IDisposable
        public void Execute(string[] arguments)
        {
            if (arguments.Length < 2)
                return;
            var scripts = new ReactiveScriptReader(
                _token,
                _pluginLocator,
                (p, m) => {},
                (m) => {})
                .Read();
            var script = scripts.FirstOrDefault(x => x.Name.Equals(arguments[0]));
            if (script == null)
                return;

            var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var match1 = "'codemodel' 'raw-filesystem-change-filecreated' '" + script.File + "'";
            var match2 = "'codemodel' 'raw-filesystem-change-filechanged' '" + script.File + "'";
            Logger.Write("Looking for: " + match1);
            Logger.Write("Looking for: " + match2);
            var name = "rscript-" + Path.GetFileNameWithoutExtension(script.File);
            var hash = 0;
            try {
                using (var output = new OutputClient(_token, (publisher, msg) => { if (name == publisher) _dispatch(msg); }))
                {
                    output.Connect();
                    var proc = new Process();
                    proc.Query(
                        Path.Combine(root, Path.Combine("EventListener", "OpenIDE.EventListener.exe")),
                        "",
                        false,
                        _token,
                        (error, s) => {
                            if (s == match1 || s == match2) {
                                var newHas = File.ReadAllText(script.File).GetHashCode();
                                if (newHas != hash) {
                                    hash = newHas;
                                    Thread.Sleep(200);
                                    _dispatch("");
                                    _dispatch("Triggering reactive script:");
                                    _dispatch("event|"+arguments[1]);
                                }
                            }
                        }
                    );
                }
            } catch (Exception ex) {
                Logger.Write(ex);
            }
        }
Ejemplo n.º 2
0
 private void watchOutput(object state)
 {
     var instance = (WatchInstance)state;
     var client = new OutputClient(instance.Path, instance.Printer);
     while (true) {
         client.Connect();
         while (client.IsConnected) {
             Thread.Sleep(100);
         }
         if (!instance.Follow)
             break;
         Thread.Sleep(1000);
     }
 }