diff --git a/SolidMapper/SolidMapper/DITools.cs b/SolidMapper/SolidMapper/DITools.cs index 35fc7ff..cd34258 100644 --- a/SolidMapper/SolidMapper/DITools.cs +++ b/SolidMapper/SolidMapper/DITools.cs @@ -3,23 +3,22 @@ using System.Linq; using System.Reflection; -namespace SolidMapper +namespace SolidMapper; + +public static class IServiceCollectionExtensions { - public static class IServiceCollectionExtensions + public static void AddSolidMapper(this IServiceCollection services, Assembly assembly) { - public static void AddSolidMapper(this IServiceCollection services, Assembly assembly) - { - AddSolidMapper(services, new Assembly[] { assembly }); - } + AddSolidMapper(services, new Assembly[] { assembly }); + } - public static void AddSolidMapper(this IServiceCollection services, Assembly[] assemblies) - { - var mappers = assemblies.SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Any(i => i.Namespace == "SolidMapper"))).ToList(); + public static void AddSolidMapper(this IServiceCollection services, Assembly[] assemblies) + { + var mappers = assemblies.SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Any(i => i.Namespace == "SolidMapper"))).ToList(); - foreach (var mapper in mappers) - { - services.AddScoped(Type.GetType(mapper.AssemblyQualifiedName)); - } + foreach (var mapper in mappers) + { + services.AddScoped(Type.GetType(mapper.AssemblyQualifiedName!)); } } } \ No newline at end of file diff --git a/SolidMapper/SolidMapper/IMapper.cs b/SolidMapper/SolidMapper/IMapper.cs index 5cdc6e2..ff0bd31 100644 --- a/SolidMapper/SolidMapper/IMapper.cs +++ b/SolidMapper/SolidMapper/IMapper.cs @@ -1,13 +1,12 @@ -namespace SolidMapper +namespace SolidMapper; + +public interface IMapper { - public interface IMapper - { - TEntity Map(TDTO source); + TEntity Map(TDTO source); - TDTO Map(TEntity source); + TDTO Map(TEntity source); - void Map(TEntity source, TDTO target); + void Map(TEntity source, TDTO target); - void Map(TDTO source, TEntity target); - } + void Map(TDTO source, TEntity target); } \ No newline at end of file diff --git a/SolidMapper/SolidMapper/SolidMapper.csproj b/SolidMapper/SolidMapper/SolidMapper.csproj index f57d719..9e71f8c 100644 --- a/SolidMapper/SolidMapper/SolidMapper.csproj +++ b/SolidMapper/SolidMapper/SolidMapper.csproj @@ -1,11 +1,12 @@  - net6.0 + net8.0 + enable - +