You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuSerializerContext.cs 772B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Luticate2.Auth.Utils.Business.Serializers.PartialJson
  4. {
  5. internal class LuSerializerContext
  6. {
  7. private readonly Func<string, bool> shouldSerialize;
  8. private readonly Dictionary<string, bool> cache = new Dictionary<string, bool>();
  9. public LuSerializerContext(Func<string, bool> shouldSerialize)
  10. {
  11. this.shouldSerialize = shouldSerialize;
  12. }
  13. public bool ShouldSerialize(string path)
  14. {
  15. if (this.cache.ContainsKey(path))
  16. {
  17. return this.cache[path];
  18. }
  19. var result = this.shouldSerialize(path);
  20. this.cache.Add(path, result);
  21. return result;
  22. }
  23. }
  24. }