コード例 #1
0
        private ICommsMessage _handlePropertyGet(object target, IGetPropertyCommsMessage msg)
        {
            if (target == null) throw Ex.ArgNull(() => target);
            if (msg == null) throw Ex.ArgNull(() => msg);
            if (msg.Type != CommsMessageType.PropertyGet) throw Ex.Arg(() => msg,
                "The message should be a property get comms message");

            try
            {
                if (target.GetType().GetProperty(msg.PropertyName) == null)
                {
                    throw new ApplicationException("Property not present on target type");
                }

                return new GetPropertyResultCommsMessage(msg,
                    target.GetType()
                        .GetProperty(msg.PropertyName)
                        .GetValue(target));
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to process property get message", ex);
            }
        }
コード例 #2
0
 public GetPropertyResultCommsMessage(IGetPropertyCommsMessage propertyGetMessage, object value)
     : base(CommsMessageType.PropertyGetResult)
 {
     _propertyGetMessage = propertyGetMessage;
     _value = value;
 }