public override Reply Run <T>(ControlsStorage <T> controls, IDictionary <string, dynamic> args) { CheckParamExists(args, "element_id"); CheckValidControlId <T>(args["element_id"], controls); object c = controls.GetControl(args["element_id"]); DynamicValueReply reply = new DynamicValueReply(c.GetType().Name); return(reply); }
protected void CheckValidControlId <T>(dynamic id, ControlsStorage <T> controls) where T : class { if (id < 0) { throw new ErrorReplyException(ErrorCodes.INVALID_VALUE, "invalid element id (should be >= 0)"); } if (controls != null) { if (id < 1) { throw new ErrorReplyException(ErrorCodes.INVALID_VALUE, "invalid element id (should be >= 1)"); } if (controls.GetControl(id) == null) { throw new ErrorReplyException(ErrorCodes.NOT_FOUND, "element not found with ID: " + id); } } }