</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.IO.FileSystem" />
- <Reference Include="System.Linq" />
<Reference Include="System.Threading.Thread" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsLinux)' == 'true'">
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Linq;
-using System.Threading.Tasks;
-
namespace System.Net.NetworkInformation
{
internal class BsdIPGlobalProperties : UnixIPGlobalProperties
public override IPEndPoint[] GetActiveTcpListeners()
{
TcpConnectionInformation[] allConnections = GetTcpConnections(listeners:true);
- return allConnections.Select(tci => tci.LocalEndPoint).ToArray();
+ var endPoints = new IPEndPoint[allConnections.Length];
+ for (int i = 0; i < allConnections.Length; i++)
+ {
+ endPoints[i] = allConnections[i].LocalEndPoint;
+ }
+ return endPoints;
}
public unsafe override IPEndPoint[] GetActiveUdpListeners()
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
namespace System.Net.NetworkInformation
{
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Linq;
namespace System.Net.NetworkInformation
{
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Linq;
namespace System.Net.NetworkInformation
{
}
else if (result == 0)
{
- return interfacesByName.Values.ToArray();
+ var results = new BsdNetworkInterface[interfacesByName.Count];
+ int i = 0;
+ foreach (KeyValuePair<string, BsdNetworkInterface> item in interfacesByName)
+ {
+ results[i++] = item.Value;
+ }
+ return results;
}
else
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-
namespace System.Net.NetworkInformation
{
internal class LinuxIPGlobalProperties : UnixIPGlobalProperties
using System.Collections.Generic;
using System.IO;
-using System.Linq;
namespace System.Net.NetworkInformation
{
}
else if (result == 0)
{
- return interfacesByName.Values.ToArray();
+ var results = new LinuxNetworkInterface[interfacesByName.Count];
+ int i = 0;
+ foreach (KeyValuePair<string, LinuxNetworkInterface> item in interfacesByName)
+ {
+ results[i++] = item.Value;
+ }
+ return results;
}
else
{
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Net.Sockets;
namespace System.Net.NetworkInformation
private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni)
{
var collection = new UnicastIPAddressInformationCollection();
- foreach (IPAddress address in uni.Addresses.Where((addr) => !IPAddressUtil.IsMulticast(addr)))
+ foreach (IPAddress address in uni.Addresses)
{
- IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork)
- ? uni.GetNetMaskForIPv4Address(address)
- : IPAddress.Any; // Windows compatibility
- collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask));
+ if (!IPAddressUtil.IsMulticast(address))
+ {
+ IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork)
+ ? uni.GetNetMaskForIPv4Address(address)
+ : IPAddress.Any; // Windows compatibility
+ collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask));
+ }
}
return collection;
private static MulticastIPAddressInformationCollection GetMulticastAddresses(UnixNetworkInterface uni)
{
var collection = new MulticastIPAddressInformationCollection();
- foreach (IPAddress address in uni.Addresses.Where(IPAddressUtil.IsMulticast))
+ foreach (IPAddress address in uni.Addresses)
{
- collection.InternalAdd(new UnixMulticastIPAddressInformation(address));
+ if (IPAddressUtil.IsMulticast(address))
+ {
+ collection.InternalAdd(new UnixMulticastIPAddressInformation(address));
+ }
}
return collection;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
namespace System.Net.NetworkInformation
{
public override bool Supports(NetworkInterfaceComponent networkInterfaceComponent)
{
- Sockets.AddressFamily family =
- (networkInterfaceComponent == NetworkInterfaceComponent.IPv4)
- ? Sockets.AddressFamily.InterNetwork
- : Sockets.AddressFamily.InterNetworkV6;
+ Sockets.AddressFamily family = (networkInterfaceComponent == NetworkInterfaceComponent.IPv4) ?
+ Sockets.AddressFamily.InterNetwork :
+ Sockets.AddressFamily.InterNetworkV6;
- return _addresses.Any(addr => addr.AddressFamily == family);
+ foreach (IPAddress addr in _addresses)
+ {
+ if (addr.AddressFamily == family)
+ {
+ return true;
+ }
+ }
+
+ return false;
}
/// <summary>