Esempio n. 1
0
 public override void Build(IGraphBuilder builder)
 {
     //do nothing
     //we can do the linkage here
     if (OnFalseHook != null)
     {
         builder.Link(Index, OnFalseHook.First().Index, "[label = \"f\"]");
     }
     if (OnTrueHook != null)
     {
         builder.Link(Index, OnTrueHook.First().Index, "[label = \"t\"]");
     }
 }
Esempio n. 2
0
        public override void InitialFulfill()
        {
            //this is where we need to do some if statements
            //to see what our contents are
            //in the end we will only register the OnTrue links
            //it's up to the upper level
            Operation cond0 = null;
            Operation cond1 = null;

            switch (Count)
            {
            case 2:
                cond0 = this[0];
                cond1 = this[1];
                switch (Operation)
                {
                case "&&":
                    RegisterHook((x) => { cond0.OnFalseHook = x; });
                    cond0.OnTrueHook = cond1;
                    cond0.InitialFulfill();
                    cond1.InitialFulfill();
                    if (OnFalseHook != null)
                    {
                        cond1.ResolveHooks(OnFalseHook.First());
                    }
                    //cond1.OnFalseHook = OnFalseHook.First();
                    else
                    {
                        RegisterHook((x) => { cond1.OnFalseHook = x; });
                    }
                    cond1.OnTrueHook = this.OnTrueHook;
                    RegisterHook((x) => cond1.ResolveHooks(x));
                    RegisterHook((x) => cond0.ResolveHooks(x));
                    break;

                case "||":
                    cond0.OnTrueHook = this.OnTrueHook;
                    cond1.OnTrueHook = this.OnTrueHook;
                    cond1.InitialFulfill();
                    cond0.InitialFulfill();
                    cond0.ResolveHooks(cond1.First()); //ensure
                    cond0.OnFalseHook = cond1.First();
                    //Console.WriteLine("\tcond1.First().Index = {0}, cond1.Index = {1}", cond1.First().Index, cond1.Index);
                    //Console.WriteLine("\tcond0.First().Index = {0}, cond0.Index = {1}", cond0.First().Index, cond0.Index);
                    if (OnFalseHook != null)
                    {
                        cond1.ResolveHooks(OnFalseHook.First());
                    }
                    else
                    {
                        RegisterHook((x) => { cond1.OnFalseHook = x; });
                    }
                    //The issue comes from the fact that the outer
                    //boolean expression is not providing the correct target
                    //
                    RegisterHook((x) =>
                    {
                        cond1.ResolveHooks(x);
                    });
                    RegisterHook((x) => cond0.ResolveHooks(x));
                    break;

                default:
                    //Console.WriteLine("//We are at default");
                    cond0.InitialFulfill();
                    cond1.InitialFulfill();
                    RegisterHook((x) => cond1.ResolveHooks(x));
                    RegisterHook((x) => cond0.ResolveHooks(x));
                    break;
                }
                //get those up and working
                break;

            case 1:
                cond0 = this[0];
                cond0.InitialFulfill();
                //register the operation
                RegisterHook((x) => cond0.ResolveHooks(x));
                break;

            case 0:
            default:
                RegisterHook((x) => { OnTrueHook = x; });
                break;
            }
        }