Skip to content

Commit 7f90a6c

Browse files
committed
Refactor access modifiers and relocate IPlugin implementation
Changed multiple classes and inner structures to `internal` for improved encapsulation. Moved the `IPlugin` interface to a new file to enhance modularity and maintain code organization. These changes aim to improve code maintainability and clarity.
1 parent 8fad678 commit 7f90a6c

File tree

4 files changed

+59
-58
lines changed

4 files changed

+59
-58
lines changed

source/Commas/EntryPoint.cs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,56 +45,4 @@ public string DoAction(Form parentForm, string srtText, double frameRate, string
4545

4646
return "";
4747
}
48-
}
49-
50-
public interface IPlugin
51-
{
52-
/// <summary>
53-
/// Name of the plug-in
54-
/// </summary>
55-
string Name { get; }
56-
57-
/// <summary>
58-
/// Text used in Subtitle Edit menu
59-
/// </summary>
60-
string Text { get; }
61-
62-
/// <summary>
63-
/// Version number of plugin
64-
/// </summary>
65-
decimal Version { get; }
66-
67-
/// <summary>
68-
/// Description of what plugin does
69-
/// </summary>
70-
string Description { get; }
71-
72-
/// <summary>
73-
/// Can be one of these: file, tool, sync, translate, spellcheck
74-
/// </summary>
75-
string ActionType { get; }
76-
77-
/// <summary>
78-
/// Shortcut used to active plugin - e.g. Control+Shift+F9
79-
/// </summary>
80-
string Shortcut { get; }
81-
82-
/// <summary>
83-
/// This action of callsed when Subtitle Edit calls plugin
84-
/// </summary>
85-
/// <param name="parentForm">Main form in Subtitle Edit</param>
86-
/// <param name="srtText">SubRip text</param>
87-
/// <param name="frameRate">Current frame rate</param>
88-
/// <param name="uiLineBreak"></param>
89-
/// <param name="file">Current subtitle file name</param>
90-
/// <param name="videoFile">Current video file name</param>
91-
/// <param name="rawText">Subtitle raw format</param>
92-
/// <returns>Dialog</returns>
93-
string DoAction(Form parentForm,
94-
string srtText,
95-
double frameRate,
96-
string uiLineBreak,
97-
string file,
98-
string videoFile,
99-
string rawText);
10048
}

source/Commas/IPlugin.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace Nikse.SubtitleEdit.PluginLogic;
2+
3+
public interface IPlugin
4+
{
5+
/// <summary>
6+
/// Name of the plug-in
7+
/// </summary>
8+
string Name { get; }
9+
10+
/// <summary>
11+
/// Text used in Subtitle Edit menu
12+
/// </summary>
13+
string Text { get; }
14+
15+
/// <summary>
16+
/// Version number of plugin
17+
/// </summary>
18+
decimal Version { get; }
19+
20+
/// <summary>
21+
/// Description of what plugin does
22+
/// </summary>
23+
string Description { get; }
24+
25+
/// <summary>
26+
/// Can be one of these: file, tool, sync, translate, spellcheck
27+
/// </summary>
28+
string ActionType { get; }
29+
30+
/// <summary>
31+
/// Shortcut used to active plugin - e.g. Control+Shift+F9
32+
/// </summary>
33+
string Shortcut { get; }
34+
35+
/// <summary>
36+
/// This action of callsed when Subtitle Edit calls plugin
37+
/// </summary>
38+
/// <param name="parentForm">Main form in Subtitle Edit</param>
39+
/// <param name="srtText">SubRip text</param>
40+
/// <param name="frameRate">Current frame rate</param>
41+
/// <param name="uiLineBreak"></param>
42+
/// <param name="file">Current subtitle file name</param>
43+
/// <param name="videoFile">Current video file name</param>
44+
/// <param name="rawText">Subtitle raw format</param>
45+
/// <returns>Dialog</returns>
46+
string DoAction(Form parentForm,
47+
string srtText,
48+
double frameRate,
49+
string uiLineBreak,
50+
string file,
51+
string videoFile,
52+
string rawText);
53+
}

source/Commas/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Commas;
66

7-
public partial class Main : Form
7+
internal partial class Main : Form
88
{
99
private readonly Subtitle _subtitle;
1010
private volatile bool _isProcessing;

source/Commas/Services/LmStudioClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Nikse.SubtitleEdit.PluginLogic;
77

8-
public class LmStudioClient : IDisposable
8+
internal class LmStudioClient : IDisposable
99
{
1010
private readonly string _prompt;
1111
private readonly HttpClient _httpClient;
@@ -56,7 +56,7 @@ public async Task<string> SendAsync(string text)
5656

5757
public void Dispose() => _httpClient.Dispose();
5858

59-
public class ChatCompletionRequest(bool stream, Message[] messages, double temperature)
59+
internal class ChatCompletionRequest(bool stream, Message[] messages, double temperature)
6060
{
6161
[JsonProperty("stream")]
6262
public bool Stream { get; } = stream;
@@ -68,7 +68,7 @@ public class ChatCompletionRequest(bool stream, Message[] messages, double tempe
6868
public double Temperature { get; } = temperature;
6969
}
7070

71-
public class Message(string role, string content)
71+
internal class Message(string role, string content)
7272
{
7373
[JsonProperty("role")]
7474
public string Role { get; } = role;
@@ -77,7 +77,7 @@ public class Message(string role, string content)
7777
public string Content { get; } = content;
7878
}
7979

80-
public class ChatResponse
80+
internal class ChatResponse
8181
{
8282
[JsonProperty("model")]
8383
public string Model { get; set; }
@@ -86,7 +86,7 @@ public class ChatResponse
8686
public Choices[] Choices { get; set; }
8787
}
8888

89-
public class Choices
89+
internal class Choices
9090
{
9191
[JsonProperty("index")]
9292
public int Index { get; set; }

0 commit comments

Comments
 (0)