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


C# TypeMapper.Map方法代码示例

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


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

示例1: CanMapSimpleNullableTypes

        public void CanMapSimpleNullableTypes(Type type, string expectedParamType, string expectedFormat = "")
        {
            var mapper = new TypeMapper();
            var inputParam = new InputParameter { Type = type };
            var param = mapper.Map(inputParam);

            Assert.AreEqual(expectedParamType, param.type);
            Assert.AreEqual(expectedFormat, param.format);

            Assert.IsEmpty(mapper.Models);
        }
开发者ID:huoxudong125,项目名称:OpenRastaSwagger,代码行数:11,代码来源:TypeMapperFixture.cs

示例2: Bug002__MapToInterfaceProperty_WhereTargetInterfaceIsDifferentThanSourceType

        public void Bug002__MapToInterfaceProperty_WhereTargetInterfaceIsDifferentThanSourceType()
        {
            var c1 = new Bug002_Class_One();
            c1.Id = 1;
            c1.Property = new Bug002_Class_One();
            c1.Property.Id = 2;

            var tm = new TypeMapper();

            var clone = tm.Map<Bug002_Class_Two>(c1);

            Assert.IsNotNull(clone);
            Assert.AreEqual(clone.Id, c1.Id);
            Assert.AreEqual(clone.Property.Id, c1.Property.Id);
            Assert.IsNull(clone.Property.Property);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:16,代码来源:TypeMapper._BugFixes.cs

示例3: SetUp

        public void SetUp()
        {
            _mapper = new TypeMapper();

            _mapper.Map<IList, ArrayList>();
            //_mapper.Map(typeof(IList), typeof(ArrayList));
            _mapper.Map(typeof(IList<>), typeof(List<>));
            _mapper.Map(typeof(IPropertyHelper<>), typeof(PropertyHelper<>));
        }
开发者ID:peteyoung,项目名称:Testify,代码行数:9,代码来源:TypeMapperSpec.cs

示例4: Bug003_MappingFailsWhenSourceHasReadOnlyPropertyWithNullValue

        public void Bug003_MappingFailsWhenSourceHasReadOnlyPropertyWithNullValue()
        {
            var c1 = new Bug003_Class_One();
            
            var tm = new TypeMapper();

            var clone = tm.Map<Bug003_Class_One>(c1);

            Assert.IsNotNull(clone);
            Assert.AreEqual(clone.Id, c1.Id);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:11,代码来源:TypeMapper._BugFixes.cs

示例5: Bug006_ReuseTargetCollectionsWhenPossible_false__Fails_to_create_new_collection

        public void Bug006_ReuseTargetCollectionsWhenPossible_false__Fails_to_create_new_collection()
        {
            var c1 = new Bug006_Class_One { Name = "1" };

            var trp1 = new Bug006_Class_One
            {
                Name = "trp1"
            };
            var trp2 = new Bug006_Class_One
            {
                Name = "trp2"
            };

            c1.Items.Add(trp1);
            c1.Items.Add(trp2);

            var c2 = new Bug006_Class_One();

            var mo = new MappingOptions()
            {
                ReuseTargetCollectionsWhenPossible = false,
            };

            var tm = new TypeMapper();

            tm.Map(c1, c2, mo);

            Assert.AreEqual(c1.Name, c2.Name);

            // when the bug wasn't fixed, c2.Items.Count would be 0
            Assert.AreEqual(c1.Items.Count, c2.Items.Count);

            for (int i = 0; i < c1.Items.Count; i++)
            {
                Assert.AreEqual(c1.Items[i].Name, c2.Items[i].Name);
            }
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:37,代码来源:TypeMapper._BugFixes.cs

示例6: Bug005_mapping_fails_when_type_contains_list_property_without_a_setter

        public void Bug005_mapping_fails_when_type_contains_list_property_without_a_setter()
        {
            var c1 = new Bug005_Class_One { Name = "1" };

            var c1_1 = new Bug005_Class_One { Name = "1_1" };
            var c1_2 = new Bug005_Class_One { Name = "1_2" };
            var c1_3 = new Bug005_Class_One { Name = "1_3" };

            c1.Items.Add(c1_1);
            c1.Items.Add(c1_2);
            c1.Items.Add(c1_3);

            var c2 = new Bug005_Class_One();

            var tm = new TypeMapper();

            tm.Map(c1, c2);

            Assert.AreEqual(c1.Name, c2.Name);
            Assert.AreEqual(c1.Items.Count, c2.Items.Count);

            for(int i = 0; i < c1.Items.Count; i++)
            {
                Assert.AreEqual(c1.Items[i].Name, c2.Items[i].Name);
            }
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:26,代码来源:TypeMapper._BugFixes.cs

示例7: Bug004_CloneFailsOnTypeWithReadOnlyPropertiesWhichThrowException

        public void Bug004_CloneFailsOnTypeWithReadOnlyPropertiesWhichThrowException()
        {
            var c1 = new Bug004_Class_One();

            var tm = new TypeMapper();

            var clone = tm.Map<Bug004_Class_One>(c1);

            Assert.IsNotNull(clone);
            Assert.AreEqual(clone.Id, c1.Id);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:11,代码来源:TypeMapper._BugFixes.cs


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