From e8c9ae120985b4b6056762e23fea41b9b68dfa0e Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 27 Oct 2017 20:02:40 +0100 Subject: Add parser settings WithXyz methods --- csharp/src/Google.Protobuf/JsonParser.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'csharp') diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 2ab4a860..3621b0c0 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -1037,6 +1037,23 @@ namespace Google.Protobuf /// true if unknown fields should be ignored when parsing; false to throw an exception. public Settings WithIgnoreUnknownFields(bool ignoreUnknownFields) => new Settings(RecursionLimit, TypeRegistry, ignoreUnknownFields); + + /// + /// Creates a new object based on this one, but with the specified recursion limit. + /// + /// The new recursion limit. + public Settings WithRecursionLimit(int recursionLimit) => + new Settings(recursionLimit, TypeRegistry, IgnoreUnknownFields); + + /// + /// Creates a new object based on this one, but with the specified type registry. + /// + /// The new type registry. Must not be null. + public Settings WithTypeRegistry(TypeRegistry typeRegistry) => + new Settings( + RecursionLimit, + ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)), + IgnoreUnknownFields); } } } -- cgit v1.2.3