private RawMessage <TRaw> GetFormattedMessage(WampMessage <object> message) { RawMessage <TRaw> result = message as RawMessage <TRaw>; if (result == null) { result = new RawMessage <TRaw>(message); result.Raw = mParser.Format(message); } return(result); }
private RawMessage <TRaw> GetFormattedMessage(WampMessage <object> message) { if (!(message is RawMessage <TRaw> result)) { result = new RawMessage <TRaw>(message); result.Raw = mParser.Format(message); if (ComputeBytes == true) { result.Bytes = mParser.GetBytes(result.Raw); } } return(result); }
public static byte[] GetBytes <TMessage, TRaw>(this IWampMessageParser <TMessage, TRaw> parser, WampMessage <object> message) { if (message is RawMessage <TRaw> rawMessage && rawMessage.Bytes != null) { return(rawMessage.Bytes); } else { TRaw raw = parser.Format(message); byte[] binary = parser.GetBytes(raw); return(binary); } }