Skip to content

Instantly share code, notes, and snippets.

View Seloris's full-sized avatar

Daniel Djordjevic Seloris

View GitHub Profile
@Seloris
Seloris / AppError.step2.cs
Created February 21, 2022 23:48
Gérer les exceptions de son API .NET Core - AppError step 2
public class AppError
{
public string Message { get; set; }
// object pour la sérialisation
public object? Details { get; set; }
public ErrorKeys ErrorKey { get; set; }
public HttpStatusCode StatusCode { get; set; }
@Seloris
Seloris / AlgoComputeException.cs
Created February 21, 2022 23:36
Gérer les exceptions de son API .NET Core - AlgoComputeException
public class AlgoComputeException : ExceptionBase, IHasErrorDetails
{
public IErrorDetails ErrorDetails { get; }
public override ErrorKeys ErrorKey => ErrorKeys.InvalidNumber;
public AlgoComputeException(string? message, AlgoComputeErrorDetails errorPayload) : base(message)
{
ErrorDetails = errorPayload;
}
@Seloris
Seloris / IHasErrorDetails.cs
Created February 21, 2022 23:34
Gérer les exceptions de son API .NET Core - IHasErrorDetails
public interface IHasErrorDetails
{
public IErrorDetails ErrorDetails { get; }
}
public interface IErrorDetails { }
@Seloris
Seloris / ExceptionBase.cs
Last active February 21, 2022 23:29
Gérer les exceptions de son API .NET Core - ExceptionBase
public abstract class ExceptionBase : Exception
{
public abstract ErrorKeys ErrorKey { get; }
public ExceptionBase(string? message) : base(message)
{
}
}
public enum ErrorKeys
@Seloris
Seloris / ExceptionMiddleware.cs
Created February 21, 2022 22:47
Gérer les exceptions de son API .NET Core - ExceptionMiddleware
public class ExceptionMiddleware
{
private readonly RequestDelegate _next;
public ExceptionMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext httpContext)
@Seloris
Seloris / AppError.cs
Last active February 21, 2022 22:47
Gérer les exceptions de son API .NET Core - AppError Step 1
public class AppError
{
public string Message { get; set; }
// object pour la sérialisation
public object? Details { get; set; }
public ErrorKeys ErrorKey { get; set; }
public HttpStatusCode StatusCode { get; set; }
<a href="com.elior.poc://">Url Scheme</a>
@Seloris
Seloris / test.cs
Created November 24, 2021 14:36
Test Medium
var state = new RequestState
{
AccountId = command.User.AccountId,
CreationDate = DateTime.UtcNow,
StateId = RequestStateEnum.Requested,
Payload = Json.Serialize(serviceModel)
};
request.States.Add(state);
/// <summary>
/// Converter used to compare some methods to get a SolidColorBrush from string hex/name colors
/// With the help of Jerome Giacomini (http://jeromegiacomini.net/Blog/2015/08/20/convertir-des-couleurs-hexa-et-des-colorname-en-solidcolorbrush/)
/// And Jonathan Antoine (http://blogs.infinitesquare.com/b/jonathan/archives/astuce-windowsphone-creer-un-objet-%E2%80%98color-a-partir-de-sa-chaine-hexadecimale-string#.VdYkOPntlBd)
/// </summary>
public static class ConverterHelper
{
/// <summary>
/// Gets or sets the limit.
public static class ConverterHelper
{
/// <summary>
/// Gets or sets the limit.
/// </summary>
/// <value>
/// The limit.
/// </value>
public const int Limit = 20;