public void Watch(string virtualPath, SourceChangedDelegate callback) { if (virtualPath == null) { throw new ArgumentNullException(nameof(virtualPath)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } lock (_files) { FileChangeEventInfo fileChangeEventInfo; var physicalPath = GetPhysicalPath(virtualPath); if (!_files.TryGetValue(physicalPath, out fileChangeEventInfo)) { _files.Add(physicalPath, fileChangeEventInfo = new FileChangeEventInfo(virtualPath, ResetCounter)); } _bundleDiagnostic.Log(LogLevel.Debug, Tag, nameof(Watch), $"{virtualPath} ({physicalPath}) added for watching."); fileChangeEventInfo.Add(callback); } }
public void Unwatch(string virtualPath, SourceChangedDelegate callback) { if (virtualPath == null) { throw new ArgumentNullException(nameof(virtualPath)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } lock (_files) { var physicalPath = GetPhysicalPath(virtualPath); FileChangeEventInfo fileChangeEventInfo; if (!_files.TryGetValue(physicalPath, out fileChangeEventInfo)) { return; } fileChangeEventInfo.Remove(callback); _bundleDiagnostic.Log(LogLevel.Debug, Tag, nameof(Watch), $"{virtualPath} ({physicalPath}) removed from watching."); if (fileChangeEventInfo.Subscribers.Count == 0) { _files.Remove(physicalPath); } } }
public void Add(SourceChangedDelegate sourceChangedDelegate) { lock (_writeLock) { if (!_subscribers.Contains(sourceChangedDelegate)) { _subscribers.Add(sourceChangedDelegate); } } }
public void Remove(SourceChangedDelegate sourceChangedDelegate) { lock (_writeLock) { _subscribers.Remove(sourceChangedDelegate); } }