首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏林德熙的博客

    C# 转换类型和字符串

    那么我们可以使用 TypeDescriptor string value = "123"; var typeDescriptor = TypeDescriptor.GetConverter (typeof(int)); int @int =(int) typeDescriptor.ConvertFromString(value); Console.WriteLine (typeDescriptor.ConvertToString(@int)); typeDescriptor = TypeDescriptor.GetConverter(typeof (double)); double @double = (double)typeDescriptor.ConvertFromString(value); Console.WriteLine(typeDescriptor.ConvertToString(@double)); 参见:http://www.jianshu.com/p/cdc8f5fe6405

    61210编辑于 2022-08-04
  • 来自专栏快乐阿超

    Converter集合转换

    去一个一个转换 实际上org.springframework.core.convert.ConversionService也为我们提供了参数为org.springframework.core.convert.TypeDescriptor import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.TypeDescriptor sourceType, TypeDescriptor targetType) { return CONVERSION_SERVICE.convert(source, sourceType (List.class, TypeDescriptor.valueOf(source.get(0).getClass())), TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(targetClass))); } } 使用起来只需要: final List

    44610编辑于 2022-08-21
  • 来自专栏林德熙的博客

    C# 转换类型和字符串

    那么我们可以使用 TypeDescriptor string value = "123"; var typeDescriptor = TypeDescriptor.GetConverter (typeof(int)); int @int =(int) typeDescriptor.ConvertFromString(value); Console.WriteLine (typeDescriptor.ConvertToString(@int)); typeDescriptor = TypeDescriptor.GetConverter(typeof (double)); double @double = (double)typeDescriptor.ConvertFromString(value); Console.WriteLine(typeDescriptor.ConvertToString(@double)); 参见:http://www.jianshu.com/p/cdc8f5fe6405

    1K10发布于 2018-09-18
  • 来自专栏明明如月的技术专栏

    Spring问题研究之bean的属性xml注入List类型不匹配

    = null && typeDescriptor ! = null && typeDescriptor ! TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue); if (conversionService.canConvert typeDescriptor) { if (! elementType = (typeDescriptor !

    2.9K10发布于 2021-08-27
  • 来自专栏c++与qt学习

    Spring读源码系列番外篇---05----类型转换---中---三种全新的类型转换器

    public interface ConditionalConverter { boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType > source, TypeDescriptor streamType, TypeDescriptor targetType) { //这里是先把Stream转换为List List<Object sourceClass =TypeDescriptor.valueOf(User.class); TypeDescriptor targetClass = TypeDescriptor.valueOf source = TypeDescriptor.valueOf(String.class); TypeDescriptor target = TypeDescriptor.valueOf { public GenericTypeDescriptor(TypeDescriptor typeDescriptor) { super(typeDescriptor.getResolvableType

    1.3K20编辑于 2022-05-10
  • 来自专栏BAT的乌托邦

    【小家Spring】聊聊Spring中的数据转换:Converter、ConversionService、TypeConverter、PropertyEditor

    public TypeDescriptor getMapKeyTypeDescriptor(); public TypeDescriptor getMapValueTypeDescriptor() > mapType, @Nullable TypeDescriptor keyTypeDescriptor, @Nullable TypeDescriptor valueTypeDescriptor); public static TypeDescriptor array(@Nullable TypeDescriptor elementTypeDescriptor); public static TypeDescriptor nested(MethodParameter methodParameter, int nestingLevel); public static TypeDescriptor > targetType); boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType);

    6.9K31发布于 2019-09-03
  • 来自专栏chenssy

    【死磕 Spring】----- IOC 之深入分析 Bean 的类型转换体系

    > targetType); boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType sourceType, TypeDescriptor targetType); } 其 UML 类图如下: ? getConverter() 如下: protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType); 到这里我们就可以得到 如下: public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType

    1.1K20发布于 2019-03-06
  • 来自专栏跟着阿笨一起玩NET

    PropertyGrid绑定Dictionary

    (this, true);     }     public EventDescriptor GetDefaultEvent()     {         return TypeDescriptor.GetDefaultEvent (this, true);     }     public string GetClassName()     {         return TypeDescriptor.GetClassName in them:     public EventDescriptorCollection GetEvents(Attribute[] attributes)     {         return TypeDescriptor.GetEvents (this, true);     }     public TypeConverter GetConverter()     {         return TypeDescriptor.GetConverter (this, true);     }     public object GetEditor(Type editorBaseType)     {         return TypeDescriptor.GetEditor

    1.1K20发布于 2018-09-18
  • 来自专栏Java程序员的技能宝典

    Spring官网阅读系列(十一):Spring中的BeanWrapper及类型转换

    typeDescriptor) throws TypeMismatchException { throw new UnsupportedOperationException("TypeDescriptor = null && typeDescriptor ! = null) { TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue); ClassUtils.isAssignableValue(requiredType, convertedValue))) { if (typeDescriptor ! > targetType); boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType)

    1.6K01发布于 2020-03-29
  • 来自专栏c++与qt学习

    Spring读源码系列番外篇---06----类型转换---下---ConversionService相关家族

    > targetType); boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType); <T> T convert (Object source, Class<T> targetType); Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor TypeDescriptor.valueOf(sourceType) : null), TypeDescriptor.valueOf(targetType)); } @Override public boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { Assert.notNull Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { Assert.notNull(targetType

    76420编辑于 2022-05-10
  • 来自专栏程序员DMZ

    Spring官网阅读(十四)Spring中的BeanWrapper及类型转换

    typeDescriptor) throws TypeMismatchException { throw new UnsupportedOperationException("TypeDescriptor = null && typeDescriptor ! = null) { TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue); if (conversionService.canConvert > targetType); boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType); sourceType, TypeDescriptor targetType); } UML类图 ?

    1.8K30发布于 2020-07-07
  • 来自专栏c++与qt学习

    Spring读源码系列番外篇---02---PropertyResolver的结构体系剖析---上

    TypeDescriptor.valueOf(sourceType) : null), TypeDescriptor.valueOf(targetType)); } @Override public boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { Assert.notNull convert(@Nullable Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { sourceType, TypeDescriptor targetType) { // Check raw type first... sourceType; private final TypeDescriptor targetType; public ConverterCacheKey(TypeDescriptor sourceType

    1.1K40编辑于 2022-05-10
  • 来自专栏c++与qt学习

    Spring读源码系列番外篇08---BeanWrapper没有那么简单--上

    new TypeDescriptor(methodParam) : TypeDescriptor.valueOf(requiredType))); } @Override @Nullable new TypeDescriptor(field) : TypeDescriptor.valueOf(requiredType))); } //最终调用的方法 @Nullable @Override = null && typeDescriptor ! = null && typeDescriptor ! TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(mapKeyType); Object convertedMapKey = convertIfNecessary

    1.2K20编辑于 2022-05-10
  • 来自专栏java

    字节码使用方法与组件封装方法详细指南

    ) { if (typeDescriptor.startsWith("[")) { return toJavaTypeName(typeDescriptor.substring (1)) + "[]"; } else if (typeDescriptor.startsWith("L") && typeDescriptor.endsWith(";")) { return typeDescriptor.substring(1, typeDescriptor.length() - 1).replace('/', '.'); } else if ( primitiveTypes.containsKey(typeDescriptor)) { return primitiveTypes.get(typeDescriptor).getName (); } return typeDescriptor; } /** * 动态加载类 */ public static Class<?

    32810编辑于 2025-06-13
  • 来自专栏BAT的乌托邦

    5. 穿过拥挤的人潮,Spring已为你制作好高级赛道

    sourceTypeDesp = TypeDescriptor.valueOf(Set.class); TypeDescriptor targetTypeDesp = TypeDescriptor.valueOf sourceType, TypeDescriptor targetType) { return (sourceType.getType() ! sourceType, TypeDescriptor targetType) { Method finder = getFinder(targetType.getType()); return ( = null && this.conversionService.canConvert(sourceType, TypeDescriptor.valueOf(finder.getParameterTypes sourceTypeDesp = TypeDescriptor.valueOf(String.class); TypeDescriptor targetTypeDesp = TypeDescriptor.valueOf

    53220编辑于 2022-03-08
  • 来自专栏BAT的乌托邦

    4. 上新了Spring,全新一代类型转换机制

    由此也能看出该转换器是可以支持N:N的(大多数情况下只写一对值而已,也有写多对的) TypeDescriptor:类型描述。 CollectionToCollectionConverter: @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor sourceTypeDesp = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)); TypeDescriptor targetTypeDesp = TypeDescriptor.collection(Set.class, TypeDescriptor.valueOf(Integer.class)); System.out.println public interface ConditionalConverter { boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType

    1.6K30发布于 2020-12-21
  • 来自专栏BAT的乌托邦

    4. 上新了Spring,全新一代类型转换机制

    由此也能看出该转换器是可以支持N:N的(大多数情况下只写一对值而已,也有写多对的) TypeDescriptor:类型描述。 CollectionToCollectionConverter: @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor sourceTypeDesp = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)); TypeDescriptor targetTypeDesp = TypeDescriptor.collection(Set.class, TypeDescriptor.valueOf(Integer.class)); System.out.println public interface ConditionalConverter { boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType

    1.2K20编辑于 2022-03-08
  • 来自专栏BAT的乌托邦

    6. 抹平差异,统一类型转换服务ConversionService

    > targetType); boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType); <T> T convert 查找find @Nullable public GenericConverter find(TypeDescriptor sourceType, TypeDescriptor targetType) { TypeDescriptor.valueOf(sourceType) : null), TypeDescriptor.valueOf(targetType)); } @Override public boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { if (sourceType Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { if (sourceType ==

    1.6K80发布于 2020-12-28
  • 来自专栏BAT的乌托邦

    6. 抹平差异,统一类型转换服务ConversionService

    > targetType); boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType); <T> T convert 查找find @Nullable public GenericConverter find(TypeDescriptor sourceType, TypeDescriptor targetType) { TypeDescriptor.valueOf(sourceType) : null), TypeDescriptor.valueOf(targetType)); } @Override public boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { if (sourceType Object source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { if (sourceType ==

    1K21编辑于 2022-03-08
  • 来自专栏BAT的乌托邦

    5. 穿过拥挤的人潮,Spring已为你制作好高级赛道

    sourceTypeDesp = TypeDescriptor.valueOf(Set.class); TypeDescriptor targetTypeDesp = TypeDescriptor.valueOf sourceType, TypeDescriptor targetType) { return (sourceType.getType() ! sourceType, TypeDescriptor targetType) { Method finder = getFinder(targetType.getType()); return ( = null && this.conversionService.canConvert(sourceType, TypeDescriptor.valueOf(finder.getParameterTypes sourceTypeDesp = TypeDescriptor.valueOf(String.class); TypeDescriptor targetTypeDesp = TypeDescriptor.valueOf

    75340发布于 2020-12-22
领券