ITaskAction.cs 2.0 KB
Newer Older
麦壳饼's avatar
麦壳饼 已提交
1 2 3 4 5
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Dynamic;

W
wq1234wq 已提交
6

麦壳饼's avatar
麦壳饼 已提交
7 8 9 10
namespace IoTSharp.TaskAction
{
    public interface ITaskAction
    {
麦壳饼's avatar
麦壳饼 已提交
11
        public TaskActionOutput Execute(TaskActionInput _input);
麦壳饼's avatar
麦壳饼 已提交
12 13 14 15 16 17 18
    }

    public class TaskActionOutput
    {
        private string _value;
        private dynamic _DynamicOutput;
        private readonly ExpandoObjectConverter expConverter = new();
19
        public Guid DeviceId { get; set; }
W
wq1234wq 已提交
20 21
        public bool ExecutionStatus { get; set; }
        public string ExecutionInfo { get; set; }
麦壳饼's avatar
麦壳饼 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
        public dynamic DynamicOutput
        {
            get
            {
                return _DynamicOutput;
            }
            set
            {
                _DynamicOutput = value;
                _value = JsonConvert.SerializeObject(_DynamicOutput, expConverter);
            }
        }

        public string Output
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
                _DynamicOutput = JsonConvert.DeserializeObject<ExpandoObject>(_value, expConverter);
            }
        }
    }

49
    public class TaskActionInput
麦壳饼's avatar
麦壳饼 已提交
50
    {
51 52 53
        private dynamic _DynamicOutput;
        private string _value;
        private readonly ExpandoObjectConverter expConverter = new();
麦壳饼's avatar
麦壳饼 已提交
54
        public Guid  DeviceId { get; set; }
W
wq1234wq 已提交
55
        public String ExecutorConfig { get; set; }
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        public dynamic DynamicInput
        {
            get
            {
                return _DynamicOutput;
            }
            set
            {
                _DynamicOutput = value;
                _value = JsonConvert.SerializeObject(_DynamicOutput, expConverter);
            }
        }

        public string Input
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
                _DynamicOutput = JsonConvert.DeserializeObject<ExpandoObject>(_value, expConverter);
            }
        }
麦壳饼's avatar
麦壳饼 已提交
81 82
    }
}