FlowDecision.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / FlowDecision.cs / 1305376 / FlowDecision.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.Activities.Statements 
{
    using System; 
    using System.Activities; 
    using System.Activities.Expressions;
    using System.Collections.Generic; 
    using System.ComponentModel;
    using System.Linq.Expressions;
    using System.Windows.Markup;
 
    public sealed class FlowDecision : FlowNode
    { 
        public FlowDecision() 
        {
        } 

        public FlowDecision(Expression> condition)
            : this()
        { 
            if (condition == null)
            { 
                throw FxTrace.Exception.ArgumentNull("condition"); 
            }
 
            this.Condition = new LambdaValue(condition);
        }

        public FlowDecision(Activity condition) 
            : this()
        { 
            if (condition == null) 
            {
                throw FxTrace.Exception.ArgumentNull("condition"); 
            }

            this.Condition = condition;
        } 

        [DefaultValue(null)] 
        public Activity Condition 
        {
            get; 
            set;
        }

        [DefaultValue(null)] 
        [DependsOn("Condition")]
        public FlowNode True 
        { 
            get;
            set; 
        }

        [DefaultValue(null)]
        [DependsOn("True")] 
        public FlowNode False
        { 
            get; 
            set;
        } 

        internal override void OnOpen(Flowchart owner, NativeActivityMetadata metadata)
        {
            if (this.Condition == null) 
            {
                metadata.AddValidationError(SR.FlowDecisionRequiresCondition(owner.DisplayName)); 
            } 
        }
 
        internal override void GetConnectedNodes(IList connections)
        {
            if (True != null)
            { 
                connections.Add(True);
            } 
 
            if (False != null)
            { 
                connections.Add(False);
            }
        }
 
        internal override void GetChildActivities(ICollection children)
        { 
            if (Condition != null) 
            {
                children.Add(Condition); 
            }
        }

        internal bool Execute(NativeActivityContext context, CompletionCallback onConditionCompleted) 
        {
            context.ScheduleActivity(Condition, onConditionCompleted); 
            return false; 
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK