public void FillValues(PropertyInfo property, IBindingContext context)
            {
                if (_conversionPropertyBinder.CanBeParsed(property.PropertyType))
                {
                    bool convertedAsIs = context.Data.ValueAs <string>(property.Name, value => _conversionPropertyBinder.Bind(property, context));
                    if (convertedAsIs)
                    {
                        return;
                    }
                }

                var collection = property.GetValue(context.Object, null) as ICollection <T>;

                if (collection == null)
                {
                    collection = new List <T>();
                    property.SetValue(context.Object, collection, null);
                }

                context.GetEnumerableRequests(property.Name).Each(request =>
                {
                    context.Logger.PushElement(typeof(T));

                    // TODO -- got to add the BindResult to context to store it later
                    context.BindObject(request, typeof(T), @object => { collection.Add((T)@object); });
                });
            }
Пример #2
0
            public void FillValues(PropertyInfo property, IBindingContext context)
            {
                if (_conversionPropertyBinder.CanBeParsed(property.PropertyType))
                {
                    bool convertedAsIs = context.Data.ValueAs <string>(property.Name, value => _conversionPropertyBinder.Bind(property, context));
                    if (convertedAsIs)
                    {
                        return;
                    }
                }

                var requests = context.GetEnumerableRequests(property.Name).ToList();

                // TODO -- need an end to end test on this behavior
                if (!requests.Any())
                {
                    return;
                }

                var data = new T[requests.Count];

                for (int i = 0; i < requests.Count; i++)
                {
                    var requestData = requests[i];

                    context.Logger.PushElement(typeof(T));

                    // TODO -- got to add the BindResult to context to store it later
                    context.BindObject(requestData, typeof(T), o =>
                    {
                        data[i] = (T)o;
                    });
                }

                property.SetValue(context.Object, data, null);
            }