Beispiel #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);
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }