7 instantiations of IPNetwork
Microsoft.AspNetCore.HttpOverrides (4)
DualIPNetworkList.cs (4)
27
var loopback = new
IPNetwork
(IPAddress.Loopback, 8);
54
_system[index] = new
IPNetwork
(value.Prefix, value.PrefixLength);
67
_system.Add(new
IPNetwork
(item.Prefix, item.PrefixLength));
105
_system.Insert(index, new
IPNetwork
(item.Prefix, item.PrefixLength));
Microsoft.AspNetCore.HttpOverrides.Tests (1)
ForwardedHeadersMiddlewareTest.cs (1)
1206
options.KnownIPNetworks.Add(new System.Net.
IPNetwork
(networkIp, prefixLength));
System.Net.Primitives (2)
System\Net\IPNetwork.cs (2)
192
result = new
IPNetwork
(address, prefixLength);
220
result = new
IPNetwork
(address, prefixLength);
98 references to IPNetwork
Microsoft.AspNetCore.HttpOverrides (30)
DualIPNetworkList.cs (26)
8
using IPNetwork = System.Net.
IPNetwork
;
13
/// Internal list implementation that keeps <see cref="System.Net.
IPNetwork
"/> and the obsolete
17
internal sealed class DualIPNetworkList : IList<
IPNetwork
>, IList<AspNetIPNetwork>
21
private readonly List<
IPNetwork
> _system = new();
27
var
loopback = new IPNetwork(IPAddress.Loopback, 8);
32
int ICollection<
IPNetwork
>.Count => _system.Count;
35
bool ICollection<
IPNetwork
>.IsReadOnly => false;
38
IPNetwork
IList<
IPNetwork
>.this[int index]
58
void ICollection<
IPNetwork
>.Add(
IPNetwork
item)
76
void ICollection<
IPNetwork
>.Clear() => Clear();
79
bool ICollection<
IPNetwork
>.Contains(
IPNetwork
item) => _system.Contains(item);
82
public void CopyTo(
IPNetwork
[] array, int arrayIndex) => _system.CopyTo(array, arrayIndex);
85
void ICollection<
IPNetwork
>.CopyTo(
IPNetwork
[] array, int arrayIndex) => CopyTo(array, arrayIndex);
90
IEnumerator<
IPNetwork
> IEnumerable<
IPNetwork
>.GetEnumerator() => _system.GetEnumerator();
93
int IList<
IPNetwork
>.IndexOf(
IPNetwork
item) => _system.IndexOf(item);
96
void IList<
IPNetwork
>.Insert(int index,
IPNetwork
item)
108
bool ICollection<
IPNetwork
>.Remove(
IPNetwork
item)
136
void IList<
IPNetwork
>.RemoveAt(int index) => RemoveAt(index);
ForwardedHeadersMiddleware.cs (1)
402
foreach (
var
network in _options.KnownIPNetworks)
ForwardedHeadersOptions.cs (2)
7
using IPNetwork = System.Net.
IPNetwork
;
99
public IList<
IPNetwork
> KnownIPNetworks => _knownNetworks;
IPNetwork.cs (1)
12
/// Please use <see cref="System.Net.
IPNetwork
"/> instead
Microsoft.AspNetCore.HttpOverrides.Tests (13)
DualIPNetworkListTests.cs (13)
31
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
55
options.KnownIPNetworks[0] = System.Net.
IPNetwork
.Parse("172.16.0.0/12");
87
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
88
var
first = options.KnownIPNetworks[0];
104
var
loopback = options.KnownIPNetworks[0];
115
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
116
var arr = new System.Net.
IPNetwork
[5];
142
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
143
Assert.Equal(1, options.KnownIPNetworks.IndexOf(System.Net.
IPNetwork
.Parse("10.0.0.0/8")));
165
options.KnownIPNetworks.Insert(0, System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
186
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
210
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
242
options.KnownIPNetworks.Add(System.Net.
IPNetwork
.Parse("10.0.0.0/8"));
System.Net.Primitives (55)
System\Net\IPNetwork.cs (55)
22
public readonly struct IPNetwork : IEquatable<
IPNetwork
>, ISpanFormattable, ISpanParsable<
IPNetwork
>, IUtf8SpanFormattable, IUtf8SpanParsable<
IPNetwork
>
37
/// Initializes a new instance of the <see cref="
IPNetwork
"/> class with the specified <see cref="IPAddress"/> and prefix length.
112
/// Converts a CIDR <see cref="string"/> to an <see cref="
IPNetwork
"/> instance.
115
/// <returns>An <see cref="
IPNetwork
"/> instance.</returns>
118
public static
IPNetwork
Parse(string s)
125
/// Converts a CIDR character span to an <see cref="
IPNetwork
"/> instance.
128
/// <returns>An <see cref="
IPNetwork
"/> instance.</returns>
130
public static
IPNetwork
Parse(ReadOnlySpan<char> s)
132
if (!TryParse(s, out
IPNetwork
result))
141
/// Converts a UTF-8 CIDR character span to an <see cref="
IPNetwork
"/> instance.
144
/// <returns>An <see cref="
IPNetwork
"/> instance.</returns>
146
public static
IPNetwork
Parse(ReadOnlySpan<byte> utf8Text)
148
if (!TryParse(utf8Text, out
IPNetwork
result))
157
/// Converts the specified CIDR string to an <see cref="
IPNetwork
"/> instance and returns a value indicating whether the conversion succeeded.
160
/// <param name="result">When the method returns, contains an <see cref="
IPNetwork
"/> instance if the conversion succeeds.</param>
162
public static bool TryParse(string? s, out
IPNetwork
result)
174
/// Converts the specified CIDR character span to an <see cref="
IPNetwork
"/> instance and returns a value indicating whether the conversion succeeded.
177
/// <param name="result">When the method returns, contains an <see cref="
IPNetwork
"/> instance if the conversion succeeds.</param>
179
public static bool TryParse(ReadOnlySpan<char> s, out
IPNetwork
result)
202
/// Converts the specified UTF-8 CIDR character span to an <see cref="
IPNetwork
"/> instance and returns a value indicating whether the conversion succeeded.
205
/// <param name="result">When the method returns, contains an <see cref="
IPNetwork
"/> instance if the conversion succeeds.</param>
207
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out
IPNetwork
result)
280
/// Converts the instance to a string containing the <see cref="
IPNetwork
"/>'s CIDR notation.
282
/// <returns>The <see cref="string"/> containing the <see cref="
IPNetwork
"/>'s CIDR notation.</returns>
287
/// Attempts to write the <see cref="
IPNetwork
"/>'s CIDR notation to the given <paramref name="destination"/> span and returns a value indicating whether the operation succeeded.
296
/// Attempts to write the <see cref="
IPNetwork
"/>'s CIDR notation to the given <paramref name="utf8Destination"/> UTF-8 span and returns a value indicating whether the operation succeeded.
305
/// Determines whether two <see cref="
IPNetwork
"/> instances are equal.
307
/// <param name="other">The <see cref="
IPNetwork
"/> instance to compare to this instance.</param>
309
/// <exception cref="InvalidOperationException">Uninitialized <see cref="
IPNetwork
"/> instance.</exception>
310
public bool Equals(
IPNetwork
other) =>
315
/// Determines whether two <see cref="
IPNetwork
"/> instances are equal.
317
/// <param name="obj">The <see cref="
IPNetwork
"/> instance to compare to this instance.</param>
318
/// <returns><see langword="true"/> if <paramref name="obj"/> is an <see cref="
IPNetwork
"/> instance and the networks are equal; otherwise <see langword="false"/>.</returns>
319
/// <exception cref="InvalidOperationException">Uninitialized <see cref="
IPNetwork
"/> instance.</exception>
321
obj is
IPNetwork
other &&
325
/// Determines whether the specified instances of <see cref="
IPNetwork
"/> are equal.
330
public static bool operator ==(
IPNetwork
left,
IPNetwork
right) => left.Equals(right);
333
/// Determines whether the specified instances of <see cref="
IPNetwork
"/> are not equal.
338
public static bool operator !=(
IPNetwork
left,
IPNetwork
right) => !(left == right);
360
static
IPNetwork
IParsable<
IPNetwork
>.Parse([NotNull] string s, IFormatProvider? provider) => Parse(s);
363
static bool IParsable<
IPNetwork
>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out
IPNetwork
result) => TryParse(s, out result);
366
static
IPNetwork
ISpanParsable<
IPNetwork
>.Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s);
369
static
IPNetwork
IUtf8SpanParsable<
IPNetwork
>.Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text);
372
static bool ISpanParsable<
IPNetwork
>.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out
IPNetwork
result) => TryParse(s, out result);
375
static bool IUtf8SpanParsable<
IPNetwork
>.TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out
IPNetwork
result) => TryParse(utf8Text, out result);