• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Activities.Variable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


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


示例18: CreateRetrieveWithComplexPredicateWF

        // Creates a workflow that uses FindInSqlTable activity with a more complex predicate to retrieve entities from a Sql Server Database
        static Activity CreateRetrieveWithComplexPredicateWF()
        {
            Variable<IList<Employee>> employees = new Variable<IList<Employee>>();
            DelegateInArgument<Employee> employeeIterationVariable = new DelegateInArgument<Employee>();
            return new Sequence()
            {
                Variables = { employees },
                Activities =
                {
                    new WriteLine { Text = "\r\nEmployees by Role and Location (more complex predicate)\r\n============================================" },
                    new FindInSqlTable<Employee>
                    {
                        ConnectionString = cnn,
                        Predicate = new LambdaValue<Func<Employee, bool>>(c => new Func<Employee, bool>(emp => emp.Role.Equals("PM") && emp.Location.Equals("Redmond"))),
                        Result = new OutArgument<IList<Employee>>(employees)
                    },
                    new ForEach<Employee>
                    {
                        Values = new InArgument<IEnumerable<Employee>>(employees),
                        Body = new ActivityAction<Employee>()
                        {
                            Argument = employeeIterationVariable,
                            Handler = new WriteLine { Text = new InArgument<string>(env => employeeIterationVariable.Get(env).ToString()) }

                        }
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:30,代码来源:Program.cs


示例19: CacheMetadata

        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            RuntimeArgument valuesArgument = new RuntimeArgument("Values", typeof(IEnumerable), ArgumentDirection.In, true);
            metadata.Bind(this.Values, valuesArgument);
            metadata.SetArgumentsCollection(new Collection<RuntimeArgument> { valuesArgument });

            // declare the CompletionCondition as a child
            if (this.CompletionCondition != null)
            {
                metadata.SetChildrenCollection(new Collection<Activity> { this.CompletionCondition });
            }

            // declare the hasCompleted variable
            if (this.CompletionCondition != null)
            {
                if (this.hasCompleted == null)
                {
                    this.hasCompleted = new Variable<bool>();
                }

                metadata.AddImplementationVariable(this.hasCompleted);
            }

            metadata.AddDelegate(this.Body);
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:25,代码来源:ParallelForEach.cs


示例20: Create

        public Activity Create(DependencyObject target)
        {
            string correlationHandleName = ActivityDesignerHelper.GenerateUniqueVariableNameForContext(target, correlationHandleNamePrefix);

            Variable<CorrelationHandle> requestReplyCorrelation = new Variable<CorrelationHandle> { Name = correlationHandleName };
           
            Send send = new Send
            {
                OperationName = "Operation1",
                ServiceContractName = XName.Get("IService", "http://tempuri.org/"),
                CorrelationInitializers =
                {
                    new RequestReplyCorrelationInitializer
                    {
                        CorrelationHandle = new VariableValue<CorrelationHandle> { Variable = requestReplyCorrelation }
                    }
                }
            };

            Sequence sequence = new Sequence()
            {
                Variables = { requestReplyCorrelation },
                Activities =
                {
                    send,
                    new ReceiveReply
                    {      
                        DisplayName = "ReceiveReplyForSend",
                        Request = send,
                    },
                }
            };
            return sequence;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:34,代码来源:SendAndReceiveReplyFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Activities.WorkflowApplication类代码示例发布时间:2022-05-26
下一篇:
C# Activities.ActivityInstance类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap