コード例 #1
0
        /// <summary>
        /// Runs this flow item
        /// </summary>
        /// <returns>Returns the path to take from here</returns>
        public override SMPathOut Run()
        {
            lock (this)
            {
                // If is a flow container
                if (HasChildren)
                {
                    // Run as a container
                    return(base.Run());
                }
                DoRebuild();
                // Evaluate
                if (_propWrapper == null)
                {
                    return(null);
                }

                //Comment Out by Kasem 15-May-2019
                //bool value = (bool)_propWrapper.Invoke();

                bool value = false;
                //Implement Dry Run Signal
                if (UseDryRunLogic && CompMachine.s_machine.IsDryRun)
                {
                    value = this.DryRunLogic;
                }
                else
                {
                    value = (bool)_propWrapper.Invoke();
                }

                foreach (SMPathOut pathOut in _pathList)
                {
                    SMPathOutBool pathOutBool = (pathOut as SMPathOutBool);
                    if (pathOutBool != null)
                    {
                        pathOutBool.ApplyPathDelay(ParentContainer);
                        if (pathOutBool.True == value)
                        {
                            return(pathOut);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        public override bool Validate()
        {
            Object sourceVal  = null;
            Object compareVal = null;

            lock (this)
            {
                string x = _propWrapperSource.PropertyType.ToString();
                if (_propWrapperSource.PropertyType.ToString().Contains("System") || _propWrapperSource.PropertyType.ToString().Contains("+"))
                {
                    var sourceProp = _propWrapperSource.Invoke();
                    sourceVal = sourceProp;
                }
                else if (_propWrapperSource.PropertyType.IsSubclassOf(typeof(MDouble.MDoubleBase)))
                {
                    MDouble.MDoubleBase sourceProp = (MDouble.MDoubleBase)_propWrapperSource.Invoke();
                    sourceVal = sourceProp.Val;
                }


                if (_propWrapperCompare != null)
                {
                    if (_propWrapperCompare.PropertyType.ToString().Contains("System") || _propWrapperCompare.PropertyType.ToString().Contains("+"))
                    {
                        var compareProp = _propWrapperCompare.Invoke();
                        compareVal = compareProp;
                    }
                    else if (_propWrapperCompare.PropertyType.IsSubclassOf(typeof(MDouble.MDoubleBase)))
                    {
                        MDouble.MDoubleBase compareProp = (MDouble.MDoubleBase)_propWrapperCompare.Invoke();
                        compareVal = compareProp.Val;
                    }
                }
                else
                {
                    compareVal = _fixCompareValue;
                }
            }

            dynamic sVal = sourceVal;
            dynamic cVal = compareVal;

            //Compare Value
            if (OperatorString == "==")
            {
                ValidationResult = sVal == cVal;
                return(ValidationResult);
            }
            else if (OperatorString == "!=")
            {
                ValidationResult = sVal != cVal;
                return(ValidationResult);
            }
            else if (OperatorString == ">")
            {
                ValidationResult = sVal > cVal;
                return(ValidationResult);
            }
            else if (OperatorString == ">=")
            {
                ValidationResult = sVal >= cVal;
                return(ValidationResult);
            }
            else if (OperatorString == "<")
            {
                ValidationResult = sVal < cVal;
                return(ValidationResult);
            }
            else if (OperatorString == "<=")
            {
                ValidationResult = sVal <= cVal;
                return(ValidationResult);
            }
            return(base.Validate());
        }