User Defined Calculated FieldsIt is possible to define your own calculated fields if your protocol has some sort of calculation that is not supported out of the box by the MessageSerializer. In general, to have your own calculated field type you would need to do the following:
ExampleThe example being used here is a bit contrived but the calculation we are going to do with this made up protocol will have the following rules:
Our example message will be: For this message:
The first thing we need to do to implement this is create our Calculator: At this point we could actually define our class using the standard While it is possible to use the existing attributes as above, if they have to be added for every single message in the protocol the To make things easier we define our own attributes for this particular scenario: You can see that defining the attributes is quite easy, the big thing is creating your own The new attributes are much cleaner than our old attributes. However, since the theory behind our example is that all the messages in this protocol
have the To use our new
Then our class can be defined without any attributes: |