internal static string GetStatisticsFilePath(StatistiscType type) { string path = GetRootPath(); switch (type) { case StatistiscType.TCP: return(Path.Combine(path, Properties.Resources.TCPStatFileName)); case StatistiscType.IP: return(Path.Combine(path, Properties.Resources.IPStatFileName)); case StatistiscType.ICMP: return(Path.Combine(path, Properties.Resources.ICMPStatFileName)); case StatistiscType.UDP: return(Path.Combine(path, Properties.Resources.UDPStatFileName)); case StatistiscType.IPInterface: return(Path.Combine(path, Properties.Resources.IPInterfaceStatFileName)); default: return(Path.Combine(path, Properties.Resources.propertiesFileName)); } }
internal static List <string> GetStatistics(StatistiscType type) { object stat = null; PropertyInfo[] properties = null; IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); List <string> result = new List <string>(); switch (type) { case StatistiscType.TCP: stat = ipProperties.GetTcpIPv4Statistics(); properties = typeof(TcpStatistics).GetProperties(); break; case StatistiscType.IP: stat = ipProperties.GetIPv4GlobalStatistics(); properties = typeof(IPGlobalStatistics).GetProperties(); break; case StatistiscType.ICMP: stat = ipProperties.GetIcmpV4Statistics(); properties = typeof(IcmpV4Statistics).GetProperties(); break; case StatistiscType.UDP: stat = ipProperties.GetUdpIPv4Statistics(); properties = typeof(UdpStatistics).GetProperties(); break; default: return(GetPropertyNames()); } string temp = $"{DateTime.Now.ToString("d/M/yyyy-hh:mm:ss:FFF")};"; foreach (var property in properties) { temp += $"{property.GetValue(stat)};"; } result.Add(temp); return(result); }