1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.ServiceModel.Activities.Presentation
8 using System.Activities.Presentation;
9 using System.Activities.Presentation.Validation;
10 using System.Activities.Validation;
11 using System.Collections.Generic;
12 using System.Activities;
13 using System.Activities.Statements;
14 using System.Globalization;
16 class SendReplyValidationFeature : DesignTimeValidationFeature
18 List<Constraint> constraints;
20 protected override Type ApplyTo
22 get { return typeof(SendReply); }
25 protected override IList<Constraint> DesignTimeConstraints
29 if (this.constraints == null)
31 this.constraints = new List<Constraint> { UnrootedRequestRule() };
33 return this.constraints;
37 Constraint UnrootedRequestRule()
39 DelegateInArgument<SendReply> sendReply = new DelegateInArgument<SendReply>();
40 DelegateInArgument<ValidationContext> context = new DelegateInArgument<ValidationContext>();
41 DelegateInArgument<Activity> activityInTree = new DelegateInArgument<Activity>();
42 Variable<bool> requestInTree = new Variable<bool> { Default = false };
44 return new Constraint<SendReply>
46 Body = new ActivityAction<SendReply, ValidationContext>
48 Argument1 = sendReply,
50 Handler = new Sequence
52 Variables = { requestInTree },
57 Condition = new InArgument<bool>(ctx => sendReply.Get(ctx).Request != null),
64 Values = new GetWorkflowTree
66 ValidationContext = context,
68 Body = new ActivityAction<Activity>
70 Argument = activityInTree,
73 Condition = new InArgument<bool>(ctx => activityInTree.Get(ctx) == sendReply.Get(ctx).Request),
74 Then = new Assign<bool>
84 Assertion = new InArgument<bool>(ctx => requestInTree.Get(ctx)),
86 Message = new InArgument<string>(ctx => string.Format(CultureInfo.CurrentCulture, System.Activities.Core.Presentation.SR.UnrootedRequestInSendReply, sendReply.Get(ctx).DisplayName))