BindHelper
BindHelper
provides functionality for generating objects on base of some Enum, while binding data contained in enum attributes to corresponding properties of specified objects.
Usage
One of common use cases of this helper is a permission-objects creating objects based on corresponding enumeration.
Let's say we've got some enumeration containing permission items:
It's relatively simple to manage application users permissions in such way, but what to do if some asks to change name or description of permission?
Here comes permission-describing class which instances should be stored in DB. This will provide you with possibility to change their names and descriptions without touching source code:
Last question is how to populate such instances during first DB-seeding or when we have updated application and changed some permission? Here BindHelper
comes to our aid - with it we can do such job in one statement:
This returns the list of Permission
-objects equivalent to:
Bind
allows to specify method which will be used during creation process and populating properties. All other properties values will be taken from BindProperty
attributes marking enum values. BindPropertyAttribute
also allows to specify nested property to bind with using dots in property name. For example "Name.Eng".
Last updated