Esempio n. 1
0
// ///////////////
// Methods
// ///////////////

        /*** Immediately close the underlying edge, and don't warn the other node.
         * Prefer Connection.Close if possible.  This is idempotent.
         * @return the old state, new state pair.
         */
        public Pair <ConnectionState, ConnectionState> Abort()
        {
            var res = _state.Update(delegate(ConnectionState old_state) {
                if (old_state.Disconnected)
                {
                    return(old_state);
                }
                else
                {
                    return(new ConnectionState(old_state.Edge,
                                               old_state.StatusMessage,
                                               old_state.PeerLinkMessage, true));
                }
            });

            if (res.First != res.Second)
            {
                ProtocolLog.WriteIf(ProtocolLog.Connections, String.Format(
                                        "Abort called on {0}", this));
                //Only send the event if there is an actual change
                var ev = StateChangeEvent;
                if (null != ev)
                {
                    ev(this, res);
                }
            }
            return(res);
        }
Esempio n. 2
0
        public void MutableUpdateWorks()
        {
            var value = Mutable.Create(0);

            Mutable.Update(value, o => o + 1);
            Mutable.Update(value, o => o - 3);

            Assert.AreEqual(-2, value.Value);
        }
Esempio n. 3
0
        public void MutableUpdateWorksWithCollection()
        {
            var value = Mutable.Create(new List <int> {
                42, 54
            });

            Mutable.Update(value, (o => o.Concat(new[] { 21, 15 }).ToList()));

            CollectionAssert.AreEqual(new[] { 42, 54, 21, 15 }, value.Value);
        }