コード例 #1
0
        public void AddProperty()
        {
            Expand();
            ConfigProperty pr       = new ConfigProperty();
            int            n        = 1;
            string         nameBase = "Property";

            pr.DataName = nameBase + n.ToString();
            bool b = true;

            while (b)
            {
                b = false;
                for (int i = 0; i < Nodes.Count; i++)
                {
                    TreeNodeConfigProperty cn = Nodes[i] as TreeNodeConfigProperty;
                    if (cn != null)
                    {
                        ConfigProperty p = cn.Property;
                        if (string.Compare(pr.DataName, p.DataName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            n++;
                            pr.DataName = nameBase + n.ToString();
                            b           = true;
                        }
                    }
                }
            }
            TreeNodeConfigProperty tc = new TreeNodeConfigProperty(pr, false);

            Nodes.Add(tc);
            this.Expand();
            this.TreeView.SelectedNode = tc;
        }
コード例 #2
0
        public void VerifyConfigCategory(ConfigCategory defCat)
        {
            ConfigCategory cat = FindCategoryByName(defCat.CategoryName);

            if (cat == null)
            {
                cat = CreateSection(defCat.CategoryName);
            }
            if (defCat.Properties.Properties.Count > 0)
            {
                foreach (ConfigProperty p in defCat.Properties.Properties)
                {
                    ConfigProperty p0 = cat.GetConfigProperty(p.DataName);
                    if (p0 == null)
                    {
                        p0             = cat.CreateConfigProperty(p.DataName);
                        p0.DataType    = p.DataType;
                        p0.DefaultData = p.DefaultData;
                    }
                    else
                    {
                        if (!p0.DataType.Equals(p.DataType))
                        {
                            p0.DataType    = p.DataType;
                            p0.DefaultData = p.DefaultData;
                        }
                    }
                }
            }
        }
 public PropertyDescriptorConfig(string name, Attribute[] attrs, ApplicationConfiguration config, ConfigCategory category, ConfigProperty property)
     : base(name, attrs)
 {
     _config = config;
     _cat    = category;
     _prop   = property;
 }
コード例 #4
0
 public object this[string name]
 {
     get
     {
         ConfigProperty p = this.GetPropertyByName(name);
         if (p != null)
         {
             return(p.DefaultData);
         }
         else
         {
             throw new ConfigException("Error getting property. Property {0} not found. Invalid configuration file: [{1}]. Deleting this file may fix the problem.", name, ApplicationConfiguration.ConfigFilePath);
         }
     }
     set
     {
         ConfigProperty p = this.GetPropertyByName(name);
         if (p != null)
         {
             p.DefaultData = value;
             _dirty        = true;
         }
         else
         {
             throw new ConfigException("Error setting property. Property {0} not found. Invalid configuration file: [{1}]. Deleting this file may fix the problem.", name, ApplicationConfiguration.ConfigFilePath);
         }
     }
 }
コード例 #5
0
        public void SetPropertyValueByIndex(int index, object value)
        {
            ConfigProperty p = GetPropertyByIndex(index);

            if (p != null)
            {
                p.SetSetting(value);
                _dirty = true;
            }
        }
コード例 #6
0
        public object GetPropertyValueByIndex(int index)
        {
            ConfigProperty p = GetPropertyByIndex(index);

            if (p != null)
            {
                return(p.DefaultData);
            }
            return(null);
        }
コード例 #7
0
        public string GetPropertyValueNameByIndex(int index)
        {
            ConfigProperty p = GetPropertyByIndex(index);

            if (p != null)
            {
                return(p.DataName);
            }
            return(null);
        }
コード例 #8
0
        public object GetPropertyValueByName(string name)
        {
            ConfigProperty p = GetPropertyByName(name);

            if (p != null)
            {
                return(p.DefaultData);
            }
            return(null);
        }
コード例 #9
0
        public ConfigProperty CreateConfigProperty(string name)
        {
            ConfigProperty p = GetConfigProperty(name);

            if (p == null)
            {
                p = _properties.CreateConfigProperty(name, typeof(string));
            }
            return(p);
        }
コード例 #10
0
        public object Clone()
        {
            ConfigProperty p = new ConfigProperty();

            p._name     = _name;
            p._type     = _type;
            p._xmlNode  = _xmlNode;
            p.Encrypted = Encrypted;
            p._data     = _data;
            return(p);
        }
コード例 #11
0
        public ConfigProperty CreateConfigProperty(string name, Type type)
        {
            ConfigProperty p = new ConfigProperty();

            p.DataName = name;
            p.DataType = type;
            XmlNode nd = _catNode.OwnerDocument.CreateElement(XML_CONFIG);

            _catNode.AppendChild(nd);
            p.Save(nd);
            _properties.Add(p);
            return(p);
        }
コード例 #12
0
        public TreeNodeConfigProperty(ConfigProperty property, bool dataOnly)
        {
            _isDataOnly          = dataOnly;
            _property            = property;
            _property.IsDataOnly = dataOnly;
            Text               = _property.DataName;
            ImageIndex         = TreeNodeCat.IMG_PRO;
            SelectedImageIndex = TreeNodeCat.IMG_PRO;
            this.ContextMenu   = new ContextMenu();
            MenuItem mi = new MenuItem("Delete Property", mnu_delProp);

            ContextMenu.MenuItems.Add(mi);
            _property.NameChanging = nameChanging;
        }
コード例 #13
0
        public ConfigProperty GetPropertyByName(string name)
        {
            if (_properties == null)
            {
                _properties = new ConfigPropertyList();
            }
            foreach (ConfigProperty p in _properties.Properties)
            {
                if (string.CompareOrdinal(p.DataName, name) == 0)
                {
                    return(p);
                }
            }
            ConfigProperty p0 = CreateConfigProperty(name);

            return(p0);
        }
コード例 #14
0
        public void SetSetting(string name, object value)
        {
            ConfigProperty p = GetConfigProperty(name);

            if (p == null)
            {
                if (value != null && value != DBNull.Value)
                {
                    Type t = typeof(string);
                    p = _properties.CreateConfigProperty(name, t);
                }
                else
                {
                    return;
                }
            }
            p.SetSetting(value);
        }
コード例 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name">it is the category name</param>
 /// <param name="attrs"></param>
 public PropertyDescriptorConfig(string name, Attribute[] attrs, ConfigProperty property, ApplicationConfiguration owner)
     : base(name, attrs)
 {
     _owner    = owner;
     _property = property;
 }