EmptyEnumerator.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Controls / EmptyEnumerator.cs / 1 / EmptyEnumerator.cs

                            //---------------------------------------------------------------------------- 
//
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
//  
//
// 
// Description: Empty enumerator 
//
// History: 
//  02/26/2004 : [....] stole from ItemsView (and stole comments from UIAutomation)
//
//---------------------------------------------------------------------------
using System; 
using System.Collections;
 
namespace MS.Internal.Controls 
{
    ///  
    /// Returns an Enumerator that enumerates over nothing.
    /// 
    internal class EmptyEnumerator: IEnumerator
    { 
        // singleton class, private ctor
        private EmptyEnumerator() 
        { 
        }
 
        /// 
        /// Read-Only instance of an Empty Enumerator.
        /// 
        public static IEnumerator Instance 
        {
            get 
            { 
                if (_instance == null)
                { 
                    _instance = new EmptyEnumerator();
                }
                return _instance;
            } 
        }
 
        ///  
        /// Does nothing.
        ///  
        public void Reset() { }

        /// 
        /// Returns false. 
        /// 
        /// false 
        public bool MoveNext() { return false; } 

 
#pragma warning disable 1634, 1691  // about to use PreSharp message numbers - unknown to C#

        /// 
        /// Returns null. 
        /// 
        public object Current { 
            get 
            {
                #pragma warning disable 6503 // "Property get methods should not throw exceptions." 

                throw new InvalidOperationException();

                #pragma warning restore 6503 
            }
        } 
#pragma warning restore 1634, 1691 

        private static IEnumerator _instance; 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

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