Xaf provides methods in your controllers to enable you to customize the types that is using. I am speaking about the CustomizeTypesInfo method
The thing is that using such decoupled approach can be very dangerous and resource consuming.
Take the following example .
Say you have 10 classes and you want to customize 2 of them . You also want to decouple the customization logic.
Then you probably write one controller like
and another one like
the decoupling you wanted has as result to force the CLR to enumerate your typesInfo.PersistentTypes twice in order to apply your logic. And if you put that in real world your classes may be 500 and your logics 1000 that means 500x500 to apply 1000 logics!!! Its a big number and can slow you down for sure
Luckily that Xaf architecture can help us once more here!!! And to those that guess it already i am again speaking about the powerfull XafTypesInfo system.
So how to design the above to get max performance?
1st create 2abstract classes likethen create 2 more classes for implementing your logics
and final step one controller that can handle all logics.
That way your logic still remain decoupled at LogicRegistrator descenants and you not have to enumarate all persistent classes for each one of them.
ps: I did not calculate how much faster that would be cause the post was about simple maths :)
To be continued….