コード例 #1
0
        internal static IMemberResult[] GetModuleMembers(IModuleContext moduleContext, string[] names, bool includeMembers, IModule module)
        {
            for (int i = 1; i < names.Length && module != null; i++)
            {
                module = module.GetChildPackage(moduleContext, names[i]);
            }

            if (module != null)
            {
                var result = new Dictionary <string, List <IAnalysisSet> >();
                if (includeMembers)
                {
                    foreach (var keyValue in module.GetAllMembers(moduleContext))
                    {
                        if (!result.TryGetValue(keyValue.Key, out var results))
                        {
                            result[keyValue.Key] = results = new List <IAnalysisSet>();
                        }
                        results.Add(keyValue.Value);
                    }
                    return(MemberDictToMemberResult(result));
                }
                else
                {
                    foreach (var child in module.GetChildrenPackages(moduleContext))
                    {
                        if (!result.TryGetValue(child.Key, out var results))
                        {
                            result[child.Key] = results = new List <IAnalysisSet>();
                        }
                        results.Add(child.Value);
                    }
                    foreach (var keyValue in module.GetAllMembers(moduleContext))
                    {
                        bool anyModules = false;
                        foreach (var ns in keyValue.Value.OfType <MultipleMemberInfo>())
                        {
                            if (ns.Members.OfType <IModule>().Any(mod => !(mod is MultipleMemberInfo)))
                            {
                                anyModules = true;
                                break;
                            }
                        }
                        if (anyModules)
                        {
                            if (!result.TryGetValue(keyValue.Key, out var results))
                            {
                                result[keyValue.Key] = results = new List <IAnalysisSet>();
                            }
                            results.Add(keyValue.Value);
                        }
                    }
                    return(MemberDictToMemberResult(result));
                }
            }
            return(new IMemberResult[0]);
        }
コード例 #2
0
        internal static MemberResult[] GetModuleMembers(IModuleContext moduleContext, string[] names, bool includeMembers, IModule module)
        {
            for (int i = 1; i < names.Length && module != null; i++)
            {
                module = module.GetChildPackage(moduleContext, names[i]);
            }

            if (module != null)
            {
                List <MemberResult> result = new List <MemberResult>();
                if (includeMembers)
                {
                    foreach (var keyValue in module.GetAllMembers(moduleContext))
                    {
                        result.Add(new MemberResult(keyValue.Key, keyValue.Value));
                    }
                    return(result.ToArray());
                }
                else
                {
                    foreach (var child in module.GetChildrenPackages(moduleContext))
                    {
                        result.Add(new MemberResult(child.Key, child.Key, new[] { child.Value }, PythonMemberType.Module));
                    }
                    foreach (var keyValue in module.GetAllMembers(moduleContext))
                    {
                        bool anyModules = false;
                        foreach (var ns in keyValue.Value.OfType <MultipleMemberInfo>())
                        {
                            if (ns.Members.OfType <IModule>().Any(mod => !(mod is MultipleMemberInfo)))
                            {
                                anyModules = true;
                                break;
                            }
                        }
                        if (anyModules)
                        {
                            result.Add(new MemberResult(keyValue.Key, keyValue.Value));
                        }
                    }
                    return(result.ToArray());
                }
            }
            return(new MemberResult[0]);
        }