1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2 
3 using System.Diagnostics.CodeAnalysis;
4 using System.Linq.Expressions;
5 using System.Reflection;
6 
7 #pragma warning disable 659 // overrides AddToHashCodeCombiner instead
8 
9 namespace System.Web.Mvc.ExpressionUtil
10 {
11     // MemberExpression fingerprint class
12     // Expression of form xxx.FieldOrProperty
13 
14     [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")]
15     internal sealed class MemberExpressionFingerprint : ExpressionFingerprint
16     {
MemberExpressionFingerprint(ExpressionType nodeType, Type type, MemberInfo member)17         public MemberExpressionFingerprint(ExpressionType nodeType, Type type, MemberInfo member)
18             : base(nodeType, type)
19         {
20             Member = member;
21         }
22 
23         // http://msdn.microsoft.com/en-us/library/system.linq.expressions.memberexpression.member.aspx
24         public MemberInfo Member { get; private set; }
25 
Equals(object obj)26         public override bool Equals(object obj)
27         {
28             MemberExpressionFingerprint other = obj as MemberExpressionFingerprint;
29             return (other != null)
30                    && Equals(this.Member, other.Member)
31                    && this.Equals(other);
32         }
33 
AddToHashCodeCombiner(HashCodeCombiner combiner)34         internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
35         {
36             combiner.AddObject(Member);
37             base.AddToHashCodeCombiner(combiner);
38         }
39     }
40 }
41