Ejemplo n.º 1
0
        private IEnumerator SimpleSaga()
        {
            var data = new Ref <int>();

            yield return(Do.Call(TestCallMethod, data));

            yield return(Do.Put(new SagaAction <int>("test", data.Value)));
        }
Ejemplo n.º 2
0
        private IEnumerator DoStuff(Ref <int> data, bool fireException)
        {
            CallEffect <int> .CallTarget target = TestCallMethod;

            if (fireException == false)
            {
                target = TestCallMethodNoException;
            }

            yield return(Do.Call(target, data));

            yield return(Do.Put(new SagaAction <int>("success", data.Value)));
        }
Ejemplo n.º 3
0
        public Result <None> CreateTagCloudImage()
        {
            var tagCloudContext = cloudContextGenerator.GetTagCloudContext();

            var shuffledContentStrings = tagCloudContext
                                         .SelectValue(context => (preprocessor: vocabularyPreprocessorConstructor(context),
                                                                  cloudContent: context.TagCloudContent))
                                         .SelectValue(tuple => tuple.preprocessor.Process(tuple.cloudContent))
                                         .SelectValue(words => words.SequenceShuffle(new Random()))
                                         .SelectValue(words => words.Distinct())
                                         .SelectValue(words => words.ToArray());

            var layouter  = tagCloudContext.SelectValue(context => context.CloudLayouter);
            var size      = tagCloudContext.SelectValue(context => context.ImageSize);
            var imageName = tagCloudContext.SelectValue(context => context.ImageName);

            return(tagCloudContext
                   .Then(context => Do.Call <string[], ICloudLayouter, Size, Result <Bitmap> >(context.Cloud.CreateBitmap)
                         .With(shuffledContentStrings, layouter, size))
                   .ActionOverValue(bitmap => Do.Call <string>(bitmap.Save).With(imageName))
                   .ReplaceError(error => $"Bitmap creation error was handled:{Environment.NewLine}{error}"));
        }