Skip to content

Commit

Permalink
Code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
daleghent committed Mar 1, 2024
1 parent 1bcd182 commit 104f06d
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 34 deletions.
8 changes: 4 additions & 4 deletions Email/EmailCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ public IList<string> ValidateSettings() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "SmtpHostName":
case nameof(SmtpHostName):
SmtpHostName = Properties.Settings.Default.SmtpHostName;
break;

case "SmtpHostPort":
case nameof(SmtpHostPort):
SmtpHostPort = Properties.Settings.Default.SmtpHostPort;
break;

case "SmtpUsername":
case nameof(SmtpUsername):
SmtpUsername = Security.Decrypt(Properties.Settings.Default.SmtpUsername);
break;

case "SmtpPassword":
case nameof(SmtpPassword):
SmtpPassword = Security.Decrypt(Properties.Settings.Default.SmtpPassword);
break;
}
Expand Down
12 changes: 7 additions & 5 deletions Email/FailuresToEmailTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,26 @@ public override string ToString() {
}

private string SmtpFromAddress { get; set; }
private string SmtpDefaultRecipients { get; set; }
private string EmailFailureSubjectText { get; set; }
private string EmailFailureBodyText { get; set; }

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "SmtpFromAddress":
case nameof(SmtpFromAddress):
SmtpFromAddress = Properties.Settings.Default.SmtpFromAddress;
break;

case "SmtpDefaultRecipients":
Recipient = Properties.Settings.Default.SmtpDefaultRecipients;
case nameof(SmtpDefaultRecipients):
SmtpDefaultRecipients = Properties.Settings.Default.SmtpDefaultRecipients;
Recipient = SmtpDefaultRecipients;
break;

case "EmailFailureSubjectText":
case nameof(EmailFailureSubjectText):
EmailFailureSubjectText = Properties.Settings.Default.EmailFailureSubjectText;
break;

case "EmailFailureBodyText":
case nameof(EmailFailureBodyText):
EmailFailureBodyText = Properties.Settings.Default.EmailFailureBodyText;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Email/SendToEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ public override string ToString() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "SmtpFromAddress":
case nameof(SmtpFromAddress):
SmtpFromAddress = Properties.Settings.Default.SmtpFromAddress;
break;

case "SmtpDefaultRecipients":
case nameof(SmtpDefaultRecipients):
SmtpDefaultRecipients = Properties.Settings.Default.SmtpDefaultRecipients;
Recipient = SmtpDefaultRecipients;
break;
Expand Down
6 changes: 3 additions & 3 deletions IFTTT/FailuresToIftttTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ private string ResolveAllTokens(string text, FailedItem failedItem, IMetadata me

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "IftttFailureValue1":
case nameof(IftttFailureValue1):
IftttFailureValue1 = Properties.Settings.Default.IftttFailureValue1;
break;

case "IftttFailureValue2":
case nameof(IftttFailureValue2):
IftttFailureValue2 = Properties.Settings.Default.IftttFailureValue2;
break;

case "IftttFailureValue3":
case nameof(IftttFailureValue3):
IftttFailureValue3 = Properties.Settings.Default.IftttFailureValue3;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion IFTTT/IftttCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public IList<string> ValidateSettings() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "IFTTTWebhookKey":
case nameof(IFTTTWebhookKey):
IFTTTWebhookKey = Security.Decrypt(Properties.Settings.Default.IFTTTWebhookKey);
break;
}
Expand Down
16 changes: 11 additions & 5 deletions IpProtocols/IpCommon.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#region "copyright"

/*
Copyright Dale Ghent <[email protected]>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/
*/

#endregion "copyright"

namespace DaleGhent.NINA.GroundStation.IpProtocols
{
Expand Down
3 changes: 0 additions & 3 deletions IpProtocols/SendUdp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ This Source Code Form is subject to the terms of the Mozilla Public
#endregion "copyright"

using DaleGhent.NINA.GroundStation.MetadataClient;
using Microsoft.AspNetCore.Mvc.Routing;
using Newtonsoft.Json;
using NINA.Core.Model;
using NINA.Core.Utility;
using NINA.Equipment.Interfaces.Mediator;
using NINA.Sequencer.SequenceItem;
using NINA.Sequencer.Validations;
using NmeaParser.Gnss.Ntrip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -45,7 +43,6 @@ public partial class SendUdp : SequenceItem, IValidatable, INotifyPropertyChange
private string address = string.Empty;
private ushort port = 0;
private string payload = string.Empty;
private bool addressIsOk = true;
private short payloadType;
private short lineTermination;

Expand Down
8 changes: 4 additions & 4 deletions MQTT/MqttCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ public IList<string> ValidateSettings() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "MqttBrokerHost":
case nameof(MqttBrokerHost):
MqttBrokerHost = Properties.Settings.Default.MqttBrokerHost;
break;

case "MqttBrokerPort":
case nameof(MqttBrokerPort):
MqttBrokerPort = Properties.Settings.Default.MqttBrokerPort;
break;

case "MqttBrokerUseTls":
case nameof(MqttBrokerUseTls):
MqttBrokerUseTls = Properties.Settings.Default.MqttBrokerUseTls;
break;

case "MqttClientId":
case nameof(MqttClientId):
MqttClientId = Properties.Settings.Default.MqttClientId;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Pushover/FailuresToPushoverTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ public override string ToString() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "PushoverFailureTitleText":
case nameof(PushoverFailureTitleText):
PushoverFailureTitleText = Properties.Settings.Default.PushoverFailureTitleText;
break;

case "PushoverFailureBodyText":
case nameof(PushoverFailureBodyText):
PushoverFailureBodyText = Properties.Settings.Default.PushoverFailureBodyText;
break;
}
Expand Down
1 change: 0 additions & 1 deletion PushoverClient/PushoverClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ This Source Code Form is subject to the terms of the Mozilla Public
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;

Expand Down
2 changes: 1 addition & 1 deletion Telegram/FailuresToTelegramTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public override string ToString() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "TelegramFailureBodyText":
case nameof(TelegramFailureBodyText):
TelegramFailureBodyText = Properties.Settings.Default.TelegramFailureBodyText;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Telegram/TelegramCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public IList<string> ValidateSettings() {

private void SettingsChanged(object sender, PropertyChangedEventArgs e) {
switch (e.PropertyName) {
case "TelegramAccessToken":
case nameof(TelegramAccessToken):
TelegramAccessToken = Security.Decrypt(Properties.Settings.Default.TelegramAccessToken);
break;

case "TelegramChatId":
case nameof(TelegramChatId):
TelegramChatId = Security.Decrypt(Properties.Settings.Default.TelegramChatId);
break;
}
Expand Down
14 changes: 13 additions & 1 deletion Utilities/BackgroundQueueWorker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
using NINA.Core.Utility;
#region "copyright"

/*
Copyright 2023 Dale Ghent <[email protected]>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/
*/

#endregion "copyright"

using NINA.Core.Utility;
using Nito.AsyncEx;
using System;
using System.Threading;
Expand Down

0 comments on commit 104f06d

Please sign in to comment.