Skip to content

Commit 4936603

Browse files
committed
* messing up to much async
1 parent 1a773b8 commit 4936603

File tree

5 files changed

+1022
-384
lines changed

5 files changed

+1022
-384
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
3+
Author: Michael Hoffmeister
4+
5+
This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
6+
7+
This source code may use other Open Source software components (see LICENSE.txt).
8+
*/
9+
10+
using Extensions;
11+
using Newtonsoft.Json;
12+
using Newtonsoft.Json.Linq;
13+
using Newtonsoft.Json.Serialization;
14+
using System;
15+
using System.Collections.Generic;
16+
using System.IO;
17+
using System.Reflection;
18+
19+
namespace AdminShellNS
20+
{
21+
public static class AdminShellComparers
22+
{
23+
24+
/// see: https://www.codeproject.com/Articles/72470/LINQ-Enhancing-Distinct-With-The-PredicateEquality
25+
public class PredicateEqualityComparer<T> : EqualityComparer<T>
26+
{
27+
private Func<T, T, bool> predicate;
28+
29+
public PredicateEqualityComparer(Func<T, T, bool> predicate)
30+
: base()
31+
{
32+
this.predicate = predicate;
33+
}
34+
35+
public override bool Equals(T x, T y)
36+
{
37+
if (x != null)
38+
{
39+
return ((y != null) && this.predicate(x, y));
40+
}
41+
42+
if (y != null)
43+
{
44+
return false;
45+
}
46+
47+
return true;
48+
}
49+
50+
public override int GetHashCode(T obj)
51+
{
52+
// Always return the same value to force the call to IEqualityComparer<T>.Equals
53+
return 0;
54+
}
55+
}
56+
}
57+
}

src/AasxPackageLogic/PackageCentral/AasOnDemandEnvironment.cs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class AasIdentifiableSideInfo : OnDemandSideInfoBase
4242

4343
public string Id = "";
4444
public string IdShort = "";
45+
public Uri Endpoint;
4546

4647
/// <summary>
4748
/// In the tree of virtual elements, place a visual element below this entity

src/AasxPackageLogic/PackageCentral/AdminShellPackageDynamicFetchEnv.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public async Task<bool> TryFetchThumbnail(Aas.IAssetAdministrationShell aas)
8484
// try
8585
try
8686
{
87-
await PackageHttpDownloadUtil.HttpGetToMemoryStream(
88-
sourceUri: PackageContainerHttpRepoSubset.BuildUriForAasThumbnail(_defaultRepoBaseUri, aas.Id),
87+
await PackageHttpDownloadUtil.HttpGetToMemoryStreamOLD(
88+
sourceUri: PackageContainerHttpRepoSubset.BuildUriForRepoAasThumbnail(_defaultRepoBaseUri, aas.Id),
8989
runtimeOptions: _runtimeOptions,
9090
lambdaDownloadDone: (ms, contentFn) =>
9191
{
@@ -129,11 +129,11 @@ await PackageHttpDownloadUtil.HttpGetToMemoryStream(
129129
Aas.IIdentifiable res = null;
130130

131131
// build the location
132-
var loc = PackageContainerHttpRepoSubset.BuildUriForSubmodel(_defaultRepoBaseUri, id);
132+
var loc = PackageContainerHttpRepoSubset.BuildUriForRepoSingleSubmodel(_defaultRepoBaseUri, id);
133133
if (loc == null)
134134
return null;
135135

136-
await PackageHttpDownloadUtil.HttpGetToMemoryStream(
136+
await PackageHttpDownloadUtil.HttpGetToMemoryStreamOLD(
137137
sourceUri: loc,
138138
allowFakeResponses: _runtimeOptions?.AllowFakeResponses ?? false,
139139
runtimeOptions: _runtimeOptions,
@@ -317,15 +317,15 @@ public async Task<int> TrySaveAllTaintedIdentifiables(
317317

318318
if (allAas) count += await TrySaveAllTaintedIdentifiablesOf<Aas.IAssetAdministrationShell>(
319319
_aasEnv?.AssetAdministrationShells,
320-
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForAAS(defBase, id));
320+
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForRepoSingleAAS(defBase, id));
321321

322322
if (allSubmodels) count += await TrySaveAllTaintedIdentifiablesOf<Aas.ISubmodel>(
323323
_aasEnv?.Submodels,
324-
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForSubmodel(defBase, id));
324+
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForRepoSingleSubmodel(defBase, id));
325325

326326
if (allCDs) count += await TrySaveAllTaintedIdentifiablesOf<Aas.IConceptDescription>(
327327
_aasEnv?.ConceptDescriptions,
328-
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForCD(defBase, id));
328+
(defBase, id) => PackageContainerHttpRepoSubset.BuildUriForRepoSingleCD(defBase, id));
329329

330330
return count;
331331
}

0 commit comments

Comments
 (0)