using System; using NFC.ISO7816_4; namespace NFC { /// /// Abstract representation of the platform specific NFC Hardware. /// public interface IHardware { /// /// Check if the device has nfc support. /// /// Returns true if the device supports NFC. bool IsAvailable(); /// Returns all available readers. string[] GetReaders(); /// /// Create a new reader instance from the specified id. /// /// Returns the spatform specific reader that corresponds to the id. /// Invalid reader id. IReader OpenReader(string readerID); } public delegate void ReaderEventHandler(object sender, ICard card); /// /// Abstraction of a platform-specifc reader that can communicate with NFC cards. /// public interface IReader { /// /// Event that will be called when a new tag was discovered. /// event ReaderEventHandler CardDiscovered; /// /// Event that will be called when a tag that is in use gets disconnected. /// event ReaderEventHandler CardLost; void Start(); void Stop(); } public interface ICard { /// /// Connect to Smartcard /// void Connect(); /// /// Disconnect from Smartcard /// void Disconnect(); /// /// Transmit APDU Command to Smartcard /// /// Application Protocol Data Unit Command - ISO 7816 /// Application Protocol Data Unit Response - ISO 7816 APDUResponse Transmit(APDUCommand apdu_cmd); } public class ReaderUnavailableException : Exception { } public class CardUnavailableException : Exception { } public class APDUException : Exception { public readonly byte ResponseCode; } }