kr.bbon.Core
1.7.0
dotnet add package kr.bbon.Core --version 1.7.0
NuGet\Install-Package kr.bbon.Core -Version 1.7.0
<PackageReference Include="kr.bbon.Core" Version="1.7.0" />
paket add kr.bbon.Core --version 1.7.0
#r "nuget: kr.bbon.Core, 1.7.0"
// Install kr.bbon.Core as a Cake Addin
#addin nuget:?package=kr.bbon.Core&version=1.7.0
// Install kr.bbon.Core as a Cake Tool
#tool nuget:?package=kr.bbon.Core&version=1.7.0
kr.bbon.Core Package
π’ Overview
.NET μμ νλ‘μ νΈλ₯Ό μμν λ, λ°λ³΅μ μΌλ‘ μμ±νλ μ¬νμ ν¨ν€μ§λ‘ μ 리νμ΅λλ€.
π Namespace
kr.bbon.Core λ€μμ€νμ΄μ€
κΈ°λ³Έ λ€μμ€νμ΄μ€λ‘ kr.bbon.Core λ₯Ό μ¬μ©ν©λλ€.
kr.bbon.Core.Converters λ€μμ€νμ΄μ€
κ° λ³νμ μν κΈ°λ₯μ μ 곡νλ λ€μμ€νμ΄μ€μ λλ€.
π― Features
Exception classes
ApiException class
API μμΈλ₯Ό νννκΈ° μν΄ μ¬μ©λ©λλ€.
public Task SomeFeatureAsync()
{
if(NotValid){
var model = new ErrorModel("It's invalid message");
throw new ApiException(400, model);
}
// ...
}
HttpStatusException class
ApiException class λ₯Ό μ¬μ©νμμμ€.
HTTP μμΈλ₯Ό νννκΈ° μν΄ μ¬μ©λ©λλ€.
// Exception handling in action method
try
{
// ...
}
catch(HttpStatusException ex)
{
return StatusCode(ex.StatusCode, ex.Message, ex.GetDetails());
}
catch(Exception ex)
{
// ...
}
HttpStatusException<TDeatails> class
ApiException class λ₯Ό μ¬μ©νμμμ€.
HTTP μμΈμ μμΈ μ 보λ₯Ό νννκΈ° μν΄ μ¬μ©λ©λλ€.
throw new HttpStatusException(HttpStatusCode.BadRequest, new SomeDetails
{
Id = "err111",
Message = "AAA μμ±μ κ°μ΄ μ μκ° μλλλ€.",
});
SomethingWrongException
ApiException class λ₯Ό μ¬μ©νμμμ€.
μ¬μ©μ μ μ μμΈλ₯Ό νννκΈ° μν΄ μ¬μ©ν©λλ€.
// Exception handling in action method
try
{
// ...
}
catch(SomethingWrongException ex)
{
return StatusCode(HttpStatusCode.Forbidden, ex.Message, ex.GetDetails());
}
catch(Exception ex)
{
// ...
}
SomethingWrongException<TDetails>
ApiException class λ₯Ό μ¬μ©νμμμ€.
μ¬μ©μ μ μ μμΈμ μμΈ μ 보λ₯Ό νννκΈ° μν΄ μ¬μ©ν©λλ€.
throw new SomethingWrongException("λ°μ΄ν°λ₯Ό μ²λ¦¬νμ§ λͺ»νμ΅λλ€.", new SomeDetails
{
Id = "err111",
Message = "AAA μμ±μ κ°μ΄ μ μκ° μλλλ€.",
});
Extension methods
Object.ToJson<T>() method
Object ν΄λμ€μ ToJson λ©μλλ₯Ό μΆκ°ν©λλ€.
κ°μ²΄μ μΈμ€ν΄μ€λ₯Ό JSON λ¬Έμμ΄λ‘ μ§λ ¬ννλ κΈ°λ₯μ μ 곡ν©λλ€.
var sample = getSampleModel();
sample.ToJson();
JsonSerializerOptions 맀κ°λ³μκ° μ§μ λμ§ μμ κ²½μ° μλ κΈ°λ³Έκ°μ μ¬μ©ν©λλ€.
var defaultOptions = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
kr.bbon.Core.Converters namespace
JavascriptDateConverter class
ToDateTimeOffset method
μλ°μ€ν¬λ¦½νΈ λ°λ¦¬μ΄ κ°μ DateTimeOffset μΌλ‘ λ³νν©λλ€.
ToJavascriptDateMilliseconds method
DateTimeOffset κ°μ μλ°μ€ν¬λ¦½νΈ λ°λ¦¬μ΄ κ°μΌλ‘ λ³νν©λλ€.
JavascriptDateConverter converter = new JavascriptDateConverter();
var javascriptDateValue = 1624165031491;
var datetimeOffsetValue = converter.ToDateTimeOffset(javascriptDateValue);
var milliseconds = converter.ToJavascriptDateMilliseconds(datetimeOffsetValue);
Assert.Equal(javascriptDateValue, milliseconds.Value);
kr.bbon.Core.Reflection namespace
ReflectionHelper class
CollectAssembly method
νμ¬ AppDomain μ μ΄μ λΈλ¦¬μ€ μ λ ₯λ 쑰건μ λ§μ‘±νλ μ΄μ λΈλ¦¬ λͺ©λ‘μ μμ§ν©λλ€.
var predicte = new Func<Type, bool>(t => t.Name == nameof(ApiException));
var assemblies = ReflectionHelper.CollectAssembly(predicte);
CollectTypes method
νμ¬ AppDomain μ νμ μ€ μ‘°κ±΄μ λ§μ‘±νλ νμ λͺ©λ‘μ μμ§ν©λλ€.
var predicte = new Func<Type, bool>(t => t.Name == nameof(ApiException));
var types = ReflectionHelper.CollectTypes(predicte);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 is compatible. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.0)
- TimeZoneConverter (>= 6.1.0)
-
.NETStandard 2.1
- System.Text.Json (>= 8.0.0)
- TimeZoneConverter (>= 6.1.0)
-
net5.0
- TimeZoneConverter (>= 6.1.0)
-
net6.0
- TimeZoneConverter (>= 6.1.0)
-
net7.0
- TimeZoneConverter (>= 6.1.0)
-
net8.0
- TimeZoneConverter (>= 6.1.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on kr.bbon.Core:
Package | Downloads |
---|---|
kr.bbon.AspNetCore
Helper for ASP.NET Core |
|
kr.bbon.EntityFrameworkCore.Extensions
Provider EntityFrameworkCore extensions. |
|
kr.bbon.Data.Abstractions
kr.bbon.Data.Abstractions |
|
kr.bbon.Services
Provides implementations of frequently used services. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.0 | 254 | 1/3/2024 |
1.6.2 | 646 | 12/31/2022 |
1.6.1 | 555 | 11/22/2022 |
1.5.0 | 699 | 11/19/2022 |
1.4.10 | 364 | 11/10/2022 |
1.4.7 | 938 | 6/27/2022 |
1.4.6 | 1,033 | 5/3/2022 |
1.4.5 | 1,454 | 3/19/2022 |
1.4.3 | 830 | 1/22/2022 |
1.4.1 | 777 | 12/22/2021 |
1.4.0 | 1,454 | 12/7/2021 |
1.3.0 | 533 | 11/12/2021 |
1.2.5 | 356 | 10/11/2021 |
1.2.4 | 381 | 10/11/2021 |
1.2.3 | 554 | 9/27/2021 |
1.2.2 | 717 | 9/19/2021 |
1.2.1 | 416 | 9/19/2021 |
1.2.0 | 514 | 9/19/2021 |
1.1.0 | 455 | 6/20/2021 |
1.0.0 | 707 | 6/15/2021 |