common/Logic/Common.Logic.Extensions.Http/HttpResponse.cs
2026-04-23 17:50:07 +02:00

41 lines
1.2 KiB
C#

namespace Common.Logic.Extensions.Http
{
using System;
using System.Collections.Generic;
public class HttpResponse
{
private Exception exception;
private HttpResponse(Boolean succeeded)
=> this.Succeeded = succeeded;
private HttpResponse(Dictionary<String, String> errors) : this(false)
=> this.Errors = errors;
public HttpResponse(Exception exception) : this(false)
=> this.exception = exception;
public Boolean Succeeded { get; }
public Exception Exception { get; }
public Dictionary<String, String> Errors { get; }
public static implicit operator HttpResponse(Boolean succeeded)
=> new HttpResponse(succeeded);
public static implicit operator HttpResponse(Dictionary<String, String> errors)
=> new HttpResponse(errors);
public static implicit operator HttpResponse(Exception exception)
=> new HttpResponse(exception);
public static implicit operator Boolean(HttpResponse result)
=> result?.Succeeded ?? false;
public static implicit operator Dictionary<String, String>(HttpResponse result)
=> result?.Errors ?? new Dictionary<String, String>();
}
}