~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Expressions/SimpleExpressionEvaluator/Compilation/Functions/Operators/GreaterThan.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections;
 
3
using SimpleExpressionEvaluator.Compilation;
 
4
using SimpleExpressionEvaluator.Utilities;
 
5
 
 
6
namespace SimpleExpressionEvaluator.Compilation.Functions.Operators
 
7
{
 
8
    /// <summary>
 
9
    /// Summary description for GreaterThan.
 
10
    /// </summary>
 
11
    [Tokens(">")]
 
12
    public class GreaterThan:BinaryOperator<bool>
 
13
    {
 
14
        protected override bool EvaluateOperation(object leftVal, object rightVal)
 
15
        {
 
16
            if (leftVal == null && rightVal == null)
 
17
                return false;
 
18
            
 
19
            if (leftVal == null)
 
20
                return false;
 
21
            
 
22
            if (rightVal == null)
 
23
                return true;
 
24
 
 
25
            if (leftVal is string || rightVal is string)
 
26
                return StringComparer.CurrentCultureIgnoreCase.Compare(leftVal.ToString(), rightVal.ToString()) > 0;
 
27
 
 
28
 
 
29
            try
 
30
            {
 
31
                return Comparer.Default.Compare(leftVal, rightVal) > 0;
 
32
            }
 
33
            catch
 
34
            {
 
35
                return false;
 
36
            }
 
37
        }
 
38
 
 
39
    }
 
40
}
 
 
b'\\ No newline at end of file'