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


C# Activities.Variable类代码示例

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


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

示例1: 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

示例2: Send

 public Send()
 {
     Func<Activity> func = null;
     this.isOneWay = true;
     this.TokenImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
     if (func == null)
     {
         func = delegate {
             if (this.internalSend == null)
             {
                 return null;
             }
             if (this.requestFormatter == null)
             {
                 return this.internalSend;
             }
             Variable<Message> variable = new Variable<Message> {
                 Name = "RequestMessage"
             };
             this.requestFormatter.Message = new OutArgument<Message>(variable);
             this.requestFormatter.Send = this;
             this.internalSend.Message = new InArgument<Message>(variable);
             return new NoPersistScope { Body = new Sequence { Variables = { variable }, Activities = { this.requestFormatter, this.internalSend } } };
         };
     }
     base.Implementation = func;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:Send.cs

示例3: CompensateACompensableActivity

        // Builds a sequence of two CompensableActivites where the first is explicitly compensated
        static Activity CompensateACompensableActivity()
        {
            Variable<CompensationToken> token = new Variable<CompensationToken>();

            return new Sequence
            {
                Variables = { token },
                Activities =
                {
                    new WriteLine { Text = "Start of workflow" },

                    new CompensableActivity()
                    {
                        Body = new WriteLine() { Text = "CompensableActivity1: Body" },
                        CompensationHandler = new WriteLine() { Text = "CompensableActivity1: Compensation Handler" },
                        ConfirmationHandler = new WriteLine() { Text = "CompensableActivity1: Confirmation Handler" },
                        Result = token,
                    },

                    new CompensableActivity()
                    {
                        Body = new WriteLine() { Text = "CompensableActivity2: Body" },
                        CompensationHandler = new WriteLine() { Text = "CompensableActivity2: Compensation Handler" },
                        ConfirmationHandler = new WriteLine() { Text = "CompensableActivity2: Confirmation Handler" },
                    },

                    new Compensate()
                    {
                        Target = token,
                    },

                    new WriteLine { Text = "End of workflow" }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:36,代码来源:Program.cs

示例4: MySequence

 public MySequence()
     : base()
 {
     this.children = new Collection<Activity>();
     this.variables = new Collection<Variable>();
     this.currentIndex = new Variable<int>();
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:MySequence.cs

示例5: 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

示例6: SendInstanceIdScope

 public SendInstanceIdScope()
     : base()
 {
     this.children = new Collection<Activity>();
     this.variables = new Collection<Variable>();
     this.currentIndex = new Variable<int>();
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:SendInstanceIdScope.cs

示例7: 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

示例8: CreatePrintProcessActivity

        private static Activity CreatePrintProcessActivity(Variable<Collection<Process>> processes)
        {
            var proc = new DelegateInArgument<Process>("process");

            return new Sequence
            {
                Activities =
                {
                    // Loop over processes and print them out.
                    new ForEach<Process>
                    {
                        Values = processes,
                        Body = new ActivityAction<Process>
                        {
                            Argument = proc,
                            Handler = new WriteLine
                            {
                                Text = new InArgument<string>(ctx => proc.Get(ctx).ToString()),
                            }
                        }
                    },

                    // Print out a new line.
                    new WriteLine(),
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:27,代码来源:Program.cs

示例9: 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

示例10: StateMachine

 /// <summary>
 /// It's constructor.
 /// </summary>
 public StateMachine()
 {
     this.internalStates = new Collection<InternalState>();
     this.internalStateFuncs = new Collection<ActivityFunc<string, StateMachineEventManager, string>>();
     this.eventManager = new Variable<StateMachineEventManager> { Name = "EventManager", Default = new LambdaValue<StateMachineEventManager>(ctx => new StateMachineEventManager()) };
     this.onStateComplete = new CompletionCallback<string>(OnStateComplete);
 }
开发者ID:xiluo,项目名称:document-management,代码行数:10,代码来源:StateMachine.cs

示例11: CreateRetrieveWithoutPredicateWF

        // Creates a workflow that uses FindInTable activity without predicate to retrieve entities from a Sql Server Database
        static Activity CreateRetrieveWithoutPredicateWF()
        {
            Variable<IList<Role>> roles = new Variable<IList<Role>>();
            DelegateInArgument<Role> roleIterationVariable = new DelegateInArgument<Role>();

            return new Sequence()
            {
                Variables = { roles },
                Activities =
                {
                    new WriteLine { Text = "\r\nAll Roles (no predicates)\r\n==============" },
                    new FindInSqlTable<Role>
                    {
                        ConnectionString = cnn,
                        Result = new OutArgument<IList<Role>>(roles)
                    },
                    new ForEach<Role>
                    {
                        Values = new InArgument<IEnumerable<Role>>(roles),
                        Body = new ActivityAction<Role>()
                        {
                            Argument = roleIterationVariable ,
                            Handler = new WriteLine { Text = new InArgument<string>(env => roleIterationVariable.Get(env).Name) }
                        }
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:29,代码来源:Program.cs

示例12: CreateWF

        static Activity CreateWF()
        {
            Variable<string> message = new Variable<string>();

            return new Sequence()
            {
                Variables = { message },
                Activities =
                {
                    new AppendString()
                    {
                        Name = ".NET WF",
                        Result = message
                    },
                    new PrependString()
                    {
                        Name = message,
                        Result = message,
                    },
                    new WriteLine()
                    {
                        Text = message
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:26,代码来源:Program.cs

示例13: Receive

 public Receive()
 {
     Func<Activity> func = null;
     if (func == null)
     {
         func = delegate {
             if (this.internalReceive == null)
             {
                 return null;
             }
             if (this.requestFormatter == null)
             {
                 return this.internalReceive;
             }
             Variable<Message> variable = new Variable<Message> {
                 Name = "RequestMessage"
             };
             Variable<NoPersistHandle> variable2 = new Variable<NoPersistHandle> {
                 Name = "ReceiveNoPersistHandle"
             };
             this.internalReceive.Message = new OutArgument<Message>(variable);
             this.requestFormatter.Message = new InOutArgument<Message>(variable);
             this.internalReceive.NoPersistHandle = new InArgument<NoPersistHandle>(variable2);
             this.requestFormatter.NoPersistHandle = new InArgument<NoPersistHandle>(variable2);
             return new Sequence { Variables = { variable, variable2 }, Activities = { this.internalReceive, this.requestFormatter } };
         };
     }
     base.Implementation = func;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:Receive.cs

示例14: TestCaseActivity

 public TestCaseActivity()
 {
     children = new Collection<Activity>();
     _currentIndex = new Variable<int>();
     ErrorLevel = OnError.Continue;
     OwnDataFirst = true;
 }
开发者ID:bperreault,项目名称:autox,代码行数:7,代码来源:TestCaseActivity.cs

示例15: Main

        static void Main()
        {
            Variable<string> v = new Variable<string>();
            Sequence s = new Sequence()
            {
                Variables = { v },
                Activities =
                {
                    new Assign<string>()
                    {
                        To = v,
                        Value = "hello, world"
                    },
                    new Interop()
                    {
                        ActivityType = typeof(WriteLine),
                        ActivityProperties =
                        {
                            // Bind the Text property of the WriteLine to the Variable v
                            { "Text", new InArgument<string>(v) }
                        },
                        ActivityMetaProperties =
                        {
                            // Provide a value for the Name meta-property of the WriteLine
                            { "Name", "WriteLine" }
                        }
                    }
                }
            };

            WorkflowInvoker.Invoke(s);
            Console.WriteLine("Press [enter] to exit");
            Console.ReadLine();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:34,代码来源:Program.cs


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