Пример #1
0
            public int Run()
            {
                if (_options.ShowConsole)
                {
                    _ = new ConsoleWindow();
                }

                var serverEndpoint        = _options.ServerEndpoint;
                var environmentConnection = new ServerProxy(serverEndpoint);

                Console.Write("connecting to server: " + serverEndpoint + "...");
                var connectTask = environmentConnection.ConnectAsync(Guid.Empty);

                connectTask.Wait();
                Console.WriteLine("done.");
                var resourceCatalogProxy = new ResourceCatalogProxy(environmentConnection);

                var config = new WorkerContext(_options, resourceCatalogProxy, TriggersCatalog.Instance);

                using (var watcher = new FileSystemWatcherWrapper())
                {
                    config.WatchTriggerResource(watcher);
                    watcher.Created += (o, t) => Environment.Exit(1);
                    watcher.Changed += (o, t) => Environment.Exit(0);
                    watcher.Deleted += (o, t) => Environment.Exit(0);
                    watcher.Renamed += (o, t) => Environment.Exit(0);

                    new QueueWorkerImplementation(config).Run();
                }

                return(0);
            }