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

Build status GitHub issues GitHub forks GitHub stars License: MIT Nuget NuGet Downloads Known Vulnerabilities Gitter Blogger Patreon PayPal

可用于

  • 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 已计算。
兼容的目标框架
包含的目标框架(在包中)
了解更多关于 目标框架.NET 标准化 的信息。

NuGet 包

该包不会被任何 NuGet 包使用。

GitHub 仓库

此包未被任何流行的GitHub仓库使用。

版本 下载 最后更新
1.0.7 87 5/16/2024
1.0.6 180 12/7/2023
1.0.5 110 11/13/2023
1.0.4 72 11/11/2023
1.0.3 167 4/7/2023
1.0.2 315 11/10/2022
1.0.1 363 10/30/2022
1.0.0 390 2/21/2022

版本 1.0.7.0 (2024-05-16):移除了对Net7.0的支持。