/// <summary> /// Add a Result. /// </summary> /// <param name="value"> /// A <see cref="ThreatListUpdateResult" /> indicating a retrieved <see cref="ThreatList" /> and the /// threats associated with it that should be added to and removed from the locally stored copy of the /// threat list. /// </param> /// <returns> /// This threat list update response builder. /// </returns> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="value" /> is a null reference. /// </exception> internal ThreatListUpdateResponseBuilder AddResult(ThreatListUpdateResult value) { Guard.ThrowIf(nameof(value), value).Null(); this.Results.Add(value); return(this); }
/// <summary> /// Add a Result. /// </summary> /// <param name="valueAction"> /// An action to create a <see cref="ThreatListUpdateResult" /> indicating a retrieved /// <see cref="ThreatList" /> and the threats associated with it that should be added to and removed from /// the locally stored copy of the threat list. /// </param> /// <returns> /// This threat list update response builder. /// </returns> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="valueAction" /> is a null reference. /// </exception> public ThreatListUpdateResponseBuilder AddResult(Func <ThreatListUpdateResultBuilder, ThreatListUpdateResult> valueAction) { Guard.ThrowIf(nameof(valueAction), valueAction).Null(); // ... // // Throws an exception if the operation fails. var threatListUpdateResultBuilder = ThreatListUpdateResult.Build(); var threatListUpdateResult = valueAction(threatListUpdateResultBuilder); this.AddResult(threatListUpdateResult); return(this); }
/// <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); }