From 5428e904c08cc84bd7ddf424d064a16dee37a055 Mon Sep 17 00:00:00 2001 From: Luciana Regina Lino Date: Mon, 20 Nov 2023 16:43:29 -0300 Subject: [PATCH 1/3] fix: namespaces. --- src/Liquid.Adapter.Dataverse/DataverseAdapter.cs | 3 +-- .../DataverseClientFactory.cs | 3 +-- .../DataverseEntityMapper.cs | 5 ++--- src/Liquid.Adapter.Dataverse/DataverseSettings.cs | 2 +- .../{ => Extensions}/EntityExtensions.cs | 2 +- .../IDataverseClientFactory.cs | 2 +- src/Liquid.Adapter.Dataverse/ILiquidMapper.cs | 11 ++--------- src/Liquid.Adapter.Dataverse/LiquidMapper.cs | 15 ++++++++------- .../DataverseAdapterTests.cs | 3 +-- .../DataverseClientFactoryTests.cs | 1 - 10 files changed, 18 insertions(+), 29 deletions(-) rename src/Liquid.Adapter.Dataverse/{ => Extensions}/EntityExtensions.cs (94%) diff --git a/src/Liquid.Adapter.Dataverse/DataverseAdapter.cs b/src/Liquid.Adapter.Dataverse/DataverseAdapter.cs index 230baa88..b2df77f9 100644 --- a/src/Liquid.Adapter.Dataverse/DataverseAdapter.cs +++ b/src/Liquid.Adapter.Dataverse/DataverseAdapter.cs @@ -1,5 +1,4 @@ -using CustomerRegistration.Infra.Dataverse; -using Microsoft.Crm.Sdk.Messages; +using Microsoft.Crm.Sdk.Messages; using Microsoft.PowerPlatform.Dataverse.Client; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Messages; diff --git a/src/Liquid.Adapter.Dataverse/DataverseClientFactory.cs b/src/Liquid.Adapter.Dataverse/DataverseClientFactory.cs index 4fdbfed7..7e97dac2 100644 --- a/src/Liquid.Adapter.Dataverse/DataverseClientFactory.cs +++ b/src/Liquid.Adapter.Dataverse/DataverseClientFactory.cs @@ -1,5 +1,4 @@ -using CustomerRegistration.Infra.Dataverse; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options; using Microsoft.PowerPlatform.Dataverse.Client; using System.Diagnostics.CodeAnalysis; diff --git a/src/Liquid.Adapter.Dataverse/DataverseEntityMapper.cs b/src/Liquid.Adapter.Dataverse/DataverseEntityMapper.cs index 042a74b9..ee70548c 100644 --- a/src/Liquid.Adapter.Dataverse/DataverseEntityMapper.cs +++ b/src/Liquid.Adapter.Dataverse/DataverseEntityMapper.cs @@ -1,11 +1,10 @@ -using Liquid.Adapter.Dataverse; -using Microsoft.Xrm.Sdk; +using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Metadata; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Diagnostics.CodeAnalysis; -namespace CustomerRegistration.Infra.Dataverse +namespace Liquid.Adapter.Dataverse { /// /// Implementation of that diff --git a/src/Liquid.Adapter.Dataverse/DataverseSettings.cs b/src/Liquid.Adapter.Dataverse/DataverseSettings.cs index cc514506..04444d1a 100644 --- a/src/Liquid.Adapter.Dataverse/DataverseSettings.cs +++ b/src/Liquid.Adapter.Dataverse/DataverseSettings.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace CustomerRegistration.Infra.Dataverse +namespace Liquid.Adapter.Dataverse { /// /// Set of dataverse connection configs. diff --git a/src/Liquid.Adapter.Dataverse/EntityExtensions.cs b/src/Liquid.Adapter.Dataverse/Extensions/EntityExtensions.cs similarity index 94% rename from src/Liquid.Adapter.Dataverse/EntityExtensions.cs rename to src/Liquid.Adapter.Dataverse/Extensions/EntityExtensions.cs index f402d78f..7180c26f 100644 --- a/src/Liquid.Adapter.Dataverse/EntityExtensions.cs +++ b/src/Liquid.Adapter.Dataverse/Extensions/EntityExtensions.cs @@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json; -namespace CustomerRegistration.Infra.Dataverse +namespace Liquid.Adapter.Dataverse.Extensions { /// /// Extension methods of . diff --git a/src/Liquid.Adapter.Dataverse/IDataverseClientFactory.cs b/src/Liquid.Adapter.Dataverse/IDataverseClientFactory.cs index 59c41207..fb054afb 100644 --- a/src/Liquid.Adapter.Dataverse/IDataverseClientFactory.cs +++ b/src/Liquid.Adapter.Dataverse/IDataverseClientFactory.cs @@ -1,6 +1,6 @@ using Microsoft.PowerPlatform.Dataverse.Client; -namespace CustomerRegistration.Infra.Dataverse +namespace Liquid.Adapter.Dataverse { /// /// Defines Dataverse provider. diff --git a/src/Liquid.Adapter.Dataverse/ILiquidMapper.cs b/src/Liquid.Adapter.Dataverse/ILiquidMapper.cs index e9ac4be3..c9a7e866 100644 --- a/src/Liquid.Adapter.Dataverse/ILiquidMapper.cs +++ b/src/Liquid.Adapter.Dataverse/ILiquidMapper.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Liquid.Adapter.Dataverse +namespace Liquid.Adapter.Dataverse { /// /// Defines object that map data between two instance types. /// /// type of data source object. /// results object type. - public interface ILiquidMapper + public interface ILiquidMapper { /// /// Create a new instance of diff --git a/src/Liquid.Adapter.Dataverse/LiquidMapper.cs b/src/Liquid.Adapter.Dataverse/LiquidMapper.cs index 92e63f2e..14fb5727 100644 --- a/src/Liquid.Adapter.Dataverse/LiquidMapper.cs +++ b/src/Liquid.Adapter.Dataverse/LiquidMapper.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; namespace Liquid.Adapter.Dataverse { @@ -21,6 +16,7 @@ public LiquidMapper(string mapperName) { _mapperName = mapperName; } + /// public async Task Map(TFrom dataObject, string? entityName = null) { if (dataObject is null) @@ -39,7 +35,12 @@ public async Task Map(TFrom dataObject, string? entityName = null) throw new DataMappingException(msg, e); } } - + /// + /// + /// + /// + /// + /// protected abstract Task MapImpl(TFrom dataObject, string? entityName = null); } } diff --git a/test/Liquid.Adapter.Dataverse.Tests/DataverseAdapterTests.cs b/test/Liquid.Adapter.Dataverse.Tests/DataverseAdapterTests.cs index 6250deb1..daff8370 100644 --- a/test/Liquid.Adapter.Dataverse.Tests/DataverseAdapterTests.cs +++ b/test/Liquid.Adapter.Dataverse.Tests/DataverseAdapterTests.cs @@ -1,5 +1,4 @@ -using CustomerRegistration.Infra.Dataverse; -using Microsoft.Crm.Sdk.Messages; +using Microsoft.Crm.Sdk.Messages; using Microsoft.PowerPlatform.Dataverse.Client; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Messages; diff --git a/test/Liquid.Adapter.Dataverse.Tests/DataverseClientFactoryTests.cs b/test/Liquid.Adapter.Dataverse.Tests/DataverseClientFactoryTests.cs index 181ca7a0..80cc6345 100644 --- a/test/Liquid.Adapter.Dataverse.Tests/DataverseClientFactoryTests.cs +++ b/test/Liquid.Adapter.Dataverse.Tests/DataverseClientFactoryTests.cs @@ -1,4 +1,3 @@ -using CustomerRegistration.Infra.Dataverse; using Microsoft.Extensions.Options; using Microsoft.PowerPlatform.Dataverse.Client; using NSubstitute; From 28230079bb437518e785b0cc6fa639f6c34885a6 Mon Sep 17 00:00:00 2001 From: Luciana Regina Lino Date: Mon, 20 Nov 2023 16:57:45 -0300 Subject: [PATCH 2/3] feat(IServiceCollectionExtensions): creates dependency injection method for Dataverse Adapter services. --- .../IServiceCollectionExtensions.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/Liquid.Adapter.Dataverse/Extensions/DependencyInjection/IServiceCollectionExtensions.cs diff --git a/src/Liquid.Adapter.Dataverse/Extensions/DependencyInjection/IServiceCollectionExtensions.cs b/src/Liquid.Adapter.Dataverse/Extensions/DependencyInjection/IServiceCollectionExtensions.cs new file mode 100644 index 00000000..34730a67 --- /dev/null +++ b/src/Liquid.Adapter.Dataverse/Extensions/DependencyInjection/IServiceCollectionExtensions.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Xrm.Sdk; +using System.Diagnostics.CodeAnalysis; + +namespace Liquid.Adapter.Dataverse.Extensions.DependencyInjection +{ + /// + /// Extension methods of + /// + [ExcludeFromCodeCoverage] + public static class IServiceCollectionExtensions + { + /// + /// Registers service, it's dependency + /// , and also set configuration + /// option . + /// Also register service. + /// + /// + /// configuration section of dataverse settings. + public static IServiceCollection AddLiquidDataverseAdapter(this IServiceCollection services, string dataverseSection) + { + services.AddOptions() + .Configure((settings, configuration) => + { + configuration.GetSection(dataverseSection).Bind(settings); + }); + + services.AddTransient(); + + services.AddSingleton(); + + services.AddSingleton, DataverseEntityMapper>(); + + return services; + } + } +} From bf4ff5a989d95a18d5c909f7b6bf789b9be1a789 Mon Sep 17 00:00:00 2001 From: Luciana Regina Lino Date: Mon, 20 Nov 2023 16:58:55 -0300 Subject: [PATCH 3/3] increment package version. --- src/Liquid.Adapter.Dataverse/Liquid.Adapter.Dataverse.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Liquid.Adapter.Dataverse/Liquid.Adapter.Dataverse.csproj b/src/Liquid.Adapter.Dataverse/Liquid.Adapter.Dataverse.csproj index c4b1f7d1..233be4f0 100644 --- a/src/Liquid.Adapter.Dataverse/Liquid.Adapter.Dataverse.csproj +++ b/src/Liquid.Adapter.Dataverse/Liquid.Adapter.Dataverse.csproj @@ -8,7 +8,7 @@ Avanade Inc. Liquid - Modern Application Framework Avanade 2019 - 6.0.0-preview-20221201-01 + 6.0.0-preview-20221201-02 true true Adapter for Microsoft Dataverse integrations.