예제 #1
0
        /// <inheritdoc />
        /// <summary>
        /// Lists readers within given reader groups.
        /// </summary>
        /// <param name="readerGroups">Names of the reader groups</param>
        /// <returns>String array with names of active readers.</returns>
        public IReadOnlyList <string> ListReaders(IReadOnlyList <string> readerGroups)
        {
            byte[] multiNullTerminatedBytesArray;

            try
            {
                var readerGroupsBytes = readerGroups == null
                    ? null
                    : BinaryHelper.ConvertMultiNullTerminatedByteArrayFromStringEnumerable(Encoding, readerGroups)
                                        .ToArray();

                multiNullTerminatedBytesArray = WinSCardWrapper.ListReaders(Handle, readerGroupsBytes);
            }
            catch (Win32Exception e) when(e.ErrorCodeEquals(0x8010002E))  // 0x8010002E -> SCARD_E_NO_READERS_AVAILABLE
            {
                multiNullTerminatedBytesArray = new byte [0];
            }

            return((IReadOnlyList <string>)BinaryHelper.ConvertByteToString(Encoding,
                                                                            multiNullTerminatedBytesArray));
        }