示例#1
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="sets">Sets used by k-set algorithm.</param>
        /// <param name="chooseSet">This function have to choose a proper set from the sets
        /// based on passed <see cref="NuntiusMessage"/>.</param>
        /// <param name="options">Configuration regarding checking of tasks returned by <see cref="EventSourceBase.Send"/> event
        /// handlers.</param>
        public KAnonymityFilter(IKAnonymitySet[] sets, Func<NuntiusMessage, int> chooseSet,
            EventSourceCallbackMonitoringOptions options) : base(options)
        {
            if (sets == null || sets.Length == 0) throw new ArgumentException($"Parameter {nameof(sets)} must be array of length at least 1.");
            foreach (var set in sets)
            {
                if (set == null) throw new ArgumentNullException($"One set from {nameof(sets)} was null.");
                if (_sets.ContainsKey(set.Id)) throw new ArgumentException($"There was a set with the same id {set.Id} as a different set.");
                _sets.Add(set.Id, set);
            }

            if (chooseSet == null) throw new ArgumentNullException($"{nameof(chooseSet)} function was null.");
            _chooseSet = chooseSet;
        }
示例#2
0
 /// <summary>
 /// Creates a new instance which does not check its listeners task exceptions.
 /// </summary>
 /// <param name="sets">Sets used by k-set algorithm.</param>
 /// <param name="chooseSet">This function have to choose a proper set from the sets
 /// based on passed <see cref="NuntiusMessage"/>.</param>
 public KAnonymityFilter(IKAnonymitySet[] sets, Func<NuntiusMessage, int> chooseSet)
     : this(sets, chooseSet, EventSourceCallbackMonitoringOptions.NotCheckTaskException)
 { }