private ICommsMessage _handlePropertySet(object target, ISetPropertyCommsMessage msg) { if (target == null) throw Ex.ArgNull(() => target); if (msg == null) throw Ex.ArgNull(() => msg); if (msg.Type != CommsMessageType.PropertySet) throw Ex.Arg(() => msg, "The message should be a property set comms message"); try { if (target.GetType().GetProperty(msg.PropertyName) == null) { throw new ApplicationException("Property not present on target type"); } target.GetType() .GetProperty(msg.PropertyName) .SetValue(target, msg.Value); return new SetPropertyResultCommsMessage(msg); } catch (Exception ex) { throw new ApplicationException("Failed to process property set message", ex); } }
public SetPropertyResultCommsMessage(ISetPropertyCommsMessage setMessage) : base(CommsMessageType.PropertySetResult) { _setMessage = setMessage; }