Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DataMatch.cs
Go to the documentation of this file.
1 using System;
2 
3 namespace SiliconStudio.Assets.Diff
4 {
5  public struct DataMatch : IEquatable<DataMatch>
6  {
7  public static DataMatch Empty = new DataMatch(0, 0);
8  public static DataMatch MatchOne = new DataMatch(1, 1);
9  public static DataMatch NoMatchOne = new DataMatch(0, 1);
10 
11  public DataMatch(int count, int total)
12  {
13  Count = count;
14  Total = total;
15  }
16 
17  public readonly int Count;
18 
19  public readonly int Total;
20 
21  public bool Succeed
22  {
23  get
24  {
25  return Count == Total && Count >= 0 && Total >= 0;
26  }
27  }
28 
29  public bool Equals(DataMatch other)
30  {
31  return Count == other.Count && Total == other.Total;
32  }
33 
34  public override bool Equals(object obj)
35  {
36  if (ReferenceEquals(null, obj)) return false;
37  return obj is DataMatch && Equals((DataMatch)obj);
38  }
39 
40  public override int GetHashCode()
41  {
42  unchecked
43  {
44  return (Count*397) ^ Total;
45  }
46  }
47 
48  public static DataMatch operator +(DataMatch left, DataMatch right)
49  {
50  return new DataMatch(left.Count + right.Count, left.Total + right.Total);
51  }
52 
53  public static bool operator ==(DataMatch left, DataMatch right)
54  {
55  return left.Equals(right);
56  }
57 
58  public static bool operator !=(DataMatch left, DataMatch right)
59  {
60  return !left.Equals(right);
61  }
62 
63  public override string ToString()
64  {
65  return string.Format("Match {0}: {1} / {2}", Succeed, Count, Total);
66  }
67  }
68 }
DataMatch(int count, int total)
Definition: DataMatch.cs:11
_In_ size_t count
Definition: DirectXTexP.h:174
override bool Equals(object obj)
Definition: DataMatch.cs:34
bool Equals(DataMatch other)
Definition: DataMatch.cs:29