mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-13 15:21:45 +01:00
52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
|
using PCSC;
|
|||
|
using PCSC.Iso7816;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace NFC.Readers.PCSC
|
|||
|
{
|
|||
|
|
|||
|
public class Reader : IReader, IDisposable
|
|||
|
{
|
|||
|
private string _ReaderID;
|
|||
|
private IContextFactory _ContextFactory;
|
|||
|
private ISCardContext _SCardContext;
|
|||
|
private IsoReader _ISOReader;
|
|||
|
private ICard _Card;
|
|||
|
|
|||
|
public Reader(string readerID)
|
|||
|
{
|
|||
|
_ReaderID = readerID;
|
|||
|
}
|
|||
|
|
|||
|
public event ReaderEventHandler CardDiscovered;
|
|||
|
public event ReaderEventHandler CardLost;
|
|||
|
|
|||
|
public void Dispose()
|
|||
|
{
|
|||
|
stop();
|
|||
|
}
|
|||
|
|
|||
|
public void start()
|
|||
|
{
|
|||
|
_ContextFactory = ContextFactory.Instance;
|
|||
|
_SCardContext = _ContextFactory.Establish(SCardScope.System);
|
|||
|
|
|||
|
_ISOReader = new IsoReader(_SCardContext);
|
|||
|
|
|||
|
_Card = new Card(_ISOReader, _ReaderID);
|
|||
|
|
|||
|
CardDiscovered?.Invoke(this, _Card);
|
|||
|
}
|
|||
|
|
|||
|
public void stop()
|
|||
|
{
|
|||
|
CardLost?.Invoke(this, _Card);
|
|||
|
|
|||
|
_ISOReader.Dispose();
|
|||
|
_SCardContext.Dispose();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|