Skip to content

Commit

Permalink
Fix nullable issue in RegistryInitializerService #324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezor authored Jul 4, 2024
1 parent 345f74c commit 88a8aae
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest

if (aasRegistry == null || submodelRegistry == null)
{
foreach (AdminShellNS.AdminShellPackageEnv env in Program.env)
foreach (var env in Program.env)
{
var aas = env.AasEnv.AssetAdministrationShells[0];
if (aas.IdShort != "REGISTRY")
var aas = env.AasEnv?.AssetAdministrationShells?[0];
if (aas?.IdShort != "REGISTRY")
{
continue;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest

if (Program.withDb)
{
using (AasContext db = new AasContext())
await using (var db = new AasContext())
{
foreach (var aasDB in db.AASSets)
{
Expand Down Expand Up @@ -213,7 +213,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
}
catch
{
// Well? It seems like an Orzelski problem...
// Well? It seems like a problem with the certificate...
}

if (s2 == null)
Expand All @@ -224,7 +224,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest

var xc = new X509Certificate2Collection();
using var m = new MemoryStream();
s2.CopyTo(m);
await s2.CopyToAsync(m);
var b = m.GetBuffer();
xc.Import(b, certificatePassword, X509KeyStorageFlags.PersistKeySet);
Certificate = new X509Certificate2(b, certificatePassword);
Expand Down Expand Up @@ -494,7 +494,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
}

Program.submodelAPIcount++;
string clientToken = null;
string? clientToken = null;

switch (sd.IdShort)
{
Expand Down Expand Up @@ -525,14 +525,14 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
var policyRequestedResource = string.Empty;
foreach (var kvp in response.Headers)
{
if (kvp.Key == "policy")
switch (kvp.Key)
{
policy = kvp.Value.FirstOrDefault();
}

if (kvp.Key == "policyRequestedResource")
{
policyRequestedResource = kvp.Value.FirstOrDefault() ?? string.Empty;
case "policy":
policy = kvp.Value.FirstOrDefault();
break;
case "policyRequestedResource":
policyRequestedResource = kvp.Value.FirstOrDefault() ?? string.Empty;
break;
}
}

Expand Down

0 comments on commit 88a8aae

Please sign in to comment.