Exemple #1
0
        /**
         * Unregisters the specified property type and deletes all properties
         * of that type.
         */

        public void Delete(int id)
        {
            PropTypeItem item = FindPropTypeItem(id);

            if (item.DataType == PropDataType.Link)
            {
                _storage.DeleteLinksOfType(id);
            }
            else
            {
                _storage.DeletePropsOfType(id);
            }
            ResourceRestrictions.DeletePropRestrictions(id);

            IResultSet rs = _propTypeTable.CreateModifiableResultSet(0, id);

            try
            {
                SafeRecordEnumerator enumerator = new SafeRecordEnumerator(rs, "PropTypes.Delete");
                using ( enumerator )
                {
                    if (!enumerator.MoveNext())
                    {
                        MyPalStorage.Storage.OnIndexCorruptionDetected("PropTypeCollection.Delete: Attempt to delete non-existing property type " + id);
                    }
                    else
                    {
                        IRecord rec = enumerator.Current;
                        _storage.SafeDeleteRecord(rec, "PropTypes.Delete");
                    }
                }
            }
            finally
            {
                rs.Dispose();
            }

            IResource propTypeRes = _storage.FindUniqueResource("PropType", "ID", id);

            Debug.Assert(propTypeRes != null);
            propTypeRes.Delete();
        }