Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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));
        }