Skip to content

Commit aefefcc

Browse files
committed
Added properties for simpler use.
1 parent e660425 commit aefefcc

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎ReClass.NET/Core/CoreFunctionsManager.cs‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.Contracts;
44
using System.IO;
5+
using System.Linq;
56
using System.Windows.Forms;
67
using ReClassNET.Debugger;
78
using ReClassNET.Extensions;
@@ -12,15 +13,21 @@ namespace ReClassNET.Core
1213
{
1314
public class CoreFunctionsManager : IDisposable
1415
{
15-
public readonly Dictionary<string, ICoreProcessFunctions> functionsRegistry = new Dictionary<string, ICoreProcessFunctions>();
16-
17-
public IEnumerable<string> FunctionProviders => functionsRegistry.Keys;
18-
public ICoreProcessFunctions CurrentFunctions => currentFunctions;
16+
private readonly Dictionary<string, ICoreProcessFunctions> functionsRegistry = new Dictionary<string, ICoreProcessFunctions>();
1917

2018
private readonly InternalCoreFunctions internalCoreFunctions;
2119

2220
private ICoreProcessFunctions currentFunctions;
2321

22+
public IEnumerable<string> FunctionProviders => functionsRegistry.Keys;
23+
24+
public ICoreProcessFunctions CurrentFunctions => currentFunctions;
25+
26+
public string CurrentFunctionsProvider => functionsRegistry
27+
.Where(kv => kv.Value == currentFunctions)
28+
.Select(kv => kv.Key)
29+
.FirstOrDefault();
30+
2431
public CoreFunctionsManager()
2532
{
2633
internalCoreFunctions = InternalCoreFunctions.Create();

‎ReClass.NET/Forms/PluginForm.cs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ internal PluginForm(PluginManager pluginManager)
4343

4444
UpdatePluginDescription();
4545

46-
// Native Methods Tab
46+
// Native Methods Tab
4747

48-
string[] arrayOfFunctions = Program.CoreFunctions.FunctionProviders.ToArray();
49-
var funcIndexStr = Program.CoreFunctions.functionsRegistry.FirstOrDefault(p => p.Value == Program.CoreFunctions.CurrentFunctions);
50-
51-
functionsProvidersComboBox.Items.AddRange(arrayOfFunctions);
52-
functionsProvidersComboBox.SelectedIndex = funcIndexStr.Value == null ? 0 : Array.IndexOf(arrayOfFunctions, funcIndexStr.Key);
48+
var providers = Program.CoreFunctions.FunctionProviders.ToArray();
49+
functionsProvidersComboBox.Items.AddRange(providers);
50+
functionsProvidersComboBox.SelectedIndex = Array.IndexOf(providers, Program.CoreFunctions.CurrentFunctionsProvider);
5351
}
5452

5553
protected override void OnLoad(EventArgs e)
@@ -69,7 +67,7 @@ protected override void OnFormClosed(FormClosedEventArgs e)
6967
#region Event Handler
7068

7169
private void pluginsDataGridView_SelectionChanged(object sender, EventArgs e)
72-
{
70+
{
7371
UpdatePluginDescription();
7472
}
7573

0 commit comments

Comments
 (0)