From bd54511d70a541ba813857d0a57b45ce03585c54 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Thu, 2 Mar 2017 22:01:46 +0000 Subject: [PATCH] remove ConfigMonitor project. #54 --- .../ConfigMonitor/ConfigMonitor.cs | 88 ------------------- .../ConfigMonitor/ConfigMonitor.csproj | 55 ------------ .../ConfigMonitor/Properties/AssemblyInfo.cs | 36 -------- .../WindowsDataCenter/WindowsDataCenter.sln | 9 -- 4 files changed, 188 deletions(-) delete mode 100644 DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.cs delete mode 100644 DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.csproj delete mode 100644 DataCenter_Windows/WindowsDataCenter/ConfigMonitor/Properties/AssemblyInfo.cs diff --git a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.cs b/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.cs deleted file mode 100644 index ec6b85e..0000000 --- a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; - -namespace ConfigMonitor -{ - public class ConfigMonitor - { - private readonly FileSystemWatcher _watcher; - private DateTime _lastChange; - - public ConfigMonitor(string configFilePath) - { - if (configFilePath == null) - { - throw new ArgumentNullException(nameof(configFilePath)); - } - - _lastChange = DateTime.MinValue; - configFilePath = string.Concat(System.Reflection.Assembly.GetEntryAssembly().Location, ".config"); - if (File.Exists(configFilePath)) - { - _watcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath)) - { - EnableRaisingEvents = true - }; - _watcher.Changed += Watcher_Changed; - } - } - - ~ConfigMonitor() - { - _watcher.EnableRaisingEvents = false; - _watcher.Changed -= Watcher_Changed; - _watcher.Dispose(); - } - - public void Stop() - { - _watcher.EnableRaisingEvents = false; - _watcher.Changed -= Watcher_Changed; - _watcher.Dispose(); - } - - private void Watcher_Changed(object sender, FileSystemEventArgs e) - { - if ((DateTime.Now - _lastChange).Seconds <= 5 || IsFileLocked(e.FullPath)) return; - var monitoredSections = ConfigurationManager.AppSettings["monitoredSections"]; - - if (monitoredSections != null) - { - IEnumerable sections = monitoredSections.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - if (sections.Any()) - { - foreach (var section in sections) - { - ConfigurationManager.RefreshSection(section); - } - } - } - else - { - ConfigurationManager.RefreshSection("appSettings"); - } - _lastChange = DateTime.Now; - } - - private bool IsFileLocked(string filePath) - { - FileStream stream = null; - try - { - stream = File.OpenRead(filePath); - } - catch (IOException) - { - return true; - } - finally - { - stream?.Close(); - } - return false; - } - } -} diff --git a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.csproj b/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.csproj deleted file mode 100644 index 6e23f2e..0000000 --- a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/ConfigMonitor.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Debug - AnyCPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71} - Library - Properties - ConfigMonitor - ConfigMonitor - v4.5.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/Properties/AssemblyInfo.cs deleted file mode 100644 index 380067c..0000000 --- a/DataCenter_Windows/WindowsDataCenter/ConfigMonitor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ConfigMonitor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ConfigMonitor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6f3878b0-1e07-4de7-bfec-509ff4443b71")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln index 10a1bd9..8f6ddca 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln @@ -28,7 +28,6 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "CardReaderServiceInstaller" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installers", "Installers", "{10A7E78C-0D11-40DD-AEC3-27C2C507A926}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigMonitor", "ConfigMonitor\ConfigMonitor.csproj", "{6F3878B0-1E07-4DE7-BFEC-509FF4443B71}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigurationHandler", "ConfigurationHandler\ConfigurationHandler.csproj", "{115250F6-F8C4-4F9B-A15F-251EA258D963}" EndProject Global @@ -107,14 +106,6 @@ Global {119216DE-FC7F-408A-9C2C-105874449E42}.Release|Any CPU.ActiveCfg = Release|x86 {119216DE-FC7F-408A-9C2C-105874449E42}.Release|x86.ActiveCfg = Release|x86 {119216DE-FC7F-408A-9C2C-105874449E42}.Release|x86.Build.0 = Release|x86 - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Debug|x86.ActiveCfg = Debug|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Debug|x86.Build.0 = Debug|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Release|Any CPU.Build.0 = Release|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Release|x86.ActiveCfg = Release|Any CPU - {6F3878B0-1E07-4DE7-BFEC-509FF4443B71}.Release|x86.Build.0 = Release|Any CPU {115250F6-F8C4-4F9B-A15F-251EA258D963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {115250F6-F8C4-4F9B-A15F-251EA258D963}.Debug|Any CPU.Build.0 = Debug|Any CPU {115250F6-F8C4-4F9B-A15F-251EA258D963}.Debug|x86.ActiveCfg = Debug|Any CPU