Skip to content

Commit 3c960d8

Browse files
committed
Avoid drawer and analyzer allocation per-call
1 parent 88ee4db commit 3c960d8

File tree

47 files changed

+355
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+355
-368
lines changed

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/AnsiCodabarBarcodeZplCommandAnalyzer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class AnsiCodabarBarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public AnsiCodabarBarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BK", virtualPrinter) { }
9+
public AnsiCodabarBarcodeZplCommandAnalyzer() : base("^BK") { }
1010

11-
public override ZplElementBase Analyze(string zplCommand)
11+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1212
{
1313
string[] zplDataParts = this.SplitCommand(zplCommand);
1414

1515
bool checkDigit = false;
16-
int height = this.VirtualPrinter.BarcodeInfo.Height;
16+
int height = virtualPrinter.BarcodeInfo.Height;
1717
bool printInterpretationLine = true;
1818
bool printInterpretationLineAboveCode = false;
1919
char startCharacter = 'A';
2020
char stopCharacter = 'A';
2121

22-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
22+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
2323

2424
if (zplDataParts.Length > 1)
2525
{
@@ -52,7 +52,7 @@ public override ZplElementBase Analyze(string zplCommand)
5252
}
5353

5454
//The field data are processing in the FieldDataZplCommandAnalyzer
55-
this.VirtualPrinter.SetNextElementFieldData(new AnsiCodabarFieldData
55+
virtualPrinter.SetNextElementFieldData(new AnsiCodabarFieldData
5656
{
5757
FieldOrientation = fieldOrientation,
5858
StartCharacter = startCharacter,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/AztecBarcodeZplCommandAnalyzer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class AztecBarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public AztecBarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BO", virtualPrinter) { }
9+
public AztecBarcodeZplCommandAnalyzer() : base("^BO") { }
1010

1111
///<inheritdoc/>
12-
public override ZplElementBase Analyze(string zplCommand)
12+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1313
{
1414
string[] zplDataParts = this.SplitCommand(zplCommand);
1515

1616
int tmpint;
17-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
17+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
1818
int magnificationFactor = 2;
1919
bool extendedChannel = false;
2020
int errorControl = 0;
@@ -52,7 +52,7 @@ public override ZplElementBase Analyze(string zplCommand)
5252
idField = zplDataParts[6];
5353
}
5454

55-
this.VirtualPrinter.SetNextElementFieldData(new AztecBarcodeFieldData
55+
virtualPrinter.SetNextElementFieldData(new AztecBarcodeFieldData
5656
{
5757
FieldOrientation = fieldOrientation,
5858
MagnificationFactor = magnificationFactor,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/BarCodeFieldDefaultZplCommandAnalyzer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
44
{
55
public class BarCodeFieldDefaultZplCommandAnalyzer : ZplCommandAnalyzerBase
66
{
7-
public BarCodeFieldDefaultZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BY", virtualPrinter) { }
7+
public BarCodeFieldDefaultZplCommandAnalyzer() : base("^BY") { }
88

99
///<inheritdoc/>
10-
public override ZplElementBase Analyze(string zplCommand)
10+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1111
{
1212
string[] zplDataParts = this.SplitCommand(zplCommand);
1313

@@ -32,9 +32,9 @@ public override ZplElementBase Analyze(string zplCommand)
3232
barcodeHeight = tmpint;
3333
}
3434

35-
this.VirtualPrinter.SetBarcodeModuleWidth(moduleWidth);
36-
this.VirtualPrinter.SetBarcodeWideBarToNarrowBarWidthRatio(wideBarToNarrowBarWidthRatio);
37-
this.VirtualPrinter.SetBarcodeHeight(barcodeHeight);
35+
virtualPrinter.SetBarcodeModuleWidth(moduleWidth);
36+
virtualPrinter.SetBarcodeWideBarToNarrowBarWidthRatio(wideBarToNarrowBarWidthRatio);
37+
virtualPrinter.SetBarcodeHeight(barcodeHeight);
3838

3939
return null;
4040
}

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ChangeAlphanumericDefaultFontZplCommandAnalyzer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
44
{
55
public class ChangeAlphanumericDefaultFontZplCommandAnalyzer : ZplCommandAnalyzerBase
66
{
7-
public ChangeAlphanumericDefaultFontZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^CF", virtualPrinter) { }
7+
public ChangeAlphanumericDefaultFontZplCommandAnalyzer() : base("^CF") { }
88

99
///<inheritdoc/>
10-
public override ZplElementBase Analyze(string zplCommand)
10+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1111
{
1212
string[] zplDataParts = this.SplitCommand(zplCommand);
1313

14-
this.VirtualPrinter.SetFontName(zplDataParts[0]);
14+
virtualPrinter.SetFontName(zplDataParts[0]);
1515

1616
int tmpint;
1717
int fontHeight = 9;
@@ -27,8 +27,8 @@ public override ZplElementBase Analyze(string zplCommand)
2727
fontWidth = tmpint;
2828
}
2929

30-
this.VirtualPrinter.SetFontHeight(fontHeight);
31-
this.VirtualPrinter.SetFontWidth(fontWidth);
30+
virtualPrinter.SetFontHeight(fontHeight);
31+
virtualPrinter.SetFontWidth(fontWidth);
3232

3333
return null;
3434
}

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ChangeInternationalFontCommandAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
88
public class ChangeInternationalFontCommandAnalyzer : ZplCommandAnalyzerBase
99
{
1010

11-
public ChangeInternationalFontCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^CI", virtualPrinter) { }
11+
public ChangeInternationalFontCommandAnalyzer() : base("^CI") { }
1212

13-
public override ZplElementBase Analyze(string zplCommand)
13+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1414
{
1515
string charSet = zplCommand.Substring(this.PrinterCommandPrefix.Length);
1616

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/Code128BarcodeZplCommandAnalyzer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using BinaryKits.Zpl.Label;
1+
using BinaryKits.Zpl.Label;
22
using BinaryKits.Zpl.Label.Elements;
33
using BinaryKits.Zpl.Viewer.Models;
44

55
namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class Code128BarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public Code128BarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BC", virtualPrinter) { }
9+
public Code128BarcodeZplCommandAnalyzer() : base("^BC") { }
1010

1111
///<inheritdoc/>
12-
public override ZplElementBase Analyze(string zplCommand)
12+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1313
{
1414
string[] zplDataParts = this.SplitCommand(zplCommand);
1515

16-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
16+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
1717

1818
int tmpint;
19-
int height = this.VirtualPrinter.BarcodeInfo.Height;
19+
int height = virtualPrinter.BarcodeInfo.Height;
2020
bool printInterpretationLine = true;
2121
bool printInterpretationLineAboveCode = false;
2222
bool uccCheckDigit = false;
@@ -48,7 +48,7 @@ public override ZplElementBase Analyze(string zplCommand)
4848
}
4949

5050
//The field data are processing in the FieldDataZplCommandAnalyzer
51-
this.VirtualPrinter.SetNextElementFieldData(new Code128BarcodeFieldData
51+
virtualPrinter.SetNextElementFieldData(new Code128BarcodeFieldData
5252
{
5353
FieldOrientation = fieldOrientation,
5454
Height = height,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/Code39BarcodeZplCommandAnalyzer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using BinaryKits.Zpl.Label;
1+
using BinaryKits.Zpl.Label;
22
using BinaryKits.Zpl.Label.Elements;
33
using BinaryKits.Zpl.Viewer.Models;
44

55
namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class Code39BarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public Code39BarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^B3", virtualPrinter) { }
9+
public Code39BarcodeZplCommandAnalyzer() : base("^B3") { }
1010

1111
///<inheritdoc/>
12-
public override ZplElementBase Analyze(string zplCommand)
12+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1313
{
1414
string[] zplDataParts = this.SplitCommand(zplCommand);
1515

1616
int tmpint;
1717
bool mod43CheckDigit = false;
18-
int height = this.VirtualPrinter.BarcodeInfo.Height;
18+
int height = virtualPrinter.BarcodeInfo.Height;
1919
bool printInterpretationLine = true;
2020
bool printInterpretationLineAboveCode = false;
2121

22-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
22+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
2323
if (zplDataParts.Length > 1)
2424
{
2525
mod43CheckDigit = this.ConvertBoolean(zplDataParts[1]);
@@ -41,7 +41,7 @@ public override ZplElementBase Analyze(string zplCommand)
4141
}
4242

4343
//The field data are processing in the FieldDataZplCommandAnalyzer
44-
this.VirtualPrinter.SetNextElementFieldData(new Code39BarcodeFieldData
44+
virtualPrinter.SetNextElementFieldData(new Code39BarcodeFieldData
4545
{
4646
FieldOrientation = fieldOrientation,
4747
Height = height,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/Code93BarcodeZplCommandAnalyzer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class Code93BarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public Code93BarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BA", virtualPrinter) { }
9+
public Code93BarcodeZplCommandAnalyzer() : base("^BA") { }
1010

1111
///<inheritdoc/>
12-
public override ZplElementBase Analyze(string zplCommand)
12+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1313
{
1414
string[] zplDataParts = this.SplitCommand(zplCommand);
1515

1616
int tmpint;
1717
bool printCheckDigit = false;
18-
int height = this.VirtualPrinter.BarcodeInfo.Height;
18+
int height = virtualPrinter.BarcodeInfo.Height;
1919
bool printInterpretationLine = true;
2020
bool printInterpretationLineAboveCode = false;
2121

22-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
22+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
2323
if (zplDataParts.Length > 1 && int.TryParse(zplDataParts[1], out tmpint))
2424
{
2525
height = tmpint;
@@ -41,7 +41,7 @@ public override ZplElementBase Analyze(string zplCommand)
4141
}
4242

4343
//The field data are processing in the FieldDataZplCommandAnalyzer
44-
this.VirtualPrinter.SetNextElementFieldData(new Code93BarcodeFieldData
44+
virtualPrinter.SetNextElementFieldData(new Code93BarcodeFieldData
4545
{
4646
FieldOrientation = fieldOrientation,
4747
Height = height,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/CodeEAN13BarcodeZplCommandAnalyzer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using BinaryKits.Zpl.Label;
1+
using BinaryKits.Zpl.Label;
22
using BinaryKits.Zpl.Label.Elements;
33
using BinaryKits.Zpl.Viewer.Models;
44

55
namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
66
{
77
public class CodeEAN13BarcodeZplCommandAnalyzer : ZplCommandAnalyzerBase
88
{
9-
public CodeEAN13BarcodeZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^BE", virtualPrinter) { }
9+
public CodeEAN13BarcodeZplCommandAnalyzer() : base("^BE") { }
1010

1111
///<inheritdoc/>
12-
public override ZplElementBase Analyze(string zplCommand)
12+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1313
{
1414
string[] zplDataParts = this.SplitCommand(zplCommand);
1515

16-
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0]);
16+
FieldOrientation fieldOrientation = this.ConvertFieldOrientation(zplDataParts[0], virtualPrinter);
1717

1818
int tmpint;
19-
int height = this.VirtualPrinter.BarcodeInfo.Height;
19+
int height = virtualPrinter.BarcodeInfo.Height;
2020
bool printInterpretationLine = true;
2121
bool printInterpretationLineAboveCode = false;
2222

@@ -36,7 +36,7 @@ public override ZplElementBase Analyze(string zplCommand)
3636
}
3737

3838
//The field data are processing in the FieldDataZplCommandAnalyzer
39-
this.VirtualPrinter.SetNextElementFieldData(new CodeEAN13BarcodeFieldData
39+
virtualPrinter.SetNextElementFieldData(new CodeEAN13BarcodeFieldData
4040
{
4141
FieldOrientation = fieldOrientation,
4242
Height = height,

src/BinaryKits.Zpl.Viewer/CommandAnalyzers/CommentZplCommandAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
44
{
55
public class CommentZplCommandAnalyzer : ZplCommandAnalyzerBase
66
{
7-
public CommentZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^FX", virtualPrinter) { }
7+
public CommentZplCommandAnalyzer() : base("^FX") { }
88

99
///<inheritdoc/>
10-
public override ZplElementBase Analyze(string zplCommand)
10+
public override ZplElementBase Analyze(string zplCommand, VirtualPrinter virtualPrinter, IPrinterStorage printerStorage)
1111
{
1212
string comment = zplCommand.Substring(this.PrinterCommandPrefix.Length);
13-
this.VirtualPrinter.AddComment(comment);
13+
virtualPrinter.AddComment(comment);
1414

1515
return null;
1616
}

0 commit comments

Comments
 (0)