Пример #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);
        }
Пример #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);
            }
        }
Пример #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);
        }
Пример #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));
        }