PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Tools/IronStudio/IronStudio/IronStudio/Navigation/ModuleId.cs

#
C# | 59 lines | 35 code | 7 blank | 17 comment | 6 complexity | 16edf99def316e3e2d6772c64f2f5b28 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. * ***************************************************************************/
  14. using Microsoft.VisualStudio.Shell.Interop;
  15. namespace Microsoft.IronStudio.Navigation {
  16. /// <summary>
  17. /// Class used to identify a module. The module is identified using the hierarchy that
  18. /// contains it and its item id inside the hierarchy.
  19. /// </summary>
  20. public sealed class ModuleId {
  21. private IVsHierarchy _ownerHierarchy;
  22. private uint _itemId;
  23. public ModuleId(IVsHierarchy owner, uint id) {
  24. _ownerHierarchy = owner;
  25. _itemId = id;
  26. }
  27. public IVsHierarchy Hierarchy {
  28. get { return _ownerHierarchy; }
  29. }
  30. public uint ItemID {
  31. get { return _itemId; }
  32. }
  33. public override int GetHashCode() {
  34. int hash = 0;
  35. if (null != _ownerHierarchy) {
  36. hash = _ownerHierarchy.GetHashCode();
  37. }
  38. hash = hash ^ (int)_itemId;
  39. return hash;
  40. }
  41. public override bool Equals(object obj) {
  42. ModuleId other = obj as ModuleId;
  43. if (null == obj) {
  44. return false;
  45. }
  46. if (!_ownerHierarchy.Equals(other._ownerHierarchy)) {
  47. return false;
  48. }
  49. return (_itemId == other._itemId);
  50. }
  51. }
  52. }