Ejemplo n.º 1
0
        public override IEnumerable <Code> Traverse(
            Func <List <Expression>, bool?>?branchPicker)
        {
            bool?branchesToExecute = branchPicker == null? null: branchesToExecute = branchPicker(Expressions);

            // This yield lets any clients see the IF itself, for example for reporting purposes. It is filtered out and ignored in most cases.
            yield return(this);

            if (branchesToExecute == null || branchesToExecute == true)
            {
                foreach (var code in TrueCode.Traverse())
                {
                    yield return(code);
                }
            }
            if (FalseCode != null)
            {
                if (branchesToExecute == null || branchesToExecute == false)
                {
                    foreach (var code in FalseCode.Traverse())
                    {
                        yield return(code);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void Traverse(
     Func <Code, string, bool> examine,
     string originalSourceText)
 {
     if (examine(this, originalSourceText))
     {
         TrueCode.Traverse(examine, originalSourceText);
     }
     else if (FalseCode != null)
     {
         FalseCode.Traverse(examine, originalSourceText);
     }
 }