Exemple #1
0
 public void LocateConstructor(IConstructor cp)
 {
     for (int i = 0; i < treeViewConstructors.Nodes.Count; i++)
     {
         TreeNodeConstructor tn = treeViewConstructors.Nodes[i] as TreeNodeConstructor;
         if (tn != null)
         {
             ConstructorPointer cp0 = tn.OwnerPointer as ConstructorPointer;
             if (cp0.IsSameMethod((IMethod)cp))
             {
                 cp0.CopyFrom(cp);
                 treeViewConstructors.SelectedNode = tn;
                 break;
             }
         }
         else
         {
             TreeNodeCustomConstructorPointer tn2 = treeViewConstructors.Nodes[i] as TreeNodeCustomConstructorPointer;
             if (tn2 != null)
             {
                 CustomConstructorPointer cp2 = tn2.OwnerPointer as CustomConstructorPointer;
                 if (cp2.IsSameMethod((IMethod)cp))
                 {
                     treeViewConstructors.SelectedNode = tn2;
                     break;
                 }
             }
         }
     }
 }
Exemple #2
0
        public bool LoadData(LocalVariable lv)
        {
            ConstructorInfo[] cifs;
            Type t = lv.BaseClassType;

            if (t.IsEnum)
            {
                cifs = null;
            }
            else
            {
                try
                {
                    Type tCo = VPLUtil.GetCoClassType(t);
                    if (tCo != null)
                    {
                        cifs = tCo.GetConstructors();
                    }
                    else
                    {
                        cifs = t.GetConstructors();
                    }
                }
                catch
                {
                    cifs = null;
                }
            }
            if (cifs != null && cifs.Length > 0)
            {
                Text = string.Format(Resources.TitleSelectConstructor, t.Name);
                List <TreeNodeConstructor> list = new List <TreeNodeConstructor>();
                for (int i = 0; i < cifs.Length; i++)
                {
                    TreeNodeConstructor tn = new TreeNodeConstructor(new ConstructorPointer(cifs[i], lv));
                    list.Add(tn);
                }
                if (!t.IsValueType)
                {
                    treeViewConstructors.Nodes.Add(new TreeNodeConstructor(new ConstructorPointerNull(lv)));
                }
                IOrderedEnumerable <TreeNodeConstructor> sorted = list.OrderBy <TreeNodeConstructor, string>(r => r.Text);
                foreach (TreeNodeConstructor nc in sorted)
                {
                    treeViewConstructors.Nodes.Add(nc);
                }
                if (lv.VariableCustomType != null)
                {
                    List <ConstructorClass> clst = lv.VariableCustomType.GetCustomConstructors();
                    if (clst != null && clst.Count > 0)
                    {
                        foreach (ConstructorClass cc in clst)
                        {
                            TreeNodeCustomConstructorPointer tnc = new TreeNodeCustomConstructorPointer(new CustomConstructorPointer(cc, lv.RootPointer));
                            treeViewConstructors.Nodes.Add(tnc);
                        }
                    }
                }
                return(true);
            }
            return(false);
        }