CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Using nested static classes

    I'm wondering if any of you use static nested classes? Any opinions or drawbacks?

    Here's an example...
    Code:
    public class Constants
    {
    	internal static class DB
    	{
    		public static class Params
    		{
    			public const string Address1 = "Address1";
    			public const string City = "City";
    
    			public class Scheduler
    			{
    				public const string Active = "Active";
    				public const string DepartmentID = "DepartmentID";
    			}
    		}
    
    		public static class Sprocs
    		{
    			public static class Employee
    			{
    				public const string Create = "[dbo].[Employee.Create]";
    				public const string Delete = "[dbo].[Employee.Delete]";
    				public const string Get = "[dbo].[Employee.Get]";
    				public const string GetList = "[dbo].[Employee.GetList]";
    			}
    		}
    
    		public static class Connections
    		{
    			public static string Facilitator
    			{
    				get { return ConfigurationManager.ConnectionStrings[ "Facilitator" ].ConnectionString; }
    			}
    		}
    	}
    }
    Usage:
    Code:
    publicEmployee[ ] GetEmployees( Guid companyID, bool includeInactive )
    {
      List<Employee> list = newList<Employee>( );
     
      using( DAL dal = DAL.Create( Constants.DB.Connections.Facilitator ) )
      {
        dal.Open( );
     
        SqlParamCollection sqlParams = SqlParamCollection.Create( );
        sqlParams.Add( Constants.DB.Params.CompanyID, companyID );
        sqlParams.Add( Constants.DB.Params.IncludeInactive, includeInactive );
     
        using( SafeDataReader dr = SafeDataReader.Create( dal.ExecuteReader( Constants.DB.Sprocs.Employee.GetList, sqlParams ) ) )
        {
          while( dr.Read( ) )
          {
            list.Add( EmployeeCreator.Create( dr ) );
          }
        }
      }
      return list.ToArray( );
    }


    Comments?
    [/SIZE]
    Last edited by Arjay; August 23rd, 2009 at 10:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured