Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using AutoMapper;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- namespace Core.Configuration
- {
- public class AutomapperProfileConfiguration : Profile
- {
- private readonly IConfiguration Configuration;
- public AutomapperProfileConfiguration(IConfiguration configuration)
- {
- this.Configuration = configuration;
- var pecAckTimeoutIntervalHours = Convert.ToInt32(Configuration["AppSettings:PecAckTimeoutIntervalHours"]);
- CreateMap<Sessions, Session>().ForMember(
- dest => dest.Invalidated,
- opt => opt.MapFrom(src => src.InvalidationTime));
- CreateMap<DataBuckets, DataBucket<JObject>>().ForMember(
- dest => dest.Kind,
- opt => opt.MapFrom(src => src.Kind.Name))
- .ForMember(
- dest => dest.Data,
- opt => opt.MapFrom(src => JsonConvert.DeserializeObject<JObject>(src.Data)));
- CreateMap<Files, FileInfo>().ForMember(
- dest => dest.ContentType,
- opt => opt.MapFrom(src => src.MimeType))
- .ForMember(
- dest => dest.Hash,
- opt => opt.MapFrom(src => Convert.ToBase64String(src.Hash)))
- .ForMember(
- dest => dest.Kind,
- opt => opt.MapFrom(src => ((FileKind) src.KindId).GetDescription()));
- }
- }
- }
Add Comment
Please, Sign In to add comment