forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexExpressionFingerprint.cs
More file actions
44 lines (36 loc) · 1.72 KB
/
Copy pathIndexExpressionFingerprint.cs
File metadata and controls
44 lines (36 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Reflection;
#pragma warning disable 659 // overrides AddToHashCodeCombiner instead
namespace System.Web.Mvc.ExpressionUtil
{
// IndexExpression fingerprint class
// Represents certain forms of array access or indexer property access
[SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")]
internal sealed class IndexExpressionFingerprint : ExpressionFingerprint
{
public IndexExpressionFingerprint(ExpressionType nodeType, Type type, PropertyInfo indexer)
: base(nodeType, type)
{
// Other properties on IndexExpression (like the argument count) are simply derived
// from Type and Indexer, so they're not necessary for inclusion in the fingerprint.
Indexer = indexer;
}
// http://msdn.microsoft.com/en-us/library/system.linq.expressions.indexexpression.indexer.aspx
public PropertyInfo Indexer { get; private set; }
public override bool Equals(object obj)
{
IndexExpressionFingerprint other = obj as IndexExpressionFingerprint;
return (other != null)
&& Equals(this.Indexer, other.Indexer)
&& this.Equals(other);
}
internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
{
combiner.AddObject(Indexer);
base.AddToHashCodeCombiner(combiner);
}
}
}