I'd like to see the ISerializationFormatter feature extended to allow applying my own implementation. Being able to specify the type in the app.config/web.config similarly to how you provide a custom WcfProxy or DataPortalActivator would be perfect for me. My current problem requires me to provide the BinaryFormatter with a custom SerializationBinder. This feature would make this a lot easier. Has this idea been tossed around at all?
Did you look at the MobileFormatter and its supported formatters?
Thanks JonnyBee for your reply!
I have looked at the MobileFormatter and I don't believe it provides the extension points I need, even if I implemented my own ICslaWriter and ICslaReader. Basically I have my own custom SerializationBinder which I need to apply to the BinaryFormatter. This represents my custom formatter. I have created by own WcfProxy and DataPortal so I've been able to apply my custom formatter there. I've overridden GetClone in my BusinessBases as well. However not sure how to provide my custom formatter to the UndoableBase for the n-level undo feature. The further I dig, the more it seems I need this feature.
This has not been tossed around at all.
Creating a serialized that actually works (does deserialization properly - that's the hard part) is really hard, and you are perhaps the third person to bring up the desire to do so at all.
(fwiw, the first two people said "this is easy", I warned them it was hard, then they disappeared never to be heard from again - so I'm guessing the effort broke them :) )
I obviously haven't put any thought or analysis into how difficult it would be to allow the use of a custom type, but I imagine the changes to CSLA would be relatively small. The risk to someone providing such a type would be high, but could be mitigated through extensive testing of cloning complex object graphs, just like we do with MobileFormatter.
In other words, if this is highly important to you, and can be done with minimal change/risk to CSLA itself, I would consider accepting a pull request along this line.
I completely agree. Writing my own serialization/deserialization code would be hard and I have no interest in doing so. I simply want to provide the BinaryFormatter with a custom implementation of a SerializationBinder. SerializationBinder is a abstract class in BCL that has one abstract method, BindToType to aid in deserialization. The way you apply a custom binder to a formatter is as follows:
var formatter = new BinaryFormatter();
formatter.Binder = new MyCustomBinder();
However, since CSLA controls the object initialization of its formatter, I'm unable to supply my custom binder. So from a framework standpoint, I'd figured there would be more use cases for customizing the whole formatter, instead of just allowing a custom binder. I'll start digging in to see how much work the change to CSLA would be. If its simple enough, I'll send a pull request for review.
Copyright (c) Marimer LLC