예제 #1
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);
        }