Beispiel #1
0
        public BLLAppDTO.Person MapPersonDisplay(DALAppDTO.PersonDisplay inObject)
        {
            //return Mapper.Map<BLLAppDTO.Person>(inObject);
            var inProperties = inObject
                               .GetType()
                               .GetProperties()
                               .ToDictionary(
                key => key.Name,
                val => val.GetValue(inObject));

            var result = new BLLAppDTO.Person();

            foreach (var property in result.GetType().GetProperties())
            {
                if (inProperties.TryGetValue(property.Name, out var value))
                {
                    if (property.PropertyType.IsEnum)
                    {
                        BLLAppDTO.PersonType pt = (BLLAppDTO.PersonType)Enum.Parse(typeof(BLLAppDTO.PersonType), (string)value !, true);
                        property.SetValue(result, pt);
                        continue;
                    }
                    if (value != null)
                    {
                        property.SetValue(result, value);
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        public BLLAppDTO.PersonDisplay MapPersonDisplayToPersonDisplay(DALAppDTO.PersonDisplay inObject)
        {
            return(Mapper.Map <BLLAppDTO.PersonDisplay>(inObject));


            //MapperConfigurationExpression.CreateMap<BLLAppDTO.PersonDisplay, DALAppDTO.PersonDisplay>();
        }