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


C# TypeMapper.Resolve方法代码示例

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


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

示例1: InitializeTypeMapper_should_configure_TypeMapper_to_resolve_types

        public void InitializeTypeMapper_should_configure_TypeMapper_to_resolve_types()
        {
            // Arrange
            var initializer = new CollectionMappingInitializer();
            var typeMapper = new TypeMapper();

            // Act
            initializer.InitializeTypeMapper(typeMapper);

            // Assert
            typeMapper.Resolve<IList>().ShouldEqual(typeof(ArrayList));
            typeMapper.Resolve<IDictionary>().ShouldEqual(typeof(Hashtable));
            typeMapper.Resolve<IList<string>>().ShouldEqual(typeof(List<string>));
            typeMapper.Resolve<IDictionary<int, double>>()
                .ShouldEqual(typeof(Dictionary<int, double>));

            Assert.Throws<ApplicationException>(
                () => typeMapper.Resolve<IEnumerable>());

            typeMapper.Resolve(typeof(IList<>)).ShouldEqual(typeof(List<>));
            typeMapper.Resolve(typeof(IDictionary<,>)).ShouldEqual(typeof(Dictionary<,>));
        }
开发者ID:peteyoung,项目名称:Testify,代码行数:22,代码来源:CollectionMappingInitializerSpec.cs

示例2: Should_get_proper_mapping_to_types_for_interfaces

        public void Should_get_proper_mapping_to_types_for_interfaces()
        {
            // Arrange
            var initializer = new IInterfaceConventionInitializer();
            var typeMapper = new TypeMapper();

            // Act
            initializer.InitializeTypeMapper(typeMapper);

            // Assert
            typeMapper.Resolve(typeof (ITypeMapper)).ShouldEqual(typeof (TypeMapper));
            typeMapper.Resolve(typeof (IInitializerFilter)).ShouldEqual(typeof (InitializerFilter));
            typeMapper.Resolve(typeof (IInitializerLocator)).ShouldEqual(typeof (InitializerLocator));
            typeMapper.Resolve(typeof (IPropertySetterFactory)).ShouldEqual(typeof (PropertySetterFactory));

            typeMapper.Resolve(typeof (IPropertyHelper<string>)).ShouldEqual(typeof (PropertyHelper<string>));
            typeMapper.Resolve(typeof (IPropertyHelper<Int64>)).ShouldEqual(typeof (PropertyHelper<Int64>));
            typeMapper.Resolve(typeof (IPropertyHelper<>)).ShouldEqual(typeof (PropertyHelper<>));
        }
开发者ID:peteyoung,项目名称:Testify,代码行数:19,代码来源:DITSpec.cs


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