public void Write(Models.Atm pObject, Stream pTargetStream) { var jsonFormatter = new DataContractJsonSerializer(typeof(Models.Atm)); using (pTargetStream) { jsonFormatter.WriteObject(pTargetStream, pObject); } }
/// <summary> /// </summary> /// <param name="atm"></param> /// <param name="accountId"></param> /// <exception cref="IllegalStateException"></exception> public Session(Models.Atm atm, int accountId) { _atm = atm; _account = _dbManager.GetAccountDatabase().Get(accountId); if (_account == null) { throw new IllegalStateException("Account not found"); } _user = _dbManager.GetUserDataBase().Get(_account.OwnerId); if (_user == null) { throw new IllegalStateException("User not found"); } _transactionManager = TransactionManager.GetInstance(); }
/// <summary> /// </summary> /// <exception cref="InitializationException"></exception> private void Initialize(AtmSource atmSource) { var serializer = new AtmSerializer(); var stream = atmSource.GetStream(); _atm = serializer.Read(stream); StreamUtils.CloseStream(stream); if (_atm == null) { throw new InitializationException(); } try { DbManager.GetInstance().SetSourceProvider(_atm.SourceProvider); DbManager.GetInstance().Initialize(); } catch (Exception) { throw new InitializationException(); } }
public int GetDistanceTo(Models.Atm atm) { return(isGeolocationEnabled ? (int)atm.Position.GetDistance(MyLocation) : 0); }
internal SessionManager(Models.Atm atm) { _atm = atm; }