Пример #1
0
        /// <summary>
        /// User clicked an action.
        /// </summary>
        /// <param name="message"></param>
        public void OnActionEvent(ActionEvent message)
        {
            switch (message.ActionId)
            {
            case "category1.action1":
                //Get data with indexer:
                var data1 = message["category1.action1.data1"] ?? "<null>";
                var data2 = message["category1.action1.data2"] ?? "<null>";
                var data3 = message["category1.action1.data3"] ?? "<null>";
                var data4 = message["category1.action1.data4"] ?? "<null>";
                //Get date with method:
                var data5 = message.GetValue("category1.action1.data5") ?? "<null>";
                var data6 = message.GetValue("category1.action1.data6") ?? "<null>";
                var data7 = message.GetValue("category1.action1.data7") ?? "<null>";
                var data8 = message.GetValue("category1.action1.data8") ?? "<null>";
                _logger?.LogInformation($"[OnAction] PressState: {message.GetPressState()}, ActionId: {message.ActionId}, Data: data1:'{data1}', data2:'{data2}', data3:'{data3}', data4:'{data4}', data5:'{data5}', data6:'{data6}', data7:'{data7}', data8:'{data8}'");
                break;

            default:
                var dataArray = message.Data
                                .Select(dataItem => $"\"{dataItem.Id}\":\"{dataItem.Value}\"")
                                .ToArray();

                var dataString = string.Join(", ", dataArray);
                _logger?.LogInformation($"[OnAction] PressState: {message.GetPressState()}, ActionId: {message.ActionId}, Data: '{dataString}'");
                break;
            }
        }