CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Custom ISerializationFormatter Feature Request

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 5 Replies | 2 Followers

    Not Ranked
    5 Posts
    Brett Janer posted on Thu, May 14 2015 4:13 PM

    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?

    Answered (Verified) Verified Answer

    Top 10 Contributor
    9,475 Posts

    https://github.com/MarimerLLC/csla/issues/361

     

     

    Rocky

    All Replies

    Top 10 Contributor
    2,279 Posts
    JonnyBee replied on Fri, May 15 2015 12:47 AM

    Hi,

    Did you look at the MobileFormatter and its supported formatters? 

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    5 Posts

    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.

    Top 10 Contributor
    9,475 Posts

    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.

    Rocky

    Not Ranked
    5 Posts

    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.

    Top 10 Contributor
    9,475 Posts

    https://github.com/MarimerLLC/csla/issues/361

     

     

    Rocky

    Page 1 of 1 (6 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems