Skip to content

Commit

Permalink
Define various variables to be readonly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinematics committed Mar 11, 2015
1 parent 3d2371c commit 52fe587
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion NetTally/Quest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace NetTally
/// </summary>
public class Quest : IQuest, INotifyPropertyChanged
{
static Regex urlRegex = new Regex(@"^(http://forums.sufficientvelocity.com/threads/)?(?<questName>[^/]+)(/.*)?");
static readonly Regex urlRegex = new Regex(@"^(http://forums.sufficientvelocity.com/threads/)?(?<questName>[^/]+)(/.*)?");

/// <summary>
/// Empty constructor for XML serialization.
Expand Down
2 changes: 1 addition & 1 deletion NetTally/Quests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NetTally
{
public class Quests : IQuests, INotifyPropertyChanged
{
static List<IQuest> questList = new List<IQuest>();
static readonly List<IQuest> questList = new List<IQuest>();
IQuest currentQuest;

/// <summary>
Expand Down
20 changes: 10 additions & 10 deletions NetTally/VoteCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ private void SetupFormattingRegexes()
string threadAuthor = string.Empty;

// A post with ##### at the start of one of the lines is a posting of tally results. Don't read it.
Regex tallyRegex = new Regex(@"^(\[/?[ibu]\]|\[color[^]]+\])*#####", RegexOptions.Multiline);
readonly Regex tallyRegex = new Regex(@"^(\[/?[ibu]\]|\[color[^]]+\])*#####", RegexOptions.Multiline);
// A valid vote line must start with [x] or -[x] (with any number of dashes). It must be at the start of the line.
Regex voteRegex = new Regex(@"^(\s|\[/?[ibu]\]|\[color[^]]+\])*-*\[[xX]\].*", RegexOptions.Multiline);
readonly Regex voteRegex = new Regex(@"^(\s|\[/?[ibu]\]|\[color[^]]+\])*-*\[[xX]\].*", RegexOptions.Multiline);
// A voter referral is a user name on a vote line, possibly starting with 'Plan'.
Regex voterRegex = new Regex(@"^\s*-*\[[xX]\]\s*([pP][lL][aA][nN]\s*)?(?<name>.*?)[.]?\s*$");
readonly Regex voterRegex = new Regex(@"^\s*-*\[[xX]\]\s*([pP][lL][aA][nN]\s*)?(?<name>.*?)[.]?\s*$");
// Clean extraneous information from a vote in order to compare with other votes.
Regex cleanRegex = new Regex(@"(\[/?[ibu]\]|\[color[^]]+\]|\[/color\]|\s|\.)");
readonly Regex cleanRegex = new Regex(@"(\[/?[ibu]\]|\[color[^]]+\]|\[/color\]|\s|\.)");
// Clean extraneous information from a vote line in order to compare with other votes.
Regex cleanLinePartRegex = new Regex(@"(^-+|\[/?[ibu]\]|\[color[^]]+\]|\[/color\]|\s|\.)");
readonly Regex cleanLinePartRegex = new Regex(@"(^-+|\[/?[ibu]\]|\[color[^]]+\]|\[/color\]|\s|\.)");
// Strip BBCode formatting from a vote line. Use with Replace().
Regex stripFormattingRegex = new Regex(@"\[/?[ibu]\]|\[/?color[^]]*\]");
readonly Regex stripFormattingRegex = new Regex(@"\[/?[ibu]\]|\[/?color[^]]*\]");

List<string> formattingTags = new List<string>() { "color", "b", "i", "u" };
Dictionary<string, Regex> rxStart = new Dictionary<string, Regex>();
Dictionary<string, Regex> rxEnd = new Dictionary<string, Regex>();
readonly List<string> formattingTags = new List<string>() { "color", "b", "i", "u" };
readonly Dictionary<string, Regex> rxStart = new Dictionary<string, Regex>();
readonly Dictionary<string, Regex> rxEnd = new Dictionary<string, Regex>();

Dictionary<string, string> cleanVoteLookup = new Dictionary<string, string>();
readonly Dictionary<string, string> cleanVoteLookup = new Dictionary<string, string>();


/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions NetTally/WebPageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public WebPageProvider(IForumData forumData)
this.forumData = forumData;
}

Dictionary<string, CachedPage> pageCache = new Dictionary<string, CachedPage>();
Dictionary<string, int> lastPageLoadedFor = new Dictionary<string, int>();
readonly Dictionary<string, CachedPage> pageCache = new Dictionary<string, CachedPage>();
readonly Dictionary<string, int> lastPageLoadedFor = new Dictionary<string, int>();

#region Event handlers
public event EventHandler<MessageEventArgs> StatusChanged;
Expand Down

0 comments on commit 52fe587

Please sign in to comment.