dotnet add package HaemmerElectronics.SeppPenner.ProtobufNetPrimitives --version 1.0.7
NuGet\Install-Package HaemmerElectronics.SeppPenner.ProtobufNetPrimitives -Version 1.0.7
<PackageReference Include="HaemmerElectronics.SeppPenner.ProtobufNetPrimitives" Version="1.0.7" />
paket add HaemmerElectronics.SeppPenner.ProtobufNetPrimitives --version 1.0.7
#r "nuget: HaemmerElectronics.SeppPenner.ProtobufNetPrimitives, 1.0.7"
// Install HaemmerElectronics.SeppPenner.ProtobufNetPrimitives as a Cake Addin #addin nuget:?package=HaemmerElectronics.SeppPenner.ProtobufNetPrimitives&version=1.0.7 // Install HaemmerElectronics.SeppPenner.ProtobufNetPrimitives as a Cake Tool #tool nuget:?package=HaemmerElectronics.SeppPenner.ProtobufNetPrimitives&version=1.0.7
ProtobufNetPrimitives
可用于
- Net 6.0
- Net 8.0
Net Core和Net Framework最新版和LTS版本
可用数据类型
Net类型 | GRPC类型 | 备注 |
---|---|---|
bool |
DtoBool |
- |
byte |
DtoByte |
- |
char |
DtoChar |
- |
DateTime |
DtoDateTime |
内部存储为long,使用属性DateTime 获取正确值。 |
DateTimeOffset |
DtoDateTimeOffset |
内部存储为long,使用属性DateTimeOffset 获取正确值。 |
decimal |
DtoDecimal |
- |
double |
DtoDouble |
- |
float |
DtoFloat |
- |
Guid |
DtoGuid |
内部存储为string,使用属性Uuid 获取正确值。 |
int |
DtoInt |
- |
long |
DtoLong |
- |
nint |
DtoNint |
- |
无符号整数 |
DtoNuint |
- |
有符号字节 |
DtoSbyte |
- |
短整数 |
DtoShort |
- |
字符串 |
DtoString |
- |
时间跨度 |
DtoTimeSpan |
值内部以长整型存储,请使用属性 TimeSpan 获取正确值。 |
无符号整数 |
DtoUint |
- |
无符号长整数 |
DtoUlong |
- |
无符号短整数 |
DtoUshort |
- |
支持非空和可空类型(不同的子命名空间)。
为什么在这里不能使用泛型
/// <summary>
/// The base DTO class.
/// </summary>
[ProtoContract]
[ProtoInclude(1, typeof(DtoBool))]
public class DtoBase<T> where T : new()
{
/// <summary>
/// Initializes a new instance of the <see cref="DtoBase{T}"/> class.
/// </summary>
public DtoBase()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DtoBase{T}"/> class.
/// </summary>
/// <param name="value">The value.</param>
public DtoBase(T value)
{
this.Data = value;
}
/// <summary>
/// Gets or sets the data.
/// </summary>
[ProtoMember(2)]
public T Data { get; set; } = new();
}
/// <summary>
/// The DTO class to transfer bool data.
/// </summary>
[ProtoContract]
public class DtoBool : DtoBase<bool>
{
/// <summary>
/// Initializes a new instance of the <see cref="DtoBool"/> class.
/// </summary>
public DtoBool()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DtoBool"/> class.
/// </summary>
/// <param name="value">The value.</param>
public DtoBool(bool value)
{
this.Data = value;
}
}
抛出错误,请参阅https://github.com/protobuf-net/protobuf-net/issues/829(尚未解决)。
安装
dotnet add package HaemmerElectronics.SeppPenner.ProtobufNetPrimitives
变更历史
查看变更历史。
产品 | 版本 兼容和额外的计算目标框架版本。 |
---|---|
.NET | net6.0 兼容。 net6.0-android 已计算。 net6.0-ios 已计算。 net6.0-maccatalyst 已计算。 net6.0-macos 已计算。 net6.0-tvos 已计算。 net6.0-windows 已计算。 net7.0 已计算。 net7.0-android 已计算。 net7.0-ios 已计算。 net7.0-maccatalyst 已计算。 net7.0-macos 已计算。 net7.0-tvos 已计算。 net7.0-windows 已计算。 net8.0 兼容。 net8.0-android 已计算。 net8.0-browser 已计算。 net8.0-ios 已计算。 net8.0-maccatalyst 已计算。 net8.0-macos 已计算。 net8.0-tvos 已计算。 net8.0-windows 已计算。 |
-
net6.0
- protobuf-net.Grpc (>= 1.1.1)
-
net8.0
- protobuf-net.Grpc (>= 1.1.1)
NuGet 包
该包不会被任何 NuGet 包使用。
GitHub 仓库
此包未被任何流行的GitHub仓库使用。
版本 1.0.7.0 (2024-05-16):移除了对Net7.0的支持。