本文整理汇总了C#中TypeMapper.Forward方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMapper.Forward方法的具体用法?C# TypeMapper.Forward怎么用?C# TypeMapper.Forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeMapper
的用法示例。
在下文中一共展示了TypeMapper.Forward方法的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);
}
示例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)));
}
示例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());
}