コード例 #1
0
                /// <summary>
                /// Set the property value
                /// </summary>
                /// <param name="component">The component to use</param>
                /// <param name="value">The value to set</param>
                public override void SetValue(object component, object value)
                {
                    if (PropertyChanged != null)
                    {
                        bool   changed = false;
                        object old     = GetValue(component);

                        if (old != null)
                        {
                            if (!old.Equals(value))
                            {
                                changed = true;
                            }
                        }
                        else if (value != null)
                        {
                            changed = true;
                        }

                        if (changed)
                        {
                            PropertyChanged.Invoke(this, new EventArgs());
                        }
                    }

                    ServerConfig config = component as ServerConfig;

                    if (config != null)
                    {
                        config.CurrConfig()[_property.Name] = value;
                    }
                }
コード例 #2
0
                /// <summary>
                /// Reset the value
                /// </summary>
                /// <param name="component">The component to use</param>
                public override void ResetValue(object component)
                {
                    ServerConfig config = component as ServerConfig;

                    if (config != null)
                    {
                        config.CurrConfig()[_property.Name] = _property.DefaultValue;
                    }
                }
コード例 #3
0
                /// <summary>
                /// Get the property value
                /// </summary>
                /// <param name="component">The component to use</param>
                /// <returns>The property value</returns>
                public override object GetValue(object component)
                {
                    ServerConfig config = component as ServerConfig;

                    if (config != null)
                    {
                        if (config.CurrConfig().ContainsKey(_property.Name))
                        {
                            return(config.CurrConfig()[_property.Name]);
                        }
                        else
                        {
                            return(_property.DefaultValue);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }