Esempio n. 1
0
        /// <summary>
        /// 尝试获取某属性值并转换成指定类型
        /// </summary>
        /// <typeparam name="T">转换成指定的类型</typeparam>
        /// <param name="propertyName">属性名</param>
        /// <param name="defaultValue">缺省值</param>
        /// <returns>指定类型的实例</returns>
        public virtual T TryGetPropertyValue <T>(string propertyName, T defaultValue)
        {
            OptionValue value = this._optionValues[propertyName];

            if (value != null)
            {
                return((value as IConverting).TryToObject <T>(defaultValue));
            }
            else
            {
                return(defaultValue);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 尝试获取某属性值
        /// </summary>
        /// <param name="propertyName">属性名</param>
        /// <returns>属性值</returns>
        public virtual string TryGetPropertyValue(string propertyName)
        {
            OptionValue value = this._optionValues[propertyName];

            if (value != null)
            {
                return(value.Value);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 合并选项节
        /// </summary>
        /// <param name="setting">需被合并的选项节</param>
        /// <returns>合并后的选项节</returns>
        public virtual Option Merge(Option setting)
        {
            if (setting == null || string.Compare(this.Name, setting.Name, true) != 0)
            {
                return(this);
            }
            this.Property.Merge(setting.Property);
            this.value = setting.Value.Clone(this.ReadOnly);

            foreach (Option optionSetting in setting.operatorSettings.Values)
            {
                this.operatorSettings.Add(optionSetting).Parent = this;
            }

            Compile(this, setting.operatorSettings);
            return(this);
        }
Esempio n. 4
0
        /// <summary>
        /// �ϲ�ѡ���
        /// </summary>
        /// <param name="setting">�豻�ϲ���ѡ���</param>
        /// <returns>�ϲ����ѡ���</returns>
        public virtual Option Merge(Option setting)
        {
            if (setting == null || string.Compare(this.Name, setting.Name, true) != 0)
            {
                return this;
            }
            this.Property.Merge(setting.Property);
            this.value = setting.Value.Clone(this.ReadOnly);

            foreach (Option optionSetting in setting.operatorSettings.Values)
            {
                this.operatorSettings.Add(optionSetting).Parent = this;
            }

            Compile(this, setting.operatorSettings);
            return this;
        }