Commit eac303e 1 parent 7f678cc commit eac303e Copy full SHA for eac303e
File tree 1 file changed +10
-2
lines changed
src/AasxCsharpLibrary/Extensions
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
10
10
using AdminShellNS . Extensions ;
11
11
using Newtonsoft . Json ;
12
12
using System ;
13
+ using System . Collections ;
13
14
using System . Collections . Generic ;
14
15
using System . IO ;
15
16
using System . Linq ;
@@ -497,8 +498,13 @@ public static ISubmodel FindSubmodel(this AasCore.Aas3_0.Environment environment
497
498
return null ;
498
499
}
499
500
500
- var submodels = environment . Submodels . Where ( s => s . Id . Equals ( key . Value , StringComparison . OrdinalIgnoreCase ) ) ;
501
- if ( submodels . Any ( ) )
501
+ List < ISubmodel > submodels = null ;
502
+ if ( environment != null && ! environment . Submodels . IsNullOrEmpty ( ) )
503
+ {
504
+ submodels = environment . Submodels . Where ( s => s . Id . Equals ( key . Value , StringComparison . OrdinalIgnoreCase ) ) . ToList ( ) ;
505
+
506
+ }
507
+ if ( ! submodels . IsNullOrEmpty ( ) )
502
508
{
503
509
return submodels . First ( ) ;
504
510
}
@@ -1032,6 +1038,7 @@ public static IReference CopySubmodelRefAndCD(this AasCore.Aas3_0.Environment en
1032
1038
if ( dstSub == null && copySubmodel )
1033
1039
{
1034
1040
dstSub = srcSub . Copy ( ) ;
1041
+ environment . Submodels ??= new List < ISubmodel > ( ) ;
1035
1042
environment . Submodels . Add ( dstSub ) ;
1036
1043
}
1037
1044
else
@@ -1074,6 +1081,7 @@ private static void CopyConceptDescriptionsFrom(this AasCore.Aas3_0.Environment
1074
1081
if ( cdDest == null )
1075
1082
{
1076
1083
// copy new
1084
+ environment . ConceptDescriptions ??= new List < IConceptDescription > ( ) ;
1077
1085
environment . ConceptDescriptions . Add ( cdSrc . Copy ( ) ) ;
1078
1086
}
1079
1087
You can’t perform that action at this time.
0 commit comments