Esempio n. 1
0
        /// <summary>
        /// Deserialize data from the parameters with the provided configuration.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Deserialized message</returns>
        /// <exception cref="System.FormatException">
        /// </exception>
        public override IMessage Deserialize(MessageSinkParameters parameters)
        {
            if (parameters == null)
            {
                ThrowHelper.ThrowArgumentNullException("parameters");
            }
            if ((parameters.ConfigurationToDeserialize as MessageSinkConfiguration) == null)
            {
                throw new FormatException(string.Format("Configuration class type is not {0}", typeof(MessageSinkConfiguration).FullName));
            }

            IMessage result = null;

            try
            {
                MessageSinkConfiguration config = (MessageSinkConfiguration)parameters.ConfigurationToDeserialize;
                using (MemoryStream ms = new MemoryStream(config.DecompressData ? Decompress(parameters.SerializedData) : parameters.SerializedData))
                {
                    ms.Position = 0;
                    result      = mFormatter.Read(ms);
                }
            }
            catch (Exception ex)
            {
                throw new FormatException(ex.Message, ex);
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (!obj.GetType().Equals(GetType()))
            {
                return(false);
            }

            MessageSinkConfiguration other = (MessageSinkConfiguration)obj;

            return(other.MessageSinkId == MessageSinkId && other.DecompressData.Equals(DecompressData));
        }