本文整理汇总了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<,>));
}
示例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<>));
}