コード例 #1
0
        public Result <ImageSlideShow> MoveToRandomImage(ImageSlideShow imageSlideShow)
        {
            var workingSlideShow = imageSlideShow.Clone();

            workingSlideShow.ImageIndex = _randomNumberService.Roll(0, imageSlideShow.ImageList.Count - 1);
            return(Result.Ok(workingSlideShow));
        }
コード例 #2
0
        private Result <ImageSlideShow> MoveSlideShow(ImageSlideShow imageSlideShow, int moveVector)
        {
            var workingSlideShow = imageSlideShow.Clone();

            var newIndex = workingSlideShow.ImageIndex + moveVector;

            if (newIndex < 0)
            {
                return(Result.Fail <ImageSlideShow>("At the start of this slideshow"));
            }
            if (newIndex == imageSlideShow.ImageList.Count)
            {
                return(Result.Fail <ImageSlideShow>("At the end of this slideshow"));
            }
            workingSlideShow.ImageIndex = newIndex;

            return(Result.Ok(workingSlideShow));
        }