|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GenericTypeMapper
{
public class ConcreteMappingProvider : IMappingProvider
{
public T Map<T>(IMappable input)
{
// TypeB cannot be cast directly from TypeA
// but it can be cast from object.
object result = map(input as TypeA);
return (T)result;
}
private TypeB map(TypeA input)
{
TypeB result = new TypeB();
result.StringX = input.StringA;
result.intY = input.IntB;
result.StringZ = input.GuidC.ToString();
return result;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.