Skip to content

Commit 7dd8cc9

Browse files
committed
replaced generic clone with Iclonable interface for this particular use case, now the highlight entries are displayed again
1 parent 7b3a1f4 commit 7dd8cc9

12 files changed

Lines changed: 346 additions & 364 deletions

File tree

src/LogExpert/Classes/Highlight/ActionEntry.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
namespace LogExpert.Classes.Highlight
44
{
55
[Serializable]
6-
public class ActionEntry
6+
public class ActionEntry : ICloneable
77
{
88
#region Fields
99

10-
public string actionParam;
11-
public string pluginName;
10+
public string ActionParam { get; set; }
1211

13-
#endregion
14-
15-
#region Public methods
12+
public string PluginName { get; set; }
1613

17-
public ActionEntry Copy()
14+
public object Clone()
1815
{
19-
ActionEntry e = new();
20-
e.pluginName = this.pluginName;
21-
e.actionParam = this.actionParam;
22-
return e;
16+
var actionEntry = new ActionEntry
17+
{
18+
PluginName = PluginName,
19+
ActionParam = ActionParam
20+
};
21+
22+
return actionEntry;
2323
}
2424

2525
#endregion
Lines changed: 56 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,204 +1,108 @@
1-
using System;
1+
using Newtonsoft.Json;
2+
3+
using System;
24
using System.Drawing;
35
using System.Text.RegularExpressions;
4-
using Newtonsoft.Json;
5-
//using System.Linq;
66

77
namespace LogExpert.Classes.Highlight
88
{
99
[Serializable]
10-
public class HilightEntry
10+
[method: JsonConstructor]
11+
public class HilightEntry() : ICloneable
1112
{
1213
#region Fields
1314

14-
private ActionEntry actionEntry;
15-
private Color bgColor;
16-
private string bookmarkComment;
17-
private Color fgColor;
18-
private bool isActionEntry;
19-
private bool isBold;
20-
private bool isCaseSensitive;
21-
private bool isLedSwitch;
22-
private bool isRegEx;
23-
24-
[NonSerialized] private bool isSearchHit; // highlightes search result
25-
26-
private bool isSetBookmark;
27-
private bool isStopTail;
28-
private bool isWordMatch;
29-
private bool noBackground;
30-
3115
[NonSerialized] private Regex regex = null;
3216

33-
private string searchText = "";
34-
35-
#endregion
36-
37-
#region cTor
38-
39-
[JsonConstructor]
40-
public HilightEntry()
41-
{
42-
43-
}
44-
45-
public HilightEntry(string searchText, Color fgColor, Color bgColor, bool isWordMatch)
46-
{
47-
this.searchText = searchText;
48-
this.fgColor = fgColor;
49-
this.bgColor = bgColor;
50-
this.isRegEx = false;
51-
this.isCaseSensitive = false;
52-
this.isLedSwitch = false;
53-
this.isStopTail = false;
54-
this.isSetBookmark = false;
55-
this.isActionEntry = false;
56-
this.actionEntry = null;
57-
this.IsWordMatch = isWordMatch;
58-
}
59-
60-
61-
public HilightEntry(string searchText, Color fgColor, Color bgColor,
62-
bool isRegEx, bool isCaseSensitive, bool isLedSwitch,
63-
bool isStopTail, bool isSetBookmark, bool isActionEntry, ActionEntry actionEntry, bool isWordMatch)
64-
{
65-
this.searchText = searchText;
66-
this.fgColor = fgColor;
67-
this.bgColor = bgColor;
68-
this.isRegEx = isRegEx;
69-
this.isCaseSensitive = isCaseSensitive;
70-
this.isLedSwitch = isLedSwitch;
71-
this.isStopTail = isStopTail;
72-
this.isSetBookmark = isSetBookmark;
73-
this.isActionEntry = isActionEntry;
74-
this.actionEntry = actionEntry;
75-
this.IsWordMatch = isWordMatch;
76-
}
17+
private string _searchText = string.Empty;
7718

78-
#endregion
19+
#endregion Fields
7920

8021
#region Properties
8122

82-
public bool IsStopTail
83-
{
84-
get { return isStopTail; }
85-
set { isStopTail = value; }
86-
}
23+
public bool IsStopTail { get; set; }
8724

88-
public bool IsSetBookmark
89-
{
90-
get { return isSetBookmark; }
91-
set { isSetBookmark = value; }
92-
}
25+
public bool IsSetBookmark { get; set; }
9326

94-
public bool IsRegEx
95-
{
96-
get { return isRegEx; }
97-
set { isRegEx = value; }
98-
}
27+
public bool IsRegEx { get; set; }
9928

100-
public bool IsCaseSensitive
101-
{
102-
get { return isCaseSensitive; }
103-
set
104-
{
105-
isCaseSensitive = value;
106-
this.regex = null;
107-
}
108-
}
29+
public bool IsCaseSensitive { get; set; }
10930

31+
public Color ForegroundColor { get; set; }
11032

111-
public Color ForegroundColor
112-
{
113-
get { return this.fgColor; }
114-
set { this.fgColor = value; }
115-
}
116-
117-
public Color BackgroundColor
118-
{
119-
get { return this.bgColor; }
120-
set { this.bgColor = value; }
121-
}
33+
public Color BackgroundColor { get; set; }
12234

12335
public string SearchText
12436
{
125-
get { return this.searchText; }
37+
get => _searchText;
12638
set
12739
{
128-
this.searchText = value;
129-
this.regex = null;
40+
_searchText = value;
41+
regex = null;
13042
}
13143
}
13244

133-
public bool IsLedSwitch
134-
{
135-
get { return this.isLedSwitch; }
136-
set { this.isLedSwitch = value; }
137-
}
45+
public bool IsLedSwitch { get; set; }
13846

139-
public ActionEntry ActionEntry
140-
{
141-
get { return this.actionEntry; }
142-
set { this.actionEntry = value; }
143-
}
47+
public ActionEntry ActionEntry { get; set; }
14448

145-
public bool IsActionEntry
146-
{
147-
get { return this.isActionEntry; }
148-
set { this.isActionEntry = value; }
149-
}
49+
public bool IsActionEntry { get; set; }
15050

151-
public string BookmarkComment
152-
{
153-
get { return this.bookmarkComment; }
154-
set { this.bookmarkComment = value; }
155-
}
51+
public string BookmarkComment { get; set; }
15652

15753
public Regex Regex
15854
{
15955
get
16056
{
161-
if (this.regex == null)
57+
if (regex == null)
16258
{
163-
if (this.IsRegEx)
59+
if (IsRegEx)
16460
{
165-
this.regex = new Regex(this.SearchText,
166-
this.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
61+
regex = new Regex(SearchText, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
16762
}
16863
else
16964
{
170-
this.regex = new Regex(Regex.Escape(this.SearchText),
171-
this.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
65+
regex = new Regex(Regex.Escape(SearchText), IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
17266
}
17367
}
174-
return this.regex;
68+
return regex;
17569
}
17670
}
17771

178-
public bool IsWordMatch
179-
{
180-
get { return this.isWordMatch; }
181-
set { this.isWordMatch = value; }
182-
}
72+
public bool IsWordMatch { get; set; }
18373

184-
public bool IsSearchHit
185-
{
186-
get { return this.isSearchHit; }
187-
set { this.isSearchHit = value; }
188-
}
74+
// highlightes search result
75+
[field: NonSerialized]
76+
public bool IsSearchHit { get; set; }
18977

190-
public bool IsBold
191-
{
192-
get { return this.isBold; }
193-
set { this.isBold = value; }
194-
}
78+
public bool IsBold { get; set; }
19579

196-
public bool NoBackground
197-
{
198-
get { return noBackground; }
199-
set { noBackground = value; }
200-
}
80+
public bool NoBackground { get; set; }
20181

202-
#endregion
82+
public object Clone()
83+
{
84+
var highLightEntry = new HilightEntry
85+
{
86+
SearchText = SearchText,
87+
ForegroundColor = ForegroundColor,
88+
BackgroundColor = BackgroundColor,
89+
IsRegEx = IsRegEx,
90+
IsCaseSensitive = IsCaseSensitive,
91+
IsLedSwitch = IsLedSwitch,
92+
IsStopTail = IsStopTail,
93+
IsSetBookmark = IsSetBookmark,
94+
IsActionEntry = IsActionEntry,
95+
ActionEntry = ActionEntry != null ? (ActionEntry)ActionEntry.Clone() : null,
96+
IsWordMatch = IsWordMatch,
97+
IsBold = IsBold,
98+
BookmarkComment = BookmarkComment,
99+
NoBackground = NoBackground,
100+
IsSearchHit = IsSearchHit
101+
};
102+
103+
return highLightEntry;
104+
}
105+
106+
#endregion Properties
203107
}
204108
}

src/LogExpert/Classes/Highlight/HilightMatchEntry.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
/// </summary>
66
public class HilightMatchEntry
77
{
8-
#region Fields
9-
10-
#endregion
11-
128
#region Properties
139

1410
public HilightEntry HilightEntry { get; set; }
@@ -23,7 +19,7 @@ public class HilightMatchEntry
2319

2420
public override string ToString()
2521
{
26-
return this.HilightEntry.SearchText + "/" + this.StartPos + "/" + this.Length;
22+
return $"{HilightEntry.SearchText}/{StartPos}/{Length}";
2723
}
2824

2925
#endregion

0 commit comments

Comments
 (0)