Skip to content

Commit

Permalink
optimized access modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKnarz committed Mar 20, 2023
1 parent 2041077 commit 063b16e
Show file tree
Hide file tree
Showing 65 changed files with 334 additions and 334 deletions.
8 changes: 4 additions & 4 deletions Common/KNARZhelper/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Log
/// <summary>
/// Logger instance from playnite
/// </summary>
private static readonly ILogger logger = LogManager.GetLogger();
private static readonly ILogger _logger = LogManager.GetLogger();

/// <summary>
/// Logs an error message.
Expand All @@ -33,7 +33,7 @@ public static void Error(Exception ex, string Message = "", bool showDialog = fa

Message += $"|{traceInfos.FileName}|{traceInfos.LineNumber}";

logger.Error(ex, $"{Message}");
_logger.Error(ex, $"{Message}");

if (showDialog)
{
Expand All @@ -48,7 +48,7 @@ public static void Error(Exception ex, string Message = "", bool showDialog = fa
/// <param name="showDialog">Additionally shows the error message as a dialog if set to true.</param>
public static void Info(string Message, bool showDialog = false)
{
logger.Info($"{Message}");
_logger.Info($"{Message}");

if (showDialog)
{
Expand All @@ -60,7 +60,7 @@ public static void Info(string Message, bool showDialog = false)
/// Logs a debug message.
/// </summary>
/// <param name="Message">The Message to log</param>
public static void Debug(string Message) => logger.Debug($"{Message}");
public static void Debug(string Message) => _logger.Debug($"{Message}");
}

/// <summary>
Expand Down
56 changes: 28 additions & 28 deletions Common/KNARZhelper/PlatformHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,43 @@ namespace KNARZhelper
/// </summary>
public class PlatformHelper
{
private readonly Dictionary<string, string[]> platformSpecNameByNormalName;
private readonly Regex TrimCompanyName = new Regex(@"^(atari|bandai|coleco|commodore|mattel|nec|nintendo|sega|sinclair|snk|sony|microsoft)?\s+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
private readonly Regex TrimInput = new Regex(@"^(pal|jpn?|usa?|ntsc)\s+|[™®©]", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
private readonly Dictionary<string, string[]> _platformSpecNameByNormalName;
private readonly Regex _trimCompanyName = new Regex(@"^(atari|bandai|coleco|commodore|mattel|nec|nintendo|sega|sinclair|snk|sony|microsoft)?\s+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
private readonly Regex _trimInput = new Regex(@"^(pal|jpn?|usa?|ntsc)\s+|[™®©]", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);

public PlatformHelper(List<Platform> platforms)
{
platformSpecNameByNormalName = new Dictionary<string, string[]>(StringComparer.InvariantCultureIgnoreCase);
_platformSpecNameByNormalName = new Dictionary<string, string[]>(StringComparer.InvariantCultureIgnoreCase);

foreach (Platform platform in platforms.Where(p => p.SpecificationId != null))
{
platformSpecNameByNormalName.Add(platform.Name, new[] { platform.SpecificationId });
_platformSpecNameByNormalName.Add(platform.Name, new[] { platform.SpecificationId });

string nameWithoutCompany = TrimCompanyName.Replace(platform.Name, string.Empty);
string nameWithoutCompany = _trimCompanyName.Replace(platform.Name, string.Empty);

if (!platformSpecNameByNormalName.ContainsKey(nameWithoutCompany))
if (!_platformSpecNameByNormalName.ContainsKey(nameWithoutCompany))
{
platformSpecNameByNormalName.Add(nameWithoutCompany, new[] { platform.SpecificationId });
_platformSpecNameByNormalName.Add(nameWithoutCompany, new[] { platform.SpecificationId });
}
}
TryAddPlatformByName(platformSpecNameByNormalName, "3DO", "3do");
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "Microsoft Windows", "Windows", "PC", "PC CD-ROM", "PC DVD", "PC DVD-ROM", "Windows 95" }, new[] { "pc_windows" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "DOS", "MS-DOS" }, new[] { "pc_dos" });
TryAddPlatformByName(platformSpecNameByNormalName, "Linux", "pc_linux");
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "Mac", "OSX", "OS X", "MacOS", "Mac OS", "Mac OS X" }, new[] { "macintosh" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "Microsoft Xbox Series X", "Microsoft Xbox Series S", "Xbox Series X", "Xbox Series S", "Microsoft Xbox Series X/S", "Microsoft Xbox Series S/X", "Xbox Series X/S", "Xbox Series S/X", "Xbox Series X|S", }, new[] { "xbox_series" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "PS", "PS1", "PSX" }, new[] { "sony_playstation" });
TryAddPlatformByName(platformSpecNameByNormalName, "PS2", "sony_playstation2");
TryAddPlatformByName(platformSpecNameByNormalName, "PS3", "sony_playstation3");
TryAddPlatformByName(platformSpecNameByNormalName, "PS4", "sony_playstation4");
TryAddPlatformByName(platformSpecNameByNormalName, "PS5", "sony_playstation5");
TryAddPlatformByName(platformSpecNameByNormalName, "PSP", "sony_psp");
TryAddPlatformByName(platformSpecNameByNormalName, "Vita", "sony_vita");
TryAddPlatformByName(platformSpecNameByNormalName, "PS4/5", new[] { "sony_playstation4", "sony_playstation5" });
TryAddPlatformByName(platformSpecNameByNormalName, "Playstation 4/5", new[] { "sony_playstation4", "sony_playstation5" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "Sega Mega Drive", "Mega Drive", "Mega Drive/Genesis" }, new[] { "sega_genesis" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "Super NES", "Super Nintendo Entertainment System" }, new[] { "nintendo_super_nes" });
TryAddPlatformByName(platformSpecNameByNormalName, new[] { "SNK Neo Geo MVS", "Neo Geo MVS", "SNK Neo Geo AES", "Neo Geo AES" }, new[] { "snk_neogeo_aes" });
TryAddPlatformByName(_platformSpecNameByNormalName, "3DO", "3do");
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "Microsoft Windows", "Windows", "PC", "PC CD-ROM", "PC DVD", "PC DVD-ROM", "Windows 95" }, new[] { "pc_windows" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "DOS", "MS-DOS" }, new[] { "pc_dos" });
TryAddPlatformByName(_platformSpecNameByNormalName, "Linux", "pc_linux");
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "Mac", "OSX", "OS X", "MacOS", "Mac OS", "Mac OS X" }, new[] { "macintosh" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "Microsoft Xbox Series X", "Microsoft Xbox Series S", "Xbox Series X", "Xbox Series S", "Microsoft Xbox Series X/S", "Microsoft Xbox Series S/X", "Xbox Series X/S", "Xbox Series S/X", "Xbox Series X|S", }, new[] { "xbox_series" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "PS", "PS1", "PSX" }, new[] { "sony_playstation" });
TryAddPlatformByName(_platformSpecNameByNormalName, "PS2", "sony_playstation2");
TryAddPlatformByName(_platformSpecNameByNormalName, "PS3", "sony_playstation3");
TryAddPlatformByName(_platformSpecNameByNormalName, "PS4", "sony_playstation4");
TryAddPlatformByName(_platformSpecNameByNormalName, "PS5", "sony_playstation5");
TryAddPlatformByName(_platformSpecNameByNormalName, "PSP", "sony_psp");
TryAddPlatformByName(_platformSpecNameByNormalName, "Vita", "sony_vita");
TryAddPlatformByName(_platformSpecNameByNormalName, "PS4/5", new[] { "sony_playstation4", "sony_playstation5" });
TryAddPlatformByName(_platformSpecNameByNormalName, "Playstation 4/5", new[] { "sony_playstation4", "sony_playstation5" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "Sega Mega Drive", "Mega Drive", "Mega Drive/Genesis" }, new[] { "sega_genesis" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "Super NES", "Super Nintendo Entertainment System" }, new[] { "nintendo_super_nes" });
TryAddPlatformByName(_platformSpecNameByNormalName, new[] { "SNK Neo Geo MVS", "Neo Geo MVS", "SNK Neo Geo AES", "Neo Geo AES" }, new[] { "snk_neogeo_aes" });
}
private bool TryAddPlatformByName(Dictionary<string, string[]> dict, string platformName, params string[] platformSpecNames)
{
Expand Down Expand Up @@ -94,9 +94,9 @@ public IEnumerable<MetadataProperty> GetPlatforms(string platformName, bool stri
return new List<MetadataProperty>();
}

string sanitizedPlatformName = TrimInput.Replace(platformName, string.Empty);
string sanitizedPlatformName = _trimInput.Replace(platformName, string.Empty);

if (platformSpecNameByNormalName.TryGetValue(sanitizedPlatformName, out string[] specIds))
if (_platformSpecNameByNormalName.TryGetValue(sanitizedPlatformName, out string[] specIds))
{
return specIds.Select(s => new MetadataSpecProperty(s)).ToList<MetadataProperty>();
}
Expand Down
4 changes: 2 additions & 2 deletions Generic/CompanyCompanion/CompanyCompanion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public CompanyCompanion(IPlayniteAPI api) : base(api)
}

/// <summary>
/// Shows the merge companies window.
/// Shows the _merge companies window.
/// </summary>
public void ShowMergeView()
private void ShowMergeView()
{
try
{
Expand Down
16 changes: 8 additions & 8 deletions Generic/CompanyCompanion/CompanyCompanionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ namespace CompanyCompanion
{
public class CompanyCompanionSettings : ObservableObject
{
private bool showGroupKey = false;
private ObservableCollection<string> businessEntityDescriptors;
private ObservableCollection<string> ignoreWords;
private bool _showGroupKey = false;
private ObservableCollection<string> _businessEntityDescriptors;
private ObservableCollection<string> _ignoreWords;

/// <summary>
/// Defines, if the group key will be shown in the merge companies window.
/// Defines, if the group key will be shown in the _merge companies window.
/// </summary>
public bool ShowGroupKey { get => showGroupKey; set => SetValue(ref showGroupKey, value); }
public bool ShowGroupKey { get => _showGroupKey; set => SetValue(ref _showGroupKey, value); }
/// <summary>
/// List of words that will be removed from the games as business entity descriptors.
/// </summary>
public ObservableCollection<string> BusinessEntityDescriptors { get => businessEntityDescriptors; set => SetValue(ref businessEntityDescriptors, value); }
public ObservableCollection<string> BusinessEntityDescriptors { get => _businessEntityDescriptors; set => SetValue(ref _businessEntityDescriptors, value); }
/// <summary>
/// List of words than will be ignored when searching for similar companies.
/// </summary>
public ObservableCollection<string> IgnoreWords { get => ignoreWords; set => SetValue(ref ignoreWords, value); }
public ObservableCollection<string> IgnoreWords { get => _ignoreWords; set => SetValue(ref _ignoreWords, value); }
}

public class CompanyCompanionSettingsViewModel : ObservableObject, ISettings
Expand Down Expand Up @@ -89,7 +89,7 @@ public CompanyCompanionSettings Settings

public CompanyCompanionSettingsViewModel(CompanyCompanion plugin)
{
// Injecting your plugin instance is required for Save/Load method because Playnite saves data to a location based on what plugin requested the operation.
// Injecting your _plugin instance is required for Save/Load method because Playnite saves data to a location based on what _plugin requested the operation.
this.plugin = plugin;

// Load saved Settings.
Expand Down
Loading

0 comments on commit 063b16e

Please sign in to comment.