public static T Snapshoot<T>(this XtraForm form, T obj) { var config = new DefaultMapConfig(); config.SetConfigName("AllField"); var map = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper<T, T>(config); var config2 = map.MapperImpl.MappingConfigurator as DefaultMapConfig; return map.Map(obj); } public static T Restore<T>(this XtraForm form, T src, T tag) { var config = new DefaultMapConfig().IgnoreMembers<T, T>(new string[] { "EntityKey", "EntityState" }); config.SetConfigName("NoEntityKey"); var map = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper<T, T>(config); var config2 = map.MapperImpl.MappingConfigurator as DefaultMapConfig; return map.Map(src,tag); }
如果不指定config名称,那么后一次调用不会覆盖前一次调用的config设置
时间: 2024-10-02 09:36:56