Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Created July 26, 2016 13:27
Show Gist options
  • Save lbargaoanu/a5f7e193c17b712e7d0094df419ac82e to your computer and use it in GitHub Desktop.
Save lbargaoanu/a5f7e193c17b712e7d0094df419ac82e to your computer and use it in GitHub Desktop.
(src, dest, ctxt) =>
{
return (src == null)
? null
: {
var typeMapDestination = dest ?? new ComplexTypeMapper.Foo();
try
{
var resolvedValue = (false | (src == null)) ? null : src.Ints;
typeMapDestination.Ints = (resolvedValue == null)
? new int[0]
: {
var sourceLength = resolvedValue.Length;
var destArray = new int[sourceLength];
Array.Copy(resolvedValue, destArray, sourceLength);
return destArray;
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.IntArr;
typeMapDestination.IntArr = (resolvedValue == null)
? new int[0]
: {
var sourceLength = resolvedValue.Length;
var destArray = new int[sourceLength];
Array.Copy(resolvedValue, destArray, sourceLength);
return destArray;
};
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? null : src.FooArr;
typeMapDestination.FooArr = (resolvedValue == null)
? new ComplexTypeMapper.Foo[0]
: {
var count = resolvedValue.Count();
var destinationArray = new ComplexTypeMapper.Foo[count];
var destinationArrayIndex = 0;
var sourceArrayIndex = 0;
while (true)
{
if (sourceArrayIndex < resolvedValue.Length)
{
var item = resolvedValue[sourceArrayIndex];
destinationArray[destinationArrayIndex++] = ctxt.Map(item, null);
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.Foos;
typeMapDestination.Foos =
{
var passedDestination = (dest == null) ? null : typeMapDestination.Foos;
var collectionDestination = (passedDestination != null) ? passedDestination : new List<ComplexTypeMapper.Foo>();
return (resolvedValue == null)
? collectionDestination
: {
var enumerator = resolvedValue.GetEnumerator();
while (true)
{
if (enumerator.MoveNext())
{
var item = enumerator.Current;
collectionDestination.Add(ctxt.Map(item, null));
}
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.Foo1;
typeMapDestination.Foo1 = ctxt.Map(resolvedValue, (dest == null) ? null : typeMapDestination.Foo1);
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? default(DateTime) : src.DateTime;
typeMapDestination.DateTime = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? default(double) : src.Doublen;
typeMapDestination.Doublen = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? default(float) : src.Floatn;
typeMapDestination.Floatn = 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.NullInt;
typeMapDestination.NullInt = resolvedValue;
}
catch (Exception ex)
{
throw new AutoMapperMappingException("Error mapping types.", ex, AutoMapper.TypePair, AutoMapper.TypeMap, AutoMapper.PropertyMap);
}
try
{
var resolvedValue = (false | (src == null)) ? default(long) : src.Int64;
typeMapDestination.Int64 = 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.Int32;
typeMapDestination.Int32 = 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.Name;
typeMapDestination.Name = 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