|
12 | 12 | // <author>Miriam Kyoseva</author> |
13 | 13 | // <site>https://bellatrix.solutions/</site> |
14 | 14 |
|
15 | | -using AutoMapper; |
| 15 | +using Mapster; |
16 | 16 |
|
17 | 17 | namespace Bellatrix.Playwright.SyncPlaywright; |
18 | 18 |
|
19 | 19 | internal static class MapperService |
20 | 20 | { |
21 | | - private static MapperConfiguration Config; |
22 | | - private static IMapper Mapper; |
| 21 | + private static readonly TypeAdapterConfig Config; |
23 | 22 |
|
24 | 23 | static MapperService() |
25 | 24 | { |
26 | | - Config = new MapperConfiguration(cfg => |
27 | | - { |
28 | | - cfg.CreateMap<GetByAltTextOptions, LocatorGetByAltTextOptions>(); |
29 | | - cfg.CreateMap<GetByAltTextOptions, FrameLocatorGetByAltTextOptions>(); |
30 | | - cfg.CreateMap<GetByAltTextOptions, PageGetByAltTextOptions>(); |
31 | | - |
32 | | - cfg.CreateMap<GetByLabelOptions, LocatorGetByLabelOptions>(); |
33 | | - cfg.CreateMap<GetByLabelOptions, FrameLocatorGetByLabelOptions>(); |
34 | | - cfg.CreateMap<GetByLabelOptions, PageGetByLabelOptions>(); |
35 | | - |
36 | | - cfg.CreateMap<GetByPlaceholderOptions, LocatorGetByPlaceholderOptions>(); |
37 | | - cfg.CreateMap<GetByPlaceholderOptions, FrameLocatorGetByPlaceholderOptions>(); |
38 | | - cfg.CreateMap<GetByPlaceholderOptions, PageGetByPlaceholderOptions>(); |
39 | | - |
40 | | - cfg.CreateMap<GetByRoleOptions, LocatorGetByRoleOptions>(); |
41 | | - cfg.CreateMap<GetByRoleOptions, FrameLocatorGetByRoleOptions>(); |
42 | | - cfg.CreateMap<GetByRoleOptions, PageGetByRoleOptions>(); |
43 | | - |
44 | | - cfg.CreateMap<GetByTextOptions, LocatorGetByTextOptions>(); |
45 | | - cfg.CreateMap<GetByTextOptions, FrameLocatorGetByTextOptions>(); |
46 | | - cfg.CreateMap<GetByTextOptions, PageGetByTextOptions>(); |
47 | | - |
48 | | - cfg.CreateMap<GetByTitleOptions, LocatorGetByTitleOptions>(); |
49 | | - cfg.CreateMap<GetByTitleOptions, FrameLocatorGetByTitleOptions>(); |
50 | | - cfg.CreateMap<GetByTitleOptions, PageGetByTitleOptions>(); |
51 | | - }, null); |
52 | | - |
53 | | - Mapper = Config.CreateMapper(); |
| 25 | + Config = new TypeAdapterConfig(); |
| 26 | + |
| 27 | + Config.NewConfig<GetByAltTextOptions, LocatorGetByAltTextOptions>(); |
| 28 | + Config.NewConfig<GetByAltTextOptions, FrameLocatorGetByAltTextOptions>(); |
| 29 | + Config.NewConfig<GetByAltTextOptions, PageGetByAltTextOptions>(); |
| 30 | + |
| 31 | + Config.NewConfig<GetByLabelOptions, LocatorGetByLabelOptions>(); |
| 32 | + Config.NewConfig<GetByLabelOptions, FrameLocatorGetByLabelOptions>(); |
| 33 | + Config.NewConfig<GetByLabelOptions, PageGetByLabelOptions>(); |
| 34 | + |
| 35 | + Config.NewConfig<GetByPlaceholderOptions, LocatorGetByPlaceholderOptions>(); |
| 36 | + Config.NewConfig<GetByPlaceholderOptions, FrameLocatorGetByPlaceholderOptions>(); |
| 37 | + Config.NewConfig<GetByPlaceholderOptions, PageGetByPlaceholderOptions>(); |
| 38 | + |
| 39 | + Config.NewConfig<GetByRoleOptions, LocatorGetByRoleOptions>(); |
| 40 | + Config.NewConfig<GetByRoleOptions, FrameLocatorGetByRoleOptions>(); |
| 41 | + Config.NewConfig<GetByRoleOptions, PageGetByRoleOptions>(); |
| 42 | + |
| 43 | + Config.NewConfig<GetByTextOptions, LocatorGetByTextOptions>(); |
| 44 | + Config.NewConfig<GetByTextOptions, FrameLocatorGetByTextOptions>(); |
| 45 | + Config.NewConfig<GetByTextOptions, PageGetByTextOptions>(); |
| 46 | + |
| 47 | + Config.NewConfig<GetByTitleOptions, LocatorGetByTitleOptions>(); |
| 48 | + Config.NewConfig<GetByTitleOptions, FrameLocatorGetByTitleOptions>(); |
| 49 | + Config.NewConfig<GetByTitleOptions, PageGetByTitleOptions>(); |
54 | 50 | } |
55 | 51 |
|
56 | 52 | public static T ConvertTo<T>(this IOptions options) |
57 | 53 | { |
58 | | - return Mapper.Map<T>(options); |
| 54 | + return options.Adapt<T>(Config); |
59 | 55 | } |
60 | 56 | } |
0 commit comments