ReportMainItem.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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;
  15. namespace HidSharp.ReportDescriptors.Parser
  16. {
  17. public class ReportMainItem
  18. {
  19. ReportCollection _parent;
  20. public ReportMainItem()
  21. {
  22. Indexes = new LocalIndexes();
  23. }
  24. public LocalIndexes Indexes
  25. {
  26. get;
  27. private set;
  28. }
  29. public ReportCollection Parent
  30. {
  31. get { return _parent; }
  32. set
  33. {
  34. if (_parent == value) { return; }
  35. ReportCollection check = value;
  36. while (check != null && check != this) { check = check.Parent; }
  37. if (check == this) { throw new ArgumentException("Can't set up a loop."); }
  38. if (_parent != null) { _parent._children.Remove(this); }
  39. _parent = value;
  40. if (_parent != null) { _parent._children.Add(this); }
  41. }
  42. }
  43. }
  44. }