private void LoadField(TreeNode parentNode, FieldInfo fd) { TreeNode tr; if (fd.IsLiteral) { tr = new FieldTreeNode(fd, Access.Public, true); parentNode.Nodes.Add(tr); } else if (fd.IsPublic) { tr = new FieldTreeNode(fd, Access.Public, false); parentNode.Nodes.Add(tr); } else if (fd.IsPrivate) { tr = new FieldTreeNode(fd, Access.Private, false); parentNode.Nodes.Add(tr); } else if (fd.IsFamilyOrAssembly) { tr = new FieldTreeNode(fd, Access.Internal, false); parentNode.Nodes.Add(tr); } else { // It must be protected. tr = new FieldTreeNode(fd, Access.Protected, false); parentNode.Nodes.Add(tr); } }
public FieldInfo Field(FieldDefinition fieldDefinition) { if (_fieldCorrespondence.ContainsKey(fieldDefinition)) { return(_fieldCorrespondence[fieldDefinition]); } var fieldInfo = new FieldInfo { Text = fieldDefinition.Name, Name = fieldDefinition.Name, FullName = fieldDefinition.FullName, Icon = FieldTreeNode.GetIcon(fieldDefinition), IsInternal = fieldDefinition.IsAssembly, IsPrivate = fieldDefinition.IsPrivate, IsPublic = fieldDefinition.IsPublic, IsProtected = fieldDefinition.IsFamily, IsProtectedAndInternal = fieldDefinition.IsFamilyAndAssembly, IsProtectedOrInternal = fieldDefinition.IsFamilyOrAssembly, IsStatic = fieldDefinition.IsStatic, IsLiteral = fieldDefinition.IsLiteral, IsInitOnly = fieldDefinition.IsInitOnly, IsSpecialName = fieldDefinition.IsSpecialName, MemberReference = fieldDefinition }; _fieldCorrespondence.Add(fieldDefinition, fieldInfo); return(fieldInfo); }
protected override void OnPropertyChanged(Object source, EventArgs e) { if (IsLoading()) { return; } // This means there are no fields yet. Do nothing if (CurrentNode == null) { return; } FieldTreeNode currentFieldNode = (FieldTreeNode)CurrentNode; if (source == _cmbDataField) { currentFieldNode.DataField = _cmbDataField.Text; } else if (source == _txtDataFormatString) { currentFieldNode.DataFormatString = _txtDataFormatString.Text; } else if (source == _txtTitle) { currentFieldNode.Title = _txtTitle.Text; } else if (source == _ckbVisible) { currentFieldNode.Visible = _ckbVisible.Checked; } SetDirty(); CurrentNode.Dirty = true; }
public override TreeViewNodeFilterResult GetFilterResult(FieldDef field) { if (showPublicApi() && !FieldTreeNode.IsPublicAPIInternal(field)) { return(new TreeViewNodeFilterResult(FilterResult.Hidden, false)); } return(base.GetFilterResult(field)); }
protected override void LoadItems() { using (new LoadingModeResource(this)) { foreach (ObjectListField field in _objectList.Fields) { FieldTreeNode newNode = new FieldTreeNode(field.Name, field); TreeList.TvList.Nodes.Add(newNode); } } }
FieldDefSettingsCommand(FieldTreeNode fieldNode, FieldDefOptions options) { this.fieldNode = fieldNode; this.newOptions = options; this.origOptions = new FieldDefOptions(fieldNode.FieldDefinition); this.origParentNode = (ILSpyTreeNode)fieldNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(fieldNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; }
void Search(LoadedAssembly ownerModule, TypeDef type, FieldDef field) { var res = filter.GetFilterResult(field); if (res.FilterResult == FilterResult.Hidden) return; ImplMap im; if (res.IsMatch && (IsMatch(field.Name, field) || ((im = field.ImplMap) != null && (IsMatch(im.Name, im) || IsMatch(im.Module == null ? null : im.Module.Name, null))))) { onMatch(new SearchResult { Language = language, Object = field, NameObject = field, TypeImageInfo = FieldTreeNode.GetImageInfo(field, BackgroundType.Search), LocationObject = type, LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search), LoadedAssembly = ownerModule, }); } }
protected override void OnClickAddButton(Object source, EventArgs e) { if (IsLoading()) { return; } FieldTreeNode newNode = new FieldTreeNode(GetNewName()); TreeList.TvList.Nodes.Add(newNode); TreeList.TvList.SelectedNode = newNode; CurrentNode = newNode; newNode.Dirty = true; newNode.BeginEdit(); LoadItemProperties(); SetDirty(); }
FieldDefSettingsCommand(FieldTreeNode fieldNode, FieldDefOptions options) { this.fieldNode = fieldNode; this.newOptions = options; this.origOptions = new FieldDefOptions(fieldNode.FieldDefinition); this.origParentNode = (ILSpyTreeNode)fieldNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(fieldNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.nameChanged) { this.memberRefInfos = RefFinder.FindMemberRefsToThisModule(ILSpyTreeNode.GetModule(fieldNode)).Where(a => RefFinder.FieldEqualityComparerInstance.Equals(a, fieldNode.FieldDefinition)).Select(a => new MemberRefInfo(a)).ToArray(); } }
void Search(LoadedAssembly ownerModule, TypeDef type, FieldDef field) { var res = filter.GetFilterResult(field); if (res.FilterResult == FilterResult.Hidden) { return; } if (res.IsMatch && IsMatch(field.Name, field)) { onMatch(new SearchResult { Language = language, Object = field, NameObject = field, TypeImageInfo = FieldTreeNode.GetImageInfo(field, BackgroundType.Search), LocationObject = type, LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search), LoadedAssembly = ownerModule, }); } }
protected override void LoadItemProperties() { using (new LoadingModeResource(this)) { if (CurrentNode != null) { FieldTreeNode currentFieldNode = (FieldTreeNode)CurrentNode; _cmbDataField.Text = currentFieldNode.DataField; _txtDataFormatString.Text = currentFieldNode.DataFormatString; _txtTitle.Text = currentFieldNode.Title; _ckbVisible.Checked = currentFieldNode.Visible; } else { _cmbDataField.Text = String.Empty; _txtDataFormatString.Text = String.Empty; _txtTitle.Text = String.Empty; _ckbVisible.Checked = false; } } }
//private void LoadConstant(TreeNode parentNode, PropertyInfo ptd) //{ // //TreeNode tr = new FieldTreeNode(fd, Access.Protected, false); // //parentNode.Nodes.Add(tr); // parentNode.Nodes.Add(ptd.FullName, ptd.Name, Constants.ConstantIcon, Constants.ConstantIcon); //} #region LoadEnum private void LoadEnum(TreeNode parentNode, Type td) { TreeNode enode; TreeNode tr; if (td.IsPublic) { enode = new ClassTreeNode(td, ClassType.Enum, Access.Public); parentNode.Nodes.Add(enode); } else if (td.IsNestedPrivate) { enode = new ClassTreeNode(td, ClassType.Enum, Access.Private); parentNode.Nodes.Add(enode); } else if (td.IsNestedFamORAssem) { enode = new ClassTreeNode(td, ClassType.Enum, Access.Internal); parentNode.Nodes.Add(enode); } else { // It must be protected. enode = new ClassTreeNode(td, ClassType.Enum, Access.Protected); parentNode.Nodes.Add(enode); } // Now we get to load it's values. foreach (FieldInfo fd in td.GetFields()) { // We don't want to show "value__" because it's automatically added // by the compiler. if (fd.Name != "value__") { tr = new FieldTreeNode(fd, Access.Public, true); enode.Nodes.Add(tr); } } }
IBitmap GetIcon(IEntity member) { switch (member) { case ITypeDefinition t: return(TypeTreeNode.GetIcon(t)); case IField f: return(FieldTreeNode.GetIcon(f)); case IProperty p: return(PropertyTreeNode.GetIcon(p)); case IMethod m: return(MethodTreeNode.GetIcon(m)); case IEvent e: return(EventTreeNode.GetIcon(e)); default: throw new NotSupportedException(member?.GetType() + " not supported!"); } }
void PerformSearch(TypeDefinition type) { if (searchMode == SearchMode_Type && IsMatch(type.Name)) { AddResult(new SearchResult { Member = type, Image = TypeTreeNode.GetIcon(type), Name = language.TypeToString(type, includeNamespace: false), LocationImage = type.DeclaringType != null ? TypeTreeNode.GetIcon(type.DeclaringType) : Images.Namespace, Location = type.DeclaringType != null ? language.TypeToString(type.DeclaringType, includeNamespace: true) : type.Namespace }); } foreach (TypeDefinition nestedType in type.NestedTypes) { PerformSearch(nestedType); } if (searchMode == SearchMode_Type) { return; } foreach (FieldDefinition field in type.Fields) { if (IsMatch(field)) { AddResult(new SearchResult { Member = field, Image = FieldTreeNode.GetIcon(field), Name = field.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (PropertyDefinition property in type.Properties) { if (IsMatch(property)) { AddResult(new SearchResult { Member = property, Image = PropertyTreeNode.GetIcon(property), Name = property.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (EventDefinition ev in type.Events) { if (IsMatch(ev)) { AddResult(new SearchResult { Member = ev, Image = EventTreeNode.GetIcon(ev), Name = ev.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (MethodDefinition method in type.Methods) { switch (method.SemanticsAttributes) { case MethodSemanticsAttributes.Setter: case MethodSemanticsAttributes.Getter: case MethodSemanticsAttributes.AddOn: case MethodSemanticsAttributes.RemoveOn: case MethodSemanticsAttributes.Fire: continue; } if (IsMatch(method)) { AddResult(new SearchResult { Member = method, Image = MethodTreeNode.GetIcon(method), Name = method.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } }
CreateFieldDefCommand(TypeTreeNode ownerNode, FieldDefOptions options) { this.ownerNode = ownerNode; this.fieldNode = new FieldTreeNode(options.CreateFieldDef(ownerNode.TypeDefinition.Module)); }
protected override void Write(ITextOutput output, Language language) { Language.TypeToString(output, analyzedField.DeclaringType, true); output.Write('.', TextTokenType.Operator); FieldTreeNode.Write(output, analyzedField, Language); }
protected override void LoadItems() { using (new MobileComponentEditorPage.LoadingModeResource(this)) { foreach (ObjectListField field in this._objectList.get_Fields()) { FieldTreeNode node = new FieldTreeNode(field.get_Name(), field); base.TreeList.TvList.Nodes.Add(node); } } }
protected override void OnClickAddButton(object source, EventArgs e) { if (!base.IsLoading()) { FieldTreeNode node = new FieldTreeNode(this.GetNewName()); base.TreeList.TvList.Nodes.Add(node); base.TreeList.TvList.SelectedNode = node; base.CurrentNode = node; node.Dirty = true; node.BeginEdit(); this.LoadItemProperties(); this.SetDirty(); } }
public static ImageSource GetIcon(MemberIcon icon, BackgroundType bgType) { return(FieldTreeNode.GetIcon(icon, bgType)); }
void PerformSearch(TypeDef type) { if (searchMode == SearchMode_Type && IsMatch(type.Name)) { AddResult(new SearchResult { Member = type, Image = TypeTreeNode.GetIcon(type), Name = language.TypeToString(type, includeNamespace: false), LocationImage = type.DeclaringType != null ? TypeTreeNode.GetIcon(type.DeclaringType) : Images.Namespace, Location = type.DeclaringType != null ? language.TypeToString(type.DeclaringType, includeNamespace: true) : type.Namespace.String }); } foreach (TypeDef nestedType in type.NestedTypes) { PerformSearch(nestedType); } if (searchMode == SearchMode_Type) { return; } foreach (FieldDef field in type.Fields) { if (IsMatch(field)) { AddResult(new SearchResult { Member = field, Image = FieldTreeNode.GetIcon(field), Name = field.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (PropertyDef property in type.Properties) { if (IsMatch(property)) { AddResult(new SearchResult { Member = property, Image = PropertyTreeNode.GetIcon(property), Name = property.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (EventDef ev in type.Events) { if (IsMatch(ev)) { AddResult(new SearchResult { Member = ev, Image = EventTreeNode.GetIcon(ev), Name = ev.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } foreach (MethodDef method in type.Methods) { if (Decompiler.DnlibExtensions.HasSemantics(method)) { continue; } if (IsMatch(method)) { AddResult(new SearchResult { Member = method, Image = MethodTreeNode.GetIcon(method), Name = method.Name, LocationImage = TypeTreeNode.GetIcon(type), Location = language.TypeToString(type, includeNamespace: true) }); } } }