@@ -16,7 +16,7 @@ namespace CodeFactory.DotNet.CSharp
1616 /// <summary> 
1717 /// Data model that implements the base implement for all models that support members. 
1818 /// </summary> 
19-  public  abstract  class  CsContainer : CsModel , ICsContainer 
19+  public  abstract  class  CsContainer : CsModel , ICsContainer , ICsNestedModel 
2020 { 
2121 #region Property backing fields
2222 private  readonly  IReadOnlyList < CsAttribute >  _attributes ; 
@@ -35,6 +35,10 @@ public abstract class CsContainer:CsModel,ICsContainer
3535 private  readonly  CsSecurity  _security ; 
3636 private  readonly  IReadOnlyList < CsInterface >  _inheritedInterfaces ; 
3737 private  readonly  IReadOnlyList < CsMember >  _members ; 
38+  private  readonly  bool  _isNested ; 
39+  private  readonly  CsNestedType  _nestedType ; 
40+  private  readonly  IReadOnlyList < ICsNestedModel >  _nestedModels ; 
41+ 
3842 #endregion
3943
4044 /// <summary> 
@@ -46,9 +50,12 @@ public abstract class CsContainer:CsModel,ICsContainer
4650 /// <param name="language">The target language the model was generated from.</param> 
4751 /// <param name="modelType">The type of code model created.</param> 
4852 /// <param name="members">The members assigned to this container.</param> 
53+  /// <param name="isNested">Flag that determines if the container type is nested in another type definition.</param> 
54+  /// <param name="nestedType">Enumeration of the type of nesting the container is.</param> 
55+  /// <param name="nestedModels">List of nested models assigned to this container. This is an optional parameter and can be null</param> 
4956 /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> 
5057 /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> 
51-  /// <param name="modelErrors">Optional the error that occured  while creating the model.</param> 
58+  /// <param name="modelErrors">Optional the error that occurred  while creating the model.</param> 
5259 /// <param name="attributes">List of the attributes assigned to this model.</param> 
5360 /// <param name="isGeneric">Flag that determines if the container is a generic definition.</param> 
5461 /// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param> 
@@ -70,8 +77,9 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
7077 IReadOnlyList < CsGenericParameter >  genericParameters ,  IReadOnlyList < CsType >  genericTypes ,  string  modelSourceFile , 
7178 IReadOnlyList < string >  sourceFiles ,  bool  hasDocumentation ,  string  documentation ,  string  lookupPath , 
7279 string  name ,  string  ns ,  string  parentPath ,  CsContainerType  containerType ,  CsSecurity  security , 
73-  IReadOnlyList < CsInterface >  inheritedInterfaces ,  IReadOnlyList < CsMember >  members , 
74-  string  sourceDocument  =  null ,  ModelStore < ICsModel >  modelStore  =  null ,  IReadOnlyList < ModelLoadException >  modelErrors  =  null ) 
80+  IReadOnlyList < CsInterface >  inheritedInterfaces ,  IReadOnlyList < CsMember >  members ,  bool  isNested ,  CsNestedType  nestedType ,  IReadOnlyList < ICsNestedModel >  nestedModels  =  null , 
81+ 
82+  string  sourceDocument  =  null ,  ModelStore < ICsModel >  modelStore  =  null ,  IReadOnlyList < ModelLoadException >  modelErrors  =  null ) 
7583 :  base ( isLoaded ,  hasErrors ,  loadedFromSource ,  language ,  modelType ,  sourceDocument ,  modelStore ,  modelErrors ) 
7684 { 
7785 _attributes  =  attributes  ??  ImmutableList < CsAttribute > . Empty ; 
@@ -91,6 +99,9 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
9199 _security  =  security ; 
92100 _inheritedInterfaces  =  inheritedInterfaces  ??  ImmutableList < CsInterface > . Empty ; 
93101 _members  =  members  ??  ImmutableList < CsMember > . Empty ; 
102+  _isNested  =  isNested ; 
103+  _nestedType  =  nestedType ; 
104+  _nestedModels  =  nestedModels  ??  ImmutableList < ICsNestedModel > . Empty ; 
94105 } 
95106
96107 /// <summary> 
@@ -214,7 +225,7 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
214225 /// List of the methods that are implemented in this container. 
215226 /// </summary> 
216227 public  IReadOnlyList < CsMethod >  Methods  =>  _members . Where ( m =>  m . MemberType  ==  CsMemberType . Method ) 
217-  . Cast < CsMethod > ( ) . Where ( m =>  m . MethodType  ==  CsMethodType . Member ) 
228+  . Cast < CsMethod > ( ) . Where ( m =>  m . MethodType  ==  CsMethodType . Member   |   m . MethodType   ==   CsMethodType . PartialImplementation   |   m . MethodType   ==   CsMethodType . PartialDefinition ) 
218229 . ToImmutableList ( )  ??  ImmutableList < CsMethod > . Empty ; 
219230
220231 /// <summary> 
@@ -230,6 +241,60 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
230241 public  IReadOnlyList < CsEvent >  Events  =>  _members . Where ( m =>  m . MemberType  ==  CsMemberType . Event ) . Cast < CsEvent > ( ) 
231242 . ToImmutableList ( )  ??  ImmutableList < CsEvent > . Empty ; 
232243
244+  /// <summary> 
245+  /// Models that are nested in the implementation of this container. 
246+  /// </summary> 
247+  public  IReadOnlyList < ICsNestedModel >  NestedModels  =>  _nestedModels ; 
248+ 
249+  /// <summary> 
250+  /// Classes that are nested in this container. 
251+  /// </summary> 
252+  public  IReadOnlyList < CsClass >  NestedClasses  => 
253+  _nestedModels . Where ( n =>  n . NestedType  ==  CsNestedType . Class ) . Cast < CsClass > ( ) . ToImmutableList ( ) ; 
254+ 
255+  /// <summary> 
256+  /// Interfaces that are nested in this container. 
257+  /// </summary> 
258+  public  IReadOnlyList < CsInterface >  NestedInterfaces  => 
259+  _nestedModels . Where ( n =>  n . NestedType  ==  CsNestedType . Interface ) . Cast < CsInterface > ( ) . ToImmutableList ( ) ; 
260+ 
261+  /// <summary> 
262+  /// Structures that are nested in this container. 
263+  /// </summary> 
264+  public  IReadOnlyList < CsStructure >  NestedStructures  => 
265+  _nestedModels . Where ( n =>  n . NestedType  ==  CsNestedType . Structure ) . Cast < CsStructure > ( ) . ToImmutableList ( ) ; 
266+ 
267+  /// <summary> 
268+  /// Enums that are nested in this container. 
269+  /// </summary> 
270+  public  IReadOnlyList < CsEnum >  NestedEnums  => 
271+  _nestedModels . Where ( n =>  n . NestedType  ==  CsNestedType . Enum ) . Cast < CsEnum > ( ) . ToImmutableList ( ) ; 
272+ 
273+  /// <summary> 
274+  /// Models that are nested in the implementation of this container. 
275+  /// </summary> 
276+  IReadOnlyList < IDotNetNestedModel >  IDotNetContainer . NestedModels  =>  NestedModels ; 
277+ 
278+  /// <summary> 
279+  /// Classes that are nested in this container. 
280+  /// </summary> 
281+  IReadOnlyList < IDotNetClass >  IDotNetContainer . NestedClasses  =>  NestedClasses ; 
282+ 
283+  /// <summary> 
284+  /// Interfaces that are nested in this container. 
285+  /// </summary> 
286+  IReadOnlyList < IDotNetInterface >  IDotNetContainer . NestedInterfaces  =>  NestedInterfaces ; 
287+ 
288+  /// <summary> 
289+  /// Structures that are nested in this container. 
290+  /// </summary> 
291+  IReadOnlyList < IDotNetStructure >  IDotNetContainer . NestedStructures  =>  NestedStructures ; 
292+ 
293+  /// <summary> 
294+  /// Enums that are nested in this container. 
295+  /// </summary> 
296+  IReadOnlyList < IDotNetEnum >  IDotNetContainer . NestedEnums  =>  NestedEnums ; 
297+ 
233298 /// <summary> 
234299 /// The source code syntax that is stored in the body of the container model. This will be null if the container was not loaded from source code. 
235300 /// </summary> 
@@ -430,5 +495,20 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
430495
431496 /// <inheritdoc/> 
432497 public  string  ModelSourceFile  =>  _modelSourceFile ; 
498+ 
499+  /// <summary> 
500+  /// Identifies the type of model that has been nested. 
501+  /// </summary> 
502+  DotNetNestedType  IDotNetNestedModel . NestedType  =>  ( DotNetNestedType )  _nestedType  ; 
503+ 
504+  /// <summary> 
505+  /// Identifies the type of model that has been nested. 
506+  /// </summary> 
507+  public  CsNestedType  NestedType  =>  _nestedType ; 
508+ 
509+  /// <summary> 
510+  /// Flag that determines if this model is nested in a parent model. 
511+  /// </summary> 
512+  public  bool  IsNested  {  get ;  } 
433513 } 
434514} 
0 commit comments