~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/NotEquals.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
 
 
5
namespace SimpleExpressionEvaluator.Compilation.Functions.Operators
 
6
{
 
7
    /// <summary>
 
8
    /// Summary description for NotEquals.
 
9
    /// </summary>
 
10
    [Tokens("!=","<>")]
 
11
    public class NotEquals:BinaryOperator<bool>
 
12
    {
 
13
        protected override bool EvaluateOperation(object left, object right)
 
14
        {
 
15
            if (left == null && right == null)
 
16
                return false;
 
17
 
 
18
            if (left == null || right == null)
 
19
                return true;
 
20
 
 
21
            if (left is string || right is string)
 
22
                return StringComparer.CurrentCultureIgnoreCase.Compare(left, right) != 0;
 
23
 
 
24
            try
 
25
            {
 
26
                return Comparer.Default.Compare(left, right) != 0;
 
27
            }
 
28
            catch
 
29
            {
 
30
                //If the two objects can't be compared, then they certainly aren't equal.
 
31
                return true;
 
32
            }
 
33
        }
 
34
 
 
35
    }
 
36
}
 
 
b'\\ No newline at end of file'