static IEnumerable <Type> GetTypes(Stencil stencil, Type type) { return(stencil.GetAssemblies() .SelectMany(a => a.GetTypesSafe(), (domainAssembly, assemblyType) => assemblyType) .Where(t => !t.IsAbstract && !t.IsInterface && t.BaseType != null && (t.IsSubclassOf(type) || type.IsGenericType && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == type.GetGenericTypeDefinition())) .ToList()); }
public GraphElementSearcherDatabase AddExtensionMethods(Type type) { Dictionary <Type, List <MethodInfo> > extensions = TypeSystem.GetExtensionMethods(Stencil.GetAssemblies()); if (!extensions.TryGetValue(type, out var methodInfos)) { return(this); } SearcherItem parent = null; foreach (MethodInfo methodInfo in methodInfos .Where(m => !m.GetParameters().Any(p => p.ParameterType.IsByRef || p.IsOut))) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } MethodDetails details = methodInfo.GetMethodDetails(); if (methodInfo.ReturnType != typeof(void)) { parent.AddChild(new GraphNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => data.CreateFunctionCallNode(methodInfo), details.MethodName )); continue; } parent.AddChild(new StackNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => data.CreateFunctionCallNode(methodInfo), details.MethodName )); } return(this); }