generated from Yortw/OssLibTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AfterPaySystemClock.cs
51 lines (41 loc) · 1.77 KB
/
AfterPaySystemClock.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
using System;
using System.Collections.Generic;
using System.Text;
namespace Yort.LatitudePay.InStore
{
/// <summary>
/// Represents the default system clock used by the Yort.LatitudePay.Instore library to retrieve the current date and time.
/// </summary>
/// <remarks>
/// <para>This implementation simply wraps the <see cref="DateTimeOffset.Now"/> property and relies on the underlying system clock for accuracy.</para>
/// <para>This class has a private constructor and cannot be created by user code. To obtain and instance use the static <see cref="DefaultInstance"/> property.</para>
/// </remarks>
public sealed class LatitudePaySystemClock : ILatitudePaySystemClock
{
#region Instance Members
private LatitudePaySystemClock()
{
}
/// <summary>
/// Returns the current date and time from the system clock.
/// </summary>
/// <see cref="System.DateTimeOffset.Now"/>
public DateTimeOffset Now
{
get { return DateTimeOffset.Now; }
}
#endregion
#region Static Memnbers
private static LatitudePaySystemClock? s_DefaultInstance;
/// <summary>
/// Returns an instance of this clock.
/// </summary>
/// <remarks>
/// <para>The instance returned by this method is cached after the first call to reduce allocations, so all subsquent calls will receive the same shared instance.
/// However the property is not thread-safe and two threads calling the method simultanously for the first time may receive different instances.
/// This should not cause a problem as clients should not (and are instructed not to) compare instances or rely on shared instances.</para>
/// </remarks>
public static LatitudePaySystemClock DefaultInstance { get { return s_DefaultInstance ?? (s_DefaultInstance = new LatitudePaySystemClock()); } }
#endregion
}
}