예제 #1
0
    public MapperEmit <TSrc, TDest> Match(string nameFrom, string nameDest)
    {
        PropertyInfo pSrc  = klassSrc.GetProperty(nameFrom);
        PropertyInfo pDest = klassDest.GetProperty(nameDest);

        if (pSrc.PropertyType == pDest.PropertyType)
        {
            props.Add(nameDest, MappingPropsBuidler.CreateMappingProps(pSrc, pDest));
        }
        else if (!pSrc.PropertyType.IsPrimitive && !pDest.PropertyType.IsPrimitive)
        {
            props.Add(nameDest, new MappingEntities(pSrc, pDest));
        }
        return(this);
    }
예제 #2
0
    private readonly Dictionary <String, IMapping> props; // key: dest Prop and Value: src Prop

    public MapperEmit()
    {
        this.klassSrc  = typeof(TSrc);
        this.klassDest = typeof(TDest);
        this.props     = new Dictionary <String, IMapping>();

        foreach (PropertyInfo p in klassDest.GetProperties())
        {
            PropertyInfo pSrc = klassSrc.GetProperty(p.Name);
            if (pSrc != null && pSrc.PropertyType == p.PropertyType)
            {
                props.Add(p.Name, MappingPropsBuidler.CreateMappingProps(pSrc, p));
            }
        }
    }