Skip to content

Commit ba4bb07

Browse files
authored
Merge pull request #323 from zarunbal/revert-322-issue321
Revert "Issue321: Highlights should be there separated .json settings file"
2 parents 8e16f79 + f5e352a commit ba4bb07

35 files changed

Lines changed: 2315 additions & 2453 deletions

src/LogExpert.Tests/JSONSaveTest.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using LogExpert.Config;
2-
32
using Newtonsoft.Json;
4-
53
using NUnit.Framework;
6-
74
using System.IO;
85

96
namespace LogExpert.Tests
@@ -20,14 +17,14 @@ public void SaveOptionsAsJSON()
2017
string settingsFile = configDir + "\\settings.json";
2118

2219
Settings settings = null;
23-
20+
2421
Assert.DoesNotThrow(CastSettings);
2522
Assert.That(settings, Is.Not.Null);
2623
Assert.That(settings.alwaysOnTop, Is.True);
2724

2825
ConfigManager.Settings.alwaysOnTop = false;
2926
ConfigManager.Save(SettingsFlags.All);
30-
27+
3128
settings = null;
3229
Assert.DoesNotThrow(CastSettings);
3330

src/LogExpert/Classes/CmdLine.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/*
55
* Taken from https://cmdline.codeplex.com/
6-
*
6+
*
77
*/
88

99
namespace LogExpert.Classes
@@ -15,19 +15,23 @@ public class CmdLineException : Exception
1515
{
1616
#region cTor
1717

18-
public CmdLineException(string parameter, string message) : base($"Syntax error of parameter -{parameter}: {message}")
18+
public CmdLineException(string parameter, string message)
19+
:
20+
base(string.Format("Syntax error of parameter -{0}: {1}", parameter, message))
1921
{
2022
}
2123

22-
public CmdLineException(string message) : base(message)
24+
public CmdLineException(string message)
25+
:
26+
base(message)
2327
{
2428
}
2529

2630
#endregion
2731
}
2832

2933
/// <summary>
30-
/// Represents a command line parameter.
34+
/// Represents a command line parameter.
3135
/// Parameters are words in the command line beginning with a hyphen (-).
3236
/// The value of the parameter is the next word in
3337
/// </summary>
@@ -99,7 +103,7 @@ public virtual void SetValue(string value)
99103
}
100104

101105
/// <summary>
102-
/// Represents an integer command line parameter.
106+
/// Represents an integer command line parameter.
103107
/// </summary>
104108
public class CmdLineInt : CmdLineParameter
105109
{
@@ -158,25 +162,22 @@ public CmdLineInt(string name, bool required, string helpMessage, int min, int m
158162
public override void SetValue(string value)
159163
{
160164
base.SetValue(value);
161-
int i;
162-
165+
int i = 0;
163166
try
164167
{
165168
i = Convert.ToInt32(value);
166169
}
167170
catch (Exception)
168171
{
169-
throw new CmdLineException(Name, "Value is not an integer.");
172+
throw new CmdLineException(base.Name, "Value is not an integer.");
170173
}
171-
172174
if (i < _min)
173175
{
174-
throw new CmdLineException(Name, $"Value must be greather or equal to {_min}.");
176+
throw new CmdLineException(base.Name, string.Format("Value must be greather or equal to {0}.", _min));
175177
}
176-
177178
if (i > _max)
178179
{
179-
throw new CmdLineException(Name, $"Value must be less or equal to {_max}.");
180+
throw new CmdLineException(base.Name, string.Format("Value must be less or equal to {0}.", _max));
180181
}
181182
Value = i;
182183
}
@@ -252,11 +253,11 @@ public CmdLineParameter this[string name]
252253
{
253254
get
254255
{
255-
if (!parameters.TryGetValue(name, out CmdLineParameter value))
256+
if (!parameters.ContainsKey(name))
256257
{
257258
throw new CmdLineException(name, "Not a registered parameter.");
258259
}
259-
return value;
260+
return parameters[name];
260261
}
261262
}
262263

@@ -306,8 +307,8 @@ public string[] Parse(string[] args)
306307
if (args[i].Length > 1 && args[i][0] == '-')
307308
{
308309
// The current string is a parameter name
309-
string key = args[i][1..].ToLower();
310-
string value = string.Empty;
310+
string key = args[i].Substring(1, args[i].Length - 1).ToLower();
311+
string value = "";
311312
i++;
312313
if (i < args.Length)
313314
{
@@ -322,17 +323,17 @@ public string[] Parse(string[] args)
322323
i++;
323324
}
324325
}
325-
if (!parameters.TryGetValue(key, out CmdLineParameter cmdLineParameter))
326+
if (!parameters.ContainsKey(key))
326327
{
327328
throw new CmdLineException(key, "Parameter is not allowed.");
328329
}
329330

330-
if (cmdLineParameter.Exists)
331+
if (parameters[key].Exists)
331332
{
332333
throw new CmdLineException(key, "Parameter is specified more than once.");
333334
}
334335

335-
cmdLineParameter.SetValue(value);
336+
parameters[key].SetValue(value);
336337
}
337338
else
338339
{
@@ -342,7 +343,7 @@ public string[] Parse(string[] args)
342343
}
343344

344345

345-
// Check that required parameters are present in the command line.
346+
// Check that required parameters are present in the command line.
346347
foreach (string key in parameters.Keys)
347348
{
348349
if (parameters[key].Required && !parameters[key].Exists)
@@ -393,7 +394,7 @@ public class ConsoleCmdLine : CmdLine
393394

394395
public ConsoleCmdLine()
395396
{
396-
RegisterParameter(new CmdLineString("help", false, "Prints the help screen."));
397+
base.RegisterParameter(new CmdLineString("help", false, "Prints the help screen."));
397398
}
398399

399400
#endregion
@@ -403,7 +404,7 @@ public ConsoleCmdLine()
403404
public new string[] Parse(string[] args)
404405
{
405406
string[] ret = null;
406-
string error = string.Empty;
407+
string error = "";
407408
try
408409
{
409410
ret = base.Parse(args);
@@ -417,15 +418,15 @@ public ConsoleCmdLine()
417418
{
418419
//foreach(string s in base.HelpScreen().Split('\n'))
419420
// Console.WriteLine(s);
420-
Console.WriteLine(HelpScreen());
421-
Environment.Exit(0);
421+
Console.WriteLine(base.HelpScreen());
422+
System.Environment.Exit(0);
422423
}
423424

424425
if (error != "")
425426
{
426427
Console.WriteLine(error);
427428
Console.WriteLine("Use -help for more information.");
428-
Environment.Exit(1);
429+
System.Environment.Exit(1);
429430
}
430431
return ret;
431432
}

src/LogExpert/Classes/Columnizer/ColumnizerPicker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer)
4848
object o = cti.Invoke(new object[] { });
4949
if (o is IColumnizerConfigurator configurator)
5050
{
51-
configurator.LoadConfig(ConfigManager.Settings.Preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir);
51+
configurator.LoadConfig(ConfigManager.Settings.preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir);
5252
}
5353
return (ILogLineColumnizer)o;
5454
}

0 commit comments

Comments
 (0)