I'll work with the assumption that you want this class to be immutable.
If you want "true" immutability, you will need to stick with the constructor arguments, since the constructor is the only piece of code that can set a readonly
field.
However, you can also just implement public getters and private setters. For all intents and purposes that makes the object immutable too. You'd set the private fields in a static factory(ish) method.
In this example I assume the RFID data arrives at your application in a stream, but you could easily modify this to work with a byte array, series of structs, XML, whatever.
class RFIDMessage
{
private string _a;
private string _b;
private string _c;
//etc
private RFIDMessage()
{
//Declare privatedefault constructor soprivate onlyso thenobody classelse can instantiate itselfan RFIDMessage on their own
}
static public RFIDMessage FromStream(Stream stream)
{
var reader = new RFIDStreamReader(stream);
var newObject -= new RFIDMessage();
newObject._a = reader.ReadA();
newObject._b = reader.ReadB();
//etc.
return newObject;
}
}
void SampleUsage()
{
var rfidStream = RFIDAPI.GetStream(); //Or whatever
varRFIDMessage message = RFIDMessage.FromStream(rfidStream);
}
I don't know the name of this pattern, but it is common in the .NET CLR, e.g. FromBase64String.