MVC Declarative Binding

One of the things that makes the bar to implement any "MVC-ish" pattern high is the tremendous amount of plumbing required just to get started in order for the different entities to communicate state changes. This article introduces a utility library that can be used to declaratively bind the model and view encapsulating all the wiring required and making implementation much easier.

Here's how to consume the library:


The idea is to declaratively bind property and collection change events. I have created two attributes for this: BoundToPropertyAttribute and BoundToCollectionAttribute. We can either define these on an interface the view will implement (which is the usage I prefer) or we can declare the attributes on the concrete view.

public interface IPersonView
{
[BoundToProperty(typeof(Person), "Name")]
String Name { get; set; }

[BoundToCollection(BoundCollectionChangedMethod.AddItems)]
void FriendsAdded(IEnumerable<Person> people);

[BoundToCollection(BoundCollectionChangedMethod.RemoveItems)]
void FriendsRemoved(IEnumerable<Person> people);

[BoundToCollection(BoundCollectionChangedMethod.ResetItems)]
void FriendsReset(IEnumerable<Person> people);
}

See full detail: http://www.c-sharpcorner.com/UploadFile/rmcochran/MVCDeclarativeBinding06072009124427PM/MVCDeclarativeBinding.aspx

Comments

Popular posts from this blog

Very fast test data generation using exponential INSERT

Basic concept and fundamentals of ASP.NET MVC (Model View Controller) Architecture

MVC Architecture Model In ASP.NET