public object ParseReadValue(string readValue, Type destinationType, IniContext iniContext)
        {
            var listType     = typeof(List <>).MakeGenericType(iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type);
            var returnedList = (IList)Activator.CreateInstance(listType);

            for (int i = 0; i < int.MaxValue; i++)
            {
                var dynamicIniOptionsAttribute = new IniOptionsAttribute()
                {
                    Section = GenerateDynamicSection(iniContext, i)
                };

                var section = iniContext.IniParser.Read(dynamicIniOptionsAttribute.Section, null);
                if (string.IsNullOrEmpty(section))
                {
                    break;
                }

                var loadedComplexType = _iniWrapperWithCustomMemberInfo.LoadConfigurationFromFileWithCustomMemberInfo(
                    iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type,
                    dynamicIniOptionsAttribute);

                returnedList.Add(loadedComplexType);
            }
            return(returnedList);
        }
        public void ComplexTypeFieldInfoWrapper_ShouldReturnGivenIniOptionsAttribute_WhenInvokeGetAttributeWithIniOptionsAttribute()
        {
            var expected = new IniOptionsAttribute()
            {
                Section = "SectionTest",
                Key     = "KeyTest"
            };
            var sut = new ComplexTypeMemberInfoWrapper(null, expected);

            var result = sut.GetAttribute <IniOptionsAttribute>();

            result.Section.Should().Be(expected.Section);
            result.Key.Should().Be(expected.Key);
        }
        public IniValue FormatToWrite(object objectToFormat, IniContext iniContext)
        {
            var enumerable = objectToFormat as IEnumerable;

            var index = 0;

            foreach (var item in enumerable)
            {
                if (item == null)
                {
                    continue;
                }

                var dynamicIniOptionsAttribute = new IniOptionsAttribute()
                {
                    Section = GenerateDynamicSection(iniContext, index)
                };

                _iniWrapperWithCustomMemberInfo.SaveConfigurationWithCustomMemberInfo(item, dynamicIniOptionsAttribute);
                index++;
            }

            return(null);
        }
 public ComplexTypeMemberInfoWrapper(IMemberInfoWrapper infoWrapper, IniOptionsAttribute dynamicIniOptionsAttribute)
 {
     _infoWrapper = infoWrapper;
     _dynamicIniOptionsAttribute = dynamicIniOptionsAttribute;
 }
        public object LoadConfigurationFromFileWithCustomMemberInfo(Type configurationType, IniOptionsAttribute iniOptionsAttribute)
        {
            var memberInfoFactory = new ComplexTypeMemberInfoFactory(iniOptionsAttribute);

            return(_constructorChecker.HasConstructorWithAttribute(configurationType)
                ? ReadForImmutableType(configurationType, memberInfoFactory)
                : ReadForNormalType(configurationType, memberInfoFactory));
        }
        public void SaveConfigurationWithCustomMemberInfo(object configuration, IniOptionsAttribute iniOptionsAttribute)
        {
            var memberInfoFactory = new ComplexTypeMemberInfoFactory(iniOptionsAttribute);

            _iniWrapperInternal.SaveConfigurationInternal(configuration, memberInfoFactory);
        }
 public ComplexTypeMemberInfoFactory(IniOptionsAttribute iniOptionsAttribute)
 {
     _iniOptionsAttribute = iniOptionsAttribute;
 }