...
As many classes require access to the the Manager class instance, removing the singleton instance property meant we now needed to add a Manager property to all our Forms, Dialogs and Business Logic - and provide a way of setting that property.
Our interfaces which are implemented by all our Forms, Dialogs and Business Logic have had a Manager property added:
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaCollection
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaCollectionItem
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaDialog
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaEntity
- JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm
So all classes implementing the above interfaces now have a Manager property also. The We also included in the above interfaces a Setup method. The factories should always be used to create a new instance of any class implementing the above, as the factory will set the Manager property and then invoke the Setup method of the newly instantiated object.
The factories are accessible via properties of the Manager class - these are BusinessLogicFactory, CollectionFactory, CollectionItemFactory, DialogFactory, EntityFactory, FormFactory.
...
Code Block | ||||
---|---|---|---|---|
| ||||
var debtorPrice = Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaInventory.DebtorSpecificInventorySpecific>(); debtorPrice.Debtor.Search(); Inventory.DebtorPrices.Add(debtorPrice); |
Migration Steps
Always use a factory to create an instance of a class implementing any of the following interfaces:
- IJiwaBusinessLogic
- IJiwaCollection
- IJiwaCollectionItem
- IJiwaDialog
- IJiwaEntity
- IJiwaForm
Any classes implementing the above interfaces should not have any reference in their constructor to their Manager property - move that to the Setup method and ensure the first line of code in the overridden Setup method is calling the base Setup method.
Code Block | ||||
---|---|---|---|---|
| ||||
public override void Setup()
{
base.Setup();
_Debtor = Manager.EntityFactory.CreateEntity<JiwaApplication.Entities.Debtor.Debtor>();
} |
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...