public void UnaryConstructorTest() { UnaryOperators op = new UnaryOperators(); // TODO: Initialize to an appropriate value float expression = 0F; // TODO: Initialize to an appropriate value Unary target = new Unary(op, expression); Assert.Inconclusive("TODO: Implement code to verify target"); }
public UnaryOperatorExpression( UnaryOperators @operator, ExpressionBase <T> operand ) { Operator = @operator; Operand = operand; }
public Predicate(string operand, UnaryOperators unaryOperator) { if (unaryOperator == UnaryOperators.Not) { ExpressionValue = "NOT (" + operand + ")"; } else if (unaryOperator == UnaryOperators.IsNull) { ExpressionValue = operand + " IS NULL"; } else if (unaryOperator == UnaryOperators.IsNotNull) { ExpressionValue = operand + " IS NOT NULL"; } else { throw new NotImplementedException(); } }
public Glossary() { ReservedWords = OtherReservedWords.Union(Types) .Union(Conditions).Union(Cycles).ToList(); UnaryOperators = IncDecOperators.Union(UnaryBinary).Union(new List <string> { "!", "~" }).ToList(); Operators = BinaryOperatorsByPriority.Union(UnaryOperators).Union(AssignationOperators).ToList(); Operators.Remove("?"); Operators.Remove("."); ConsiderAsUnary = UnaryOperators.Union(Types).ToList(); Brackets = OpeningBrackets.Select(b => b + ClosingBrackets[OpeningBrackets.IndexOf(b)]).ToList(); LexemesOfTokenType = new Dictionary <TokenType, List <string> > { { TokenType.OpeningBracket, OpeningBrackets }, { TokenType.ClosingBracket, ClosingBrackets }, { TokenType.Punctuation, Punctuation }, { TokenType.ReservedWord, ReservedWords }, { TokenType.Operator, Operators }, { TokenType.Quote, Quotes } }; }
public static string AsString(this UnaryOperators @operator) => @operator switch {
public Unary(UnaryOperators op, bool expression) : this(op, new ConstantTypes.Bit(expression)) { // }
public Unary(UnaryOperators op, int expression) : this(op, new ConstantTypes.Integer(expression)) { // }
public Unary(UnaryOperators op, float expression) : this(op, new ConstantTypes.Float(expression)) { // }
public Unary(UnaryOperators op, decimal expression) : this(op, new ConstantTypes.Decimal(expression)) { // }
public Unary(UnaryOperators op, System.DateTime expression) : this(op, new ConstantTypes.DateTime(expression)) { // }
public Unary(UnaryOperators op, Expression expression) { Expression = expression; Operator = op; }
protected override void MetaOperate(List <MutableObject> entryList, UnaryOperators operation) { switch (operation) { case UnaryOperators.Value: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Operand.GetValue(subEntry), subEntry); } break; case UnaryOperators.Abs: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Abs(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Sum: float total = 0; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Average: total = 0; int count = 0; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); count++; } total /= count; foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Max: float max = float.MinValue; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundVal = Operand.GetValue(subEntry); if (max < foundVal) { max = foundVal; } } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(max, subEntry); } break; case UnaryOperators.Min: float min = float.MaxValue; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundVal = Operand.GetValue(subEntry); if (min > foundVal) { min = foundVal; } } foreach (var subEntry in OutputValue.GetEntries(entryList)) { OutputValue.SetValue(min, subEntry); } break; case UnaryOperators.Accumulate: total = 0f; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Diff: bool first = true; var prior = 0f; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundEntry = Operand.GetValue(subEntry); prior = foundEntry - prior; if (first) { first = false; OutputValue.SetValue(0f, subEntry); prior = foundEntry; continue; } OutputValue.SetValue(prior, subEntry); prior = foundEntry; } break; case UnaryOperators.Sign: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue((Operand.GetValue(subEntry) >= 0?1f:-1f), subEntry); } break; case UnaryOperators.Sin: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Sin(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Cos: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Cos(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Tan: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Mathf.Tan(Operand.GetValue(subEntry)), subEntry); } break; default: throw new Exception("Unknown operation type!"); } }
public UnaryExpression(SourceLocation location, UnaryOperators @operator, Expression argument) : base(location) { this.Operator = @operator; this.Argument = argument; }
public void Test() { BinaryOperators o1 = new BinaryOperators() { X = 20, Y = 12 }; BinaryOperators o2 = new BinaryOperators() { X = 30, Y = 38 }; BinaryOperators o3 = o1 + o2; o3 += 2; Console.WriteLine("o3.X {0}, o3.Y {1}", o3.X, o3.Y); UnaryOperators uOp1 = new UnaryOperators() { X = 100, Y = 200 }; Console.WriteLine("uOp1.X {0}, uOp1.Y {1}", uOp1.X, uOp1.Y); uOp1++; ++uOp1; Console.WriteLine("uOp1.X {0}, uOp1.Y {1}", uOp1.X, uOp1.Y); EqualityOperator eo1 = new EqualityOperator() { X = 100, Y = 200 }; EqualityOperator eo2 = new EqualityOperator() { X = 100, Y = 200 }; Console.WriteLine("eo1 == eo2 {0} eo1.Equals(eo2) {1} ", eo1 == eo2, eo1.Equals(eo2)); ComparisonOperator co1 = new ComparisonOperator() { X = 2, Y = 2 }; ComparisonOperator co3 = new ComparisonOperator() { X = 6, Y = 6 }; ComparisonOperator co2 = new ComparisonOperator() { X = 4, Y = 4 }; Console.WriteLine(" co1 < co2 {0}", co1 < co2); Console.WriteLine(" co1 < co2 {0}", co1 > co2); Console.WriteLine(" co3 < co2 {0}", co3 > co2); CustomConversionA customA = new CustomConversionA() { Description = "My Description" }; CustomConversionC customC = new CustomConversionC() { Description = "My Description" }; CustomConversionB customBfromA = (CustomConversionB)customA; CustomConversionB customBfromCex = (CustomConversionB)customC; CustomConversionB customBfromCimp = customC; Console.WriteLine("CustomBfromA : {0}", customBfromA.ReverseDescription); Console.WriteLine("CustomBfromC(explicit) : {0}", customBfromCex.ReverseDescription); Console.WriteLine("CustomBfromC(implpicit) : {0}", customBfromCimp.ReverseDescription); }
protected abstract void MetaOperate(List <MutableObject> entryList, UnaryOperators operation);
protected override void MetaOperate(List <MutableObject> entryList, UnaryOperators operation) { switch (operation) { case UnaryOperators.Value: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Operand.GetValue(subEntry), subEntry); } break; case UnaryOperators.Accumulate: var total = Vector3.zero; foreach (var subEntry in Operand.GetEntries(entryList)) { total += Operand.GetValue(subEntry); OutputValue.SetValue(total, subEntry); } break; case UnaryOperators.Diff: bool first = true; var prior = Vector3.zero; foreach (var subEntry in Operand.GetEntries(entryList)) { var foundEntry = Operand.GetValue(subEntry); prior = foundEntry - prior; if (first) { first = false; OutputValue.SetValue(0, subEntry); prior = foundEntry; continue; } OutputValue.SetValue(prior, subEntry); prior = foundEntry; } break; case UnaryOperators.Sign: foreach (var subEntry in Operand.GetEntries(entryList)) { OutputValue.SetValue(Vector3.Normalize(Operand.GetValue(subEntry)), subEntry); } break; case UnaryOperators.Sin: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Sin(result.x), Mathf.Sin(result.y), Mathf.Sin(result.z)), subEntry); } break; case UnaryOperators.Cos: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Cos(result.x), Mathf.Cos(result.y), Mathf.Cos(result.z)), subEntry); } break; case UnaryOperators.Tan: foreach (var subEntry in Operand.GetEntries(entryList)) { var result = Operand.GetValue(subEntry); OutputValue.SetValue( new Vector3( Mathf.Tan(result.x), Mathf.Tan(result.y), Mathf.Tan(result.z)), subEntry); } break; default: throw new Exception("Unhandled operation type!"); } }