4
4
5
5
namespace Shared . DataContracts
6
6
{
7
- public struct Id : IComparable , IComparable < Id > , IEquatable < Id > , IFormattable
7
+ public struct Id : IComparable , IComparable < Id > , IEquatable < Id >
8
8
{
9
- // this would also work genericly
10
- // https://stackoverflow.com/questions/5377237/strongly-typing-id-values-in-c-sharp
11
9
private readonly Guid _guid ;
12
- private static readonly Guid _default = Guid . Empty ;
10
+ private static readonly Guid _default = default ( Guid ) ;
13
11
14
12
public Id ( Guid ? guid )
15
13
{
16
- _guid = guid ?? Guid . Empty ;
14
+ _guid = guid ?? _default ;
17
15
}
18
16
19
- public static readonly Id Default = new Id ( Guid . Empty ) ;
17
+ public bool IsDefault ( )
18
+ {
19
+ return this . _guid . Equals ( _default ) ;
20
+ }
21
+
22
+ public static Id Default ( )
23
+ {
24
+ return new Id ( _default ) ;
25
+ }
20
26
21
27
public static Id New ( )
22
28
{
23
29
return new Id ( Guid . NewGuid ( ) ) ;
24
- }
30
+ }
25
31
26
32
public static explicit operator Id ( Guid guid )
27
33
{
@@ -40,7 +46,7 @@ public override bool Equals(object obj)
40
46
41
47
public int CompareTo ( object obj )
42
48
{
43
- if ( obj is Id )
49
+ if ( obj is Id )
44
50
{
45
51
return this . CompareTo ( ( Id ) obj ) ;
46
52
}
@@ -64,10 +70,6 @@ public override string ToString()
64
70
{
65
71
return _guid . ToString ( ) ;
66
72
}
67
- public string ToString ( string format , IFormatProvider formatProvider )
68
- {
69
- return _guid . ToString ( format , formatProvider ) ;
70
- }
71
73
72
74
public override int GetHashCode ( )
73
75
{
0 commit comments