1
- using System ;
1
+ using Microsoft . Win32 ;
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
using System . IO ;
4
- using System . Linq ;
5
- using System . Text ;
6
- using System . Threading . Tasks ;
7
5
8
6
namespace Analogy . Managers
9
7
{
@@ -12,11 +10,32 @@ public class AnalogyNonPersistSettings
12
10
private static readonly Lazy < AnalogyNonPersistSettings > _instance =
13
11
new Lazy < AnalogyNonPersistSettings > ( ( ) => new AnalogyNonPersistSettings ( ) ) ;
14
12
public static AnalogyNonPersistSettings Instance { get ; set ; } = _instance . Value ;
13
+ private static string AnalogyRegistryKey => @"SOFTWARE\Analogy.LogViewer" ;
15
14
public List < string > AdditionalAssembliesDependenciesLocations { get ; }
16
15
public bool DisableUpdatesByDataProvidersOverrides { get ; set ; }
16
+ public bool DisableUpdateFromRegistry { get ; set ; }
17
+
18
+ public bool UpdateAreDisabled => DisableUpdateFromRegistry || DisableUpdatesByDataProvidersOverrides ;
17
19
public AnalogyNonPersistSettings ( )
18
20
{
19
- AdditionalAssembliesDependenciesLocations = new List < string > ( ) ;
21
+ AdditionalAssembliesDependenciesLocations = new List < string > ( ) ;
22
+ try
23
+ {
24
+ using ( RegistryKey ? key = Registry . LocalMachine . OpenSubKey ( AnalogyRegistryKey ) )
25
+ {
26
+ object ? updateRegistryValue = key ? . GetValue ( "DisableUpdates" ) ;
27
+ if ( updateRegistryValue != null && bool . TryParse ( updateRegistryValue . ToString ( ) , out var disable ) )
28
+ {
29
+ AnalogyLogger . Instance . LogInformation ( $ "Disable mode: { disable } ") ;
30
+ DisableUpdateFromRegistry = disable ;
31
+ }
32
+ }
33
+ }
34
+ catch ( Exception e )
35
+ {
36
+ AnalogyLogManager . Instance . LogError ( $ "Error reading registry: { e } ", nameof ( AnalogyNonPersistSettings ) ) ;
37
+ }
38
+
20
39
}
21
40
22
41
public void AddDependencyLocation ( string path )
@@ -29,7 +48,7 @@ public void AddDependencyLocation(string path)
29
48
}
30
49
else
31
50
{
32
- AnalogyLogManager . Instance . LogWarning ( $ "{ path } already exist in dependencies list", nameof ( AddDependencyLocation ) ) ;
51
+ AnalogyLogManager . Instance . LogWarning ( $ "{ path } already exist in dependencies list", nameof ( AddDependencyLocation ) ) ;
33
52
}
34
53
}
35
54
else
0 commit comments