当前位置: 首页>>代码示例>>C#>>正文


C# Command.ToArray方法代码示例

本文整理汇总了C#中Command.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Command.ToArray方法的具体用法?C# Command.ToArray怎么用?C# Command.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


在下文中一共展示了Command.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Select

		public static Stream Select(SmartCard card, SelectType selectType, byte[] file, SelectFileOccurrence fileOccurrence, SelectFileControlInformation fileControlInformation, int expectedLength) {
			Command cmd = new Command();
			cmd.Instruction = 0xA4;
			cmd.Parameter1 = (byte)selectType;
			cmd.Parameter2 = (byte)((byte)fileOccurrence | (byte)fileControlInformation);
			cmd.Data = file;
			cmd.ResponseLength = expectedLength;
			byte[] command = cmd.ToArray();
			byte[] buffer = new byte[256];
			//Console.Write("Sending command {0}...", BitConverter.ToString(command));
			int len = card.Transmit(command, buffer);
			//Console.WriteLine(BitConverter.ToString(buffer, 0, len));
			CommandStatus status = GetStatus(buffer, len);
			if (!status.IsNormal())
				throw status.ToException();
			Stream result = new MemoryStream();
			result.Write(buffer, 0, len - 2);
			while (status.Sw1 == 0x61) {
				throw new NotImplementedException("Reading of remaining length not implemented");
			}
			return result;
		}
开发者ID:hosumayok,项目名称:pcsc-sharp,代码行数:22,代码来源:Commands.cs

示例2: ReadBinary

		public static Stream ReadBinary(SmartCard card, int offset, int expectedLength) {
			if ((offset < 0) || (offset > 0x7FFF))
				throw new ArgumentOutOfRangeException("offset");
			Command cmd = new Command();
			cmd.Instruction = 0xB0;
			cmd.Parameter1 = (byte)((offset >> 8) & 0x7F);
			cmd.Parameter2 = (byte)offset;
			cmd.ResponseLength = expectedLength;
			byte[] command = cmd.ToArray();
			byte[] buffer = new byte[expectedLength + 2];
			//Console.Write("Sending command {0}...", BitConverter.ToString(command));
			int len = card.Transmit(command, buffer);
			//Console.WriteLine(BitConverter.ToString(buffer, 0, len));
			CommandStatus status = GetStatus(buffer, len);
			if (!status.IsNormal())
				throw status.ToException();
			Stream result = new MemoryStream();
			result.Write(buffer, 0, len - 2);
			while (status.Sw1 == 0x61) {
				throw new NotImplementedException("Reading of remaining length not implemented");
			}
			result.Position = 0;
			return result;
		}
开发者ID:hosumayok,项目名称:pcsc-sharp,代码行数:24,代码来源:Commands.cs


注:本文中的Command.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。