Fabio replied on Sunday, September 24, 2006
Hola Andres... cuando vamos a tomar esa cerveza?
Well... now something serious..
xal:
Even if something like that doesn't make it into the framework, you could just implement that in your own base class and inherit your BOs from that (I know I'm just stating the obvious).
Yes... you know that i have something like 3 class before a concrete BO...
To the point:
Suppose that you are a freelancer and that you don't know who, when and for what somebody use the BO you have implement. Now suppose that I'm a user of your BO.
I had see a class on your assembly and i think i can use that class for something (note: i use PTracker and I know PT is only an example).
Like user of your class i can write this code:
ProjectTracker.Library.ResourceList rl = ProjectTracker.Library.ResourceList.GetResourceList();
rl.AllowEdit = true;
rl.AllowNew = true;
rl.AllowRemove = true;
ProjectTracker.Library.ResourceInfo ri = rl.AddNew();
I can copile the code and, at run time, i recive an exception for AddNew.
So, IsReadOnly is protected but the other properties are some confused.... i can't set IsReadOnly but i can set AllowRemove and so on.
For Binding matter I, like user of your class, can set AllowEdit, and so on, and if I use an ObjectBinding navigator the buttons for adding, removing and editing a BO are enabled... this mean that you give me the option to have a "hunts the joker" effect in the front-end.
"hunts the joker" mean that the operator (user of the application) can click the add button and the action send him the message "you can't add!!".These matters are only for preventing, an improper use of BO, at copile-time.
If you look on chapter 7 you can find
public static bool CanAddObject()All "public static" method, mean that the user of your class can't use a BindingSource directly but he need prevent "hunts the joker" using specific methods... (you are optimistic, and your user must write some more code). Remember that the
AddNew method is public in the BindingList and you can write a BoEditableList overriding
AddNewCore and the user (user of your class) can use a BindingSource with Navigator and a grid (for example) without write "special" code to add new item.
xal:
The locking of getting items sounds interesting... Where would you use it and why?
I think that we can prevent something using the
new modifier and, the implementation, can enable Rocky ("the Rock") to give us a standard
per type rules for collection too (without the necessity to use static methods)
for all BOLists
.
I would like to have something more, like a IAuthorizationProvider and IBrokenRuleProvider to inject (by config or an IoC FW ;) ) a class to read Authorization and Rules from XML, DB and so on.... but this is another matter (step-by-step).
Bye
Fabio.
P.S. When i have an idea i post it, then
the Rock maximize it.