CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
MethodCacheKey.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="MethodCacheKey.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9
10namespace Csla.Reflection
11{
12 internal class MethodCacheKey
13 {
14 public string TypeName { get; private set; }
15 public string MethodName { get; private set; }
16 public Type[] ParamTypes { get; private set; }
17 private int _hashKey;
18
19 public MethodCacheKey(string typeName, string methodName, Type[] paramTypes)
20 {
21 this.TypeName = typeName;
22 this.MethodName = methodName;
23 this.ParamTypes = paramTypes;
24
25 _hashKey = typeName.GetHashCode();
26 _hashKey = _hashKey ^ methodName.GetHashCode();
27 foreach (Type item in paramTypes)
28#if NETFX_CORE
29 _hashKey = _hashKey ^ item.Name().GetHashCode();
30#else
31 _hashKey = _hashKey ^ item.Name.GetHashCode();
32#endif
33 }
34
35 public override bool Equals(object obj)
36 {
37 MethodCacheKey key = obj as MethodCacheKey;
38 if (key != null &&
39 key.TypeName == this.TypeName &&
40 key.MethodName == this.MethodName &&
41 ArrayEquals(key.ParamTypes, this.ParamTypes))
42 return true;
43
44 return false;
45 }
46
47 private bool ArrayEquals(Type[] a1, Type[] a2)
48 {
49 if (a1.Length != a2.Length)
50 return false;
51
52 for (int pos = 0; pos < a1.Length; pos++)
53 if (a1[pos] != a2[pos])
54 return false;
55 return true;
56 }
57
58 public override int GetHashCode()
59 {
60 return _hashKey;
61 }
62 }
63}