You are creating a custom activity named SocketActivity by using Microsoft .NET Framework 3.5. You use Windows Workflow Foundation to create the custom activity.
The custom activity is derived from the System.Workflow.ComponentModel.Activity class. The activity includes the following field definition.
[NonSerialized]
private Socket _socket = null;
The custom activity might enter the idle state during execution. When it enters the idle state, the activity is serialized and unloaded by a persistence service.
You need to ensure that the _socket field is initialized each time the custom activity executes.
Which code segment should you use?
A.
public SocketActivity(){ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);}
B.
protected override void InitializeProperties(){ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); base.InitializeProperties();}
C.
protected override void Initialize(IServiceProvider provider){ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); base.Initialize(provider);}
D.
protected override void OnActivityExecutionContextLoad(IServiceProvider provider){ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); base.OnActivityExecutionContextLoad(provider);}