Skip to content

Commit

Permalink
create more facades
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezor committed Jun 7, 2024
1 parent 61d8262 commit abf7b1f
Show file tree
Hide file tree
Showing 8 changed files with 728 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/AasCore/Reporting/ErrorFacade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace AasCore.Reporting;

public class ErrorFacade
{
private readonly Aas3_0.Reporting.Error _error;

public ErrorFacade(string cause)
{
_error = new Aas3_0.Reporting.Error(cause);
}

public string Cause => _error.Cause;

public ICollection<Aas3_0.Reporting.Segment> PathSegments =>
new List<Aas3_0.Reporting.Segment>(_error.PathSegments);

public void PrependSegment(Aas3_0.Reporting.Segment segment)
{
_error.PrependSegment(segment);
}
}
78 changes: 78 additions & 0 deletions src/AasCore/Types/AssetInformationFacade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using AasCore.Aas3_0;

namespace AasCore.Types;

public class AssetInformationFacade
{
private readonly AssetInformation _assetInformation;

//TODO: have a facade for all constructor values
public AssetInformationFacade(
AssetKind assetKind,
string? globalAssetId = null,
List<ISpecificAssetId>? specificAssetIds = null,
string? assetType = null,
IResource? defaultThumbnail = null
)
{
_assetInformation = new AssetInformation(
assetKind,
globalAssetId,
specificAssetIds,
assetType,
defaultThumbnail
);
}

public AssetKind AssetKind
{
get => _assetInformation.AssetKind;
set => _assetInformation.AssetKind = value;
}

public string? GlobalAssetId
{
get => _assetInformation.GlobalAssetId;
set => _assetInformation.GlobalAssetId = value;
}

public List<ISpecificAssetId>? SpecificAssetIds
{
get => _assetInformation.SpecificAssetIds;
set => _assetInformation.SpecificAssetIds = value;
}

public string? AssetType
{
get => _assetInformation.AssetType;
set => _assetInformation.AssetType = value;
}

public IResource? DefaultThumbnail
{
get => _assetInformation.DefaultThumbnail;
set => _assetInformation.DefaultThumbnail = value;
}

public IEnumerable<ISpecificAssetId> OverSpecificAssetIdsOrEmpty() =>
_assetInformation.OverSpecificAssetIdsOrEmpty();

public IEnumerable<IClass> DescendOnce() => _assetInformation.DescendOnce();

public IEnumerable<IClass> Descend() => _assetInformation.Descend();

public void Accept(Visitation.IVisitor visitor) => _assetInformation.Accept(visitor);

public void Accept<TContext>(
Visitation.IVisitorWithContext<TContext> visitor,
TContext context
) => _assetInformation.Accept(visitor, context);

public T Transform<T>(Visitation.ITransformer<T> transformer) =>
_assetInformation.Transform(transformer);

public T Transform<TContext, T>(
Visitation.ITransformerWithContext<TContext, T> transformer,
TContext context
) => _assetInformation.Transform(transformer, context);
}
129 changes: 129 additions & 0 deletions src/AasCore/Types/BlobFacade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
using AasCore.Aas3_0;

namespace AasCore.Types;

public class BlobFacade
{
private readonly Blob _blob;

public BlobFacade(
string contentType,
List<IExtension>? extensions = null,
string? category = null,
string? idShort = null,
List<ILangStringNameType>? displayName = null,
List<ILangStringTextType>? description = null,
IReference? semanticId = null,
List<IReference>? supplementalSemanticIds = null,
List<IQualifier>? qualifiers = null,
List<IEmbeddedDataSpecification>? embeddedDataSpecifications = null,
byte[]? value = null
)
{
_blob = new Blob(
contentType,
extensions,
category,
idShort,
displayName,
description,
semanticId,
supplementalSemanticIds,
qualifiers,
embeddedDataSpecifications,
value
);
}

public string? Category
{
get => _blob.Category;
set => _blob.Category = value;
}

public string? IdShort
{
get => _blob.IdShort;
set => _blob.IdShort = value;
}

public List<ILangStringNameType>? DisplayName
{
get => _blob.DisplayName;
set => _blob.DisplayName = value;
}

public List<ILangStringTextType>? Description
{
get => _blob.Description;
set => _blob.Description = value;
}

public IReference? SemanticId
{
get => _blob.SemanticId;
set => _blob.SemanticId = value;
}

public List<IReference>? SupplementalSemanticIds
{
get => _blob.SupplementalSemanticIds;
set => _blob.SupplementalSemanticIds = value;
}

public List<IQualifier>? Qualifiers
{
get => _blob.Qualifiers;
set => _blob.Qualifiers = value;
}

public List<IEmbeddedDataSpecification>? EmbeddedDataSpecifications
{
get => _blob.EmbeddedDataSpecifications;
set => _blob.EmbeddedDataSpecifications = value;
}

public byte[]? Value
{
get => _blob.Value;
set => _blob.Value = value;
}

public string ContentType => _blob.ContentType;

public IEnumerable<IExtension> OverExtensionsOrEmpty() => _blob.OverExtensionsOrEmpty();

public IEnumerable<ILangStringNameType> OverDisplayNameOrEmpty() =>
_blob.OverDisplayNameOrEmpty();

public IEnumerable<ILangStringTextType> OverDescriptionOrEmpty() =>
_blob.OverDescriptionOrEmpty();

public IEnumerable<IReference> OverSupplementalSemanticIdsOrEmpty() =>
_blob.OverSupplementalSemanticIdsOrEmpty();

public IEnumerable<IQualifier> OverQualifiersOrEmpty() => _blob.OverQualifiersOrEmpty();

public IEnumerable<IEmbeddedDataSpecification> OverEmbeddedDataSpecificationsOrEmpty() =>
_blob.OverEmbeddedDataSpecificationsOrEmpty();

public string CategoryOrDefault() => _blob.CategoryOrDefault();

public IEnumerable<IClass> DescendOnce() => _blob.DescendOnce();

public IEnumerable<IClass> Descend() => _blob.Descend();

public void Accept(Visitation.IVisitor visitor) => _blob.Accept(visitor);

public void Accept<TContext>(
Visitation.IVisitorWithContext<TContext> visitor,
TContext context
) => _blob.Accept(visitor, context);

public T Transform<T>(Visitation.ITransformer<T> transformer) => _blob.Transform(transformer);

public T Transform<TContext, T>(
Visitation.ITransformerWithContext<TContext, T> transformer,
TContext context
) => _blob.Transform(transformer, context);
}
111 changes: 111 additions & 0 deletions src/AasCore/Types/ConceptDescriptionFacade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using AasCore.Aas3_0;

namespace AasCore.Types;

public class ConceptDescriptionFacade
{
private readonly ConceptDescription _conceptDescription;

public ConceptDescriptionFacade(
string id,
List<IExtension>? extensions = null,
string? category = null,
string? idShort = null,
List<ILangStringNameType>? displayName = null,
List<ILangStringTextType>? description = null,
IAdministrativeInformation? administration = null,
List<IEmbeddedDataSpecification>? embeddedDataSpecifications = null,
List<IReference>? isCaseOf = null
)
{
_conceptDescription = new ConceptDescription(
id,
extensions,
category,
idShort,
displayName,
description,
administration,
embeddedDataSpecifications,
isCaseOf
);
}

public string? Category
{
get => _conceptDescription.Category;
set => _conceptDescription.Category = value;
}

public string? IdShort
{
get => _conceptDescription.IdShort;
set => _conceptDescription.IdShort = value;
}

public List<ILangStringNameType>? DisplayName
{
get => _conceptDescription.DisplayName;
set => _conceptDescription.DisplayName = value;
}

public List<ILangStringTextType>? Description
{
get => _conceptDescription.Description;
set => _conceptDescription.Description = value;
}

public IAdministrativeInformation? Administration
{
get => _conceptDescription.Administration;
set => _conceptDescription.Administration = value;
}

public string Id => _conceptDescription.Id;

public List<IEmbeddedDataSpecification>? EmbeddedDataSpecifications
{
get => _conceptDescription.EmbeddedDataSpecifications;
set => _conceptDescription.EmbeddedDataSpecifications = value;
}

public List<IReference>? IsCaseOf
{
get => _conceptDescription.IsCaseOf;
set => _conceptDescription.IsCaseOf = value;
}

public IEnumerable<IExtension> OverExtensionsOrEmpty() =>
_conceptDescription.OverExtensionsOrEmpty();

public IEnumerable<ILangStringNameType> OverDisplayNameOrEmpty() =>
_conceptDescription.OverDisplayNameOrEmpty();

public IEnumerable<ILangStringTextType> OverDescriptionOrEmpty() =>
_conceptDescription.OverDescriptionOrEmpty();

public IEnumerable<IEmbeddedDataSpecification> OverEmbeddedDataSpecificationsOrEmpty() =>
_conceptDescription.OverEmbeddedDataSpecificationsOrEmpty();

public IEnumerable<IReference> OverIsCaseOfOrEmpty() =>
_conceptDescription.OverIsCaseOfOrEmpty();

public IEnumerable<IClass> DescendOnce() => _conceptDescription.DescendOnce();

public IEnumerable<IClass> Descend() => _conceptDescription.Descend();

public void Accept(Visitation.IVisitor visitor) => _conceptDescription.Accept(visitor);

public void Accept<TContext>(
Visitation.IVisitorWithContext<TContext> visitor,
TContext context
) => _conceptDescription.Accept(visitor, context);

public T Transform<T>(Visitation.ITransformer<T> transformer) =>
_conceptDescription.Transform(transformer);

public T Transform<TContext, T>(
Visitation.ITransformerWithContext<TContext, T> transformer,
TContext context
) => _conceptDescription.Transform(transformer, context);
}
Loading

0 comments on commit abf7b1f

Please sign in to comment.