public class AStreamManager
{
public IVehicle Vehicle { get; set; }
public string AIp { get; set; }
public int APort { get; set; }
public delegate NetworkStream ConnectToAStream(string host, int port);
public AStreamManager(IVehicle vehicle, string IP, int Port)
{
Vehicle = vehicle;
AIp = IP;
APort = Port;
}
public NetworkStream ConnectToVehicleAStream(ConnectToAStream conn)
{
return conn(AIp, APort); ;
}
}
public class BStreamManager
{
public IVehicle Vehicle { get; set; }
public string BIp { get; set; }
public int BPort { get; set; }
public delegate NetworkStream ConnectToBStream(string host, int port);
public BStreamManager(IVehicle vehicle, string IP, int Port)
{
Vehicle = vehicle;
BIp = IP;
BPort = Port;
}
public NetworkStream ConnectToVehicleBStream(ConnectToBStream conn)
{
return conn(BIp, BPort); ;
}
}
I have two classes AStreamManager
and BStreamManager
. As you can see above,there is a member variable Vehicle
of type IVehicle
which is common across these classes.
Does it make sense and can I refactor in such a way that 'IVehicle Vehicle` is moved to a base class?