Skip to content

Commit 6d2e5bf

Browse files
committed
optimizations
1 parent 75ff7c4 commit 6d2e5bf

10 files changed

Lines changed: 123 additions & 125 deletions

File tree

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
1-
namespace LogExpert
1+
namespace LogExpert;
2+
3+
///<summary>
4+
///This is a callback interface. Some of the ILogLineColumnizer functions
5+
///are called with this interface as an argument. You don't have to implement this interface. It's implemented
6+
///by LogExpert. You can use it in your own columnizers, if you need it.
7+
///</summary>
8+
///<remarks>
9+
///Implementors of ILogLineColumnizer can use the provided functions to get some more informations
10+
///about the log file. In the most cases you don't need this interface. It's provided here for special cases.<br></br>
11+
///<br></br>
12+
///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation
13+
///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp.
14+
///</remarks>
15+
public interface ILogLineColumnizerCallback
216
{
3-
///<summary>
4-
///This is a callback interface. Some of the ILogLineColumnizer functions
5-
///are called with this interface as an argument. You don't have to implement this interface. It's implemented
6-
///by LogExpert. You can use it in your own columnizers, if you need it.
7-
///</summary>
8-
///<remarks>
9-
///Implementors of ILogLineColumnizer can use the provided functions to get some more informations
10-
///about the log file. In the most cases you don't need this interface. It's provided here for special cases.<br></br>
11-
///<br></br>
12-
///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation
13-
///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp.
14-
///</remarks>
15-
public interface ILogLineColumnizerCallback
16-
{
17-
#region Public methods
17+
#region Public methods
1818

19-
/// <summary>
20-
/// This function returns the current line number. That is the line number of the log line
21-
/// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
22-
/// </summary>
23-
/// <returns>The current line number starting at 0</returns>
24-
int GetLineNum ();
19+
/// <summary>
20+
/// This function returns the current line number. That is the line number of the log line
21+
/// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
22+
/// </summary>
23+
/// <returns>The current line number starting at 0</returns>
24+
int GetLineNum ();
2525

26-
/// <summary>
27-
/// This function sets the current line number. That is the line number of the log line
28-
/// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
29-
/// </summary>
30-
/// <param name="lineNum">line number to be set</param>
31-
void SetLineNum (int lineNum);
32-
/// <summary>
33-
/// Returns the full file name (path + name) of the current log file.
34-
/// </summary>
35-
/// <returns>File name of current log file</returns>
36-
string GetFileName ();
26+
/// <summary>
27+
/// This function sets the current line number. That is the line number of the log line
28+
/// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
29+
/// </summary>
30+
/// <param name="lineNum">line number to be set</param>
31+
void SetLineNum (int lineNum);
32+
/// <summary>
33+
/// Returns the full file name (path + name) of the current log file.
34+
/// </summary>
35+
/// <returns>File name of current log file</returns>
36+
string GetFileName ();
3737

38-
/// <summary>
39-
/// Returns the log line with the given index (zero-based).
40-
/// </summary>
41-
/// <param name="lineNum">Number of the line to be retrieved</param>
42-
/// <returns>A string with line content or null if line number is out of range</returns>
43-
ILogLine GetLogLine (int lineNum);
38+
/// <summary>
39+
/// Returns the log line with the given index (zero-based).
40+
/// </summary>
41+
/// <param name="lineNum">Number of the line to be retrieved</param>
42+
/// <returns>A string with line content or null if line number is out of range</returns>
43+
ILogLine GetLogLine (int lineNum);
4444

45-
/// <summary>
46-
/// Returns the number of lines of the logfile.
47-
/// </summary>
48-
/// <returns>Number of lines.</returns>
49-
int GetLineCount ();
45+
/// <summary>
46+
/// Returns the number of lines of the logfile.
47+
/// </summary>
48+
/// <returns>Number of lines.</returns>
49+
int GetLineCount ();
5050

51-
#endregion
52-
}
51+
#endregion
5352
}
Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,70 @@
11
using LogExpert.Core.Interface;
22

3-
namespace LogExpert.Classes.ILogLineColumnizerCallback
4-
{
5-
public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback
6-
{
7-
#region Fields
8-
9-
private protected ILogWindow _logWindow;
10-
private protected IPluginRegistry _pluginRegistry;
3+
namespace LogExpert.Core.Callback;
114

12-
#endregion
5+
public class ColumnizerCallback : ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback
6+
{
7+
#region cTor
138

14-
#region cTor
9+
public ColumnizerCallback (ILogWindow logWindow)
10+
{
11+
LogWindow = logWindow;
12+
}
1513

16-
public ColumnizerCallback (ILogWindow logWindow)
17-
{
18-
_logWindow = logWindow;
19-
}
14+
private ColumnizerCallback (ColumnizerCallback original)
15+
{
16+
LogWindow = original.LogWindow;
17+
LineNum = original.GetLineNum();
18+
}
2019

21-
private ColumnizerCallback (ColumnizerCallback original)
22-
{
23-
_logWindow = original._logWindow;
24-
LineNum = original.GetLineNum();
25-
}
20+
#endregion
2621

27-
#endregion
22+
#region Properties
2823

29-
#region Properties
24+
public int LineNum { get; set; }
3025

31-
public int LineNum { get; set; }
26+
protected ILogWindow LogWindow { get; set; }
3227

33-
#endregion
28+
protected IPluginRegistry PluginRegistry { get; set; }
3429

35-
#region Public methods
30+
#endregion
3631

37-
public ColumnizerCallback CreateCopy ()
38-
{
39-
return new ColumnizerCallback(this);
40-
}
32+
#region Public methods
4133

42-
public int GetLineNum ()
43-
{
44-
return LineNum;
45-
}
34+
public ColumnizerCallback CreateCopy ()
35+
{
36+
return new ColumnizerCallback(this);
37+
}
4638

47-
public string GetFileName ()
48-
{
49-
return _logWindow.GetCurrentFileName(GetLineNum());
50-
}
39+
public int GetLineNum ()
40+
{
41+
return LineNum;
42+
}
5143

52-
public ILogLine GetLogLine (int lineNum)
53-
{
54-
return _logWindow.GetLine(lineNum);
55-
}
44+
public string GetFileName ()
45+
{
46+
return LogWindow.GetCurrentFileName(GetLineNum());
47+
}
5648

57-
public IList<ILogLineColumnizer> GetRegisteredColumnizers ()
58-
{
59-
return _pluginRegistry.RegisteredColumnizers;
60-
}
49+
public ILogLine GetLogLine (int lineNum)
50+
{
51+
return LogWindow.GetLine(lineNum);
52+
}
6153

62-
public int GetLineCount ()
63-
{
64-
return _logWindow.LogFileReader.LineCount;
65-
}
54+
public IList<ILogLineColumnizer> GetRegisteredColumnizers ()
55+
{
56+
return PluginRegistry.RegisteredColumnizers;
57+
}
6658

67-
public void SetLineNum (int lineNum)
68-
{
69-
LineNum = lineNum;
70-
}
59+
public int GetLineCount ()
60+
{
61+
return LogWindow.LogFileReader.LineCount;
62+
}
7163

72-
#endregion
64+
public void SetLineNum (int lineNum)
65+
{
66+
LineNum = lineNum;
7367
}
68+
69+
#endregion
7470
}

src/LogExpert.Core/Classes/Filter/Filter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22
using LogExpert.Core.Classes;
33
using LogExpert.Core.Classes.Filter;
44

src/LogExpert.Core/Classes/Filter/FilterStarter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22
using LogExpert.Core.Classes.Filter;
33

44
using NLog;

src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22
using LogExpert.Core.Classes.Log;
33

44
namespace LogExpert.UI.Controls.LogWindow;
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22

3-
namespace LogExpert.UI.Controls.LogWindow
4-
{
5-
internal class LogExpertCallback(LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback
6-
{
7-
#region Public methods
3+
namespace LogExpert.UI.Controls.LogWindow;
84

9-
public void AddTempFileTab(string fileName, string title)
10-
{
11-
_logWindow.AddTempFileTab(fileName, title);
12-
}
5+
internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback
6+
{
7+
#region Public methods
138

14-
public void AddPipedTab(IList<LineEntry> lineEntryList, string title)
15-
{
16-
_logWindow.WritePipeTab(lineEntryList, title);
17-
}
9+
public void AddTempFileTab (string fileName, string title)
10+
{
11+
LogWindow.AddTempFileTab(fileName, title);
12+
}
1813

19-
public string GetTabTitle()
20-
{
21-
return _logWindow.Text;
22-
}
14+
public void AddPipedTab (IList<LineEntry> lineEntryList, string title)
15+
{
16+
LogWindow.WritePipeTab(lineEntryList, title);
17+
}
2318

24-
#endregion
19+
public string GetTabTitle ()
20+
{
21+
return LogWindow.Text;
2522
}
23+
24+
#endregion
2625
}

src/LogExpert.UI/Controls/LogWindow/LogWindow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using LogExpert.Classes.Filter;
2-
using LogExpert.Classes.ILogLineColumnizerCallback;
2+
using LogExpert.Core.Callback;
33
using LogExpert.Core.Classes.Bookmark;
44
using LogExpert.Core.Classes.Filter;
55
using LogExpert.Core.Classes.Highlight;
@@ -14,7 +14,9 @@
1414
using LogExpert.UI.Controls.LogTabWindow;
1515
using LogExpert.UI.Dialogs;
1616
using LogExpert.UI.Extensions.Forms;
17+
1718
using NLog;
19+
1820
using WeifenLuo.WinFormsUI.Docking;
1921
//using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used.
2022

src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Text.RegularExpressions;
44

55
using LogExpert.Classes.Filter;
6-
using LogExpert.Classes.ILogLineColumnizerCallback;
6+
using LogExpert.Core.Callback;
77
using LogExpert.Core.Classes;
88
using LogExpert.Core.Classes.Columnizer;
99
using LogExpert.Core.Classes.Filter;

src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22
using LogExpert.Core.Classes;
33
using LogExpert.Core.Classes.Filter;
44
using LogExpert.Core.Entities;
5+
56
using NLog;
67

78
using Range = LogExpert.Core.Entities.Range;

src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using LogExpert.Classes.ILogLineColumnizerCallback;
1+
using LogExpert.Core.Callback;
22
using LogExpert.Core.Classes;
33
using LogExpert.Core.Interface;
4+
45
using NLog;
56

67
using System;

0 commit comments

Comments
 (0)