-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
369 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// <copyright file="ClassExtensions.cs" company="Starion Group S.A."> | ||
// | ||
// Copyright 2019-2024 Starion Group S.A. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, softwareUseCases | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// </copyright> | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
namespace uml4net.Extensions | ||
{ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
|
||
using uml4net.POCO.Classification; | ||
using uml4net.POCO.StructuredClassifiers; | ||
|
||
/// <summary> | ||
/// Extension methods for <see cref="IClass"/> interface | ||
/// </summary> | ||
public static class ClassExtensions | ||
{ | ||
/// <summary> | ||
/// Queries all the properties that are implemented by the class directly or through superclasses | ||
/// or interface implementations | ||
/// </summary> | ||
/// <param name="class">The <see cref="IClass"/> from which to query the properties</param> | ||
/// <returns>A <see cref="ReadOnlyCollection{T}"/> of <see cref="IProperty"/></returns> | ||
public static ReadOnlyCollection<IProperty> QueryAllProperties(this IClass @class) | ||
{ | ||
var result = new List<IProperty>(); | ||
|
||
var superClassifiers = @class.QueryAllGeneralClassifiers(); | ||
|
||
foreach (var classifier in superClassifiers) | ||
{ | ||
if (classifier is IClass c) | ||
{ | ||
result.AddRange(c.OwnedAttribute); | ||
result.AddRange(c.QueryInterfaces().SelectMany(x => x.Attribute).Distinct()); | ||
} | ||
} | ||
|
||
return result.Distinct().ToList().AsReadOnly(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="ClassifierExtensions.cs" company="Starion Group N.V."> | ||
// Copyright (c) 2024 Starion Group N.V. | ||
// | ||
// Author: Seliman Niakate, Sebastien d'Antuono, Nathanael Smiechowski, Amine Nemmaoui, Amir Janati. | ||
// | ||
// This file is part of the SafePlace solution. | ||
// | ||
// SafePlace is distributed under the terms and conditions of the | ||
// European Space Agency Public License (ESA-PL) Weak Copyleft (Type 2) – v2.4 | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace uml4net.Extensions | ||
{ | ||
using POCO.Classification; | ||
using System.Collections.Generic; | ||
|
||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
|
||
/// <summary> | ||
/// The <see cref="ClassifierExtensions"/> class provides extensions methods for the <see cref="IClassifier"/> | ||
/// </summary> | ||
public static class ClassifierExtensions | ||
{ | ||
/// <summary> | ||
/// Queries all the general <see cref="IClassifier"/>s of the subject <see cref="IClassifier"/> | ||
/// </summary> | ||
/// <param name="classifier"> | ||
/// the subject <see cref="IClassifier"/> | ||
/// </param> | ||
/// <returns> | ||
/// a readonly collection of <see cref="IClassifier"/>s, including the subject <see cref="IClassifier"/>, of | ||
/// all the super classifiers | ||
/// </returns> | ||
public static ReadOnlyCollection<IClassifier> QueryAllGeneralClassifiers(this IClassifier classifier) | ||
{ | ||
var result = new List<IClassifier> { classifier }; | ||
|
||
if (classifier.Generalization != null) | ||
{ | ||
foreach (var generalization in classifier.Generalization) | ||
{ | ||
result.AddRange(generalization.General.QueryAllGeneralClassifiers()); | ||
} | ||
} | ||
|
||
return result.Distinct().ToList().AsReadOnly(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
uml4net.Reporting.Tests/Generators/ModelInspectorTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.