design problem (binary parser)
I'm currently
writing a part of an application which must translate a sequence of
bytes (read from a network connection) into an object instance. The
whole sequence is considered as a unique value, except for the first 2
bytes which identify the type of the value (numeric, string, or
structured), and how the value should be parsed (the value itself can
eventually be a list of values).
I was thinking of inheriting from
System.IO.BinaryReader for the parser (using a System.IO.MemoryStream
for the byte sequence), having an abstract base class for the sequence
content representation (class ContentBase), and different concrete
classes which inherit from ContentBase (for example ContentInteger,
ContentString, ContentListString, etc).
However, I can't figure how
to combine those elements to produce the correct object instance and then
parse the sequence the right way (maybe a known design pattern that I'm
missing?)... any suggestion would be appreciated :-)
thanks in advance

