Ejemplo n.º 1
0
        private IrbisConnection GetConnection()
        {
            string connectionString
                = CM.AppSettings["connectionString"];

            IrbisConnection result
                = new IrbisConnection(connectionString);

            if (_slowBox.CheckBox.Checked)
            {
                SlowSocket slow = new SlowSocket
                                  (
                    result,
                    result.Socket
                                  )
                {
                    Delay = 1000
                };
                result.SetSocket(slow);
            }

            if (_brokenBox.CheckBox.Checked)
            {
                BrokenSocket broken = new BrokenSocket
                                      (
                    result,
                    result.Socket
                                      )
                {
                    Probability = 0.5
                };
                result.SetSocket(broken);
            }

            if (_busyBox.CheckBox.Checked)
            {
                _busyStripe.SubscribeTo(result);
            }

            if (_retryBox.CheckBox.Checked)
            {
                RetryManager manager =
                    result.SetupRetryForm();
                manager.ExceptionOccurs += ExceptionOccurs;
                manager.Resolved        += ExceptionResolved;
                result.Disposing        += ConnectionDisposing;
            }

            return(result);
        }