Example #1
0
        private void ReadFields(Type destinationType, IMemberInfoFactory memberInfoFactory)
        {
            var fields = destinationType.GetFields();

            foreach (var field in fields)
            {
                var fieldInfoWrapper = memberInfoFactory.CreateMemberInfo(field);

                var readValue = _readingManager.ReadValue(fieldInfoWrapper, default, destinationType);
Example #2
0
        private void SaveFields(object configuration, IMemberInfoFactory memberInfoFactory)
        {
            var fields = configuration.GetType().GetFields();

            foreach (var field in fields)
            {
                var fieldInfoWrapper = memberInfoFactory.CreateMemberInfo(field);
                _savingManager.SaveValue(fieldInfoWrapper, configuration);
            }
        }
Example #3
0
        private void SaveProperties(object configuration, IMemberInfoFactory memberInfoFactory)
        {
            var properties = configuration.GetType().GetProperties();

            foreach (var property in properties)
            {
                var propertyInfoWrapper = memberInfoFactory.CreateMemberInfo(property);
                _savingManager.SaveValue(propertyInfoWrapper, configuration);
            }
        }
Example #4
0
        private void ReadFields(object configuration, IMemberInfoFactory memberInfoFactory)
        {
            var configurationType = configuration.GetType();
            var fields            = configurationType.GetFields();

            foreach (var field in fields)
            {
                var fieldInfoWrapper = memberInfoFactory.CreateMemberInfo(field);
                var readValue        = _readingManager.ReadValue(fieldInfoWrapper, configuration, configurationType);

                if (readValue == null)
                {
                    continue;
                }

                field.SetValue(configuration, readValue);
            }
        }
Example #5
0
        private void ReadProperties(object configuration, IMemberInfoFactory memberInfoFactory)
        {
            var configurationType = configuration.GetType();
            var properties        = configurationType.GetProperties();

            foreach (var property in properties)
            {
                var propertyInfoWrapper = memberInfoFactory.CreateMemberInfo(property);
                var readValue           = _readingManager.ReadValue(propertyInfoWrapper, configuration, configurationType);

                if (readValue == null)
                {
                    continue;
                }

                if (!property.CanWrite)
                {
                    throw new ArgumentException($"Please add setter to property with name {propertyInfoWrapper.Name} in type {configurationType} or decorate it with IniIgnoreAttribute.");
                }

                property.SetValue(configuration, readValue);
            }
        }