-1
我構建的應用程序,打開Wireshark服務(Wireshark有幾個服務),以便對Wireshark文件上的不同事情,如編輯,更改格式,統計等... 每個選項通常使用不同的服務,所以我想建立我的班,繼承 我很懷疑,如果我想要做什麼是適當的方式或恰當的方式:繼承設計審查
主類WiresharkServices具有以下成員和方法: 這是所有其他類應該inherite類來自
public class WiresharkProcesses
{
protected string _filePath; //the file path who send to Wiresahrk process
protected string _capinfos;
protected string _dumpcap;
protected string _editcap;
protected string _mergecap;
protected string _rawshark;
protected string _text2pcap;
protected string _tshark;
protected string _wireshark;
public void initializeServices()
{
if (Directory.Exists(@"C:\Program Files (x86)\Wireshark"))
{
_capinfos = @"C:\Program Files (x86)\Wireshark\_capinfos.exe";
_dumpcap = @"C:\Program Files (x86)\Wireshark\_dumpcap.exe";
_editcap = @"C:\Program Files (x86)\Wireshark\editcap.exe";
_mergecap = @"C:\Program Files (x86)\Wireshark\_mergecap.exe";
_rawshark = @"C:\Program Files (x86)\Wireshark\_rawshark.exe";
_text2pcap = @"C:\Program Files (x86)\Wireshark\_text2pcap.exe";
_tshark = @"C:\Program Files (x86)\Wireshark\_tshark.exe";
_wireshark = @"C:\Program Files (x86)\Wireshark\_wireshark.exe";
}
else if (Directory.Exists(@"C:\Program Files\Wireshark"))
{
_capinfos = @"C:\Program File)\Wireshark\_capinfos.exe";
_dumpcap = @"C:\Program Files\Wireshark\_dumpcap.exe";
_editcap = @"C:\Program Files\Wireshark\editcap.exe";
_mergecap = @"C:\Program Files\Wireshark\_mergecap.exe";
_rawshark = @"C:\Program Files\Wireshark\_rawshark.exe";
_text2pcap = @"C:\Program Files\Wireshark\_text2pcap.exe";
_tshark = @"C:\Program Files\Wireshark\_tshark.exe";
_wireshark = @"C:\Program Files\Wireshark\_wireshark.exe";
}
}
}
當應用程序運行我當然檢查機器上安裝了Wireshark的,如果沒有拋出異常,並在Wireshark的存在:
WiresharkServices wservices = new WiresharkServices();
wservices .initializeServices();
,並在每個類它自己的方法。
誰收到的文件路徑子類例如將其轉換爲其他格式Wireshark的:
public class Editcap : WiresharkProcesses
{
private string _newFileName;
public void startProcess(string filePath)
{
FileInfo file = new FileInfo(filePath);
_newFileName = file.FullName.Replace(file.Extension, "_new") + ".pcap";
ProcessStartInfo editcapProcess = new ProcessStartInfo(string.Format("\"{0}\"", _editcap))
{
Arguments = string.Format("{2}{0}{2} -F libpcap {2}{1}{2}", file.FullName, _newFileName, "\""),
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
UseShellExecute = false,
ErrorDialog = false
};
using (Process editcap = Process.Start(editcapProcess))
{
editcap.WaitForExit();
}
}
public string getNewFileName()
{
return _newFileName;
}
}
好的,什麼是你的題? –
據我所知,你的類都沒有擴展其他類,所以你似乎根本沒有使用繼承 –
這是所有其他類應繼承的類,我的問題是如果這是適當的建立它的方法 – user1710944