摘要: 上篇介绍了OO Mapper 最核心的映射,简单类型映射,这篇将介绍的复合类型的映射。 1. Dictionary - > Dictionary 字典类型分为:IDictionary,IDictioanry<TKey,TValue> public class SourceValue { public int Value { get; set; } } public class DestValue { public int Value { get; set; } } [Test] public void Example() { var sourceDict = new Dict 阅读全文
posted @ 2011-04-08 15:53 风云 阅读(3236) 评论(11) 推荐(3) 编辑
摘要: 上一篇介绍了OO Mapper的作用以及支持的功能。这一篇将以上一篇为提纲进行实践。 准备工作:下载NLite编译NLite 项目创建一个NUnit单元测试项目添加NLite.dll 引用添加 : using NLite; 实践: 1. Any -> StringAssert.AreEqual("5", Mapper.Map<int, string>(5)); 2. primitive->Enum,Enum->primitive [TestFixture] public class EnumTests { public enum En1 : b 阅读全文
posted @ 2011-04-08 12:50 风云 阅读(4213) 评论(6) 推荐(6) 编辑
摘要: 昨天看了dudu 老大的文章博客园现代化建设——AutoMapper有感便推荐一下OOMapper 组件,诚然OOMapper 组件是站在巨人的肩膀上,如AutoMapper,EmitMapper,以及Codeplex上所有类似组件上都做了借鉴,也重新发明了轮子,但是在发明轮子的过程中个人的积累也在提升。 OO Mapper 是NLite组件库中的一个组件,它是一个对象到对象转换的映射工具,常常用于把复杂的对象转化为DTO对象。 OO Mapper 支持以下映射功能: Any -> String Primitive -> Enum Enum -> Primitive Null 阅读全文
posted @ 2011-04-08 11:45 风云 阅读(7053) 评论(20) 推荐(3) 编辑