-
Notifications
You must be signed in to change notification settings - Fork 252
/
GuidDMAObjectRef.cs
57 lines (48 loc) · 983 Bytes
/
GuidDMAObjectRef.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
using System;
using Skyline.DataMiner.Net.Ownership;
namespace Skyline.DataMiner.Net
{
public interface IGuidDMAObjectRef
{
Guid Id { get; }
}
public static class GuidDMAObjectRefExtentions
{
public static Guid SafeId(this IGuidDMAObjectRef obj)
{
if (obj == null)
return Guid.Empty;
return obj.Id;
}
}
[Serializable]
public abstract class GuidDMAObjectRef<T> : DMAObjectRef, IEquatable<T>, IComparable<T>
where T : class, IGuidDMAObjectRef
{
public abstract Guid Id { get; }
protected GuidDMAObjectRef()
{
}
public bool Equals(T other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Id.Equals(other.Id);
}
public override bool Equals(object obj)
{
return Equals(obj as T);
}
public override int GetHashCode()
{
return 0;
}
public override void Write(SimpleByteWriter writer)
{
}
public int CompareTo(T other)
{
return 0;
}
}
}