System.Configuration.ConfigurationElementCollection.BaseRemoveAt C# (CSharp) Метод

BaseRemoveAt() защищенный Метод

protected BaseRemoveAt ( int index ) : void
index int
Результат void
        protected internal void BaseRemoveAt(int index) {
            if (IsReadOnly()) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_read_only));
            }
            int VirtualIndex = 0;
            Entry entry = (Entry)null;

            foreach (Entry entryfound in _items) {
                if (VirtualIndex == index && (entryfound._entryType != EntryType.Removed)) {
                    entry = entryfound;
                    break;
                }

                if (entryfound._entryType != EntryType.Removed) {
                    VirtualIndex++;
                }
            }

            if (entry == null) {
                throw new ConfigurationErrorsException(SR.GetString(SR.IndexOutOfRange, index));
            }
            else {
                if (entry._value.LockItem == true) {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_attribute_locked, entry.GetKey(this)));
                }

                if (entry._value.ElementPresent == false) {
                    CheckLockedElement(_removeElement, null); // has remove been locked? 
                }

                switch (entry._entryType) {
                    case EntryType.Added:
                        if (CollectionType != ConfigurationElementCollectionType.AddRemoveClearMap &&
                            CollectionType != ConfigurationElementCollectionType.AddRemoveClearMapAlternate) {
                            if (CollectionType == ConfigurationElementCollectionType.BasicMapAlternate) {
                                if (index >= Count - _inheritedCount) {
                                    throw (new ConfigurationErrorsException(SR.GetString(SR.Config_base_cannot_remove_inherited_items)));
                                }
                            }

                            if (CollectionType == ConfigurationElementCollectionType.BasicMap) {
                                if (index < _inheritedCount) {
                                    throw (new ConfigurationErrorsException(SR.GetString(SR.Config_base_cannot_remove_inherited_items)));
                                }
                            }

                            _items.RemoveAt(index);

                        }
                        else {
                            // don't really remove it from the collection just mark it removed
                            if (entry._value.ElementPresent == false) {
                                CheckLockedElement(_removeElement, null); // has remove been locked? 
                            }

                            entry._entryType = EntryType.Removed;
                            _removedItemCount++;
                        }

                        break;

                    case EntryType.Removed:
                        throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_collection_entry_already_removed));

                    default:
                        if (CollectionType != ConfigurationElementCollectionType.AddRemoveClearMap &&
                            CollectionType != ConfigurationElementCollectionType.AddRemoveClearMapAlternate) {
                            throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_collection_elements_may_not_be_removed));
                        }

                        entry._entryType = EntryType.Removed;
                        _removedItemCount++;
                        break;
                }
                bModified = true;
            }
        }