添加Encoder、Decoder测试

zw
lch 7 months ago
parent 0adcea06f8
commit 825050bf85

@ -1,6 +1,7 @@
// See https://aka.ms/new-console-template for more information
using System.Collections;
using ConsoleStarter;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Utils;
@ -8,6 +9,67 @@ internal class Program
{
public static void Main(string[] args)
{
TestPerson testPerson = new TestPerson();
testPerson.intParam = 11;
testPerson.intParamNull = 12;
testPerson.uit = 13;
testPerson.byteParam = 2;
testPerson._sb = 3;
testPerson.s = "abcdef";
testPerson.st = -15;
testPerson.ust = 15;
testPerson.I16 = -16;
testPerson.UI16 = 16
;
testPerson.I32 = -32;
testPerson.UI32 = 32;
//testPerson.I64 = -64;
//testPerson.UI64 = 64;
//testPerson.lg = -100;
//testPerson.ulg = 100;
testPerson.ft = 12.11f;
testPerson.de = -12.12d;
// testPerson.de2 = -12.12d;
// testPerson.bl = false;
testPerson.ft2 = -13.126f;
byte[] bytes2 = ModelConvert.Encode(testPerson);
TestPerson testPerson1 = ModelConvert.Declode<TestPerson>(bytes2);
int a = testPerson1.intParam;
int b9 = (int)testPerson1.intParamNull;
uint c = testPerson1.uit;
byte d = testPerson1.byteParam;
byte e = testPerson1._sb;
string f = testPerson1.s;
short a1 = testPerson1.st;
ushort a2 = testPerson1.ust;
Int16 a3 = testPerson1.I16;
UInt16 a4 = testPerson1.UI16;
Int32 b1 = testPerson1.I32;
UInt32 b2 = testPerson1.UI32;
//Int64 b3 = testPerson1.I64;
//UInt64 b4 = testPerson1.UI64;
//long b5 = testPerson1.lg;
//ulong c1 = testPerson1.ulg;
float c2 = testPerson1.ft;
double c3 = testPerson1.de;
//double c6 = testPerson1.de2;
//bool c4 = testPerson1.bl;
float c5 = testPerson1.ft2;
List<PropertyAttribute> list = new List<PropertyAttribute>
{
new(0, 4),
@ -120,7 +182,8 @@ internal class Program
{
queue.Enqueue(new EncodeData()
{
Start = 0, Length = p.Length
Start = 0,
Length = p.Length
});
}
else
@ -153,7 +216,8 @@ internal class Program
{
queue.Enqueue(new EncodeData()
{
Start = occupy, Length = size
Start = occupy,
Length = size
});
}
}

@ -1,40 +1,100 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace ConsoleStarter;
public class TestPerson
{
public int Id { get; set; }
public int? Idn { get; set; }
[PropertyAttribute(0, 4, PropertyReadConstant.Byte)]
public int intParam { get; set; }
[PropertyAttribute(32, 32)]
public int intParamNull { get; set; }
[PropertyAttribute(64, 32)]
public uint uit { get; set; }
public byte b { get; set; }
public sbyte sb { get; set; }
public byte[] bs { get; set; }
[PropertyAttribute(96, 1, PropertyReadConstant.Byte)]
public byte byteParam { get; set; }
//-128-127
[PropertyAttribute(104, 8)]
public byte _sb { get; set; }
[PropertyAttribute(112, 10, PropertyReadConstant.Byte)]
public string s { get; set; }
public string[] ss { get; set; }
[PropertyAttribute(208, 2, PropertyReadConstant.Byte)]
public short st { get; set; }
[PropertyAttribute(224, 2, PropertyReadConstant.Byte)]
public ushort ust { get; set; }
[PropertyAttribute(240, 2, PropertyReadConstant.Byte)]
public Int16 I16 { get; set; }
[PropertyAttribute(256, 2, PropertyReadConstant.Byte)]
public UInt16 UI16 { get; set; }
[PropertyAttribute(272, 4, PropertyReadConstant.Byte)]
public Int32 I32 { get; set; }
[PropertyAttribute(304, 4, PropertyReadConstant.Byte)]
public UInt32 UI32 { get; set; }
public Int64 I64 { get; set; }
public UInt64 UI64 { get; set; }
//[PropertyAttribute(336, 8, PropertyReadConstant.Byte)]
//public Int64 I64 { get; set; }
//[PropertyAttribute(400, 8, PropertyReadConstant.Byte)]
//public UInt64 UI64 { get; set; }
public long lg { get; set; }
public ulong ulg { get; set; }
[Property(start:2, length:4)]
//[PropertyAttribute(336, 8, PropertyReadConstant.Byte)]
//public long lg { get; set; }
//[PropertyAttribute(400, 8, PropertyReadConstant.Byte)]
//public ulong ulg { get; set; }
[PropertyAttribute(336, 2, PropertyReadConstant.Byte, 0.01, 2)]
public float ft { get; set; }
[PropertyAttribute(352, 4, PropertyReadConstant.Byte, 0.001,3)]
public double de { get; set; }
public bool bl { get; set; }
public bool[] bls { get; set; }
[PropertyAttribute(384, 4, PropertyReadConstant.Byte, 0.1, 2)]
public float ft2 { get; set; }
//[PropertyAttribute(416, 8, PropertyReadConstant.Byte, 0.01, 2)]
//public double de2 { get; set; }
//[PropertyAttribute(416, 1)]
//public bool bl { get; set; }
//[PropertyAttribute(0, 32)]
//public byte[] bs { get; set; }
//[PropertyAttribute(0, 32)]
//public string[] ss { get; set; }
}

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup />
</Project>
Loading…
Cancel
Save