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
- Int64AnimationUsingKeyFrames.cs
- TabControl.cs
- SamlAuthenticationClaimResource.cs
- TypeToken.cs
- ColumnHeader.cs
- HtmlTableRow.cs
- WebPartActionVerb.cs
- DiscriminatorMap.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- PropertyGridView.cs
- WebRequestModuleElementCollection.cs
- PolicyImporterElement.cs
- GcSettings.cs
- ControlCollection.cs
- HtmlGenericControl.cs
- DateTimeSerializationSection.cs
- ReflectEventDescriptor.cs
- PointLight.cs
- ObjectDataSource.cs
- SqlFormatter.cs
- ErrorActivity.cs
- ExpressionEditorAttribute.cs
- documentsequencetextcontainer.cs
- MasterPageParser.cs
- AsymmetricKeyExchangeDeformatter.cs
- MenuStrip.cs
- PartialCachingControl.cs
- SelectionProcessor.cs
- XmlSchemaObject.cs
- PolyLineSegment.cs
- SizeChangedEventArgs.cs
- MetaForeignKeyColumn.cs
- RotateTransform3D.cs
- RsaSecurityKey.cs
- columnmapfactory.cs
- EnumUnknown.cs
- FilteredXmlReader.cs
- XmlCharCheckingWriter.cs
- CalendarTable.cs
- DuplexChannelFactory.cs
- StreamWithDictionary.cs
- ProtocolElementCollection.cs
- CodeObjectCreateExpression.cs
- SharedPerformanceCounter.cs
- PasswordDeriveBytes.cs
- ConstructorExpr.cs
- XmlText.cs
- AddInSegmentDirectoryNotFoundException.cs
- DesignerAttribute.cs
- OSFeature.cs
- BuildProviderUtils.cs
- ExpressionBuilderCollection.cs
- HandleExceptionArgs.cs
- TextRenderingModeValidation.cs
- SyndicationDeserializer.cs
- ProfileModule.cs
- ParameterToken.cs
- XsltConvert.cs
- PanelContainerDesigner.cs
- CaretElement.cs
- ServiceObjectContainer.cs
- BitmapEffectGroup.cs
- FontWeight.cs
- CorrelationTokenInvalidatedHandler.cs
- DockPanel.cs
- SelectedDatesCollection.cs
- Geometry3D.cs
- NumberFormatInfo.cs
- ListViewCommandEventArgs.cs
- RoleGroup.cs
- WorkflowRuntime.cs
- ToolStripSplitStackLayout.cs
- MessageBox.cs
- XmlNodeChangedEventArgs.cs
- FlowDocumentReaderAutomationPeer.cs
- BindingUtils.cs
- ExtenderProvidedPropertyAttribute.cs
- AllMembershipCondition.cs
- CatalogPartCollection.cs
- ExpanderAutomationPeer.cs
- SafeCryptContextHandle.cs
- TextTreeText.cs
- DataSourceProvider.cs
- BitmapFrameDecode.cs
- AsnEncodedData.cs
- QueryHandler.cs
- backend.cs
- WebPartVerb.cs
- InkCanvasInnerCanvas.cs
- ImageCodecInfoPrivate.cs
- DataGridViewTopRowAccessibleObject.cs
- AccessorTable.cs
- HtmlAnchor.cs
- Itemizer.cs
- SourceElementsCollection.cs
- ItemContainerProviderWrapper.cs
- EntryIndex.cs
- SecurityValidationBehavior.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- StringArrayEditor.cs