Example #1
0
 public void DeregisterSubItem(RegexBalanceGroupItem <T> item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (item.___balanceGroup == this)
     {
         if (this.openItem == item || this.closeItem == item)
         {
             throw new InvalidOperationException("指定平衡组项已在此平衡组中注册,且不为子项。");
         }
         else
         {
             this.DeregisterItem(item);
             this.subItems.Remove(item);
         }
     }
     else if (item.___balanceGroup == null)
     {
         throw new InvalidOperationException("指定平衡组项未注册为任何一个平衡组的项。");
     }
     else
     {
         throw new InvalidOperationException("指定平衡组项已注册为另一个平衡组的项。");
     }
 }
Example #2
0
 public void RegisterCloseItem(RegexBalanceGroupItem <T> item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (item.___balanceGroup == this)
     {
         if (this.closeItem == item)
         {
             return;
         }
         else
         {
             throw new InvalidOperationException("指定平衡组项已在此平衡组中注册,且不为结束项。");
         }
     }
     else if (item.___balanceGroup == null)
     {
         this.closeItem = item;
         this.RegisterItem(item);
     }
     else
     {
         throw new InvalidOperationException("指定平衡组项已注册为另一个平衡组的项。");
     }
 }
Example #3
0
        public RegexBalanceGroup(RegexObject <T> regex, RegexBalanceGroupItem <T> openItem, IEnumerable <RegexBalanceGroupItem <T> > subItems, RegexBalanceGroupItem <T> closeItem, object id = null) : base(regex, id, true)
        {
            if (openItem == null)
            {
                throw new ArgumentNullException(nameof(openItem));
            }
            if (subItems == null)
            {
                throw new ArgumentNullException(nameof(subItems));
            }
            if (closeItem == null)
            {
                throw new ArgumentNullException(nameof(closeItem));
            }

            this.RegisterOpenItem(openItem);
            foreach (var subItem in subItems)
            {
                this.RegisterSubItem(subItem);
            }
            this.RegisterCloseItem(closeItem);
        }
Example #4
0
 protected internal void DeregisterItem(RegexBalanceGroupItem <T> item)
 {
     item.___balanceGroup = null;
 }
Example #5
0
 protected internal void RegisterItem(RegexBalanceGroupItem <T> item)
 {
     item.___balanceGroup = this;
 }