| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Text.Json |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Determines the naming policy used to convert a string-based name to another format, such as a camel-casing forma |
| | | 8 | | /// </summary> |
| | | 9 | | #if BUILDING_SOURCE_GENERATOR |
| | | 10 | | internal |
| | | 11 | | #else |
| | | 12 | | public |
| | | 13 | | #endif |
| | | 14 | | abstract class JsonNamingPolicy |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of <see cref="JsonNamingPolicy"/>. |
| | | 18 | | /// </summary> |
| | 0 | 19 | | protected JsonNamingPolicy() { } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Returns the naming policy for camel-casing. |
| | | 23 | | /// </summary> |
| | 0 | 24 | | public static JsonNamingPolicy CamelCase { get; } = new JsonCamelCaseNamingPolicy(); |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Returns the naming policy for lower snake-casing. |
| | | 28 | | /// </summary> |
| | 0 | 29 | | public static JsonNamingPolicy SnakeCaseLower { get; } = new JsonSnakeCaseLowerNamingPolicy(); |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Returns the naming policy for upper snake-casing. |
| | | 33 | | /// </summary> |
| | 0 | 34 | | public static JsonNamingPolicy SnakeCaseUpper { get; } = new JsonSnakeCaseUpperNamingPolicy(); |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Returns the naming policy for lower kebab-casing. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public static JsonNamingPolicy KebabCaseLower { get; } = new JsonKebabCaseLowerNamingPolicy(); |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Returns the naming policy for upper kebab-casing. |
| | | 43 | | /// </summary> |
| | 0 | 44 | | public static JsonNamingPolicy KebabCaseUpper { get; } = new JsonKebabCaseUpperNamingPolicy(); |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// When overridden in a derived class, converts the specified name according to the policy. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <param name="name">The name to convert.</param> |
| | | 50 | | /// <returns>The converted name.</returns> |
| | | 51 | | public abstract string ConvertName(string name); |
| | | 52 | | } |
| | | 53 | | } |