示例#1
0
        private async void SetSelectedItemLifetime(DisplayItemLifetime value)
        {
            if (selectedItemLifetime == value)
            {
                return;
            }

            if (setSelectedItemLifetimeRunning)
            {
                return;
            }
            setSelectedItemLifetimeRunning = true;

            var result = selectedItemLifetime < value ||
                         await messageService.ShowYesNoQuestionDialogAsync(resourceService.GetString("ReduceFeedItemLifetimeQuestion"));

            if (result)
            {
                selectedItemLifetime     = value;
                FeedManager.ItemLifetime = value.ToValue();
            }

            RaisePropertyChanged(nameof(SelectedItemLifetime));
            setSelectedItemLifetimeRunning = false;
        }
示例#2
0
        public static TimeSpan?ToValue(this DisplayItemLifetime enumValue)
        {
            switch (enumValue)
            {
            case DisplayItemLifetime._1Month:
                return(TimeSpan.FromDays(30));

            case DisplayItemLifetime._3Month:
                return(TimeSpan.FromDays(90));

            case DisplayItemLifetime._6Month:
                return(TimeSpan.FromDays(180));

            case DisplayItemLifetime._1Year:
                return(TimeSpan.FromDays(365));

            case DisplayItemLifetime.Forever:
                return(null);

            default:
                throw new NotSupportedException($"The value {enumValue} is not supported.");
            }
        }