IdentifierCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Internal / GrammarBuilding / IdentifierCollection.cs / 1 / IdentifierCollection.cs

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

using System.Collections.Generic; 
 
namespace System.Speech.Internal.GrammarBuilding
{ 
    /// 
    ///
    /// 
    internal class IdentifierCollection 
    {
 
 
        //*******************************************************************
        // 
        // Constructors
        //
        //*******************************************************************
 
        #region Constructors
 
        ///  
        ///
        ///  
        internal IdentifierCollection()
        {
            _identifiers = new List();
            CreateNewIdentifier ("_"); 
        }
 
        #endregion 

 
        //********************************************************************
        //
        // Internal Methods
        // 
        //*******************************************************************
 
        #region Internal Methods 

        ///  
        ///
        /// 
        /// 
        ///  
        internal string CreateNewIdentifier(string id)
        { 
            if (!_identifiers.Contains(id)) 
            {
                _identifiers.Add(id); 
                return id;
            }
            else
            { 
                string newId;
                int i = 1; 
                do 
                {
                    newId = id + i; 
                    i++;
                } while (_identifiers.Contains(newId));
                _identifiers.Add(newId);
                return newId; 
            }
        } 
 
        #endregion
 

        //********************************************************************
        //
        // Protected Fields 
        //
        //******************************************************************** 
 
        #region Protected Fields
 
        /// 
        ///
        /// 
        protected List _identifiers; 

        #endregion 
 
    }
} 

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

using System.Collections.Generic; 
 
namespace System.Speech.Internal.GrammarBuilding
{ 
    /// 
    ///
    /// 
    internal class IdentifierCollection 
    {
 
 
        //*******************************************************************
        // 
        // Constructors
        //
        //*******************************************************************
 
        #region Constructors
 
        ///  
        ///
        ///  
        internal IdentifierCollection()
        {
            _identifiers = new List();
            CreateNewIdentifier ("_"); 
        }
 
        #endregion 

 
        //********************************************************************
        //
        // Internal Methods
        // 
        //*******************************************************************
 
        #region Internal Methods 

        ///  
        ///
        /// 
        /// 
        ///  
        internal string CreateNewIdentifier(string id)
        { 
            if (!_identifiers.Contains(id)) 
            {
                _identifiers.Add(id); 
                return id;
            }
            else
            { 
                string newId;
                int i = 1; 
                do 
                {
                    newId = id + i; 
                    i++;
                } while (_identifiers.Contains(newId));
                _identifiers.Add(newId);
                return newId; 
            }
        } 
 
        #endregion
 

        //********************************************************************
        //
        // Protected Fields 
        //
        //******************************************************************** 
 
        #region Protected Fields
 
        /// 
        ///
        /// 
        protected List _identifiers; 

        #endregion 
 
    }
} 

// 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