本文整理汇总了C#中Response.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Response.Add方法的具体用法?C# Response.Add怎么用?C# Response.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Summary
public Response Summary()
{
Response response = new Response();
// response.Add("AccountTests", accountService.GetAccountTestSummary());
response.Add("CardSummary", summaryService.GetMasterDataSummary<Card>(card => card.Class));
//response.Add("EquipSummary", summaryService.GetMasterDataSummary<Equip>());
//response.Add("AreaSummary", summaryService.GetMasterDataSummary<Area>());
return response;
}
示例2: Transmit
/// <summary>Transmits the specified command APDU.</summary>
/// <param name="commandApdu">The command APDU.</param>
/// <returns>A response containing one ore more <see cref="ResponseApdu" />.</returns>
public virtual Response Transmit(CommandApdu commandApdu) {
if (commandApdu == null) {
throw new ArgumentNullException("commandApdu");
}
// prepare send buffer (Check Command APDU and convert it to an byte array)
byte[] sendBuffer;
try {
sendBuffer = commandApdu.ToArray();
} catch (InvalidOperationException exception) {
throw new InvalidApduException("Invalid APDU.", commandApdu, exception);
}
// create Response object
var response = new Response();
// prepare receive buffer (Response APDU)
var receiveBufferLength = commandApdu.ExpectedResponseLength; // expected size that shall be returned
var receiveBuffer = new byte[receiveBufferLength];
var receivePci = new SCardPCI();
var responseApdu = SimpleTransmit(
sendBuffer,
sendBuffer.Length,
commandApdu.Case, // ISO case used by the Command APDU
commandApdu.Protocol, // Protocol used by the Command APDU
receivePci,
ref receiveBuffer,
ref receiveBufferLength);
/* Check status word SW1SW2:
*
* 1. 0x6cxx -> Set response buffer size Le <- SW2
* 2. AND/OR 0x61xx -> More data can be read with GET RESPONSE
*/
if (responseApdu.SW1 == (byte) SW1Code.ErrorP3Incorrect) {
// Case 1: SW1=0x6c, Previous Le/P3 not accepted -> Set le = SW2
var resendCmdApdu = (CommandApdu) commandApdu.Clone();
if (responseApdu.SW2 == 0) {
resendCmdApdu.Le = 0; // 256
receiveBufferLength = 256 + 2; // 2 bytes for status word
} else {
resendCmdApdu.Le = responseApdu.SW2;
receiveBufferLength = responseApdu.SW2 + 2; // 2 bytes for status word
}
receiveBuffer = new byte[receiveBufferLength];
receivePci = new SCardPCI();
try {
sendBuffer = resendCmdApdu.ToArray();
// Shall we wait until we re-send we APDU/TPDU?
if (RetransmitWaitTime > 0) {
Thread.Sleep(RetransmitWaitTime);
}
// send Command APDU again with new Le value
responseApdu = SimpleTransmit(
sendBuffer,
sendBuffer.Length,
resendCmdApdu.Case,
resendCmdApdu.Protocol,
receivePci,
ref receiveBuffer,
ref receiveBufferLength);
} catch (InvalidOperationException ex) {
throw new InvalidApduException("Got SW1=0x6c. Retransmission failed because of an invalid APDU.",
resendCmdApdu, ex);
}
}
if (responseApdu.SW1 == (byte) SW1Code.NormalDataResponse) {
// Case 2: SW1=0x61, More data available -> GET RESPONSE
/* The transmission system shall issue a GET RESPONSE command APDU (or TPDU)
* to the card by assigning the minimum of SW2 and Le to parameter Le (or P3)).
* Le = min(Le,SW2)
*/
var le = (commandApdu.Le < responseApdu.SW2)
? commandApdu.Le
: responseApdu.SW2;
do {
// add the last ResponseAPDU to the Response object
response.Add(responseApdu);
response.Add(receivePci);
var getResponseApdu = ConstructGetResponseApdu(ref le);
if (le == 0) {
receiveBufferLength = 256 + 2; // 2 bytes for status word
} else {
receiveBufferLength = le + 2; // 2 bytes for status word
}
//.........这里部分代码省略.........