From c5d4b9ab4a5d7bf43e175db2db594ccd0a409494 Mon Sep 17 00:00:00 2001 From: Jeremy Miller Date: Mon, 9 Apr 2012 09:49:09 -0500 Subject: [PATCH] model binding fixes uncovered doing integration with Surgery Logistics system --- src/FubuCore/Binding/ArrayPropertyBinder.cs | 4 ++++ src/FubuCore/Binding/InMemory/RecordingBindingLogger.cs | 2 +- src/FubuCore/Binding/Logging/BindingReport.cs | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/FubuCore/Binding/ArrayPropertyBinder.cs b/src/FubuCore/Binding/ArrayPropertyBinder.cs index f57d5fa..65aaef4 100644 --- a/src/FubuCore/Binding/ArrayPropertyBinder.cs +++ b/src/FubuCore/Binding/ArrayPropertyBinder.cs @@ -43,6 +43,10 @@ public class ArrayBuilder : IArrayBuilder public void FillValues(PropertyInfo property, IBindingContext context) { 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++) diff --git a/src/FubuCore/Binding/InMemory/RecordingBindingLogger.cs b/src/FubuCore/Binding/InMemory/RecordingBindingLogger.cs index 6be7031..b785c1a 100644 --- a/src/FubuCore/Binding/InMemory/RecordingBindingLogger.cs +++ b/src/FubuCore/Binding/InMemory/RecordingBindingLogger.cs @@ -91,7 +91,7 @@ public void UsedValue(BindingValue value) { if (_models.Any()) { - currentReport.LastProperty.Used(value); + currentReport.Used(value); } } diff --git a/src/FubuCore/Binding/Logging/BindingReport.cs b/src/FubuCore/Binding/Logging/BindingReport.cs index 7d17ba6..3f0b722 100644 --- a/src/FubuCore/Binding/Logging/BindingReport.cs +++ b/src/FubuCore/Binding/Logging/BindingReport.cs @@ -94,5 +94,14 @@ public PropertyBindingReport For(Expression> expression) var property = expression.ToAccessor().InnerProperty; return For(property); } + + // TODO -- what if Value() is used outside the context of a property? + public void Used(BindingValue value) + { + if (_properties.Any()) + { + LastProperty.Used(value); + } + } } } \ No newline at end of file