Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

WinForms-compatible dependency resolution for Model type #24

Closed
wants to merge 9 commits into from
Closed

WinForms-compatible dependency resolution for Model type #24

wants to merge 9 commits into from

Conversation

john-patterson
Copy link

As discussed in the issue I opened, #23 , these are my additions to the framework that allow for easy computed properties on the model. Before, computed properties could not be bound to effectively, because they would never have NotifyPropertyChanged called on them unless you had some strange event-soup to do this.

The framework originally got around this by the [<DerivedProperty>] annotation on the field that, at binding time (when you call Binding.OfExpression) would create a multibinding to tie the property to its dependencies. This works fine, but it is only compatible with WPF.

This commit adds optional syntax for modeling the dependencies of your data directly, so that computed properties get NotifyPropertyChanged when their parents get NotifyPropertyChanged. It does this by hijacking the Abstract & PropertySetter propertyName match in the implementation of IInterceptor.Intercept in Model.fs.

I understand if there is an aversion to duplicate functionality, or if there is an aversion to add features to support WinForms when this is primarily a WPF framework.

john-patterson and others added 9 commits October 4, 2016 15:57
This lets you mark the data dependencies on computed fields of a model.
This hijacks invocations to the setters on the abstract properties of the
models and checks to see if there are any computed fields that depend on
the property being updated. Any children found in this process have
NotifyPropertyChanged called on the model using the child name.
This posits a feature such that if a parent dependency is not a property
and is, instead, itself a derived property, then we can crawl up the chain
and identify the base data dependencies.
This should isolate this logic a bit more instead of having to read an
understand two different functions and expect one to be called before the
other for safety
Should improve performance on subsequent event calls. This is important
when we enter the territory of transitive dependency resolution.
This relies on a mutable .NET List outside of the looping body, but the
logic is really simple. Needs to be converted into something using an
accumulator and a Seq.collect, I think.
Before I was using gross mutations to a .NET List object, but this
implementation uses the F# seq computation expression.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants