Esempio n. 1
0
 private void Toggle(bool primary)
 {
     lock (_sync)
     {
         _state = primary
   ? ImmutableState.Primary(this)
   : ImmutableState.Secondary(this);
     }
 }
Esempio n. 2
0
        public AddressSwitcher(string primaryUrl, string secondaryUrl, TimeSpan timeframe, ITime time)
        {
            _primaryUrl   = primaryUrl;
            _secondaryUrl = secondaryUrl;
            _timeframe    = timeframe;
            _time         = time;

            _sync  = new object();
            _state = ImmutableState.Primary(this);
        }
Esempio n. 3
0
        public IState GetState()
        {
            lock (_sync)
            {
                var state = _state;

                if (state.ValidUntil > _time.Now)
                {
                    return(state);
                }

                state = _state = ImmutableState.Primary(this);

                return(state);
            }
        }