Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/referencesource/System.Activities.Core.Presentation/System/ServiceModel/Activities/Presentation/ReceiveReplyValidationFeature.cs')
-rw-r--r--mcs/class/referencesource/System.Activities.Core.Presentation/System/ServiceModel/Activities/Presentation/ReceiveReplyValidationFeature.cs97
1 files changed, 97 insertions, 0 deletions
diff --git a/mcs/class/referencesource/System.Activities.Core.Presentation/System/ServiceModel/Activities/Presentation/ReceiveReplyValidationFeature.cs b/mcs/class/referencesource/System.Activities.Core.Presentation/System/ServiceModel/Activities/Presentation/ReceiveReplyValidationFeature.cs
new file mode 100644
index 00000000000..578a8b76531
--- /dev/null
+++ b/mcs/class/referencesource/System.Activities.Core.Presentation/System/ServiceModel/Activities/Presentation/ReceiveReplyValidationFeature.cs
@@ -0,0 +1,97 @@
+//----------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//----------------------------------------------------------------
+
+namespace System.ServiceModel.Activities.Presentation
+{
+ using System.Runtime;
+ using System.Activities.Presentation;
+ using System.Activities.Presentation.Validation;
+ using System.Activities.Validation;
+ using System.Collections.Generic;
+ using System.Activities;
+ using System.Activities.Statements;
+ using System.Globalization;
+
+ class ReceiveReplyValidationFeature : DesignTimeValidationFeature
+ {
+ List<Constraint> constraints;
+
+ protected override Type ApplyTo
+ {
+ get { return typeof(ReceiveReply); }
+ }
+
+ protected override IList<Constraint> DesignTimeConstraints
+ {
+ get
+ {
+ if (this.constraints == null)
+ {
+ this.constraints = new List<Constraint> { UnrootedRequestRule() };
+ }
+ return this.constraints;
+ }
+ }
+
+ Constraint UnrootedRequestRule()
+ {
+ DelegateInArgument<ReceiveReply> receiveReply = new DelegateInArgument<ReceiveReply>();
+ DelegateInArgument<ValidationContext> context = new DelegateInArgument<ValidationContext>();
+ DelegateInArgument<Activity> activityInTree = new DelegateInArgument<Activity>();
+ Variable<bool> requestInTree = new Variable<bool> { Default = false };
+
+ return new Constraint<ReceiveReply>
+ {
+ Body = new ActivityAction<ReceiveReply, ValidationContext>
+ {
+ Argument1 = receiveReply,
+ Argument2 = context,
+ Handler = new Sequence
+ {
+ Variables = { requestInTree },
+ Activities =
+ {
+ new If
+ {
+ Condition = new InArgument<bool>(ctx => receiveReply.Get(ctx).Request != null),
+ Then = new Sequence
+ {
+ Activities =
+ {
+ new ForEach<Activity>
+ {
+ Values = new GetWorkflowTree
+ {
+ ValidationContext = context,
+ },
+ Body = new ActivityAction<Activity>
+ {
+ Argument = activityInTree,
+ Handler = new If
+ {
+ Condition = new InArgument<bool>(ctx => activityInTree.Get(ctx) == receiveReply.Get(ctx).Request),
+ Then = new Assign<bool>
+ {
+ To = requestInTree,
+ Value = true,
+ }
+ }
+ }
+ },
+ new AssertValidation
+ {
+ Assertion = new InArgument<bool>(ctx => requestInTree.Get(ctx)),
+ IsWarning = false,
+ Message = new InArgument<string>(ctx => string.Format(CultureInfo.CurrentCulture, System.Activities.Core.Presentation.SR.UnrootedRequestInReceiveReply, receiveReply.Get(ctx).DisplayName))
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+ }
+}