DummyDataSource.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / DummyDataSource.cs / 1305376 / DummyDataSource.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls { 
 
    using System;
    using System.Collections; 


    /// 
    ///  
    internal sealed class DummyDataSource : ICollection {
 
        private int dataItemCount; 

        internal DummyDataSource(int dataItemCount) { 
            this.dataItemCount = dataItemCount;
        }

        public int Count { 
            get {
                return dataItemCount; 
            } 
        }
 
        public bool IsSynchronized {
            get {
                return false;
            } 
        }
 
        public Object SyncRoot { 
            get {
                return this; 
            }
        }

        public void CopyTo(Array array, int index) { 
            for (IEnumerator e = this.GetEnumerator(); e.MoveNext();)
                array.SetValue(e.Current, index++); 
        } 

        public IEnumerator GetEnumerator() { 
            return new DummyDataSourceEnumerator(dataItemCount);
        }

 
        private class DummyDataSourceEnumerator : IEnumerator {
 
            private int count; 
            private int index;
 
            public DummyDataSourceEnumerator(int count) {
                this.count = count;
                this.index = -1;
            } 

            public object Current { 
                get { 
                    return null;
                } 
            }

            public bool MoveNext() {
                index++; 
                return index < count;
            } 
 
            public void Reset() {
                this.index = -1; 
            }
        }
    }
} 


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK