IndexBase.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #region License
  2. /* Copyright 2011 James F. Bellinger <http://www.zer7.com/software/hidsharp>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  13. #endregion
  14. using System.Collections.Generic;
  15. namespace HidSharp.ReportDescriptors.Parser
  16. {
  17. public class IndexBase
  18. {
  19. public static readonly IndexBase Unset = new IndexBase();
  20. public bool ContainsValue(uint value)
  21. {
  22. int index; return IndexFromValue(value, out index);
  23. }
  24. public virtual bool IndexFromValue(uint value, out int index)
  25. {
  26. index = -1; return false;
  27. }
  28. public virtual IEnumerable<uint> ValuesFromIndex(int index)
  29. {
  30. yield break;
  31. }
  32. public virtual int Count
  33. {
  34. get { return 0; }
  35. }
  36. }
  37. }