I am writing a simple mapper class to clone and copy properties between different objects of different/same types.
Mapping is performed via reflection and works just fine for value types, lists and reference types.
Everything works for types like this one:
class SimpleValueTypes
{
public string Name { get; set; }
public int Number { get; set; }
public long LongNumber { get; set; }
public float FloatNumber { get; set; }
public bool BooleanValue { get; set; }
public AnotherType AnotherProperty{ get; set; }
}
where AnotherType is a class type. Mapping of reference types is performed by inspecting the properties recursively until all the properties are mapped to the destination pretty much this way:
object value = mapFrom.GetValue(input, null);
mapTo.SetValue(output, value, null);
where mapForm and mapTo are PropertyInfo objects.
Problems began when a new type with a "Bitmap" property arrived and I realised a whole class of objects cannot be treated the same way.
Class NewType
{
public Bitmap Bitmap{get;set;}
public string Name{get;set;}
}
What would you reccomend to do for cases like these? Obviously copying the properties would not lead to a new copy of the original Bitmap object.
PS
I can't use automapper/emit mapper or any other external packages.