Click here to Skip to main content
15,881,803 members
Articles / Programming Languages / Visual Basic

C#, Visual Basic and C++ .NET Line Count Utility

Rate me:
Please Sign up or sign in to vote.
4.72/5 (60 votes)
9 Jul 2007CPOL6 min read 194.8K   7.2K   63  
A utility to count the number of lines in a C#, VB or C++ .NET solution or project
using System;
using System.Collections.Generic;
using System.Text;

namespace LineCount.CodeContainers
{
    /// <summary>
    /// Simple factory idiom for creating the appropriate code container based
    /// on the path entered in the application
    /// </summary>
    class CodeContainerFactory
    {
        public CodeContainer CreateCodeContainer(string fullName)
        {
            CodeContainer result = null;
            if (fullName.EndsWith(".sln"))
                result = new Solution(fullName);
            else if (fullName.EndsWith(".vbproj") || fullName.EndsWith(".csproj"))
                result = new Project(fullName);
            else if (fullName.EndsWith(".cs") || fullName.EndsWith(".vb"))
                result = new CodeFile(fullName);
            return result;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
United States United States
I work in the investment banking division of a large American bank. I work in credit technology.

I write a blog about technical issues in .Net and other computer technologies that interest me at http://richnewman.wordpress.com/. I also write occasionally about derivatives.

Comments and Discussions