Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Common / QueryCache / CompiledQueryCacheKey.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="CompiledQueryCacheKey.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner  Microsoft
7 // @backupOwner Microsoft
8 //------------------------------------------------------------------------------
9
10 namespace System.Data.Common.QueryCache
11 {
12     using System;
13     using System.Diagnostics;
14     
15     internal sealed class CompiledQueryCacheKey : QueryCacheKey
16     {
17         private readonly Guid _cacheIdentity;
18
19         internal CompiledQueryCacheKey(Guid cacheIdentity)
20         {
21             _cacheIdentity = cacheIdentity;
22         }
23
24         /// <summary>
25         /// Determines equality of this key with respect to <paramref name="compareTo"/>
26         /// </summary>
27         /// <param name="otherObject"></param>
28         /// <returns></returns>
29         public override bool Equals(object compareTo)
30         {
31             Debug.Assert(compareTo != null, "Comparison key should not be null");
32             if (typeof(CompiledQueryCacheKey) != compareTo.GetType())
33             {
34                 return false;
35             }
36
37             return ((CompiledQueryCacheKey)compareTo)._cacheIdentity.Equals(this._cacheIdentity);
38         }
39
40         /// <summary>
41         /// Returns the hashcode for this cache key
42         /// </summary>
43         /// <returns></returns>
44         public override int GetHashCode()
45         {
46             return _cacheIdentity.GetHashCode();
47         }
48
49         /// <summary>
50         /// Returns a string representation of the state of this cache key
51         /// </summary>
52         /// <returns>
53         /// A string representation that includes query text, parameter information, include path information
54         /// and merge option information about this cache key.
55         /// </returns>
56         public override string ToString()
57         {
58             return _cacheIdentity.ToString();
59         }
60     }
61 }