using AutoMapper;
using GxPress.Common.Tools;
using GxPress.Entity;
using GxPress.Entity.WorkProcess;
using GxPress.Entity.WorkProcessDto;
using GxPress.Result.Process;

namespace GxPress.Mappings
{
    /// <summary>
    /// 流程相关的映射
    /// </summary>
    public class ProcessMapping : Profile
    {
        public ProcessMapping()
        {
            CreateMap<ProcessDto, Process>();
            CreateMap<Process, ProcessDto>();
            CreateMap<Process, ProcessBaseInfoResult>();
            CreateMap<ProcessField, ProcessFormSettingResult>().AfterMap<ToProcessFormSettingResultAction>();
        }

        private class ToProcessFormSettingResultAction : IMappingAction<ProcessField, ProcessFormSettingResult>
        {
            public void Process(ProcessField source, ProcessFormSettingResult destination, ResolutionContext context)
            {
                destination.Options = StringUtils.StringCollectionToStringList(source.Options);
            }
        }
    }
}