将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。

This commit is contained in:
QI Mingxuan
2026-04-16 17:31:13 +08:00
parent 6ec4c3ddaa
commit 2bd6e566c3
581 changed files with 74600 additions and 222 deletions
@@ -0,0 +1,54 @@
using System;
using System.IO;
namespace XP.Hardware.RaySource.Comet.Host.Pipe
{
/// <summary>
/// 管道写入流包装器
/// 重写 Flush() 为空操作,避免 StreamWriter.AutoFlush 触发
/// NamedPipe 的 FlushFileBuffers(该 API 会阻塞直到对端读取数据)
/// Write 操作直接写入底层管道的内核缓冲区,对端可立即读取
/// </summary>
internal class WriteOnlyPipeStream : Stream
{
private readonly Stream _inner;
public WriteOnlyPipeStream(Stream inner)
{
_inner = inner;
}
public override bool CanRead => false;
public override bool CanSeek => false;
public override bool CanWrite => _inner.CanWrite;
public override long Length => _inner.Length;
public override long Position
{
get => _inner.Position;
set => _inner.Position = value;
}
public override void Write(byte[] buffer, int offset, int count)
{
_inner.Write(buffer, offset, count);
}
/// <summary>
/// 空操作,不调用底层管道的 FlushFlushFileBuffers
/// </summary>
public override void Flush()
{
// 故意不调用 _inner.Flush()
}
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();
protected override void Dispose(bool disposing)
{
// 不释放底层流,由调用方统一管理
base.Dispose(disposing);
}
}
}