示例#1
0
        public IValue Find(IValue Value, string ColumnNames = null, bool IncludeChildren = false)
        {
            List <ValueTreeColumn> processing_list = Columns.GetProcessingColumnList(ColumnNames);

            foreach (ValueTreeRow row in _rows)
            {
                foreach (ValueTreeColumn col in processing_list)
                {
                    IValue current = row.Get(col);
                    if (Value.Equals(current))
                    {
                        return(row);
                    }
                }
                if (IncludeChildren)
                {
                    IValue children_result = row.Rows.Find(Value, ColumnNames, IncludeChildren);
                    if (children_result.DataType != Machine.DataType.Undefined)
                    {
                        return(children_result);
                    }
                }
            }
            return(ValueFactory.Create());
        }
示例#2
0
        protected static IValue IdentityEqual(List <IValue> arguments, Scope s)
        {
            IValue first  = arguments.First();
            IValue second = arguments.Skip(1).First();

            return(first.Equals(second) ? Bool.True : Bool.False);
        }
示例#3
0
        public IValue interpret(Context context, IValue lval, IValue rval)
        {
            bool equal = false;

            switch (oper)
            {
            case EqOp.IS:
                equal = lval == rval;
                break;

            case EqOp.IS_NOT:
                equal = lval != rval;
                break;

            case EqOp.IS_A:
                equal = isA(context, lval, rval);
                break;

            case EqOp.IS_NOT_A:
                equal = !isA(context, lval, rval);
                break;

            case EqOp.EQUALS:
                equal = lval.Equals(context, rval);
                break;

            case EqOp.NOT_EQUALS:
                equal = !lval.Equals(context, rval);
                break;

            case EqOp.CONTAINS:
                equal = lval.Contains(context, rval);
                break;

            case EqOp.NOT_CONTAINS:
                equal = !lval.Contains(context, rval);
                break;

            case EqOp.ROUGHLY:
                equal = lval.Roughly(context, (IValue)rval);
                break;
            }
            return(BooleanValue.ValueOf(equal));
        }
示例#4
0
 /// <summary>
 /// <see cref="IElement.RemoveItem" />
 /// </summary>
 public override void RemoveItem(object objectToRemove)
 {
     if (_leftValue != null && _leftValue.Equals(objectToRemove))
     {
         _leftValue = null;
     }
     else
     {
         _rightValue = null;
     }
 }
示例#5
0
        private void interpretError(Context context, ExecutionError e)
        {
            IValue actual        = e.interpret(context, "__test_error__");
            IValue expectedError = error == null ? null : error.interpret(context);

            if (expectedError != null && expectedError.Equals(actual))
            {
                printSuccess(context);
            }
            else
            {
                String actualName   = ((IInstance)actual).GetMemberValue(context, "name", false).ToString();
                String expectedName = error == null ? "SUCCESS" : error.getName();
                printMissingError(context, expectedName, actualName);
            }
        }
示例#6
0
        public IValue Find(IValue value, string columnNames = null)
        {
            List <ValueTableColumn> processing_list = GetProcessingColumnList(columnNames);

            foreach (ValueTableRow row in _rows)
            {
                foreach (ValueTableColumn col in processing_list)
                {
                    IValue current = row.Get(col);
                    if (value.Equals(current))
                    {
                        return(row);
                    }
                }
            }
            return(ValueFactory.Create());
        }
示例#7
0
        private bool CheckFilterCriteria(ValueTableRow Row, StructureImpl Filter)
        {
            foreach (KeyAndValueImpl kv in Filter)
            {
                ValueTableColumn Column = Columns.FindColumnByName(kv.Key.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(kv.Key.AsString());
                }

                IValue current = Row.Get(Column);
                if (!current.Equals(kv.Value))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#8
0
        public void Test_02_SymbolicValue()
        {
            string msg = "Error: wrong definition of IEquatable interface for: {0}.";

            SymbolicValue   sv   = new SymbolicValue("sv");
            IValue <AValue> sive = sv;
            dynamic         dsv  = new SymbolicValue("sv");
            object          osv  = new SymbolicValue("sv");

            Assert.IsTrue(sv.Equals(dsv), msg, "SymbolicValue");
            Assert.IsTrue(dsv.Equals(sv), msg, "SymbolicValue");
            Assert.IsTrue(dsv.Equals(sive), msg, "SymbolicValue and IValue<AValue>");
            Assert.IsTrue(osv.Equals(dsv), msg, "SymbolicValue");
            Assert.IsTrue(sv.Equals(osv), msg, "SymbolicValue");
            Assert.IsTrue(osv.Equals(sv), msg, "SymbolicValue");
            Assert.IsTrue(osv.Equals(sive), msg, "SymbolicValue and IValue<AValue>");
            Assert.IsTrue(sive.Equals(osv), msg, "SymbolicValue and IValue<AValue>");
        }
示例#9
0
        public static void AssertBencodexEqual(IValue expected, IValue actual)
        {
            bool equal = (expected is null && actual is null) ||
                         (expected is Null && actual is Null) ||
                         (expected is Bencodex.Types.Boolean && actual is Bencodex.Types.Boolean &&
                          expected.Equals(actual)) ||
                         (expected is Integer && actual is Integer && expected.Equals(actual)) ||
                         (expected is Binary && actual is Binary && expected.Equals(actual)) ||
                         (expected is Text && actual is Text && expected.Equals(actual)) ||
                         (expected is List && actual is List && expected.Equals(actual)) ||
                         (expected is Dictionary && actual is Dictionary && expected.Equals(actual));

            if (equal)
            {
                return;
            }

            string        expectedInspection = expected?.ToString() ?? "(null)";
            string        actualInspection   = actual?.ToString() ?? "(null)";
            DiffPaneModel diffModel          = InlineDiffBuilder.Diff(expectedInspection, actualInspection);
            var           prefixes           = new Dictionary <ChangeType, string>
            {
                [ChangeType.Deleted]   = "-",
                [ChangeType.Inserted]  = "+",
                [ChangeType.Unchanged] = " ",
            };

            string diff = string.Join(
                Environment.NewLine,
                diffModel.Lines.Select(line =>
                                       (prefixes.TryGetValue(line.Type, out string prefix) ? prefix : " ") + line.Text
                                       )
                );

            throw new XunitException(
                      "Two Bencodex values are not equal.\n--- Expected\n+++ Actual\n\n" + diff
                      );
        }
示例#10
0
 public override BooleanValue Equals(IValue other)
 {
     return(other.Equals(this));
 }
示例#11
0
 public bool Equals(TableSheetsState other)
 {
     return(_serialized?.Equals(other._serialized) ?? false);
 }
示例#12
0
 /// <summary>
 /// Не равенство
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 public static IValue UNEQ(IValue left, IValue right)
 {
     return(Create(!left.Equals(right)));
 }
示例#13
0
        static void Main(string[] args)
        {
            //double a = 43.52;
            //double b = 40000566.78234234;
            //double max;

            //Stopwatch sw = Stopwatch.StartNew();


            //sw.Restart();
            //max = SergeysBitwiseMax(a, b);
            //sw.Stop();

            //Console.WriteLine("SergeysBitwiseMax(" + a + ", " + b + ") = " + max + " took " + ElapsedNanoSeconds(sw) + " ns!");


            //sw.Restart();
            //max = Math.Max(a, b);
            //sw.Stop();

            //Console.WriteLine("Math.Max(" + a + ", " + b + ") = " + max + " took " + ElapsedNanoSeconds(sw) + " ns!");


            SymbolicExpression ident = new SymbolicExpression("symbolic");

            Console.WriteLine(ident);

            SimpleExpression <SymbolicValue> SymbolicSE = new SymbolicExpression("symbolic_exspression");

            Console.WriteLine(SymbolicSE.GetValue());

            SymbolicValue   sv   = new SymbolicValue("sv");
            IValue <AValue> sive = sv;
            dynamic         dsv  = new SymbolicValue("sv");
            object          osv  = new SymbolicValue("sv");

            Console.WriteLine(sv.Equals(dsv));
            Console.WriteLine(dsv.Equals(sv));
            Console.WriteLine(dsv.Equals(sive));
            Console.WriteLine(osv.Equals(dsv));
            Console.WriteLine(sv.Equals(osv));
            Console.WriteLine(osv.Equals(sv));
            Console.WriteLine(osv.Equals(sive));
            Console.WriteLine(sive.Equals(osv));

            IExpression <IValue <AValue> > sSV = SymbolicSE;

            List <IExpression <IValue <AValue> > > aivL = new List <IExpression <IValue <AValue> > >();

            aivL.Add(sSV);
            aivL.Add(SymbolicSE);

            NumericExpression n = new NumericExpression(6.7);

            Console.WriteLine(n.GetValue());

            SimpleExpression <NumericValue> NumericSE = new NumericExpression(3.4);

            Console.WriteLine(NumericSE.GetValue());

            FunctionInvocation <int> f = new FunctionInvocation <int>(
                delegate(object[] parameters)
            {
                int sum = 0;
                foreach (object parameter in parameters)
                {
                    sum += (int)parameter;
                }
                return(new NumericValue(sum));
            },
                5, 7, 8);

            Console.WriteLine("!! FunctionInvocation !! " + f.GetValue());

            // money

            Money <SymbolicValue> moneyFromSymbolicValue = new Money <SymbolicValue>(ident, Currency.GBP);

            Console.WriteLine(moneyFromSymbolicValue.GetValue());

            Money <SymbolicValue> moneyFromSymbolicExpression = new Money <SymbolicValue>(SymbolicSE, Currency.GBP);

            Console.WriteLine(moneyFromSymbolicExpression.GetValue());

            Money <NumericValue> moneyFromNumericValue = new Money <NumericValue>(n, Currency.GBP);

            Console.WriteLine(moneyFromNumericValue.GetValue());

            Money <NumericValue> moneyFromNumericExpression = new Money <NumericValue>(NumericSE, Currency.GBP);

            Console.WriteLine(moneyFromNumericExpression.GetValue());

            // percentage

            Percentage <SymbolicValue> symSEPerc = new Percentage <SymbolicValue>(SymbolicSE);

            Console.WriteLine(symSEPerc);

            Percentage <NumericValue> numPerc = new Percentage <NumericValue>(n);

            Console.WriteLine(numPerc);

            // Ratio

            Ratio <SymbolicValue> symbolicRatio = new Ratio <SymbolicValue>(ident);

            Console.WriteLine(symbolicRatio);

            Ratio <Value> funcInvRatio = new Ratio <Value>(f);

            Console.WriteLine(funcInvRatio);

            Ratio <NumericValue> percNumRatio = new Ratio <NumericValue>(numPerc);

            Console.WriteLine(percNumRatio);

            // participation

            Participation <SymbolicValue> symbolicRatioParticipation = new Participation <SymbolicValue>(symbolicRatio);

            Console.WriteLine(symbolicRatioParticipation);

            Participation <Value> funcInvRatioParticipation = new Participation <Value>(funcInvRatio);

            Console.WriteLine(funcInvRatioParticipation);

            Participation <NumericValue> percNumRatioParticipation = new Participation <NumericValue>(percNumRatio);

            Console.WriteLine(percNumRatioParticipation);

            // _Limit specification

            LimitSpecification <MoneyValue <SymbolicValue> > moneyFromSymbolicExpressionPayoutSpec =
                new LimitSpecification <MoneyValue <SymbolicValue> >(moneyFromSymbolicExpression);

            Console.WriteLine(moneyFromSymbolicExpressionPayoutSpec);

            LimitSpecification <MoneyValue <NumericValue> > moneyFromNumericValuePayoutSpec =
                new LimitSpecification <MoneyValue <NumericValue> >(moneyFromNumericValue, true);

            Console.WriteLine(moneyFromNumericValuePayoutSpec);

            LimitSpecification <NumericValue> numPercPayoutSpec =
                new LimitSpecification <NumericValue>(numPerc, true);

            Console.WriteLine(numPercPayoutSpec);

            // _Limit

            Limit <MoneyValue <SymbolicValue> > moneyFromSymbolicExpressionPayout
                = new Limit <MoneyValue <SymbolicValue> >(moneyFromSymbolicExpressionPayoutSpec, 1);

            // _Attachment

            Attachment <NumericValue> NumericSEAttachment = new Attachment <NumericValue>(NumericSE);

            // cover

            Cover <NumericValue, MoneyValue <SymbolicValue>, NumericValue> coverNumSymbNum
                = new Cover <NumericValue, MoneyValue <SymbolicValue>, NumericValue>(percNumRatioParticipation, moneyFromSymbolicExpressionPayout, NumericSEAttachment);

            Console.WriteLine(coverNumSymbNum);

            ICover <Value, Value, Value> cNSN
                = (ICover <Value, Value, Value>)coverNumSymbNum;

            Cover <SymbolicValue> coverNumShareNumPayout
                = new Cover <SymbolicValue>(symbolicRatioParticipation, "\"MyCoverLabel\"");

            Console.WriteLine(coverNumShareNumPayout);

            Console.ReadKey();
        }