kr.bbon.Core 1.4.7

.NET 5.0 .NET Standard 2.0
NuGet\Install-Package kr.bbon.Core -Version 1.4.7
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.
dotnet add package kr.bbon.Core --version 1.4.7
<PackageReference Include="kr.bbon.Core" Version="1.4.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add kr.bbon.Core --version 1.4.7
#r "nuget: kr.bbon.Core, 1.4.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install kr.bbon.Core as a Cake Addin
#addin nuget:?package=kr.bbon.Core&version=1.4.7

// Install kr.bbon.Core as a Cake Tool
#tool nuget:?package=kr.bbon.Core&version=1.4.7

kr.bbon.Core Package

publish to nuget

πŸ“’ 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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.7 142 6/27/2022
1.4.6 243 5/3/2022
1.4.5 450 3/19/2022
1.4.3 174 1/22/2022
1.4.1 178 12/22/2021
1.4.0 295 12/7/2021
1.3.0 286 11/12/2021
1.2.5 180 10/11/2021
1.2.4 196 10/11/2021
1.2.3 259 9/27/2021
1.2.2 328 9/19/2021
1.2.1 217 9/19/2021
1.2.0 272 9/19/2021
1.1.0 264 6/20/2021
1.0.0 377 6/15/2021