Statistics
| Branch: | Revision:

root / trunk / Libraries / Json40r2 / Source / Src / Newtonsoft.Json.Tests / TestObjects / Product.cs @ d78cbf09

History | View | Annotate | Download (1.7 kB)

1 d78cbf09 Panagiotis Kanavos
#region License
2 d78cbf09 Panagiotis Kanavos
// Copyright (c) 2007 James Newton-King
3 d78cbf09 Panagiotis Kanavos
//
4 d78cbf09 Panagiotis Kanavos
// Permission is hereby granted, free of charge, to any person
5 d78cbf09 Panagiotis Kanavos
// obtaining a copy of this software and associated documentation
6 d78cbf09 Panagiotis Kanavos
// files (the "Software"), to deal in the Software without
7 d78cbf09 Panagiotis Kanavos
// restriction, including without limitation the rights to use,
8 d78cbf09 Panagiotis Kanavos
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9 d78cbf09 Panagiotis Kanavos
// copies of the Software, and to permit persons to whom the
10 d78cbf09 Panagiotis Kanavos
// Software is furnished to do so, subject to the following
11 d78cbf09 Panagiotis Kanavos
// conditions:
12 d78cbf09 Panagiotis Kanavos
//
13 d78cbf09 Panagiotis Kanavos
// The above copyright notice and this permission notice shall be
14 d78cbf09 Panagiotis Kanavos
// included in all copies or substantial portions of the Software.
15 d78cbf09 Panagiotis Kanavos
//
16 d78cbf09 Panagiotis Kanavos
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 d78cbf09 Panagiotis Kanavos
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 d78cbf09 Panagiotis Kanavos
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 d78cbf09 Panagiotis Kanavos
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 d78cbf09 Panagiotis Kanavos
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 d78cbf09 Panagiotis Kanavos
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 d78cbf09 Panagiotis Kanavos
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 d78cbf09 Panagiotis Kanavos
// OTHER DEALINGS IN THE SOFTWARE.
24 d78cbf09 Panagiotis Kanavos
#endregion
25 d78cbf09 Panagiotis Kanavos
26 d78cbf09 Panagiotis Kanavos
using System;
27 d78cbf09 Panagiotis Kanavos
28 d78cbf09 Panagiotis Kanavos
namespace Newtonsoft.Json.Tests.TestObjects
29 d78cbf09 Panagiotis Kanavos
{
30 d78cbf09 Panagiotis Kanavos
  public class Product
31 d78cbf09 Panagiotis Kanavos
  {
32 d78cbf09 Panagiotis Kanavos
    public string Name;
33 d78cbf09 Panagiotis Kanavos
    public DateTime ExpiryDate = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
34 d78cbf09 Panagiotis Kanavos
    public decimal Price;
35 d78cbf09 Panagiotis Kanavos
    public string[] Sizes;
36 d78cbf09 Panagiotis Kanavos
37 d78cbf09 Panagiotis Kanavos
    public override bool Equals(object obj)
38 d78cbf09 Panagiotis Kanavos
    {
39 d78cbf09 Panagiotis Kanavos
      if (obj is Product)
40 d78cbf09 Panagiotis Kanavos
      {
41 d78cbf09 Panagiotis Kanavos
        Product p = (Product)obj;
42 d78cbf09 Panagiotis Kanavos
43 d78cbf09 Panagiotis Kanavos
        return (p.Name == Name && p.ExpiryDate == ExpiryDate && p.Price == Price);
44 d78cbf09 Panagiotis Kanavos
      }
45 d78cbf09 Panagiotis Kanavos
46 d78cbf09 Panagiotis Kanavos
      return base.Equals(obj);
47 d78cbf09 Panagiotis Kanavos
    }
48 d78cbf09 Panagiotis Kanavos
49 d78cbf09 Panagiotis Kanavos
    public override int GetHashCode()
50 d78cbf09 Panagiotis Kanavos
    {
51 d78cbf09 Panagiotis Kanavos
      return (Name ?? string.Empty).GetHashCode();
52 d78cbf09 Panagiotis Kanavos
    }
53 d78cbf09 Panagiotis Kanavos
  }
54 d78cbf09 Panagiotis Kanavos
}