mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-09 04:41:07 +00:00
Update projects
This commit is contained in:
parent
44dc36430a
commit
93301110b7
101 changed files with 23635 additions and 16252 deletions
|
|
@ -0,0 +1,35 @@
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<PackageId>Tribufu.Serialization</PackageId>
|
||||
<Description>Tribufu Serialization Extensions</Description>
|
||||
<Description>Tribufu Serialization</Description>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue