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
- InputScopeConverter.cs
- ByteAnimation.cs
- SerializationAttributes.cs
- PointAnimationBase.cs
- RNGCryptoServiceProvider.cs
- ServiceDescriptionReflector.cs
- OleDbSchemaGuid.cs
- FakeModelPropertyImpl.cs
- SrgsDocument.cs
- TextElementCollection.cs
- ImmComposition.cs
- CodeActivityMetadata.cs
- ComponentChangingEvent.cs
- DecoratedNameAttribute.cs
- DataKeyArray.cs
- RTLAwareMessageBox.cs
- DesignTimeVisibleAttribute.cs
- SiteMapNode.cs
- TileBrush.cs
- InternalDispatchObject.cs
- SerializationAttributes.cs
- CLSCompliantAttribute.cs
- SamlAttributeStatement.cs
- Utils.cs
- CultureTableRecord.cs
- RenderingBiasValidation.cs
- Material.cs
- TextParagraphProperties.cs
- ListDesigner.cs
- FamilyMap.cs
- Model3D.cs
- odbcmetadatacollectionnames.cs
- XamlInt32CollectionSerializer.cs
- ParenthesizePropertyNameAttribute.cs
- ModelTreeEnumerator.cs
- ResourceReferenceExpressionConverter.cs
- WinFormsUtils.cs
- DataServiceClientException.cs
- DeobfuscatingStream.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- EndpointAddress10.cs
- DesignerDataColumn.cs
- StructuralCache.cs
- _PooledStream.cs
- TypeConverterAttribute.cs
- InputScopeNameConverter.cs
- httpstaticobjectscollection.cs
- ErrorFormatter.cs
- QilUnary.cs
- URL.cs
- TransactionContextValidator.cs
- XmlSchemaAttributeGroup.cs
- connectionpool.cs
- RegisteredArrayDeclaration.cs
- ToolStripContentPanel.cs
- Serializer.cs
- GPPOINT.cs
- Binding.cs
- DataGridViewCellLinkedList.cs
- ProcessModelInfo.cs
- FacetValues.cs
- DbDataAdapter.cs
- ThemeInfoAttribute.cs
- X509CertificateClaimSet.cs
- JsonWriter.cs
- XsltInput.cs
- HttpCapabilitiesSectionHandler.cs
- UrlPath.cs
- ModuleBuilder.cs
- ZipIOExtraFieldPaddingElement.cs
- DateTimeConverter.cs
- ToolStripDesigner.cs
- CompositeFontInfo.cs
- TimeoutException.cs
- ControlUtil.cs
- XmlNavigatorStack.cs
- ReadOnlyActivityGlyph.cs
- BoolExpr.cs
- ColumnCollection.cs
- AsyncPostBackErrorEventArgs.cs
- ValidationResults.cs
- ClassData.cs
- TypeInitializationException.cs
- FormatVersion.cs
- LineVisual.cs
- DescendantOverDescendantQuery.cs
- FilteredDataSetHelper.cs
- BuildManagerHost.cs
- Semaphore.cs
- IpcClientChannel.cs
- WinEventHandler.cs
- RijndaelManagedTransform.cs
- TextUtf8RawTextWriter.cs
- _FixedSizeReader.cs
- BoundsDrawingContextWalker.cs
- VerificationAttribute.cs
- SecurityException.cs
- _NtlmClient.cs
- ProcessModelInfo.cs
- ToggleProviderWrapper.cs