205 lines
6.6 KiB
C#
205 lines
6.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
namespace System.Text.RegularExpressions
|
|
{
|
|
/// <summary>Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.</summary>
|
|
// Token: 0x020002B0 RID: 688
|
|
[Serializable]
|
|
public class MatchCollection : ICollection, IEnumerable
|
|
{
|
|
// Token: 0x06001919 RID: 6425 RVA: 0x00055DE4 File Offset: 0x00053FE4
|
|
internal MatchCollection(Match start)
|
|
{
|
|
this.current = start;
|
|
this.list = new ArrayList();
|
|
}
|
|
|
|
/// <summary>Gets the number of matches.</summary>
|
|
/// <returns>The number of matches.</returns>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x170007E1 RID: 2017
|
|
// (get) Token: 0x0600191A RID: 6426 RVA: 0x00055E00 File Offset: 0x00054000
|
|
public int Count
|
|
{
|
|
get
|
|
{
|
|
return this.FullList.Count;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value that indicates whether the collection is read only.</summary>
|
|
/// <returns>This value of this property is always true.</returns>
|
|
// Token: 0x170007E2 RID: 2018
|
|
// (get) Token: 0x0600191B RID: 6427 RVA: 0x00055E10 File Offset: 0x00054010
|
|
public bool IsReadOnly
|
|
{
|
|
get
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether access to the collection is synchronized (thread-safe).</summary>
|
|
/// <returns>The value of this property is always false.</returns>
|
|
// Token: 0x170007E3 RID: 2019
|
|
// (get) Token: 0x0600191C RID: 6428 RVA: 0x00055E14 File Offset: 0x00054014
|
|
public bool IsSynchronized
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets an individual member of the collection.</summary>
|
|
/// <returns>The captured substring at position <paramref name="i" /> in the collection.</returns>
|
|
/// <param name="i">Index into the Match collection. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="i" /> is less than 0 or greater than or equal to <see cref="P:System.Text.RegularExpressions.MatchCollection.Count" />. </exception>
|
|
// Token: 0x170007E4 RID: 2020
|
|
public virtual Match this[int i]
|
|
{
|
|
get
|
|
{
|
|
if (i < 0 || !this.TryToGet(i))
|
|
{
|
|
throw new ArgumentOutOfRangeException("i");
|
|
}
|
|
return (i >= this.list.Count) ? this.current : ((Match)this.list[i]);
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets an object that can be used to synchronize access to the collection.</summary>
|
|
/// <returns>An object that can be used to synchronize access to the collection. This property always returns the object itself.</returns>
|
|
// Token: 0x170007E5 RID: 2021
|
|
// (get) Token: 0x0600191E RID: 6430 RVA: 0x00055E70 File Offset: 0x00054070
|
|
public object SyncRoot
|
|
{
|
|
get
|
|
{
|
|
return this.list;
|
|
}
|
|
}
|
|
|
|
/// <summary>Copies all the elements of the collection to the given array starting at the given index.</summary>
|
|
/// <param name="array">The array the collection is to be copied into. </param>
|
|
/// <param name="arrayIndex">The position in the array where copying is to begin. </param>
|
|
/// <exception cref="T:System.ArgumentException">
|
|
/// <paramref name="array" /> is a multi-dimensional array.</exception>
|
|
/// <exception cref="T:System.IndexOutOfRangeException">
|
|
/// <paramref name="arrayIndex" /> is outside the bounds of <paramref name="array" />.-or-<paramref name="arrayIndex" /> plus <see cref="P:System.Text.RegularExpressions.GroupCollection.Count" /> is outside the bounds of <paramref name="array" />.</exception>
|
|
// Token: 0x0600191F RID: 6431 RVA: 0x00055E78 File Offset: 0x00054078
|
|
public void CopyTo(Array array, int index)
|
|
{
|
|
this.FullList.CopyTo(array, index);
|
|
}
|
|
|
|
/// <summary>Provides an enumerator in the same order as <see cref="P:System.Text.RegularExpressions.MatchCollection.Item(System.Int32)" />.</summary>
|
|
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> object that contains all Match objects within the MatchCollection.</returns>
|
|
// Token: 0x06001920 RID: 6432 RVA: 0x00055E88 File Offset: 0x00054088
|
|
public IEnumerator GetEnumerator()
|
|
{
|
|
IEnumerator enumerator2;
|
|
if (this.current.Success)
|
|
{
|
|
IEnumerator enumerator = new MatchCollection.Enumerator(this);
|
|
enumerator2 = enumerator;
|
|
}
|
|
else
|
|
{
|
|
enumerator2 = this.list.GetEnumerator();
|
|
}
|
|
return enumerator2;
|
|
}
|
|
|
|
// Token: 0x06001921 RID: 6433 RVA: 0x00055EC0 File Offset: 0x000540C0
|
|
private bool TryToGet(int i)
|
|
{
|
|
while (i > this.list.Count && this.current.Success)
|
|
{
|
|
this.list.Add(this.current);
|
|
this.current = this.current.NextMatch();
|
|
}
|
|
return i < this.list.Count || this.current.Success;
|
|
}
|
|
|
|
// Token: 0x170007E6 RID: 2022
|
|
// (get) Token: 0x06001922 RID: 6434 RVA: 0x00055F38 File Offset: 0x00054138
|
|
private ICollection FullList
|
|
{
|
|
get
|
|
{
|
|
if (this.TryToGet(2147483647))
|
|
{
|
|
throw new SystemException("too many matches");
|
|
}
|
|
return this.list;
|
|
}
|
|
}
|
|
|
|
// Token: 0x040013D0 RID: 5072
|
|
private Match current;
|
|
|
|
// Token: 0x040013D1 RID: 5073
|
|
private ArrayList list;
|
|
|
|
// Token: 0x020002B1 RID: 689
|
|
private class Enumerator : IEnumerator
|
|
{
|
|
// Token: 0x06001923 RID: 6435 RVA: 0x00055F5C File Offset: 0x0005415C
|
|
internal Enumerator(MatchCollection coll)
|
|
{
|
|
this.coll = coll;
|
|
this.index = -1;
|
|
}
|
|
|
|
// Token: 0x06001924 RID: 6436 RVA: 0x00055F74 File Offset: 0x00054174
|
|
void IEnumerator.Reset()
|
|
{
|
|
this.index = -1;
|
|
}
|
|
|
|
// Token: 0x170007E7 RID: 2023
|
|
// (get) Token: 0x06001925 RID: 6437 RVA: 0x00055F80 File Offset: 0x00054180
|
|
object IEnumerator.Current
|
|
{
|
|
get
|
|
{
|
|
if (this.index < 0)
|
|
{
|
|
throw new InvalidOperationException("'Current' called before 'MoveNext()'");
|
|
}
|
|
if (this.index > this.coll.list.Count)
|
|
{
|
|
throw new SystemException("MatchCollection in invalid state");
|
|
}
|
|
if (this.index == this.coll.list.Count && !this.coll.current.Success)
|
|
{
|
|
throw new InvalidOperationException("'Current' called after 'MoveNext()' returned false");
|
|
}
|
|
return (this.index >= this.coll.list.Count) ? this.coll.current : this.coll.list[this.index];
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001926 RID: 6438 RVA: 0x00056048 File Offset: 0x00054248
|
|
bool IEnumerator.MoveNext()
|
|
{
|
|
if (this.index > this.coll.list.Count)
|
|
{
|
|
throw new SystemException("MatchCollection in invalid state");
|
|
}
|
|
return (this.index != this.coll.list.Count || this.coll.current.Success) && this.coll.TryToGet(++this.index);
|
|
}
|
|
|
|
// Token: 0x040013D2 RID: 5074
|
|
private int index;
|
|
|
|
// Token: 0x040013D3 RID: 5075
|
|
private MatchCollection coll;
|
|
}
|
|
}
|
|
}
|