private void BuildParameterProvider(INConfigSettings settings, SectionProvider provider, Parameter parameter, PropertyInfo parameterPropertyInfo)
        {
            if (string.IsNullOrEmpty(parameter.TypeName))
            {
                parameter.TypeName = parameterPropertyInfo.PropertyType.AssemblyQualifiedName;
            }
            else if (!parameterPropertyInfo.PropertyType.IsAssignableFrom(Type.GetType(parameter.TypeName, true)))
            {
                throw new InvalidParameterConfiguration(string.Format("Specified type {0} for parameter {1} is not assignable to the property of type {2}", parameter.TypeName, parameter.Name,parameterPropertyInfo.PropertyType.FullName));
            }

            var valueProvider = new ParameterToParameterValueProviderConverter().Convert(parameter, settings);
            provider.ParameterValuesProviders.Add(parameterPropertyInfo.Name, valueProvider);
        }
        private IFilterPolicy GetFilterPolicy(Parameter parameter, Type parameterType, INConfigSettings settings)
        {
            IFilterPolicy filterPolicy = this._helper.GetConfigurationProperty<Parameter, IFilterPolicy>
                (parameter,x=>x.PolicyName,
                () =>
                {
                    if (settings.ResultBuilderProvider.IsTypeIsSupportedCollection(parameterType))
                    {
                        return settings.FilterPolicies[Configure.DefaultCollectionFilterPolicyName];
                    }
                    else
                    {
                        return settings.FilterPolicies[Configure.DefaultSingleValueFilterPolicyName];
                    }
                }
                    ,
                x => settings.FilterPolicies[x]);

            return filterPolicy;
        }
        public IParameterValueProvider Convert(Parameter parameter, INConfigSettings settings)
        {
            var parameterType = Type.GetType(parameter.TypeName, true);

            var policy = this.GetFilterPolicy(parameter, parameterType, settings);

            var required = this.GetRequired(parameter);

            var parameterValueType = this.DetermineParameterValueType(parameterType);

            var translator = this.GetTranslator(parameter, parameterValueType, settings);

            IEnumerable<IValueProvider> valueProviders = this.BuildValueProviders(parameter.Values,translator,settings);

            var resultBuilder = settings.ResultBuilderProvider.Get(parameterType);

            IParameterValueProvider parameterValueProvider = new ParameterValueProvider
                (valueProviders, resultBuilder, new Filter(policy, settings.FilterConditionsEvaluator), required, parameter.Name);

            return parameterValueProvider;
        }
        public void ConvertSection()
        {
            Section section = new Section
                {
                    TypeName = typeof (SimpleSection).AssemblyQualifiedName,
                    ModelBinder = null,
                };
            var strPropParam = new Parameter
                {
                    Name = "StrProp",
                    Values = new List<ParameterValue>
                        {
                            new ParameterValue{Value = "aa"}
                        },
                };

            var intPropParam = new Parameter
                {
                    Name = "IntProp",
                    Values = new List<ParameterValue>
                        {
                            new ParameterValue
                                {
                                    Value = "11"
                                }
                        },
                };

            section.Parameters.Add(strPropParam.Name, strPropParam);
            section.Parameters.Add(intPropParam.Name, intPropParam);

            var sectionProvider = new SectionToProviderConverter().Convert(section, new NConfigSettings());

            var sectionInstance = sectionProvider.Get(new Dictionary<string, string>());

            Assert.IsInstanceOf<SimpleSection>(sectionInstance);
            Assert.AreEqual(11, ((SimpleSection)sectionInstance).IntProp);
            Assert.AreEqual("aa", ((SimpleSection)sectionInstance).StrProp);
        }
        private IStringToValueTranslator GetTranslator(Parameter parameter, Type parameterValueType, INConfigSettings settings)
        {
            var translatorProvider = this._helper.GetConfigurationProperty<Parameter, IStringToValueTranslatorProvider>
                (parameter,x=>x.Translator,() => settings.TranslatorProviders[settings.DefaultRawValueTranslatorName],
                x => settings.TranslatorProviders[x]);

            return translatorProvider.Get(parameterValueType);
        }
 private bool GetRequired(Parameter parameter)
 {
     bool required = this._helper.GetConfigurationProperty<Parameter, bool>
         (parameter, x => x.Required, () => true,bool.Parse);
     return required;
 }
 public MemberNotFouldForParameter(Parameter parameter)
     : base(string.Format("A matching member was not found for parameter with name: {0}", parameter.Name))
 {
     Parameter = parameter;
 }