another step for constructing base project

This commit is contained in:
hamid
2026-06-17 22:53:49 +03:30
parent 5b4c0d183f
commit 5388bea320
76 changed files with 3836 additions and 1961 deletions
@@ -0,0 +1,17 @@
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Routing;
namespace Baya.WebFramework.Routing;
public sealed class SnakeCaseParameterTransformer : IOutboundParameterTransformer
{
private static readonly Regex _upperAfterLower = new(@"([a-z0-9])([A-Z])", RegexOptions.Compiled);
private static readonly Regex _consecutiveUpper = new(@"([A-Z]+)([A-Z][a-z])", RegexOptions.Compiled);
public string TransformOutbound(object value)
{
if (value is null) return null;
var s = _consecutiveUpper.Replace(value.ToString()!, "$1_$2");
return _upperAfterLower.Replace(s, "$1_$2").ToLowerInvariant();
}
}