private IEnumerable <IValueProviderFactory> FilterBy(ParameterSource source)
        {
            IValueProviderFactory factory;

            foreach (string name in source.Sources)
            {
                if (_collection.TryGetValue(name, out factory))
                {
                    yield return(factory);
                }
            }
        }
        public IValueProvider GetProvider(ControllerContext context, ParameterSource source)
        {
            if (source.AllowAll)
            {
                return(GetProvider(context));
            }

            return(new ValueProviderCollection(
                       FilterBy(source)
                       .Select(c => c.Create(context))
                       .Where(p => p != null)
                       ));
        }
        private void InitFromAttributes()
        {
            _binder = GetModelBinder(_parameter);
            _source = ParameterSource.Default;

            BindAttribute attribute = (BindAttribute)Attribute.GetCustomAttribute(_parameter, typeof(BindAttribute));
            if (attribute != null)
            {
                _name = attribute.Name ?? _parameter.Name;
                _source = ParameterSource.FromString(attribute.Source);
                _defaultValue = attribute.Default;
            }
        }
Exemple #4
0
        private void InitFromAttributes()
        {
            _binder = GetModelBinder(_parameter);
            _source = ParameterSource.Default;

            BindAttribute attribute = (BindAttribute)Attribute.GetCustomAttribute(_parameter, typeof(BindAttribute));

            if (attribute != null)
            {
                _name         = attribute.Name ?? _parameter.Name;
                _source       = ParameterSource.FromString(attribute.Source);
                _defaultValue = attribute.Default;
            }
        }
		protected virtual IValueProvider GetValueProvider(ControllerContext context, ParameterSource source)
		{
			return Configuration.Instance.Models.ValueProviders.GetProvider(context, source);
		}
 protected virtual IValueProvider GetValueProvider(ControllerContext context, ParameterSource source)
 {
     return(Configuration.Instance.Models.ValueProviders.GetProvider(context, source));
 }