当前位置: 首页>>代码示例>>C#>>正文


C# Main.Autostart方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:xmarwin,项目名称:MwPinger,代码行数:101,代码来源:MainForm.cs


注:本文中的Main.Autostart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。