コード例 #1
0
        /// <summary>
        ///     Create a Threat List Update Result.
        /// </summary>
        /// <param name="builder">
        ///     A <see cref="ThreatListUpdateResultBuilder" /> to initialize the threat list update result with.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="builder" /> is a null reference.
        /// </exception>
        internal ThreatListUpdateResult(ThreatListUpdateResultBuilder builder)
        {
            Guard.ThrowIf(nameof(builder), builder).Null();
            Guard.ThrowIf(nameof(builder), builder.RetrievedThreatListChecksum).Null();
            Guard.ThrowIf(nameof(builder), builder.Query).Null();
            Guard.ThrowIf(nameof(builder), builder.RetrievedThreatList).Null();

            this.Query = builder.Query;
            this.RetrievedThreatList         = builder.RetrievedThreatList;
            this.RetrievedThreatListChecksum = builder.RetrievedThreatListChecksum;
            this.ThreatsToAdd = builder.ThreatsToAdd;
            this.UpdateType   = builder.UpdateType;
            // ...
            //
            // ...
            this._threatsToRemove = CreateThreatsToRemove(this, builder);

            // <summary>
            //      Create Threats to Remove.
            // </summary>
            IReadOnlyCollection <int> CreateThreatsToRemove(ThreatListUpdateResult @this, ThreatListUpdateResultBuilder cBuilder)
            {
                IReadOnlyCollection <int> cThreatsToRemove = Array.Empty <int>();

                if (@this.IsPartialUpdate)
                {
                    cThreatsToRemove = cBuilder.ThreatsToRemove;
                }

                return(cThreatsToRemove);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Build a Threat List Update Result.
        /// </summary>
        /// <returns>
        ///     A <see cref="ThreatListUpdateResult" />.
        /// </returns>
        public ThreatListUpdateResult Build()
        {
            // ...
            //
            // Throws an exception if the operation fails.
            var threatListUpdateResult = new ThreatListUpdateResult(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.Query = null;
            this.RetrievedThreatList         = null;
            this.RetrievedThreatListChecksum = null;
            this.ThreatsToAdd    = new List <string>();
            this.ThreatsToRemove = new List <int>();
            this.UpdateType      = default;

            return(threatListUpdateResult);
        }
コード例 #3
0
 /// <summary>
 ///     Set Update Type.
 /// </summary>
 /// <param name="value">
 ///     An <see cref="ThreatListUpdateType" /> indicating how the retrieved <see cref="ThreatList" /> was
 ///     retrieved.
 /// </param>
 /// <returns>
 ///     This threat list update result builder.
 /// </returns>
 public ThreatListUpdateResultBuilder SetUpdateType(ThreatListUpdateType value)
 {
     this.UpdateType = value;
     return(this);
 }