private void ReadFromRegistry() { ITracer dagNetEnvironmentTracer = Dependencies.DagNetEnvironmentTracer; IRegistryReader reader = Dependencies.RegistryReader; Exception ex = RegistryUtil.RunRegistryFunction(delegate() { int value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "DisableSocketStream", 0); this.DisableSocketStream = this.IntToBool(value); value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "LogShipCompressionDisable", 0); this.LogShipCompressionDisable = this.IntToBool(value); value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "DisableNetworkSigning", 0); this.DisableNetworkSigning = this.IntToBool(value); value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "LogDiagnosticNetworkEvents", 0); this.LogDiagnosticNetworkEvents = this.IntToBool(value); value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "LogCopyNetworkTransferSize", this.LogCopyNetworkTransferSize); this.LogCopyNetworkTransferSize = value; value = reader.GetValue <int>(Registry.LocalMachine, this.RegistryRootKeyName, "SeedingNetworkTransferSize", this.SeedingNetworkTransferSize); this.SeedingNetworkTransferSize = value; }); if (ex != null) { dagNetEnvironmentTracer.TraceError(0L, "ReadFromRegistry({0}) fails: {1}", new object[] { this.RegistryRootKeyName, ex }); } }
public static bool IsMinimizeEnabled() { int num = 0; Exception ex = null; try { IRegistryReader instance = RegistryReader.Instance; num = instance.GetValue <int>(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Replay\\Parameters", "DisableADObjectMinimize", 0); } catch (IOException ex2) { ex = ex2; } catch (UnauthorizedAccessException ex3) { ex = ex3; } catch (SecurityException ex4) { ex = ex4; } if (ex != null) { ADObjectWrapperBase.Tracer.TraceError <Exception>(0L, "IsMinimizeEnabled caught {0}", ex); num = 1; } return(num == 0); }
/// <summary> /// Creates a new instance of the <see cref="RegisteredMachineUserValueProvider"/> class. /// </summary> public RegisteredMachineUserValueProvider() : this(null) { if (this.reader == null) { this.reader = new RegistryReader(Registry.LocalMachine, RegKey, RegKeyValue); } }
public IDictionary <Guid, FailureRec> GetQuarantinedJobs() { IRegistryReader instance = RegistryReader.Instance; IRegistryWriter instance2 = RegistryWriter.Instance; string[] array = null; try { array = instance.GetSubKeyNames(Registry.LocalMachine, JobQuarantineProvider.KeyNameFormatQuarantinedJobRoot); } catch (ArgumentException) { } if (array == null) { return(new Dictionary <Guid, FailureRec>()); } Dictionary <Guid, FailureRec> dictionary = new Dictionary <Guid, FailureRec>(array.Length); string[] array2 = array; int i = 0; while (i < array2.Length) { string text = array2[i]; Guid key = Guid.Empty; string subkeyName = Path.Combine(JobQuarantineProvider.KeyNameFormatQuarantinedJobRoot, text); try { key = new Guid(text); } catch (FormatException) { try { instance2.DeleteSubKeyTree(Registry.LocalMachine, subkeyName); } catch (ArgumentException) { } goto IL_118; } goto IL_80; IL_118: i++; continue; IL_80: string value = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "FailureType", string.Empty); string value2 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "Message", string.Empty); string value3 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "StackTrace", string.Empty); string value4 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "DataContext", string.Empty); string value5 = instance.GetValue <string>(Registry.LocalMachine, subkeyName, "InnerException", string.Empty); FailureRec value6 = FailureRec.Create(value, value2, value3, value4, value5); dictionary.Add(key, value6); goto IL_118; } return(dictionary); }
public Settings( IConfigurationRoot?config = null, IFileSystem?fileSystem = null, IRegistryReader?registryReader = null) { _fileSystem = fileSystem ?? new FileSystem(); _config = config ?? LoadConfigFile(); _registryReader = registryReader ?? new RegistryReader(); LoadSettings(); }
/// <summary> /// Gets the default save location of projects in the current Visual Studio environment. /// </summary> private static string GetDefaultProjectSaveLocation(IRegistryReader reader) { Guard.NotNull(() => reader, reader); var value = reader.ReadValue(); if (value != null) { return value.ToString(); } return null; }
/// <summary> /// Gets the default save location of projects in the current Visual Studio environment. /// </summary> private static string GetDefaultProjectSaveLocation(IRegistryReader reader) { Guard.NotNull(() => reader, reader); var value = reader.ReadValue(); if (value != null) { return(value.ToString()); } return(null); }
/// <summary> /// Creates and opens a new blank solution /// </summary> internal static void CreateBlankSolution(this EnvDTE.DTE dte, IRegistryReader reader) { Guard.NotNull(() => dte, dte); //Close existing solution if (dte.Solution.IsOpen) { dte.Solution.Close(true); } // Determine next available solution directory var defaultSaveLocation = GetDefaultProjectSaveLocation(reader); if (string.IsNullOrEmpty(defaultSaveLocation)) { throw new InvalidOperationException(Resources.DteExtensions_CreateNewSolution_FailedDirSearch); } var existingSolutionFolders = Directory.GetDirectories(defaultSaveLocation).Select(dir => new DirectoryInfo(dir).Name); var nextSolutionDir = UniqueNameGenerator.EnsureUnique(NewSolutionNamePrefix, existingSolutionFolders, true); // Create solution directory var solutionDir = Path.Combine(defaultSaveLocation, nextSolutionDir); if (!Directory.Exists(solutionDir)) { Directory.CreateDirectory(solutionDir); } // Save and Open new solution var solutionFullPath = Path.Combine(solutionDir, nextSolutionDir); try { dte.Solution.Create(solutionDir, nextSolutionDir); dte.Solution.SaveAs(solutionFullPath); } catch (COMException) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.DteExtensions_CreateNewSolution_FailedCreate, solutionDir)); } }
public static CompressionConfig ReadCompressionConfig(out Exception ex) { ex = null; try { IRegistryReader instance = RegistryReader.Instance; string value = instance.GetValue <string>(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Replay\\Parameters", "CompressionConfig", null); if (value == null) { return(new CompressionConfig { Provider = CompressionConfig.CompressionProvider.Xpress }); } if (!string.IsNullOrEmpty(value)) { return((CompressionConfig)SerializationUtil.XmlToObject(value, typeof(CompressionConfig))); } } catch (InvalidOperationException ex2) { ex = ex2; } catch (IOException ex3) { ex = ex3; } catch (UnauthorizedAccessException ex4) { ex = ex4; } catch (SecurityException ex5) { ex = ex5; } catch (SerializationException ex6) { ex = ex6; } return(new CompressionConfig()); }
/// <summary> /// Identifies and gathers ShellBag items from raw binary registry data. /// </summary> /// <returns>a list of different variety ShellBag items</returns> public static List <IShellItem> GetShellItems(IRegistryReader registryReader) { List <IShellItem> shellItems = new List <IShellItem>(); Dictionary <RegistryKeyWrapper, IShellItem> keyShellMappings = new Dictionary <RegistryKeyWrapper, IShellItem>(); foreach (RegistryKeyWrapper keyWrapper in registryReader.GetRegistryKeys()) { if (keyWrapper.Value != null) // Some Registry Keys are null { ShellItemList shellItemList = new ShellItemList(keyWrapper.Value); foreach (IShellItem shellItem in shellItemList.Items()) { IShellItem parentShellItem = null; //obtain the parent shellitem from the parent registry key (if it exists) if (keyWrapper.Parent != null) { if (keyShellMappings.TryGetValue(keyWrapper.Parent, out IShellItem pShellItem)) { parentShellItem = pShellItem; } } RegistryShellItemDecorator decoratedShellItem = new RegistryShellItemDecorator(shellItem, keyWrapper, parentShellItem); try { keyShellMappings.Add(keyWrapper, decoratedShellItem); } catch (ArgumentException ex) { //*should* never happen, if it does Absolute Path finding need to be reworked. Potentially should be a fatal exception // as now the shellbags involved are misleading. (contain incomplete data) logger.Error(ex, $"Registry Item {keyWrapper.RegistryPath} already had an associated Shellbag ({keyShellMappings[keyWrapper].Name}), Absolute Path's are no longer accurate."); } shellItems.Add(decoratedShellItem); } } } return(shellItems); }
public static string ReadCompressionConfigString(out Exception ex) { ex = null; string result = null; try { IRegistryReader instance = RegistryReader.Instance; result = instance.GetValue <string>(Registry.LocalMachine, Parameters.CurrentValues.RegistryRootKeyName, "CompressionConfig", null); } catch (IOException ex2) { ex = ex2; } catch (UnauthorizedAccessException ex3) { ex = ex3; } catch (SecurityException ex4) { ex = ex4; } return(result); }
internal static Exception TryRegistryRead <T>(string valueName, T defaultVal, out T returnedVal) { returnedVal = defaultVal; IRegistryReader reader = Dependencies.RegistryReader; T readVal = defaultVal; Exception ex = RegistryUtil.RunRegistryFunction(delegate() { readVal = reader.GetValue <T>(Registry.LocalMachine, DagNetEnvironment.RegistryRootKeyName, valueName, defaultVal); }); if (ex != null) { DagNetEnvironment.Tracer.TraceError(0L, "TryRegistryRead({0}) fails: {1}", new object[] { valueName, ex }); } else { returnedVal = readVal; } return(ex); }
public static string ReadCompressionConfigString(out Exception ex) { ex = null; string result = null; try { IRegistryReader instance = RegistryReader.Instance; result = instance.GetValue <string>(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Replay\\Parameters", "CompressionConfig", null); } catch (IOException ex2) { ex = ex2; } catch (UnauthorizedAccessException ex3) { ex = ex3; } catch (SecurityException ex4) { ex = ex4; } return(result); }
public DefaultHttpServer(IKeyValueStore keyValueStore, IRegistryReader registryReader, IFileSystem fileSystem) { _keyValueStore = keyValueStore; _registryReader = registryReader; _fileSystem = fileSystem; }
/// <summary> /// Creates a new instance of the <see cref="RegisteredMachineUserValueProvider"/> class. /// </summary> internal RegisteredMachineUserValueProvider(IRegistryReader reader) : base() { this.reader = reader; }
public void Setup() { _network = new Network(); Setup("fakemac"); SetupRoutesOnInterface(new[] { new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.1" }, new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.2" } }); _networkInterface1 = NetworkInterface; _networkInterface1.label = "public"; _network.Interfaces.Add("fakemac", _networkInterface1); Setup("fakemac1"); SetupRoutesOnInterface(new[] { new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.1" }, new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.3" } }); _networkInterface2 = NetworkInterface; _networkInterface2.gateway = "10.1.1.1"; _network.Interfaces.Add("fakemac1", _networkInterface2); _executableProcessQueue = MockRepository.GenerateMock<IExecutableProcessQueue>(); _executableProcessQueue.Expect(x => x.Go()).Repeat.Once(); _registryReader = MockRepository.GenerateMock<IRegistryReader>(); _registryReader.Stub(x => x.GetValuesFrom(Arg<string>.Is.Anything)) .Return(new List<string> { "0.0.0.0,0.0.0.0,172.16.251.2,2", "1.2.3.4,5.6.7.8,9.10.11.12.13,10" }); _logger = MockRepository.GenerateMock<ILogger>(); ExecutableProcessQueue.Replay(); _setNetworkRoutes = new SetNetworkRoutes(_executableProcessQueue, _registryReader, _logger); _setNetworkRoutes.Execute(_network); }
public MailHelper(IMimeMailer mailer, IRegistryReader registryReader) { this.mailer = mailer; this.registryReader = registryReader; }
public MailHelper(MailTransport mailer, IRegistryReader registryReader, IConfiguration configuration) { _configuration = configuration; this.mailer = mailer; this.registryReader = registryReader; }
public void Setup() { _network = new Network(); Setup("fakemac"); SetupRoutesOnInterface(new[] { new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.1" }, new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.2" } }); _networkInterface1 = NetworkInterface; _networkInterface1.label = "public"; _network.Interfaces.Add("fakemac", _networkInterface1); Setup("fakemac1"); SetupRoutesOnInterface(new[] { new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.1" }, new NetworkRoute { gateway = "10.1.10.20", netmask = "255.255.255.0", route = "10.1.10.3" } }); _networkInterface2 = NetworkInterface; _networkInterface2.gateway = "10.1.1.1"; _network.Interfaces.Add("fakemac1", _networkInterface2); _executableProcessQueue = MockRepository.GenerateMock <IExecutableProcessQueue>(); _executableProcessQueue.Expect(x => x.Go()).Repeat.Once(); _registryReader = MockRepository.GenerateMock <IRegistryReader>(); _registryReader.Stub(x => x.GetValuesFrom(Arg <string> .Is.Anything)) .Return(new List <string> { "0.0.0.0,0.0.0.0,172.16.251.2,2", "1.2.3.4,5.6.7.8,9.10.11.12.13,10" }); _logger = MockRepository.GenerateMock <ILogger>(); ExecutableProcessQueue.Replay(); _setNetworkRoutes = new SetNetworkRoutes(_executableProcessQueue, _registryReader, _logger); _setNetworkRoutes.Execute(_network); }
public SetNetworkRoutes(IExecutableProcessQueue executableProcessQueue, IRegistryReader registryReader, ILogger logger) { _executableProcessQueue = executableProcessQueue; _registryReader = registryReader; _logger = logger; }