Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (!(obj is AnotherCustomer))
            {
                return(false);
            }
            AnotherCustomer item = (AnotherCustomer)obj;

            return(Id.Equals(item.Id));
        }
Exemplo n.º 2
0
        public static int CompareBy <T>(Func <AnotherCustomer, T> comparison, AnotherCustomer x, AnotherCustomer y)
        {
            if (comparison == null)
            {
                throw new ArgumentNullException(nameof(comparison));
            }
            IComparable a = comparison(x) as IComparable;

            if (a == null)
            {
                throw new ArgumentException(nameof(comparison));
            }
            return(a.CompareTo(comparison(y)));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var c = new Customer()
            {
                Id = 10, Name = "bbb", LastName = "zzz"
            };
            var c1 = new Customer()
            {
                Id = 10, Name = "ccc", LastName = "yyy"
            };

            Console.WriteLine(Customer.CompareBy(e => e.LastName, c, c1));
            var c2 = new AnotherCustomer()
            {
                Id = 10, Name = "bbb", LastName = "fff"
            };
            var c3 = new AnotherCustomer()
            {
                Id = 10, Name = "ccc", LastName = "yyy"
            };

            Console.WriteLine(AnotherCustomer.CompareBy(e => e.Id, c2, c3));
            Console.WriteLine(c2 > c3);
        }
Exemplo n.º 4
0
 public static bool LessThan(AnotherCustomer x, AnotherCustomer y)
 {
     return(string.Compare(x.Name, y.Name) < 0);
 }
Exemplo n.º 5
0
 public static bool GreaterThan(AnotherCustomer x, AnotherCustomer y)
 {
     return(string.Compare(x.Name, y.Name) > 0);
 }