Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ServiceRef.cs
1using System.Diagnostics;
2using System.Dynamic;
3using System.Globalization;
4using System.Reflection;
5using Microsoft.Extensions.Localization;
23using ZXing;
24
26{
30 public static class ServiceRef
31 {
32 private static IXmppService? xmppService;
33 private static IUiService? uiService;
34 private static ITagProfile? tagProfile;
35 private static ILogService? logService;
36 private static INetworkService? networkService;
37 private static IContractOrchestratorService? contractOrchestratorService;
38 private static IThingRegistryOrchestratorService? thingRegistryOrchestratorService;
39 private static INeuroWalletOrchestratorService? neuroWalletOrchestratorService;
40 private static IAttachmentCacheService? attachmentCacheService;
41 private static ICryptoService? cryptoService;
42 private static ISettingsService? settingsService;
43 private static IStorageService? storageService;
44 private static INfcService? nfcService;
45 private static INotificationService? notificationService;
46 private static IPushNotificationService? pushNotificationService;
47 private static IStringLocalizer? localizer;
48 private static IPlatformSpecific? platformSpecific;
49 private static IBarcodeReader? barcodeReader;
50
54 public static IUiService UiService
55 {
56 get
57 {
58 uiService ??= App.Instantiate<IUiService>();
59 return uiService;
60 }
61 }
62
67 {
68 get
69 {
70 xmppService ??= App.Instantiate<IXmppService>();
71 return xmppService;
72 }
73 }
74
78 public static ITagProfile TagProfile
79 {
80 get
81 {
82 tagProfile ??= App.Instantiate<ITagProfile>();
83 return tagProfile;
84 }
85 }
86
90 public static ILogService LogService
91 {
92 get
93 {
94 logService ??= App.Instantiate<ILogService>();
95 return logService;
96 }
97 }
98
103 {
104 get
105 {
106 networkService ??= App.Instantiate<INetworkService>();
107 return networkService;
108 }
109 }
110
115 {
116 get
117 {
118 contractOrchestratorService ??= App.Instantiate<IContractOrchestratorService>();
119 return contractOrchestratorService;
120 }
121 }
122
127 {
128 get
129 {
130 thingRegistryOrchestratorService ??= App.Instantiate<IThingRegistryOrchestratorService>();
131 return thingRegistryOrchestratorService;
132 }
133 }
134
139 {
140 get
141 {
142 neuroWalletOrchestratorService ??= App.Instantiate<INeuroWalletOrchestratorService>();
143 return neuroWalletOrchestratorService;
144 }
145 }
146
151 {
152 get
153 {
154 attachmentCacheService ??= App.Instantiate<IAttachmentCacheService>();
155 return attachmentCacheService;
156 }
157 }
158
163 {
164 get
165 {
166 cryptoService ??= App.Instantiate<ICryptoService>();
167 return cryptoService;
168 }
169 }
170
175 {
176 get
177 {
178 settingsService ??= App.Instantiate<ISettingsService>();
179 return settingsService;
180 }
181 }
182
187 {
188 get
189 {
190 storageService ??= App.Instantiate<IStorageService>();
191 return storageService;
192 }
193 }
194
199 {
200 get
201 {
202 nfcService ??= App.Instantiate<INfcService>();
203 return nfcService;
204 }
205 }
206
211 {
212 get
213 {
214 notificationService ??= App.Instantiate<INotificationService>();
215 return notificationService;
216 }
217 }
218
223 {
224 get
225 {
226 pushNotificationService ??= App.Instantiate<IPushNotificationService>();
227 return pushNotificationService;
228 }
229 }
230
234 public static IStringLocalizer Localizer
235 {
236 get
237 {
238 localizer ??= new LocalizerReportingMissingStrings(LocalizationManager.GetStringLocalizer<AppResources>());
239 return localizer;
240 }
241 }
242
247 private class LocalizerReportingMissingStrings(IStringLocalizer Localizer) : IStringLocalizer
248 {
249 private readonly IStringLocalizer localizer = Localizer;
250
251 public LocalizedString this[string Name]
252 {
253 get
254 {
255 LocalizedString Result = this.localizer[Name];
256 if (Result is not null && !Result.ResourceNotFound)
257 return Result;
258
259 StackTrace Trace = new();
260 Type Caller = typeof(ServiceRef);
261 int i, c = Trace.FrameCount;
262 Assembly ThisAssembly = typeof(App).Assembly;
263
264 for (i = 1; i < c; i++)
265 {
266 Type? T = Trace.GetFrame(i)?.GetMethod()?.DeclaringType;
267 if (T is null)
268 continue;
269
270 if (T.Assembly.FullName == ThisAssembly.FullName)
271 {
272 if (T == typeof(LocalizerReportingMissingStrings))
273 continue;
274
275 if (T.IsConstructedGenericType)
276 T = T.GetGenericTypeDefinition();
277
278 Caller = T;
279 break;
280 }
281 }
282
284
285 return new LocalizedString(Name, Name, true);
286 }
287 }
288
289 public LocalizedString this[string Name, params object[] Arguments]
290 {
291 get
292 {
293 LocalizedString Result = this[Name];
294 if (Result.ResourceNotFound)
295 return Result;
296
297 return new LocalizedString(Name, string.Format(CultureInfo.CurrentCulture, Result.Value, Arguments));
298 }
299 }
300
301 public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
302 {
303 return this.localizer.GetAllStrings(includeParentCultures);
304 }
305 }
306
311 {
312 get
313 {
314 platformSpecific ??= ServiceHelper.GetService<IPlatformSpecific>();
315 return platformSpecific;
316 }
317 }
318
319
323 public static IBarcodeReader BarcodeReader
324 {
325 get
326 {
327 barcodeReader ??= ServiceHelper.GetService<IBarcodeReader>();
328 return barcodeReader;
329 }
330 }
331 }
332}
The Application class, representing an instance of the Neuro-Access app.
Definition: App.xaml.cs:69
static void ReportMissingString(string StringId, Type Type)
Reports a missing string
Near-Field Communication (NFC) Service.
Definition: NfcService.cs:19
Android implementation of platform-specific features.
Base class that references services in the app.
Definition: ServiceRef.cs:31
static ILogService LogService
Log service.
Definition: ServiceRef.cs:91
static INetworkService NetworkService
Network service.
Definition: ServiceRef.cs:103
static IAttachmentCacheService AttachmentCacheService
AttachmentCache service.
Definition: ServiceRef.cs:151
static IStorageService StorageService
Storage service.
Definition: ServiceRef.cs:187
static ICryptoService CryptoService
Crypto service.
Definition: ServiceRef.cs:163
static INeuroWalletOrchestratorService NeuroWalletOrchestratorService
Neuro Wallet orchestrator service.
Definition: ServiceRef.cs:139
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
static IContractOrchestratorService ContractOrchestratorService
Contract orchestrator service.
Definition: ServiceRef.cs:115
static IThingRegistryOrchestratorService ThingRegistryOrchestratorService
Thing Registry orchestrator service.
Definition: ServiceRef.cs:127
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:67
static ISettingsService SettingsService
Settings service.
Definition: ServiceRef.cs:175
The TAG Profile is the heart of the digital identity for a specific user/device. Use this instance to...
Definition: TagProfile.cs:24
Represents a service that caches images downloaded via http calls. They are stored for a certain dura...
Orchestrates operations on contracts upon receiving certain events, like approving or rejecting other...
Cryptographic service that helps create passwords and other security related tasks.
A log implementation for logging warnings, exceptions and events.
Definition: ILogService.cs:11
Interface for platform-specific functions.
The network service is a wafer-thin wrapper around the Connectivity object. It exposes an event handl...
Interface for the Near-Field Communication (NFC) Service.
Definition: INfcService.cs:11
Handles common runtime settings that need to be persisted during sessions.
Wraps the Database for easy access to persistent encrypted storage. Use this for any sensitive data.
The TAG Profile is the heart of the digital identity for a specific user/device. Use this instance to...
Definition: ITagProfile.cs:17
Service serializing and managing UI-related tasks.
Definition: IUiService.cs:14
Represents an abstraction of a connection to an XMPP Server.
Definition: IXmppService.cs:35