当前位置: 首页>>代码示例>>C#>>正文


C# State.Flatten方法代码示例

本文整理汇总了C#中State.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# State.Flatten方法的具体用法?C# State.Flatten怎么用?C# State.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State.Flatten方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateFinalRedressAmountAsync

        internal async Task CalculateFinalRedressAmountAsync(State context)
        {
            var states = context.Flatten();
            var collateData = states.OfType<CollateData>().FirstOrDefault(s => s.Name.Equals("Collate Data"));
            var responseReceived = states.OfType<ResponseReceived>().FirstOrDefault(s => s.Name.Equals("Response Received"));
            var adjustment = states.OfType<Adjustment>().FirstOrDefault(s => s.Name.Equals("Adjustment"));

            decimal? finalRedressAmount = 0;

            if (collateData != null
                && collateData.RedressAmount.HasValue)
            {
                finalRedressAmount = collateData.RedressAmount;
            }

            if (adjustment != null
                && adjustment.AdjustmentAmount.HasValue)
            {
                finalRedressAmount += adjustment.AdjustmentAmount;
            }

            if (responseReceived != null
                && responseReceived.ConsequentialLossClaim.HasValue)
            {
                finalRedressAmount += responseReceived.ConsequentialLossClaim;
            }

            FinalRedressAmount = finalRedressAmount;

            if (Transition == null)
            {
                Transition = Transitions.FirstOrDefault(s => s.Name.Equals("Payment"));
            }

            await TaskRunner.DoAsyncStuff();
        }
开发者ID:WELL-E,项目名称:origin,代码行数:36,代码来源:RedressReview.cs

示例2: GetRemediationWorkflow


//.........这里部分代码省略.........
            var remediationWorkflow = new State(100, "Remediation Workflow", StateType.Root);

            var communication = new Communication()
            {
                Id = 200,
                Name = "Communication"
            };

            var letterSent = new LetterSent()
            {
                Id = 210,
                Name = "Letter Sent"
            };

            var responseReceived = new ResponseReceived()
            {
                Id = 220,
                Name = "Response Received"
            };

            var collateData = new CollateData()
            {
                Id = 300,
                Name = "Collate Data"
            };

            var adjustmentDecision = new AdjustmentDecision()
            {
                Id = 400,
                Name = "Adjustment Decision",
                Type = StateType.Auto
            };

            var adjustment = new Adjustment()
            {
                Id = 500,
                Name = "Adjustment"
            };

            var autoTransitionToRedressReview = new AutoTransitionToRedressReview()
            {
                Id = 600,
                Name = "Auto Transition Redress Review",
                Type = StateType.Auto
            };

            var redressReview = new RedressReview()
            {
                Id = 700,
                Name = "Redress Review"
            };

            var payment = new Payment()
            {
                Id = 800,
                Name = "Payment"
            };

            redressReview
                .AddTransition(payment, true)
                .AddTransition(collateData)
                .AddDependency(communication, true)
                .AddDependency(autoTransitionToRedressReview, true);

            autoTransitionToRedressReview
                .AddDependant(redressReview)
                .AddTransition(redressReview, true);

            adjustment
                .AddTransition(autoTransitionToRedressReview, true);

            adjustmentDecision
                .AddTransition(adjustment)
                .AddTransition(autoTransitionToRedressReview);

            collateData
                .AddTransition(adjustmentDecision, true);

            letterSent
                .AddTransition(responseReceived, true);

            communication
                .AddSubState(letterSent, true)
                .AddSubState(responseReceived)
                .AddDependant(redressReview)
                .AddTransition(redressReview, true);

            remediationWorkflow
                .AddSubState(communication, true)
                .AddSubState(collateData, true)
                .AddSubState(adjustmentDecision)
                .AddSubState(adjustment, completionRequired: false)
                .AddSubState(autoTransitionToRedressReview)
                .AddSubState(redressReview)
                .AddSubState(payment);

            await remediationWorkflow.ExecuteAsync(StateExecutionType.Initialise);

            return remediationWorkflow.Flatten();
        }
开发者ID:WELL-E,项目名称:origin,代码行数:101,代码来源:RemediationService.cs


注:本文中的State.Flatten方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。