public void Remove(ImportItem item)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Bạn có muốn xóa phần tử này hay không?", "Cảnh báo", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (messageBoxResult == MessageBoxResult.OK)
            {
                ImportList.Remove(item);
                UpdateValue();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Resolves reference from libraries to classes and other libraries.
        /// </summary>
        /// <param name="libraryTable">The table of known libraries.</param>
        /// <param name="resolvedLibraryList">The list of libraries that have been resolved so far.</param>
        /// <param name="importChanged">Indicates that the import specifier has changed.</param>
        /// <param name="errorList">List of errors found.</param>
        /// <returns>True if the method succeeded.</returns>
        public virtual bool Resolve(ISealableDictionary <string, ISealableDictionary <string, ILibrary> > libraryTable, IList <ILibrary> resolvedLibraryList, ref bool importChanged, IErrorList errorList)
        {
            List <IImport> ToRemove = new List <IImport>();
            bool           Success  = true;

            foreach (IImport ImportItem in ImportList)
            {
                // Check the import and obtain the matching library.
                if (!ImportItem.CheckImportConsistency(libraryTable, out ILibrary MatchingLibrary, errorList))
                {
                    Success = false;
                    continue;
                }

                // You can't import the same library twice.
                if (ImportedLibraryList.Contains(MatchingLibrary))
                {
                    Success = false;
                    errorList.AddError(new ErrorDuplicateImport((IIdentifier)ImportItem.LibraryIdentifier, MatchingLibrary.ValidLibraryName, MatchingLibrary.ValidSourceName));
                    continue;
                }

                // If the imported library hasn't been resolved yet, ignore it for now.
                if (!resolvedLibraryList.Contains(MatchingLibrary))
                {
                    continue;
                }

                // The imported library was resolved, merge this import with it.
                if (!MergeImports(ImportedClassTable, ImportItem, MatchingLibrary, errorList))
                {
                    Success = false;
                    continue;
                }

                ImportedLibraryList.Add(MatchingLibrary);
                ToRemove.Add(ImportItem);
                importChanged = true;
            }

            foreach (IImport ImportItem in ToRemove)
            {
                ImportList.Remove(ImportItem);
            }

            Debug.Assert(Success || !errorList.IsEmpty);
            return(Success);
        }