Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Created July 26, 2016 13:29
Show Gist options
  • Save lbargaoanu/df66fcdcf72853d73b21e44d1a473f33 to your computer and use it in GitHub Desktop.
Save lbargaoanu/df66fcdcf72853d73b21e44d1a473f33 to your computer and use it in GitHub Desktop.
(src, dest, ctxt) =>
{
return (src == null)
? null
: {
var typeMapDestination = dest ?? new DeepTypeMapper.CustomerDTO();
try
{
var resolvedValue = ((false | (src == null)) | (src.Address == null)) ? null : src.Address.City;
typeMapDestination.AddressCity = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.WorkAddresses;
typeMapDestination.WorkAddresses =
{
var passedDestination = (dest == null) ? null : typeMapDestination.WorkAddresses;
var collectionDestination = (passedDestination != null) ? passedDestination : new List<DeepTypeMapper.AddressDTO>();
return (resolvedValue == null)
? collectionDestination
: {
var enumerator = resolvedValue.GetEnumerator();
while (true)
{
if (enumerator.MoveNext())
{
var item = enumerator.Current;
collectionDestination.Add(
(item == null)
? null
: {
var typeMapDestination = null ?? new DeepTypeMapper.AddressDTO();
try
{
var resolvedValue = (false | (item == null)) ? null : item.Country;
typeMapDestination.Country = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (item == null)) ? null : item.City;
typeMapDestination.City = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (item == null)) ? default(int) : item.Id;
typeMapDestination.Id = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
return typeMapDestination;
});
}
else
{
break;
}
}
return collectionDestination;
return }
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.Addresses;
typeMapDestination.Addresses = (resolvedValue == null)
? new DeepTypeMapper.AddressDTO[0]
: {
var count = resolvedValue.Count();
var destinationArray = new DeepTypeMapper.AddressDTO[count];
var destinationArrayIndex = 0;
var sourceArrayIndex = 0;
while (true)
{
if (sourceArrayIndex < resolvedValue.Length)
{
var item = resolvedValue[sourceArrayIndex];
destinationArray[destinationArrayIndex++] =
{
return (item == null)
? null
: {
typeMapDestination = null ?? new DeepTypeMapper.AddressDTO();
try
{
resolvedValue = (false | (item == null)) ? null : item.Country;
typeMapDestination.Country = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
resolvedValue = (false | (item == null)) ? null : item.City;
typeMapDestination.City = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
resolvedValue = (false | (item == null)) ? default(int) : item.Id;
typeMapDestination.Id = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
return typeMapDestination;
}
};
sourceArrayIndex++;
}
else
{
break;
}
}
return destinationArray;
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.HomeAddress;
typeMapDestination.HomeAddress =
{
return (resolvedValue == null)
? null
: {
typeMapDestination = (dest == null) ? null : typeMapDestination.HomeAddress ?? new DeepTypeMapper.AddressDTO();
try
{
resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Country;
typeMapDestination.Country = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.City;
typeMapDestination.City = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
resolvedValue = (false | (resolvedValue == null)) ? default(int) : resolvedValue.Id;
typeMapDestination.Id = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
return typeMapDestination;
}
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.Address;
typeMapDestination.Address =
{
return (resolvedValue == null)
? null
: {
var typeMapDestination = (dest == null) ? null : typeMapDestination.Address ?? new DeepTypeMapper.Address();
try
{
var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Country;
typeMapDestination.Country = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.City;
typeMapDestination.City = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (resolvedValue == null)) ? null : resolvedValue.Street;
typeMapDestination.Street = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (resolvedValue == null)) ? default(int) : resolvedValue.Id;
typeMapDestination.Id = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
return typeMapDestination;
}
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.Name;
typeMapDestination.Name = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? default(int) : src.Id;
typeMapDestination.Id = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
return typeMapDestination;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment