private void Toggle(bool primary)
 {
     lock (_sync)
     {
         _state = primary
   ? ImmutableState.Primary(this)
   : ImmutableState.Secondary(this);
     }
 }
        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);
        }
        public IState GetState()
        {
            lock (_sync)
            {
                var state = _state;

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

                state = _state = ImmutableState.Primary(this);

                return(state);
            }
        }
示例#4
0
 private void OnImmutableStateMachineStateChanged(ImmutableState immutableState)
 {
     Console.WriteLine(immutableState);
 }
示例#5
0
 public PartSysParamKeyframes(PartSysParamKeyframe[] frames)
 {
     _frames = frames;
     _state  = new ImmutableState(frames);
 }