Inheritance: System.Configuration.ConfigurationElement
        protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
        {
            base.Unmerge(sourceElement, parentElement, saveMode);
            SwitchElement element = sourceElement as SwitchElement;

            if ((element != null) && (element._attributes != null))
            {
                this._attributes = element._attributes;
            }
        }
示例#2
0
        protected override void Unmerge(ConfigurationElement sourceElement,
                                        ConfigurationElement parentElement,
                                        ConfigurationSaveMode saveMode)
        {
            base.Unmerge(sourceElement, parentElement, saveMode);

            // Unmerge the optional attributes cache as well
            SwitchElement le = sourceElement as SwitchElement;

            if ((le != null) && (le._attributes != null))
            {
                this._attributes = le._attributes;
            }
        }
示例#3
0
文件: Switch.cs 项目: ash2005/z
        private bool InitializeWithStatus()
        {
            if (!initialized)
            {
                lock (IntializedLock) {
                    if (initialized || initializing)
                    {
                        return(false);
                    }

                    // This method is re-entrent during intitialization, since calls to OnValueChanged() in subclasses could end up having InitializeWithStatus()
                    // called again, we don't want to get caught in an infinite loop.
                    initializing = true;

                    if (switchSettings == null)
                    {
                        if (!InitializeConfigSettings())
                        {
                            initialized  = true;
                            initializing = false;
                            return(false);
                        }
                    }

                    if (switchSettings != null)
                    {
                        SwitchElement mySettings = switchSettings[displayName];
                        if (mySettings != null)
                        {
                            string value = mySettings.Value;
                            if (value != null)
                            {
                                this.Value = value;
                            }
                            else
                            {
                                this.Value = defaultValue;
                            }

                            try {
                                TraceUtils.VerifyAttributes(mySettings.Attributes, GetSupportedAttributes(), this);
                            } catch (ConfigurationException) {
                                // if VerifyAttributes throws, clean up a little bit so we're not in a bad state.
                                initialized  = false;
                                initializing = false;
                                throw;
                            }

                            attributes = new StringDictionary();
                            attributes.ReplaceHashtable(mySettings.Attributes);
                        }
                        else
                        {
                            // We don't use the property here because we don't want to catch exceptions
                            // and rethrow them as ConfigurationException.  In this case there's no config.
                            switchValueString = defaultValue;
                            OnValueChanged();
                        }
                    }
                    else
                    {
                        // We don't use the property here because we don't want to catch exceptions
                        // and rethrow them as ConfigurationException.  In this case there's no config.
                        switchValueString = defaultValue;
                        OnValueChanged();
                    }

                    initialized  = true;
                    initializing = false;
                }
            }

            return(true);
        }
示例#4
0
 private bool InitializeWithStatus()
 {
     if (!this.initialized)
     {
         lock (this.IntializedLock)
         {
             if (this.initialized || this.initializing)
             {
                 return(false);
             }
             this.initializing = true;
             if ((this.switchSettings == null) && !this.InitializeConfigSettings())
             {
                 this.initialized  = true;
                 this.initializing = false;
                 return(false);
             }
             if (this.switchSettings != null)
             {
                 SwitchElement element = this.switchSettings[this.displayName];
                 if (element != null)
                 {
                     string str = element.Value;
                     if (str != null)
                     {
                         this.Value = str;
                     }
                     else
                     {
                         this.Value = this.defaultValue;
                     }
                     try
                     {
                         TraceUtils.VerifyAttributes(element.Attributes, this.GetSupportedAttributes(), this);
                     }
                     catch (ConfigurationException)
                     {
                         this.initialized  = false;
                         this.initializing = false;
                         throw;
                     }
                     this.attributes = new StringDictionary();
                     this.attributes.ReplaceHashtable(element.Attributes);
                 }
                 else
                 {
                     this.switchValueString = this.defaultValue;
                     this.OnValueChanged();
                 }
             }
             else
             {
                 this.switchValueString = this.defaultValue;
                 this.OnValueChanged();
             }
             this.initialized  = true;
             this.initializing = false;
         }
     }
     return(true);
 }
示例#5
0
        private bool InitializeWithStatus()
        {
            if (!initialized)
            {
                if (initializing)
                {
                    return(false);
                }

                initializing = true;

                if (switchSettings == null)
                {
                    if (!InitializeConfigSettings())
                    {
                        return(false);
                    }
                }

                if (switchSettings != null)
                {
                    SwitchElement mySettings = switchSettings[displayName];
                    if (mySettings != null)
                    {
                        string value = mySettings.Value;
                        if (value != null)
                        {
                            this.Value = value;
                        }
                        else
                        {
                            this.Value = defaultValue;
                        }

                        try {
                            TraceUtils.VerifyAttributes(mySettings.Attributes, GetSupportedAttributes(), this);
                        }
                        catch (ConfigurationException) {
                            // if VerifyAttributes throws, clean up a little bit so we're not in a bad state.
                            initialized  = false;
                            initializing = false;
                            throw;
                        }

                        attributes          = new StringDictionary();
                        attributes.contents = mySettings.Attributes;
                    }
                    else
                    {
                        // We don't use the property here because we don't want to catch exceptions
                        // and rethrow them as ConfigurationException.  In this case there's no config.
                        switchValueString = defaultValue;
                        OnValueChanged();
                    }
                }
                else
                {
                    // We don't use the property here because we don't want to catch exceptions
                    // and rethrow them as ConfigurationException.  In this case there's no config.
                    switchValueString = defaultValue;
                    OnValueChanged();
                }

                initialized  = true;
                initializing = false;
            }

            return(true);
        }