GhBase 1.3.5

dotnet add package GhBase --version 1.3.5
                    
NuGet\Install-Package GhBase -Version 1.3.5
                    
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="GhBase" Version="1.3.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GhBase" Version="1.3.5" />
                    
Directory.Packages.props
<PackageReference Include="GhBase" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GhBase --version 1.3.5
                    
#r "nuget: GhBase, 1.3.5"
                    
#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.
#:package GhBase@1.3.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GhBase&version=1.3.5
                    
Install as a Cake Addin
#tool nuget:?package=GhBase&version=1.3.5
                    
Install as a Cake Tool

光衡Base

说明

光衡Base实现软件基础功能

GhMessage 光衡消息,支持不同应用间发送消息

GhMessage ghMessage = GhMessage.Initialize(Action<RedisOperateMsg> action, string connectionString = "localhost:6379", string password = "");
ghMessage.Subscribe("test-topic", (string message)=>{
});
ghMessage.Publish("test-topic", "1234");

RedisHelper 使用, 支持key,value键值设置、读取、删除。

RedisHelper redisHelper = RedisHelper.GetInstance("localhost:6379"); //获取实例

redisHelper.Set("test", "1"); //设置key value,长期有效

redisHelper.Set("test", "1",60); //设置key value,60秒有效

redisHelper.Get("test");// 获取指定key里的value

redisHelper.Get("test", "1");// 获取指定key里的value,如果key不存在,返回 "1"

strint oldValue = redisHelper.SetAndGet("test", "1");// 先获取再更新

bool exists = redisHelper.Exists("test"); //key是否存在 

redisHelper.Delete("test"); //删除指定key 

redisHelper.Increment("test", 1) //自增1

redisHelper.Decrement("test", 1) //自减1

HeartbeatHelper 软件心跳

//在软件启动后,调用这个方法即可,需要指定当前软件名称,用英文或拼音,不可使用中文
HeartbeatHelper.StartHeartbeatAsync(string appName, string connectionString = "localhost:6379")

RedisQueueHelper 队列实现,支持在不同应用间实现队列,本应用内也可以更简单实现队列功能

RedisQueueHelper redisQueueHelper = new RedisQueueHelper(string queueKey, string connectionString, string _redisPassword = "");
redisQueueHelper.Enqueue("test");// 入队
string tmp = redisQueueHelper.Dequeue();// 出队,先进先出,

//取队列示例
 _ = Task.Run(async () =>
{
    // 定义输入字符串的格式
    while (isRunning)
    {
        string queueStr = null;
        try
        {
            //出队
            queueStr = redisQueueHelper.Dequeue();
            if (String.IsNullOrEmpty(queueStr))
            {
                await Task.Delay(10000);
                continue;
            }
        }
        catch
        {
            //出现异常后,可以把队列放回
            if (!String.IsNullOrEmpty(queueStr))
            {
                redisQueueHelper.Enqueue(queueStr);
            }
        }
    }
});

日志功能

//在软件启动后,指定项目名称和日志目录
Logeer.Initialize(string appName, string logDirectory = null);//不传目录的话,默认使用软件当前目录
Logeer.Log("test", LogLevel.Info);

public enum LogLevel
{
    Debug,
    Info,
    Warning,
    Error,
    Critical
}

命名管道消息

NamedPipeServer server = new NamedPipeServer("testpipe");
server.MessageReceived += Server_MessageReceived;
server.Start();
server.Stop();
private void Server_MessageReceived(object? sender, string e)
{
    this.Invoke(new Action(() => { textBox1.Text = e; }));
}

NamedPipeClient client = new NamedPipeClient("testpipe");
client.SendMessageAsync("Hello:"+DateTime.Now.ToString("fff"));

共享内存

GhSharedMemoryImg memoryImg = new GhSharedMemoryImg("testimg", 8192 * 11000); //创建共享内存对象,参数为共享内存名称
GhSharedMemoryImg memoryImg2 = new GhSharedMemoryImg("testimg", 8192 * 11000); //打开同名共享内存对象
var isCreateOk = memoryImg.CreateMemMap();
var isOpenOk = memoryImg2.OpenMemMap();
using (var mat_high_jz = Cv2.ImRead(@"D:\test\***.jpg", ImreadModes.Grayscale))
{
    if (isCreateOk)
    {
        byte[] img_data_array_h = new byte[mat_high_jz.Cols * mat_high_jz.Rows];
        mat_high_jz.GetArray(out img_data_array_h);

        var isWriteOk = memoryImg.WriteDataByte(img_data_array_h, 0);
        if (isWriteOk && isOpenOk)
        {
            byte[] img_data_array_src = new byte[mat_high_jz.Cols * mat_high_jz.Rows];
            img_data_array_src = memoryImg2.ReadDataByte(0, mat_high_jz.Cols * mat_high_jz.Rows);

            using Mat mat_read = new Mat(mat_high_jz.Rows, mat_high_jz.Cols, MatType.CV_8UC1);
            mat_read.SetArray(img_data_array_src);
            Cv2.ImWrite(@"D:\test\test.jpg", mat_read);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.5 117 3/23/2026
1.3.4 109 3/9/2026
1.3.3 116 2/6/2026
1.3.2 110 2/4/2026
1.3.1 114 2/4/2026
1.2.9 270 11/14/2025
1.2.8 189 10/16/2025
1.2.7 268 8/26/2025
1.2.6 155 7/27/2025
1.2.5 373 7/20/2025
1.2.4 118 7/19/2025
1.2.3 198 6/15/2025
1.2.2 345 6/11/2025
1.2.1 172 5/30/2025
1.2.0 172 5/30/2025
1.1.9 171 5/30/2025
1.1.8 203 5/29/2025
1.1.7 195 5/28/2025
1.1.6 197 5/28/2025
1.1.5 202 5/28/2025
Loading failed