Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Regex / System / Text / RegularExpressions / RegexCaptureCollection.cs / 1 / RegexCaptureCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
// The CaptureCollection lists the captured Capture numbers
// contained in a compiled Regex.
namespace System.Text.RegularExpressions {
using System.Collections;
/*
* This collection returns the Captures for a group
* in the order in which they were matched (left to right
* or right to left). It is created by Group.Captures
*/
///
///
/// Represents a sequence of capture substrings. The object is used
/// to return the set of captures done by a single capturing group.
///
///
[ Serializable() ]
public class CaptureCollection : ICollection {
internal Group _group;
internal int _capcount;
internal Capture[] _captures;
/*
* Nonpublic constructor
*/
internal CaptureCollection(Group group) {
_group = group;
_capcount = _group._capcount;
}
/*
* The object on which to synchronize
*/
///
/// [To be supplied.]
///
public Object SyncRoot {
get {
return _group;
}
}
/*
* ICollection
*/
///
/// [To be supplied.]
///
public bool IsSynchronized {
get {
return false;
}
}
/*
* ICollection
*/
///
/// [To be supplied.]
///
public bool IsReadOnly {
get {
return true;
}
}
/*
* The number of captures for the group
*/
///
///
/// Returns the number of captures.
///
///
public int Count {
get {
return _capcount;
}
}
/*
* The ith capture in the group
*/
///
///
/// Provides a means of accessing a specific capture in the collection.
///
///
public Capture this[int i]
{
get {
return GetCapture(i);
}
}
/*
* As required by ICollection
*/
///
///
/// Copies all the elements of the collection to the given array
/// beginning at the given index.
///
///
public void CopyTo(Array array, int arrayIndex) {
if (array == null)
throw new ArgumentNullException("array");
for (int i = arrayIndex, j = 0; j < Count; i++, j++) {
array.SetValue(this[j], i);
}
}
/*
* As required by ICollection
*/
///
///
/// Provides an enumerator in the same order as Item[].
///
///
public IEnumerator GetEnumerator() {
return new CaptureEnumerator(this);
}
/*
* Nonpublic code to return set of captures for the group
*/
internal Capture GetCapture(int i) {
if (i == _capcount - 1 && i >= 0)
return _group;
if (i >= _capcount || i < 0)
throw new ArgumentOutOfRangeException("i");
// first time a capture is accessed, compute them all
if (_captures == null) {
_captures = new Capture[_capcount];
for (int j = 0; j < _capcount - 1; j++) {
_captures[j] = new Capture(_group._text, _group._caps[j * 2], _group._caps[j * 2 + 1]);
}
}
return _captures[i];
}
}
/*
* This non-public enumerator lists all the captures
* Should it be public?
*/
[ Serializable() ]
internal class CaptureEnumerator : IEnumerator {
internal CaptureCollection _rcc;
internal int _curindex;
/*
* Nonpublic constructor
*/
internal CaptureEnumerator(CaptureCollection rcc) {
_curindex = -1;
_rcc = rcc;
}
/*
* As required by IEnumerator
*/
public bool MoveNext() {
int size = _rcc.Count;
if (_curindex >= size)
return false;
_curindex++;
return(_curindex < size);
}
/*
* As required by IEnumerator
*/
public Object Current {
get { return Capture;}
}
/*
* Returns the current capture
*/
public Capture Capture {
get {
if (_curindex < 0 || _curindex >= _rcc.Count)
throw new InvalidOperationException(SR.GetString(SR.EnumNotStarted));
return _rcc[_curindex];
}
}
/*
* Reset to before the first item
*/
public void Reset() {
_curindex = -1;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
// The CaptureCollection lists the captured Capture numbers
// contained in a compiled Regex.
namespace System.Text.RegularExpressions {
using System.Collections;
/*
* This collection returns the Captures for a group
* in the order in which they were matched (left to right
* or right to left). It is created by Group.Captures
*/
///
///
/// Represents a sequence of capture substrings. The object is used
/// to return the set of captures done by a single capturing group.
///
///
[ Serializable() ]
public class CaptureCollection : ICollection {
internal Group _group;
internal int _capcount;
internal Capture[] _captures;
/*
* Nonpublic constructor
*/
internal CaptureCollection(Group group) {
_group = group;
_capcount = _group._capcount;
}
/*
* The object on which to synchronize
*/
///
/// [To be supplied.]
///
public Object SyncRoot {
get {
return _group;
}
}
/*
* ICollection
*/
///
/// [To be supplied.]
///
public bool IsSynchronized {
get {
return false;
}
}
/*
* ICollection
*/
///
/// [To be supplied.]
///
public bool IsReadOnly {
get {
return true;
}
}
/*
* The number of captures for the group
*/
///
///
/// Returns the number of captures.
///
///
public int Count {
get {
return _capcount;
}
}
/*
* The ith capture in the group
*/
///
///
/// Provides a means of accessing a specific capture in the collection.
///
///
public Capture this[int i]
{
get {
return GetCapture(i);
}
}
/*
* As required by ICollection
*/
///
///
/// Copies all the elements of the collection to the given array
/// beginning at the given index.
///
///
public void CopyTo(Array array, int arrayIndex) {
if (array == null)
throw new ArgumentNullException("array");
for (int i = arrayIndex, j = 0; j < Count; i++, j++) {
array.SetValue(this[j], i);
}
}
/*
* As required by ICollection
*/
///
///
/// Provides an enumerator in the same order as Item[].
///
///
public IEnumerator GetEnumerator() {
return new CaptureEnumerator(this);
}
/*
* Nonpublic code to return set of captures for the group
*/
internal Capture GetCapture(int i) {
if (i == _capcount - 1 && i >= 0)
return _group;
if (i >= _capcount || i < 0)
throw new ArgumentOutOfRangeException("i");
// first time a capture is accessed, compute them all
if (_captures == null) {
_captures = new Capture[_capcount];
for (int j = 0; j < _capcount - 1; j++) {
_captures[j] = new Capture(_group._text, _group._caps[j * 2], _group._caps[j * 2 + 1]);
}
}
return _captures[i];
}
}
/*
* This non-public enumerator lists all the captures
* Should it be public?
*/
[ Serializable() ]
internal class CaptureEnumerator : IEnumerator {
internal CaptureCollection _rcc;
internal int _curindex;
/*
* Nonpublic constructor
*/
internal CaptureEnumerator(CaptureCollection rcc) {
_curindex = -1;
_rcc = rcc;
}
/*
* As required by IEnumerator
*/
public bool MoveNext() {
int size = _rcc.Count;
if (_curindex >= size)
return false;
_curindex++;
return(_curindex < size);
}
/*
* As required by IEnumerator
*/
public Object Current {
get { return Capture;}
}
/*
* Returns the current capture
*/
public Capture Capture {
get {
if (_curindex < 0 || _curindex >= _rcc.Count)
throw new InvalidOperationException(SR.GetString(SR.EnumNotStarted));
return _rcc[_curindex];
}
}
/*
* Reset to before the first item
*/
public void Reset() {
_curindex = -1;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ServiceEndpoint.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- OutputCacheSettings.cs
- UserNamePasswordValidator.cs
- CompiledIdentityConstraint.cs
- NameValueConfigurationElement.cs
- GenericTextProperties.cs
- TextControl.cs
- VectorConverter.cs
- TemplateControlParser.cs
- GuidelineCollection.cs
- ColorConverter.cs
- Char.cs
- RenderDataDrawingContext.cs
- ConfigXmlElement.cs
- OperandQuery.cs
- StylusPointPropertyInfoDefaults.cs
- TriggerAction.cs
- NonParentingControl.cs
- Identity.cs
- ContractListAdapter.cs
- ExclusiveCanonicalizationTransform.cs
- ServiceSecurityAuditBehavior.cs
- SqlError.cs
- QueueProcessor.cs
- MetabaseSettingsIis7.cs
- OptimizedTemplateContentHelper.cs
- PenLineJoinValidation.cs
- EdgeModeValidation.cs
- TransactionalPackage.cs
- XmlSchemaSimpleContent.cs
- Scene3D.cs
- XmlStreamStore.cs
- ByteConverter.cs
- Base64Stream.cs
- SwitchAttribute.cs
- SystemColors.cs
- RelationshipConverter.cs
- Wizard.cs
- DockAndAnchorLayout.cs
- KeysConverter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- CroppedBitmap.cs
- HotSpot.cs
- AnnotationStore.cs
- SizeChangedInfo.cs
- JobDuplex.cs
- AbandonedMutexException.cs
- ContextBase.cs
- CodeAttributeDeclarationCollection.cs
- XmlElementAttributes.cs
- SQLDateTime.cs
- DataAdapter.cs
- SequentialActivityDesigner.cs
- SafeArrayRankMismatchException.cs
- WhitespaceRuleLookup.cs
- BitmapEffect.cs
- SerializerProvider.cs
- TableCell.cs
- OleDbParameter.cs
- LookupNode.cs
- EntityProviderServices.cs
- AttachedAnnotationChangedEventArgs.cs
- AuthenticationModulesSection.cs
- QilLiteral.cs
- UTF8Encoding.cs
- KeyedHashAlgorithm.cs
- CacheDependency.cs
- EntityDataSource.cs
- DataContractJsonSerializerOperationFormatter.cs
- Matrix3DConverter.cs
- ColorBlend.cs
- DockPatternIdentifiers.cs
- baseshape.cs
- TabOrder.cs
- SpotLight.cs
- NonSerializedAttribute.cs
- WinEventQueueItem.cs
- SourceFilter.cs
- ListDictionaryInternal.cs
- DocumentSequenceHighlightLayer.cs
- IpcPort.cs
- ActivityExecutionFilter.cs
- TableRow.cs
- Tuple.cs
- SizeAnimationUsingKeyFrames.cs
- MemoryRecordBuffer.cs
- TemplatePropertyEntry.cs
- DataGridLengthConverter.cs
- ResetableIterator.cs
- HwndMouseInputProvider.cs
- ResourcePermissionBase.cs
- SettingsContext.cs
- GeometryModel3D.cs
- RegionInfo.cs
- SafeProcessHandle.cs
- ToolStripPanelRenderEventArgs.cs
- SqlFactory.cs
- WindowsTreeView.cs
- DocumentReferenceCollection.cs