Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Enumerables / ParallelQuery.cs / 1305376 / ParallelQuery.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // ParallelQuery.cs // //[....] // // ParallelQuery is an abstract class that represents a PLINQ query. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; using System.Linq.Parallel; using System.Diagnostics.Contracts; namespace System.Linq { ////// Represents a parallel sequence. /// public class ParallelQuery : IEnumerable { // Settings that have been specified on the query so far. private QuerySettings m_specifiedSettings; internal ParallelQuery(QuerySettings specifiedSettings) { m_specifiedSettings = specifiedSettings; } //------------------------------------------------------------------------------------ // Settings that have been specified on the query so far. Some settings may still // be unspecified and will be replaced either by operators further in the query, // or filled in with defaults at query opening time. // internal QuerySettings SpecifiedQuerySettings { get { return m_specifiedSettings; } } //----------------------------------------------------------------------------------- // Returns a parallel enumerable that represents 'this' enumerable, with each element // casted to TCastTo. If some element is not of type TCastTo, InvalidCastException // is thrown. // internal virtual ParallelQueryCast () { Contract.Assert(false, "The derived class must override this method."); throw new NotSupportedException(); } //----------------------------------------------------------------------------------- // Returns a parallel enumerable that represents 'this' enumerable, with each element // casted to TCastTo. Elements that are not of type TCastTo will be left out from // the results. // internal virtual ParallelQuery OfType () { Contract.Assert(false, "The derived class must override this method."); throw new NotSupportedException(); } //----------------------------------------------------------------------------------- // Derived classes implement GetEnumeratorUntyped() instead of IEnumerable.GetEnumerator() // This is to avoid the method name conflict if the derived classes also implement // IEnumerable . // internal virtual IEnumerator GetEnumeratorUntyped() { Contract.Assert(false, "The derived class must override this method."); throw new NotSupportedException(); } /// /// Returns an enumerator that iterates through the sequence. /// ///An enumerator that iterates through the sequence. IEnumerator IEnumerable.GetEnumerator() { return GetEnumeratorUntyped(); } } ////// Represents a parallel sequence. /// public class ParallelQuery: ParallelQuery, IEnumerable { internal ParallelQuery(QuerySettings settings) : base(settings) { } internal sealed override ParallelQuery Cast () { return ParallelEnumerable.Select (this, elem => (TCastTo)(object)elem); } internal sealed override ParallelQuery OfType () { // @PERF: Currently defined in terms of other operators. This isn't the most performant // solution (because it results in two operators) but is simple to implement. return this .Where (elem => elem is TCastTo) .Select (elem => (TCastTo)(object)elem); } internal override IEnumerator GetEnumeratorUntyped() { return ((IEnumerable )this).GetEnumerator(); } /// /// Returns an enumerator that iterates through the sequence. /// ///An enumerator that iterates through the sequence. public virtual IEnumeratorGetEnumerator() { Contract.Assert(false, "The derived class must override this method."); throw new NotSupportedException(); } } } // 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
- ISSmlParser.cs
- NativeMethods.cs
- LiteralSubsegment.cs
- NumberSubstitution.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- WindowsFormsHostPropertyMap.cs
- ApplicationSecurityManager.cs
- DrawingContext.cs
- OracleBFile.cs
- FilteredSchemaElementLookUpTable.cs
- WebPartDisplayModeCollection.cs
- WindowShowOrOpenTracker.cs
- TextEditorParagraphs.cs
- SchemaReference.cs
- SmiRecordBuffer.cs
- XDRSchema.cs
- WorkerRequest.cs
- ObjectDataSource.cs
- InteropAutomationProvider.cs
- DataStreams.cs
- AccessDataSourceView.cs
- WindowsAuthenticationEventArgs.cs
- CodeDomSerializationProvider.cs
- Point3D.cs
- ResourceDescriptionAttribute.cs
- XmlTextEncoder.cs
- ThreadAttributes.cs
- Boolean.cs
- TextBoxRenderer.cs
- LocalizabilityAttribute.cs
- DrawingDrawingContext.cs
- CodeRegionDirective.cs
- Atom10ItemFormatter.cs
- RoleGroupCollection.cs
- ACL.cs
- QilFunction.cs
- MarkupExtensionSerializer.cs
- XPathDescendantIterator.cs
- SqlDataReaderSmi.cs
- RelatedView.cs
- WorkflowEventArgs.cs
- ArraySubsetEnumerator.cs
- ConstraintManager.cs
- DefaultValueAttribute.cs
- Operand.cs
- StatusStrip.cs
- WebPartUserCapability.cs
- safePerfProviderHandle.cs
- CreateRefExpr.cs
- Parameter.cs
- DateTimeConverter.cs
- AdCreatedEventArgs.cs
- WorkflowInspectionServices.cs
- ProtocolsConfigurationHandler.cs
- MeshGeometry3D.cs
- Vars.cs
- ChildrenQuery.cs
- HashMembershipCondition.cs
- XmlDigitalSignatureProcessor.cs
- Subtree.cs
- ThousandthOfEmRealDoubles.cs
- ClickablePoint.cs
- CodeTypeReferenceExpression.cs
- tabpagecollectioneditor.cs
- HtmlForm.cs
- PageFunction.cs
- TextServicesLoader.cs
- HyperLinkColumn.cs
- PersistChildrenAttribute.cs
- AssemblySettingAttributes.cs
- Frame.cs
- DecoderExceptionFallback.cs
- XmlBinaryReaderSession.cs
- SectionRecord.cs
- ProtocolsConfigurationEntry.cs
- cookiecontainer.cs
- Vector3DAnimation.cs
- ExternalDataExchangeClient.cs
- SizeConverter.cs
- PeerCollaboration.cs
- ListDataBindEventArgs.cs
- EntityProviderFactory.cs
- WindowsSysHeader.cs
- EdmSchemaAttribute.cs
- CodeCompileUnit.cs
- DynamicHyperLink.cs
- HttpModuleActionCollection.cs
- HashRepartitionEnumerator.cs
- sqlpipe.cs
- ContractTypeNameCollection.cs
- SmtpAuthenticationManager.cs
- ClickablePoint.cs
- AnnotationResource.cs
- XmlValueConverter.cs
- DeclarativeCatalogPartDesigner.cs
- TableAutomationPeer.cs
- XmlDocumentType.cs
- Control.cs
- SqlCommandBuilder.cs
- ConnectionsZone.cs