KnowHoper
KnowHoper

Reputation: 4622

Microsoft Bond System.Object

I need to ensure the following class is serializable by Microsoft Bond. I am struggling to find a way to do this due to the inclusion of the object member.

  public class BondRemotingRequestMessageBody : IServiceRemotingRequestMessageBody
  {

    public object Value;

    public BondRemotingRequestMessageBody()
    {
    }

    public BondRemotingRequestMessageBody(int parameterInfos)
    {

    }

    public void SetParameter(int position, string paramName, object parameter)
    {
      Value = parameter;
    }

    public object GetParameter(int position, string paramName, Type paramType)
    {
      return Value;
    }
  }

Is there a way around this?

This is for an Azure Service Fabric ASR implementation.

Thanks in advance.

Upvotes: 0

Views: 167

Answers (1)

chwarr
chwarr

Reputation: 7202

I don't know about the Service Fabric parts, but from a Bond perspective, all of the fields that are to be serialized must be known to Bond and must be a type (or convertible to a type) that can be serialized. In practice, this means that all of the data structures that you need to serialize is expressed in a collection of .bond files.

The closest to C#'s object would be a bonded<bond.Void> field that you later deserialize as the proper well-known derived type. You would need to include (or be able to infer/derive) the correct derived type. The polymorphic container example demonstrates this pattern; it uses an enum field in a base struct to carry the derived type information.

Upvotes: 1

Related Questions