I have searched the web for examples of inheriting System.Net.NetworkInformation.NetworkInterface but I cannot see any elegant solutions to this. It appears that the static method NetworkInterface.GetAllNetworkInterfaces() returns an internal implementation called SystemNetworkInterface.
Basically I want to inherit this into a class called ManagedNetworkInterface and add some additional functionality to it. Can anyone think of an elegant solution of how to do this? I have tried, but every time, something stops me dead in my tracks!
EDIT 1:
Is it acceptable to provide the implementation by casting the implementation back to NetworkInterface and then to ManagedNetworkInterface?
…this example seems messy!
ManagedNetworkInterface mni = (ManagedNetworkInterface)(NetworkInterface)NetworkInterface.GetAllNetworkInterfaces()[0];
EDIT 2:
I have also thought of using a composition-like model…
public class ManagedNetworkInterface : NetworkInterface
{
private NetworkInterface ni;
public override string Description
{
get { return ni.Description; }
}
//ect...
}
Is this a good or bad idea?
Issue resolved. I have used composition to inherit and implement abstract class
NetworkInterfaceCode
The new class now includes several mechanisms for creating instances of ManagedNetworkInterface using things like IP Address, Physical Address, ID, Name etc.