Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Visual Studio Add-in for testing regular expressions

, 1 Dec 2010 CPOL
An add-in for debugging and creating regular expression directly in Visual Studio
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Reflection;
using System.IO;
using System.Xml;
using System.Windows.Forms;

namespace RegexTester
    /// <summary>
    /// Installs the Regular Expression Tester.
    /// </summary>
    public partial class RegexTesterInstaller : System.Configuration.Install.Installer
        public RegexTesterInstaller()

        private string GetAddInXmlPath()
            return Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData),

        public override void Install(System.Collections.IDictionary stateSaver)
            string assemblyPath = base.Context.Parameters["AssemblyPath"];
            string addinXmlPath = GetAddInXmlPath();

            Stream addInStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RegexTester.RegexTester.AddIn");
            XmlDocument doc = new XmlDocument();
            XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(doc.NameTable);
            nameSpaceManager.AddNamespace("addin", "");
            XmlNode node = doc.SelectSingleNode("/addin:Extensibility/addin:Addin/addin:Assembly", nameSpaceManager);
            node.InnerText = assemblyPath;
            string directoryName = Path.GetDirectoryName(addinXmlPath);
            if (!Directory.Exists(directoryName))
            using (FileStream fs = new FileStream(addinXmlPath, FileMode.Create, FileAccess.Write, FileShare.Write))
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                settings.Encoding = System.Text.Encoding.UTF8;
                XmlWriter writer = XmlWriter.Create(fs, settings);

        private void DeleteAddInFile()
            string file = GetAddInXmlPath();
            if (File.Exists(file))

        public override void Uninstall(IDictionary savedState)


        public override void Rollback(IDictionary savedState)


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.


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


About the Author

Andreas Andersen
Software Developer (Senior)
Denmark Denmark
.NET developer. I wanted to be first an astronaut, then a jet pilot, but when I got a Commodore 64 for Christmas I never looked back. Also I would never have qualified for the first two things and everybody knows computer programmers get all the girls.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 1 Dec 2010
Article Copyright 2010 by Andreas Andersen
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid