WitIntValue.cs 979 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. using Meta.WitAi.Json;
  9. namespace Meta.WitAi.Data
  10. {
  11. public class WitIntValue : WitValue
  12. {
  13. public override object GetValue(WitResponseNode response)
  14. {
  15. return GetIntValue(response);
  16. }
  17. public override bool Equals(WitResponseNode response, object value)
  18. {
  19. int iValue = 0;
  20. if (value is int i)
  21. {
  22. iValue = i;
  23. }
  24. else if (null != value && !int.TryParse("" + value, out iValue))
  25. {
  26. return false;
  27. }
  28. return GetIntValue(response) == iValue;
  29. }
  30. public int GetIntValue(WitResponseNode response)
  31. {
  32. return Reference.GetIntValue(response);
  33. }
  34. }
  35. }