Skip to content

Commit 48380c6

Browse files
rankobpBranko Pejić
andauthored
Add AddRange to SourceCollection (#240)
Co-authored-by: Branko Pejić <[email protected]>
1 parent 45ae5d5 commit 48380c6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/NetEscapades.AspNetCore.SecurityHeaders/Headers/SourceCollection.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ public void Add(string source)
2929
}
3030
}
3131

32+
/// <summary>
33+
/// Adds a source to the collection for the given directive.
34+
/// Calls to <see cref="AddRange"/> are idempotent;
35+
/// if the source has already been added, it will not be added again.
36+
/// </summary>
37+
/// <param name="sources">The sources to add</param>
38+
public void AddRange(IEnumerable<string> sources)
39+
{
40+
foreach (var source in sources)
41+
{
42+
Add(source);
43+
}
44+
}
45+
3246
/// <summary>
3347
/// Removes a source from the collection for the given directive.
3448
/// Returns true if the source was removed. Returns false if the

test/NetEscapades.AspNetCore.SecurityHeaders.Test/PublicApiTest.PublicApiHasNotChanged.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ namespace NetEscapades.AspNetCore.SecurityHeaders.Headers
599599
public SourceCollection() { }
600600
public int Count { get; }
601601
public void Add(string source) { }
602+
public void AddRange(System.Collections.Generic.IEnumerable<string> sources) { }
602603
public System.Collections.Generic.IEnumerator<string> GetEnumerator() { }
603604
public bool Remove(string source) { }
604605
}

0 commit comments

Comments
 (0)