예제 #1
0
        public object BindObject(Type settingsType, IBindingContext bindingContext)
        {
            var settingsInstance = Activator.CreateInstance(settingsType);
            var propertyInfos = settingsType.GetProperties();
            propertyInfos.Each(property =>
            {
                var value = bindingContext.ValueFor(bindingContext.Prefix + property.Name);
                if (value == null)
                    return;

                var convertedValue = _typeConverter.ConvertTo(value, property.PropertyType);

                property.SetValue(settingsInstance, convertedValue, null);
            });

            return settingsInstance;
        }