コード例 #1
0
        private void EventHandler(object sender, TransactionCommittedEventArgs ev)
        {
            var exceptions = new List <Exception>();

            foreach (var item in this.subscriptions.ToArray())
            {
                if (!item.Value.Predicate(ev.Transaction))
                {
                    continue;
                }

                try
                {
                    item.Value.Callback(item.Key, ev.Transaction);
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }

            if (exceptions.Count == 0)
            {
                return;
            }

            if (exceptions.Count == 1)
            {
                throw exceptions[0];
            }

            throw new AggregateException(exceptions);
        }
コード例 #2
0
        private async void OnTransactionCommitted(object sender, TransactionCommittedEventArgs e)
        {
            if (e.Transaction.Payload != null)
            {
                var o = (IDictionary <string, object>)e.Transaction.Payload;

                if (o.TryGetValue("@internal", out object @internal) && "script".Equals(@internal))
                {
                    if (e.Transaction.Status == TransactionStatus.Authorized)
                    {
                        await ProcessScriptTransaction(e.Transaction);
                    }
                }
            }
        }