Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / QueryOperators / QueryOperatorEnumerator.cs / 1305376 / QueryOperatorEnumerator.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // QueryOperatorEnumerator.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; using System.Diagnostics.Contracts; namespace System.Linq.Parallel { ////// A common enumerator type that unifies all query operator enumerators. /// ////// internal abstract class QueryOperatorEnumerator { // Moves the position of the enumerator forward by one, and simultaneously returns // the (new) current element and key. If empty, false is returned. internal abstract bool MoveNext(ref TElement currentElement, ref TKey currentKey); // Standard implementation of the disposable pattern. public void Dispose() { Dispose(true); } protected virtual void Dispose(bool disposing) { // This is a no-op by default. Subclasses can override. } internal virtual void Reset() { // This is a no-op by default. Subclasses can override. } //------------------------------------------------------------------------------------ // A simple way to turn a query operator enumerator into a "classic" one. // internal IEnumerator AsClassicEnumerator() { return new QueryOperatorClassicEnumerator(this); } class QueryOperatorClassicEnumerator : IEnumerator { private QueryOperatorEnumerator m_operatorEnumerator; private TElement m_current; internal QueryOperatorClassicEnumerator(QueryOperatorEnumerator operatorEnumerator) { Contract.Assert(operatorEnumerator != null); m_operatorEnumerator = operatorEnumerator; } public bool MoveNext() { TKey keyUnused = default(TKey); return m_operatorEnumerator.MoveNext(ref m_current, ref keyUnused); } public TElement Current { get { return m_current; } } object IEnumerator.Current { get { return m_current; } } public void Dispose() { m_operatorEnumerator.Dispose(); m_operatorEnumerator = null; } public void Reset() { m_operatorEnumerator.Reset(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // QueryOperatorEnumerator.cs // // [....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; using System.Diagnostics.Contracts; namespace System.Linq.Parallel { ////// A common enumerator type that unifies all query operator enumerators. /// ////// internal abstract class QueryOperatorEnumerator { // Moves the position of the enumerator forward by one, and simultaneously returns // the (new) current element and key. If empty, false is returned. internal abstract bool MoveNext(ref TElement currentElement, ref TKey currentKey); // Standard implementation of the disposable pattern. public void Dispose() { Dispose(true); } protected virtual void Dispose(bool disposing) { // This is a no-op by default. Subclasses can override. } internal virtual void Reset() { // This is a no-op by default. Subclasses can override. } //------------------------------------------------------------------------------------ // A simple way to turn a query operator enumerator into a "classic" one. // internal IEnumerator AsClassicEnumerator() { return new QueryOperatorClassicEnumerator(this); } class QueryOperatorClassicEnumerator : IEnumerator { private QueryOperatorEnumerator m_operatorEnumerator; private TElement m_current; internal QueryOperatorClassicEnumerator(QueryOperatorEnumerator operatorEnumerator) { Contract.Assert(operatorEnumerator != null); m_operatorEnumerator = operatorEnumerator; } public bool MoveNext() { TKey keyUnused = default(TKey); return m_operatorEnumerator.MoveNext(ref m_current, ref keyUnused); } public TElement Current { get { return m_current; } } object IEnumerator.Current { get { return m_current; } } public void Dispose() { m_operatorEnumerator.Dispose(); m_operatorEnumerator = null; } public void Reset() { m_operatorEnumerator.Reset(); } } } } // 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
- Boolean.cs
- HtmlContainerControl.cs
- SqlException.cs
- CompModSwitches.cs
- SqlClientWrapperSmiStream.cs
- Models.cs
- DeviceSpecificChoiceCollection.cs
- IndexedEnumerable.cs
- SHA512.cs
- MarkupProperty.cs
- ViewKeyConstraint.cs
- Win32PrintDialog.cs
- CommandManager.cs
- ConfigurationManagerHelperFactory.cs
- SignedXml.cs
- DataBindingCollection.cs
- MimeParameters.cs
- DataGridViewRowCancelEventArgs.cs
- EditorPartCollection.cs
- ComponentChangingEvent.cs
- StateWorkerRequest.cs
- BrowserCapabilitiesFactoryBase.cs
- BaseResourcesBuildProvider.cs
- DownloadProgressEventArgs.cs
- X509Chain.cs
- PkcsMisc.cs
- GridViewEditEventArgs.cs
- XmlSchemaDatatype.cs
- SByte.cs
- Row.cs
- HostedTransportConfigurationManager.cs
- RegexMatchCollection.cs
- LocalizationComments.cs
- Pkcs9Attribute.cs
- WindowsToolbarAsMenu.cs
- SpStreamWrapper.cs
- ProgressChangedEventArgs.cs
- XmlDocumentType.cs
- ThreadPool.cs
- DataErrorValidationRule.cs
- UrlPath.cs
- ListCollectionView.cs
- XamlTypeMapper.cs
- AnnotationMap.cs
- GifBitmapDecoder.cs
- AutomationPropertyInfo.cs
- CompositeActivityTypeDescriptorProvider.cs
- TargetControlTypeAttribute.cs
- ElementMarkupObject.cs
- SslStream.cs
- ExpressionCopier.cs
- RichTextBox.cs
- WsdlBuildProvider.cs
- Module.cs
- SchemaImporterExtensionElementCollection.cs
- PlaceHolder.cs
- ChameleonKey.cs
- SharedUtils.cs
- DeferredReference.cs
- GPPOINTF.cs
- Type.cs
- XPathDocumentNavigator.cs
- PageParser.cs
- XmlSchemaSimpleTypeRestriction.cs
- OptimalTextSource.cs
- Visual3D.cs
- WebHttpSecurityElement.cs
- EpmCustomContentDeSerializer.cs
- HttpPostedFileWrapper.cs
- BufferedGraphics.cs
- ControlAdapter.cs
- ExpressionBuilder.cs
- PagesChangedEventArgs.cs
- DebugViewWriter.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- OrderedDictionaryStateHelper.cs
- ColumnPropertiesGroup.cs
- TypeResolver.cs
- WebSysDisplayNameAttribute.cs
- HtmlInputPassword.cs
- LocalizationParserHooks.cs
- ToolStripItemImageRenderEventArgs.cs
- DataSourceViewSchemaConverter.cs
- ProcessingInstructionAction.cs
- IsolationInterop.cs
- CodeStatementCollection.cs
- DragDrop.cs
- CompilerWrapper.cs
- RecoverInstanceLocksCommand.cs
- _Rfc2616CacheValidators.cs
- VBCodeProvider.cs
- PrimaryKeyTypeConverter.cs
- StateRuntime.cs
- selecteditemcollection.cs
- DataServiceHostWrapper.cs
- IndentedTextWriter.cs
- PropertyPathConverter.cs
- ContainerFilterService.cs
- OrderedEnumerableRowCollection.cs
- UIElement.cs