Skip to content

Commit 9b9976f

Browse files
committed
another pass
1 parent aa02d5a commit 9b9976f

4 files changed

+135
-129
lines changed

docs/framework/additional-apis/pos-for-net/creating-a-service-object-sample.md

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -19,127 +19,129 @@ To compile this sample, your project has to have the correct references and glob
1919

2020
## Example
2121

22-
using System;
23-
using Microsoft.PointOfService;
24-
using Microsoft.PointOfService.BaseServiceObjects;
25-
26-
namespace Samples.ServiceObjects.MSR
22+
```csharp
23+
using System;
24+
using Microsoft.PointOfService;
25+
using Microsoft.PointOfService.BaseServiceObjects;
26+
27+
namespace Samples.ServiceObjects.MSR
28+
{
29+
[HardwareId(@"HID\Vid_05e0&Pid_038a", @"HID\Vid_05e0&Pid_038a")]
30+
31+
[ServiceObject(DeviceType.Msr,
32+
"SampleMsr",
33+
"Sample Msr Service Object",
34+
1,
35+
9)]
36+
public class SampleMsr : MsrBase
2737
{
28-
[HardwareId(@"HID\Vid_05e0&Pid_038a", @"HID\Vid_05e0&Pid_038a")]
29-
30-
[ServiceObject(DeviceType.Msr,
31-
"SampleMsr",
32-
"Sample Msr Service Object",
33-
1,
34-
9)]
35-
public class SampleMsr : MsrBase
38+
// String returned from CheckHealth
39+
private string MyHealthText;
40+
41+
public SampleMsr()
3642
{
37-
// String returned from CheckHealth
38-
private string MyHealthText;
43+
// Initialize device capability properties.
44+
Properties.CapIso = true;
45+
Properties.CapTransmitSentinels = true;
46+
Properties.DeviceDescription = "Sample MSR";
3947

40-
public SampleMsr()
41-
{
42-
// Initialize device capability properties.
43-
Properties.CapIso = true;
44-
Properties.CapTransmitSentinels = true;
45-
Properties.DeviceDescription = "Sample MSR";
48+
// Initialize other class variables.
49+
MyHealthText = "";
50+
}
4651

47-
// Initialize other class variables.
48-
MyHealthText = "";
49-
}
52+
~SampleMsr()
53+
{
54+
Dispose(false);
55+
}
5056

51-
~SampleMsr()
57+
// Release any resources managed by this object.
58+
protected override void Dispose(bool disposing)
59+
{
60+
try
5261
{
53-
Dispose(false);
62+
// Your code here.
5463
}
55-
56-
// Release any resources managed by this object.
57-
protected override void Dispose(bool disposing)
64+
finally
5865
{
59-
try
60-
{
61-
// Your code here.
62-
}
63-
finally
64-
{
65-
// Must call base class Dispose.
66-
base.Dispose(disposing);
67-
}
66+
// Must call base class Dispose.
67+
base.Dispose(disposing);
6868
}
69+
}
6970

70-
#region PosCommon overrides
71-
// Returns the result of the last call to CheckHealth().
72-
public override string CheckHealthText
71+
#region PosCommon overrides
72+
// Returns the result of the last call to CheckHealth().
73+
public override string CheckHealthText
74+
{
75+
get
7376
{
74-
get
75-
{
76-
// MsrBasic.VerifyState(mustBeClaimed,
77-
// mustBeEnabled). This may throw an exception.
78-
VerifyState(false, false);
79-
80-
return MyHealthText;
81-
}
77+
// MsrBasic.VerifyState(mustBeClaimed,
78+
// mustBeEnabled). This may throw an exception.
79+
VerifyState(false, false);
80+
81+
return MyHealthText;
8282
}
83+
}
8384

84-
public override string CheckHealth(
85-
HealthCheckLevel level)
86-
{
87-
// Verify that device is open, claimed, and enabled.
88-
VerifyState(true, true);
85+
public override string CheckHealth(
86+
HealthCheckLevel level)
87+
{
88+
// Verify that device is open, claimed, and enabled.
89+
VerifyState(true, true);
8990

90-
// Your code here:
91-
// check the health of the device and return a
92-
// descriptive string.
91+
// Your code here:
92+
// check the health of the device and return a
93+
// descriptive string.
9394
94-
// Cache result in the CheckHealthText property.
95-
MyHealthText = "Ok";
96-
return MyHealthText;
97-
}
95+
// Cache result in the CheckHealthText property.
96+
MyHealthText = "Ok";
97+
return MyHealthText;
98+
}
9899

99-
public override DirectIOData DirectIO(
100-
int command,
101-
int data,
102-
object obj)
103-
{
104-
// Verify that device is open.
105-
VerifyState(false, false);
100+
public override DirectIOData DirectIO(
101+
int command,
102+
int data,
103+
object obj)
104+
{
105+
// Verify that device is open.
106+
VerifyState(false, false);
106107

107-
return new DirectIOData(data, obj);
108-
}
109-
#endregion // PosCommon overrides
110-
111-
#region MsrBasic Overrides
112-
protected override MsrFieldData ParseMsrFieldData(
113-
byte[] track1Data,
114-
byte[] track2Data,
115-
byte[] track3Data,
116-
byte[] track4Data,
117-
CardType cardType)
118-
{
119-
// Your code here:
120-
// Implement this method to parse track data
121-
// into fields which will be returned as
122-
// properties to the application
123-
// (for example, FirstName,
124-
// AccountNumber, etc.)
125-
return new MsrFieldData();
126-
}
108+
return new DirectIOData(data, obj);
109+
}
110+
#endregion // PosCommon overrides
111+
112+
#region MsrBasic Overrides
113+
protected override MsrFieldData ParseMsrFieldData(
114+
byte[] track1Data,
115+
byte[] track2Data,
116+
byte[] track3Data,
117+
byte[] track4Data,
118+
CardType cardType)
119+
{
120+
// Your code here:
121+
// Implement this method to parse track data
122+
// into fields which will be returned as
123+
// properties to the application
124+
// (for example, FirstName,
125+
// AccountNumber, etc.)
126+
return new MsrFieldData();
127+
}
127128

128-
protected override MsrTrackData ParseMsrTrackData(
129-
byte[] track1Data,
130-
byte[] track2Data,
131-
byte[] track3Data,
132-
byte[] track4Data,
133-
CardType cardType)
134-
{
129+
protected override MsrTrackData ParseMsrTrackData(
130+
byte[] track1Data,
131+
byte[] track2Data,
132+
byte[] track3Data,
133+
byte[] track4Data,
134+
CardType cardType)
135+
{
135136

136-
// Your code here:
137-
// Implement this method to convert raw track data.
138-
return new MsrTrackData();
139-
}
140-
#endregion
137+
// Your code here:
138+
// Implement this method to convert raw track data.
139+
return new MsrTrackData();
141140
}
141+
#endregion
142142
}
143+
}
144+
```
143145

144146
In order to simplify this sample, the code does not implement any globalization features. For example, the value for **Properties.DeviceDescription** would typically be read from a localized strings resource file.
145147

docs/framework/additional-apis/pos-for-net/exception-classes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following table provides a mapping between the UnifiedPOS standard error cod
5353
| NotClaimed | E_NOTCLAIMED | The POS application attempted to access an exclusive-use device that must be claimed before the method or property set action can be used. |
5454
| Offline | E_OFFLINE | The POS device is offline. |
5555
| Timeout | E_TIMEOUT | The Service Object timed out waiting for a response from the POS device. |
56+
5657
## Example
5758

5859
The following code example demonstrates how MSR handles POS exceptions and uses the **ErrorCodes** contained in those exceptions to gather information about them.

docs/framework/additional-apis/pos-for-net/linedisplay-sample.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ namespace SOSample.LineDisplay
161161
}
162162
}
163163
```
164+
164165
## See Also
165166

166167
#### Other Resources

docs/framework/additional-apis/pos-for-net/using-visual-studio-net-management-extensions-and-the-pos-for-net-wmi-management-classes.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,37 @@ This feature requires that Visual Studio 2013 and POS for .NET are installed on
4141

4242
The following code example demonstrates the use of the **PosDevice** class **GetInstances** method to enumerate Point of Service devices. It creates a collection of the devices within a scope. It then lists the type, name and path for each device in the collection and indicates whether the device is enabled or disabled.
4343

44-
using System;
45-
using System.Management;
46-
using ROOT.MICROSOFTPOINTOFSERVICE;
47-
48-
namespace Management
49-
{
50-
public class Test
51-
{
52-
public Test()
53-
{
54-
ManagementScope scope = new ManagementScope("root\\microsoftpointofservice");
55-
scope.Connect();
56-
PosDevice.PosDeviceCollection devices = PosDevice.GetInstances(scope, "");
57-
string format = "{0,10}\t{1,25}\t{2}\t{3,50}";
58-
if( devices.Count > 0 )
59-
Console.WriteLine(format, "Type", "Name", "Enabled", "Path");
60-
foreach( PosDevice d in devices )
61-
{
62-
Console.WriteLine(format, d.Type, d.SoName, d.Enabled ? 'Y' : 'N', d.Path);
63-
}
64-
}
65-
66-
static int Main()
67-
{
68-
Test t = new Test();
69-
return 0;
70-
}
71-
}
72-
}
44+
```csharp
45+
using System;
46+
using System.Management;
47+
using ROOT.MICROSOFTPOINTOFSERVICE;
48+
49+
namespace Management
50+
{
51+
public class Test
52+
{
53+
public Test()
54+
{
55+
ManagementScope scope = new ManagementScope("root\\microsoftpointofservice");
56+
scope.Connect();
57+
PosDevice.PosDeviceCollection devices = PosDevice.GetInstances(scope, "");
58+
string format = "{0,10}\t{1,25}\t{2}\t{3,50}";
59+
if( devices.Count > 0 )
60+
Console.WriteLine(format, "Type", "Name", "Enabled", "Path");
61+
foreach( PosDevice d in devices )
62+
{
63+
Console.WriteLine(format, d.Type, d.SoName, d.Enabled ? 'Y' : 'N', d.Path);
64+
}
65+
}
66+
67+
static int Main()
68+
{
69+
Test t = new Test();
70+
return 0;
71+
}
72+
}
73+
}
74+
```
7375

7476
## See Also
7577

0 commit comments

Comments
 (0)