C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Fee.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.Serialization;
5
8
10{
13 public abstract class Fee : APIType_Polymorphic, IEquatable<Fee>
14 {
16 [DataMember(Order = 10)]
17 [NotNull]
18 public string name { get; set; }
19
21 [DataMember(Order = 11)]
22 [NotNull]
23 public DateTime? payout_date { get; set; }
24
25 #region Equality Overrides
27 public bool Equals(Fee other) => ReferenceEquals(this, other) ||
28 other != null &&
29 other.type == type &&
30 other.name == name &&
31 other.payout_date == payout_date;
32
36 public override bool Equals(object obj) =>
37 obj is Fee fee && Equals(fee);
38
41 public override int GetHashCode()
42 {
43 return new { type, name, payout_date }.GetHashCode();
44 }
45 #endregion Equality Overrides
46
53 {
55 {
56 // Bitwise Exclusive Or (^) of all elements ensures the hash is order-independent
57 return references?.Aggregate(17, (hash, r) => hash ^ r.GetHashCode()) ?? 0;
58 }
59 }
60
64 {
65 // Do the quickest checks first before doing a full order-independent comparison.
66 if (ReferenceEquals(first, second)) return true;
67 if (first == null || second == null) return false;
68 if (first.Count != second.Count) return false;
69 // TODO: If all derivers of Fee contained HashSets of fee references rather than
70 // lists, this equality test wouldn't be so expensive.
71 return new HashSet<FeeReference>(first).SetEquals(second);
72 }
73 }
74}
Base class used by all types and resources.
string type
The server name for this type of resource.
Describes a collection of resources which can be listed.
Abstract representation of a fee. This resource type cannot be instantiated instead derived resource ...
Definition Fee.cs:14
static bool ReferencesEquivalent(List< FeeReference > first, List< FeeReference > second)
Used to determine if two lists of fee references are equivalent while ignoring the order in which fee...
Definition Fee.cs:63
bool Equals(Fee other)
override bool Equals(object obj)
Determine if this Fee is equivalent to another.
string name
A user friendly name for this fee.
Definition Fee.cs:18
DateTime? payout_date
The date on which the payout is made.
Definition Fee.cs:23
override int GetHashCode()
Get the HashCode for this Fee.
Definition Fee.cs:41
static int HashReferences(IEnumerable< FeeReference > references)
Get the HashCode for a collection of Fee References.
Definition Fee.cs:52