Skip to content

Commit fd2952b

Browse files
committed
Improve code quality
1 parent 4218b63 commit fd2952b

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Helper/PathHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class PathHelper
99
{
1010
public static string GetPathName(this string selectedPath)
1111
{
12-
if (string.IsNullOrEmpty(selectedPath)) return "";
12+
if (string.IsNullOrEmpty(selectedPath)) return string.Empty;
1313
var path = selectedPath.EndsWith(Constants.DirectorySeparator) ? selectedPath[0..^1] : selectedPath;
1414

1515
if (path.EndsWith(':'))
@@ -18,5 +18,4 @@ public static string GetPathName(this string selectedPath)
1818
return path.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
1919
.Last();
2020
}
21-
2221
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Collections.ObjectModel;
43
using System.ComponentModel;
54
using System.Linq;
@@ -8,15 +7,12 @@
87
using System.Windows.Forms;
98
using Flow.Launcher.Plugin.Explorer.Helper;
109
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
11-
using JetBrains.Annotations;
1210

1311
namespace Flow.Launcher.Plugin.Explorer.Views;
1412

1513
public partial class QuickAccessLinkSettings : INotifyPropertyChanged
1614
{
17-
1815
private string _selectedPath;
19-
2016
public string SelectedPath
2117
{
2218
get => _selectedPath;
@@ -26,20 +22,20 @@ public string SelectedPath
2622
{
2723
_selectedPath = value;
2824
OnPropertyChanged();
29-
if (string.IsNullOrEmpty(_selectedName)) SelectedName = _selectedPath.GetPathName();
25+
if (string.IsNullOrEmpty(_selectedName))
26+
{
27+
SelectedName = _selectedPath.GetPathName();
28+
}
3029
}
3130
}
3231
}
3332

34-
3533
private string _selectedName;
36-
3734
public string SelectedName
3835
{
3936
get
4037
{
41-
if (string.IsNullOrEmpty(_selectedName)) return _selectedPath.GetPathName();
42-
return _selectedName;
38+
return string.IsNullOrEmpty(_selectedName) ? _selectedPath.GetPathName() : _selectedName;
4339
}
4440
set
4541
{
@@ -52,7 +48,7 @@ public string SelectedName
5248
}
5349

5450
private bool IsEdit { get; set; }
55-
[CanBeNull] private AccessLink SelectedAccessLink { get; }
51+
private AccessLink SelectedAccessLink { get; }
5652

5753
public ObservableCollection<AccessLink> QuickAccessLinks { get; }
5854

@@ -62,7 +58,7 @@ public QuickAccessLinkSettings(ObservableCollection<AccessLink> quickAccessLinks
6258
InitializeComponent();
6359
}
6460

65-
public QuickAccessLinkSettings(ObservableCollection<AccessLink> quickAccessLinks,AccessLink selectedAccessLink)
61+
public QuickAccessLinkSettings(ObservableCollection<AccessLink> quickAccessLinks, AccessLink selectedAccessLink)
6662
{
6763
IsEdit = true;
6864
_selectedName = selectedAccessLink.Name;
@@ -72,15 +68,12 @@ public QuickAccessLinkSettings(ObservableCollection<AccessLink> quickAccessLinks
7268
InitializeComponent();
7369
}
7470

75-
76-
7771
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
7872
{
7973
DialogResult = false;
8074
Close();
8175
}
8276

83-
8477
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
8578
{
8679
if (string.IsNullOrEmpty(SelectedName) || string.IsNullOrEmpty(SelectedPath))
@@ -121,7 +114,7 @@ private void SelectPath_OnClick(object commandParameter, RoutedEventArgs e)
121114

122115
private void EditAccessLink()
123116
{
124-
if (SelectedAccessLink == null)throw new ArgumentException("Access Link object is null");
117+
if (SelectedAccessLink == null) throw new ArgumentException("Access Link object is null");
125118

126119
var index = QuickAccessLinks.IndexOf(SelectedAccessLink);
127120
if (index >= 0)
@@ -134,19 +127,10 @@ private void EditAccessLink()
134127
Close();
135128
}
136129

137-
public event PropertyChangedEventHandler PropertyChanged;
130+
public event PropertyChangedEventHandler PropertyChanged;
138131

139132
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
140133
{
141134
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
142135
}
143-
144-
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
145-
{
146-
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
147-
field = value;
148-
OnPropertyChanged(propertyName);
149-
return true;
150-
}
151136
}
152-

0 commit comments

Comments
 (0)