Condividi tramite


DocData Class

Definition

Important

This API is not CLS-compliant.

Abstract base class representing a file in memory. This class implements the IVsPersistDocData2 interface, which the shell calls through to load and save the document. This class also handled listening to external file change events, and prompting the user to reload the file.

public ref class DocData abstract : MarshalByRefObject, IDisposable, IServiceProvider, Microsoft::VisualStudio::OLE::Interop::IPersist, Microsoft::VisualStudio::Shell::Interop::IPersistFileFormat, Microsoft::VisualStudio::Shell::Interop::IVsDocDataFileChangeControl, Microsoft::VisualStudio::Shell::Interop::IVsFileChangeEvents, Microsoft::VisualStudio::Shell::Interop::IVsPersistDocData2, Microsoft::VisualStudio::Shell::Interop::IVsSaveOptionsDlg, Microsoft::VisualStudio::TextManager::Interop::IVsFileBackup, Microsoft::VisualStudio::TextManager::Interop::IVsUserData
public ref class DocData abstract : MarshalByRefObject, IDisposable, IServiceProvider, Microsoft::VisualStudio::Shell::Interop::IPersistFileFormat, Microsoft::VisualStudio::Shell::Interop::IVsDocDataFileChangeControl, Microsoft::VisualStudio::Shell::Interop::IVsFileChangeEvents, Microsoft::VisualStudio::Shell::Interop::IVsPersistDocData2, Microsoft::VisualStudio::Shell::Interop::IVsSaveOptionsDlg, Microsoft::VisualStudio::TextManager::Interop::IVsFileBackup, Microsoft::VisualStudio::TextManager::Interop::IVsUserData
[System.CLSCompliant(false)]
public abstract class DocData : MarshalByRefObject, IDisposable, IServiceProvider, Microsoft.VisualStudio.OLE.Interop.IPersist, Microsoft.VisualStudio.Shell.Interop.IPersistFileFormat, Microsoft.VisualStudio.Shell.Interop.IVsDocDataFileChangeControl, Microsoft.VisualStudio.Shell.Interop.IVsFileChangeEvents, Microsoft.VisualStudio.Shell.Interop.IVsPersistDocData2, Microsoft.VisualStudio.Shell.Interop.IVsSaveOptionsDlg, Microsoft.VisualStudio.TextManager.Interop.IVsFileBackup, Microsoft.VisualStudio.TextManager.Interop.IVsUserData
public abstract class DocData : MarshalByRefObject, IDisposable, IServiceProvider, Microsoft.VisualStudio.Shell.Interop.IPersistFileFormat, Microsoft.VisualStudio.Shell.Interop.IVsDocDataFileChangeControl, Microsoft.VisualStudio.Shell.Interop.IVsFileChangeEvents, Microsoft.VisualStudio.Shell.Interop.IVsPersistDocData2, Microsoft.VisualStudio.Shell.Interop.IVsSaveOptionsDlg, Microsoft.VisualStudio.TextManager.Interop.IVsFileBackup, Microsoft.VisualStudio.TextManager.Interop.IVsUserData
[<System.CLSCompliant(false)>]
type DocData = class
    inherit MarshalByRefObject
    interface IVsPersistDocData2
    interface IVsPersistDocData
    interface IVsFileChangeEvents
    interface IVsDocDataFileChangeControl
    interface IPersistFileFormat
    interface IPersist
    interface IDisposable
    interface IVsSaveOptionsDlg
    interface IVsUserData
    interface IVsFileBackup
    interface IServiceProvider
type DocData = class
    inherit MarshalByRefObject
    interface IVsPersistDocData2
    interface IVsPersistDocData
    interface IVsFileChangeEvents
    interface IVsDocDataFileChangeControl
    interface IPersistFileFormat
    interface IPersist
    interface IDisposable
    interface IVsSaveOptionsDlg
    interface IVsUserData
    interface IVsFileBackup
    interface IServiceProvider
Public MustInherit Class DocData
Inherits MarshalByRefObject
Implements IDisposable, IPersist, IPersistFileFormat, IServiceProvider, IVsDocDataFileChangeControl, IVsFileBackup, IVsFileChangeEvents, IVsPersistDocData2, IVsSaveOptionsDlg, IVsUserData
Public MustInherit Class DocData
Inherits MarshalByRefObject
Implements IDisposable, IPersistFileFormat, IServiceProvider, IVsDocDataFileChangeControl, IVsFileBackup, IVsFileChangeEvents, IVsPersistDocData2, IVsSaveOptionsDlg, IVsUserData
Inheritance
Derived
Attributes
Implements

Constructors

DocData(IServiceProvider, Guid)

Initialize the DocData.

Properties

Cookie

Gets the cookie used to indentify this document in the RDT (running documents table).

DocViews

Retrieves the collection of views currently open on this document.

Encoding

Gets or sets the encoding that this doc data is persisted in

FileName

Gets the filename corresponding to this document

FormatList

Overriden in derived classes to return a string used to filter the Save As... dialog. Each string should be terminated with a newline (\n) character. The last string in the buffer must be terminated with the newline character as well. The caller can replace each newline character with a NULL (\0) character. Then, the caller can have a string that is the same as the lpstrFilter member of the WinAPI OPENFILENAME structure. The first string in each pair is a display string that describes the filter, such as "Text Only (.txt)". The second string specifies the filter pattern, such as ".txt". To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns: ".htm;.html;.asp". A pattern string can be a combination of valid file name characters and the asterisk () wildcard character. Do not include spaces in the pattern string. The following string is an example of a file pattern string: "HTML File (.htm; .html; .asp)\n.htm;.html;.asp\nText File (.txt)\n.txt\n."

Hierarchy

Gets the hierarchy this document belongs to.

IsBackupFileObsolete

Is the backup file dirty with respect to this document?

IsLoaded

Indicates whether this DocData has been loaded.

ItemId

Gets the itemid which identifies this document within its hierarchy.

ServiceProvider
UndoManager

Returns the undo manager for the DocData.

UndoManagerIsShared

If derived classes need share the same undo manager among multiple DocData instances, they should override this property to return true. Derived classes that return true here are also responsible for handling undo manager disposal.

VSUndoManager

Provides access to the VS undo manager interface.

Methods

BackupFile(String)

Make a single file backup of this document. Returns whether the document is expected to re-load without data loss. If there are any actual save errors then an exception should be raised.

CanSave(Boolean)

Provides derived classes a mechanism to cancel a save operation.

Close()

Called by the shell when it wants to close the document.

DirectoryChanged(String)

Unused.

Dispose(Boolean)

Disposes the state of this object.

FilesChanged(UInt32, String[], UInt32[])

Notifies clients of changes made to one or more files.

FlushUndoManager()

Clears the undo/redo stacks

GetClassID(Guid)

Returns the GUID of our editor factory.

GetCurFile(String, UInt32)

Returns the current file name.

GetData(Guid, Object)

Implementation of IVsUserData.GetData

GetFormatList(String)

Returns the list of file formats we support so that the shell can display the Save As dialog.

GetGuidEditorType(Guid)

Returns the unique identifier of the editor factory that created the IVsPersistDocData object.

GetService(Type)

Return the requested service.

HandleLoadDocDataException(String, Exception, Boolean)

Called to handle exception thrown during LoadDocData (if any)

HandleSaveDocDataException(String, Exception)

Called to handle exception thrown during SaveDocData (if any)

IgnoreFileChanges(Int32)

IVsDocDataFileChangeControl interface implementation. Allows clients such as SCC to inform the DocData to ignore file changes (in the case a file is reloaded from SCC, for example).

InitNew(UInt32)

Initializes a document data class.

IsDirty(Int32)

Repeats the functionality provided by IVsPersistDocData2.IsDocDataDirty.

IsDocDataDirty(Int32)

Determines whether the document data has changed since the last save.

IsDocDataReadOnly(Int32)

Determines if the document data is read-only.

IsDocDataReloadable(Int32)

Determines whether or not the document data can be reloaded.

Load(String, Boolean)

Overriden by derived classes to load the document.

Load(String, UInt32, Int32)

Loads a file.

LoadDocData(String, Boolean)

Loads the document data from a given file name. Called by IVsPersistDocData2.LoadDocData and IVsPersistDocData2.ReloadDocData

LoadDocData(String)

Loads the document data from a given file name.

MarkDocumentChangedForBackup()

Mark that the document has changed and thus a new backup should be created

OnDocumentClosed(EventArgs)

Called after the document is closed

OnDocumentClosing(EventArgs)

Called before the document is closed

OnDocumentLoaded(EventArgs)

Called after the document has been initially loaded.

OnDocumentLoading(EventArgs)

Called before the document is initially loaded with data.

OnDocumentReadOnlyChanged(EventArgs)

Called when the ReadOnly state of the document changes.

OnDocumentReloaded(EventArgs)

Called after the document has been reloaded.

OnDocumentReloading(EventArgs)

Called before the document is reloaded.

OnDocumentSaved(EventArgs)

Called after the document has been saved.

OnDocumentSaving(EventArgs)

Called before the document is saved.

OnFileNameChanged(EventArgs)

Called when the document's filename changes.

OnHierarchyChanged(EventArgs)

Called when the document's hierarchy or itemid changes

OnRegisterDocData(UInt32, IVsHierarchy, UInt32)

Called by the RDT (running documents table) when it registers the document data.

OpenView(Guid, Object)

Called to open a particular view on this DocData.

QueryEditFile()

Helper to perform an SCC QueryEditFiles on the file represented by this DocData.

QueryEditFile(String, tagVSQueryEditFlags)

Helper to perform an SCC QueryEditFiles call.

QuerySaveFile()

Helper to perform an SCC QuerySaveFiles call on the file represented by this DocData.

QuerySaveFile(String, tagVSQuerySaveFlags)

Helper to perform an SCC QuerySaveFiles call.

ReloadDocData(UInt32)

Reloads the document data.

ReloadDocDataWorker(UInt32)

Overridable implementation for handling ReloadDocData.

RenameDocData(UInt32, IVsHierarchy, UInt32, String)

Called by the shell when it wants to rename a document.

ResumeFileChangeNotification(String)

Resume file change notifications for the given file.

Save(String, Int32, UInt32)

Saves a document.

Save(String)

Overriden by derived classes to save the document.

SaveCompleted(String)

Called when the save operation is complete.

SaveDocData(VSSAVEFLAGS, String, Int32)

Saves the document data to a given location. May need to display the Save As dialog.

SaveDocDataToFile(VSSAVEFLAGS, String, Int32, IVsUIShell)

Save as the doc data to a file

SaveSubordinateFile(DocData, String)

Save the given document that is subordinate to this document.

SetData(Guid, Object)

Implementation of IVsUserData.SetData Called by IVsCodePageSelection.ShowEncodingDialog to return the selected encoding.

SetDocDataDirty(Int32)

Sets the dirty flag for the document data.

SetDocDataReadOnly(Int32)

Sets the readOnly flag for the document.

SetFileName(String)

Called to initialize/change the filename

SetHierarchyInfo(IVsHierarchy, UInt32)

Called to initialize/change the hierarchy.

SetUntitledDocPath(String)

Unused.

ShowSaveOptionsDlg(UInt32, IntPtr, IntPtr)

Implementation of IVsSaveOptionsDlg.ShowSaveOptionsDlg. Display the AdvancedSaveDialog to gather the encoding from the user.

SuspendFileChangeNotification(String)

Suspend file change notifications for the given file. Helpful to avoid spurious file reload messages for subordinate files.

Events

DocumentClosed

Fired after the document is closed

DocumentClosing

Fired before the document is closed

DocumentLoaded

Fires after the document has been initially loaded.

DocumentLoading

Fires before the document is intitially loaded with data.

DocumentReadOnlyChanged

Fired when the ReadOnly state of the document changes.

DocumentReloaded

Fires after the document has been reloaded.

DocumentReloading

Fires before the document is reloaded.

DocumentSaved

Fires after the document has been saved.

DocumentSaving

Fires before the document is saved.

FileNameChanged

Fired when the document's filename changes.

HierarchyChanged

Fired when the document's hierarhcy or itemid changes

Explicit Interface Implementations

IDisposable.Dispose()

Cleans up resources allocated by the doc data. Allows us to pre-empt the GC.

IPersistFileFormat.GetClassID(Guid)

Returns the GUID of our editor factory.

IVsFileBackup.BackupFile(String)

Make a single file backup of this document.

IVsFileBackup.IsBackupFileObsolete(Int32)

Is the backup file dirty with respect to this document?

Applies to