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; } }
/// <summary> 创建树形基础节点 </summary> public static TypeNodeClass CreateTypeNode(Type t, string baseName) { TypeNodeClass node = new TypeNodeClass(); node.Value = t; node.FullPath = baseName; node.Init(); return(node); }
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); } }
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); } }