Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / Util / SingleObjectCollection.cs / 1 / SingleObjectCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* SingleObjectCollection class
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Collections;
/*
* Fast implementation of a collection with a single object
*/
internal class SingleObjectCollection: ICollection {
private class SingleObjectEnumerator: IEnumerator {
private object _object;
private bool done;
public SingleObjectEnumerator(object o) { _object = o; }
public object Current { get { return _object; } }
public bool MoveNext() {
if (!done) {
done = true;
return true;
}
return false;
}
public void Reset() { done = false; }
}
private object _object;
public SingleObjectCollection(object o) { _object = o; }
IEnumerator IEnumerable.GetEnumerator() { return new SingleObjectEnumerator(_object); }
public int Count { get { return 1; } }
bool ICollection.IsSynchronized { get { return true; } }
object ICollection.SyncRoot { get { return this; } }
public void CopyTo(Array array, int index) {
array.SetValue(_object, index);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* SingleObjectCollection class
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Collections;
/*
* Fast implementation of a collection with a single object
*/
internal class SingleObjectCollection: ICollection {
private class SingleObjectEnumerator: IEnumerator {
private object _object;
private bool done;
public SingleObjectEnumerator(object o) { _object = o; }
public object Current { get { return _object; } }
public bool MoveNext() {
if (!done) {
done = true;
return true;
}
return false;
}
public void Reset() { done = false; }
}
private object _object;
public SingleObjectCollection(object o) { _object = o; }
IEnumerator IEnumerable.GetEnumerator() { return new SingleObjectEnumerator(_object); }
public int Count { get { return 1; } }
bool ICollection.IsSynchronized { get { return true; } }
object ICollection.SyncRoot { get { return this; } }
public void CopyTo(Array array, int index) {
array.SetValue(_object, index);
}
}
}
// 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
- BindingParameterCollection.cs
- FixedDSBuilder.cs
- ValidationErrorInfo.cs
- DbException.cs
- SelectionItemProviderWrapper.cs
- CodeDelegateInvokeExpression.cs
- SettingsBindableAttribute.cs
- Configuration.cs
- MemberAccessException.cs
- ConfigurationLocation.cs
- ClrProviderManifest.cs
- comcontractssection.cs
- WebPartZoneAutoFormat.cs
- UIElementAutomationPeer.cs
- ExtensionSimplifierMarkupObject.cs
- TextAdaptor.cs
- TextRangeAdaptor.cs
- SystemMulticastIPAddressInformation.cs
- TagPrefixAttribute.cs
- FunctionParameter.cs
- DesignerView.Commands.cs
- StringValidatorAttribute.cs
- TextTreeUndoUnit.cs
- BaseCAMarshaler.cs
- SchemaCollectionCompiler.cs
- ApplicationActivator.cs
- OleStrCAMarshaler.cs
- JsonFormatReaderGenerator.cs
- TypefaceMap.cs
- EmptyEnumerable.cs
- LoadWorkflowByInstanceKeyCommand.cs
- InputLangChangeEvent.cs
- JoinGraph.cs
- IBuiltInEvidence.cs
- FeatureSupport.cs
- AsymmetricAlgorithm.cs
- RequestQueryParser.cs
- XmlReader.cs
- XmlRawWriter.cs
- ToolBar.cs
- BinaryFormatterWriter.cs
- ImageList.cs
- SchemaCollectionPreprocessor.cs
- AnnotationObservableCollection.cs
- PackWebResponse.cs
- KeyConverter.cs
- httpserverutility.cs
- KeyEventArgs.cs
- DebugView.cs
- ListItem.cs
- UnsupportedPolicyOptionsException.cs
- OpenFileDialog.cs
- SoapAttributeOverrides.cs
- AxParameterData.cs
- CookieHandler.cs
- DaylightTime.cs
- PersonalizationAdministration.cs
- Blend.cs
- SqlBooleanMismatchVisitor.cs
- ObjectViewEntityCollectionData.cs
- CompilerError.cs
- PropertyDescriptorCollection.cs
- BitmapScalingModeValidation.cs
- BitmapDecoder.cs
- ValueConversionAttribute.cs
- CultureInfo.cs
- ErrorRuntimeConfig.cs
- MessageTraceRecord.cs
- EnumerableRowCollectionExtensions.cs
- ClientTargetCollection.cs
- ColorBlend.cs
- XmlRawWriterWrapper.cs
- GatewayIPAddressInformationCollection.cs
- ContentDisposition.cs
- FormsAuthenticationModule.cs
- ManualResetEventSlim.cs
- GraphicsPathIterator.cs
- BatchParser.cs
- Function.cs
- UrlAuthFailureHandler.cs
- Path.cs
- CultureInfoConverter.cs
- SchemaImporter.cs
- _FixedSizeReader.cs
- XmlCustomFormatter.cs
- AnnotationComponentManager.cs
- GeneratedCodeAttribute.cs
- FrameworkElement.cs
- Trace.cs
- DesignTimeParseData.cs
- SecurityState.cs
- ThreadStaticAttribute.cs
- ListBoxAutomationPeer.cs
- GridViewSelectEventArgs.cs
- TrackingStringDictionary.cs
- MatrixAnimationUsingKeyFrames.cs
- ObjectListCommand.cs
- InvalidDataContractException.cs
- XmlSerializationWriter.cs
- InvokePattern.cs