Interface IVsDocumentActions
Visual studio actions that support the IVsDocument model.
Namespace: CodeFactory.VisualStudio
Assembly: CodeFactory.VisualStudio.dll
Syntax
public interface IVsDocumentActions
Methods
| Improve this Doc View SourceAddContentAsync(VsDocument, IDocumentLocation, string)
Adds content to a target starting at an assigned
Declaration
Task AddContentAsync(VsDocument source, IDocumentLocation location, string content)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | Document to have content added to. |
IDocumentLocation | location | Location within the document to add content to. |
string | content | The content to be added to the document. |
Returns
Type | Description |
---|---|
Task |
AddContentToBeginningAsync(VsDocument, string)
Adds content to the beginning of a document.
Declaration
Task AddContentToBeginningAsync(VsDocument source, string content)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | Document to add content to. |
string | content | The content to be added. |
Returns
Type | Description |
---|---|
Task |
AddContentToEndAsync(VsDocument, string)
Adds content to the end of a document.
Declaration
Task AddContentToEndAsync(VsDocument source, string content)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | Document to add content to. |
string | content | The content to be added. |
Returns
Type | Description |
---|---|
Task |
DeleteAsync(VsDocument)
Deletes the document.
Declaration
Task<bool> DeleteAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | document to be deleted. |
Returns
Type | Description |
---|---|
Task<bool> | Flag that notifies if the delete operation completed successfully. |
Remarks
Currently does not support deleting solution documents.
GetChildrenAsync(VsDocument, bool)
Gets the direct children of the document.
Declaration
Task<IReadOnlyList<VsDocument>> GetChildrenAsync(VsDocument source, bool allChildren)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The document to get children from. |
bool | allChildren | Flag that determines if all children from the document should be returned. |
Returns
Type | Description |
---|---|
Task<IReadOnlyList<VsDocument>> | Readonly list of all the project documents, if no children are found then an empty readonly list will be returned. |
GetCSharpSourceModelAsync(VsDocument)
If the document is implemented as a C# code model. Will return the C# source code model from the visual studio document.
Declaration
Task<CsSource> GetCSharpSourceModelAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The source document to load the C# code model from. |
Returns
Type | Description |
---|---|
Task<CsSource> | The loaded model or null if the model could not be loaded. |
GetDocumentContentAsContentAsync(VsDocument)
Gets the content of the document.
Declaration
Task<IDocumentContent> GetDocumentContentAsContentAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The document to get content from. |
Returns
Type | Description |
---|---|
Task<IDocumentContent> | Document content as |
GetDocumentContentAsStringAsync(VsDocument, IDocumentLocation, IDocumentLocation)
Gets the content of the document.
Declaration
Task<string> GetDocumentContentAsStringAsync(VsDocument source, IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The document to get content from. |
IDocumentLocation | startLocation | The starting position within the document to get content from. |
IDocumentLocation | endLocation | The ending position within the document to get content form. |
Returns
Type | Description |
---|---|
Task<string> | The content of the document or null if there is no content in the document. |
GetDocumentContentAsStringAsync(VsDocument)
Gets the content of the document.
Declaration
Task<string> GetDocumentContentAsStringAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The document to get content from. |
Returns
Type | Description |
---|---|
Task<string> | The content of the document or null if there is no content in the document. |
GetParentAsync(VsDocument)
Get the parent visual studio model of the document.
Declaration
Task<VsModel> GetParentAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | document to get the parent of. |
Returns
Type | Description |
---|---|
Task<VsModel> | Model of the parent of this document. The model will be returned unless there is no parent, otherwise null will be returned. |
RemoveAsync(VsDocument)
Removes a document from visual studio but does not remove it from the file system.
Declaration
Task<bool> RemoveAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | document to be removed. |
Returns
Type | Description |
---|---|
Task<bool> | Flag that notifies if the remove operation completed successfully. |
Remarks
Currently does not support removing solution documents.
RemoveContentAsync(VsDocument, IDocumentLocation, IDocumentLocation)
Removes a target set of content from the document.
Declaration
Task RemoveContentAsync(VsDocument source, IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | Document to remove content from. |
IDocumentLocation | startLocation | The starting position within the document to remove content from. |
IDocumentLocation | endLocation | The ending position within the document to remove content form. |
Returns
Type | Description |
---|---|
Task |
RemoveContentAsync(VsDocument)
Removes all the content from a document.
Declaration
Task RemoveContentAsync(VsDocument source)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | Document to remove content from. |
Returns
Type | Description |
---|---|
Task |
ReplaceContentAsync(VsDocument, string, IDocumentLocation, IDocumentLocation)
Replaces all the content within the document.
Declaration
Task ReplaceContentAsync(VsDocument source, string content, IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The target document to have content replaced. |
string | content | Content to replace the existing content in the document. |
IDocumentLocation | startLocation | The starting position within the document to replace content. |
IDocumentLocation | endLocation | The ending location within the document to replace content. |
Returns
Type | Description |
---|---|
Task |
ReplaceContentAsync(VsDocument, string)
Replaces all the content within the document.
Declaration
Task ReplaceContentAsync(VsDocument source, string content)
Parameters
Type | Name | Description |
---|---|---|
VsDocument | source | The target document to have content replaced. |
string | content | Content to replace the existing content in the document. |
Returns
Type | Description |
---|---|
Task |