Esempio n. 1
0
        protected virtual bool TransferMultiAction(LBAction[] _others, LBActionTransitTypes _transit, LBActionTransitDirection _dir)
        {
            int  i;
            bool b;

            b = false;

            if (_dir == LBActionTransitDirection.In)             // transition from _other to this (IN this)
            {
                for (i = 0; i < _others.Length; i++)
                {
                    if (!this.CanTransferAction(_others [i], _transit, LBActionTransitDirection.In))
                    {
                        return(false);
                    }

                    if (_others [i] is LBTransitiveAction)
                    {
                        LBTransitiveAction other = (LBTransitiveAction)(_others [i]);

                        if (other.CanTransferAction(this, _transit, LBActionTransitDirection.Out))
                        {
                            other.Deactivate(this, _transit);
                            //this.Activate (other, _transit);
                            b = true;

                            //return true;
                        }
                    }
                    else
                    {
                        if (_others [i].CanDeactivateAction())                          // here we are deactivating with an external call
                        {
                            _others [i].DeactivateAction();
                            ///this.Activate (_others[i], _transit);
                            b = true;

                            //return true;
                        }
                    }
                }

                if (b == true)
                {
                    this.Activate(_others, _transit);
                    return(true);
                }
            }
            else             // transition from this to _other (OUT of this)
            {
                for (i = 0; i < _others.Length; i++)
                {
                    if (!this.CanTransferAction(_others [i], _transit, LBActionTransitDirection.Out))
                    {
                        return(false);
                    }

                    if (_others [i] is LBTransitiveAction)
                    {
                        LBTransitiveAction other = (LBTransitiveAction)(_others [i]);

                        if (other.CanTransferAction(this, _transit, LBActionTransitDirection.In))
                        {
                            other.Activate(this, _transit);
                            //this.Deactivate (other, _transit);
                            b = true;

                            //return true;
                        }
                    }
                    else
                    {
                        if (_others [i].CanActivateAction())                          // here we are activating with an external call
                        {
                            _others [i].ActivateAction();
                            //this.Deactivate (_other, _transit);
                            b = true;

                            //return true;
                        }
                    }
                }

                if (b == true)
                {
                    this.Deactivate(_others, _transit);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        protected virtual bool TransferAction(LBAction _other, LBActionTransitTypes _transit, LBActionTransitDirection _dir)
        {
            if (_dir == LBActionTransitDirection.In)             // transition from _other to this (IN this)
            {
                if (!this.CanTransferAction(_other, _transit, LBActionTransitDirection.In))
                {
                    return(false);
                }

                if (_other is LBTransitiveAction)
                {
                    LBTransitiveAction other = (LBTransitiveAction)_other;

                    if (other.CanTransferAction(this, _transit, LBActionTransitDirection.Out))
                    {
                        other.Deactivate(this, _transit);
                        this.Activate(other, _transit);

                        return(true);
                    }
                }
                else
                {
                    if (_other.CanDeactivateAction())                      // here we are deactivating with an external call
                    {
                        _other.DeactivateAction();
                        this.Activate(_other, _transit);

                        return(true);
                    }
                }
            }
            else             // transition from this to _other (OUT of this)
            {
                if (!this.CanTransferAction(_other, _transit, LBActionTransitDirection.Out))
                {
                    return(false);
                }

                if (_other is LBTransitiveAction)
                {
                    LBTransitiveAction other = (LBTransitiveAction)_other;

                    if (other.CanTransferAction(this, _transit, LBActionTransitDirection.In))
                    {
                        other.Activate(this, _transit);
                        this.Deactivate(other, _transit);

                        return(true);
                    }
                }
                else
                {
                    if (_other.CanActivateAction())                      // here we are activating with an external call
                    {
                        _other.ActivateAction();
                        this.Deactivate(_other, _transit);

                        return(true);
                    }
                }
            }

            return(false);
        }