Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Enumerables / EmptyEnumerable.cs / 1305376 / EmptyEnumerable.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // EmptyEnumerable.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; namespace System.Linq.Parallel { ////// We occ----ionally need a no-op enumerator to stand-in when we don't have data left /// within a partition's data stream. These are simple enumerable and enumerator /// implementations that always and consistently yield no elements. /// ///internal class EmptyEnumerable : ParallelQuery { private EmptyEnumerable() : base(QuerySettings.Empty) { } // A singleton cached and shared among callers. private static EmptyEnumerable s_instance; private static EmptyEnumerator s_enumeratorInstance; internal static EmptyEnumerable Instance { get { if (s_instance == null) { // There is no need for thread safety here. s_instance = new EmptyEnumerable (); } return s_instance; } } public override IEnumerator GetEnumerator() { if (s_enumeratorInstance == null) { // There is no need for thread safety here. s_enumeratorInstance = new EmptyEnumerator (); } return s_enumeratorInstance; } } internal class EmptyEnumerator : QueryOperatorEnumerator , IEnumerator { internal override bool MoveNext(ref T currentElement, ref int currentKey) { return false; } // IEnumerator methods. public T Current { get { return default(T); } } object IEnumerator.Current { get { return null; } } public bool MoveNext() { return false; } void Collections.IEnumerator.Reset() { } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // EmptyEnumerable.cs // // [....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; namespace System.Linq.Parallel { ////// We occ----ionally need a no-op enumerator to stand-in when we don't have data left /// within a partition's data stream. These are simple enumerable and enumerator /// implementations that always and consistently yield no elements. /// ///internal class EmptyEnumerable : ParallelQuery { private EmptyEnumerable() : base(QuerySettings.Empty) { } // A singleton cached and shared among callers. private static EmptyEnumerable s_instance; private static EmptyEnumerator s_enumeratorInstance; internal static EmptyEnumerable Instance { get { if (s_instance == null) { // There is no need for thread safety here. s_instance = new EmptyEnumerable (); } return s_instance; } } public override IEnumerator GetEnumerator() { if (s_enumeratorInstance == null) { // There is no need for thread safety here. s_enumeratorInstance = new EmptyEnumerator (); } return s_enumeratorInstance; } } internal class EmptyEnumerator : QueryOperatorEnumerator , IEnumerator { internal override bool MoveNext(ref T currentElement, ref int currentKey) { return false; } // IEnumerator methods. public T Current { get { return default(T); } } object IEnumerator.Current { get { return null; } } public bool MoveNext() { return false; } void Collections.IEnumerator.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
- cryptoapiTransform.cs
- OpCodes.cs
- CodeArrayIndexerExpression.cs
- GlyphShapingProperties.cs
- StringSource.cs
- Directory.cs
- SourceItem.cs
- NavigationCommands.cs
- BuildProviderCollection.cs
- GB18030Encoding.cs
- UndoUnit.cs
- LogicalTreeHelper.cs
- Hex.cs
- ResourcesBuildProvider.cs
- FocusWithinProperty.cs
- ISAPIWorkerRequest.cs
- GlobalEventManager.cs
- TcpConnectionPool.cs
- ReachObjectContext.cs
- MasterPageParser.cs
- DiagnosticStrings.cs
- SystemIPInterfaceProperties.cs
- ZoneButton.cs
- UpdateTracker.cs
- WindowsFormsHostPropertyMap.cs
- TypeBuilder.cs
- BitmapMetadataBlob.cs
- RemoveStoryboard.cs
- GraphicsPath.cs
- AddingNewEventArgs.cs
- AssociationType.cs
- FormViewModeEventArgs.cs
- FlowDocumentPaginator.cs
- RightsManagementInformation.cs
- SMSvcHost.cs
- ReachPageContentCollectionSerializerAsync.cs
- ConstructorNeedsTagAttribute.cs
- GroupBox.cs
- RequestBringIntoViewEventArgs.cs
- GifBitmapDecoder.cs
- KeyEventArgs.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- AutomationEventArgs.cs
- HttpClientCertificate.cs
- EventPrivateKey.cs
- CharacterBufferReference.cs
- SelectionEditingBehavior.cs
- Dictionary.cs
- BookmarkList.cs
- MenuCommand.cs
- BaseDataBoundControl.cs
- SkipStoryboardToFill.cs
- Dynamic.cs
- LocalServiceSecuritySettings.cs
- TypeLoadException.cs
- SqlConnectionFactory.cs
- SchemaLookupTable.cs
- RectangleGeometry.cs
- PointCollectionConverter.cs
- VisualTreeHelper.cs
- ApplicationHost.cs
- RequestBringIntoViewEventArgs.cs
- QualifierSet.cs
- RadioButtonStandardAdapter.cs
- RichTextBoxContextMenu.cs
- unsafenativemethodsother.cs
- HttpHeaderCollection.cs
- WmlListAdapter.cs
- FontNameEditor.cs
- SponsorHelper.cs
- DesignTimeHTMLTextWriter.cs
- PipelineDeploymentState.cs
- DataGridLinkButton.cs
- filewebresponse.cs
- QueryExpr.cs
- PolicyValidationException.cs
- ObjectStateFormatter.cs
- RenderOptions.cs
- InternalMappingException.cs
- SrgsSubset.cs
- RowUpdatingEventArgs.cs
- panel.cs
- CounterCreationDataCollection.cs
- MenuItemStyle.cs
- ChtmlTextWriter.cs
- DbSourceCommand.cs
- SizeFConverter.cs
- StylusEventArgs.cs
- LinqDataSourceUpdateEventArgs.cs
- mactripleDES.cs
- PropertyConverter.cs
- WebPartZoneBaseDesigner.cs
- ClientUrlResolverWrapper.cs
- CompilerParameters.cs
- ContextMarshalException.cs
- Descriptor.cs
- EntityConnection.cs
- SmtpTransport.cs
- TypeConverterAttribute.cs
- ObjectDataSource.cs