/// <summary> /// Adds the lookup. /// </summary> /// <param name="item">The item.</param> /// <param name="startLocation">The start location.</param> /// <param name="endLocation">The end location.</param> /// <param name="canCoalesce">if set to <c>true</c> [can coalesce].</param> public void AddLookup(RegexItem item, int startLocation, int endLocation, bool canCoalesce) { if (item == null) { throw new ArgumentNullException("item", "RegexItem is null"); } if (this.inseries) { // in a series, add character to the previous one... if (canCoalesce) { RegexRef lastItem = (RegexRef)this.expressionLookup[this.expressionLookup.Count - 1]; lastItem.StringValue += item.ToString(0); lastItem.Length += endLocation - startLocation + 1; } else { this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation)); this.inseries = false; } } else { if (canCoalesce) { this.inseries = true; } this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation)); } }
/// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than obj. Zero This instance is equal to obj. Greater than zero This instance is greater than obj. /// </returns> /// <exception cref="T:System.ArgumentException">obj is not the same type as this instance. </exception> public int CompareTo(object obj) { RegexRef ref2 = (RegexRef)obj; if (this.Length < ref2.Length) { return(-1); } return(this.Length > ref2.Length ? 1 : 0); }