diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb2ea073..e60e817b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,10 +53,9 @@ jobs: - name: Package NuGet run: | - nuget pack ../nuspec/nuget/BBT.StructureTools.nuspec - nuget pack ../nuspec/nuget/BBT.StructureTools.Extensions.nuspec + dotnet pack -c $BUILD_CONFIG -p:PackageVersion=$BUILD_VERSION - name: Publish NuGet run: | - nuget push ./BBT.StructureTools.$BUILD_VERSION.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}} - nuget push ./BBT.StructureTools.Extensions.$BUILD_VERSION.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}} + nuget push ./BBT.StructureTools/bin/Release/BBT.StructureTools.$BUILD_VERSION.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}} + nuget push ./BBT.StructureTools.Extensions/bin/Release/BBT.StructureTools.Extensions.$BUILD_VERSION.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}} diff --git a/nuspec/nuget/BBT.StructureTools.Extensions.nuspec b/nuspec/nuget/BBT.StructureTools.Extensions.nuspec deleted file mode 100644 index 16eb2e22..00000000 --- a/nuspec/nuget/BBT.StructureTools.Extensions.nuspec +++ /dev/null @@ -1,32 +0,0 @@ - - - - BBT.StructureTools.Extensions - BBT StructureTools Extensions - 2.1.2 - BBT Software AG - bbtsoftware - .NET. classes for copying, comparing and converting object structures. - .NET. classes for copying, comparing and converting object structures. - MIT - icon.png - false - - Copyright © BBT Software AG - StructureTools Functional - https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/2.1.2 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nuspec/nuget/BBT.StructureTools.nuspec b/nuspec/nuget/BBT.StructureTools.nuspec deleted file mode 100644 index b185b18c..00000000 --- a/nuspec/nuget/BBT.StructureTools.nuspec +++ /dev/null @@ -1,32 +0,0 @@ - - - - BBT.StructureTools - BBT StructureTools - 2.1.2 - BBT Software AG - bbtsoftware - .NET. classes for copying, comparing and converting object structures. - .NET. classes for copying, comparing and converting object structures. - MIT - icon.png - false - - Copyright © BBT Software AG - StructureTools Functional - https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/2.1.2 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nuspec/nuget/icon.png b/nuspec/nuget/icon.png deleted file mode 100644 index 9925180b..00000000 Binary files a/nuspec/nuget/icon.png and /dev/null differ diff --git a/src/BBT.StructureTools.Extensions/BBT.StructureTools.Extensions.csproj b/src/BBT.StructureTools.Extensions/BBT.StructureTools.Extensions.csproj index 0bc7f14e..83b53d56 100644 --- a/src/BBT.StructureTools.Extensions/BBT.StructureTools.Extensions.csproj +++ b/src/BBT.StructureTools.Extensions/BBT.StructureTools.Extensions.csproj @@ -4,25 +4,28 @@ netstandard2.0;net6.0 BBT.StructureTools.Extensions ..\BBT.StructureTools.ruleset - bin\$(Configuration)\BBT.StructureTools.XML + bin\$(Configuration)\BBT.StructureTools.xml bin\$(Configuration)\ true - BBT.StructureTools.Extensions + BBT StructureTools Extensions Extensions to BBT.StructureTools (e.g. implementations of ICreateConvertHelper and IConvertHelperFactory interfaces). BBT.StructureTools BBT Software AG BBT Software AG Copyright © BBT Software AG - copy compare convert + BBT.StructureTools.Extensions + StructureTools Functional icon.png - http://bbtsoftware.github.io/BBT.StructureTools/ + https://github.com/bbtsoftware/BBT.StructureTools/ MIT + false git https://github.com/bbtsoftware/BBT.StructureTools.git - https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/2.0.1 + https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/3.0.0 + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.xml @@ -32,16 +35,13 @@ pdbonly - + - + - - True - - + diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelper.cs b/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelper.cs index 24ec3ae4..3c873594 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelper.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelper.cs @@ -26,15 +26,18 @@ public CreateConvertFromStrategyHelper(IGenericStrategyProvider - public TTarget CreateTarget(TSource source, ICollection additionalProcessings) + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) { - source.NotNull(nameof(source)); - additionalProcessings.NotNull(nameof(additionalProcessings)); + var strategy = this.strategyProvider.GetStrategy(source); + strategy.Convert(source, target, additionalProcessings); + } + /// + public TTarget Create(TSource source) + { var strategy = this.strategyProvider.GetStrategy(source); var concreteTarget = strategy.CreateTarget(source); - strategy.Convert(source, concreteTarget, additionalProcessings); return concreteTarget; } diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperReverse.cs b/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperReverse.cs index 853b3048..13278120 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperReverse.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperReverse.cs @@ -30,18 +30,19 @@ public CreateConvertFromStrategyHelperReverse(IGenericStrategyProvider - public TTarget CreateTarget( - TSource source, - TReverseRelation reverseRelation, - ICollection additionalProcessings) + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) { - source.NotNull(nameof(source)); - reverseRelation.NotNull(nameof(reverseRelation)); + var strategy = this.strategyProvider.GetStrategy(source); + strategy.Convert(source, target, additionalProcessings); + } + /// + public TTarget Create(TSource source, TReverseRelation reverseRelation) + { var strategy = this.strategyProvider.GetStrategy(source); var concreteTarget = strategy.CreateTarget(source); concreteTarget.SetPropertyValue(this.reverseRelationExpr, reverseRelation); - strategy.Convert(source, concreteTarget, additionalProcessings); + return concreteTarget; } diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelper.cs b/src/BBT.StructureTools.Extensions/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelper.cs index d6968c2e..bdd5b2d8 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelper.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelper.cs @@ -47,20 +47,18 @@ public void SetupReverseRelation(Expression> rev } /// - public TTarget CreateTarget( - TSource source, - TReverseRelation reverseRelation, - ICollection additionalProcessings) + public TTarget Create(TSource source, TReverseRelation reverseRelation) { - source.NotNull(nameof(source)); - reverseRelation.NotNull(nameof(reverseRelation)); - additionalProcessings.NotNull(nameof(additionalProcessings)); - var target = this.instanceCreator.Create(); target.SetPropertyValue(this.reverseRelationExpr, reverseRelation); - this.convert.Convert(source, target, additionalProcessings); return target; } + + /// + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) + { + this.convert.Convert(source, target, additionalProcessings); + } } /// @@ -92,15 +90,15 @@ public CreateTargetConvertTargetHelper( } /// - public TTarget CreateTarget( - TSource source, - ICollection additionalProcessings) + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) { - source.NotNull(nameof(source)); - additionalProcessings.NotNull(nameof(additionalProcessings)); + this.convert.Convert(source, target, additionalProcessings); + } + /// + public TTarget Create(TSource source) + { var target = this.instanceCreator.Create(); - this.convert.Convert(source, target, additionalProcessings); return target; } } diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelper.cs b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelper.cs index 7c7bbf00..d9aac6af 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelper.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelper.cs @@ -47,20 +47,18 @@ public void SetupReverseRelation(Expression> rev } /// - public TTarget CreateTarget( - TSource source, - TReverseRelation reverseRelation, - ICollection additionalProcessings) + public TTarget Create(TSource source, TReverseRelation reverseRelation) { - source.NotNull(nameof(source)); - reverseRelation.NotNull(nameof(reverseRelation)); - additionalProcessings.NotNull(nameof(additionalProcessings)); - var target = this.instanceCreator.Create(); target.SetPropertyValue(this.reverseRelationExpr, reverseRelation); - this.convert.Convert(source, target, additionalProcessings); return target; } + + /// + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) + { + this.convert.Convert(source, target, additionalProcessings); + } } /// @@ -93,15 +91,15 @@ public CreateTargetImplConvertTargetHelper( } /// - public TTarget CreateTarget( - TSource source, - ICollection additionalProcessings) + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) { - source.NotNull(nameof(source)); - additionalProcessings.NotNull(nameof(additionalProcessings)); + this.convert.Convert(source, target, additionalProcessings); + } + /// + public TTarget Create(TSource source) + { var target = this.instanceCreator.Create(); - this.convert.Convert(source, target, additionalProcessings); return target; } } diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelper.cs b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelper.cs index 2035a6be..1c2dfe0c 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelper.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelper.cs @@ -32,15 +32,15 @@ public CreateTargetImplConvertTargetImplHelper( } /// - public TTarget CreateTarget( - TSource source, - ICollection additionalProcessings) + public void Convert(TSource source, TTarget target, ICollection additionalProcessings) { - source.NotNull(nameof(source)); - additionalProcessings.NotNull(nameof(additionalProcessings)); + this.convert.Convert(source, (TTargetImpl)target, additionalProcessings); + } + /// + public TTarget Create(TSource source) + { var target = this.instanceCreator.Create(); - this.convert.Convert(source, target, additionalProcessings); return target; } diff --git a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperReverse.cs b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperReverse.cs index 16e7c890..3e9dcb4f 100644 --- a/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperReverse.cs +++ b/src/BBT.StructureTools.Extensions/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperReverse.cs @@ -44,20 +44,19 @@ public void SetupReverseRelation(Expression> rev } /// - public TTarget CreateTarget( - TSource source, - TReverseRelation reverseRelation, - ICollection additionalProcessings) + public TTarget Create(TSource source, TReverseRelation reverseRelation) { - source.NotNull(nameof(source)); - reverseRelation.NotNull(nameof(reverseRelation)); - additionalProcessings.NotNull(nameof(additionalProcessings)); - var target = this.instanceCreator.Create(); target.SetPropertyValue(this.reverseRelationExpr, reverseRelation); - this.convert.Convert(source, target, additionalProcessings); return target; } + + /// + public void Convert( + TSource source, TTarget target, ICollection additionalProcessings) + { + this.convert.Convert(source, (TTargetImpl)target, additionalProcessings); + } } } \ No newline at end of file diff --git a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj index 742f59aa..fa66f4ff 100644 --- a/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj +++ b/src/BBT.StructureTools.Tests/BBT.StructureTools.Tests.csproj @@ -25,14 +25,14 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + all - + all diff --git a/src/BBT.StructureTools.Tests/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperTests.cs index 8f6f2cd9..e7657cae 100644 --- a/src/BBT.StructureTools.Tests/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/CreateConvertFromStrategy/CreateConvertFromStrategyHelperTests.cs @@ -34,7 +34,8 @@ public void CreateTarget_NoReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceDerivedLeaf(); - var target = testCandidate.CreateTarget(source, processings); + var target = testCandidate.Create(source); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.Should().BeOfType(); @@ -55,7 +56,8 @@ public void CreateTarget_WithReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceDerivedLeaf(); var reverseRelation = new TargetRoot(); - var target = testCandidate.CreateTarget(source, reverseRelation, processings); + var target = testCandidate.Create(source, reverseRelation); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.Should().BeOfType(); diff --git a/src/BBT.StructureTools.Tests/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelperTests.cs index 0b7489d0..7ae57416 100644 --- a/src/BBT.StructureTools.Tests/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/CreateTargetConvertTarget/CreateTargetConvertTargetHelperTests.cs @@ -30,7 +30,8 @@ public void CreateTarget_NoReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); - var target = testCandidate.CreateTarget(source, processings); + var target = testCandidate.Create(source); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); @@ -48,7 +49,8 @@ public void CreateTarget_WithReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); var reverseRelation = new TargetTree(); - var target = testCandidate.CreateTarget(source, reverseRelation, processings); + var target = testCandidate.Create(source, reverseRelation); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); diff --git a/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelperTests.cs index 42f1c3e5..9449fd46 100644 --- a/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTarget/CreateTargetImplConvertTargetHelperTests.cs @@ -30,7 +30,8 @@ public void CreateTarget_NoReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); - var target = testCandidate.CreateTarget(source, processings); + var target = testCandidate.Create(source); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); @@ -48,7 +49,8 @@ public void CreateTarget_WithReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); var reverseRelation = new TargetTree(); - var target = testCandidate.CreateTarget(source, reverseRelation, processings); + var target = testCandidate.Create(source, reverseRelation); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); diff --git a/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperTests.cs b/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperTests.cs index 5de3aa84..3c5b945b 100644 --- a/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperTests.cs +++ b/src/BBT.StructureTools.Tests/Convert/CreateTargetImplConvertTargetImpl/CreateTargetImplConvertTargetImplHelperTests.cs @@ -30,7 +30,8 @@ public void CreateTarget_NoReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); - var target = testCandidate.CreateTarget(source, processings); + var target = testCandidate.Create(source); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); @@ -48,7 +49,8 @@ public void CreateTarget_WithReverseRelation_CreateAndConvert() var processings = new List(); var source = new SourceTreeLeaf(); var reverseRelation = new TargetTree(); - var target = testCandidate.CreateTarget(source, reverseRelation, processings); + var target = testCandidate.Create(source, reverseRelation); + testCandidate.Convert(source, target, processings); target.Should().NotBeNull(); target.OriginId.Should().Be(source.Id); diff --git a/src/BBT.StructureTools/BBT.StructureTools.csproj b/src/BBT.StructureTools/BBT.StructureTools.csproj index 14ed9f65..59832fc0 100644 --- a/src/BBT.StructureTools/BBT.StructureTools.csproj +++ b/src/BBT.StructureTools/BBT.StructureTools.csproj @@ -4,25 +4,28 @@ netstandard2.0;net6.0 BBT.StructureTools ..\BBT.StructureTools.ruleset - bin\$(Configuration)\BBT.StructureTools.XML + bin\$(Configuration)\BBT.StructureTools.xml bin\$(Configuration)\ true - BBT.StructureTools - Classes for copying, comparing and converting object structures. + BBT StructureTools + .NET classes for copying, comparing and converting object structures. BBT.StructureTools BBT Software AG BBT Software AG Copyright © BBT Software AG - copy compare convert + BBT.StructureTools + StructureTools Functional icon.png - http://bbtsoftware.github.io/BBT.StructureTools/ + https://github.com/bbtsoftware/BBT.StructureTools/ MIT + false git https://github.com/bbtsoftware/BBT.StructureTools.git - https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/2.0.1 + https://github.com/bbtsoftware/BBT.StructureTools/releases/tag/3.0.0 + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.xml @@ -39,7 +42,7 @@ - + diff --git a/src/BBT.StructureTools/Convert/ICreateConvertHelper.cs b/src/BBT.StructureTools/Convert/ICreateConvertHelper.cs index 1e609ee8..3477365c 100644 --- a/src/BBT.StructureTools/Convert/ICreateConvertHelper.cs +++ b/src/BBT.StructureTools/Convert/ICreateConvertHelper.cs @@ -23,11 +23,18 @@ public interface ICreateConvertHelper> reverseRelationExpr); /// - /// Creates a new converted from . + /// Creates with . /// - TTarget CreateTarget( + TTarget Create( TSource source, - TReverseRelation reverseRelation, + TReverseRelation reverseRelation); + + /// + /// Converts into . + /// + void Convert( + TSource source, + TTarget target, ICollection additionalProcessings); } @@ -43,10 +50,16 @@ public interface ICreateConvertHelper where TConvertIntention : IBaseConvertIntention { /// - /// Creates a new converted from . + /// Creates . + /// + TTarget Create(TSource source); + + /// + /// Converts into . /// - TTarget CreateTarget( + void Convert( TSource source, + TTarget target, ICollection additionalProcessings); } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateFromSourceWithReverseRelation.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateFromSourceWithReverseRelation.cs index 9f2a147d..aaacb4d1 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateFromSourceWithReverseRelation.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateFromSourceWithReverseRelation.cs @@ -48,14 +48,16 @@ public void Execute( return; } - var targetValue = this.createConvertHelper.CreateTarget( - source, - target, - additionalProcessings); + var targetValue = this.createConvertHelper.Create(source, target); target.SetPropertyValue( this.targetExpression, targetValue); + + this.createConvertHelper.Convert( + source, + targetValue, + additionalProcessings); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToMany.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToMany.cs index 3b34d6f0..531be5db 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToMany.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToMany.cs @@ -68,7 +68,7 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(source); - var copies = new List(); + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { @@ -78,15 +78,12 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( - sourceValue, - additionalProcessings); - copies.Add(copy); - } + var copy = this.createConvertHelper.Create(sourceValue); + + targetList.AddUnique(copy); - target.AddRangeFilterNullValues( - this.targetExpression, - copies); + this.createConvertHelper.Convert(sourceValue, copy, additionalProcessings); + } } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelation.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelation.cs index 56897688..150dce0e 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelation.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelation.cs @@ -74,10 +74,9 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(source); - var copies = new List(); - var relation = this.relationFunc(source, target); + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -86,16 +85,16 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( + var copy = this.createConvertHelper.Create( + sourceValue, + relation); + targetList.AddUnique(copy); + + this.createConvertHelper.Convert( sourceValue, - relation, + copy, additionalProcessings); - copies.Add(copy); } - - target.AddRangeFilterNullValues( - this.targetExpression, - copies); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelationInclTargetArg.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelationInclTargetArg.cs index 5ac3838c..f0e98bf5 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelationInclTargetArg.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithRelationInclTargetArg.cs @@ -74,10 +74,9 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(source, target); - var copies = new List(); - var relation = this.relationFunc(source, target); + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -86,16 +85,17 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( + var copy = this.createConvertHelper.Create( sourceValue, - relation, + relation); + + targetList.AddUnique(copy); + + this.createConvertHelper.Convert( + sourceValue, + copy, additionalProcessings); - copies.Add(copy); } - - target.AddRangeFilterNullValues( - this.targetExpression, - copies); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithReverseRelation.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithReverseRelation.cs index d01fc0d6..89dede21 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithReverseRelation.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToManyWithReverseRelation.cs @@ -69,8 +69,7 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(source); - var copies = new List(); - + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -79,16 +78,17 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( + var copy = this.createConvertHelper.Create( + sourceValue, + target); + + targetList.AddUnique(copy); + + this.createConvertHelper.Convert( sourceValue, - target, + copy, additionalProcessings); - copies.Add(copy); } - - target.AddRangeFilterNullValues( - this.targetExpression, - copies); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOne.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOne.cs index ff1fe535..c33ec4e8 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOne.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOne.cs @@ -60,13 +60,13 @@ public void Execute( return; } - var targetValue = this.createConvertHelper.CreateTarget( - sourceValue, - additionalProcessings); + var targetValue = this.createConvertHelper.Create(sourceValue); target.SetPropertyValue( this.targetExpression, targetValue); + + this.createConvertHelper.Convert(sourceValue, targetValue, additionalProcessings); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneHistWithCondition.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneHistWithCondition.cs index 932ec7ef..5cd0bf8a 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneHistWithCondition.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneHistWithCondition.cs @@ -82,8 +82,7 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(source, target); - var copies = new List(); - + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -98,21 +97,22 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( + var copy = this.createConvertHelper.Create( sourceValue, - target, + target); + + targetList.AddUnique(copy); + + this.createConvertHelper.Convert( + sourceValue, + copy, additionalProcessings); - copies.Add(copy); - } - if (copyToOne) - { - this.targetValueTemporalDataHandler.SetEndInfinte(copies[0], TemporalConstants.InfiniteDate); + if (copyToOne) + { + this.targetValueTemporalDataHandler.SetEndInfinte(copy, TemporalConstants.InfiniteDate); + } } - - target.AddRangeFilterNullValues( - this.targetExpression, - copies); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelation.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelation.cs index 6d58bb7c..ba486268 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelation.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelation.cs @@ -67,14 +67,18 @@ public void Execute( var relation = this.relationFunc(source, target); - var targetValue = this.createConvertHelper.CreateTarget( - sourceValue, - relation, - additionalProcessings); + var targetValue = this.createConvertHelper.Create( + sourceValue, + relation); target.SetPropertyValue( this.targetExpression, targetValue); + + this.createConvertHelper.Convert( + sourceValue, + targetValue, + additionalProcessings); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelationInclTargetArg.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelationInclTargetArg.cs index 5a0db366..2900b29c 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelationInclTargetArg.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithRelationInclTargetArg.cs @@ -67,14 +67,18 @@ public void Execute( var relation = this.relationFunc(source, target); - var targetValue = this.createConvertHelper.CreateTarget( + var targetValue = this.createConvertHelper.Create( sourceValue, - relation, - additionalProcessings); + relation); target.SetPropertyValue( this.targetExpression, targetValue); + + this.createConvertHelper.Convert( + sourceValue, + targetValue, + additionalProcessings); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithReverseRelation.cs b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithReverseRelation.cs index 8fecea1d..c6230017 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithReverseRelation.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationCreateToOneWithReverseRelation.cs @@ -60,14 +60,18 @@ public void Execute( return; } - var targetValue = this.createConvertHelper.CreateTarget( - sourceValue, - target, - additionalProcessings); + var targetValue = this.createConvertHelper.Create( + sourceValue, + target); target.SetPropertyValue( this.targetExpression, targetValue); + + this.createConvertHelper.Convert( + sourceValue, + targetValue, + additionalProcessings); } } } diff --git a/src/BBT.StructureTools/Convert/Strategy/OperationMergeLevel.cs b/src/BBT.StructureTools/Convert/Strategy/OperationMergeLevel.cs index 25b2d944..204cb748 100644 --- a/src/BBT.StructureTools/Convert/Strategy/OperationMergeLevel.cs +++ b/src/BBT.StructureTools/Convert/Strategy/OperationMergeLevel.cs @@ -77,8 +77,6 @@ public void Execute( var mergeValues = this.mergeFunc.Invoke(source); - var copies = new List(); - foreach (var mergeValue in mergeValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -89,6 +87,7 @@ public void Execute( var sourceValues = this.sourceFunc.Invoke(mergeValue); + var targetList = target.GetList(this.targetExpression); foreach (var sourceValue in sourceValues) { if (!this.convertHelper.ContinueConvertProcess( @@ -97,17 +96,18 @@ public void Execute( continue; } - var copy = this.createConvertHelper.CreateTarget( + var copy = this.createConvertHelper.Create( sourceValue, - target, + target); + + targetList.AddUnique(copy); + + this.createConvertHelper.Convert( + sourceValue, + copy, additionalProcessings); - copies.Add(copy); } } - - target.AddRangeFilterNullValues( - this.targetExpression, - copies); } } } diff --git a/src/BBT.StructureTools/Extension/ReferenceTypeExtension.cs b/src/BBT.StructureTools/Extension/ReferenceTypeExtension.cs index b400a378..6d3fc9ce 100644 --- a/src/BBT.StructureTools/Extension/ReferenceTypeExtension.cs +++ b/src/BBT.StructureTools/Extension/ReferenceTypeExtension.cs @@ -11,6 +11,45 @@ /// internal static class ReferenceTypeExtension { + /// + /// Adds to . + /// But only if is not already added. + /// + /// Type of list entries. + internal static void AddUnique( + this ICollection targetList, + TValue value) + where TValue : class + { + targetList.NotNull(nameof(targetList)); + value.NotNull(nameof(value)); + + if (!targetList.Contains(value)) + { + targetList.Add(value); + } + } + + /// + /// Gets the list of collection property + /// according to . + /// + /// The owner of the list. + /// The type of list entries. + internal static ICollection GetList( + this TTarget target, + Expression>> targetExpression) + where TTarget : class + where TValue : class + { + target.NotNull(nameof(target)); + targetExpression.NotNull(nameof(targetExpression)); + + var targetListFunc = targetExpression.Compile(); + var targetList = targetListFunc.Invoke(target); + return targetList; + } + /// /// An extension enabling addition of many elements to an enumeration without adding null values within the origin. ///