Beispiel #1
0
        /// <summary>
        ///     Tries the deserialize XML.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="messageBytes">The message bytes.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        private bool TryDeserializeXml(string channel, byte[] messageBytes, out RedisMessage message)
        {
            string messageText = Encoding.UTF8.GetString(messageBytes);

            Match match = PayloadRegex.Match(messageText);

            if (match.Success)
            {
                message = new RedisMessage(channel, GetEncodedRegexGroupArgument <string>(match, "mac"), GetEncodedRegexGroupArgument <string>(match, "pro"), GetEncodedRegexGroupArgument <int>(match, "proId"), GetEncodedRegexGroupArgument <string>(match, "app"), GetEncodedRegexGroupArgument <int>(match, "appId"), new DateTime(GetEncodedRegexGroupArgument <long>(match, "dt")), messageText.Length, -1, GetEncodedRegexGroupArgument <string>(match, "dat"));
                return(true);
            }

            message = null;
            return(false);
        }
Beispiel #2
0
        /// <summary>
        ///     Tries the deserialize binary.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="messageBytes">The message bytes.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        private bool TryDeserializeBinary(string channel, byte[] messageBytes, out RedisMessage message)
        {
            try
            {
                using (var stream = new MemoryStream(messageBytes))
                {
                    switch (channel)
                    {
                    case "Entity":
                        message = Deserialize <EntityCacheMessage>(stream, channel);
                        return(true);

                    case "EntityField":
                        message = Deserialize <EntityFieldCacheMessage>(stream, channel);
                        return(true);

                    case "FieldEntity":
                        message = Deserialize <FieldEntityCacheMessage>(stream, channel);
                        return(true);

                    case "EntityRelationship":
                        message = Deserialize <EntityRelationshipCacheMessage>(stream, channel);
                        return(true);

                    case "Profiling":
                        message = Deserialize <string>(stream, channel);
                        return(true);
                    }
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }

            message = null;
            return(false);
        }
Beispiel #3
0
        private bool TryDeserializeBinaryByChannelName(string channel, byte [] messageBytes, out RedisMessage message)
        {
            try
            {
                using (var stream = new MemoryStream(messageBytes))
                {
                    if (channel.StartsWith("channel|LocalQueue"))
                    {
                        message = Deserialize <ListeningQueueMessage>(stream, channel);
                        return(true);
                    }
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }

            message = null;
            return(false);
        }