Class CsUsingStatement
Data model that represents a namespace reference in source code.
Implements
Inherited Members
Namespace: CodeFactory.DotNet.CSharp
Assembly: CodeFactory.DotNet.dll
Syntax
public abstract class CsUsingStatement : CsModel, ICsUsingStatement, IDotNetNamespaceReference, ILookup, ICsModel, IDotNetModel, IModelStatus, IParent, IParent
Constructors
| Improve this Doc View SourceCsUsingStatement(bool, bool, bool, SourceCodeType, string, string, bool, string, string, string, ModelStore<ICsModel>, IReadOnlyList<ModelLoadException>)
Constructor for the CsUsingStatement
Declaration
protected CsUsingStatement(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, string lookupPath, string referenceNamespace, bool hasAlias, string alias, string parentPath, string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
Parameters
Type | Name | Description |
---|---|---|
bool | isLoaded | Flag that determines if the model was loaded. |
bool | hasErrors | Flag that determine if errors were found creating the model. |
bool | loadedFromSource | Flag that determines if the model was loaded from source code or from an existing library. |
SourceCodeType | language | The target language the model was generated from. |
string | lookupPath | Fully qualified path for the model to be stored in the model store. |
string | referenceNamespace | The full namespace being referenced. |
bool | hasAlias | Flag that determines if the namespace is referenced by a alias name. |
string | alias | The alias name for the referenced namespace. this will be null when HasAlias is false |
string | parentPath | Fully qualified lookup path for the parent model to this model. |
string | sourceDocument | The source document that was used to build this model. This is optional parameter and can be null. |
ModelStore<ICsModel> | modelStore | Optional the lookup storage for models created during the compile or lookup of the model. |
IReadOnlyList<ModelLoadException> | modelErrors | Optional the error that occurred while creating the model. |
Properties
| Improve this Doc View SourceAlias
The alias assigned to the namespace being imported. This will be null if the HasAlias is false.
Declaration
public string Alias { get; }
Property Value
Type | Description |
---|---|
string |
HasAlias
Flag that determines if the namespace reference has an alias.
Declaration
public bool HasAlias { get; }
Property Value
Type | Description |
---|---|
bool |
LookupPath
The fully qualified path for this model that can be used when searching the source for the model.
Declaration
public string LookupPath { get; }
Property Value
Type | Description |
---|---|
string |
Parent
The parent to the current model. This will return null if there is no parent for this model, or the parent could not be located.
Declaration
public CsModel Parent { get; }
Property Value
Type | Description |
---|---|
CsModel |
ReferenceNamespace
The target namespace that is being imported into the sources scope.
Declaration
public string ReferenceNamespace { get; }
Property Value
Type | Description |
---|---|
string |
Methods
| Improve this Doc View SourceAddAfterAsync(string, string)
Adds the source code directly after the definition of the ICsUsingStatement in the target document.
Declaration
public abstract Task<CsSource> AddAfterAsync(string sourceDocument, string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceDocument | The fully qualified path to the source code document to be updated. |
string | sourceCode | The source code that is to be added to the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
AddAfterAsync(string)
Adds the source code directly after the definition of the ICsUsingStatement in the target document.
Declaration
public abstract Task<CsSource> AddAfterAsync(string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceCode | The source code that is to be added to the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
AddBeforeAsync(string, string)
Adds the source code directly before the definition of the ICsUsingStatement in the target document.
Declaration
public abstract Task<CsSource> AddBeforeAsync(string sourceDocument, string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceDocument | The fully qualified path to the source code document to be updated. |
string | sourceCode | The source code that is to be added to the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
AddBeforeAsync(string)
Adds the source code directly before the definition of the ICsUsingStatement in the target document.
Declaration
public abstract Task<CsSource> AddBeforeAsync(string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceCode | The source code that is to be added to the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
DeleteAsync()
Deletes the definition of the using statement from the source document.
Declaration
public abstract Task<CsSource> DeleteAsync()
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the using statement has been removed from the document. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
DeleteAsync(string)
Deletes the definition of the using statement from the source document.
Declaration
public abstract Task<CsSource> DeleteAsync(string sourceDocument)
Parameters
Type | Name | Description |
---|---|---|
string | sourceDocument | The source document that the using statement is to be removed from. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the using statement has been removed from the document. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
GetSourceLocationAsync()
Gets the starting and ending locations within the document where the using statement is located.
Declaration
public abstract Task<ISourceLocation> GetSourceLocationAsync()
Returns
Type | Description |
---|---|
Task<ISourceLocation> | The source location for the using statement. |
Exceptions
Type | Condition |
---|---|
DocumentException | Raised when an error occurs getting the location from the document. |
GetSourceLocationAsync(string)
Gets the starting and ending locations within the document where the using statement is located.
Declaration
public abstract Task<ISourceLocation> GetSourceLocationAsync(string sourceDocument)
Parameters
Type | Name | Description |
---|---|---|
string | sourceDocument | The fully qualified path to the document that has the using statement defined in. |
Returns
Type | Description |
---|---|
Task<ISourceLocation> | The source location for the using statement. |
Exceptions
Type | Condition |
---|---|
DocumentException | Raised when an error occurs getting the location from the document. |
ReplaceAsync(string, string)
Replaces the current using statement with the provided source code.
Declaration
public abstract Task<CsSource> ReplaceAsync(string sourceDocument, string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceDocument | The fully qualified path to the source code document to be updated. |
string | sourceCode | The source code that is to be used to replace the original definition in the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
ReplaceAsync(string)
Replaces the current using statement with the provided source code.
Declaration
public abstract Task<CsSource> ReplaceAsync(string sourceCode)
Parameters
Type | Name | Description |
---|---|---|
string | sourceCode | The source code that is to be used to replace the original definition in the document. |
Returns
Type | Description |
---|---|
Task<CsSource> | A newly loaded copy of the ICsSource model after the changes have been applied. |
Exceptions
Type | Condition |
---|---|
DocumentException | Error is raised when errors occur updating the source document. |
Explicit Interface Implementations
| Improve this Doc View SourceIParent.Parent
The parent to the current model. This will return null if there is no parent for this model, or the parent could not be located.
Declaration
IDotNetModel IParent.Parent { get; }
Returns
Type | Description |
---|---|
IDotNetModel |