JsonBytesRpcParameter.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.Json;
  5. using System.Threading.Tasks;
  6. namespace JsonRPC4.Router
  7. {
  8. public class JsonBytesRpcParameter : IRpcParameter
  9. {
  10. public RpcParameterType Type
  11. {
  12. get;
  13. }
  14. private Memory<byte> bytes
  15. {
  16. get;
  17. }
  18. private JsonSerializerOptions serializerOptions
  19. {
  20. get;
  21. }
  22. public JsonBytesRpcParameter(RpcParameterType type, Memory<byte> bytes, JsonSerializerOptions serializerOptions = null)
  23. {
  24. //IL_000e: Unknown result type (might be due to invalid IL or missing references)
  25. //IL_000f: Unknown result type (might be due to invalid IL or missing references)
  26. Type = type;
  27. this.bytes = bytes;
  28. this.serializerOptions = serializerOptions;
  29. }
  30. public bool TryGetValue(Type type, out object value)
  31. {
  32. //IL_0002: Unknown result type (might be due to invalid IL or missing references)
  33. //IL_0007: Unknown result type (might be due to invalid IL or missing references)
  34. //IL_000a: Unknown result type (might be due to invalid IL or missing references)
  35. //IL_000f: Unknown result type (might be due to invalid IL or missing references)
  36. try
  37. {
  38. value = JsonSerializer.Deserialize(this.bytes.Span, type, this.serializerOptions);
  39. return true;
  40. }
  41. catch (Exception)
  42. {
  43. value = null;
  44. return false;
  45. }
  46. }
  47. }
  48. }