Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NfcInterface.cs
1using Android.Nfc;
2using Android.Nfc.Tech;
4
6{
15 public abstract class NfcInterface(Tag Tag, BasicTagTechnology Technology) : INfcInterface
16 {
20 protected readonly Tag tag = Tag;
21
25 protected readonly BasicTagTechnology technology = Technology;
26
27 private bool isDisposed;
28
32 public INfcTag? Tag
33 {
34 get;
35 internal set;
36 }
37
42 public async Task OpenIfClosed()
43 {
44 if (!this.technology.IsConnected)
45 await this.technology.ConnectAsync();
46 }
47
51 public void CloseIfOpen()
52 {
53 if (this.technology.IsConnected)
54 this.technology.Close();
55 }
56
60 public void Dispose()
61 {
62 this.Dispose(true);
63 GC.SuppressFinalize(this);
64 }
65
69 protected virtual void Dispose(bool Disposing)
70 {
71 if (this.isDisposed)
72 return;
73
74 if (Disposing)
75 {
76 this.CloseIfOpen();
77 this.technology.Dispose();
78 this.tag.Dispose();
79 }
80
81 this.isDisposed = true;
82 }
83
88 internal static IOException UnableToReadDataFromDevice()
89 {
90 return new IOException("Unable to read data from device.");
91 }
92 }
93}
Specific Interface (technology) for communication with an NFC Tag.
Interface for an NFC Tag.
Definition: INfcTag.cs:9