public byte[] Decode(byte[] bytes, byte[] schemaVersion) { EnsureSchemaInitialized(); if (_requireSchemaValidation) { // verify the message can be detected by the underlying schema _schema.Decode(bytes, schemaVersion); } return(bytes); }
public void DataCallback(string message, IPAddress ipaddres) { IDictionary <string, string> DecodedMsg; DecodedMsg = schemaObj.Decode(message, false); string fromIP = DecodedMsg["fromIP"]; string PureMessage = DecodedMsg["Msg"]; string toIP = DecodedMsg["toIP"]; string dateTime = DecodedMsg["dateTime"]; string flag = DecodedMsg["flag"]; /// DateTime DateTime = Convert.ToDateTime(StrDateTime); if (String.Equals("True", flag)) { DataReceiver(PureMessage, toIP, fromIP, dateTime); } else { Connectifier(fromIP, PureMessage); } }
private void TestBytesSchema(ISchema <byte[]> schema) { var data = Encoding.UTF8.GetBytes("hello world"); var serializedData = schema.Encode(data); Assert.Same(data, serializedData); var deserializedData = schema.Decode(serializedData); Assert.Same(data, deserializedData); }
public virtual KeyValue <K, V> Decode(byte[] KeyBytes, byte[] ValueBytes, byte[] SchemaVersion) { K K; if (KeyBytes == null) { K = default(K); } else { if (_keySchema.SupportSchemaVersioning() && SchemaVersion != null) { K = _keySchema.Decode(KeyBytes, SchemaVersion); } else { K = _keySchema.Decode(KeyBytes); } } V V; if (ValueBytes == null) { V = default(V); } else { if (_valueSchema.SupportSchemaVersioning() && SchemaVersion != null) { V = _valueSchema.Decode(ValueBytes, SchemaVersion); } else { V = _valueSchema.Decode(ValueBytes); } } return(new KeyValue <K, V>(K, V)); }