示例#1
0
        public GraphElementSearcherDatabase AddMethods(
            Type type,
            BindingFlags bindingFlags,
            Dictionary <string, List <Type> > blackList = null
            )
        {
            SearcherItem parent = null;

            foreach (MethodInfo methodInfo in type.GetMethods(bindingFlags)
                     .Where(m => !m.IsSpecialName &&
                            m.GetCustomAttribute <ObsoleteAttribute>() == null &&
                            m.GetCustomAttribute <HiddenAttribute>() == null &&
                            !m.Name.StartsWith("get_", StringComparison.Ordinal) &&
                            !m.Name.StartsWith("set_", StringComparison.Ordinal) &&
                            !m.GetParameters().Any(p => p.ParameterType.IsByRef || p.IsOut || p.ParameterType.IsPointer) &&
                            !SearcherItemCollectionUtility.IsMethodBlackListed(m, blackList))
                     .OrderBy(m => m.Name))
            {
                if (parent == null)
                {
                    parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false));
                }

                MethodDetails details = methodInfo.GetMethodDetails();

                if (methodInfo.ReturnType == typeof(void))
                {
                    parent.AddChild(new StackNodeModelSearcherItem(
                                        new MethodSearcherItemData(methodInfo),
                                        data => ((StackBaseModel)data.StackModel).CreateFunctionCallNode(
                                            methodInfo,
                                            data.Index,
                                            data.SpawnFlags
                                            ),
                                        details.MethodName,
                                        details.Details
                                        ));
                    continue;
                }

                if (!methodInfo.ReturnType.IsPointer)
                {
                    parent.AddChild(new GraphNodeModelSearcherItem(
                                        new MethodSearcherItemData(methodInfo),
                                        data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode(
                                            methodInfo,
                                            data.Position,
                                            data.SpawnFlags
                                            ),
                                        details.MethodName,
                                        details.Details
                                        ));
                }
            }

            return(this);
        }
        public GraphElementSearcherDatabase AddMethods(
            Type type,
            BindingFlags bindingFlags,
            Dictionary <string, List <Type> > blackList = null
            )
        {
            var methods = type.GetMethods(bindingFlags)
                          .Where(m => m.GetCustomAttribute <ObsoleteAttribute>() == null &&
                                 m.GetCustomAttribute <HiddenAttribute>() == null &&
                                 !SearcherItemCollectionUtility.IsMethodBlackListed(m, blackList))
                          .OrderBy(m => m.Name);

            AddMethods(methods);

            return(this);
        }