EnvDTE.Document.Save(string)

Here are the examples of the csharp api class EnvDTE.Document.Save(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

11 Examples 7

1. Example

Project: Paket.VisualStudio
Source File: DteHelper.cs
View license
public static void SaveDocument()
        {
            var doc = DTE.ActiveDocument;

            if (doc != null)
                doc.Save();
        }

2. Example

View license
protected override void InternalSave(XDocument document)
        {
            var projectItem = DefaultProjectItem;

            try
            {
                if (projectItem.Document?.Save() == EnvDTE.vsSaveStatus.vsSaveSucceeded)
                    return;
            }
            catch
            {
                // in case of errors write directly to the file...
            }

            base.InternalSave(document);
        }

3. Example

Project: TSVN
Source File: TSVNPackage.cs
View license
private void UpdateToRevisionFileCommand(object sender, EventArgs e)
        {
            _currentFilePath = FileHelper.GetPath();
            if (string.IsNullOrEmpty(_currentFilePath)) return;
            Dte.ActiveDocument?.Save();
            CommandHelper.StartProcess(_tortoiseProc, $"/command:update /path:\"{_currentFilePath}\" /rev /closeonend:0");
        }

4. Example

Project: TSVN
Source File: TSVNPackage.cs
View license
private void AddFileCommand(object sender, EventArgs e)
        {
            _currentFilePath = FileHelper.GetPath();
            if (string.IsNullOrEmpty(_currentFilePath)) return;
            Dte.ActiveDocument?.Save();
            CommandHelper.StartProcess(_tortoiseProc, $"/command:add /path:\"{_currentFilePath}\" /closeonend:0");
        }

5. Example

Project: TSVN
Source File: TSVNPackage.cs
View license
private void CommitFileCommand(object sender, EventArgs e)
        {
            _currentFilePath = FileHelper.GetPath();
            if (string.IsNullOrEmpty(_currentFilePath)) return;
            Dte.ActiveDocument?.Save();
            CommandHelper.StartProcess(_tortoiseProc, $"/command:commit /path:\"{_currentFilePath}\" /closeonend:0");
        }

6. Example

Project: TSVN
Source File: TSVNPackage.cs
View license
private void UpdateFileCommand(object sender, EventArgs e)
        {
            _currentFilePath = FileHelper.GetPath();
            if (string.IsNullOrEmpty(_currentFilePath)) return;
            Dte.ActiveDocument?.Save();
            CommandHelper.StartProcess(_tortoiseProc, $"/command:update /path:\"{_currentFilePath}\" /closeonend:0");
        }

7. Example

View license
public void SaveAll()
        {
            try {
                if (!shouldSaveActiveDocument()) {
                    return;
                }

                if (!_dte.Solution.Saved) {
                    _dte.Solution.SaveAs(_dte.Solution.FullName);
                }

                foreach (Project project in _dte.Solution.AllProjects().Where(x => !x.Saved)) {
                    project.Save(); 
                }

                foreach (Document item in _dte.Documents.AllDocuments().Where(item => !item.Saved)) {
                    item.Save();
                }
            } catch (Exception ex) {
                this.Log().WarnException("Failed to save all documents", ex);
            }
        }

8. Example

Project: codemaid
Source File: TestOperations.cs
View license
public static void ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(Action<Document> command, ProjectItem projectItem)
        {
            UIThreadInvoker.Invoke(new Action(() =>
            {
                var document = GetActivatedDocument(projectItem);

                // Run command a first time and assert it is not saved afterwards.
                Assert.IsTrue(document.Saved, "ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass was not initially saved");
                command(document);
                Assert.IsFalse(document.Saved, "ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass did not change save state as expected");

                // Save the document.
                document.Save();
                Assert.IsTrue(document.Saved, "ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass was not secondarily saved");

                // Run command a second time and assert it is still in a saved state (i.e. no changes).
                command(document);
                Assert.IsTrue(document.Saved, "ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass was not finally saved");
            }));
        }

9. Example

Project: codemaid
Source File: TestOperations.cs
View license
public static void ExecuteCommandAndVerifyResults(Action<Document> command, ProjectItem projectItem, string baselinePath)
        {
            UIThreadInvoker.Invoke(new Action(() =>
            {
                var document = GetActivatedDocument(projectItem);

                // Run command and assert it is not saved afterwards.
                Assert.IsTrue(document.Saved, "ExecuteCommandAndVerifyResults was not initially saved");
                command(document);
                Assert.IsFalse(document.Saved, "ExecuteCommandAndVerifyResults did not change save state as expected");

                // Save the document.
                document.Save();
                Assert.IsTrue(document.Saved, "ExecuteCommandAndVerifyResults was not finally saved");

                // Read the file contents of the baseline and cleaned content and assert they match.
                var baselineContent = File.ReadAllText(baselinePath);
                var cleanedContent = File.ReadAllText(document.FullName);

                Assert.AreEqual(baselineContent, cleanedContent);
            }));
        }

10. Example

View license
void CSharpItemRenamed(ProjectItem renamedQuery, string OldName)

        {
            if (OldName./n ..... /n //View Source file for more details /n }

11. Example

View license
private void ReformatDocuments(IEnumerable<Document> documentsToReformat, bool saveDocumentsAf/n ..... /n //View Source file for more details /n }