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
- AuthorizationRule.cs
- DataGridRowHeader.cs
- ManifestSignedXml.cs
- MessageBox.cs
- GiveFeedbackEvent.cs
- MaterializeFromAtom.cs
- ExpressionBuilder.cs
- ClipboardData.cs
- GridView.cs
- TextSerializer.cs
- XslUrlEditor.cs
- RefExpr.cs
- EDesignUtil.cs
- securitycriticaldataClass.cs
- PropertyGeneratedEventArgs.cs
- MembershipSection.cs
- xmlfixedPageInfo.cs
- MultiBindingExpression.cs
- Knowncolors.cs
- SoapInteropTypes.cs
- BitmapPalette.cs
- AttributeCollection.cs
- HostingPreferredMapPath.cs
- TraceLog.cs
- ChannelManagerService.cs
- DesignerAttributeInfo.cs
- SoundPlayerAction.cs
- SafeHandles.cs
- ColorKeyFrameCollection.cs
- UIElementHelper.cs
- AccessText.cs
- TaskHelper.cs
- XmlSchemaDatatype.cs
- OpenFileDialog.cs
- returneventsaver.cs
- Debug.cs
- ThemeDirectoryCompiler.cs
- DataTableReader.cs
- AddInController.cs
- VBCodeProvider.cs
- ExcCanonicalXml.cs
- SqlBulkCopyColumnMappingCollection.cs
- TriState.cs
- LinkedList.cs
- AttachedPropertyBrowsableAttribute.cs
- Renderer.cs
- formatter.cs
- WinCategoryAttribute.cs
- EntityDataSourceChangingEventArgs.cs
- DynamicQueryStringParameter.cs
- DataErrorValidationRule.cs
- DataGridRowHeaderAutomationPeer.cs
- XDeferredAxisSource.cs
- DeviceFilterDictionary.cs
- parserscommon.cs
- MetabaseReader.cs
- CommonXSendMessage.cs
- NetworkInterface.cs
- DataGridViewRowEventArgs.cs
- SHA512.cs
- Roles.cs
- XPathSingletonIterator.cs
- GenerateScriptTypeAttribute.cs
- EntityConnection.cs
- StorageComplexPropertyMapping.cs
- ObjectDataSource.cs
- XmlCountingReader.cs
- ErrorWebPart.cs
- DataKey.cs
- httpserverutility.cs
- CapabilitiesState.cs
- OracleFactory.cs
- AuthenticationModulesSection.cs
- XmlDataDocument.cs
- MenuItemBindingCollection.cs
- InvalidEnumArgumentException.cs
- RegularExpressionValidator.cs
- AccessViolationException.cs
- InstanceDataCollection.cs
- DefaultClaimSet.cs
- XmlAtomicValue.cs
- WebRequestModulesSection.cs
- PowerModeChangedEventArgs.cs
- ExtendLockAsyncResult.cs
- AvTrace.cs
- TextLine.cs
- XmlDataSource.cs
- NonceCache.cs
- SpellCheck.cs
- Animatable.cs
- HMACRIPEMD160.cs
- SQLByte.cs
- CultureSpecificCharacterBufferRange.cs
- ItemCollection.cs
- TableLayoutColumnStyleCollection.cs
- OciEnlistContext.cs
- CodeAttachEventStatement.cs
- UIElementCollection.cs
- WebPartEditorOkVerb.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs