Exemplo n.º 1
0
        /// <summary>
        /// Performs validation of the <paramref name="rules"/>.
        /// </summary>
        /// <param name="rules"> The set of retention rules to validate. </param>
        public void Validate([NotNull, ItemNotNull] IReadOnlyCollection <RetentionRule> rules)
        {
            AssertArg.NotNullOrEmpty(rules, nameof(rules));
            AssertArg.NoNullItems(rules, nameof(rules));

            AssertNoDuplicates(rules);

            AssertNoContradictions(rules);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RetentionPolicy" /> class.
        /// </summary>
        /// <param name="rules">
        /// The collection of rules that define the policy.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="rules"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Any item in the <paramref name="rules"/> is <see langword="null"/> or
        /// <paramref name="rules"/> is empty or
        /// <paramref name="rules"/> contains duplicate or mutually contradictory items.
        /// </exception>
        public RetentionPolicy([NotNull, ItemNotNull] IReadOnlyCollection <RetentionRule> rules)
        {
            AssertArg.NotNullOrEmpty(rules, nameof(rules));
            AssertArg.NoNullItems(rules, nameof(rules));

            Validator.Validate(rules);

            _orderedRules = rules
                            .OrderBy(r => r.OlderThan)
                            .ToReadOnlyList();
        }