-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCsNamespace.cs
More file actions
84 lines (74 loc) · 4.2 KB
/
CsNamespace.cs
File metadata and controls
84 lines (74 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//*****************************************************************************
//* Code Factory SDK
//* Copyright (c) 2020-2022 CodeFactory, LLC
//*****************************************************************************
using System.Collections.Generic;
using System.Collections.Immutable;
using CodeFactory.SourceCode;
namespace CodeFactory.DotNet.CSharp
{
/// <summary>
/// Data model that represents the definition of a namespace.
/// </summary>
public abstract class CsNamespace:CsModel,ICsNamespace
{
#region Property backing fields
private readonly string _lookupPath;
private readonly IReadOnlyList<string> _sourceFiles;
private readonly string _name;
private readonly string _parentPath;
#endregion
/// <summary>
/// Constructor for the <see cref="CsNamespace"/>
/// </summary>
/// <param name="isLoaded">Flag that determines if the model was loaded.</param>
/// <param name="hasErrors">Flag that determine if errors were found creating the model.</param>
/// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param>
/// <param name="language">The target language the model was generated from.</param>
/// <param name="parentPath">The fully qualified path for the model that is a parent of this model.</param>
/// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param>
/// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
/// <param name="modelErrors">Optional the error that occurred while creating the model.</param>
/// <param name="lookupPath">The fully qualified lookup path for the model to be used in the model store.</param>
/// <param name="modelSourceFile">The source code file the model was generated from.</param>
/// <param name="sourceFiles">The source files where the namespace is defined in.</param>
/// <param name="name">The fully qualified name of the namespace.</param>
protected CsNamespace(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,string lookupPath, string modelSourceFile,
IReadOnlyList<string> sourceFiles, string name, string parentPath, string sourceDocument = null, ModelStore<ICsModel> modelStore = null,
IReadOnlyList<ModelLoadException> modelErrors = null)
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Namespace, sourceDocument, modelStore, modelErrors)
{
_lookupPath = lookupPath;
_modelSourceFile = modelSourceFile;
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
_name = name;
_parentPath = parentPath;
}
/// <summary>
/// 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.
/// </summary>
IDotNetModel DotNet.IParent.Parent => Parent;
/// <summary>
/// The fully qualified path for this model that can be used when searching the source for the model.
/// </summary>
public string LookupPath => _lookupPath;
/// <summary>
/// The source file or files in which the model was loaded from. This will be an empty enumeration if the source models were loaded from metadata only.
/// </summary>
public IReadOnlyList<string> SourceFiles => _sourceFiles;
/// <summary>
/// The name of the namespace.
/// </summary>
public string Name => _name;
/// <summary>
/// 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.
/// </summary>
public CsModel Parent => GetModel(_parentPath);
/// <summary>
/// Backing field for <see cref="ModelSourceFile"/>
/// </summary>
private readonly string _modelSourceFile;
/// <inheritdoc/>
public string ModelSourceFile => _modelSourceFile;
}
}