private static (JToken json, JToken salts) RecursiveRedactDataAndSalts(JToken json, JToken redactSettings, JToken salts = null) { // ReSharper disable once SwitchStatementMissingSomeCases switch (redactSettings.Type) { case JTokenType.Boolean: if (!(bool)redactSettings) { return(json, salts); } ObjectHashImplementation objectHash = new ObjectHashImplementation(); objectHash.HashJToken(json, salts); return("**REDACTED**" + objectHash.HashAsString(), "**REDACTED**"); case JTokenType.Object: try { return(RedactObject((JObject)json, (JObject)redactSettings, salts.IsNullOrEmpty() ? null : (JObject)salts)); } catch (InvalidCastException e) { throw new BadRequestException( "The provided JSON does not contain an object -> {} where the redact settings require one. Please check the JSON data or the redact settings.", e); } case JTokenType.Array: try { return(RedactArray((JArray)json, (JArray)redactSettings, salts.IsNullOrEmpty() ? null : (JArray)salts)); } catch (InvalidCastException e) { throw new BadRequestException( "The provided JSON does not contain an array -> [] where the redact settings require one. Please check the JSON data or the redact settings", e); } case JTokenType.Null: { return(json, salts); } default: throw new BadRequestException( "The redact setting JSON is invalid. It can only contain a nested JSON, arrays and the data type Boolean."); } }
// ReSharper disable once UnusedMember.Global public int CompareTo(ObjectHashImplementation other) { return(string.Compare(HashAsString(), other.HashAsString(), Globals.STRING_COMPARE_METHOD)); }