Skip to content

Commit

Permalink
Merge pull request #185 from Avanade/feature/updateTargetFramework
Browse files Browse the repository at this point in the history
Feature/update target framework
  • Loading branch information
lucianareginalino authored Nov 20, 2023
2 parents db029e2 + bf4ff5a commit aa8ace5
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/Liquid.Adapter.Dataverse/DataverseAdapter.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Liquid.Adapter.Dataverse/DataverseClientFactory.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
5 changes: 2 additions & 3 deletions src/Liquid.Adapter.Dataverse/DataverseEntityMapper.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Implementation of <see cref="LiquidMapper{TFrom, TTo}"/> that
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Adapter.Dataverse/DataverseSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;

namespace CustomerRegistration.Infra.Dataverse
namespace Liquid.Adapter.Dataverse
{
/// <summary>
/// Set of dataverse connection configs.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Extension methods of <see cref="IServiceCollection"/>
/// </summary>
[ExcludeFromCodeCoverage]
public static class IServiceCollectionExtensions
{
/// <summary>
/// Registers <see cref="DataverseAdapter"/> service, it's dependency
/// <see cref="DataverseClientFactory"/>, and also set configuration
/// option <see cref="DataverseSettings"/>.
/// Also register <see cref="DataverseEntityMapper"/> service.
/// </summary>
/// <param name="services"></param>
/// <param name="dataverseSection">configuration section of dataverse settings.</param>
public static IServiceCollection AddLiquidDataverseAdapter(this IServiceCollection services, string dataverseSection)
{
services.AddOptions<DataverseSettings>()
.Configure<IConfiguration>((settings, configuration) =>
{
configuration.GetSection(dataverseSection).Bind(settings);
});

services.AddTransient<IDataverseClientFactory, DataverseClientFactory>();

services.AddSingleton<ILiquidDataverseAdapter, DataverseAdapter>();

services.AddSingleton<ILiquidMapper<string, Entity>, DataverseEntityMapper>();

return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;

namespace CustomerRegistration.Infra.Dataverse
namespace Liquid.Adapter.Dataverse.Extensions
{
/// <summary>
/// Extension methods of <see cref="Entity"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Adapter.Dataverse/IDataverseClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.PowerPlatform.Dataverse.Client;

namespace CustomerRegistration.Infra.Dataverse
namespace Liquid.Adapter.Dataverse
{
/// <summary>
/// Defines Dataverse <see cref="ServiceClient"/> provider.
Expand Down
11 changes: 2 additions & 9 deletions src/Liquid.Adapter.Dataverse/ILiquidMapper.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Defines object that map data between two instance types.
/// </summary>
/// <typeparam name="TFrom">type of data source object.</typeparam>
/// <typeparam name="TTo">results object type.</typeparam>
public interface ILiquidMapper<TFrom,TTo>
public interface ILiquidMapper<TFrom, TTo>
{
/// <summary>
/// Create a new instance of <see cref="TTo"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Company>Avanade Inc.</Company>
<Product>Liquid - Modern Application Framework</Product>
<Copyright>Avanade 2019</Copyright>
<Version>6.0.0-preview-20221201-01</Version>
<Version>6.0.0-preview-20221201-02</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<Description>Adapter for Microsoft Dataverse integrations.
Expand Down
15 changes: 8 additions & 7 deletions src/Liquid.Adapter.Dataverse/LiquidMapper.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -21,6 +16,7 @@ public LiquidMapper(string mapperName)
{
_mapperName = mapperName;
}
///<inheritdoc/>
public async Task<TTo> Map(TFrom dataObject, string? entityName = null)
{
if (dataObject is null)
Expand All @@ -39,7 +35,12 @@ public async Task<TTo> Map(TFrom dataObject, string? entityName = null)
throw new DataMappingException(msg, e);
}
}

/// <summary>
///
/// </summary>
/// <param name="dataObject"></param>
/// <param name="entityName"></param>
/// <returns></returns>
protected abstract Task<TTo> MapImpl(TFrom dataObject, string? entityName = null);
}
}
3 changes: 1 addition & 2 deletions test/Liquid.Adapter.Dataverse.Tests/DataverseAdapterTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using CustomerRegistration.Infra.Dataverse;
using Microsoft.Extensions.Options;
using Microsoft.PowerPlatform.Dataverse.Client;
using NSubstitute;
Expand Down

0 comments on commit aa8ace5

Please sign in to comment.