Beispiel #1
0
            /// <summary>
            ///     Create an Invalid Threat List.
            /// </summary>
            /// <param name="threatListDescriptor">
            ///     A <see cref="ThreatListDescriptor" /> identifying the threat list.
            /// </param>
            /// <returns>
            ///     An invalid threat list.
            /// </returns>
            /// <exception cref="System.ArgumentNullException">
            ///     Thrown if <paramref name="threatListDescriptor" /> is a null reference.
            /// </exception>
            internal static ThreatList CreateInvalidThreatList(ThreatListDescriptor threatListDescriptor)
            {
                Guard.ThrowIf(nameof(threatListDescriptor), threatListDescriptor).Null();

                var threatList = InvalidThreatListCache.Cache.GetOrAdd(threatListDescriptor, tld => {
                    var cThreatList = new ThreatList(tld, InvalidThreatListCache.InvalidThreatListState, DateTime.UtcNow);
                    return(cThreatList);
                });

                return(threatList);
            }
        /// <summary>
        ///     Build a Threat List.
        /// </summary>
        /// <returns>
        ///     A <see cref="ThreatList" />.
        /// </returns>
        public ThreatList Build()
        {
            // ...
            //
            // Throws an exception if the operation fails.
            var threatList = new ThreatList(this);

            // ...
            //
            // Reinitialize the builder's state to prevent it from corrupting the immutable built object's state after
            // its built. If the object holds a reference to the builder's state, any mutation to the builder's state
            // will be reflected in the built object's state.
            this.Descriptor   = null;
            this.RetrieveDate = default;
            this.State        = null;
            this.WaitToDate   = default;

            return(threatList);
        }