Example #1
0
        private void EstablishContext()
        {
            var platform = Environment.OSVersion.Platform;

            if (platform == PlatformID.Win32S || platform == PlatformID.Win32Windows || platform == PlatformID.Win32NT || platform == PlatformID.WinCE)
            {
                _context = Pcsc <WinSCard> .EstablishContext(SCardScope.User);
            }
            else
            {
                _context = Pcsc <PCSCliteAPI> .EstablishContext(SCardScope.User);
            }
        }
Example #2
0
 static void Main(string[] args)
 {
     using (var context = Pcsc <WinSCard> .EstablishContext(SCardScope.User))
     {
         Console.WriteLine(context.IsEstablished);
         context.Validate();
         context.Release();
         Console.WriteLine(context.IsEstablished);
         try
         {
             context.Validate();
         }
         catch (PcscException ex)
         {
             Console.WriteLine($"0x{ex.NativeErrorCode:X8}: {ex.Message}");
         }
     }
     Console.WriteLine("Hello World!");
 }
        public PcscContext EstablishContext()
        {
            if (_context != null)
            {
                throw new ConnectionException(Constants.ErrorCodes.ContextExists);
            }

            var platform = Environment.OSVersion.Platform;

            if (
                platform == PlatformID.Win32S ||
                platform == PlatformID.Win32Windows ||
                platform == PlatformID.Win32NT ||
                platform == PlatformID.WinCE)
            {
                _context = Pcsc <WinSCard> .EstablishContext(SCardScope.User);
            }
            else
            {
                _context = Pcsc <PCSCliteAPI> .EstablishContext(SCardScope.User);
            }

            return(_context);
        }