コード例 #1
0
        public static JsonSerializerOptions BuildAndSaveToDefault(
            this JsonSerializerOptionsBuilder builder)
        {
            JsonSerializerOptions option = builder.Build();

            JsonSerializerOptionsBuilderExtesions.DefaultOptions = option;
            return(option);
        }
コード例 #2
0
 public static JsonSerializerOptionsBuilder SetEncoder(
     this JsonSerializerOptionsBuilder builder,
     [NotNull] JavaScriptEncoder encoder)
 {
     encoder.CheckNullWithException(nameof(encoder));
     return(SetActionBase(
                builder,
                t => t.Encoder = encoder));
 }
コード例 #3
0
 private static JsonSerializerOptionsBuilder SetActionBase(
     [NotNull] JsonSerializerOptionsBuilder builder,
     [NotNull] Action <JsonSerializerOptions> action)
 {
     builder.CheckNullWithException(nameof(builder));
     action.CheckNullWithException(nameof(action));
     builder.BuildActionList.Add(action);
     return(builder);
 }
コード例 #4
0
 public static JsonSerializerOptions GetOrBuildDefaultOptions(this JsonSerializerOptionsBuilder builder)
 {
     if (JsonSerializerOptionsBuilderExtesions.DefaultOptions.IsNull())
     {
         return(builder
                .SetCamelCase()
                .SetEncoderToUnicodeRangeAll()
                .BuildAndSaveToDefault());
     }
     else
     {
         return(JsonSerializerOptionsBuilderExtesions.DefaultOptions);
     }
 }
コード例 #5
0
 public static JsonSerializerOptions GetDefaultOptions(this JsonSerializerOptionsBuilder builder)
 {
     return(JsonSerializerOptionsBuilderExtesions.DefaultOptions);
 }
コード例 #6
0
 public static JsonSerializerOptionsBuilder Configure(
     this JsonSerializerOptionsBuilder builder,
     [NotNull] Action <JsonSerializerOptions> action)
 {
     return(SetActionBase(builder, action));
 }
コード例 #7
0
 public static JsonSerializerOptionsBuilder SetEncoderToUnicodeRangeAll(this JsonSerializerOptionsBuilder builder)
 {
     return(SetActionBase(
                builder,
                t => t.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)));
 }
コード例 #8
0
 public static JsonSerializerOptionsBuilder SetCamelCase(this JsonSerializerOptionsBuilder builder)
 {
     return(SetActionBase(
                builder,
                t => t.PropertyNamingPolicy = JsonNamingPolicy.CamelCase));
 }
コード例 #9
0
 static JsonSerializerOptionsBuilder()
 {
     DefaultOptions = JsonSerializerOptionsBuilder.Create()
                      .GetOrBuildDefaultOptions();
 }