NanoByte.Common
2.6.1
|
Keeps two collections of different types in sync based on mapping rules. More...
Public Member Functions | |
ModelViewSync (MonitoredCollection< TModel > model, ICollection< TView > view) | |
Creates a new Model-View synchronizer. More... | |
void | Initialize () |
Must be called once, after all relevant mapping rules have been registered. More... | |
void | Dispose () |
TModel | Lookup (TView representation) |
Looks up the Model element a View representation was created for. More... | |
void | RegisterMultiple< TSpecificModel, TSpecificView > (Func< TSpecificModel, IEnumerable< TSpecificView >> create, Action< TSpecificModel, TSpecificView >? update=null) |
Registers a mapping rule for a specific type of Model element. More... | |
void | Register< TSpecificModel, TSpecificView > (Func< TSpecificModel, TSpecificView > create, Action< TSpecificModel, TSpecificView >? update=null) |
Registers a mapping rule for a specific type of Model element. More... | |
Properties | |
IEnumerable< TView > | Representations [get] |
All View representations created by the synchronizer. More... | |
Keeps two collections of different types in sync based on mapping rules.
TModel | The common base type of elements in the model. |
TView | The common base type of representations in the view. |
Useful for maintaining View representations for a set of mutable Model elements in a Model-View-Controller/Presenter design. Generated View representations will automatically be disposed on removal, if they implement IDisposable.
TModel | : | class | |
TModel | : | IChangeNotify<TModel> | |
TView | : | class |
|
inline |
Creates a new Model-View synchronizer.
model | The Model that can change on its own accord. |
view | The View that is to be automatically updated to reflect changes in the Model. |
|
inline |
Must be called once, after all relevant mapping rules have been registered.
TModel NanoByte.Common.Dispatch.ModelViewSync< TModel, TView >.Lookup | ( | TView | representation | ) |
Looks up the Model element a View representation was created for.
KeyNotFoundException | There is no match. |
|
inline |
Registers a mapping rule for a specific type of Model element.
create | Callback that creates a View representation for a given Model element. |
update | Callback that updates a View representation based on the state of a given Model element; can be null . |
TSpecificModel | : | class | |
TSpecificModel | : | TModel | |
TSpecificView | : | class | |
TSpecificView | : | TView |
|
inline |
Registers a mapping rule for a specific type of Model element.
create | Callback that creates a set of 0..n View representations for a given Model element. |
update | Callback that updates a specific View representation based on the state of a given Model element; can be null . |
TSpecificModel | : | class | |
TSpecificModel | : | TModel | |
TSpecificView | : | class | |
TSpecificView | : | TView |
|
get |
All View representations created by the synchronizer.