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


C# MappingConfiguration.AddMappingSpecification方法代码示例

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


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

示例1: GenerateFastMappersBenchmarkCode

        private static void GenerateFastMappersBenchmarkCode()
        {
            MappingConfiguration config = new MappingConfiguration();

            var matcher = new SimpleMatcher();
            var customerSpec = new MappingSpecification<BenchmarkFastMapper.Classes.Customer, BenchmarkFastMapper.Classes.CustomerDTO>();
            customerSpec.AddMapsBasedOnMatches(matcher);
            customerSpec.AddMap(source => source.Address.City, target => target.AddressCity);

            var addressSpec = new MappingSpecification<BenchmarkFastMapper.Classes.Address, BenchmarkFastMapper.Classes.AddressDTO>();
            addressSpec.AddMapsBasedOnMatches(matcher);

            config.AddMappingSpecification(customerSpec);
            config.AddMappingSpecification(addressSpec);

            CheckConfigAndGenCode(config, "FastMapper");
        }
开发者ID:AndreasNoergaard,项目名称:MapperatorBenchmark,代码行数:17,代码来源:Program.cs

示例2: SetupFlatteningMapOneLayered

        private static MappingConfiguration SetupFlatteningMapOneLayered()
        {
            var matcher = new SimpleMatcher();
            matcher.AddPossibleTargetSuffix("ProperName");
            MappingConfiguration config = new MappingConfiguration();
            var map1 = new MappingSpecification<Model1, Dto1>();
            var map2 = new MappingSpecification<Model2, Dto2>();
            var map3 = new MappingSpecification<Model3, Dto3>();
            var map4 = new MappingSpecification<Model4, Dto4>();
            var map5 = new MappingSpecification<Model5, Dto5>();
            var map6 = new MappingSpecification<Model6, Dto6>();
            var map7 = new MappingSpecification<Model7, Dto7>();
            var map8 = new MappingSpecification<Model8, Dto8>();
            var map9 = new MappingSpecification<Model9, Dto9>();
            var map10 = new MappingSpecification<Model10, Dto10>();
            var mapObject = new MappingSpecification<ModelObject, ModelDto>();
            map1.AddMapsBasedOnMatches(matcher);
            map2.AddMapsBasedOnMatches(matcher);
            map3.AddMapsBasedOnMatches(matcher);
            map4.AddMapsBasedOnMatches(matcher);
            map5.AddMapsBasedOnMatches(matcher);
            map6.AddMapsBasedOnMatches(matcher);
            map7.AddMapsBasedOnMatches(matcher);
            map8.AddMapsBasedOnMatches(matcher);
            map9.AddMapsBasedOnMatches(matcher);
            map10.AddMapsBasedOnMatches(matcher);
            mapObject.AddMap(source => source.BaseDate, target => target.BaseDate);
            mapObject.AddMap(source => source.Sub.ProperName, target => target.SubProperName);
            mapObject.AddMap(source => source.Sub2.ProperName, target => target.Sub2ProperName);
            mapObject.AddMap(source => source.SubWithExtraName.ProperName, target => target.SubWithExtraNameProperName);
            mapObject.AddMap(source => source.Sub.SubSub.IAmACoolProperty, target => target.SubSubSubIAmACoolProperty);
            config.AddMappingSpecification(map1);
            config.AddMappingSpecification(map2);
            config.AddMappingSpecification(map3);
            config.AddMappingSpecification(map4);
            config.AddMappingSpecification(map5);
            config.AddMappingSpecification(map6);
            config.AddMappingSpecification(map7);
            config.AddMappingSpecification(map8);
            config.AddMappingSpecification(map9);
            config.AddMappingSpecification(map10);
            config.AddMappingSpecification(mapObject);

            return config;
        }
开发者ID:AndreasNoergaard,项目名称:MapperatorBenchmark,代码行数:45,代码来源:Program.cs


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