Ejemplo n.º 1
0
        public void OnToggle(IToggleable toggleable)
        {
            var disabled = DisabledFunc?.Invoke();

            if (disabled.HasValue && disabled.Value)
            {
                return;
            }

            var id = toggleable.GetInstanceID();

            foreach (var pair in _idAndToggleablePairs.Where(pair => pair.Key != id && pair.Value.IsToggledOn))
            {
                pair.Value.SetToggledOff();
                OnToggledOff.OnNext(pair.Value);
            }

            if (toggleable.IsToggledOn)
            {
                toggleable.SetToggledOff();
                OnToggledOff.OnNext(toggleable);
            }
            else
            {
                toggleable.SetToggledOn();
                OnToggledOn.OnNext(toggleable);
            }
        }
Ejemplo n.º 2
0
        public void SetToggledOff(IToggleable toggleable)
        {
            var id = toggleable.GetInstanceID();

            foreach (var pair in _idAndToggleablePairs.Where(pair => pair.Key == id))
            {
                pair.Value.SetToggledOff();
            }
        }
Ejemplo n.º 3
0
        public void RegisterToggleable(IToggleable toggleable)
        {
            var id = toggleable.GetInstanceID();

            if (_idAndToggleablePairs.ContainsKey(id))
            {
                return;
            }

            _idAndToggleablePairs.Add(id, toggleable);
            toggleable.SetToggleListener(this);
        }