本文整理汇总了C#中Main.Autostart方法的典型用法代码示例。如果您正苦于以下问题:C# Main.Autostart方法的具体用法?C# Main.Autostart怎么用?C# Main.Autostart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main.Autostart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm()
{
InitializeComponent();
m = new Main();
settings = new Settings(m);
#region Get Targets
XmlDocument xmlTargets = settings.GetTargets();
foreach (XmlNode node in xmlTargets.SelectNodes("/PingInstanceList/PingInstance"))
{
var target = IPAddress.Parse(node.Attributes["target"].Value);
int interval = int.Parse(node.Attributes["interval"].Value);
int timeout = int.Parse(node.Attributes["timeout"].Value);
int bufferSize = int.Parse(node.Attributes["bufferSize"].Value);
string name = node.Attributes["name"].Value.ToString();
string id = node.Attributes["id"].Value;
bool autostart = node.Attributes["autostart"].Value.Equals("true", StringComparison.InvariantCultureIgnoreCase);
int intId = 0;
if (int.TryParse(id, out intId))
{
if (intId > maxPingInstanceId)
{
maxPingInstanceId = intId;
}
}
else
{
// TODO
}
PingInstance pi = new PingInstance(pingObject)
{
Target = target,
Interval = interval,
Timeout = timeout,
BufferSize = bufferSize,
Name = name,
Id = id,
Autostart = autostart,
Status = PingResultStatus.Idle
};
pi.PingReceived += pi_PingReceived;
pi.Uc = new ucPingInstance(pi);
m.PingInstances.Add(pi);
}
#endregion
#region Get Nodes
var xmlNodes = settings.GetNodes();
foreach (XmlNode node in xmlNodes.SelectNodes("/NodeList/Node"))
{
string id = node.Attributes["id"].Value;
string parentId = node.Attributes["parentNodeId"].Value;
string name = node.Attributes["name"].Value;
int intId = 0;
if (int.TryParse(id, out intId))
{
if (intId > maxNodeId)
{
maxNodeId = intId;
}
}
else
{
// TODO
}
Location l = new Location()
{
Id = id,
ParentId = parentId,
Name = name
};
m.Locations.Add(l);
}
#endregion
#region Get Ping Instance Locations
var xmlPingInstanceLocations = settings.GetPingInstanceLocations();
foreach (XmlNode loc in xmlPingInstanceLocations.SelectNodes("/PingInstanceLocations/PingInstanceLocation"))
{
string nodeId = loc.Attributes["nodeId"].Value;
string pingInstanceId = loc.Attributes["pingInstanceId"].Value;
var node = m.Locations.FirstOrDefault(x => x.Id.Equals(nodeId));
if (node != null)
{
node.PingInstanceIds.Add(pingInstanceId);
//.........这里部分代码省略.........