BaseGet() protected method

protected BaseGet ( Object key ) : ConfigurationElement
key Object
return ConfigurationElement
Esempio n. 1
0
        protected internal override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode updateMode)
        {
            ConfigurationElementCollection source = (ConfigurationElementCollection)sourceElement;
            ConfigurationElementCollection parent = (ConfigurationElementCollection)parentElement;

            for (int n = 0; n < source.Count; n++)
            {
                ConfigurationElement sitem = source.BaseGet(n);
                object key = source.GetElementKey(sitem);
                ConfigurationElement pitem = parent != null?parent.BaseGet(key) as ConfigurationElement : null;

                if (pitem != null && updateMode != ConfigurationSaveMode.Full)
                {
                    ConfigurationElement nitem = CreateNewElementInternal(null);
                    nitem.Unmerge(sitem, pitem, ConfigurationSaveMode.Minimal);
                    if (nitem.HasValues())
                    {
                        BaseAdd(nitem);
                    }
                }
                else
                {
                    ConfigurationElement nitem = CreateNewElementInternal(null);
                    nitem.Unmerge(sitem, null, ConfigurationSaveMode.Full);
                    BaseAdd(nitem);
                }
            }

            if (updateMode == ConfigurationSaveMode.Full)
            {
                EmitClear = true;
            }
            else if (parent != null)
            {
                for (int n = 0; n < parent.Count; n++)
                {
                    ConfigurationElement pitem = parent.BaseGet(n);
                    object key = parent.GetElementKey(pitem);
                    if (source.IndexOfKey(key) == -1)
                    {
                        if (removed == null)
                        {
                            removed = new ArrayList();
                        }
                        removed.Add(pitem);
                    }
                }
            }
        }
        protected internal override void Reset(ConfigurationElement parentElement)
        {
            bool basic = IsBasic;

            ConfigurationElementCollection parent = (ConfigurationElementCollection)parentElement;

            for (int n = 0; n < parent.Count; n++)
            {
                ConfigurationElement parentItem = parent.BaseGet(n);
                ConfigurationElement item       = CreateNewElementInternal(null);
                item.Reset(parentItem);
                BaseAdd(item);

                if (basic)
                {
                    if (inherited == null)
                    {
                        inherited = new ArrayList();
                    }
                    inherited.Add(item);
                }
            }
            if (IsAlternate)
            {
                inheritedLimitIndex = 0;
            }
            else
            {
                inheritedLimitIndex = Count - 1;
            }
            modified = false;
        }
        public override bool Equals(object compareTo)
        {
            ConfigurationElementCollection other = compareTo as ConfigurationElementCollection;

            if (other == null)
            {
                return(false);
            }
            if (GetType() != other.GetType())
            {
                return(false);
            }
            if (Count != other.Count)
            {
                return(false);
            }

            for (int n = 0; n < Count; n++)
            {
                if (!BaseGet(n).Equals(other.BaseGet(n)))
                {
                    return(false);
                }
            }
            return(true);
        }