Click here to Skip to main content
15,895,557 members
Articles / Programming Languages / C#

Extending Visual Studio Part 2 - Creating Addins

Rate me:
Please Sign up or sign in to vote.
4.92/5 (47 votes)
17 Jun 2013CPOL11 min read 158K   3.7K   119  
Create an amazingly useful 'Switch' addin to switch between cpp/h, designer/code, XAML/codebehind and more!
using System;
using System.Collections.Generic;
using System.Text;

namespace Switch2010
{
    /// <summary>
    /// A Switch Target defines what we switch from, to.
    /// </summary>
    public class SwitchTarget
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SwitchTarget"/> class.
        /// </summary>
        public SwitchTarget()
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SwitchTarget"/> class.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        public SwitchTarget(string from, string to)
        {
            From = from;
            To = to;
        }

        /// <summary>
        /// Maps the from path to the to path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>The mapped path</returns>
        public string MapPath(string path)
        {
            //  Replace the path 'from' with the part 'to'.
            if (path.Length < From.Length)
                return null;

            return path.Substring(0, path.Length - From.Length) + To;
        }

        /// <summary>
        /// Gets from.
        /// </summary>
        public string From
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets to.
        /// </summary>
        public string To
        {
            get;
            private set;
        }
    }
}

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
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions