public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var autoStart = (AutoStartEntry)values[0];

            if (autoStart.CanBeRemoved.HasValue)
            {
                return(autoStart.CanBeRemoved.Value);
            }
            Task.Run(() => {
                AutoStartService.LoadCanBeRemoved(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 LoadCanBeRemoved_UpdatesAutoStartEntryAndRaisesEvents(bool canBeRemoved)
        {
            A.CallTo(() => ConnectorService.CanBeRemoved(AutoStartEntry)).Returns(canBeRemoved);
            var changeEventHandler = A.Fake <AutoStartChangeHandler>();

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

            Service.HistoryAutoStartChange += historyAutoStartChange;

            await Service.LoadCanBeRemoved(AutoStartEntry);

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