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
- FlowDocumentView.cs
- SettingsSection.cs
- ChannelAcceptor.cs
- Literal.cs
- ToolStripLabel.cs
- ConsumerConnectionPointCollection.cs
- RichTextBoxConstants.cs
- webclient.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- BuildProviderAppliesToAttribute.cs
- DNS.cs
- safesecurityhelperavalon.cs
- GenericTextProperties.cs
- ToolStripContainer.cs
- LocalizableResourceBuilder.cs
- StructuredTypeEmitter.cs
- SettingsAttributes.cs
- OptionalColumn.cs
- RemoveStoryboard.cs
- ParagraphResult.cs
- DetailsViewRow.cs
- QilInvokeLateBound.cs
- CalendarDataBindingHandler.cs
- AutoGeneratedField.cs
- WindowShowOrOpenTracker.cs
- SequentialActivityDesigner.cs
- PrtCap_Reader.cs
- X509Extension.cs
- TraceHandler.cs
- LeaseManager.cs
- EntityDataSourceWizardForm.cs
- ChildrenQuery.cs
- SortKey.cs
- CurrencyWrapper.cs
- GlyphsSerializer.cs
- ChannelCacheDefaults.cs
- DockAndAnchorLayout.cs
- XmlConverter.cs
- DataContractSerializerOperationGenerator.cs
- XmlSchemaComplexType.cs
- DataGridViewElement.cs
- SelectionListComponentEditor.cs
- contentDescriptor.cs
- CounterCreationDataCollection.cs
- TraversalRequest.cs
- XmlSchemaObject.cs
- SecuritySessionClientSettings.cs
- ProfileService.cs
- RequestCacheManager.cs
- ArrayConverter.cs
- ExchangeUtilities.cs
- BamlResourceContent.cs
- AuthenticatedStream.cs
- View.cs
- ProcessModelInfo.cs
- CodeExporter.cs
- SafeNativeHandle.cs
- XPathArrayIterator.cs
- ErrorWrapper.cs
- WorkflowOperationErrorHandler.cs
- Activator.cs
- SQLDateTimeStorage.cs
- XmlCDATASection.cs
- FilterInvalidBodyAccessException.cs
- BehaviorEditorPart.cs
- NeutralResourcesLanguageAttribute.cs
- RoutedEventHandlerInfo.cs
- ProcessingInstructionAction.cs
- X509Utils.cs
- Documentation.cs
- CommonRemoteMemoryBlock.cs
- WCFBuildProvider.cs
- ValidatorUtils.cs
- DBConnection.cs
- FixedSOMImage.cs
- ComplexPropertyEntry.cs
- Button.cs
- BindingOperations.cs
- SectionInput.cs
- baseshape.cs
- DurableRuntimeValidator.cs
- QilVisitor.cs
- ThrowOnMultipleAssignment.cs
- ConnectionManagementSection.cs
- FixedSOMTableRow.cs
- DataSourceCache.cs
- DataSourceExpression.cs
- Debugger.cs
- Filter.cs
- QueryOptionExpression.cs
- WorkflowRuntimeServicesBehavior.cs
- HtmlInputSubmit.cs
- StopStoryboard.cs
- ComplexPropertyEntry.cs
- Attributes.cs
- MaterializeFromAtom.cs
- ToolStripDropDownButton.cs
- ContainerUtilities.cs
- TableLayoutPanelCellPosition.cs
- GridViewRowCollection.cs