예제 #1
0
        private void ReorderRange <TParent, TMember>(Workspace workspace, MetaDataTableType parentTable, MetaDataTableType memberTable, int memberListIndex, Func <TParent, TMember[]> getMembersFunc)
            where TParent : MetaDataMember
            where TMember : MetaDataMember
        {
            if (workspace.Members.ContainsKey(parentTable) && workspace.Members.ContainsKey(memberTable))
            {
                MetaDataMemberInfo[] newRange      = new MetaDataMemberInfo[workspace.Members[memberTable].Length];
                TParent[]            parentMembers = workspace.GetMembers <TParent>(parentTable);
                MetaDataTable        targetTable   = workspace.Members[memberTable][0].Instance.Table;

                uint currentIndex = 0;

                for (int i = 0; i < parentMembers.Length; i++)
                {
                    TMember[] members = getMembersFunc(parentMembers[i]);

                    if (members.Length > 0)
                    {
                        int startIndex = workspace.GetIndexOfMember(members[0]);
                        int endIndex   = workspace.GetIndexOfMember(members[members.Length - 1]);

                        Array.Copy(workspace.Members[memberTable], startIndex, newRange, currentIndex, endIndex - startIndex + 1);
                    }

                    parentMembers[i].MetaDataRow.Parts[memberListIndex] = ConvertToIndex(targetTable, currentIndex + 1);

                    currentIndex += (uint)members.Length;
                }

                workspace.Members[memberTable] = newRange;
            }
        }
예제 #2
0
        private void CollectMembers(TablesHeap tablesHeap, Workspace workspace)
        {
            Constructor.Log("Collecting .NET metadata members.");
            for (int i = 0; i < tablesHeap._tables.Length; i++)
            {
                MetaDataTableType tableType = (MetaDataTableType)i;
                if (tablesHeap.HasTable(tableType))
                {
                    MetaDataTable table = tablesHeap.GetTable(tableType);

                    if (table.Members.Count != 0)
                    {
                        MetaDataMemberInfo[] subMembers = new MetaDataMemberInfo[table.Members.Count];

                        for (int j = 0; j < subMembers.Length; j++)
                        {
                            subMembers[j] = new MetaDataMemberInfo(table.Members[j]);
                        }

                        workspace.Members.Add(tableType, subMembers);
                    }
                }
            }
        }