-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTypeModifier.cs
More file actions
73 lines (60 loc) · 1.57 KB
/
TypeModifier.cs
File metadata and controls
73 lines (60 loc) · 1.57 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Date: 13.12.2014, Time: 10:51 */
using System;
using System.Reflection.Emit;
using IllidanS4.SharpUtils.Reflection.Emit;
namespace IllidanS4.SharpUtils.Reflection
{
public class TypeModifier : ISignatureElement, IEquatable<TypeModifier>
{
public CorElementType ElementType{get; private set;}
internal TypeModifier(CorElementType elementType)
{
ElementType = elementType;
}
protected virtual void AddSignature(SignatureHelper signature)
{
signature.AddElementType(ElementType);
}
void ISignatureElement.AddSignature(SignatureHelper signature)
{
this.AddSignature(signature);
}
public static implicit operator TypeModifier(Type modifyingType)
{
return new CustomTypeModifier(modifyingType);
}
#region Equals and GetHashCode implementation
public override bool Equals(object obj)
{
TypeModifier other = obj as TypeModifier;
if(other == null)
return false;
return Equals(other);
}
public virtual bool Equals(TypeModifier other)
{
return this.ElementType == other.ElementType;
}
public override int GetHashCode()
{
int hashCode = 0;
unchecked {
hashCode += 1000000007 * ElementType.GetHashCode();
}
return hashCode;
}
public static bool operator ==(TypeModifier lhs, TypeModifier rhs)
{
if (ReferenceEquals(lhs, rhs))
return true;
if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
return false;
return lhs.Equals(rhs);
}
public static bool operator !=(TypeModifier lhs, TypeModifier rhs)
{
return !(lhs == rhs);
}
#endregion
}
}