mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
The move!
This commit is contained in:
parent
1daf480b1b
commit
25526cc4d9
1147 changed files with 85 additions and 8524 deletions
35
src/Ombi.Mapping/AutoMapperProfile.cs
Normal file
35
src/Ombi.Mapping/AutoMapperProfile.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AutoMapper;
|
||||
using AutoMapper.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Ombi.Mapping
|
||||
{
|
||||
public static class AutoMapperProfile
|
||||
{
|
||||
public static IServiceCollection AddOmbiMappingProfile(this IServiceCollection services)
|
||||
{
|
||||
System.Reflection.Assembly ass = typeof(AutoMapperProfile).GetTypeInfo().Assembly;
|
||||
var assemblies = new List<Type>();
|
||||
foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
||||
{
|
||||
if (ti.ImplementedInterfaces.Contains(typeof(IProfileConfiguration)))
|
||||
{
|
||||
assemblies.Add(ti.AsType());
|
||||
}
|
||||
}
|
||||
var config = new AutoMapper.MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.AddProfiles(assemblies);
|
||||
});
|
||||
|
||||
var mapper = config.CreateMapper();
|
||||
services.AddSingleton(mapper);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue