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


C# TypePair类代码示例

本文整理汇总了C#中TypePair的典型用法代码示例。如果您正苦于以下问题:C# TypePair类的具体用法?C# TypePair怎么用?C# TypePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: IsMatch

 public bool IsMatch(TypePair context)
 {
     return IsPrimitiveArrayType(context.DestinationType) &&
            IsPrimitiveArrayType(context.SourceType) &&
            (TypeHelper.GetElementType(context.DestinationType)
                .Equals(TypeHelper.GetElementType(context.SourceType)));
 }
开发者ID:garora,项目名称:AutoMapper,代码行数:7,代码来源:PrimitiveArrayMapper.cs

示例2: GetTargetName

 private string GetTargetName(
     Option<BindingConfig> bindingConfig,
     TypePair typePair,
     MemberInfo sourceMember,
     Dictionary<string, string> targetBindings)
 {
     Option<string> targetName;
     List<BindAttribute> binds = sourceMember.GetAttributes<BindAttribute>();
     BindAttribute bind = binds.FirstOrDefault(x => x.TargetType.IsNull());
     if (bind.IsNull())
     {
         bind = binds.FirstOrDefault(x => typePair.Target.IsAssignableFrom(x.TargetType));
     }
     if (bind.IsNotNull())
     {
         targetName = new Option<string>(bind.MemberName);
     }
     else
     {
         targetName = bindingConfig.Map(x => x.GetBindField(sourceMember.Name));
         if (targetName.HasNoValue)
         {
             string targetMemberName;
             if (targetBindings.TryGetValue(sourceMember.Name, out targetMemberName))
             {
                 targetName = new Option<string>(targetMemberName);
             }
             else
             {
                 targetName = new Option<string>(sourceMember.Name);
             }
         }
     }
     return targetName.Value;
 }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:35,代码来源:MappingMemberBuilder.cs

示例3: CreateMapperCacheItem

 private MapperCacheItem CreateMapperCacheItem(TypePair typePair)
 {
     MapperBuilder mapperBuilder = GetMapperBuilder(typePair);
     Mapper mapper = mapperBuilder.Build(typePair);
     MapperCacheItem mapperCacheItem = _mapperCache.Add(typePair, mapper);
     return mapperCacheItem;
 }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:7,代码来源:CollectionMapperBuilder.cs

示例4: DryRunTypeMap

 private void DryRunTypeMap(ICollection<TypeMap> typeMapsChecked, ResolutionContext context)
 {
     var typeMap = context.TypeMap;
     if (typeMap != null)
     {
         typeMapsChecked.Add(typeMap);
         CheckPropertyMaps(typeMapsChecked, context);
     }
     else
     {
         var mapperToUse = _config.GetMappers().FirstOrDefault(mapper => mapper.IsMatch(context.Types));
         if (mapperToUse == null && context.SourceType.IsNullableType())
         {
             var nullableTypes = new TypePair(Nullable.GetUnderlyingType(context.SourceType),
                 context.DestinationType);
             mapperToUse = _config.GetMappers().FirstOrDefault(mapper => mapper.IsMatch(nullableTypes));
         }
         if (mapperToUse == null)
         {
             throw new AutoMapperConfigurationException(context);
         }
         if (mapperToUse is ArrayMapper || mapperToUse is EnumerableMapper || mapperToUse is CollectionMapper)
         {
             CheckElementMaps(typeMapsChecked, context);
         }
     }
 }
开发者ID:jbogard,项目名称:AutoMapper,代码行数:27,代码来源:ConfigurationValidator.cs

示例5: IsMatch

 public bool IsMatch(TypePair context)
 {
     // destination type must be IEnumerable interface or a class implementing at least IList 
     return ((context.DestinationType.IsInterface() && context.DestinationType.IsEnumerableType()) ||
             context.DestinationType.IsListType())
            && context.SourceType.IsEnumerableType();
 }
开发者ID:284247028,项目名称:AutoMapper,代码行数:7,代码来源:EnumerableMapper.cs

示例6: EnumToEnumMapping

 private static bool EnumToEnumMapping(TypePair context)
 {
     // Enum to enum mapping
     var sourceEnumType = TypeHelper.GetEnumerationType(context.SourceType);
     var destEnumType = TypeHelper.GetEnumerationType(context.DestinationType);
     return sourceEnumType != null && destEnumType != null;
 }
开发者ID:garora,项目名称:AutoMapper,代码行数:7,代码来源:EnumMapper.cs

示例7: DryRunTypeMap

 private void DryRunTypeMap(ICollection<TypeMap> typeMapsChecked, TypePair types, TypeMap typeMap, ResolutionContext context)
 {
     if (typeMap != null)
     {
         typeMapsChecked.Add(typeMap);
         if(typeMap.CustomMapper != null || typeMap.TypeConverterType != null)
         {
             return;
         }
         CheckPropertyMaps(typeMapsChecked, typeMap, context);
     }
     else
     {
         var mapperToUse = _config.GetMappers().FirstOrDefault(mapper => mapper.IsMatch(types));
         if (mapperToUse == null && types.SourceType.IsNullableType())
         {
             var nullableTypes = new TypePair(Nullable.GetUnderlyingType(types.SourceType),
                 types.DestinationType);
             mapperToUse = _config.GetMappers().FirstOrDefault(mapper => mapper.IsMatch(nullableTypes));
         }
         if (mapperToUse == null)
         {
             throw new AutoMapperConfigurationException(types);
         }
         if (mapperToUse is ArrayMapper || mapperToUse is EnumerableMapper || mapperToUse is CollectionMapper)
         {
             CheckElementMaps(typeMapsChecked, types, context);
         }
     }
 }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:30,代码来源:ConfigurationValidator.cs

示例8: ConvertEnum

        private static Option<Func<object, object>> ConvertEnum(TypePair pair)
        {
            Func<object, object> result;
            if (pair.IsEnumTypes)
            {
                result = x => Convert.ChangeType(x, pair.Source);
                return result.ToOption();
            }

            if (pair.Target.IsEnum)
            {
                if (pair.Source.IsEnum == false)
                {
                    if (pair.Source == typeof(string))
                    {
                        result = x => Enum.Parse(pair.Target, x.ToString());
                    }
                }
                result = x => Enum.ToObject(pair.Target, Convert.ChangeType(x, Enum.GetUnderlyingType(pair.Target)));
                return result.ToOption();
            }

            if (pair.Source.IsEnum)
            {
                result = x => Convert.ChangeType(x, pair.Target);
                return result.ToOption();
            }
            return Option<Func<object, object>>.Empty;
        }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:29,代码来源:ConvertibleTypeMapperBuilder.cs

示例9: CreateMapperCacheItem

        private MapperCacheItem CreateMapperCacheItem(TypePair parentTypePair, MappingMember mappingMember)
        {
            MapperBuilder mapperBuilder = _config.GetMapperBuilder(parentTypePair, mappingMember);
            Mapper mapper = mapperBuilder.Build(parentTypePair, mappingMember);
            MapperCacheItem mapperCacheItem = _mapperCache.Add(mappingMember.TypePair, mapper);

            return mapperCacheItem;
        }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:8,代码来源:MemberMapper.cs

示例10: Build

 public MemberEmitterDescription Build(TypePair parentTypePair, List<MappingMember> members)
 {
     var emitter = new EmitComposite();
     members.ForEach(x => emitter.Add(Build(parentTypePair, x)));
     var result = new MemberEmitterDescription(emitter, _mapperCache);
     result.AddMapper(_mapperCache);
     return result;
 }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:8,代码来源:MemberMapper.cs

示例11: TypeMap

 public TypeMap(TypeDetails sourceType, TypeDetails destinationType, MemberList memberList, ProfileMap profile)
 {
     SourceTypeDetails = sourceType;
     DestinationTypeDetails = destinationType;
     Types = new TypePair(sourceType.Type, destinationType.Type);
     Profile = profile;
     ConfiguredMemberList = memberList;
 }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:8,代码来源:TypeMap.cs

示例12: TypeMap

 public TypeMap(TypeDetails sourceType, TypeDetails destinationType, MemberList memberList)
 {
     _sourceType = sourceType;
     _destinationType = destinationType;
     Types = new TypePair(sourceType.Type, destinationType.Type);
     Profile = ConfigurationStore.DefaultProfileName;
     ConfiguredMemberList = memberList;
 }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:8,代码来源:TypeMap.cs

示例13: GetMapperBuilder

 public MapperBuilder GetMapperBuilder(TypePair parentTypePair, MappingMember mappingMember)
 {
     if (_customTypeMapperBuilder.IsSupported(parentTypePair, mappingMember))
     {
         return _customTypeMapperBuilder;
     }
     return GetTypeMapperBuilder(mappingMember.TypePair);
 }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:8,代码来源:TargetMapperBuilder.cs

示例14: IsSupported

 public bool IsSupported(TypePair parentTypePair, MappingMember mappingMember)
 {
     Option<BindingConfig> bindingConfig = _config.GetBindingConfig(parentTypePair);
     if (bindingConfig.HasNoValue)
     {
         return false;
     }
     return bindingConfig.Value.HasCustomTypeConverter(mappingMember.Target.Name);
 }
开发者ID:DeanMilojevic,项目名称:TinyMapper,代码行数:9,代码来源:CustomTypeMapperBuilder.cs

示例15: IsMatch

        public bool IsMatch(TypePair context)
        {
            if (!(context.SourceType.IsEnumerableType() && context.DestinationType.IsGenericType()))
                return false;

            var genericType = context.DestinationType.GetGenericTypeDefinition();

            return genericType == typeof (ReadOnlyCollection<>);
        }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:9,代码来源:ReadOnlyCollectionMapper.cs


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