Class VsDocument
Data model that represents a document that is hosted in visual studio.
Inherited Members
Namespace: CodeFactory.VisualStudio
Assembly: CodeFactory.VisualStudio.dll
Syntax
public abstract class VsDocument : VsModel, IVsDocument, IVsModel, IModel<VisualStudioModelType>, IParent, IChildren
Constructors
| Improve this Doc View SourceVsDocument(bool, bool, IReadOnlyList<ModelException<VisualStudioModelType>>, string, bool, bool, string, VsDocumentType, bool, SourceCodeType)
Constructor for the base class VsDocument
Declaration
protected VsDocument(bool isLoaded, bool hasErrors, IReadOnlyList<ModelException<VisualStudioModelType>> modelErrors, string name, bool hasParent, bool hasChildren, string path, VsDocumentType documentType, bool isSourceCode, SourceCodeType sourceType)
Parameters
Type | Name | Description |
---|---|---|
bool | isLoaded | Flag that determines if the model is loaded. |
bool | hasErrors | Flag that determines if errors occurred while loading the model. |
IReadOnlyList<ModelException<VisualStudioModelType>> | modelErrors | The list of errors that occurred if any. |
string | name | The name of the model. |
bool | hasParent | Flag that determines if this model has a parent model. |
bool | hasChildren | Flag that determines if this model has child models. |
string | path | The fully qualified path to the document. |
VsDocumentType | documentType | The type of visual studio document. |
bool | isSourceCode | Is a source code file loadable by code factory. |
SourceCodeType | sourceType | The type of source code found in the document. |
Properties
| Improve this Doc View SourceDocumentType
The type of document that is loaded.
Declaration
public VsDocumentType DocumentType { get; }
Property Value
Type | Description |
---|---|
VsDocumentType |
HasChildren
Flag that determines if this visual studio object has child objects.
Declaration
public bool HasChildren { get; }
Property Value
Type | Description |
---|---|
bool |
HasParent
Flag that determines if the visual studio object has a parent.
Declaration
public bool HasParent { get; }
Property Value
Type | Description |
---|---|
bool |
IsSourceCode
Flag that determines if the project document contains source code that can be managed by code factory.
Declaration
public bool IsSourceCode { get; }
Property Value
Type | Description |
---|---|
bool |
Path
The fully qualified path to the project document.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
string |
SourceType
The target type of source code that is implemented in the project document.
Declaration
public SourceCodeType SourceType { get; }
Property Value
Type | Description |
---|---|
SourceCodeType |
Methods
| Improve this Doc View SourceAddContentAsync(IDocumentLocation, string)
Adds content to a target starting at an assigned
Declaration
public abstract Task AddContentAsync(IDocumentLocation location, string content)
Parameters
Type | Name | Description |
---|---|---|
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(string)
Adds content to the beginning of a document.
Declaration
public abstract Task AddContentToBeginningAsync(string content)
Parameters
Type | Name | Description |
---|---|---|
string | content | The content to be added. |
Returns
Type | Description |
---|---|
Task |
AddContentToEndAsync(string)
Adds content to the end of a document.
Declaration
public abstract Task AddContentToEndAsync(string content)
Parameters
Type | Name | Description |
---|---|---|
string | content | The content to be added. |
Returns
Type | Description |
---|---|
Task |
DeleteAsync()
Deletes the document.
Declaration
public abstract Task<bool> DeleteAsync()
Returns
Type | Description |
---|---|
Task<bool> | Flag that notifies if the delete operation completed successfully. |
Remarks
Currently does not support deleting solution documents.
GetChildrenAsync(bool)
Gets the direct children of the document.
Declaration
public abstract Task<IReadOnlyList<VsDocument>> GetChildrenAsync(bool allChildren)
Parameters
Type | Name | Description |
---|---|---|
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()
If the document is implemented as a C# code model. Will return the C# source code model from the visual studio document.
Declaration
public abstract Task<CsSource> GetCSharpSourceModelAsync()
Returns
Type | Description |
---|---|
Task<CsSource> | The loaded model or null if the model could not be loaded. |
GetDocumentContentAsContentAsync()
Gets the content of the document.
Declaration
public abstract Task<IDocumentContent> GetDocumentContentAsContentAsync()
Returns
Type | Description |
---|---|
Task<IDocumentContent> | Document content as |
GetDocumentContentAsStringAsync()
Gets the content of the document.
Declaration
public abstract Task<string> GetDocumentContentAsStringAsync()
Returns
Type | Description |
---|---|
Task<string> | The content of the document or null if there is no content in the document. |
GetDocumentContentAsStringAsync(IDocumentLocation, IDocumentLocation)
Gets the content of the document.
Declaration
public abstract Task<string> GetDocumentContentAsStringAsync(IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
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. |
GetParentAsync()
Get the parent visual studio model of the document.
Declaration
public abstract Task<VsModel> GetParentAsync()
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()
Removes a document from visual studio but does not remove it from the file system.
Declaration
public abstract Task<bool> RemoveAsync()
Returns
Type | Description |
---|---|
Task<bool> | Flag that notifies if the remove operation completed successfully. |
Remarks
Currently does not support removing solution documents.
RemoveContentAsync()
Removes all the content from a document.
Declaration
public abstract Task RemoveContentAsync()
Returns
Type | Description |
---|---|
Task |
RemoveContentAsync(IDocumentLocation, IDocumentLocation)
Removes a target set of content from the document.
Declaration
public abstract Task RemoveContentAsync(IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
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 |
ReplaceContentAsync(string, IDocumentLocation, IDocumentLocation)
Replaces all the content within the document.
Declaration
public abstract Task ReplaceContentAsync(string content, IDocumentLocation startLocation, IDocumentLocation endLocation)
Parameters
Type | Name | Description |
---|---|---|
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(string)
Replaces all the content within the document.
Declaration
public abstract Task ReplaceContentAsync(string content)
Parameters
Type | Name | Description |
---|---|---|
string | content | Content to replace the existing content in the document. |
Returns
Type | Description |
---|---|
Task |