Exemple #1
0
 protected internal override void ResetCard(Protocol protocol)
 {
     if (this.CardHandle != IntPtr.Zero)
     {
         this.scardApi.Reconnect(this.CardHandle, SCardDisposition.Reset, SCardShareMode.Exclusive, PcscCardReader.ProtocolToScardProtocol(protocol));
     }
 }
Exemple #2
0
        protected internal override void ConnectCard(Protocol protocol)
        {
            if (this.CardHandle != IntPtr.Zero)
            {
                throw new InvalidOperationException("Smart Card already connected");
            }

            try
            {
                this.CardHandle = this.scardApi.Connect(this.Name, SCardShareMode.Exclusive, PcscCardReader.ProtocolToScardProtocol(protocol));
            }
            catch (SCardException Exception)
            {
                switch (Exception.Error)
                {
                case SCardError.RequestNotSupported:
                case SCardError.ProtocolMismatch:
                    throw new ProtocolNotSupportedException(this.SmartCard, protocol);

                case SCardError.SharingViolation:
                    throw new SmartCardInUseException(this.SmartCard);

                default:
                    throw;
                }
            }
        }