Example #1
0
        public void Deserialize(MessageParameterDirection direction, Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
                foreach (var property in direction == MessageParameterDirection.Request ? this.inputProperties : this.outputProperties)
                {
                    this.Deserialize(reader, property, direction == MessageParameterDirection.Request ? this.Request : this.Response);
                }
        }
Example #2
0
        protected long BindResponse(object source, MessageParameterDirection direction)
        {
            if (source == null)
            {
                return(ResponseCode.ObjectNotFound);
            }

            if (this.boundProperties == null)
            {
                this.boundProperties = MessageHandler.GetPropertiesToBind(source.GetType(), direction == MessageParameterDirection.Request ? this.inputProperties : this.outputProperties);
            }

            foreach (var p in this.boundProperties)
            {
                p.Parameter.Property.SetValue(this, Convert.ChangeType(p.Property.GetValue(source), p.Property.PropertyType, CultureInfo.InvariantCulture));
            }

            return(ResponseCode.Success);
        }