Beispiel #1
0
        public PropertyInfo Property(PropertyDefinition propertyDefinition)
        {
            if (_propertyCorrespondence.ContainsKey(propertyDefinition))
            {
                return(_propertyCorrespondence[propertyDefinition]);
            }

            var propertyInfo = new PropertyInfo
            {
                Text      = PropertyTreeNode.GetText(propertyDefinition, MainWindow.Instance.CurrentLanguage) as string,
                Name      = propertyDefinition.Name,
                FullName  = propertyDefinition.FullName,
                Icon      = PropertyTreeNode.GetIcon(propertyDefinition),
                IsVirtual = propertyDefinition.GetMethod != null && propertyDefinition.GetMethod.IsVirtual ||
                            propertyDefinition.SetMethod != null && propertyDefinition.SetMethod.IsVirtual,
                IsOverride = propertyDefinition.GetMethod != null &&
                             propertyDefinition.GetMethod.IsVirtual &&
                             !propertyDefinition.GetMethod.IsNewSlot ||
                             propertyDefinition.SetMethod != null &&
                             propertyDefinition.SetMethod.IsVirtual &&
                             !propertyDefinition.SetMethod.IsNewSlot,
                IsStatic = propertyDefinition.GetMethod != null && propertyDefinition.GetMethod.IsStatic ||
                           propertyDefinition.SetMethod != null && propertyDefinition.SetMethod.IsStatic,
                IsFinal = propertyDefinition.GetMethod != null && propertyDefinition.GetMethod.IsFinal ||
                          propertyDefinition.SetMethod != null && propertyDefinition.SetMethod.IsFinal,
                MemberReference = propertyDefinition
            };

            AdjustPropertyVisibility(propertyInfo, propertyDefinition);

            _propertyCorrespondence.Add(propertyDefinition, propertyInfo);

            return(propertyInfo);
        }
Beispiel #2
0
 public virtual void Search(TypeDefinition type, Language language, Action <SearchResult> addResult)
 {
     Add(type.Fields, type, language, addResult, IsMatch, FieldTreeNode.GetIcon);
     Add(type.Properties, type, language, addResult, IsMatch, p => PropertyTreeNode.GetIcon(p));
     Add(type.Events, type, language, addResult, IsMatch, EventTreeNode.GetIcon);
     Add(type.Methods.Where(NotSpecialMethod), type, language, addResult, IsMatch, MethodTreeNode.GetIcon);
 }
Beispiel #3
0
        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!");
            }
        }
Beispiel #4
0
            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)
                        });
                    }
                }
            }
            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)
                        });
                    }
                }
            }