Example #1
0
        protected void Check(Identifiable other)
        {
            Guard.AssertNotNull(other, nameof(other));

            if (SchemeVersion != other.SchemeVersion)
            {
                throw new PolymorphicPseudonymisationException($"Scheme version {SchemeVersion} is not equal to {other.SchemeVersion}");
            }

            if (SchemeKeyVersion != other.SchemeKeyVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Scheme key version {SchemeKeyVersion} is not equal to {other.SchemeKeyVersion}");
            }

            if (!Recipient.Equals(other.Recipient, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new PolymorphicPseudonymisationException($"Recipient '{Recipient}' is not equal to '{other.Recipient}'");
            }

            if ((ShouldCheckSetVersion || other.ShouldCheckSetVersion) && RecipientKeySetVersion != other.RecipientKeySetVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Recipient key set version {RecipientKeySetVersion} does not match key {other.RecipientKeySetVersion}");
            }
        }
        private static void Check(Identifiable a, Identifiable b, bool includeKeySetVersion)
        {
            if (a.SchemeVersion != b.SchemeVersion)
            {
                throw new PolymorphicPseudonymisationException($"Scheme version {a.SchemeVersion} is not equal to {b.SchemeVersion}");
            }

            if (a.SchemeKeyVersion != b.SchemeKeyVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Scheme key version {a.SchemeKeyVersion} is not equal to {a.SchemeKeyVersion}");
            }

            if (!a.Recipient.Equals(b.Recipient))
            {
                throw new PolymorphicPseudonymisationException($"Recipient '{a.Recipient}' is not equal to '{b.Recipient}'");
            }

            if (includeKeySetVersion && a.RecipientKeySetVersion != b.RecipientKeySetVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Recipient key set version {a.RecipientKeySetVersion} does not match key {b.RecipientKeySetVersion}");
            }
        }
        protected void Check(Identifiable other)
        {
            if (SchemeVersion != other.SchemeVersion)
            {
                throw new PolymorphicPseudonymisationException($"Scheme version {SchemeVersion} is not equal to {other.SchemeVersion}");
            }

            if (SchemeKeyVersion != other.SchemeKeyVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Scheme key version {SchemeKeyVersion} is not equal to {other.SchemeKeyVersion}");
            }

            if (!Recipient.Equals(other.Recipient))
            {
                throw new PolymorphicPseudonymisationException($"Recipient '{Recipient}' is not equal to '{other.Recipient}'");
            }

            if ((ShouldCheckSetVersion || other.ShouldCheckSetVersion) && RecipientKeySetVersion != other.RecipientKeySetVersion)
            {
                throw new PolymorphicPseudonymisationException(
                          $"Recipient key set version {RecipientKeySetVersion} does not match key {other.RecipientKeySetVersion}");
            }
        }
 protected void Check(Identifiable other, bool includeKeySetVersion)
 {
     Check(this, other, includeKeySetVersion);
 }