public static string GetStylesheet() { string folder = ProjectHelpers.GetSolutionFolderPath(); if (!string.IsNullOrEmpty(folder)) { string file = Path.Combine(folder, _stylesheet); if (File.Exists(file)) { string linkFormat = "<link rel=\"stylesheet\" href=\"{0}\" />"; return(string.Format(linkFormat, file)); } } return("<style>body{font: 1.1em 'Century Gothic'}</style>"); }
private void Renamed(RenamedEventArgs renamedEventArgument, Func <string, bool, Task> updateBundle) { Task.Run(async() => { using (await rwLock.ReadLockAsync()) { if (!_watchedFiles.ContainsKey(renamedEventArgument.OldFullPath) || !renamedEventArgument.FullPath.StartsWith(ProjectHelpers.GetSolutionFolderPath(), StringComparison.OrdinalIgnoreCase)) { return; } } HashSet <Tuple <string, FileSystemWatcher> > oldValue; using (await rwLock.ReadLockAsync()) { oldValue = _watchedFiles[renamedEventArgument.OldFullPath]; } using (await rwLock.WriteLockAsync()) { _watchedFiles.Remove(renamedEventArgument.OldFullPath); } _document = await _document.LoadFromFile(renamedEventArgument.FullPath); foreach (Tuple <string, FileSystemWatcher> tuple in oldValue) { tuple.Item2.EnableRaisingEvents = false; tuple.Item2.Dispose(); if (_extensions.Any(e => tuple.Item1.EndsWith(e, StringComparison.OrdinalIgnoreCase))) { await AttachFileObserver(_document, _document.FileName, updateBundle); } else { await AttachFileObserver(_document, tuple.Item1, updateBundle); } } }).Wait(); }
public static void CreateStylesheet() { string file = Path.Combine(ProjectHelpers.GetSolutionFolderPath(), _stylesheet); using (StreamWriter writer = new StreamWriter(file, false, new UTF8Encoding(true))) { writer.Write("body { background: yellow; }"); } Solution2 solution = EditorExtensionsPackage.DTE.Solution as Solution2; Project project = solution.Projects .OfType <Project>() .FirstOrDefault(p => p.Name.Equals(Settings._solutionFolder, StringComparison.OrdinalIgnoreCase)); if (project == null) { project = solution.AddSolutionFolder(Settings._solutionFolder); } project.ProjectItems.AddFromFile(file); }
void SolutionEvents_Opened() { System.Threading.Tasks.Task.Run(() => BundleFilesMenu.BindAllBundlesAssets(ProjectHelpers.GetSolutionFolderPath())); }