public override bool Evaluate()
        {
            if (m_comparer == null)
            {
                if (_comparerType != null && _comparerType.IsValid)
                {
                    m_comparer = (IntComparer)System.Activator.CreateInstance(_comparerType.Type);
                }
                else
                {
                    throw new System.NullReferenceException("Null comparer");
                }
            }

            return(m_comparer.Compare(_providerA.GetValue(), _providerB.GetValue()));
        }
Beispiel #2
0
    public void M()
    {
        // Operators
        var i = 42;

        if (i == 32)
        {
            ;
        }
        if (i != 32)
        {
            ;
        }
        if (i > 32)
        {
            ;
        }
        if (i < 32)
        {
            ;
        }
        if (i >= 32)
        {
            ;
        }
        if (i <= 32)
        {
            ;
        }

        // Qualified method calls
        var o = (object)i;
        var s = "abc";

        this.Equals(32); // Equals
        if (o.Equals(32))
        {
            ;               // Equals
        }
        if (s.Equals("32"))
        {
            ;                 // IEquatable<T>.Equals
        }
        // Unqualified method calls
        Equals(32);
        Equals(o, 32);
        object.Equals(0, 32);
        ReferenceEquals(0, 32);
        object.ReferenceEquals(0, 32);

        // User-defined operators
        C c1 = null, c2 = null;

        if (c1 == c2)
        {
            ;
        }
        if (c1 != c2)
        {
            ;
        }
        if (c1 > c2)
        {
            ;
        }
        if (c1 < c2)
        {
            ;
        }
        if (c1 >= c2)
        {
            ;
        }
        if (c1 <= c2)
        {
            ;
        }

        // IComparer.Compare
        var comparer = new Comparer();

        comparer.Compare(i, "32");

        // IComparer<T>.Compare
        var intComparer = new IntComparer();

        intComparer.Compare(i, 32);

        // IComparable.Compare
        c1.CompareTo("c2");

        // IComparable<T>.Compare
        c1.CompareTo(c2);
    }
Beispiel #3
0
        public override DbReader <TestDbReader> CreateReader(TestCommand command)
        {
            DbReader <TestDbReader> ret = null;

            _lock.EnterWriteLock();

            if (command.Command.Contains("ReadWithDeleteAndLocal"))
            {
                var split = command.Command.Split(new[] { "%" }, StringSplitOptions.RemoveEmptyEntries);
                command.Command   = "asc2";
                command.Local     = bool.Parse(split[1]);
                command.IsDeleted = bool.Parse(split[2]);
            }

            switch (command.Command)
            {
            case "readMeta":
            case "read":
                var meta1 = Meta.Find(x => x.Value == command.Value && x.IsDeleted == command.IsDeleted);
                ret = meta1 == null
                        ? new TestDbReader(new List <int>(), new List <TestCommand>())
                        : new TestDbReader(command.Value, Meta.Find(x => x.Value == command.Value));
                break;

            case "ReadAllElementsAndMergeWhereStatemenetForKey":
                var meta = Meta.Where(x =>
                {
                    if (command.Support == 10)
                    {
                        return(x.Value == command.Value && x.IsDeleted == command.IsDeleted);
                    }

                    if (command.Local)
                    {
                        if (x.IsDeleted == command.IsDeleted)
                        {
                            return(true);
                        }
                        return(false);
                    }

                    if (!x.Local && x.IsDeleted == command.IsDeleted)
                    {
                        return(true);
                    }
                    return(false);
                }).ToList();
                var data = Data.Where(x => meta.Exists(w => w.Value == x)).ToList();
                ret = new TestDbReader(data, meta);
                break;

            case "desc":
                var meta2 = Meta.FindAll(x => x.IsDeleted == command.IsDeleted).ToList();
                meta2.Sort((x, y) => IntComparer.Compare(x.Value, y.Value));
                var data2 = Data.Where(x => meta2.Exists(w => w.Value == x)).ToList();
                ret = new TestDbReader(data2, meta2, true);
                break;

            case "asc":
                var meta3 = Meta.FindAll(x => x.IsDeleted == command.IsDeleted).ToList();
                meta3.Sort((x, y) => IntComparer.Compare(x.Value, y.Value));
                var data3 = Data.Where(x => meta3.Exists(w => w.Value == x)).ToList();
                ret = new TestDbReader(data3, meta3, false, true);
                break;

            case "asc2":
                var meta4 = Meta.FindAll(x => x.IsDeleted == command.IsDeleted && x.Local == command.Local).ToList();
                meta4.Sort((x, y) => - IntComparer.Compare(x.Value, y.Value));
                var data4 = Data.Where(x => meta4.Exists(w => w.Value == x)).ToList();
                ret = new TestDbReader(data4, meta4, false, true);
                break;
            }

            _lock.ExitWriteLock();
            return(ret);
        }