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


C# BlockingCollection.ElementAt方法代码示例

本文整理汇总了C#中BlockingCollection.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# BlockingCollection.ElementAt方法的具体用法?C# BlockingCollection.ElementAt怎么用?C# BlockingCollection.ElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlockingCollection的用法示例。


在下文中一共展示了BlockingCollection.ElementAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: bw_DoWork

        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            treeData = new BlockingCollection<TreeNode>();
            RootNodes.Clear();
            
            int i = -1;
            int j = 0;

            targetDoneCount = Targets.Count();

            foreach (Target myTarget in Targets)
            {

                if (!RootNodes.Contains(myTarget.documentURL))
                {
                    i++;
                    j = 0;

                    TreeNode newNode = new TreeNode();
                    newNode.Name = myTarget.targetId.ToString();

                    Font boldFont = new Font(treeView1.Font, FontStyle.Bold);
                    newNode.NodeFont = boldFont;

                    newNode.Text = myTarget.friendlyName;
                    newNode.Text = newNode.Text;

                    newNode.ToolTipText = "Device Description:\r\n" + myTarget.friendlyName +
                         "\r\nDocument URL:\r\n" + myTarget.documentURL +
                        "\r\nControl URL:\r\n" + myTarget.controlURL + "\r\n";
                    newNode.Tag = myTarget;

                    treeData.Add(newNode);

                    RootNodes.Add(myTarget.documentURL);
                }
                else
                {
                    i = RootNodes.IndexOf(myTarget.documentURL);
                    j = treeData.ElementAt(i).GetNodeCount(false);
                }

                string makeSOAPRequest = "<?xml version=\"1.0\"?>\r\n" +
                                         "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" +
                                         "<s:Body>\r\n" +
                                         "<m:" + myTarget.actionDesc.Name + " xmlns:m=\"" + myTarget.ServiceTypeIdentifier + "\">\r\n";

                string makeSOAPResponse = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
                                          "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" +
                                          "<s:Body>\r\n" +
                                          "<u:" + myTarget.actionDesc.Name + " xmlns:u=\"" + myTarget.ServiceTypeIdentifier + "\">";

                List<String> collectDataType = new List<string>();


                bool alreadyHasAction = false;

                foreach (TreeNode checkNode in treeData.ElementAt(i).Nodes)
                {
                    if (checkNode.Text == myTarget.actionDesc.Name)
                    {
                        alreadyHasAction = true;
                    }
                }

                if (!alreadyHasAction)
                {
                    treeData.ElementAt(i).Nodes.Add(myTarget.targetId.ToString(), myTarget.actionDesc.Name);
                    treeData.ElementAt(i).Nodes[j].Tag = myTarget;

                    foreach (ArgumentDescription nArg in myTarget.actionDesc.Arguments.Values)
                    {
                        if (nArg.Direction == "in")
                        {
                            TreeNode argumentNode = treeData.ElementAt(i).Nodes[j].Nodes.Add(myTarget.targetId.ToString(), String.Format("->{0}", nArg.Name));
                            argumentNode.Tag = myTarget;

                            argumentNode.Nodes.Add(myTarget.targetId.ToString(), String.Format("Data Type: {0}", myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].DataType));
                            if (myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].DefaultValue != "")
                            {
                                argumentNode.Nodes.Add(myTarget.targetId.ToString(), String.Format("Default Value: {0}", myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].DefaultValue));
                            }
                            if (myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedValues.Count > 0)
                            {
                                int av = 1;
                                foreach (string allowedValue in myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedValues)
                                {
                                    argumentNode.Nodes.Add(myTarget.targetId.ToString(), String.Format("Allowed Value {0}: {1}", av.ToString(), allowedValue));
                                    av++;
                                }
                            }
                            if (myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedRange.Minimum != "")
                            {
                                argumentNode.Nodes.Add(myTarget.targetId.ToString(), String.Format("Minimum Value: {0}", myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedRange.Minimum));
                            }
                            if (myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedRange.Maximum != "")
                            {
                                argumentNode.Nodes.Add(myTarget.targetId.ToString(), String.Format("Maximum Value: {0}", myTarget.targetServiceDesc.StateVariables[nArg.RelatedStateVariable].AllowedRange.Maximum));
                            }

//.........这里部分代码省略.........
开发者ID:nccgroup,项目名称:UPnP-Pentest-Toolkit,代码行数:101,代码来源:Form1.cs


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