public void Reconnect(CardInitialization initialization, ReaderSharingMode mode, Protocol preferredProtocol)
        {
            var connectResult = WinSCardWrapper.Reconnect(Handle, mode, initialization, preferredProtocol);

            Handle         = connectResult.ConnectionHandle;
            ActiveProtocol = connectResult.Protocol;
            ConnectionMode = mode;
        }
        public void Connect(ReaderSharingMode mode, Protocol preferredProtocol)
        {
            var readerNameBytes = BinaryHelper.ConvertNullTerminatedByteArrayFromString(Encoding, PcscReaderName);
            var connectResult   = WinSCardWrapper.Connect(ContextHandler.Instance.Handle, readerNameBytes.ToArray(), mode, preferredProtocol);

            Handle         = connectResult.ConnectionHandle;
            ActiveProtocol = connectResult.Protocol;
            ConnectionMode = mode;
        }
        public static ConnectResult Reconnect(IntPtr connectionHandle, ReaderSharingMode readerSharingMode, CardInitialization initialization, Protocol protocol)
        {
            var retCode = SCardReconnect(connectionHandle, (int)readerSharingMode, (int)protocol, (int)initialization, out var activeProtocol);

            if (SuccessCode != retCode)
            {
                throw ExceptionHelper.PrepareException(retCode, "SCardReconnect");
            }

            return(new ConnectResult {
                ConnectionHandle = connectionHandle, Protocol = (Protocol)activeProtocol
            });
        }
        public static ConnectResult Connect(IntPtr contextHandle, byte[] readerNameBytes, ReaderSharingMode readerSharingMode, Protocol protocol)
        {
            var retCode = SCardConnect(contextHandle, readerNameBytes, (int)readerSharingMode, (int)protocol, out var tempHandle, out var activeProtocol);

            if (SuccessCode != retCode)
            {
                throw ExceptionHelper.PrepareException(retCode, "SCardConnect");
            }

            return(new ConnectResult {
                ConnectionHandle = tempHandle, Protocol = (Protocol)activeProtocol
            });
        }