web configuration
This commit is contained in:
@@ -31,10 +31,32 @@ public class PrintServerBootstrapper
|
||||
{
|
||||
_kernel = new StandardKernel();
|
||||
|
||||
_kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
|
||||
_kernel.Bind<HttpClient>().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope();
|
||||
_kernel.Bind<EpsonPrintServiceConfiguration>().ToConstant(_config);
|
||||
_kernel.Bind<IPrinterFactory>().To<EpsonPrinterFactory>();
|
||||
|
||||
if (_config.EmulationMode)
|
||||
{
|
||||
var emulationConfigs = new Dictionary<string, (string OutputPath, byte PrinterId, int PaperWidth)>
|
||||
{
|
||||
["127.0.0.2"] = ("emulation/u220.html", 0x13, 258),
|
||||
["127.0.0.3"] = ("emulation/t30.html", 0x01, 384),
|
||||
};
|
||||
|
||||
var discovery = new PreconfiguredDiscoveryService();
|
||||
discovery.AddPrinter("127.0.0.2", "TM-U220II");
|
||||
discovery.AddPrinter("127.0.0.3", "TM-T30III");
|
||||
_kernel.Bind<IDiscoveryService>().ToConstant(discovery).InSingletonScope();
|
||||
|
||||
_kernel.Bind<IPrinterFactory>().ToMethod(ctx =>
|
||||
new EmulationPrinterFactory(emulationConfigs, ctx.Kernel.Get<ILogger>()));
|
||||
|
||||
Console.WriteLine("Emulation mode enabled: 127.0.0.2 (TM-U220II), 127.0.0.3 (TM-T30III)");
|
||||
}
|
||||
else
|
||||
{
|
||||
_kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
|
||||
_kernel.Bind<IPrinterFactory>().To<EpsonPrinterFactory>();
|
||||
}
|
||||
_kernel.Bind<IPrintJobSource, SignalRPrintJobSource>().To<SignalRPrintJobSource>().InSingletonScope();
|
||||
_kernel.Bind<IPrintService>().To<Inspectron.Epson.PrintServer.PrintServices.EpsonPrintService>();
|
||||
_kernel.Bind<ILogger>().ToMethod(ctx =>
|
||||
|
||||
Reference in New Issue
Block a user