Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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 */ ////// [ 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 */ ////// Represents a sequence of capture substrings. The object is used /// to return the set of captures done by a single capturing group. /// ////// 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 */ ///[To be supplied.] ////// public int Count { get { return _capcount; } } /* * The ith capture in the group */ ////// Returns the number of captures. /// ////// public Capture this[int i] { get { return GetCapture(i); } } /* * As required by ICollection */ ////// Provides a means of accessing a specific capture in the collection. /// ////// 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 */ ////// Copies all the elements of the collection to the given array /// beginning at the given index. /// ////// 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. //------------------------------------------------------------------------------ ///// Provides an enumerator in the same order as Item[]. /// ///// 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 */ ////// [ 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 */ ////// Represents a sequence of capture substrings. The object is used /// to return the set of captures done by a single capturing group. /// ////// 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 */ ///[To be supplied.] ////// public int Count { get { return _capcount; } } /* * The ith capture in the group */ ////// Returns the number of captures. /// ////// public Capture this[int i] { get { return GetCapture(i); } } /* * As required by ICollection */ ////// Provides a means of accessing a specific capture in the collection. /// ////// 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 */ ////// Copies all the elements of the collection to the given array /// beginning at the given index. /// ////// 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./// Provides an enumerator in the same order as Item[]. /// ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DBSqlParserColumn.cs
- SafeThreadHandle.cs
- iisPickupDirectory.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- RuleSettingsCollection.cs
- ColumnResizeUndoUnit.cs
- RawStylusInputReport.cs
- ContentDisposition.cs
- InstallerTypeAttribute.cs
- VirtualizingPanel.cs
- KeyValuePairs.cs
- TypeSystem.cs
- WaitHandleCannotBeOpenedException.cs
- TokenDescriptor.cs
- ByteAnimationUsingKeyFrames.cs
- TimeSpan.cs
- PriorityBinding.cs
- EpmTargetPathSegment.cs
- StaticResourceExtension.cs
- BlurEffect.cs
- BufferModesCollection.cs
- AudioSignalProblemOccurredEventArgs.cs
- CompiledIdentityConstraint.cs
- MasterPage.cs
- StreamAsIStream.cs
- DecoderFallbackWithFailureFlag.cs
- ListBase.cs
- ScriptingScriptResourceHandlerSection.cs
- DecimalAnimationBase.cs
- LogPolicy.cs
- BamlTreeUpdater.cs
- ImageFormatConverter.cs
- Scripts.cs
- InputDevice.cs
- SqlDataSourceCache.cs
- GeneratedCodeAttribute.cs
- VerticalAlignConverter.cs
- EmptyStringExpandableObjectConverter.cs
- MarshalByValueComponent.cs
- PageSetupDialog.cs
- TreeIterators.cs
- ClientCredentialsElement.cs
- MasterPage.cs
- CryptoKeySecurity.cs
- IncrementalCompileAnalyzer.cs
- CorrelationTokenInvalidatedHandler.cs
- TextRunTypographyProperties.cs
- QilBinary.cs
- TemplatePagerField.cs
- TextEffectResolver.cs
- DataGridViewImageColumn.cs
- TypeDelegator.cs
- TextTreeTextBlock.cs
- OutKeywords.cs
- PeerPresenceInfo.cs
- DataBindingCollection.cs
- ASCIIEncoding.cs
- InvokeHandlers.cs
- CalendarDay.cs
- MouseCaptureWithinProperty.cs
- ResolveDuplexCD1AsyncResult.cs
- ObjRef.cs
- TraceRecord.cs
- XmlText.cs
- SelfIssuedAuthProofToken.cs
- Matrix3DStack.cs
- HtmlInputPassword.cs
- HeaderCollection.cs
- SequenceRangeCollection.cs
- DataGridViewHeaderCell.cs
- ImageFormat.cs
- ExceptionUtility.cs
- NameValueConfigurationElement.cs
- TaskCanceledException.cs
- codemethodreferenceexpression.cs
- Application.cs
- SymbolTable.cs
- HighContrastHelper.cs
- DefaultTextStore.cs
- Font.cs
- CompositeDispatchFormatter.cs
- LinearGradientBrush.cs
- ConsumerConnectionPointCollection.cs
- MultiTrigger.cs
- RadioButtonAutomationPeer.cs
- HtmlDocument.cs
- X509PeerCertificateAuthenticationElement.cs
- Debug.cs
- Compensate.cs
- LineSegment.cs
- TextSpan.cs
- Geometry3D.cs
- SingleConverter.cs
- StringComparer.cs
- basemetadatamappingvisitor.cs
- DynamicResourceExtension.cs
- AutomationPatternInfo.cs
- ReliableReplySessionChannel.cs
- LayoutExceptionEventArgs.cs
- TableLayoutCellPaintEventArgs.cs