Exemple #1
0
            public void Reset(string name, string workspace, Config.ProjectOption set)
            {
                _config      = set ?? new Config.ProjectOption();
                _config.Name = name;

                IsRunOnSave       = _config.IsRunOnSave;
                CommandConfigPath = _config.CommandConfigPath;
                _workspace        = workspace;

                if (string.IsNullOrEmpty(CommandConfigPath) == false)
                {
                    var commandFilePath = Path.GetFullPath(Path.Combine(workspace, CommandConfigPath));
                    if (File.Exists(commandFilePath))
                    {
                        var text = File.ReadAllText(commandFilePath);
                        _commands = JsonConvert.DeserializeObject <List <Command> >(text);

                        if (_commandFilewatcher != null)
                        {
                            _commandFilewatcher.Changed -= OnCommandsFileChanged;
                            _commandFilewatcher.Dispose();
                        }
                        _commandFilewatcher = new FileSystemWatcher()
                        {
                            Path         = Path.GetDirectoryName(commandFilePath),
                            Filter       = "*" + Path.GetExtension(commandFilePath),
                            NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
                                           | NotifyFilters.FileName | NotifyFilters.DirectoryName
                        };
                        _commandFilewatcher.Changed += OnCommandsFileChanged;

                        _commandFilewatcher.EnableRaisingEvents = true;
                    }
                }
            }
Exemple #2
0
 public Project(string name, string workspace, Config.ProjectOption set)
 {
     Reset(name, workspace, set);
 }