Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / XML

.NET Regular Expressions Find and Replace Add-In for Visual Studio 2008

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
12 Oct 2009CPOL3 min read 184.7K   1.6K   117  
A .NET Regular Expressions Find and Replace add-in for Visual Studio 2008
using System;

namespace RegexFindAndReplace
{
    /// <summary>
    /// The MatchContextInfo contains information about a match in a text file, including the filename, 
    /// the location of the match, and the length of the match
    /// </summary>
    public class MatchContextInfo
    {
        public MatchContextInfo( string fullFilename, int startLine, int endLine, string matchContent, string matchContext, int startLineOffset, int matchIndex, int matchLength, int endLineOffset )
        {
            this.fullFilename = fullFilename;
            this.startLine = startLine;
            this.endLine = endLine;
            this.matchContent = matchContent;
            this.matchContext = matchContext;
            this.startLineOffset = startLineOffset;

            this.matchIndex = matchIndex;
            this.matchLength = matchLength;
            this.endLineOffset = endLineOffset;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchContextInfo"/> class.
        /// </summary>
        /// <param name="FullFilename">The full filename.</param>
        /// <param name="startLine">The start line.</param>
        /// <param name="endLine">The end line.</param>
        /// <param name="matchContent">Content of the match.</param>
        /// <param name="matchContext">The match context.</param>
        public MatchContextInfo( string FullFilename, int startLine, int endLine, string matchContent, string matchContext )
            : this( FullFilename, startLine, endLine, matchContent, matchContext, 0, 0, 0, 0 )
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchContextInfo"/> class.
        /// </summary>
        /// <param name="startLine">The start line.</param>
        /// <param name="endLine">The end line.</param>
        /// <param name="matchContent">Content of the match.</param>
        /// <param name="startLineOffset">The start line offset.</param>
        /// <param name="matchIndex">Index of the match.</param>
        /// <param name="matchLength">Length of the match.</param>
        /// <param name="endLineOffset">The end line offset.</param>
        public MatchContextInfo( int startLine, int endLine, string matchContent, int startLineOffset, int matchIndex, int matchLength, int endLineOffset )
            : this( string.Empty, startLine, endLine, matchContent, string.Empty, startLineOffset, matchIndex, matchLength, endLineOffset )
        {
        }

        private string fullFilename;
        public string FullFilename
        {
            get
            {
                return this.fullFilename;
            }
        }

        private int startLine;
        public int StartLine
        {
            get
            {
                return this.startLine;
            }
        }

        private int endLine;
        public int EndLine
        {
            get
            {
                return this.endLine;
            }
        }

        private string matchContent;
        public string MatchContent
        {
            get
            {
                return this.matchContent;
            }
        }

        private string matchContext;
        public string MatchContext
        {
            get
            {
                return this.matchContext;
            }
        }

        private int startLineOffset;
        public int StartLineOffset
        {
            get
            {
                return this.startLineOffset;
            }
        }

        private int matchIndex;
        public int MatchIndex
        {
            get
            {
                return this.matchIndex;
            }
        }

        private int matchLength;
        public int MatchLength
        {
            get
            {
                return this.matchLength;
            }
        }

        private int endLineOffset;
        public int EndLineOffset
        {
            get
            {
                return this.endLineOffset;
            }
        }
    }
}

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 States United States
I am a software developer currently working in Salt Lake City, Utah. I work primarily with C# for my job, but I mess around with C, Perl, and Windows PowerShell for fun.

Comments and Discussions