IndexOfKey() public méthode

public IndexOfKey ( string key ) : int
key string
Résultat int
Exemple #1
0
 private TreeNode GetOrAdd(TreeNodeCollection aNodes, string aValue)
 {
     int idx = aNodes.IndexOfKey(aValue);
     if (idx >= 0)
     {
         return aNodes[idx];
     }
     else
     {
         TreeNode node =  aNodes.Add(aValue, aValue);
         node.ExpandAll();
         return node;
     }
 }
 private void CreateNodes(TreeNodeCollection treeNodeCollection, string[] parts, int index, ref string parent)
 {
     if (!treeNodeCollection.ContainsKey(parts[index]))
     {
         string extension = Path.GetExtension(parts[index]);
         ResourceTreeNode node;
         switch (extension)
         {
             case "":
                 node = new FolderTreeNode();
                 node.Text = Path.ChangeExtension(parts[index], null);
                 node.Name = parts[index];
                 string path = string.Empty;
                 for (int i = 0; i <= index; i++)
                     path = Path.Combine(path, parts[i]);
                 node.Path = Path.Combine(parent, path);
                 treeNodeCollection.Add(node);
                 break;
             case Sunfish.Tag.Path.Extension:
                 node = new ClassTreeNode();
                 node.Text = Path.ChangeExtension(parts[index], null);
                 node.Name = parts[index];
                 path = string.Empty;
                 foreach (string s in parts)
                     path = Path.Combine(path, s);
                 node.Path = Path.Combine(parent, path);
                 treeNodeCollection.Add(node);
                 break;
         }
     }
     if (parts.Length > index + 1)
         CreateNodes(treeNodeCollection[treeNodeCollection.IndexOfKey(parts[index])].Nodes, parts, index + 1, ref parent);
 }