コード例 #1
0
        public static bool AllDynamic <T>(List <T> items, T valueToCompare, OperatorTypes operatorType, bool caseSensitive, SetTypes setType)
        {
            Expression <Func <T, bool> > myLambda = CollectionProcessingExpressions.GetLambda <T>(valueToCompare, operatorType, caseSensitive, setType);
            bool retVal = items.AsQueryable <T>().All(myLambda);

            return(retVal);
        }
コード例 #2
0
        /// <summary>
        /// Handle click event on the equals button to perform the operation in course
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Equals_Click(object sender, RoutedEventArgs e)
        {
            operands.Add(DisplayNumber);
            switch (currentOperation)
            {
            case OperatorTypes.Addition:
                DisplayNumber = SumOperands();
                break;

            case OperatorTypes.Subtraction:
                DisplayNumber = SubstractOperands();
                break;

            case OperatorTypes.Multiplication:
                DisplayNumber = MultiplyOperands();
                break;

            case OperatorTypes.Division:
                DisplayNumber = DivideOperands();
                break;

            default:
                break;
            }
            isNewNumber      = true;
            currentOperation = OperatorTypes.None;
            operands.Clear();
        }
コード例 #3
0
 public Operator(OperatorTypes operatorType, int precidence, SyntaxKind syntaxKind, string text)
 {
     this.OperatorType = operatorType;
     this.Precidence   = precidence;
     this.SyntaxKind   = syntaxKind;
     this.Text         = text;
 }
コード例 #4
0
ファイル: Operator.cs プロジェクト: QuantumCores/Mathema
 public Operator(string symbol, OperatorTypes type, int precedence, AssociativityTypes associativity, OperationTypes operationType)
 {
     this.Symbol            = symbol;
     this.Type              = type;
     this.Precedence        = precedence;
     this.AssociativityType = associativity;
     this.OperationType     = operationType;
 }
コード例 #5
0
 // Arbitrary binary operation
 public static object binary_operator(OperatorTypes op, object a, object b)
 {
     if (op >= OperatorTypes.add && op <= OperatorTypes.shr)
     {
         return(binary_operations[(int)op](a, b));
     }
     throw new ArgumentException();
 }
コード例 #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            OperatorTypes m = db.OperatorTypes.Find(id);

            db.OperatorTypes.Remove(m);
            db.SaveChanges();
            return(RedirectToAction("Index", "OperatorTypes"));
        }
コード例 #7
0
 // Arbitrary unary operation
 public static object unary_operator(OperatorTypes op, object a)
 {
     if (op >= OperatorTypes.negate && op <= OperatorTypes.logical_not)
     {
         return(unary_operations[(int)(op - OperatorTypes.negate)](a));
     }
     throw new ArgumentException();
 }
コード例 #8
0
 /// <summary>
 ///     Creates a new Operator.
 /// </summary>
 private MorestachioOperator(string operatorText,
                             OperatorTypes operatorType,
                             bool isBinaryOperator,
                             OperatorPlacement placement)
 {
     OperatorText     = operatorText;
     OperatorType     = operatorType;
     IsBinaryOperator = isBinaryOperator;
     Placement        = placement;
 }
コード例 #9
0
 /// <summary>
 ///     Creates a new Operator.
 /// </summary>
 private MorestachioOperator(string operatorText,
                             OperatorTypes operatorType,
                             bool acceptsTwoExpressions,
                             bool isPrefixOperator)
 {
     OperatorText          = operatorText;
     OperatorType          = operatorType;
     AcceptsTwoExpressions = acceptsTwoExpressions;
     IsPrefixOperator      = isPrefixOperator;
 }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "OperatorTypeID,Name")] OperatorTypes m)
 {
     if (ModelState.IsValid)
     {
         db.Entry(m).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "OperatorTypes"));
     }
     return(View(m));
 }
コード例 #11
0
        public ActionResult Create([Bind(Include = "OperatorTypeID,Name")] OperatorTypes m)
        {
            if (ModelState.IsValid)
            {
                db.OperatorTypes.Add(m);
                db.SaveChanges();
                return(RedirectToAction("Index", "OperatorTypes"));
            }

            return(View(m));
        }
コード例 #12
0
        static void Main(string[] args)
        {
            Configuration.RegisterComponents();

            List <string> delimiters    = new List <string>();
            bool          allowNegative = true;
            int?          upperBound    = null;
            OperatorTypes mathOperator  = OperatorTypes.Add;

            foreach (string arg in args)
            {
                if (arg == "--denyNegative" || arg == "-dn")
                {
                    allowNegative = false;
                }
                else if (arg.StartsWith("--upperBound") || arg.StartsWith("-ub"))
                {
                    string[] parts = arg.Split('=');
                    if (parts.Length >= 2)
                    {
                        int value;
                        if (int.TryParse(parts[1], out value))
                        {
                            upperBound = value;
                        }
                    }
                }
                else if (arg.StartsWith("--operator") || arg.StartsWith("-op"))
                {
                    string[] parts = arg.Split('=');
                    if (parts.Length >= 2)
                    {
                        switch (parts[1])
                        {
                        case "-": mathOperator = OperatorTypes.Subtract; break;

                        case "*": mathOperator = OperatorTypes.Multiply; break;

                        case "/": mathOperator = OperatorTypes.Divide; break;

                        default: mathOperator = OperatorTypes.Add; break;
                        }
                    }
                }
                else
                {
                    delimiters.Add(arg);
                }
            }

            App app = new App(Configuration.StringParser, Configuration.Calculator);

            app.Run(delimiters.ToArray(), allowNegative, upperBound, mathOperator);
        }
コード例 #13
0
        public static bool IsCompareToOperator(OperatorTypes operatorTypes)
        {
            ComparisonType comparisonType = TranslationHelper.CompareToValidEqualityTypes(operatorTypes);

            if (comparisonType != ComparisonType.NotSupported)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        public static bool IsStringComparisonOperator(OperatorTypes operatorTypes)
        {
            StringComparisonType stringComparisonType = TranslationHelper.StringComparisonValidTypes(operatorTypes);

            if (stringComparisonType != StringComparisonType.NotSupported)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #15
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (oplProp.Property != null)
                {
                    RightValueDef rv = oplProp.GetValue(_obj) as RightValueDef;

                    if (rv != null && rv.IsMethod && rv.Method != null)
                    {
                        return(property.Property != opr1Prop.Property &&
                               property.Property != operatorProp.Property &&
                               property.Property != opr2Prop.Property);
                    }
                }

                OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

                // action
                if (this.isAction())
                {
                    return(property.Property != opr1Prop.Property &&
                           property.Property != operatorProp.Property &&
                           property.Property != opr2Prop.Property);
                }

                // assign
                else if (operatorType == OperatorTypes.Assign)
                {
                    return(property.Property != opr1Prop.Property);
                }

                // compute
                else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
                {
                }

                // compare
                else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(base.ShouldAddProperty(property));
        }
コード例 #16
0
        /// <summary>
        /// only the types of equality operators you can use with CompareTo
        /// </summary>
        /// <param name="operatorTypes"></param>
        /// <returns></returns>
        public static ComparisonType CompareToValidEqualityTypes(OperatorTypes operatorTypes)
        {
            switch (operatorTypes)
            {
            case OperatorTypes.Is:
            {
                return(ComparisonType.Equal);
            }

            case OperatorTypes.Less:
            {
                return(ComparisonType.LessThan);
            }

            case OperatorTypes.LessIs:
            {
                return(ComparisonType.LessThanOrEqual);
            }

            case OperatorTypes.More:
            {
                return(ComparisonType.GreaterThan);
            }

            case OperatorTypes.MoreIs:
            {
                return(ComparisonType.GreaterThanOrEqual);
            }

            case OperatorTypes.Not:
            {
                return(ComparisonType.NotEqual);
            }

            case OperatorTypes.In:
            {
                return(ComparisonType.In);
            }

            case OperatorTypes.NotIn:
            {
                return(ComparisonType.NotIn);
            }

            default:
            {
                return(ComparisonType.NotSupported);
            }
            }
        }
コード例 #17
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OperatorTypes operatorTypes = db.OperatorTypes.Find(id);

            if (operatorTypes == null)
            {
                return(HttpNotFound());
            }
            return(View(operatorTypes));
        }
コード例 #18
0
        private void Operate(ICalculationResult result, OperatorTypes mathOperator, int nextNumber)
        {
            string text = nextNumber < 0 ? "(" + nextNumber.ToString() + ")" : nextNumber.ToString();

            if (result.Text == "")
            {
                result.Numeric = nextNumber;
                result.Text    = text;
                return;
            }

            switch (mathOperator)
            {
            case OperatorTypes.Add:
                result.Numeric += nextNumber;
                if (!string.IsNullOrEmpty(result.Text))
                {
                    result.Text += "+";
                }
                break;

            case OperatorTypes.Subtract:
                result.Numeric -= nextNumber;
                if (!string.IsNullOrEmpty(result.Text))
                {
                    result.Text += "-";
                }
                break;

            case OperatorTypes.Multiply:
                result.Numeric *= nextNumber;
                if (!string.IsNullOrEmpty(result.Text))
                {
                    result.Text += "*";
                }
                break;

            case OperatorTypes.Divide:
                result.Numeric /= nextNumber;
                if (!string.IsNullOrEmpty(result.Text))
                {
                    result.Text += "/";
                }
                break;
            }

            result.Text += text;
        }
コード例 #19
0
        public override string GetLabel(DesignerPropertyInfo property)
        {
            OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

            // compare
            if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");
                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            return(base.GetLabel(property));
        }
コード例 #20
0
 private OperatorTypes DetectGreaterOrLess()
 {
     if (InputLine.Contains(">="))
     {
         this.OperatorType = OperatorTypes.Greater;
     }
     else if (InputLine.Contains("<="))
     {
         this.OperatorType = OperatorTypes.Less;
     }
     else
     {
         this.OperatorType = OperatorTypes.none;
     }
     return(this.OperatorType);
 }
コード例 #21
0
        public override string GetLabel(DesignerPropertyInfo property)
        {
            OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

            // action
            if (this.isAction())
            {
                DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");

                if (property.Property == oplProp.Property)
                {
                    return(Resources.Method);
                }
            }

            // assign
            else if (operatorType == OperatorTypes.Assign)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            // compute
            else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
            {
            }

            // compare
            else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            return(base.GetLabel(property));
        }
コード例 #22
0
        /// <summary>
        /// Applies a specific math operator on a list of numbers.
        /// </summary>
        /// <param name="numbers"></param>
        /// <param name="mathOperator"></param>
        /// <returns></returns>
        public ICalculationResult Calculate(List <int> numbers, OperatorTypes mathOperator)
        {
            ICalculationResult result = new Result
            {
                Numeric = 0,
                Text    = ""
            };

            foreach (int number in numbers)
            {
                Operate(result, mathOperator, number);
            }

            if (!string.IsNullOrEmpty(result.Text))
            {
                result.Text += " = " + result.Numeric.ToString();
            }
            return(result);
        }
コード例 #23
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                OperatorTypes        operatorType = (OperatorTypes)GetProperty(_obj, "Operator");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");


                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                // compare
                if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(true);
        }
コード例 #24
0
        public static StringComparisonType StringComparisonValidTypes(OperatorTypes operatorTypes)
        {
            switch (operatorTypes)
            {
            case OperatorTypes.Contains:
            {
                return(StringComparisonType.Contains);
            }

            case OperatorTypes.NoContains:
            {
                return(StringComparisonType.NotContains);
            }

            case OperatorTypes.Ends:
            {
                return(StringComparisonType.EndsWith);
            }

            case OperatorTypes.NoEnds:
            {
                return(StringComparisonType.NotEndsWith);
            }

            case OperatorTypes.Starts:
            {
                return(StringComparisonType.StartsWith);
            }

            case OperatorTypes.NoStarts:
            {
                return(StringComparisonType.NotStartsWith);
            }

            default:
            {
                return(StringComparisonType.NotSupported);
            }
            }
        }
コード例 #25
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                // action
                if (this.isAction())
                {
                    return(property.Property != opr1Prop.Property &&
                           property.Property != operatorProp.Property &&
                           property.Property != opr2Prop.Property);
                }

                // assign
                else if (operatorType == OperatorTypes.Assign)
                {
                    return(property.Property != opr1Prop.Property);
                }

                // compute
                else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
                {
                }

                // compare
                else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(true);
        }
コード例 #26
0
ファイル: Example.cs プロジェクト: Aashay23/VTBCapitalTest
 public Operator(OperatorTypes operatorType)
 {
     OperatorType = operatorType;
 }
コード例 #27
0
 /// <summary>
 /// Handle click event on the division button to perform an division operation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Divide_Click(object sender, RoutedEventArgs e)
 {
     currentOperation = OperatorTypes.Division;
     isNewNumber = true;
 }
コード例 #28
0
 /// <summary>
 /// Handle click event on the equals button to perform the operation in course
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Equals_Click(object sender, RoutedEventArgs e)
 {
     operands.Add(DisplayNumber);
     switch (currentOperation)
     {
         case OperatorTypes.Addition:
             DisplayNumber = SumOperands();
             break;
         case OperatorTypes.Subtraction:
             DisplayNumber = SubstractOperands();
             break;
         case OperatorTypes.Multiplication:
             DisplayNumber = MultiplyOperands();
             break;
         case OperatorTypes.Division:
             DisplayNumber = DivideOperands();
             break;
         default:
             break;
     }
     isNewNumber = true;
     currentOperation = OperatorTypes.None;
     operands.Clear();
 }
コード例 #29
0
 /// <summary>
 /// Handle click event on the multiplication button to perform an multiplication operation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Multiply_Click(object sender, RoutedEventArgs e)
 {
     currentOperation = OperatorTypes.Multiplication;
     isNewNumber = true;
 }
コード例 #30
0
 /// <summary>
 /// Handle click event on the substraction button to perform an substraction operation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Subtract_Click(object sender, RoutedEventArgs e)
 {
     currentOperation = OperatorTypes.Subtraction;
     isNewNumber = true;
 }
コード例 #31
0
 /// <summary>
 /// Handle click event on the addition button to perform an addition operation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     currentOperation = OperatorTypes.Addition;
     isNewNumber = true;
 }
コード例 #32
0
ファイル: Predicate.cs プロジェクト: qipa/behaviac-1
        //if there is a 'Predicate' attachment, convert it to a Condition node and attach it to the '_custom_condition' connector.
        private void AutoRestruct(List <Node.ErrorCheck> result, int version, Behaviac.Design.Attachments.Attachment a, Node node)
        {
            if (version <= 1)
            {
                string attachClass = a.GetType().FullName;
                if (attachClass.IndexOf("PluginBehaviac.Events.Predicate") >= 0)
                {
                    DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opl");
                    RightValueDef        opl      = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opr");
                    RightValueDef opr = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Operator");
                    OperatorType  oprr    = (OperatorType)propInfo.GetValue(a);
                    OperatorTypes oprType = (OperatorTypes)((int)OperatorTypes.Equal - (int)OperatorType.Equal + (int)oprr);
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "BinaryOperator");
                    Behaviac.Design.Attachments.BinaryOperator binaryOpr = (Behaviac.Design.Attachments.BinaryOperator)propInfo.GetValue(a);

                    string clss      = node.GetType().FullName;
                    bool   bIsSeqSel = (node.GetType().IsSubclassOf(typeof(Sequence)) ||
                                        node.GetType().IsSubclassOf(typeof(Selector)));

                    bool bCare = (bIsSeqSel ||
                                  node.GetType().IsSubclassOf(typeof(Impulse))
                                  );

                    if (bCare ||
                        clss == "PluginBehaviac.Nodes.Query" ||
                        clss == "PluginBehaviac.Nodes.DecoratorCountLimit")
                    {
                        node.RemoveAttachment(a);
                        node.Behavior.TriggerWasModified(node);

                        Type newType = Plugin.GetType("PluginBehaviac.Nodes.Condition");

                        Behaviac.Design.Nodes.Node           newNode   = Behaviac.Design.Nodes.Node.Create(newType);
                        Behaviac.Design.Nodes.Node.Connector connector = node.GetConnector(Node.Connector.kInterupt);

                        if (connector != null && connector.Identifier == Node.Connector.kInterupt && connector.ChildCount > 0)
                        {
                            //it has multiple Predicates, so insert all of them to a newly created Sequence
                            Node oldOne = (Node)connector.GetChild(0);
                            if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                            {
                                AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                            }
                            else
                            {
                                if (bIsSeqSel)
                                {
                                    Debug.Check(oldOne.GetType().IsSubclassOf(typeof(Decorator)));
                                    Decorator d = oldOne as Decorator;
                                    node      = oldOne;
                                    connector = node.GetConnector(BaseNode.Connector.kGeneric);
                                    oldOne    = (Node)d.Children[0];
                                }

                                if (oldOne.GetType() == typeof(PluginBehaviac.Nodes.And))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.Or)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.Or");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType() == typeof(PluginBehaviac.Nodes.Or))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.And)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.And");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                                {
                                    AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                                }
                                else
                                {
                                    Debug.Check(false);
                                }
                            }
                        }
                        else
                        {
                            //the first condition
                            Behaviac.Design.Nodes.Node notNode = null;
                            if (bIsSeqSel)
                            {
                                //for sequence/selector, it is reverted
                                Type notType = Plugin.GetType("PluginBehaviac.Nodes.DecoratorNot");

                                notNode = Behaviac.Design.Nodes.Node.Create(notType);
                                node.AddChild(BaseNode.Connector.kInterupt, notNode);
                                notNode.AddChild(BaseNode.Connector.kGeneric, newNode);
                            }
                            else
                            {
                                node.AddChild(BaseNode.Connector.kInterupt, newNode);
                            }
                        }

                        // initialise the attachments properties
                        IList <DesignerPropertyInfo> lp = newNode.GetDesignerProperties();
                        for (int p = 0; p < lp.Count; ++p)
                        {
                            if (lp[p].Property.Name == "Opl")
                            {
                                lp[p].Property.SetValue(newNode, opl, null);
                            }
                            else if (lp[p].Property.Name == "Opr")
                            {
                                lp[p].Property.SetValue(newNode, opr, null);
                            }
                            else if (lp[p].Property.Name == "Operator")
                            {
                                lp[p].Property.SetValue(newNode, oprr, null);
                            }
                        }

                        // update attacheent with attributes
                        newNode.OnPropertyValueChanged(false);
                    }
                    else if (clss == "PluginBehaviac.Nodes.Action")
                    {
                        Type newType = Plugin.GetType("PluginBehaviac.Events.Precondition");

                        Behaviac.Design.Attachments.Attachment newNode = Behaviac.Design.Attachments.Attachment.Create(newType, node);
                        node.AddAttachment(newNode);
                        node.RemoveAttachment(a);
                        node.Behavior.TriggerWasModified(node);

                        // initialise the attachments properties
                        IList <DesignerPropertyInfo> lp = newNode.GetDesignerProperties();
                        for (int p = 0; p < lp.Count; ++p)
                        {
                            if (lp[p].Property.Name == "BinaryOperator")
                            {
                                lp[p].Property.SetValue(newNode, binaryOpr, null);
                            }
                            else if (lp[p].Property.Name == "Opl")
                            {
                                lp[p].Property.SetValue(newNode, opl, null);
                            }
                            else if (lp[p].Property.Name == "Opr2")
                            {
                                lp[p].Property.SetValue(newNode, opr, null);
                            }
                            else if (lp[p].Property.Name == "Operator")
                            {
                                lp[p].Property.SetValue(newNode, oprType, null);
                            }
                            else if (lp[p].Property.Name == "IsAlive")
                            {
                                lp[p].SetValueFromString(result, newNode, "true");
                            }
                        }

                        // update attacheent with attributes
                        newNode.OnPropertyValueChanged(false);
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
            } // if (version <= 1)
        }
コード例 #33
0
 private static MorestachioOperator UnaryOperator(string operatorText, OperatorTypes type, OperatorPlacement placement = OperatorPlacement.Right)
 {
     return(new MorestachioOperator(operatorText, type, false, placement));
 }
コード例 #34
0
ファイル: Operator.cs プロジェクト: notinmood/hiland
 public Operator(OperatorTypes type, string value)
 {
     this.Type = type;
     this.Value = value;
 }
コード例 #35
0
ファイル: Operator.cs プロジェクト: notinmood/hiland
        /// <summary>
        /// 运算符优先级比较
        /// </summary>
        /// <param name="optA">运算符类型A</param>
        /// <param name="optB">运算符类型B</param>
        /// <returns>A与B相比,-1,低;0,相等;1,高</returns>
        public static int ComparePriority(OperatorTypes optA, OperatorTypes optB)
        {
            if (optA == optB)
            {
                //A、B优先级相等
                return 0;
            }

            //乘,除,余(*,/,%)
            if ((optA >= OperatorTypes.MUL && optA <= OperatorTypes.MOD) &&
                (optB >= OperatorTypes.MUL && optB <= OperatorTypes.MOD))
            {
                return 0;
            }
            //加,减(+,-)
            if ((optA >= OperatorTypes.ADD && optA <= OperatorTypes.SUB) &&
                (optB >= OperatorTypes.ADD && optB <= OperatorTypes.SUB))
            {
                return 0;
            }
            //小于,小于或等于,大于,大于或等于(<,<=,>,>=)
            if ((optA >= OperatorTypes.LT && optA <= OperatorTypes.GE) &&
                (optB >= OperatorTypes.LT && optB <= OperatorTypes.GE))
            {
                return 0;
            }
            //等于,不等于(=,<>)
            if ((optA >= OperatorTypes.ET && optA <= OperatorTypes.UT) &&
                (optB >= OperatorTypes.ET && optB <= OperatorTypes.UT))
            {
                return 0;
            }
            //三角函数
            if ((optA >= OperatorTypes.TAN && optA <= OperatorTypes.ATAN) &&
                    (optB >= OperatorTypes.TAN && optB <= OperatorTypes.ATAN))
            {
                return 0;
            }

            if (optA < optB)
            {
                //A优先级高于B
                return 1;
            }

            //A优先级低于B
            return -1;
        }
コード例 #36
0
 private static MorestachioOperator UnaryOperator(string operatorText, OperatorTypes type, bool leftHandOperator)
 {
     return(new MorestachioOperator(operatorText, type, false, leftHandOperator));
 }
コード例 #37
0
 private static MorestachioOperator BinaryOperator(string operatorText, OperatorTypes type)
 {
     return(new MorestachioOperator(operatorText, type, true, false));
 }