Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Wallet.cs
1using System;
6
8{
12 [CollectionName("eDalerWallets")]
13 [TypeName(TypeNameSerialization.None)]
14 [ArchivingTime(3653)] // 10 years
15 [Index("Account", "Created")]
16 public class Wallet
17 {
18 private static readonly ICallStackCheck[] approvedSources = Assert.Convert(new object[]
19 {
20 typeof(XmppServerModule).Assembly,
21 typeof(Persistence.NeuroLedger.NeuroLedgerProvider),
22 DataStorage.Account.FromSaveUnsaved,
23 DataStorage.Account.FromUpdateObject
24 });
25 private static readonly ICallStackCheck[] approvedSourcesTest = Assert.Convert(new object[]
26 {
27 typeof(XmppServerModule).Assembly,
28 typeof(Persistence.NeuroLedger.NeuroLedgerProvider),
29 DataStorage.Account.FromSaveUnsaved,
30 DataStorage.Account.FromUpdateObject,
31 "System.Threading.PortableThreadPool+WorkerThread"
32 });
33
34 private string objectId = null;
36 private CaseInsensitiveString domain = null;
38 private decimal? balance = null;
39 private decimal? reserved = null;
40 private DateTime created = DateTime.MinValue;
41 private DateTime? balanceTimestamp = null;
42
43 public Wallet()
44 {
45 }
46
47 [ObjectId]
48 public string ObjectId
49 {
50 get => this.objectId;
51 set => this.objectId = value;
52 }
53
54 public CaseInsensitiveString Account
55 {
56 get => this.account;
57 set => this.account = value;
58 }
59
60 [DefaultValueNull]
61 public CaseInsensitiveString Domain
62 {
63 get => this.domain;
64 set => this.domain = value;
65 }
66
67 [DefaultValueStringEmpty]
68 public CaseInsensitiveString Currency
69 {
70 get
71 {
72 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
73 return this.currency;
74 }
75
76 set
77 {
78 if (!string.IsNullOrEmpty(this.currency))
79 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
80
81 this.currency = value;
82 }
83 }
84
85 public decimal Balance
86 {
87 get
88 {
89 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
90 return this.balance ?? 0;
91 }
92
93 set
94 {
95 if (this.balance.HasValue)
96 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
97
98 this.balance = value;
99 }
100 }
101
102 public decimal Reserved
103 {
104 get
105 {
106 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
107 return this.reserved ?? 0;
108 }
109
110 set
111 {
112 if (this.reserved.HasValue)
113 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
114
115 this.reserved = value;
116 }
117 }
118
119 public DateTime BalanceTimestamp
120 {
121 get
122 {
123 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
124 return this.balanceTimestamp ?? DateTime.MinValue;
125 }
126
127 set
128 {
129 if (this.balanceTimestamp.HasValue)
130 Assert.CallFromSource((DomainConfiguration.Instance?.UseDomainName ?? false) ? approvedSources : approvedSourcesTest);
131
132 this.balanceTimestamp = value;
133 }
134 }
135
136 public DateTime Created
137 {
138 get => this.created;
139 set => this.created = value;
140 }
141 }
142}
static DomainConfiguration Instance
Current instance of configuration.
bool UseDomainName
If the server uses a domain name.
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
Static class containing methods that can be used to make sure calls are made from appropriate locatio...
Definition: Assert.cs:15
static ICallStackCheck[] Convert(params object[] Sources)
Converts an array of objects into an array of ICallStackCheck objects, assuming each listed source is...
Definition: Assert.cs:99
static void CallFromSource(params string[] Sources)
Makes sure the call is made from one of the listed sources.
Definition: Assert.cs:54
Retains the current balance of an account.
Definition: Wallet.cs:17
Service Module hosting the XMPP broker and its components.
Interface for call stack checks.
TypeNameSerialization
How the type name should be serialized.