CodeWF.NetWeaver 1.3.0

dotnet add package CodeWF.NetWeaver --version 1.3.0                
NuGet\Install-Package CodeWF.NetWeaver -Version 1.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeWF.NetWeaver" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeWF.NetWeaver --version 1.3.0                
#r "nuget: CodeWF.NetWeaver, 1.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeWF.NetWeaver as a Cake Addin
#addin nuget:?package=CodeWF.NetWeaver&version=1.3.0

// Install CodeWF.NetWeaver as a Cake Tool
#tool nuget:?package=CodeWF.NetWeaver&version=1.3.0                

CodeWF.NetWeaver

CodeWF.NetWeaver 是一个简洁而强大的C#库,用于处理TCP和UDP数据包的组包和解包操作。

定义数据包如下(来自单元测试CodeWF.NetWeaver.Tests),ResponseProcessList类继承自INetObject, NetHead配置数据包标识和版本

[NetHead(10, 1)]
public class ResponseProcessList : INetObject
{
    public int TaskId { get; set; }

    public int TotalSize { get; set; }

    public int PageSize { get; set; }

    public int PageCount { get; set; }

    public int PageIndex { get; set; }

    public List<ProcessItem>? Processes { get; set; }
}

public record ProcessItem
{
    public int Pid { get; set; }

    public string? Name { get; set; }

    public byte Type { get; set; }

    public byte ProcessStatus { get; set; }

    public byte AlarmStatus { get; set; }

    public string? Publisher { get; set; }

    public string? CommandLine { get; set; }

    public short Cpu { get; set; }

    public short Memory { get; set; }

    public short Disk { get; set; }

    public short Network { get; set; }

    public short Gpu { get; set; }

    public byte GpuEngine { get; set; }

    public byte PowerUsage { get; set; }

    public byte PowerUsageTrend { get; set; }

    public uint LastUpdateTime { get; set; }

    public uint UpdateTime { get; set; }
}

单元测试数据组包与解包:

[Fact]
public void Test_SerializeResponseProcessList_Success()
{
    var netObject = new ResponseProcessList
    {
        TaskId = 3,
        TotalSize = 200,
        PageSize = 3,
        PageCount = 67,
        PageIndex = 1,
        Processes = new List<ProcessItem>()
    };
    var processItem = new ProcessItem
    {
        Pid = 1,
        Name = "CodeWF.NetWeaver",
        Type = (byte)ProcessType.Application,
        ProcessStatus = (byte)ProcessStatus.Running,
        Publisher = "沙漠尽头的狼",
        CommandLine = "dotnet CodeWF.com",
        Cpu = 112,
        Memory = 325,
        Disk = 23,
        Network = 593,
        Gpu = 253,
        GpuEngine = (byte)GpuEngine.None,
        PowerUsage = (byte)PowerUsage.Low,
        PowerUsageTrend = (byte)PowerUsage.Low,
        LastUpdateTime = 23,
        UpdateTime = 53
    };
    netObject.Processes.Add(processItem);

    var buffer = netObject.Serialize(32);
    var desObject = buffer.Deserialize<ResponseProcessList>();

    Assert.Equal(netObject.TotalSize, desObject.TotalSize);
    Assert.NotNull(desObject.Processes);
    Assert.Equal(processItem.Cpu, desObject.Processes[0].Cpu);
    Assert.Equal(processItem.LastUpdateTime, desObject.Processes[0].LastUpdateTime);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CodeWF.NetWeaver:

Package Downloads
CodeWF.EventBus.Socket

Distributed event bus implemented using Socket, independent of third-party MQ.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 273 9/21/2024
1.2.1 99 9/19/2024
1.2.0 112 9/19/2024
1.1.1.1 124 9/13/2024
1.1.1 105 7/27/2024
1.1.0 123 7/9/2024
1.0.0 121 6/12/2024