ozakboy.Help 1.1.0

dotnet add package ozakboy.Help --version 1.1.0                
NuGet\Install-Package ozakboy.Help -Version 1.1.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="ozakboy.Help" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ozakboy.Help --version 1.1.0                
#r "nuget: ozakboy.Help, 1.1.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 ozakboy.Help as a Cake Addin
#addin nuget:?package=ozakboy.Help&version=1.1.0

// Install ozakboy.Help as a Cake Tool
#tool nuget:?package=ozakboy.Help&version=1.1.0                

ozakboy.Help

nuget github

專案簡介

ozakboy.Help 是一個實用的 .NET 擴展函式庫,旨在簡化開發過程中常用的程式碼操作。本套件封裝了多個常用的擴展方法,讓開發過程更加流暢和高效。

支援框架

  • .NET Core 3.1
  • .NET 6.0
  • .NET 7.0

安裝方式

使用 NuGet Package Manager:

Install-Package ozakboy.Help

或使用 .NET CLI:

dotnet add package ozakboy.Help

功能特色

1. 日期時間處理 (DatetimeToTimestampHelp)

  • ToUnixTimestamp: 將 UTC DateTime 轉換為 Unix 時間戳
  • FromUnixTimestamp: 將 Unix 時間戳轉換為 UTC DateTime
  • DefulteData: 取得預設時間 (2000/1/1)

2. 列舉擴展 (EnumExtensions)

  • GetDescription: 從列舉常數中獲取描述文字,支援 DescriptionAttribute

3. JSON 處理 (JsonExtensions)

  • ToJsonString: 將物件序列化為 JSON 字串
  • FromJsonString<T>: 將 JSON 字串反序列化為指定的類型

4. 異常處理 (ErrorMessageException)

自定義的異常處理類,提供:

  • 錯誤代碼支援
  • 額外資訊儲存
  • 完整的序列化支援
  • 豐富的建構函式選項

使用範例

日期時間轉換

// DateTime 轉 Unix 時間戳
DateTime utcNow = DateTime.UtcNow;
long timestamp = utcNow.ToUnixTimestamp();

// Unix 時間戳轉 DateTime
DateTime dateTime = DatetimeToTimestampHelp.FromUnixTimestamp(timestamp);

列舉描述獲取

public enum Status
{
    [Description("處理中")]
    Processing,
    [Description("已完成")]
    Completed
}

Status status = Status.Processing;
string description = status.GetDescription(); // 返回 "處理中"

JSON 序列化

var obj = new { Name = "測試", Value = 123 };
string json = obj.ToJsonString();

var deserializedObj = json.FromJsonString<dynamic>();

異常處理

try
{
    throw new ErrorMessageException("發生錯誤", "ERR001", new { Details = "額外資訊" });
}
catch (ErrorMessageException ex)
{
    Console.WriteLine(ex.ErrorCode);    // ERR001
    Console.WriteLine(ex.Message);      // 發生錯誤
    Console.WriteLine(ex.AdditionalInfo); // { Details = "額外資訊" }
}

貢獻指南

歡迎提交 Issue 和 Pull Request 來協助改進這個專案。

維護資訊

  • 持續維護中
  • 定期更新
  • 歡迎回報問題

相關連結

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 is compatible.  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 netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

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.1.0 82 11/26/2024
1.0.8 183 6/30/2023
1.0.6 149 5/15/2023
1.0.5 172 5/3/2023
1.0.4 155 5/2/2023
1.0.3 180 4/29/2023
1.0.2 202 4/29/2023
1.0.1 202 4/29/2023
1.0.0 185 4/29/2023