Further to issue CQ43837 on Plato's recommendation:
Could you refactor ObjectSpace to make it more extensible and, in particular, to allow it to be subclassed so that it can use UOW descendants. Here are a few suggestions
- Make SetSession protected - to allow UOW descendants
- Wrap all event firing code into dedicated protected virtual On"EventName"(…) methods - best practice
- Make CommitChanges virtual (or make it delegate its functionality to a protected virtual method - to allow additional behaviour to be added for example if we need to enhance how exceptions generated during save are handled.
- I assume, since you plan to support different orm layers at some point, you might want to create IObjectSpace and split ObjectSpace into abstract ObjectSpaceBase and concrete ObjectSpace (i.e. "ObjectSpaceXPO").
Many thanks,
Jascha
A few more observations, you would also need to provide protected access to
objectsToSave
isNewCache
or initialise these in a protected constructor that is called by the other protected / public ones.
OR, continue use of the factory pattern by adding a IUnitOfWorkProvider parameter to ObjectSpace.
I believe everything you need is implemented.