public ConfigurationResourceLocator(string directory, string fileExtension, IConfigurationReader configurationReader, IIdConverter idConverter)
        {
            if (!Directory.Exists(directory))
                throw new ArgumentException(string.Format("The path {0} does not exist.", directory ?? string.Empty));

            _directory = directory;
            _fileExtension = !string.IsNullOrEmpty(fileExtension)
                                ? "." + fileExtension
                                : "";

            _configurationReader = configurationReader;
            _idConverter = idConverter;
        }
Exemplo n.º 2
0
        public ResourceWatcher(string path, IIdConverter idConverter, string filter = null)
        {
            if (!Directory.Exists(path))
                throw new ArgumentException(string.Format("The path {0} does not exist.", path ?? string.Empty));

            _path = path;
            _idConverter = idConverter;
            _filter = !string.IsNullOrEmpty(filter)
                        ? filter
                        : "*.*";

            _watcher = new FileSystemWatcher(_path, _filter)
                {
                    EnableRaisingEvents = true
                };
            _watcher.Created += (s, e) => ResourceAdded(_idConverter.Convert(e.FullPath), Path.GetFileName(e.FullPath));
            _watcher.Deleted += (s, e) => ResourceRemoved(_idConverter.Convert(e.FullPath), Path.GetFileName(e.FullPath));
            _watcher.Changed += (s, e) => ResourceUpdated(_idConverter.Convert(e.FullPath), Path.GetFileName(e.FullPath));
            _watcher.Renamed += (s, e) =>
                {
                    ResourceRemoved(_idConverter.Convert(e.OldFullPath), Path.GetFileName(e.OldFullPath));
                    ResourceAdded(_idConverter.Convert(e.FullPath), Path.GetFileName(e.FullPath));
                };
        }
 public ConfigurationResourceWatcher(string path, IIdConverter idConverter, string filter = null)
     : base(path, idConverter, filter)
 {
 }