Skip to content

Commit

Permalink
Fixes the issue 226 (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar authored Jul 4, 2024
1 parent 7f678cc commit 863fbd5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
using AdminShellNS.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -497,8 +498,13 @@ public static ISubmodel FindSubmodel(this AasCore.Aas3_0.Environment environment
return null;
}

var submodels = environment.Submodels.Where(s => s.Id.Equals(key.Value, StringComparison.OrdinalIgnoreCase));
if (submodels.Any())
List<ISubmodel> submodels = null;
if (environment != null && !environment.Submodels.IsNullOrEmpty())
{
submodels = environment.Submodels.Where(s => s.Id.Equals(key.Value, StringComparison.OrdinalIgnoreCase)).ToList();

}
if (!submodels.IsNullOrEmpty())
{
return submodels.First();
}
Expand Down Expand Up @@ -1032,6 +1038,7 @@ public static IReference CopySubmodelRefAndCD(this AasCore.Aas3_0.Environment en
if (dstSub == null && copySubmodel)
{
dstSub = srcSub.Copy();
environment.Submodels ??= new List<ISubmodel>();
environment.Submodels.Add(dstSub);
}
else
Expand Down Expand Up @@ -1074,6 +1081,7 @@ private static void CopyConceptDescriptionsFrom(this AasCore.Aas3_0.Environment
if (cdDest == null)
{
// copy new
environment.ConceptDescriptions ??= new List<IConceptDescription>();
environment.ConceptDescriptions.Add(cdSrc.Copy());
}

Expand Down

0 comments on commit 863fbd5

Please sign in to comment.