예제 #1
0
        public void SetValue(string value)
        {
            StringList list = StringList.Parse(value);

            if (list != null)
            {
                bool isValueType = typeof(T).IsValueType;

                foreach (string item in list)
                {
                    ExceptionItem <T> exceptionItem = new ExceptionItem <T>();  //new ExceptionItem<T>(Guid.Empty,0);

                    if (isValueType)
                    {
                        exceptionItem.Value = this[0].Value;
                    }
                    else
                    {
                        exceptionItem.Value = (T)((IExceptableSettingItem)this[0].Value).Clone();//;.Clone
                    }

                    exceptionItem.Parse(item);

                    this.Add(exceptionItem);
                }

                //Sort();
            }
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value">默认值 不能为null</param>
 public Exceptable(T value)
 {
     if (typeof(T).IsValueType || ReflectionUtil.HasInterface(typeof(T), typeof(IExceptableSettingItem)))
     {
         ExceptionItem <T> item = new ExceptionItem <T>(Guid.Empty, 0, value);
         this.Insert(0, item);
     }
     else
     {
         throw new ArgumentException("只支持值类型和IExceptableSettingItem接口");
     }
 }
예제 #3
0
 public override void Add(ExceptionItem <T> item)
 {
     if (item.RoleID == Guid.Empty)
     {
         if (this[0].RoleID == Guid.Empty)
         {
             this[0] = item;
         }
         else
         {
             this.Insert(0, item);
         }
     }
     else if (this.Count == 1 && this[0].RoleID == Guid.Empty)
     {
         this.Insert(1, item);
     }
     else
     {
         int index = 0;
         for (int i = 1; i < this.Count + 1; i++)
         {
             if (item.SortOrder > this[i - 1].SortOrder)
             {
                 index = i;
             }
             if (item.SortOrder < this[i - 1].SortOrder)
             {
                 break;
             }
         }
         if (index >= this.Count)
         {
             base.Add(item);
         }
         else
         {
             base.Insert(index, item);
         }
     }
 }