/
Startup.cs
75 lines (59 loc) · 2.72 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using DNI.Shared.Shared.Extensions;
using sInference.Contracts;
using sInference.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sInference
{
public class Startup
{
private readonly ISmartCard _smartCard;
public Startup(ISmartCard smartCard)
{
_smartCard = smartCard;
_smartCard.Authenticated += _smartCard_Authenticated;
_smartCard.Connected += _smartCard_Connected;
_smartCard.Transmitting += _smartCard_Transmitting;
}
private void _smartCard_Transmitting(object sender, SmartCardEventArgs e)
{
Console.WriteLine("{0} transmitting = {1}", string.Join('-',e.State.Stripe), e.StateResult);
}
private void _smartCard_Connected(object sender, SmartCardEventArgs e)
{
Console.WriteLine("{0} connected = {1}", string.Join('-',e.State.Stripe), e.StateResult);
}
private void _smartCard_Authenticated(object sender, SmartCardEventArgs e)
{
Console.WriteLine("{0} authenticated", string.Join('-',e.State.Stripe));
}
public async Task Begin(IEnumerable<object> args)
{
var stripe = "BNA49349824398FHQA".ToCharArray();
var stripe2 = "BNA49349824298FHQA".ToCharArray();
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Authenticate, Pin.Send, stripe)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Authenticate, Pin.Send, stripe2)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Connect, Pin.Send, stripe)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.BeginTransmit, Pin.Recieve, stripe)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.BinaryTransmit, Pin.Recieve, stripe, "MyTestData".GetBytes(Encoding.ASCII).ToArray() )));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.BinaryTransmit, Pin.Recieve, stripe, "MyTestData next bit".GetBytes(Encoding.ASCII).ToArray() )));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Disconnect, Pin.Send, stripe)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Request, Pin.Reset, stripe)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Authenticate, Pin.Send, stripe2)));
Console.WriteLine(_smartCard
.Input(SmartCardData.Create(Code.Authenticate, Pin.Send, stripe)));
}
}
}