public void Watch(bool refreshContent, IApplicationObserver observer) { _appDomainWatcher = new AppDomainFileChangeWatcher(observer.RecycleAppDomain); _appDomainWatcher.WatchBinariesAt(BinPath); if (!refreshContent) { return; } var watchedDirectory = PublicAssetFolder.IsNotEmpty() ? PublicAssetFolder : ApplicationPath; var pattern = "*.css;*.js"; ContentMatches.Each(ext => { if (!ext.StartsWith("*")) { ext = "*" + ext; } pattern += ";" + ext; }); var assetFileSet = FileSet.Deep(pattern); _watcher = new FileChangeWatcher(watchedDirectory, assetFileSet, new ContentRefresher(observer)); }
public void Watch(bool refreshContent, IApplicationObserver observer) { _appDomainWatcher = new AppDomainFileChangeWatcher(observer.RecycleAppDomain); _appDomainWatcher.WatchBinariesAt(BinPath); if (!refreshContent) { return; } var watchedDirectory = PublicAssetFolder.IsNotEmpty() ? PublicAssetFolder : ApplicationPath; var pattern = "*.css;*.js"; ContentMatches.Each(ext => { if (!ext.StartsWith("*")) ext = "*" + ext; pattern += ";" + ext; }); var assetFileSet = FileSet.Deep(pattern); _watcher = new FileChangeWatcher(watchedDirectory, assetFileSet, new ContentRefresher(observer)); }
public FubuMvcApplicationFileWatcher(IApplicationObserver observer, IFileMatcher matcher) { _observer = observer; _matcher = matcher; }
public void RemoveObserver(IApplicationObserver observer) { _appObservers.Remove(observer); }
public void AddObserver(IApplicationObserver observer) { _appObservers.Add(observer); }
public ContentRefresher(IApplicationObserver observer) { _observer = observer; }
public void Watch(bool refreshContent, IApplicationObserver observer) { FileSystemEventHandler appDomain = (o, args) => { StopWatching(); observer.RecycleAppDomain(); }; FileSystemEventHandler reload = (o, args) => { var watcher = o.As<FileSystemWatcher>(); watcher.EnableRaisingEvents = false; try { observer.RefreshContent(); } finally { watcher.EnableRaisingEvents = true; } }; add(BinPath, "*.dll").OnChangeOrCreation(appDomain); add(BinPath, "*.exe").OnChangeOrCreation(appDomain); if (ConfigurationFile.IsNotEmpty()) { add(ApplicationPath, ConfigurationFile).OnChangeOrCreation(appDomain); } if (!refreshContent) { return; } if (PublicAssetFolder.IsNotEmpty()) { add(PublicAssetFolder, "*.js").OnChange(reload); add(PublicAssetFolder, "*.jsx").OnChange(reload); add(PublicAssetFolder, "*.css").OnChange(reload); } else { add(ApplicationPath, "*.js").OnChange(reload); add(ApplicationPath, "*.jsx").OnChange(reload); add(ApplicationPath, "*.css").OnChange(reload); LinkedFolders.Each(x => { add(x, "*.js").OnChange(reload); add(x, "*.jsx").OnChange(reload); add(x, "*.css").OnChange(reload); }); } ContentMatches.Each(ext => { if (!ext.StartsWith("*")) ext = "*" + ext; add(ApplicationPath, ext).OnChange(reload); LinkedFolders.Each(folder => add(folder, ext).OnChangeOrCreation(reload)); }); }
public void Watch(bool refreshContent, IApplicationObserver observer) { FileSystemEventHandler appDomain = (o, args) => { StopWatching(); observer.RecycleAppDomain(); }; FileSystemEventHandler reload = (o, args) => { var watcher = o.As <FileSystemWatcher>(); watcher.EnableRaisingEvents = false; try { observer.RefreshContent(); } finally { watcher.EnableRaisingEvents = true; } }; add(BinPath, "*.dll").OnChangeOrCreation(appDomain); add(BinPath, "*.exe").OnChangeOrCreation(appDomain); if (ConfigurationFile.IsNotEmpty()) { add(ApplicationPath, ConfigurationFile).OnChangeOrCreation(appDomain); } if (!refreshContent) { return; } if (PublicAssetFolder.IsNotEmpty()) { add(PublicAssetFolder, "*.js").OnChange(reload); add(PublicAssetFolder, "*.jsx").OnChange(reload); add(PublicAssetFolder, "*.css").OnChange(reload); } else { add(ApplicationPath, "*.js").OnChange(reload); add(ApplicationPath, "*.jsx").OnChange(reload); add(ApplicationPath, "*.css").OnChange(reload); LinkedFolders.Each(x => { add(x, "*.js").OnChange(reload); add(x, "*.jsx").OnChange(reload); add(x, "*.css").OnChange(reload); }); } ContentMatches.Each(ext => { if (!ext.StartsWith("*")) { ext = "*" + ext; } add(ApplicationPath, ext).OnChange(reload); LinkedFolders.Each(folder => add(folder, ext).OnChangeOrCreation(reload)); }); }