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


C# Variable.Get方法代码示例

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


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

示例1: Loop

        static For Loop()
        {
            Variable<int> loopVariable = new Variable<int>();

            return new For()
            {
                Variables = { loopVariable },

                InitAction = new Assign<int>()
                {
                    To = loopVariable,
                    Value = 0,
                },

                IterationAction = new Assign<int>()
                {
                    To = loopVariable,
                    Value = new InArgument<int>(ctx => loopVariable.Get(ctx) + 1)
                },

                // ExpressionServices.Convert is called to convert LINQ expression to a
                // serializable Expression Activity.
                Condition = ExpressionServices.Convert<bool>(ctx => loopVariable.Get(ctx) < 10),
                Body = new WriteLine
                {
                    Text = new InArgument<string>(ctx => "Value of item is: " + loopVariable.Get(ctx).ToString()),
                },
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:29,代码来源:Program.cs

示例2: CreateWorkflow

        static Sequence CreateWorkflow()
        {
            Variable<int> count = new Variable<int> { Name = "count", Default = totalSteps };
            Variable<int> stepsCounted = new Variable<int> { Name = "stepsCounted" };

            return new Sequence()
            {
                Variables = { count, stepsCounted },
                Activities =
                {
                    new While((env) => count.Get(env) > 0)
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new EchoPrompt {BookmarkName = echoPromptBookmark },
                                new IncrementStepCount(),
                                new Assign<int>{ To = new OutArgument<int>(count), Value = new InArgument<int>((context) => count.Get(context) - 1)}
                            }
                        }
                    },
                    new GetCurrentStepCount {Result = new OutArgument<int>(stepsCounted )},
                    new WriteLine { Text = new InArgument<string>((context) => "there were " + stepsCounted.Get(context) + " steps in this program")}}
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:26,代码来源:Program.cs

示例3: CreateService

        private static void CreateService()
        {
            Variable<string> message = new Variable<string> { Name = "message" };
            Variable<string> echo = new Variable<string> { Name = "echo" };

            Receive receiveString = new Receive
            {
                OperationName = "Echo",
                ServiceContractName = "Echo",
                CanCreateInstance = true,
                //parameters for receive
                Content = new ReceiveParametersContent
                {
                    Parameters =
                    {
                        {"message", new OutArgument<string>(message)}
                    }
                }
            };
            Sequence workflow = new Sequence()
            {
                Variables = { message, echo },
                Activities =
                    {
                        receiveString,
                        new WriteLine
                        {
                            Text = new InArgument<string>(env =>("Message received: " + message.Get(env)))
                        },
                        new Assign<string>
                        {
                            Value = new InArgument<string>(env =>("<echo> " + message.Get(env))),
                            To = new OutArgument<string>(echo)
                        },
                        //parameters for reply
                        new SendReply
                        {
                            Request = receiveString,
                            Content = new SendParametersContent
                            {
                                Parameters =
                                {
                                    { "echo", new InArgument<string>(echo) }
                                },
                            }
                        },
                        new WriteLine
                        {
                            Text = new InArgument<string>(env =>("Message sent: " + echo.Get(env)))
                        },
                    },
            };

            service = new WorkflowService
            {
                Name = "Echo",
                Body = workflow
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:59,代码来源:Program.cs

示例4: GetClientWorkflow

        static Activity GetClientWorkflow()
        {
            Variable<PurchaseOrder> po = new Variable<PurchaseOrder>();
            Variable<OrderStatus> orderStatus = new Variable<OrderStatus>();

            Endpoint clientEndpoint = new Endpoint
            {
                Binding = Constants.Binding,
                AddressUri = new Uri(Constants.ServiceAddress)
            };

            Send submitPO = new Send
            {
                Endpoint = clientEndpoint,
                ServiceContractName = Constants.POContractName,
                OperationName = Constants.SubmitPOName,
                Content = SendContent.Create(new InArgument<PurchaseOrder>(po))
            };

            return new Sequence
            {
                Variables = { po, orderStatus },
                Activities =
                {
                    new WriteLine { Text = "Sending order for 150 widgets." },
                    new Assign<PurchaseOrder> { To = po, Value = new InArgument<PurchaseOrder>( (e) => new PurchaseOrder() { PartName = "Widget", Quantity = 150 } ) },
                    new CorrelationScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                submitPO,
                                new ReceiveReply
                                {
                                    Request = submitPO,
                                    Content = ReceiveContent.Create(new OutArgument<int>( (e) => po.Get(e).Id ))
                                }
                            }
                        }
                    },
                    new WriteLine { Text = new InArgument<string>( (e) => string.Format("Got PoId: {0}", po.Get(e).Id) ) },
                    new Assign<OrderStatus> { To = orderStatus, Value = new InArgument<OrderStatus>( (e) => new OrderStatus() { Id = po.Get(e).Id, Confirmed = true }) },
                    new Send
                    {
                        Endpoint = clientEndpoint,
                        ServiceContractName = Constants.POContractName,
                        OperationName = Constants.ConfirmPurchaseOrder,
                        Content = SendContent.Create(new InArgument<OrderStatus>(orderStatus))
                    },
                    new WriteLine { Text = "The order was confirmed." },
                    new WriteLine { Text = "Client completed." }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:55,代码来源:Program.cs

示例5: CreateMySequence

        private static Activity CreateMySequence()
        {
            Variable<int> count = new Variable<int> { Default = 1 };

            return new MySequence
            {
                Variables = { count },
                Activities = {
                    new WriteLine { Text = new InArgument<string>((env) => "Hello from sequence count is " + count.Get(env).ToString())},
                    new Assign<int> { To = count, Value = new InArgument<int>((env) => count.Get(env)+ 1)},
                    new WriteLine { Text = new InArgument<string>((env) => "Hello from sequence count is " + count.Get(env).ToString())}}
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:13,代码来源:Program.cs

示例6: CreateMyWhile

        private static Activity CreateMyWhile()
        {
            Variable<int> count = new Variable<int> { Default = 1 };

            return new MyWhile
            {
                Variables = { count },
                Condition = new LambdaValue<bool>((env) => count.Get(env) < 3),
                Body = new Sequence
                {
                    Activities = {
                        new WriteLine { Text = new InArgument<string>((env) => "Hello from while loop " + count.Get(env).ToString()) },
                        new Assign<int> { To = count, Value = new InArgument<int>((env) => count.Get(env)+ 1) }}
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:16,代码来源:Program.cs

示例7: GetServiceWorkflow

        static Activity GetServiceWorkflow()
        {
            Variable<string> echoString = new Variable<string>();

            Receive echoRequest = new Receive
            {
                CanCreateInstance = true,
                ServiceContractName = contract,
                OperationName = "Echo",
                Content = new ReceiveParametersContent()
                {
                    Parameters = { { "echoString", new OutArgument<string>(echoString) } }
                }
            };

            return new ReceiveInstanceIdScope
            {
                Variables = { echoString },
                Activities =
                {
                    echoRequest,
                    new WriteLine { Text = new InArgument<string>( (e) => "Received: " + echoString.Get(e) ) },
                    new SendReply
                    {
                        Request = echoRequest,
                        Content = new SendParametersContent()
                        {
                            Parameters = { { "result", new InArgument<string>(echoString) } }
                        }
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:33,代码来源:Program.cs

示例8: CreateService

 private static WorkflowService CreateService()
 {
     Variable<string> message = new Variable<string> { Name = "message" };
     Receive receiveString = new Receive
     {
         OperationName = "Print",
         ServiceContractName = XName.Get("IPrintService", "http://tempuri.org/"),
         Content = new ReceiveParametersContent
         {
             Parameters = 
             {
                 {"message", new OutArgument<string>(message)}
             }
         },
         CanCreateInstance = true
     };
     Sequence workflow = new Sequence()
     {
         Variables = { message },
         Activities =
         {    
             receiveString,    
             new WriteLine                        
             {    
                 Text = new InArgument<string>(env =>("Message received from Client: " + message.Get(env)))   
             },
         },
     };
     return new WorkflowService
     {
         Name = "PrintService",
         Body = workflow
     };
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:34,代码来源:Program.cs

示例9: CreateClientWorkflow

        static void CreateClientWorkflow()
        {
            Variable<string> message = new Variable<string>("message", "Hello!");
            Variable<string> result = new Variable<string> { Name = "result" };

            Endpoint endpoint = new Endpoint
            {
                AddressUri = new Uri(Microsoft.Samples.WorkflowServicesSamples.Common.Constants.ServiceBaseAddress),
                Binding = new BasicHttpBinding(),
            };

            Send requestEcho = new Send
            {
                ServiceContractName = XName.Get("Echo", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "Echo",
                //parameters for send
                Content = new SendParametersContent
                {
                    Parameters =
                        {
                            { "message", new InArgument<string>(message) }
                        }
                }
            };
            workflow = new CorrelationScope
            {
                Body = new Sequence
                {
                    Variables = { message, result },
                    Activities =
                    {
                        new WriteLine {
                            Text = new InArgument<string>("Client is ready!")
                        },
                        requestEcho,

                        new WriteLine {
                            Text = new InArgument<string>("Message sent: Hello!")
                        },

                        new ReceiveReply
                        {
                            Request = requestEcho,
                            //parameters for the reply
                            Content = new ReceiveParametersContent
                            {
                                Parameters =
                                {
                                    { "echo", new OutArgument<string>(result) }
                                }
                            }
                        },
                        new WriteLine {
                            Text = new InArgument<string>(env => "Message received: "+result.Get(env))
                        }
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:60,代码来源:Program.cs

示例10: CreateRulesInterop

        private static Activity CreateRulesInterop()
        {
            //Create the variables needed to be passed into the 35 Ruleset
            Variable<int> discountLevel = new Variable<int> { Default = 1 };
            Variable<double> discountPoints = new Variable<double> { Default = 0.0 };
            Variable<string> destination = new Variable<string> { Default = "London" };
            Variable<double> price = new Variable<double> { Default = 1000.0 };
            Variable<double> priceOut = new Variable<double> { Default = 0.0 };

            Sequence result = new Sequence
            {
                Variables = {discountLevel, discountPoints, destination, price, priceOut},
                Activities =
                {
                    new WriteLine { Text = new InArgument<string>(env => string.Format("Price before applying Discount Rules = {0}", price.Get(env).ToString())) },
                    new WriteLine { Text = "Invoking Discount Rules defined in .NET 3.5"},
                    new Interop()
                    {
                        ActivityType = typeof(TravelRuleSet),
                        ActivityProperties =
                        {
                            //These bind to the dependency properties of the 35 custom ruleset
                            { "DiscountLevel", new InArgument<int>(discountLevel) },
                            { "DiscountPoints", new InArgument<double>(discountPoints) },
                            { "Destination", new InArgument<string>(destination) },
                            { "Price", new InArgument<double>(price) },
                            { "PriceOut", new OutArgument<double>(priceOut) }
                        }
                    },
                    new WriteLine {Text = new InArgument<string>(env => string.Format("Price after applying Discount Rules = {0}", priceOut.Get(env).ToString())) }
                }
            };
            return result;
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:34,代码来源:Program.cs

示例11: CreateWorkflow

        static Activity CreateWorkflow()
        {
            Variable<string> x = new Variable<string>() { Name = "x" };
            Variable<string> y = new Variable<string>() { Name = "y" };
            Variable<string> z = new Variable<string>() { Name = "z" };

            // Create a workflow with three bookmarks: x, y, z. After all three bookmarks
            // are resumed (in any order), the concatenation of the values provided
            // when the bookmarks were resumed is written to output.
            return new Sequence
            {
                Variables = { x, y, z },
                Activities =
                {
                    new System.Activities.Statements.Parallel
                    {
                        Branches =
                        {
                            new Read<string>() { BookmarkName = "x", Result = x },
                            new Read<string>() { BookmarkName = "y", Result = y },
                            new Read<string>() { BookmarkName = "z", Result = z }
                        }
                    },
                    new WriteLine
                    {
                        Text = new InArgument<string>((ctx) => "x+y+z=" + x.Get(ctx) + y.Get(ctx) + z.Get(ctx))
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:30,代码来源:Program.cs

示例12: UnrootedRequestRule

        Constraint UnrootedRequestRule()
        {
            DelegateInArgument<SendReply> sendReply = new DelegateInArgument<SendReply>();
            DelegateInArgument<ValidationContext> context = new DelegateInArgument<ValidationContext>();
            DelegateInArgument<Activity> activityInTree = new DelegateInArgument<Activity>();
            Variable<bool> requestInTree = new Variable<bool> { Default = false };

            return new Constraint<SendReply>
            {
                Body = new ActivityAction<SendReply, ValidationContext>
                {
                    Argument1 = sendReply,
                    Argument2 = context,
                    Handler = new Sequence
                    {
                        Variables = { requestInTree },
                        Activities =
                        {
                            new If
                            {
                                Condition = new InArgument<bool>(ctx => sendReply.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) == sendReply.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.UnrootedRequestInSendReply, sendReply.Get(ctx).DisplayName))
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:59,代码来源:SendReplyValidationFeature.cs

示例13: CreateBody

        public static Activity CreateBody()
        {
            Variable<PurchaseOrder> purchaseOrder = new Variable<PurchaseOrder> { Name = "po" };

            Sequence sequence = new Sequence
            {
                Variables =
                {
                    purchaseOrder
                },

                Activities =
                {
                    new Receive
                    {
                        OperationName = "SubmitPurchaseOrder",
                        ServiceContractName = XName.Get(poContractDescription.Name),
                        CanCreateInstance = true,
                        Content = new ReceiveParametersContent
                        {
                            Parameters =
                            {
                                {"po", new OutArgument<PurchaseOrder>(purchaseOrder)}
                            }
                        }
                    },

                    new WriteLine
                    {
                       Text = new InArgument<string> (e=>"Order is received\nPO number = " + purchaseOrder.Get(e).PONumber
                           + " Customer Id = " + purchaseOrder.Get(e).CustomerId)
                    },

                    new Persist(),

                    new ExceptionThrownActivity(),

                    new WriteLine
                    {
                        Text = new InArgument<string>("Order processing is complete")
                    }
                }
            };

            return sequence;
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:46,代码来源:POWorkflow.cs

示例14: VerifyParentIsWorkflowActivity

        public static Constraint VerifyParentIsWorkflowActivity()
        {
            DelegateInArgument<Activity> element = new DelegateInArgument<Activity>();
            DelegateInArgument<ValidationContext> context = new DelegateInArgument<ValidationContext>();
            
            DelegateInArgument<Activity> parent = new DelegateInArgument<Activity>();
            Variable<bool> result = new Variable<bool>();

            return new Constraint<Activity>
            {
                Body = new ActivityAction<Activity, ValidationContext>
                {
                    Argument1 = element,
                    Argument2 = context,
                    Handler = new Sequence
                    {
                        Variables =
                        {
                            result
                        },
                        Activities =
                        {
                            new ForEach<Activity>
                            {
                                Values = new GetParentChain
                                {
                                    ValidationContext = context,
                                },
                                Body = new ActivityAction<Activity>
                                {
                                    Argument = parent, 
                                    Handler = new If
                                    {
                                        Condition = new InArgument<bool>((env) => parent.Get(env).IsWorkflowActivity()),
                                        Then = new Assign<bool>
                                        {
                                            Value = true,
                                            To = result,
                                        },
                                    },
                                },
                            },
                            new AssertValidation
                            {
                                Assertion = new InArgument<bool>((env) => result.Get(env)),
                                Message = new InArgument<string>((env) => $"{element.Get(env).GetType().GetFriendlyName()} can only be added inside a {typeof(WorkflowActivity<,>).GetFriendlyName()} activity."),
                                PropertyName = new InArgument<string>((env) => element.Get(env).DisplayName),
                            },
                        },
                    },
                },
            };
        }
开发者ID:lmagyar,项目名称:Orleans.Activities,代码行数:53,代码来源:OperationActivityHelper.cs

示例15: CreateWF

        static Activity CreateWF()
        {
            DelegateInArgument<string> current = new DelegateInArgument<string>();
            IList<string> data = new List<string>();
            for (int i = 1; i < 11; i++)
            {
                data.Add(string.Format("Branch {0}", i));
            }
            Variable<int> waitTime = new Variable<int>();

            return
                new Sequence
                {
                    Variables = { waitTime },
                    Activities =
                    {
                        new ThrottledParallelForEach<string>
                        {
                            Values = new LambdaValue<IEnumerable<string>>(c => data),
                            MaxConcurrentBranches = 3,
                            Body = new ActivityAction<string>
                            {
                                Argument = current,
                                Handler = new Sequence
                                {
                                    Activities =
                                    {
                                        new WriteLine() { Text = new InArgument<string>(ctx => string.Format("Enter {0}", current.Get(ctx))) },
                                        new Assign<int> { To = waitTime, Value = new InArgument<int>(ctx =>  new Random().Next(0, 2500)) },
                                        new WriteLine() { Text = new InArgument<string>(ctx => string.Format("...{0} will wait for {1} millisenconds...", current.Get(ctx), waitTime.Get(ctx))) },
                                        new Delay { Duration = new InArgument<TimeSpan>(ctx => new TimeSpan(0,0,0,0, waitTime.Get(ctx))) },
                                        new WriteLine() { Text = new InArgument<string>(ctx => string.Format("......Exit {0}", current.Get(ctx))) },
                                    }
                                }
                            }
                        }
                    }
                };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:39,代码来源:Program.cs


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