Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / QueryOperators / QueryResults.cs / 1305376 / QueryResults.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// QueryResults.cs
//
// [....]
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace System.Linq.Parallel
{
///
/// The QueryResults{T} is a class representing the results of the query. There may
/// be different ways the query results can be manipulated. Currently, two ways are
/// supported:
///
/// 1. Open the query results as a partitioned stream by calling GivePartitionedStream
/// and pass a generic action as an argument.
///
/// 2. Access individual elements of the results list by calling GetElement(index) and
/// ElementsCount. This method of accessing the query results is available only if
/// IsIndexible return true.
///
///
internal abstract class QueryResults : IList
{
//------------------------------------------------------------------------------------
// Gets the query results represented as a partitioned stream. Instead of returning
// the PartitionedStream, we instead call recipient.Receive(...). That way,
// the code that receives the partitioned stream has access to the TKey type.
//
// Arguments:
// recipient - the object that the partitioned stream will be passed to
//
internal abstract void GivePartitionedStream(IPartitionedStreamRecipient recipient);
//-----------------------------------------------------------------------------------
// Returns whether the query results are indexible. If this property is true, the
// user can call GetElement(index) and ElementsCount. If it is false, both
// GetElement(index) and ElementsCount should throw InvalidOperationException.
//
internal virtual bool IsIndexible
{
get { return false; }
}
//-----------------------------------------------------------------------------------
// Returns index-th element in the query results
//
// Assumptions:
// IsIndexible returns true
// 0 <= index < ElementsCount
//
internal virtual T GetElement(int index)
{
Contract.Assert(false, "GetElement property is not supported by non-indexible query results");
throw new NotSupportedException();
}
//-----------------------------------------------------------------------------------
// Returns the number of elements in the query results
//
// Assumptions:
// IsIndexible returns true
//
internal virtual int ElementsCount
{
get
{
Contract.Assert(false, "ElementsCount property is not supported by non-indexible query results");
throw new NotSupportedException();
}
}
//
// An assortment of methods we need to support in order to implement the IList interface
//
int IList.IndexOf(T item)
{
throw new NotSupportedException();
}
void IList.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
public T this[int index]
{
get { return GetElement(index); }
set
{
throw new NotSupportedException();
}
}
void ICollection.Add(T item)
{
throw new NotSupportedException();
}
void ICollection.Clear()
{
throw new NotSupportedException();
}
bool ICollection.Contains(T item)
{
throw new NotSupportedException();
}
void ICollection.CopyTo(T[] array, int arrayIndex)
{
throw new NotSupportedException();
}
public int Count
{
get { return ElementsCount; }
}
bool ICollection.IsReadOnly
{
get { return true; }
}
bool ICollection.Remove(T item)
{
throw new NotSupportedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
for (int index = 0; index < Count; index++)
{
yield return this[index];
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)this).GetEnumerator();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// QueryResults.cs
//
// [....]
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace System.Linq.Parallel
{
///
/// The QueryResults{T} is a class representing the results of the query. There may
/// be different ways the query results can be manipulated. Currently, two ways are
/// supported:
///
/// 1. Open the query results as a partitioned stream by calling GivePartitionedStream
/// and pass a generic action as an argument.
///
/// 2. Access individual elements of the results list by calling GetElement(index) and
/// ElementsCount. This method of accessing the query results is available only if
/// IsIndexible return true.
///
///
internal abstract class QueryResults : IList
{
//------------------------------------------------------------------------------------
// Gets the query results represented as a partitioned stream. Instead of returning
// the PartitionedStream, we instead call recipient.Receive(...). That way,
// the code that receives the partitioned stream has access to the TKey type.
//
// Arguments:
// recipient - the object that the partitioned stream will be passed to
//
internal abstract void GivePartitionedStream(IPartitionedStreamRecipient recipient);
//-----------------------------------------------------------------------------------
// Returns whether the query results are indexible. If this property is true, the
// user can call GetElement(index) and ElementsCount. If it is false, both
// GetElement(index) and ElementsCount should throw InvalidOperationException.
//
internal virtual bool IsIndexible
{
get { return false; }
}
//-----------------------------------------------------------------------------------
// Returns index-th element in the query results
//
// Assumptions:
// IsIndexible returns true
// 0 <= index < ElementsCount
//
internal virtual T GetElement(int index)
{
Contract.Assert(false, "GetElement property is not supported by non-indexible query results");
throw new NotSupportedException();
}
//-----------------------------------------------------------------------------------
// Returns the number of elements in the query results
//
// Assumptions:
// IsIndexible returns true
//
internal virtual int ElementsCount
{
get
{
Contract.Assert(false, "ElementsCount property is not supported by non-indexible query results");
throw new NotSupportedException();
}
}
//
// An assortment of methods we need to support in order to implement the IList interface
//
int IList.IndexOf(T item)
{
throw new NotSupportedException();
}
void IList.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
public T this[int index]
{
get { return GetElement(index); }
set
{
throw new NotSupportedException();
}
}
void ICollection.Add(T item)
{
throw new NotSupportedException();
}
void ICollection.Clear()
{
throw new NotSupportedException();
}
bool ICollection.Contains(T item)
{
throw new NotSupportedException();
}
void ICollection.CopyTo(T[] array, int arrayIndex)
{
throw new NotSupportedException();
}
public int Count
{
get { return ElementsCount; }
}
bool ICollection.IsReadOnly
{
get { return true; }
}
bool ICollection.Remove(T item)
{
throw new NotSupportedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
for (int index = 0; index < Count; index++)
{
yield return this[index];
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)this).GetEnumerator();
}
}
}
// 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
- EventHandlerService.cs
- Compiler.cs
- CreateUserErrorEventArgs.cs
- Geometry3D.cs
- LineBreak.cs
- Point3D.cs
- IPipelineRuntime.cs
- DragEvent.cs
- ListSortDescription.cs
- SortQuery.cs
- BooleanFunctions.cs
- ToolboxItemCollection.cs
- ConnectionPoolManager.cs
- PenCursorManager.cs
- WindowsClientCredential.cs
- StrokeCollectionConverter.cs
- XmlNode.cs
- TabControl.cs
- Help.cs
- BitmapVisualManager.cs
- SqlInternalConnectionSmi.cs
- SQLCharsStorage.cs
- SchemaName.cs
- GeometryHitTestResult.cs
- ButtonBaseAdapter.cs
- ChangePasswordAutoFormat.cs
- ListControl.cs
- SqlTypesSchemaImporter.cs
- RightsManagementInformation.cs
- mil_commands.cs
- PassportAuthenticationModule.cs
- XmlStreamNodeWriter.cs
- SignatureDescription.cs
- ModelServiceImpl.cs
- DataGridRowAutomationPeer.cs
- BCryptNative.cs
- CalendarDateChangedEventArgs.cs
- BatchParser.cs
- ToolStripItemGlyph.cs
- InternalConfigRoot.cs
- TreeNodeStyleCollection.cs
- PresentationSource.cs
- CompositeScriptReference.cs
- UserInitiatedNavigationPermission.cs
- HashHelper.cs
- AnnotationService.cs
- SemanticTag.cs
- Control.cs
- XsdDataContractExporter.cs
- StorageTypeMapping.cs
- ProxyAssemblyNotLoadedException.cs
- HtmlDocument.cs
- EasingKeyFrames.cs
- EntryPointNotFoundException.cs
- ToolStripDropDownClosingEventArgs.cs
- DispatcherTimer.cs
- ReaderWriterLock.cs
- BamlRecordReader.cs
- ControlTemplate.cs
- SqlGenericUtil.cs
- AnnotationHelper.cs
- MemberJoinTreeNode.cs
- WriteFileContext.cs
- SecurityDescriptor.cs
- LogWriteRestartAreaState.cs
- DataGridViewImageColumn.cs
- OneToOneMappingSerializer.cs
- CodeArrayCreateExpression.cs
- TextBlock.cs
- CodeAssignStatement.cs
- SingleAnimationUsingKeyFrames.cs
- PageClientProxyGenerator.cs
- CodeSnippetTypeMember.cs
- TCEAdapterGenerator.cs
- ServiceElementCollection.cs
- FlowLayoutSettings.cs
- OpCellTreeNode.cs
- ListBoxChrome.cs
- PropertyGeneratedEventArgs.cs
- ToolBar.cs
- SqlDataSourceSelectingEventArgs.cs
- DesignerTransaction.cs
- HostedAspNetEnvironment.cs
- RequestContext.cs
- StylusPointPropertyUnit.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- LeftCellWrapper.cs
- SaveCardRequest.cs
- VSDExceptions.cs
- DecimalAnimationUsingKeyFrames.cs
- SortExpressionBuilder.cs
- CompiledQueryCacheEntry.cs
- DataGridViewTopRowAccessibleObject.cs
- securitycriticaldataformultiplegetandset.cs
- GenericArgumentsUpdater.cs
- Command.cs
- LongTypeConverter.cs
- ParallelEnumerableWrapper.cs
- XPathDescendantIterator.cs
- DesignerOptionService.cs