public override void Initialize() { CreatableTypes() .EndingWith("Service") .AsInterfaces() .RegisterAsLazySingleton(); log = Mvx.IoCProvider.Resolve <IMvxLog>(); appSettings = Mvx.IoCProvider.Resolve <IAppSettings>(); TpsSerializer tpsSerializer = new TpsSerializer(log); FcsMessageSerializer fcsMessageSerializer = new FcsMessageSerializer(log); log.Debug("App: Initializing FcsService,TpsService and saleStatus as singleton.."); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <ITpsService>(() => new TpsService(log, appSettings.TpsIpAddress, appSettings.TpsPort, tpsSerializer)); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IFcsService>(() => new FcsService(log, fcsMessageSerializer)); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <Printer>(() => new Printer(appSettings)); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IDBAccess>(() => new DBAccess()); Mvx.IoCProvider.ConstructAndRegisterSingleton(typeof(PosManager)); Mvx.IoCProvider.ConstructAndRegisterSingleton(typeof(IPAddressManager)); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IReceiptGenerator>(() => new ReceiptGenerator( Mvx.IoCProvider.Resolve <PosManager>(), AppLanguage.multi, appSettings.FuelUnitPriceDecimal )); log.Debug("App: Load and configure all the neccessary settings.."); LoadAppSettings(); ConfigurePaymentServer(); ConfigureFcsServer(); RegisterAppStart <MainViewModel>(); }
public TpsService(IMvxLog log, string ipAddress, int port, TpsSerializer tpsSerializer) { this.log = log; IpAddress = ipAddress; Port = port; this.tpsSerializer = tpsSerializer; log.Debug("TpsService: Tps IpAddress:{0}, port:{1}", ipAddress, port); client = new AsyncNetTcpClient(ipAddress, port); log.Debug("TpsService: Suscribing ConnectionEstablished, FrameArrived and Connection closed events."); client.ConnectionEstablished += ConnectionEstablished; client.FrameArrived += FrameArrived; client.ConnectionClosed += ConnectionClosed; log.Debug("TpsService: Creating new instance of awaitaible client"); awaitaibleClient = new AwaitaibleAsyncNetTcpClient(client); }