NamingPolicy Class
Definition
- Namespace
- Bodu.Text.Serialization
- Assembly
- Bodu.Text.Serialization.dll
- Package
- Bodu.Text.Serialization 1.0.0
- Source
- NamingPolicy.cs
Determines how a member's CLR name is translated to the key used in serialized output, exposing the common casing conventions as ready-made policies.
public abstract class NamingPolicy
- Inheritance
-
NamingPolicy
- Inherited Members
- Extension Methods
Examples
// A MaxRetryCount property serializes under the key "max_retry_count".
var key = NamingPolicy.SnakeCaseLower.ConvertName("MaxRetryCount");
Remarks
A naming policy applies only when a member does not carry an explicit PropertyNameAttribute, which always wins.
Constructors
NamingPolicy()
Initializes a new instance of the NamingPolicy class.
protected NamingPolicy()
Properties
CamelCase
Gets a policy that converts a name to camelCase by lowercasing its first character.
public static NamingPolicy CamelCase { get; }
Property Value
- NamingPolicy
The camel-case naming policy.
KebabCaseLower
Gets a policy that converts a name to kebab-case using lowercase letters.
public static NamingPolicy KebabCaseLower { get; }
Property Value
- NamingPolicy
The lowercase kebab-case naming policy.
KebabCaseUpper
Gets a policy that converts a name to KEBAB-CASE using uppercase letters.
public static NamingPolicy KebabCaseUpper { get; }
Property Value
- NamingPolicy
The uppercase kebab-case naming policy.
SnakeCaseLower
Gets a policy that converts a name to snake_case using lowercase letters.
public static NamingPolicy SnakeCaseLower { get; }
Property Value
- NamingPolicy
The lowercase snake-case naming policy.
SnakeCaseUpper
Gets a policy that converts a name to SNAKE_CASE using uppercase letters.
public static NamingPolicy SnakeCaseUpper { get; }
Property Value
- NamingPolicy
The uppercase snake-case naming policy.
Methods
ConvertName(string)
Converts the specified member name to the key used in serialized output.
public abstract string ConvertName(string name)
Parameters
namestringThe CLR member name.
Returns
- string
The translated name.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |