-
Notifications
You must be signed in to change notification settings - Fork 2k
/
AssemblyPart.cs
67 lines (59 loc) · 2.21 KB
/
AssemblyPart.cs
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
using System;
using System.Diagnostics;
using System.Reflection;
namespace Orleans.ApplicationParts
{
/// <summary>
/// An <see cref="IApplicationPart"/> backed by an <see cref="Assembly"/>.
/// </summary>
[DebuggerDisplay("{" + nameof(Assembly) + "}")]
public class AssemblyPart : IApplicationPart
{
/// <summary>
/// Initializes a new <see cref="AssemblyPart"/> instance.
/// </summary>
/// <param name="assembly"></param>
public AssemblyPart(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException(nameof(assembly));
}
this.Assembly = assembly;
}
/// <summary>
/// Gets or sets a value indicating whether or not this assembly is an Orleans framework assembly.
/// </summary>
public bool IsFrameworkAssembly { get; set; }
/// <summary>
/// Gets the <see cref="Assembly"/> of the <see cref="IApplicationPart"/>.
/// </summary>
public Assembly Assembly { get; }
/// <summary>
/// Returns <see langword="true"/> if this instance is equivalent to the provided instance, <see langword="false"/> otherwise.
/// </summary>
/// <param name="other">The other instance/</param>
/// <returns>
/// <see langword="true"/> if this instance is equivalent to the provided instance, <see langword="false"/> otherwise.
/// </returns>
protected bool Equals(AssemblyPart other)
{
return Equals(this.Assembly, other?.Assembly);
}
/// <inheritdoc />
public bool Equals(IApplicationPart other) => this.Equals(other as AssemblyPart);
/// <inheritdoc />
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((AssemblyPart) obj);
}
/// <inheritdoc />
public override int GetHashCode()
{
return this.Assembly != null ? this.Assembly.GetHashCode() : 0;
}
}
}