mardi 5 mai 2015

CSLA/ReactiveUI serialization issue

I'm attempting to use CSLA (latest version) along with ReactiveUI/Reactive Extensions.

When creating the WPF bindings using reactiveUI (Bind/OneWayBind) and using the ToProperty methods, it appears that the underlying logic uses the Rx Observable.FromEventPattern to hook into the model's PropertyChanged events in CSLA's BindableBase.

The problem that is occurring is that CSLA believes that these handlers should be serializable.

This is determined by the code in BindableBase,

if (value.Method.IsPublic && 
       (value.Method.DeclaringType.IsSerializable || 
        value.Method.IsStatic))
      _serializableChangedHandlers = (PropertyChangedEventHandler)
        System.Delegate.Combine(_serializableChangedHandlers, value);
    else
      _nonSerializableChangedHandlers = (PropertyChangedEventHandler)
        System.Delegate.Combine(_nonSerializableChangedHandlers, value);

In this situation, the method is an anonymous delegate created within reactive extensions where the value.Method is public and the value.Method.DeclaringType is System.Action`2[[System.Object], System.ComponentModel.PropertyChangedEventArgs]] which has IsSerializable == true

This causes the handler to be added to the serializable list.

Any suggestions on what I might be able to do to have these handlers not be added to the serializable handlers?

Aucun commentaire:

Enregistrer un commentaire