From c77c2b34f3050e4c78defde6ca4ffc90c2882090 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 15 Jun 2021 12:19:12 +1000 Subject: [PATCH] final batch of cleanups --- AddItemDialogue.cs | 15 +++------------ MainWindow.cs | 4 ++-- SettingsWindow.cs | 2 +- YahooAuctionsItem.cs | 4 +++- buypeeb.csproj | 1 + 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/AddItemDialogue.cs b/AddItemDialogue.cs index 73123c1..e7a0ca1 100644 --- a/AddItemDialogue.cs +++ b/AddItemDialogue.cs @@ -2,11 +2,10 @@ using Gtk; namespace Buypeeb { internal class AddItemDialogue : Dialog { - private readonly Entry entryURL; - private readonly Entry entryName; + public Entry entryURL { get; } + public Entry entryName { get; } - public AddItemDialogue() : this(new Builder("add.glade")) { - } + public AddItemDialogue() : this(new Builder("add.glade")) { } private AddItemDialogue(Builder builder) : base(builder.GetObject("DialogueAdd").Handle) { Title = "Add item"; @@ -19,13 +18,5 @@ namespace Buypeeb { private static void Window_Shutdown(object sender, DeleteEventArgs args) { Application.Quit(); } - - public string GetURL() { - return entryURL.Text; - } - - public string GetName() { - return entryName.Text; - } } } diff --git a/MainWindow.cs b/MainWindow.cs index 974aa34..0a83eaa 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -548,8 +548,8 @@ namespace Buypeeb { // Console.WriteLine("ButtonAddClicked"); var aid = new AddItemDialogue {Title = "Buypeeb"}; aid.Run(); - var url = aid.GetURL(); - var name = aid.GetName(); + var url = aid.entryURL.Text; + var name = aid.entryName.Text; aid.Dispose(); // vry simpl url validation for simpol creachers diff --git a/SettingsWindow.cs b/SettingsWindow.cs index 36cd2f2..8544707 100644 --- a/SettingsWindow.cs +++ b/SettingsWindow.cs @@ -61,7 +61,7 @@ namespace Buypeeb { if (!int.TryParse(e.Text, out var result)) { failed = true; } else { - if (result < 30 || result > 6000) { + if (result is < 30 or > 6000) { failed = true; } } diff --git a/YahooAuctionsItem.cs b/YahooAuctionsItem.cs index 4e89726..28fd7ce 100644 --- a/YahooAuctionsItem.cs +++ b/YahooAuctionsItem.cs @@ -5,6 +5,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.Text.RegularExpressions; using CsvHelper.Configuration.Attributes; +// ReSharper disable MemberCanBePrivate.Global namespace Buypeeb { internal class YahooAuctionsItem { @@ -19,8 +20,9 @@ namespace Buypeeb { // there's not really a need for it i guess but it's my program and i can do what i want // anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in // userdata.json - // ReSharper disable once MemberCanBePrivate.Global + // don't remove ID's set attribute - JSON deserialisation will silently fail to assign IDs to the auction items! + // you also don't want to private any of the setters, which will have a similar effect. [Ignore] public string id { get; set; } public string name { get; set; } public int Price; diff --git a/buypeeb.csproj b/buypeeb.csproj index 3cd4a41..b37f669 100755 --- a/buypeeb.csproj +++ b/buypeeb.csproj @@ -11,6 +11,7 @@ %(Filename)%(Extension) +