Exemplo n.º 1
0
        private T TryCardOperation <T>(Func <SmartCardContext, T> func) where T : class
        {
            try {
                ClearMsg();

                using (var card = new SmartCardContext()) {
                    var readers = card.GetReaders();
                    if (readers.Length == 0)
                    {
                        Alert("No reader is found");
                        return(null);
                    }

                    // TODO: I have one reader only
                    card.OpenReader(readers[0]);
                    var rtn = func(card);
                    card.CloseReader();

                    return(rtn);
                }
            }
            catch (Exception ex) {
                Alert($"Exception: {ex.Message}, check reader and card");
                return(null);
            }
        }
Exemplo n.º 2
0
        public MemoryCardContext(SmartCardContext context, string reader)
        {
            uint version;
            int  ret = MCardInitialize(context.Handle, reader, out this.context, out version);

            if (ret != 0)
            {
                throw new Exception(ret.ToString("x"));
            }
        }
Exemplo n.º 3
0
		public MemoryCardContext(SmartCardContext context, string reader) {
			uint version;
			int ret = MCardInitialize(context.Handle, reader, out this.context, out version);
			if (ret != 0)
				throw new Exception(ret.ToString("x"));
		}