当前位置: 首页>>代码示例>>C#>>正文


C# TypeMapper.Reverse方法代码示例

本文整理汇总了C#中TypeMapper.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMapper.Reverse方法的具体用法?C# TypeMapper.Reverse怎么用?C# TypeMapper.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeMapper的用法示例。


在下文中一共展示了TypeMapper.Reverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DestinationCollectionHasSameNumberOfItemsAsSource

        public void DestinationCollectionHasSameNumberOfItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.AreEqual(t1.IntCollection.Count, t2.IntCollection.Count);
            Assert.AreEqual(t1.IntCollection.Count, t1.IntCollection.Count);
        }
开发者ID:vermie,项目名称:AnyMapper,代码行数:17,代码来源:CollectionMapperTests.cs

示例2: ConvertedPrimitiveDestinationCollectionHasEquivalentItemsAsSource

        public void ConvertedPrimitiveDestinationCollectionHasEquivalentItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, long> collectionMapper =
                new CollectionMapper<T1, int, T2, long>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.LongCollection, () => new List<long>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsTrue(t1.IntCollection.All(i => t2.LongCollection.Any(l => i == l)));
            Assert.IsTrue(t2.LongCollection.All(i => t3.IntCollection.Any(l => i == l)));
        }
开发者ID:vermie,项目名称:AnyMapper,代码行数:17,代码来源:CollectionMapperTests.cs

示例3: PrimitiveDestinationCollectionHasSameItemsAsSource

        public void PrimitiveDestinationCollectionHasSameItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsFalse(t1.IntCollection.Except(t2.IntCollection).Any());
            Assert.IsFalse(t2.IntCollection.Except(t3.IntCollection).Any());
        }
开发者ID:vermie,项目名称:AnyMapper,代码行数:17,代码来源:CollectionMapperTests.cs


注:本文中的TypeMapper.Reverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。