@@ -18,7 +18,16 @@ public class ProgramSource
18
18
{
19
19
private string name ;
20
20
21
- public string Location { get ; private set ; }
21
+ private string loc ;
22
+ public string Location
23
+ {
24
+ get => loc ;
25
+ set
26
+ {
27
+ loc = value ;
28
+ UniqueIdentifier = value . ToLowerInvariant ( ) ;
29
+ }
30
+ }
22
31
public string Name { get => name ?? new DirectoryInfo ( Location ) . Name ; set => name = value ; }
23
32
public bool Enabled { get ; set ; } = true ;
24
33
@@ -27,35 +36,34 @@ public class ProgramSource
27
36
[ JsonConstructor ]
28
37
public ProgramSource ( string name , string location , bool enabled , string uniqueIdentifier )
29
38
{
30
- Location = location ;
39
+ loc = location ;
31
40
this . name = name ;
32
41
Enabled = enabled ;
33
- UniqueIdentifier = uniqueIdentifier ;
42
+ if ( location . Equals ( uniqueIdentifier , StringComparison . OrdinalIgnoreCase ) )
43
+ {
44
+ UniqueIdentifier = location . ToLowerInvariant ( ) ; // To make sure old config can be reset to case-insensitive
45
+ }
46
+ else
47
+ {
48
+ UniqueIdentifier = uniqueIdentifier ; // For uwp apps
49
+ }
34
50
}
35
51
36
52
/// <summary>
37
53
/// Add source by location
38
54
/// </summary>
39
55
/// <param name="location">location of program source</param>
40
56
/// <param name="enabled">enabled</param>
41
- public ProgramSource ( string location , bool enabled = true )
57
+ public ProgramSource ( string location , bool enabled = true )
42
58
{
43
- Location = location ;
59
+ loc = location ;
44
60
Enabled = enabled ;
45
61
UniqueIdentifier = location . ToLowerInvariant ( ) ; // For path comparison
46
62
}
47
63
48
- public ProgramSource ( ProgramSource source )
49
- {
50
- Location = source . Location ;
51
- Name = source . Name ;
52
- Enabled = source . Enabled ;
53
- UniqueIdentifier = source . UniqueIdentifier ;
54
- }
55
-
56
64
public ProgramSource ( IProgram source )
57
65
{
58
- Location = source . Location ;
66
+ loc = source . Location ;
59
67
Name = source . Name ;
60
68
Enabled = source . Enabled ;
61
69
UniqueIdentifier = source . UniqueIdentifier ;
@@ -75,12 +83,5 @@ public override int GetHashCode()
75
83
{
76
84
return HashCode . Combine ( UniqueIdentifier ) ;
77
85
}
78
-
79
- public void SetLocation ( string value )
80
- {
81
- if ( Location == value ) return ;
82
- Location = value ;
83
- UniqueIdentifier = value . ToLowerInvariant ( ) ; // Update
84
- }
85
86
}
86
87
}
0 commit comments