示例#1
0
        public void NoError()
        {
            string value = "ee";
            var    model = TextConvert.Deserialize <SimpleModel2>(value);

            Assert.Equal(value, model.Prop1);
        }
示例#2
0
        private void TsmItemTextCleaner_Click(object sender, EventArgs e)
        {
            var frm = new TextConvert();

            if (!CheckOpened("TextConvert"))
            {
                frm.Show();
            }
        }
示例#3
0
        public void ConvertWithoutBasemodel()
        {
            string value   = "orange|blue|red|true|012|239";
            var    @object = TextConvert.Deserialize <ModelTestWithOutBasemodel>(value);

            Assert.Equal("orange", @object.Prop1);
            Assert.Equal("red", @object.Prop2);
            Assert.True(@object.Prop3);
            Assert.Equal(12, @object.Prop4);
            Assert.Equal(239, @object.Prop5);
        }
示例#4
0
        public MyEvent Deserialize(byte[] value)
        {
            string data = TextConvert.ToUTF8String(value);

            if (!int.TryParse(data, out int status))
            {
                status = -1;
            }

            return(new MyEvent {
                Status = status
            });
        }
示例#5
0
        public StatusChanged Deserialize(byte[] body)
        {
            var actin = TextConvert.ToUTF8String(body);

            if (!int.TryParse(actin, out int value))
            {
                value = -1;
            }

            return(new StatusChanged {
                Value = value
            });
        }
示例#6
0
        public StateChanged Deserialize(byte[] body)
        {
            string data = TextConvert.ToUTF8String(body);

            if (!int.TryParse(data, out int value))
            {
                value = -1;
            }

            return(new StateChanged {
                Value = value
            });
        }
        public ChangeNodeState Deserialize(byte[] body)
        {
            var data = TextConvert.ToUTF8String(body);

            var strNodeId = data.Substring(0, data.Length - 1);

            if (!int.TryParse(strNodeId, out int nodeId))
            {
                return(null);
            }

            var strActionType = data.Substring(data.Length - 1);

            if (!int.TryParse(strActionType, out int actionType))
            {
                return(null);
            }

            return(new ChangeNodeState {
                NodeId = nodeId, ActionType = actionType
            });
        }
示例#8
0
 private void btnConvert_Click(object sender, EventArgs e)
 {
     txtDesti.Text = TextConvert.PostManTestJsonConvert(txtOri.Text, txtNewObjectName.Text);
 }
 public byte[] Serialize(ChangeNodeState @event)
 => TextConvert.ToUTF8ByteArray($"{@event.NodeId}{@event.ActionType}");
 public virtual byte[] Serialize(string value) => TextConvert.ToUTF8ByteArray(value);
 public virtual string Deserialize(byte[] value) => TextConvert.ToUTF8String(value);
示例#12
0
        public byte[] Serialize(StateChanged @event)
        {
            string data = @event.Value.ToString();

            return(TextConvert.ToUTF8ByteArray(data));
        }
示例#13
0
        public byte[] Serialize(MyEvent value)
        {
            string data = string.Format($"{value.Status}{value.Status}");

            return(TextConvert.ToUTF8ByteArray(data));
        }
        public byte[] Serialize(T value)
        {
            var data = JsonConvert.SerializeObject(value);

            return(TextConvert.ToUTF8ByteArray(data));
        }
示例#15
0
 public byte[] Serialize(StatusChanged @event)
 => TextConvert.ToUTF8ByteArray(Convert.ToString(@event.Value));
        public T Deserialize(byte[] value)
        {
            string data = TextConvert.ToUTF8String(value);

            return(JsonConvert.DeserializeObject <T>(data));
        }
示例#17
0
        public void Error()
        {
            string value = "ee";

            _ = Assert.Throws <ArgumentOutOfRangeException>(() => TextConvert.Deserialize <SimpleModel>(value));
        }