예제 #1
0
        public IEnumerable<IResult> DeleteActiveProfile()
        {
            var confirmation = new Question("Are you sure ?",
                string.Format("Do you really want to delete the profile '{0}' ?", ActiveProfile.Name),
                Answer.Yes,
                Answer.No);

            yield return confirmation.AsResult()
                .CancelOnResponse(Answer.No);

            var toDelete = ActiveProfile;

            if (AvailableProfiles.Count == 1)
            {
                AvailableProfiles.Add(Profile.Default);
            }

            var index = AvailableProfiles.IndexOf(ActiveProfile);
            if (index == AvailableProfiles.Count - 1)
            {
                ActiveProfile = AvailableProfiles[index - 1];
            }
            else
            {
                ActiveProfile = AvailableProfiles[index + 1];
            }

            _profileManager.Delete(toDelete);

            NotifyOfPropertyChange(() => CanDeleteActiveProfile);
            yield break;
        }
예제 #2
0
        public override IEnumerable<IResult> Execute()
        {
            var question = new Question(Properties.Demo.LoremIpsum,
                                        Answer.Yes,
                                        Answer.No);

            yield return question.AsResult()
                // .CancelOnResponse(Answer.No) When two or more responses are given, the last response is per default the cancel response
                .WhenCancelled().Execute(new LogResult("Question result cancelled").AsCoroutine)
                .WhenCancelled().Override();

            yield return LogResponse(question);
        }