C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Policy.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.Serialization;
5
6namespace AnalyzeRe.Layers
7{
16 public class Policy : APIType, IEquatable<Policy>
17 {
18 #region Public Properties
21 [DataMember(Order = 2)]
22 public HashSet<RecordType> transform_records { get; set; } = new HashSet<RecordType>();
23
28 [DataMember(Order = 3)]
29 public HashSet<RecordType> forward_records { get; set; } = new HashSet<RecordType>();
30 #endregion Public Properties
31
32 #region Equality Overrides
37 public bool Equals(Policy other) => ReferenceEquals(this, other) ||
38 other != null &&
39 (ReferenceEquals(transform_records, other.transform_records) ||
40 transform_records != null && other.transform_records != null &&
41 transform_records.SetEquals(other.transform_records)) &&
42 (ReferenceEquals(forward_records, other.forward_records) ||
43 forward_records != null && other.forward_records != null &&
44 forward_records.SetEquals(other.forward_records));
45
49 public override bool Equals(object obj) =>
50 obj is Policy objPolicy && Equals(objPolicy);
51
54 // ReSharper disable NonReadonlyMemberInGetHashCode
55 public override int GetHashCode()
56 {
57 // Note that we intentionally use a hashing method that is order independent
58 // for each individual collection - but order dependent across both.
59 unchecked
60 {
61 // Bitwise Exclusive Or (^) of all elements ensures the hash is order-independent
62 return 23 *
63 transform_records.Aggregate(17, (hash, item) => hash ^ (int)item) +
64 forward_records.Aggregate(17, (hash, item) => hash ^ (int)item);
65 }
66 }
67 #endregion Equality Overrides
68 }
69}
Base class used by all types and resources.
Definition APIType.cs:8
Layer Policy is the rule on RecordType that determines how occurrences belonging to a particular Reco...
Definition Policy.cs:17
bool Equals(Policy other)
Determine if this Policy is equivalent to another.
override int GetHashCode()
Get the HashCode for this Policy.
Definition Policy.cs:55
HashSet< RecordType > transform_records
When a record type is listed under transform, all input occurrences with the matching record type are...
Definition Policy.cs:22
HashSet< RecordType > forward_records
When a record type is listed under forward, all input occurrences with the matching record type are n...
Definition Policy.cs:29
override bool Equals(object obj)
Determine if this Policy is equivalent to another.