示例#1
0
 /// <summary>
 /// ���뱾ѡ��ڣ���ִ��һЩѡ���������ѡ�������ѡ�����ִ�б�������ſ���ʹ��
 /// </summary>
 /// <param name="current">��ǰѡ���</param>
 /// <param name="settings">ѡ�������</param>
 /// <returns>������ѡ���</returns>
 protected static Option Compile(Option current, OptionCollection settings)
 {
     OptionCollection currentSettings = current.childSettings;
     if (settings.Count > 0)
     {
         for (int i = 0; i < settings.Count; i++)
         {
             Option setting = settings[i];
             switch (setting.SettingOperator)
             {
                 case OptionOperatorEnum.Add:
                     if (currentSettings.Contains(setting.Name))
                     {
                         throw new OptionException(string.Format("�Ѵ�����ѡ��� {0}", setting.Name));
                     }
                     else
                     {
                         currentSettings.Add(setting).Parent = current;
                     }
                     break;
                 case OptionOperatorEnum.Remove:
                     currentSettings.Remove(setting.Name);
                     break;
                 case OptionOperatorEnum.Move:
                     Option moveSetting = currentSettings[setting.Name];
                     if (moveSetting != null)
                     {
                         currentSettings.Remove(moveSetting.Name);
                         currentSettings.Add(moveSetting);
                     }
                     break;
                 case OptionOperatorEnum.Clear:
                     currentSettings.Clear();
                     break;
                 case OptionOperatorEnum.Update:
                     if (currentSettings.Contains(setting.Name))
                     {
                         currentSettings[setting.Name].Merge(setting);
                     }
                     break;
                 case OptionOperatorEnum.Set:
                     if (currentSettings.Contains(setting.Name))
                     {
                         currentSettings[setting.Name].Merge(setting);
                     }
                     else
                     {
                         currentSettings.Add(setting).Parent = current;
                     }
                     break;
                 default:
                     if (currentSettings.Contains(setting.Name))
                     {
                         currentSettings[setting.Name].Merge(setting);
                     }
                     else
                     {
                         currentSettings.Add(setting).Parent = current;
                     }
                     break;
             }
         }
     }
     return current;
 }
示例#2
0
 /// <summary>
 /// ����ѡ���ʵ��
 /// </summary>
 /// <param name="setting">�����Ƶ�ѡ���</param>
 /// <param name="deep">�Ƿ���ȸ���</param>
 /// <returns>ѡ���</returns>
 protected virtual Option CreateOptionSetting(Option setting, bool deep)
 {
     Option newSetting = this.CreateOption();
     newSetting.@readonly = setting.ReadOnly;
     newSetting.settingName = setting.settingName;
     if (deep)
     {
         newSetting.value = setting.Value.Clone();
         newSetting.property = setting.Property.Clone(this.@readonly, deep);
         newSetting.childSettings = setting.childSettings.Clone();
         newSetting.operatorSettings = setting.operatorSettings.Clone();
     }
     else
     {
         newSetting.value = setting.Value;
         newSetting.property = setting.Property;
         newSetting.childSettings = setting.childSettings;
         newSetting.operatorSettings = setting.operatorSettings;
     }
     return newSetting;
 }
示例#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;
        }