Пример #1
0
        /// <summary>
        /// Merges an import clause with already imported classes.
        /// </summary>
        /// <param name="importedClassTable">Already imported classes.</param>
        /// <param name="importItem">The merged import.</param>
        /// <param name="matchingLibrary">The library referenced by <paramref name="importItem"/>.</param>
        /// <param name="errorList">List of errors found.</param>
        /// <returns>True if the merge succeeded.</returns>
        public static bool MergeImports(ISealableDictionary <string, IImportedClass> importedClassTable, IImport importItem, ILibrary matchingLibrary, IErrorList errorList)
        {
            // Clone imported class objects from the imported library.
            ISealableDictionary <string, IImportedClass> MergedClassTable = new SealableDictionary <string, IImportedClass>();

            foreach (KeyValuePair <string, IImportedClass> Entry in matchingLibrary.ImportedClassTable)
            {
                IImportedClass Clone = new ImportedClass(Entry.Value);
                MergedClassTable.Add(Entry.Key, Clone);
            }

            if (!importItem.CheckRenames(MergedClassTable, errorList))
            {
                return(false);
            }

            if (!Class.MergeClassTables(importedClassTable, MergedClassTable, importItem, importItem.Type, errorList))
            {
                return(false);
            }

            return(true);
        }