Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version
Go to top

Refactoring a Switch Statement

, 15 Aug 2009
Avoiding a switch statement in order to avoid Cyclomatic complexity.
Refactoring-Switch.zip
Refactoring-Switch
Refactoring-Switch
bin
Debug
Refactoring-Switch.exe
Refactoring-Switch.vshost.exe
Properties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Refactoring_Switch
{
    class Program
    {
        static void Main(string[] args)
        {
            DeviceController deviceController = new DeviceController();
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            deviceController.ChangeDeviceState(DeviceStatesEnum.Active);
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            deviceController.ChangeDeviceState(DeviceStatesEnum.PowerUp);
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            Console.Read();
        }


    }

    public enum DeviceStatesEnum
    {
        PowerUp,
        Waiting,
        StandBy,
        Inactive,
        Active,
        Start,
        Ready,
        Equilibrating,
        StartRunning,
        Running,
        ShoutingDown,
        ShoutDown,
        WarmingUp,
        Error
    }
}

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)

Share

About the Author

rajeshjj
Software Developer (Senior) MphasiS an HP company
India India
I am dotnet programmer

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 Aug 2009
Article Copyright 2009 by rajeshjj
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid