コード例 #1
0
        public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var autoStart = (AutoStartEntry)value[0];

            if (autoStart.CanBeDisabled.HasValue)
            {
                return(autoStart.CanBeDisabled.Value);
            }
            Task.Run(() => {
                AutoStartService.LoadCanBeDisabled(autoStart);
            });
            return(false);
        }
コード例 #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var autoStart = (AutoStartEntry)values[0];

            switch (autoStart.Change)
            {
            case Change.Added:
                if (autoStart.CanBeRemoved.HasValue)
                {
                    return(autoStart.CanBeRemoved.Value);
                }
                Task.Run(() => {
                    AutoStartService.LoadCanBeRemoved(autoStart);
                });
                break;

            case Change.Removed:
                if (autoStart.CanBeAdded.HasValue)
                {
                    return(autoStart.CanBeAdded.Value);
                }
                Task.Run(() => {
                    AutoStartService.LoadCanBeAdded(autoStart);
                });
                break;

            case Change.Enabled:
                if (autoStart.CanBeDisabled.HasValue)
                {
                    return(autoStart.CanBeDisabled.Value);
                }
                Task.Run(() => {
                    AutoStartService.LoadCanBeDisabled(autoStart);
                });
                break;

            case Change.Disabled:
                if (autoStart.CanBeEnabled.HasValue)
                {
                    return(autoStart.CanBeEnabled.Value);
                }
                Task.Run(() => {
                    AutoStartService.LoadCanBeEnabled(autoStart);
                });
                break;
            }
            return(false);
        }
コード例 #3
0
        public async Task LoadCanBeDisabled_UpdatesAutoStartEntryAndRaisesEvents(bool canBeDisabled)
        {
            A.CallTo(() => ConnectorService.CanBeDisabled(AutoStartEntry)).Returns(canBeDisabled);
            var changeEventHandler = A.Fake <AutoStartChangeHandler>();

            Service.CurrentAutoStartChange += changeEventHandler;
            var historyAutoStartChange = A.Fake <AutoStartChangeHandler>();

            Service.HistoryAutoStartChange += historyAutoStartChange;

            await Service.LoadCanBeDisabled(AutoStartEntry);

            Assert.AreEqual(canBeDisabled, AutoStartEntry.CanBeDisabled.Value);
            A.CallTo(() => changeEventHandler.Invoke(AutoStartEntry)).MustHaveHappenedOnceExactly();
            A.CallTo(() => historyAutoStartChange.Invoke(AutoStartEntry)).MustHaveHappenedOnceExactly();
        }