-
Notifications
You must be signed in to change notification settings - Fork 11
/
AutoMapperConfig.cs
29 lines (23 loc) · 900 Bytes
/
AutoMapperConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using AutoMapper;
using System;
using System.Web.Http;
namespace ReferenceProject
{
public class AutoMapperConfig
{
protected internal static IMapper Mapper;
static Func<Type, object> GetResolver(HttpConfiguration config) => type => config.DependencyResolver.GetService(type);
public static IMapper Configure(HttpConfiguration config)
{
Action<IMapperConfigurationExpression> mapperConfigurationExp = cfg =>
{
cfg.ConstructServicesUsing(GetResolver(config));
// TODO: Create mappings here
// For more information see https://github.com/drwatson1/AspNet-WebApi/wiki#automapper
};
var mapperConfiguration = new MapperConfiguration(mapperConfigurationExp);
Mapper = mapperConfiguration.CreateMapper();
return Mapper;
}
}
}