Skip to content

Commit

Permalink
♻ Minor improvements in AutoCat(s) (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvegter committed Mar 16, 2019
1 parent d5909d4 commit eedc7ef
Show file tree
Hide file tree
Showing 79 changed files with 578 additions and 563 deletions.
14 changes: 14 additions & 0 deletions src/Depressurizer.Core/AutoCats/AutoCatRule.cs
@@ -0,0 +1,14 @@
using System.Xml.Serialization;

namespace Depressurizer.Core.AutoCats
{
public class AutoCatRule
{
#region Public Properties

[XmlElement("Text")]
public string Name { get; set; }

#endregion
}
}
9 changes: 2 additions & 7 deletions src/Depressurizer.Core/AutoCats/HoursPlayedRule.cs
@@ -1,8 +1,6 @@
using System.Xml.Serialization;

namespace Depressurizer.Core.AutoCats
namespace Depressurizer.Core.AutoCats
{
public sealed class HoursPlayedRule
public sealed class HoursPlayedRule : AutoCatRule
{
#region Constructors and Destructors

Expand Down Expand Up @@ -39,9 +37,6 @@ public HoursPlayedRule(HoursPlayedRule other)
/// </summary>
public double MinHours { get; set; }

[XmlElement("Text")]
public string Name { get; set; }

#endregion
}
}
8 changes: 2 additions & 6 deletions src/Depressurizer.Core/AutoCats/HowLongToBeatRule.cs
@@ -1,9 +1,8 @@
using System.Xml.Serialization;
using Depressurizer.Core.Enums;
using Depressurizer.Core.Enums;

namespace Depressurizer.Core.AutoCats
{
public sealed class HowLongToBeatRule
public sealed class HowLongToBeatRule : AutoCatRule
{
#region Constructors and Destructors

Expand Down Expand Up @@ -42,9 +41,6 @@ public HowLongToBeatRule(HowLongToBeatRule other)
/// </summary>
public float MinHours { get; set; }

[XmlElement("Text")]
public string Name { get; set; }

public TimeType TimeType { get; set; }

#endregion
Expand Down
44 changes: 44 additions & 0 deletions src/Depressurizer.Core/AutoCats/UserScoreRule.cs
@@ -0,0 +1,44 @@
namespace Depressurizer.Core.AutoCats
{
public class UserScoreRule : AutoCatRule
{
#region Constructors and Destructors

public UserScoreRule(string name, int minScore, int maxScore, int minReviews, int maxReviews)
{
Name = name;
MinScore = minScore;
MaxScore = maxScore;
MinReviews = minReviews;
MaxReviews = maxReviews;
}

public UserScoreRule(UserScoreRule other)
{
Name = other.Name;
MinScore = other.MinScore;
MaxScore = other.MaxScore;
MinReviews = other.MinReviews;
MaxReviews = other.MaxReviews;
}

/// <summary>
/// Parameter-less constructor for XmlSerializer.
/// </summary>
private UserScoreRule() { }

#endregion

#region Public Properties

public int MaxReviews { get; set; }

public int MaxScore { get; set; }

public int MinReviews { get; set; }

public int MinScore { get; set; }

#endregion
}
}
35 changes: 35 additions & 0 deletions src/Depressurizer.Core/Helpers/Serialization.cs
@@ -0,0 +1,35 @@
namespace Depressurizer.Core.Helpers
{
public static class Serialization
{
/// <summary>
/// Class containing common serialization constants.
/// </summary>
public static class Constants
{
#region Constants

/// <summary>
/// Filter
/// </summary>
public const string Filter = "Filter";

/// <summary>
/// Name
/// </summary>
public const string Name = "Name";

/// <summary>
/// Prefix
/// </summary>
public const string Prefix = "Prefix";

/// <summary>
/// Rule
/// </summary>
public const string Rule = "Rule";

#endregion
}
}
}
Expand Up @@ -8,7 +8,7 @@
using Depressurizer.Core.Models;
using Depressurizer.Properties;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
/// <summary>
/// Abstract base class for autocategorization schemes. Call PreProcess before any set of autocat operations.
Expand Down Expand Up @@ -219,14 +219,14 @@ public virtual void DeProcess()
db = null;
}

public virtual string GetProcessedString(string s)
public virtual string GetCategoryName(string name)
{
if (string.IsNullOrEmpty(Prefix))
{
return s;
return name;
}

return Prefix + s;
return Prefix + name;
}

/// <summary>
Expand Down
Expand Up @@ -4,7 +4,7 @@
using System.Windows.Forms;
using Depressurizer.Core.Enums;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
[TypeDescriptionProvider(typeof(InstantiableClassProvider<AutoCatConfigPanel, UserControl>))]
public class AutoCatConfigPanel : UserControl
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -2,7 +2,7 @@
using System.Windows.Forms;
using Depressurizer.Core.Enums;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Curator : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -3,7 +3,7 @@
using System.Threading;
using System.Windows.Forms;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_DevPub : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,7 +1,7 @@
using System;
using System.Windows.Forms;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Flags : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,7 +1,7 @@
using System;
using System.Windows.Forms;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Genre : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Windows.Forms;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Group : AutoCatConfigPanel
{
Expand All @@ -26,19 +26,26 @@ public AutoCatConfigPanel_Group(List<AutoCat> autocats)

#endregion

#region Public Methods and Operators
#region Public Properties

public List<string> GetGroup()
public List<string> Groups
{
List<string> group = new List<string>();
foreach (string name in lbAutocats.Items)
get
{
group.Add(name);
}
List<string> group = new List<string>();
foreach (string name in lbAutocats.Items)
{
group.Add(name);
}

return group;
return group;
}
}

#endregion

#region Public Methods and Operators

public override void LoadFromAutoCat(AutoCat autoCat)
{
AutoCatGroup ac = autoCat as AutoCatGroup;
Expand All @@ -53,13 +60,12 @@ public override void LoadFromAutoCat(AutoCat autoCat)

public override void SaveToAutoCat(AutoCat autoCat)
{
AutoCatGroup ac = autoCat as AutoCatGroup;
if (ac == null)
if (!(autoCat is AutoCatGroup ac))
{
return;
}

ac.Autocats = GetGroup();
ac.Autocats = Groups;
}

#endregion
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -5,7 +5,7 @@
using Depressurizer.Core.AutoCats;
using Depressurizer.Core.Enums;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Hltb : AutoCatConfigPanel
{
Expand Down Expand Up @@ -69,7 +69,7 @@ public override void LoadFromAutoCat(AutoCat autoCat)

txtPrefix.Text = acHltb.Prefix;
chkIncludeUnknown.Checked = acHltb.IncludeUnknown;
txtUnknownText.Text = acHltb.UnknownText == null ? string.Empty : acHltb.UnknownText;
txtUnknownText.Text = acHltb.UnknownText ?? string.Empty;
acHltb.IncludeUnknown = chkIncludeUnknown.Checked;
acHltb.UnknownText = txtUnknownText.Text;

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -4,7 +4,7 @@
using System.Windows.Forms;
using Depressurizer.Core.AutoCats;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_HoursPlayed : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -2,7 +2,7 @@
using System.Windows.Forms;
using Depressurizer.Core.Models;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Language : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -4,7 +4,7 @@
using System.Windows.Forms;
using Depressurizer.Core.Models;

namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Manual : AutoCatConfigPanel
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,4 +1,4 @@
namespace Depressurizer
namespace Depressurizer.AutoCats
{
public partial class AutoCatConfigPanel_Name : AutoCatConfigPanel
{
Expand All @@ -22,7 +22,7 @@ public override void LoadFromAutoCat(AutoCat autoCat)
return;
}

txtPrefix.Text = acName.Prefix == null ? string.Empty : acName.Prefix;
txtPrefix.Text = acName.Prefix ?? string.Empty;
cbSkipThe.Checked = acName.SkipThe;
cbGroupNumbers.Checked = acName.GroupNumbers;
chkgroupNonEnglishCharacters.Checked = acName.GroupNonEnglishCharacters;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eedc7ef

Please sign in to comment.