mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-09 12:51:06 +00:00
Migrate to new tribufu project structure
This commit is contained in:
parent
be25ee8fe3
commit
6ef2762a64
114 changed files with 35 additions and 26 deletions
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Tribufu.Serialization
|
||||
{
|
||||
public class NetworkAwareSnakeCaseNamingStrategy : SnakeCaseNamingStrategy
|
||||
{
|
||||
private static readonly string[] KnownAcronyms = new string[] { "IPv4", "IPv6" };
|
||||
|
||||
protected override string ResolvePropertyName(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
foreach (var acr in KnownAcronyms)
|
||||
{
|
||||
name = Regex.Replace(name, acr, acr.ToLower());
|
||||
}
|
||||
|
||||
var snake = base.ResolvePropertyName(name);
|
||||
foreach (var acr in KnownAcronyms)
|
||||
{
|
||||
var lower = acr.ToLower();
|
||||
snake = snake.Replace(lower.Replace("_", ""), lower);
|
||||
}
|
||||
|
||||
return snake;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue