Ejemplo n.º 1
0
        void InitChildren()
        {
            _children = new ObservableCollection <TypeNodeClass>();

            if (!(this.Value is PropertyInfo))
            {
                return;
            }

            PropertyInfo p = this.Value as PropertyInfo;

            foreach (var item in p.PropertyType.GetProperties())
            {
                if (p.PropertyType.IsEnumerableType())
                {
                    continue;
                }

                TypeNodeClass t = new TypeNodeClass();
                t.IsChecked = false;
                t.FullPath  = this.FullPath + "." + item.Name;
                t.Value     = item;
                this._children.Add(t);

                //if (p.PropertyType.IsPrimitive || p.PropertyType == typeof(string)) continue;
            }
        }
Ejemplo n.º 2
0
        /// <summary> 创建树形基础节点 </summary>
        public static TypeNodeClass CreateTypeNode(Type t, string baseName)
        {
            TypeNodeClass node = new TypeNodeClass();

            node.Value    = t;
            node.FullPath = baseName;
            node.Init();

            return(node);
        }
Ejemplo n.º 3
0
        void RefreshValue()
        {
            if (this.DllPath == null)
            {
                return;
            }

            if (!File.Exists(this.DllPath))
            {
                return;
            }

            this.Collection.Clear();

            //  Message:刷新pdb路径
            string pdb = Path.Combine(Path.GetDirectoryName(this.DllPath), Path.GetFileNameWithoutExtension(this.DllPath) + ".XML");

            if (File.Exists(pdb))
            {
                this.PdbPath = pdb;
            }
            else
            {
                this.PdbPath = string.Empty;
            }

            //  Message:获取所有类型

            byte[] fileData = File.ReadAllBytes(this.DllPath);

            var ass = Assembly.Load(fileData);

            var types = ass.GetTypes();

            foreach (var item in ass.GetTypes().OrderBy(l => l.Name))
            {
                if (item.MemberType == MemberTypes.NestedType)
                {
                    continue;
                }

                TypeNodeClass t = TypeNodeClass.CreateTypeNode(item, item.Name.ToLower());

                this.Collection.Add(t);
            }
        }
Ejemplo n.º 4
0
        void Init()
        {
            Type type = this.Value as Type;

            foreach (var p in type.GetProperties())
            {
                TypeNodeClass t = new TypeNodeClass();
                t.IsChecked = false;
                t.FullPath  = this.FullPath + "." + p.Name;
                t.Value     = p;
                this._children.Add(t);

                if (p.PropertyType.IsPrimitive || p.PropertyType == typeof(string) || p.PropertyType.IsEnumerableType())
                {
                    continue;
                }

                t.InitChildren();
            }
        }
        void RefreshRightValue()
        {
            if (this.RightPath == null)
            {
                return;
            }

            this.RightCollection.Clear();

            //  Message:获取所有类型

            if (!File.Exists(this.RightPath))
            {
                return;
            }


            var ass = Assembly.LoadFrom(this.RightPath);

            var types = ass.GetTypes();

            foreach (var item in ass.GetTypes().OrderBy(l => l.Name))
            {
                if (item.MemberType == MemberTypes.NestedType)
                {
                    continue;
                }

                //TypeNodeClass t = new TypeNodeClass();

                //t.FullPath += item.Name.ToLower();

                //t.Value = item;


                TypeNodeClass t = TypeNodeClass.CreateTypeNode(item, item.Name.ToLower());

                this.RightCollection.Add(t);
            }
        }