-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCsProperty.cs
More file actions
201 lines (176 loc) · 10.4 KB
/
CsProperty.cs
File metadata and controls
201 lines (176 loc) · 10.4 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//*****************************************************************************
//* Code Factory SDK
//* Copyright (c) 2020-2023 CodeFactory, LLC
//*****************************************************************************
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CodeFactory.SourceCode;
namespace CodeFactory.DotNet.CSharp
{
/// <summary>
/// Data model that represents the definition of a property.
/// </summary>
public abstract class CsProperty:CsMember,ICsProperty
{
#region Property backing fields
private readonly bool _hasGet;
private readonly bool _hasSet;
private readonly bool _isAbstract;
private readonly bool _isVirtual;
private readonly bool _isSealed;
private readonly bool _isOverride;
private readonly bool _isStatic;
private readonly CsType _propertyType;
private readonly CsSecurity _getSecurity;
private readonly CsSecurity _setSecurity;
private readonly CsMethod _getMethod;
private readonly CsMethod _setMethod;
private readonly bool _hasInit;
private readonly CsMethod _initMethod;
#endregion
/// <summary>
/// Constructor for the <see cref="CsProperty"/>
/// </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="setSecurity">The security access assigned to the setter.</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="attributes">List of the attributes assigned to this model.</param>
/// <param name="modelSourceFile">The source file the model was generated from.</param>
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this member is defined in.</param>
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
/// <param name="documentation">The xml documentation assigned to the model.</param>
/// <param name="lookupPath">The fully qualified model lookup path for this model.</param>
/// <param name="name">The name of the model.</param>
/// <param name="parentPath">THe fully qualified lookup path for the parent model to this one.</param>
/// <param name="security">The security scope assigned to this model.</param>
/// <param name="hasGet">Flag that determines if the property implements a getter.</param>
/// <param name="getMethod">The get accessor method assigned to the property</param>
/// <param name="hasSet">Flag that determines if the property implements a setter.</param>
/// <param name="setMethod">The set accessor method assigned to the property.</param>
/// <param name="hasInit">Flag that determines if the property implements a init accessor.</param>
/// <param name="initMethod">The init accessor method assigned to the property.</param>
/// <param name="isAbstract">Flag that determines if the model is abstract.</param>
/// <param name="isVirtual">Flag that determines if the model is virtual.</param>
/// <param name="isSealed">Flag that determines if the model is sealed.</param>
/// <param name="isOverride">Flag that determines if the model is overridden.</param>
/// <param name="isStatic">Flag that determines if the model is static.</param>
/// <param name="propertyType">The type the property supports.</param>
/// <param name="getSecurity">The security access assigned to the getter.</param>
protected CsProperty(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
IReadOnlyList<CsAttribute> attributes, string modelSourceFile, IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation,
string lookupPath, string name, string parentPath, CsSecurity security,
bool hasGet, CsMethod getMethod, bool hasSet, CsMethod setMethod, bool hasInit, CsMethod initMethod, bool isAbstract, bool isVirtual, bool isSealed,
bool isOverride, bool isStatic, CsType propertyType, CsSecurity getSecurity, CsSecurity setSecurity,
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Property,attributes, modelSourceFile, sourceFiles,
hasDocumentation, documentation, lookupPath, name, parentPath, security, CsMemberType.Property, sourceDocument, modelStore, modelErrors)
{
_hasGet = hasGet;
_hasSet = hasSet;
_isAbstract = isAbstract;
_isVirtual = isVirtual;
_isSealed = isSealed;
_isOverride = isOverride;
_isStatic = isStatic;
_propertyType = propertyType;
_getSecurity = getSecurity;
_getMethod = getMethod;
_setSecurity = setSecurity;
_setMethod = setMethod;
_hasInit = hasInit;
_initMethod = initMethod;
}
/// <summary>
/// The source data type that is managed by this property.
/// </summary>
IDotNetType IDotNetProperty.PropertyType => PropertyType;
/// <summary>
/// The security scope that is assigned to the get accessor. Make sure you check the HasGet to determine if the property supports get operations.
/// </summary>
public CsSecurity GetSecurity => _getSecurity;
/// <summary>
/// The security scope that is assigned to the set accessor. Make sure you check the HasSet to determine if the property supports set operations.
/// </summary>
public CsSecurity SetSecurity => _setSecurity;
/// <summary>
/// Flag that determines if this property supports init accessor.
/// </summary>
public bool HasInit => _hasInit;
/// <summary>
/// The source data type that is managed by this property.
/// </summary>
public CsType PropertyType => _propertyType;
/// <summary>
/// Flag that determines if this property supports get access.
/// </summary>
public bool HasGet => _hasGet;
/// <summary>
/// The security scope that is assigned to the get accessor. Make sure you check the HasGet to determine if the property supports get operations.
/// </summary>
DotNetSecurity IDotNetProperty.GetSecurity =>(DotNetSecurity)(int) _getSecurity;
/// <summary>
/// Flag that determines if this property supports set access.
/// </summary>
public bool HasSet => _hasSet;
/// <summary>
/// The security scope that is assigned to the set accessor. Make sure you check the HasSet to determine if the property supports set operations.
/// </summary>
DotNetSecurity IDotNetProperty.SetSecurity => (DotNetSecurity)(int) _setSecurity;
/// <summary>
/// Flag that determines if the property is implemented as an abstract property.
/// </summary>
public bool IsAbstract => _isAbstract;
/// <summary>
/// Flag that determines if the property is implemented as virtual.
/// </summary>
public bool IsVirtual => _isVirtual;
/// <summary>
/// Flag that determines if the property has been sealed.
/// </summary>
public bool IsSealed => _isSealed;
/// <summary>
/// Flag that determines if the property has been overridden.
/// </summary>
public bool IsOverride => _isOverride;
/// <summary>
/// Flag that determines if the property has been implemented as static.
/// </summary>
public bool IsStatic => _isStatic;
/// <summary>
/// Provides access to the get method statement in the property. This will be null if the property does not have a get statement.
/// </summary>
public CsMethod GetMethod => _getMethod;
/// <summary>
/// Provides access to the set method statement in the property. This will be null if the property does not have a set statement.
/// </summary>
public CsMethod SetMethod => _setMethod;
/// <summary>
/// Provides access to the get method statement in the property. This will be null if the property does not have a get statement.
/// </summary>
IDotNetMethod IDotNetProperty.GetMethod => _getMethod;
/// <summary>
/// Provides access to the set method statement in the property. This will be null if the property does not have a set statement.
/// </summary>
IDotNetMethod IDotNetProperty.SetMethod => _setMethod;
/// <summary>
/// Provides access to the init method statement in the property. This will be null if the property does not have a init statement.
/// </summary>
IDotNetMethod IDotNetProperty.InitMethod => _initMethod;
/// <summary>
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
/// </summary>
[Obsolete("This will be removed in later editions of the SDK. Use the GetMethod property to access the get method details.",false)]
public abstract Task<string> LoadGetBodySyntaxAsync();
/// <summary>
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
/// </summary>
[Obsolete("This will be removed in later editions of the SDK. Use the SetMethod property to access the set method details.",false)]
public abstract Task<string> LoadSetBodySyntaxAsync();
}
}