public IgnoreAttributeConverter(IIniConverter iniConverter, IMemberInfoWrapper memberInfoWrapperWrapper) { _iniConverter = iniConverter; _memberInfoWrapper = memberInfoWrapperWrapper; }
public string GetSection(Type destinationType, IMemberInfoWrapper memberInfoWrapper) { var iniOptionsAttribute = memberInfoWrapper.GetAttribute <IniOptionsAttribute>(); return(iniOptionsAttribute?.Section); }
public string GetKey(IMemberInfoWrapper memberInfoWrapper) { var iniOptionsAttribute = memberInfoWrapper.GetAttribute <IniOptionsAttribute>(); return(iniOptionsAttribute?.Key); }
private TypeDetailsInformation GetBaseTypeInformation(Type type, IMemberInfoWrapper memberInfoWrapper) { if (!IsNullableType(type) && TypeCodeMap.TryGetValue(type, out var typeCode)) { return(new TypeDetailsInformation(typeCode, new UnderlyingTypeInformation(typeCode, false, type), null, memberInfoWrapper.GetMemberType())); } if (IsDictionaryType(type)) { var underlyingGenericTypeKey = type.GenericTypeArguments[0]; var underlyingGenericTypeValue = type.GenericTypeArguments[1]; var genericKeyTypeCode = GetBaseTypeInformation(underlyingGenericTypeKey, memberInfoWrapper); var genericValueTypeCode = GetBaseTypeInformation(underlyingGenericTypeValue, memberInfoWrapper); var underlyingKeyTypeInformation = new UnderlyingTypeInformation(genericKeyTypeCode.TypeCode, genericKeyTypeCode.UnderlyingTypeInformation.IsEnum, genericKeyTypeCode.UnderlyingTypeInformation.Type); var underlyingTypeInformation = new UnderlyingTypeInformation(genericValueTypeCode.TypeCode, genericValueTypeCode.UnderlyingTypeInformation.IsEnum, genericValueTypeCode.UnderlyingTypeInformation.Type); return(new TypeDetailsInformation(TypeCode.Dictionary, underlyingTypeInformation, underlyingKeyTypeInformation, memberInfoWrapper.GetMemberType())); } if (typeof(IEnumerable).IsAssignableFrom(type)) { var underlyingGenericType = type.GenericTypeArguments[0]; var genericTypeCode = GetBaseTypeInformation(underlyingGenericType, memberInfoWrapper); return(new TypeDetailsInformation(TypeCode.Enumerable, new UnderlyingTypeInformation( genericTypeCode.TypeCode, genericTypeCode.UnderlyingTypeInformation.IsEnum, genericTypeCode.UnderlyingTypeInformation.Type), null, memberInfoWrapper.GetMemberType())); } if (type.IsEnum) { var underlyingType = Enum.GetUnderlyingType(type); var typeDetailsInformation = GetBaseTypeInformation(underlyingType, memberInfoWrapper); return(new TypeDetailsInformation(typeDetailsInformation.TypeCode, new UnderlyingTypeInformation(TypeCode.Empty, true, type), null, memberInfoWrapper.GetMemberType())); } var nullable = Nullable.GetUnderlyingType(type); if (nullable == null) { return(new TypeDetailsInformation(TypeCode.ComplexObject, new UnderlyingTypeInformation(TypeCode.Empty, false, type), null, memberInfoWrapper.GetMemberType())); } if (nullable.IsEnum) { var nullableUnderlyingType = Enum.GetUnderlyingType(nullable); var underlyingType = GetBaseTypeInformation(nullableUnderlyingType, memberInfoWrapper); return(new TypeDetailsInformation(underlyingType.TypeCode, new UnderlyingTypeInformation(TypeCode.Empty, true, nullableUnderlyingType), null, nullable)); } return(new TypeDetailsInformation(TypeCode.Nullable, new UnderlyingTypeInformation(TypeCode.Empty, false, nullable), null, nullable)); }
private IIniConverter GetHandlerWithIgnoreAttributeHandlerDecorator(TypeDetailsInformation typeInformation, IMemberInfoWrapper memberInfoWrapper) { return(new IgnoreAttributeConverter(GetHandler(typeInformation), memberInfoWrapper)); }
public (IIniConverter converter, IIniConverter defaultHandler, TypeDetailsInformation typeDetailsInformation) GetConverter(Type type, object value, IMemberInfoWrapper memberInfoWrapper) { var typeInformation = _typeManager.GetTypeInformation(type, value, memberInfoWrapper); var customIniHandlerAttribute = memberInfoWrapper.GetAttribute <IniConverterAttribute>(); if (customIniHandlerAttribute != null) { var customHandler = CreateCustomConverter(customIniHandlerAttribute); var handlerWithDecorator = GetHandlerWithIgnoreAttributeHandlerDecorator(typeInformation, memberInfoWrapper); return(customHandler, handlerWithDecorator, typeInformation); } var handlerWithIgnoreAttributeHandlerDecorator = GetHandlerWithIgnoreAttributeHandlerDecorator(typeInformation, memberInfoWrapper); return(handlerWithIgnoreAttributeHandlerDecorator, null, typeInformation); }
public string GetSection(Type destinationType, IMemberInfoWrapper memberInfoWrapper) { return(_attributeManager.GetSection(destinationType, memberInfoWrapper) ?? destinationType.Name); }
public string GetKey(IMemberInfoWrapper memberInfoWrapper) { return(_attributeManager.GetKey(memberInfoWrapper) ?? memberInfoWrapper.Name); }