It may be a way out of the left field, crazy, but I just need to ask before I start implementing this massive set of classes.
Basically, I am writing a parser message analyzer that decodes a specific format of a military message into an object. The problem is that there are literally hundreds of different types of messages, and they have almost nothing in common with each other. Thus, I plan to implement this to create hundreds of different objects.
However, although the message attributes have nothing in common, the method for decoding them is quite simple and follows the pattern. Therefore, I plan to write a code generator to generate all objects and decoding logic for each type of message.
That would be very nice if there was some way to dynamically create an object based on some kind of scheme. It doesn't have to be XML, but XML is pretty easy to work with.
Is this possible in C #?
I would like the interface to look something like this:
var decodedMessage = MessageDecoder.Decode(byteArray);
If MessageDecoder determines what type of message it has, then returns the corresponding object. It will probably return an interface that implements the MessageType property or something like that.
Basically, I am wondering if there is a way to have one object named Message that implements the MessageType property. And then Depending on the type of MessageType, the Message object is converted to any type of message, so I do not need to spend time creating all these types of messages.
source share