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

BaseAdd() приватный Метод

private BaseAdd ( int index, ConfigurationElement element, bool ignoreLocks ) : void
index int
element ConfigurationElement
ignoreLocks bool
Результат void
        private void BaseAdd(int index, ConfigurationElement element, bool ignoreLocks) {
            if (IsReadOnly()) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_read_only));
            }
            if (index < -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.IndexOutOfRange, index));
            }

            if ((index != -1) &&
                (CollectionType == ConfigurationElementCollectionType.AddRemoveClearMap ||
                CollectionType == ConfigurationElementCollectionType.AddRemoveClearMapAlternate)) {

                // If it's an AddRemoveClearMap*** collection, turn the index passed into into a real internal index
                int realIndex = 0;

                if (index > 0) {
                    foreach (Entry entryfound in _items) {
                        if (entryfound._entryType != EntryType.Removed) {
                            index--;
                        }
                        if (index == 0) {
                            break;
                        }
                        realIndex++;
                    }
                    index = ++realIndex;
                }
                // check for duplicates
                Object key = GetElementKeyInternal(element);
                foreach (Entry entry in _items) {
                    if (CompareKeys(key, entry.GetKey(this))) {
                        if (entry._entryType != EntryType.Removed) {
                            if (!element.Equals(entry._value)) {
                                throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_collection_entry_already_exists, key),
                                        element.PropertyFileName(""), element.PropertyLineNumber(""));
                            }
                            return;
                        }
                    }
                }

            }

            BaseAddInternal(index, element, false, ignoreLocks);
        }

Same methods

ConfigurationElementCollection::BaseAdd ( ConfigurationElement element ) : void
ConfigurationElementCollection::BaseAdd ( ConfigurationElement element, bool throwIfExists ) : void
ConfigurationElementCollection::BaseAdd ( ConfigurationElement element, bool throwIfExists, bool ignoreLocks ) : void
ConfigurationElementCollection::BaseAdd ( int index, ConfigurationElement element ) : void