Refactor annotation tool from WPF desktop app to .NET API

Replace the WPF desktop application (Azaion.Suite, Azaion.Annotator,
Azaion.Common, Azaion.Inference, Azaion.Loader, Azaion.LoaderUI,
Azaion.Dataset, Azaion.Test) with a standalone .NET Web API in src/.

Made-with: Cursor
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-25 04:40:03 +02:00
parent e7ea5a8ded
commit 9e7dc290db
367 changed files with 8840 additions and 16583 deletions
+40
View File
@@ -0,0 +1,40 @@
using System.Net;
using System.Text.Json;
namespace Azaion.Annotations.Middleware;
public class ErrorHandlingMiddleware(RequestDelegate next, ILogger<ErrorHandlingMiddleware> logger)
{
public async Task Invoke(HttpContext context)
{
try
{
await next(context);
}
catch (KeyNotFoundException ex)
{
await WriteError(context, HttpStatusCode.NotFound, ex.Message);
}
catch (ArgumentException ex)
{
await WriteError(context, HttpStatusCode.BadRequest, ex.Message);
}
catch (InvalidOperationException ex)
{
await WriteError(context, HttpStatusCode.Conflict, ex.Message);
}
catch (Exception ex)
{
logger.LogError(ex, "Unhandled exception");
await WriteError(context, HttpStatusCode.InternalServerError, "Internal server error");
}
}
private static async Task WriteError(HttpContext context, HttpStatusCode code, string message)
{
context.Response.StatusCode = (int)code;
context.Response.ContentType = "application/json";
var body = JsonSerializer.Serialize(new { statusCode = (int)code, message });
await context.Response.WriteAsync(body);
}
}