public void Publish <TMessage>(TMessage message) where TMessage : IMessage { var handlerTypes = message.GetType().GetAllTypesInheritedOrImplemented() .Where(t => t.Implements(typeof(IMessage))) .Select(t => typeof(IHandleMessages <>).MakeGenericType(t)) .ToArray(); _published.Add(message); var handlers = new List <object>(); foreach (var handlerType in handlerTypes) { handlers.AddRange(_serviceLocator.ResolveAll(handlerType).Cast <object>()); } var transformedMessages = new List <IMessage>(); InTransaction.Execute(() => { //var handlers = handlerTypes.SelectMany(type =>_serviceLocator.GetAllInstances(type)).ToArray(); foreach (dynamic handler in handlers) { handler.Handle((dynamic)message); } foreach (var handler in _localHandlers.Where(t => t.Item1.IsAssignableFrom(typeof(TMessage)))) { transformedMessages.AddRange(handler.Item2(message)); } }); transformedMessages.ForEach(Publish); }
public NewInTransactionRecorded(Guid fromAccountId, Guid toAccountId, InTransaction inflow) { FromAccountId = fromAccountId; ToAccountId = toAccountId; Inflow = inflow; EventType = EventType.TransferIncome; }
protected virtual void InternalDispose() { if (!_disposed) { InTransaction.Execute(() => _reservedDatabases.Values.ForEach(ReleaseDatabase)); _disposed = true; } }
public static InTx ToInTx(this InTransaction transaction) { return(transaction == null ? null : new InTx { Address = transaction.Address, Amount = transaction.Amount, Confirmations = transaction.Confirmations, RegDate = transaction.TimeStamp }); }
private async Task StoreTransaction(InTransaction transaction) { await SqlExecutor.ExecuteStoreProcedureScalar(_configuration.ConnectionString, "InTransactions_Store", new[] { new SqlParameter("@TxId", transaction.TxId), new SqlParameter("@Amount", transaction.Amount), new SqlParameter("@Address", transaction.Address), new SqlParameter("@TimeReceived", transaction.TimeReceived), new SqlParameter("@Confirmations", transaction.Confirmations) }); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new WalletConfiguration()); modelBuilder.ApplyConfiguration(new OutTransactionConfiguration()); modelBuilder.ApplyConfiguration(new InTransactionConfiguration()); var wallets = new List <Wallet>(); var wallet1 = new Wallet("http://127.0.0.1:8332/wallet/wallet1.dat", "password1") { Id = 1 }; wallet1.BalanceIn(0.002m); wallets.Add(wallet1); var wallet2 = new Wallet("http://127.0.0.1:8332/wallet/wallet2.dat", "password2") { Id = 2 }; wallet2.BalanceIn(0.004m); wallets.Add(wallet2); var wallet3 = new Wallet("http://127.0.0.1:8332/wallet/wallet3.dat", "password3") { Id = 3 }; wallet3.BalanceIn(0.006m); wallets.Add(wallet3); modelBuilder.Entity <Wallet>().HasData(wallets.ToArray()); var inTransactions = new List <InTransaction>(); var inTransaction = new InTransaction( "00b35d6f10f138c6484023cf379a8cfc2da516afd06a1321728ba331e810648f", 1, 0.004m, "000000000000000000090d549fe271b01dac3b8361ef88d8e5631551519c7cc9"); inTransaction.Id = 1; inTransaction.UpdateConfirmations(2); modelBuilder.Entity <InTransaction>().HasData(inTransaction); }
public async Task SaveAsync(InTransaction inTransaction) { await _bitcoinAppContext.InTransactions.AddAsync(inTransaction); _bitcoinAppContext.SaveChanges(); }
public async Task UpdateAsync(InTransaction inTransaction) { _bitcoinAppContext.Entry(inTransaction).State = EntityState.Modified; await _bitcoinAppContext.SaveChangesAsync(); }