Class CsModel
Base class that all C# compiler based data models derive from.
Inheritance
Inherited Members
Namespace: CodeFactory.WinVs.Models.CSharp
Assembly: CodeFactory.WinVs.dll
Syntax
public abstract class CsModel : ICsModel, IModelStatus
Constructors
CsModel(bool, bool, bool, SourceCodeType, CsModelType, string, ModelStore<ICsModel>, IReadOnlyList<ModelLoadException>)
Constructor for the CsModel
Declaration
protected CsModel(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, CsModelType modelType, 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. |
| CsModelType | modelType | The type of code model created. |
| 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. |
Fields
LocalModelErrors
Model field that stores the models load exceptions.
Declaration
protected readonly IReadOnlyList<ModelLoadException> LocalModelErrors
Field Value
| Type | Description |
|---|---|
| IReadOnlyList<ModelLoadException> |
ModelStore
Model field used to lookup models that were created during the compile or reference lookup using the C# compiler.
Declaration
protected readonly ModelStore<ICsModel> ModelStore
Field Value
| Type | Description |
|---|---|
| ModelStore<ICsModel> |
Properties
HasErrors
Flag that determines if this model or one of the children of this model has an error.
Declaration
public bool HasErrors { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsLoaded
Flag that determines if this model was able to load.
Declaration
public bool IsLoaded { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Language
The target language this model was loaded from.
Declaration
public SourceCodeType Language { get; }
Property Value
| Type | Description |
|---|---|
| SourceCodeType |
LoadedFromSource
Flag that determines if this model was loaded from source code or was loaded through reflects or symbol libraries.
Declaration
public bool LoadedFromSource { get; }
Property Value
| Type | Description |
|---|---|
| bool |
ModelType
The type of c# model that is implemented.
Declaration
public CsModelType ModelType { get; }
Property Value
| Type | Description |
|---|---|
| CsModelType |
SourceDocument
The fully qualified path to the document that was used to load the model from source. This will be populated if the model was loaded from source.
Declaration
public string SourceDocument { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetErrors()
Gets the ModelLoadException from the current model and all child models of this model.
Declaration
public abstract IReadOnlyList<ModelLoadException> GetErrors()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<ModelLoadException> | Returns a IReadOnlyList<T> of the ModelLoadException exceptions or an empty list if no exceptions exist. |
GetModel(string)
Searchs for an existing C# model that has been loaded with the load of the source code.
Declaration
public CsModel GetModel(string lookupPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lookupPath | The lookup path that is assigned to a loaded model. |
Returns
| Type | Description |
|---|---|
| CsModel | Returns the model as the base CsModel type. |
GetModel<T>(string)
Searchs for an existing C# model that has been loaded with the load of the source code.
Declaration
public T GetModel<T>(string lookupPath) where T : class, ICsModel
Parameters
| Type | Name | Description |
|---|---|---|
| string | lookupPath | The lookup path that is assigned to a loaded model. |
Returns
| Type | Description |
|---|---|
| T | Returns the model as the identified type it will either return the instance or null if it is not found or not the correct type. |
Type Parameters
| Name | Description |
|---|---|
| T | The target CsModel type to cast to before returning. |
LookupModel(string)
Helper method that looks up a code factory model from the model store.
Declaration
[Obsolete("LookupModel is obsolete and will be removed in later versions of the framework. Use GetModel or GetModel<T>", false)]
protected CsModel LookupModel(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The fully qualified path of the model to be loaded from the model store. |
Returns
| Type | Description |
|---|---|
| CsModel | The loaded model or null if the model could not be loaded, or found. |