public class CoffeeCodec : TTCN3.Codec { public override TTCN3.TriMessage encode(TTCN3.Value value) { int i; TTCN3.Type type = value.getType(); int typeclass = type.getTypeClass(); if (typeclass == TTCN3.TciTypeClass.INTEGER) { i = ((TTCN3.IntegerValue)value).getInt(); byte[] bytes = Convert.IntToByteArray(i); TTCN3.TriMessage msg = new TTCN3.TriMessage(); msg.setEncodedMessage(bytes); return msg; } else { // should not be reached, signal error TTCN3.CodecSupport.tciErrorReq("unexpected typeclass"); return null; } } public override TTCN3.Value decode (TTCN3.TriMessage message, TTCN3.Type decodingHypothesis) { int typeclass = decodingHypothesis.getTypeClass(); if (typeclass == TTCN3.TciTypeClass.CHARSTRING) { byte[] bytes = message.getEncodedMessage(); string str = Convert.ByteArrayToString(bytes); TTCN3.CharstringValue val = new TTCN3.CharstringValue(); val.setString(str); return val; } else { // should not be reached, signal error TTCN3.CodecSupport.tciErrorReq("unexpected typeclass"); return null; } } }