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
- TransformGroup.cs
- ComplexBindingPropertiesAttribute.cs
- DataBoundLiteralControl.cs
- WindowsScrollBarBits.cs
- ResourceReferenceExpression.cs
- OleDbStruct.cs
- ExclusiveHandleList.cs
- VirtualDirectoryMapping.cs
- SimpleHandlerBuildProvider.cs
- SecurityPermission.cs
- DashStyle.cs
- HostingEnvironment.cs
- VisualBasicHelper.cs
- __Filters.cs
- EmbeddedMailObjectCollectionEditor.cs
- FormatPage.cs
- HttpRequest.cs
- SocketAddress.cs
- NetNamedPipeBindingCollectionElement.cs
- UpdatePanelTrigger.cs
- StringSource.cs
- LoginUtil.cs
- CompilerErrorCollection.cs
- SpeechUI.cs
- Size3D.cs
- InvalidEnumArgumentException.cs
- BitmapEffectInput.cs
- DurationConverter.cs
- Transform3DGroup.cs
- returneventsaver.cs
- wgx_commands.cs
- DataGridViewRowCancelEventArgs.cs
- CollectionChangedEventManager.cs
- XmlQualifiedNameTest.cs
- WebZone.cs
- BaseParser.cs
- RenderTargetBitmap.cs
- ScalarConstant.cs
- Internal.cs
- TypedDatasetGenerator.cs
- ListArgumentProvider.cs
- PrefixQName.cs
- ApplicationBuildProvider.cs
- MatrixUtil.cs
- LineInfo.cs
- RewritingValidator.cs
- PropertyCondition.cs
- coordinator.cs
- BeginStoryboard.cs
- EventLog.cs
- ExtensionCollection.cs
- WmpBitmapDecoder.cs
- OAVariantLib.cs
- ManipulationLogic.cs
- ResourceWriter.cs
- FormsAuthenticationConfiguration.cs
- OwnerDrawPropertyBag.cs
- QueueAccessMode.cs
- MetadataResolver.cs
- RoutedCommand.cs
- MarkupExtensionParser.cs
- SamlAction.cs
- ScriptManagerProxy.cs
- AvTraceDetails.cs
- MessageHeaders.cs
- EpmContentDeSerializerBase.cs
- RecognizerInfo.cs
- StylusDevice.cs
- HttpHandlersSection.cs
- Grid.cs
- MetadataPropertyvalue.cs
- User.cs
- AudioDeviceOut.cs
- TextElementEnumerator.cs
- StringFreezingAttribute.cs
- WindowsAuthenticationModule.cs
- addressfiltermode.cs
- GridLengthConverter.cs
- ZipFileInfoCollection.cs
- SqlErrorCollection.cs
- ActiveXHost.cs
- ArraySortHelper.cs
- Thumb.cs
- ListCollectionView.cs
- PeerCollaboration.cs
- ResXBuildProvider.cs
- RemoveStoryboard.cs
- AccessControlEntry.cs
- UpDownEvent.cs
- InputChannelAcceptor.cs
- COAUTHINFO.cs
- MaskDescriptors.cs
- ArraySubsetEnumerator.cs
- URLString.cs
- SchemaImporterExtensionElement.cs
- ObjectCache.cs
- GeometryDrawing.cs
- NonVisualControlAttribute.cs
- AnnotationAuthorChangedEventArgs.cs
- CFGGrammar.cs