private static DropDownMenuItem CreateMenuItem_RefreshTestContainer(IHasTestContainerSourceFile hsf) { var entity = (EntityBase)hsf; return(new ThunkMenuItem("Refresh " + entity.MenuItemTypeName(), () => { model.controller.AddNewCommand(new RefreshCommand(entity, true, false)); })); }
public WatchedEntity(IHasTestContainerSourceFile entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (String.IsNullOrEmpty(entity.SourceFilePath)) { throw new ArgumentException("SourceFilePath is not specified for the entity.", "entity"); } HasSourceFileEntity = entity; Entity = (EntityBase)entity; string folderPath = Path.GetDirectoryName(HasSourceFileEntity.SourceFilePath); if (Directory.Exists(folderPath)) { CreateFSWForFile(); } else { _foldersNeedingToBeCreated = new Stack <string>(); string pathRoot = Path.GetPathRoot(folderPath); do { _foldersNeedingToBeCreated.Push(Path.GetFileName(folderPath)); folderPath = Path.GetDirectoryName(folderPath); } while (!folderPath.Equals(pathRoot, StringComparison.OrdinalIgnoreCase) && !Directory.Exists(folderPath) ); _existingFolderPath = folderPath; _watcher = new FileSystemWatcher() { Path = _existingFolderPath, //Filter = _foldersNeedingToBeCreated.Peek(), NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size, //IncludeSubdirectories = true, }; //_watcher.NotifyFilter |= NotifyFilters.CreationTime; _isWaitingForFolderToBeCreated = true; _watcher.Created += watcher_Folder; _watcher.Changed += watcher_Folder; _watcher.Renamed += watcher_Folder; //_watcher.Deleted += watcher_Folder; Debug.WriteLine("_existingFolderPath=" + _existingFolderPath, "watcher_Folder"); } }
internal RefreshCommand(EntityBase entity, bool interactive, bool confirmWithUser) : base(interactive) { if (!(entity is IHasTestContainerSourceFile)) { throw new ArgumentException("Entity doesn't implement IHasSourceFile.", "entity"); } _entity = entity; _hsf = (IHasTestContainerSourceFile)entity; if (!_hsf.SupportsRefresh) { throw new ArgumentException("The entity doesn't support refreshing.", "entity"); } _confirmWithUser = confirmWithUser; }