Ejemplo n.º 1
0
        private static void AddCasingStrategy(this IServiceCollection services, JsonCrafterCasing casing)
        {
            switch (casing)
            {
            case JsonCrafterCasing.CamelCase:
                services.AddSingleton <ICaseFormatter, CamelCaseFormatter>();
                break;

            case JsonCrafterCasing.PascalCase:
                services.AddSingleton <ICaseFormatter, PascalCaseFormatter>();
                break;

            case JsonCrafterCasing.SnakeCase:
                services.AddSingleton <ICaseFormatter, SnakeCaseFormatter>();
                break;

            case JsonCrafterCasing.ParamCase:
                services.AddSingleton <ICaseFormatter, ParamCaseFormatter>();
                break;

            default:
                throw new JsonCrafterException($"Could not activate casing strategy '{casing.ToString()}' (not supported)");
            }
        }
Ejemplo n.º 2
0
 public void SetCasing(JsonCrafterCasing format)
 {
     _casingFormat = format;
 }