1 //------------------------------------------------------------------------------
2 // <copyright file="SingleObjectCollection.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
8 * SingleObjectCollection class
10 * Copyright (c) 1999 Microsoft Corporation
13 namespace System.Web.Util {
15 using System.Collections;
18 * Fast implementation of a collection with a single object
20 internal class SingleObjectCollection: ICollection {
22 private class SingleObjectEnumerator: IEnumerator {
23 private object _object;
26 public SingleObjectEnumerator(object o) { _object = o; }
27 public object Current { get { return _object; } }
28 public bool MoveNext() {
36 public void Reset() { done = false; }
39 private object _object;
41 public SingleObjectCollection(object o) { _object = o; }
43 IEnumerator IEnumerable.GetEnumerator() { return new SingleObjectEnumerator(_object); }
44 public int Count { get { return 1; } }
45 bool ICollection.IsSynchronized { get { return true; } }
46 object ICollection.SyncRoot { get { return this; } }
48 public void CopyTo(Array array, int index) {
49 array.SetValue(_object, index);