PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms 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
 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
15using Microsoft.VisualStudio.Shell.Interop;
16
17namespace Microsoft.IronStudio.Navigation {
18    /// <summary>
19    /// Class used to identify a module. The module is identified using the hierarchy that
20    /// contains it and its item id inside the hierarchy.
21    /// </summary>
22    public sealed class ModuleId {
23        private IVsHierarchy _ownerHierarchy;
24        private uint _itemId;
25
26        public ModuleId(IVsHierarchy owner, uint id) {
27            _ownerHierarchy = owner;
28            _itemId = id;
29        }
30
31        public IVsHierarchy Hierarchy {
32            get { return _ownerHierarchy; }
33        }
34
35        public uint ItemID {
36            get { return _itemId; }
37        }
38
39        public override int GetHashCode() {
40            int hash = 0;
41            if (null != _ownerHierarchy) {
42                hash = _ownerHierarchy.GetHashCode();
43            }
44            hash = hash ^ (int)_itemId;
45            return hash;
46        }
47
48        public override bool Equals(object obj) {
49            ModuleId other = obj as ModuleId;
50            if (null == obj) {
51                return false;
52            }
53            if (!_ownerHierarchy.Equals(other._ownerHierarchy)) {
54                return false;
55            }
56            return (_itemId == other._itemId);
57        }
58    }
59}