IfcDoc.FormEdit.DeleteReferencesForDefinition C# (CSharp) Méthode

DeleteReferencesForDefinition() private méthode

Scans all data definitions and deletes any dependencies on the specified definition.
private DeleteReferencesForDefinition ( string definition ) : void
definition string Required name of definition (entity, select, enumeration, defined-type)
Résultat void
        private void DeleteReferencesForDefinition(string definition)
        {
            foreach (DocSection docSection in this.m_project.Sections)
            {
                foreach (DocSchema docSchema in docSection.Schemas)
                {
                    foreach (DocType docType in docSchema.Types)
                    {
                        if (docType is DocSelect)
                        {
                            DocSelect docSel = (DocSelect)docType;
                            foreach (DocSelectItem docItem in docSel.Selects)
                            {
                                if (docItem.Name == definition)
                                {
                                    docSel.Selects.Remove(docItem);
                                    docItem.Delete();

                                    // delete any lines as well...
                                    break;
                                }
                            }
                        }
                    }

                    foreach (DocEntity docEntity in docSchema.Entities)
                    {
                        if (docEntity.BaseDefinition == definition)
                        {
                            docEntity.BaseDefinition = null;
                        }

                        foreach (DocSubtype docSub in docEntity.Subtypes)
                        {
                            if (docSub.DefinedType == definition)
                            {
                                docEntity.Subtypes.Remove(docSub);
                                docSub.Delete();
                                break;
                            }
                        }

                        //... delete lines...

                        for (int iAttr = docEntity.Attributes.Count - 1; iAttr >= 0; iAttr--)
                        {
                            DocAttribute docAttr = docEntity.Attributes[iAttr];
                            if (docAttr.DefinedType == definition)
                            {
                                docAttr.Delete();
                                docEntity.Attributes.RemoveAt(iAttr);
                            }
                        }
                    }

                    foreach (DocPageTarget docPageTarget in docSchema.PageTargets)
                    {
                        //...check if target matches...if(docPageTarget.)
                    }

                    foreach (DocSchemaRef docSchemaRef in docSchema.SchemaRefs)
                    {
                        foreach (DocDefinitionRef docDefRef in docSchemaRef.Definitions)
                        {
                            // delete lines...
            #if false
                            foreach(DocSubtype docSub in docDefRef.Subtypes)
                            {
                                foreach(DocSubtype docSubSub in docSub.Subtypes)
                                {
                                    foreach(DocSubtype docSubSubSub in docSubSub.Subtypes)
                                    {
                                        if(docSubSubSub.DefinedType == definition)
                                        {
                                            docSubSubSub.Delete();
                                            docSubSub.Subtypes.Remove(docSubSubSub);
                                            break;
                                        }
                                    }

                                    if (docSubSub.DefinedType == definition)
                                    {
                                        docSubSub.Delete();
                                        docSub.Subtypes.Remove(docSubSub);
                                        break;
                                    }
                                }

                                if (docSub.DefinedType == definition)
                                {
                                    docSub.Delete();
                                    docDefRef.Subtypes.Remove(docSub);
                                    break;
                                }
                            }
            #endif

                            if (docDefRef.Name == definition)
                            {
                                docDefRef.Delete();
                                docSchemaRef.Definitions.Remove(docDefRef);
                            }
                            break;
                        }
                    }
                }
            }

            this.UpdateTreeDeletion();
        }
FormEdit