FINAL EDIT/SOLUTION
So after some thinking, this is now the final code for EDIT: I have extracted the HazenTask
class..to another method to remove the abstract
/base
classresponsibility of the TideDeviceset
staysaccessor. But I'm still in a roadblock on fixing the samecode smell I initially stated. I editted the code to reflect what I have now.
internal Hazen(IRawDataReceiver rawDataReceiver) : base(rawDataReceiver)
{
_serialPortConnection = rawDataReceiver as SerialPortConnection;
}
[DataMember] private SerialPortConnection _serialPortConnection;
[OnDeserialized] private void OnDeserialized(StreamingContext sc)
{
RawDataReceiver = _serialPortConnection;
}
So as you can see, the [OnDeserialized]
method will act as theEDIT2: This code is working really fine whether in constructorunit test
afterand deserializationintegration test
. Or more specifically, it mimics the base(rawDataReceiver)
part of "actual" `constructor'
That'sso I'll leave it. Thanks @jeyoung and @JNS as is until someone points out that there is something wrong here or until a problem arises. Thank you very much!