| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Utilities\HashCodeProvider.cs | - | 100.0 % | 100.0 % | 100.0 % |
|
1 | ||
2 | #region Apache Notice | |
3 | /***************************************************************************** | |
4 | * $Header: $ | |
5 | * $Revision: $ | |
6 | * $Date: $ | |
7 | * | |
8 | * iBATIS.NET Data Mapper | |
9 | * Copyright (C) 2004 - Gilles Bayon | |
10 | * | |
11 | * | |
12 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
13 | * you may not use this file except in compliance with the License. | |
14 | * You may obtain a copy of the License at | |
15 | * | |
16 | * http://www.apache.org/licenses/LICENSE-2.0 | |
17 | * | |
18 | * Unless required by applicable law or agreed to in writing, software | |
19 | * distributed under the License is distributed on an "AS IS" BASIS, | |
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
21 | * See the License for the specific language governing permissions and | |
22 | * limitations under the License. | |
23 | * | |
24 | ********************************************************************************/ | |
25 | #endregion | |
26 | ||
27 | #region Imports | |
28 | using System; | |
29 | #endregion | |
30 | ||
31 | namespace IBatisNet.Common.Utilities | |
32 | { | |
33 | /// <summary> | |
34 | /// Summary description for HashCodeProvider. | |
35 | /// </summary> | |
36 | public class HashCodeProvider | |
37 | { | |
38 | /// <summary> | |
39 | /// Supplies a hash code for an object. | |
40 | /// </summary> | |
41 | /// <param name="obj">The object.</param> | |
42 | /// <returns>A hash code</returns> | |
43 | /// <remarks> | |
44 | /// Buggy in .NET V1.0 | |
45 | /// .NET Fx v1.1 Update: | |
46 | /// As of v1.1 of the framework, there is a method System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(object) that does this as well. | |
47 | /// I will not use to Keep compatiblity with .NET V1.0 | |
48 | /// </remarks> | |
49 | 181 | public static int GetIdentityHashCode(object obj) |
50 | { | |
51 | 181 | System.Reflection.MethodInfo methodInfo = null; |
52 | 181 | Type type = typeof(object); |
53 | ||
54 | 181 | methodInfo = type.GetMethod("GetHashCode"); |
55 | 181 | return (int) methodInfo.Invoke(obj, null); |
56 | } | |
57 | } | |
58 | } | |
59 |
|