diff --git a/README.md b/README.md index 416c8fb..bf97546 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,6 @@ References Copyright & License ======================= -Copyright 2014-2016 tynor88 +Copyright 2014-2017 tynor88 Licensed under the [MIT License](https://github.com/tynor88/Topshelf.SimpleInjector/blob/master/LICENSE) diff --git a/Samples/Topshelf.FileSystemWatcher.Sample/App.config b/Samples/Topshelf.FileSystemWatcher.Sample/App.config index 8e15646..8227adb 100644 --- a/Samples/Topshelf.FileSystemWatcher.Sample/App.config +++ b/Samples/Topshelf.FileSystemWatcher.Sample/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Samples/Topshelf.FileSystemWatcher.Sample/Program.cs b/Samples/Topshelf.FileSystemWatcher.Sample/Program.cs index 5742aae..bb7e5d7 100644 --- a/Samples/Topshelf.FileSystemWatcher.Sample/Program.cs +++ b/Samples/Topshelf.FileSystemWatcher.Sample/Program.cs @@ -6,40 +6,114 @@ namespace Topshelf.FileSystemWatcher.Sample internal class Program { private static readonly string _testDir = Directory.GetCurrentDirectory() + @"\test\"; + private static readonly bool _includeSubDirectories = true; + private static readonly bool _excludeDuplicateEvents = true; private static void Main(string[] args) { HostFactory.Run(config => { - config.UseTestHost(); - config.Service(s => { s.ConstructUsing(() => new Program()); - s.WhenStarted((service, host) => + s.BeforeStartingService((hostStart) => { if (!Directory.Exists(_testDir)) Directory.CreateDirectory(_testDir); - using (FileStream fs = File.Create(_testDir + "testfile.ext")) - { - } - return true; }); + s.WhenStarted((service, host) => true); s.WhenStopped((service, host) => true); - s.WhenFileSystemCreated(configurator => - configurator.AddDirectory(dir => - { - dir.Path = _testDir; - dir.CreateDir = true; - dir.NotifyFilters = NotifyFilters.FileName; - }), FileSystemCreated); + s.WhenFileSystemCreated(ConfigureDirectoryWorkCreated, FileSystemCreated); + s.WhenFileSystemChanged(ConfigureDirectoryWorkChanged, FileSystemCreated); + s.WhenFileSystemRenamed(ConfigureDirectoryWorkRenamedFile, FileSystemRenamedFile); + s.WhenFileSystemRenamed(ConfigureDirectoryWorkRenamedDirectory, FileSystemRenamedDirectory); + s.WhenFileSystemDeleted(ConfigureDirectoryWorkDeleted, FileSystemCreated); }); }); + Console.ReadKey(); + } + + private static void ConfigureDirectoryWorkCreated(FileSystemWatcherConfigurator obj) + { + obj.AddDirectory(dir => + { + dir.Path = _testDir; + dir.IncludeSubDirectories = _includeSubDirectories; + dir.NotifyFilters = NotifyFilters.DirectoryName | NotifyFilters.FileName; + dir.ExcludeDuplicateEvents = _excludeDuplicateEvents; + }); + } + private static void ConfigureDirectoryWorkChanged(FileSystemWatcherConfigurator obj) + { + obj.AddDirectory(dir => + { + dir.Path = _testDir; + dir.IncludeSubDirectories = _includeSubDirectories; + dir.NotifyFilters = NotifyFilters.LastWrite; + dir.ExcludeDuplicateEvents = _excludeDuplicateEvents; + }); + } + private static void ConfigureDirectoryWorkRenamedFile(FileSystemWatcherConfigurator obj) + { + obj.AddDirectory(dir => + { + dir.Path = _testDir; + dir.IncludeSubDirectories = _includeSubDirectories; + dir.NotifyFilters = NotifyFilters.FileName; + dir.ExcludeDuplicateEvents = _excludeDuplicateEvents; + }); + } + private static void ConfigureDirectoryWorkRenamedDirectory(FileSystemWatcherConfigurator obj) + { + obj.AddDirectory(dir => + { + dir.Path = _testDir; + dir.IncludeSubDirectories = _includeSubDirectories; + dir.NotifyFilters = NotifyFilters.DirectoryName; + dir.ExcludeDuplicateEvents = _excludeDuplicateEvents; + }); + } + private static void ConfigureDirectoryWorkDeleted(FileSystemWatcherConfigurator obj) + { + obj.AddDirectory(dir => + { + dir.Path = _testDir; + dir.IncludeSubDirectories = _includeSubDirectories; + dir.NotifyFilters = NotifyFilters.DirectoryName | NotifyFilters.FileName; + dir.ExcludeDuplicateEvents = _excludeDuplicateEvents; + }); } private static void FileSystemCreated(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs) { - Console.WriteLine("New file created! ChangeType = {0} FullPath = {1} Name = {2} FileSystemEventType {3}", topshelfFileSystemEventArgs.ChangeType, topshelfFileSystemEventArgs.FullPath, topshelfFileSystemEventArgs.Name, topshelfFileSystemEventArgs.FileSystemEventType); + Console.WriteLine("*********************"); + Console.WriteLine("ChangeType = {0}", topshelfFileSystemEventArgs.ChangeType); + Console.WriteLine("FullPath = {0}", topshelfFileSystemEventArgs.FullPath); + Console.WriteLine("Name = {0}", topshelfFileSystemEventArgs.Name); + Console.WriteLine("FileSystemEventType {0}", topshelfFileSystemEventArgs.FileSystemEventType); + Console.WriteLine("*********************"); + } + + private static void FileSystemRenamedFile(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs) + { + Console.WriteLine("*********************"); + Console.WriteLine("Rename File"); + Console.WriteLine("ChangeType = {0}", topshelfFileSystemEventArgs.ChangeType); + Console.WriteLine("FullPath = {0}", topshelfFileSystemEventArgs.FullPath); + Console.WriteLine("Name = {0}", topshelfFileSystemEventArgs.Name); + Console.WriteLine("FileSystemEventType {0}", topshelfFileSystemEventArgs.FileSystemEventType); + Console.WriteLine("*********************"); + } + + private static void FileSystemRenamedDirectory(TopshelfFileSystemEventArgs topshelfFileSystemEventArgs) + { + Console.WriteLine("*********************"); + Console.WriteLine("Rename Dir"); + Console.WriteLine("ChangeType = {0}", topshelfFileSystemEventArgs.ChangeType); + Console.WriteLine("FullPath = {0}", topshelfFileSystemEventArgs.FullPath); + Console.WriteLine("Name = {0}", topshelfFileSystemEventArgs.Name); + Console.WriteLine("FileSystemEventType {0}", topshelfFileSystemEventArgs.FileSystemEventType); + Console.WriteLine("*********************"); } } } \ No newline at end of file diff --git a/Samples/Topshelf.FileSystemWatcher.Sample/Topshelf.FileSystemWatcher.Sample.csproj b/Samples/Topshelf.FileSystemWatcher.Sample/Topshelf.FileSystemWatcher.Sample.csproj index 1d304a9..eebd21c 100644 --- a/Samples/Topshelf.FileSystemWatcher.Sample/Topshelf.FileSystemWatcher.Sample.csproj +++ b/Samples/Topshelf.FileSystemWatcher.Sample/Topshelf.FileSystemWatcher.Sample.csproj @@ -9,9 +9,10 @@ Properties Topshelf.FileSystemWatcher.Sample Topshelf.FileSystemWatcher.Sample - v4.5 + v4.5.2 512 ..\ + AnyCPU @@ -40,8 +41,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll True @@ -67,5 +68,4 @@ --> - - + \ No newline at end of file diff --git a/Samples/Topshelf.FileSystemWatcher.Sample/packages.config b/Samples/Topshelf.FileSystemWatcher.Sample/packages.config index 77fd1c1..6540af0 100644 --- a/Samples/Topshelf.FileSystemWatcher.Sample/packages.config +++ b/Samples/Topshelf.FileSystemWatcher.Sample/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Program.cs b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Program.cs index 13379e8..a88a169 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Program.cs +++ b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Program.cs @@ -2,6 +2,7 @@ using System.Reflection; using Quartz; using SimpleInjector; +using SimpleInjector.Lifestyles; namespace Topshelf.SimpleInjector.Quartz.Decorators.Sample { @@ -13,7 +14,7 @@ private static void Main(string[] args) { _container.Register(); _container.RegisterDecorator(typeof(IJob), typeof(LoggingDecorator)); - _container.RegisterDecorator(typeof(IJob), typeof(LifetimeScopeDecoratorFuncTFactory)); + _container.RegisterDecorator(typeof(IJob), typeof(ThreadScopedDecoratorFuncTFactory)); HostFactory.Run(config => { @@ -94,12 +95,12 @@ public void Execute(IJobExecutionContext context) } } - public class LifetimeScopeDecoratorFuncTFactory : IJob + public class ThreadScopedDecoratorFuncTFactory : IJob { private readonly Func _decorateeFactory; private readonly Container _container; - public LifetimeScopeDecoratorFuncTFactory(Func decorateeFactory, Container container) + public ThreadScopedDecoratorFuncTFactory(Func decorateeFactory, Container container) { _decorateeFactory = decorateeFactory; _container = container; @@ -107,9 +108,9 @@ public LifetimeScopeDecoratorFuncTFactory(Func decorateeFactory, Container public void Execute(IJobExecutionContext context) { - using (_container.BeginLifetimeScope()) + using (ThreadScopedLifestyle.BeginScope(_container)) { - Console.WriteLine("See, i am decorating the Job: " + typeof(JobWithInjectedDependenciesDecorated).Name + " with a Lifetime Scope!"); + Console.WriteLine("See, i am decorating the Job: " + typeof(JobWithInjectedDependenciesDecorated).Name + " with a Thread Scope!"); var job = _decorateeFactory.Invoke(); job.Execute(context); } diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Topshelf.SimpleInjector.Quartz.Decorators.Sample.csproj b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Topshelf.SimpleInjector.Quartz.Decorators.Sample.csproj index 884bb30..6a45543 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Topshelf.SimpleInjector.Quartz.Decorators.Sample.csproj +++ b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/Topshelf.SimpleInjector.Quartz.Decorators.Sample.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.Quartz.Decorators.Sample Topshelf.SimpleInjector.Quartz.Decorators.Sample - v4.5 + v4.5.2 512 ..\ + AnyCPU @@ -41,16 +42,11 @@ ..\..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll True - - ..\..\packages\Quartz.2.3.3\lib\net40\Quartz.dll - True - - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll - True + + ..\..\packages\Quartz.2.5.0\lib\net40\Quartz.dll - - ..\..\packages\SimpleInjector.Extensions.LifetimeScoping.3.1.2\lib\net40-client\SimpleInjector.Extensions.LifetimeScoping.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -60,9 +56,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -71,6 +66,9 @@ + + Designer + Designer @@ -93,5 +91,4 @@ --> - - + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/app.config b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/app.config index 1548c62..e02fbb3 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/app.config +++ b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/app.config @@ -12,12 +12,12 @@ - + - + - \ No newline at end of file + diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/job_scheduling_data_2_0.xsd b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/job_scheduling_data_2_0.xsd new file mode 100644 index 0000000..d1dabc1 --- /dev/null +++ b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/job_scheduling_data_2_0.xsd @@ -0,0 +1,361 @@ + + + + + + + Root level node + + + + + + Commands to be executed before scheduling the jobs and triggers in this file. + + + + + Directives to be followed while scheduling the jobs and triggers in this file. + + + + + + + + + + + + + + Version of the XML Schema instance + + + + + + + + + + Delete all jobs, if any, in the identified group. "*" can be used to identify all groups. Will also result in deleting all triggers related to the jobs. + + + + + Delete all triggers, if any, in the identified group. "*" can be used to identify all groups. Will also result in deletion of related jobs that are non-durable. + + + + + Delete the identified job if it exists (will also result in deleting all triggers related to it). + + + + + + + + + + + Delete the identified trigger if it exists (will also result in deletion of related jobs that are non-durable). + + + + + + + + + + + + + + + + Whether the existing scheduling data (with same identifiers) will be overwritten. If false, and ignore-duplicates is not false, and jobs or triggers with the same names already exist as those in the file, an error will occur. + + + + + If true (and overwrite-existing-data is false) then any job/triggers encountered in this file that have names that already exist in the scheduler will be ignored, and no error will be produced. + + + + + If true trigger's start time is calculated based on earlier run time instead of fixed value. Trigger's start time must be undefined for this to work. + + + + + + + + Define a JobDetail + + + + + + + + + + + + + + + + + Define a JobDataMap + + + + + + + + + Define a JobDataMap entry + + + + + + + + + + Define a Trigger + + + + + + + + + + + Common Trigger definitions + + + + + + + + + + + + + + + + + + + + + + + Define a SimpleTrigger + + + + + + + + + + + + + + + + + Define a CronTrigger + + + + + + + + + + + + + + + Define a DateIntervalTrigger + + + + + + + + + + + + + + + + Cron expression (see JavaDoc for examples) + + Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression! + + Regular expressions are not my strong point but I believe this is complete, + with the caveat that order for expressions like 3-0 is not legal but will pass, + and month and day names must be capitalized. + If you want to examine the correctness look for the [\s] to denote the + seperation of individual regular expressions. This is how I break them up visually + to examine them: + + SECONDS: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + MINUTES: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + HOURS: + ( + ((([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?,)*([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?) + | (([\*]|[0-9]|[0-1][0-9]|[2][0-3])/([0-9]|[0-1][0-9]|[2][0-3])) + | ([\?]) + | ([\*]) + ) [\s] + DAY OF MONTH: + ( + ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?,)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?(C)?) + | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])/([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?) + | (L(-[0-9])?) + | (L(-[1-2][0-9])?) + | (L(-[3][0-1])?) + | (LW) + | ([1-9]W) + | ([1-3][0-9]W) + | ([\?]) + | ([\*]) + )[\s] + MONTH: + ( + ((([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?,)*([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?) + | (([1-9]|0[1-9]|1[0-2])/([1-9]|0[1-9]|1[0-2])) + | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?,)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?) + | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)) + | ([\?]) + | ([\*]) + )[\s] + DAY OF WEEK: + ( + (([1-7](-([1-7]))?,)*([1-7])(-([1-7]))?) + | ([1-7]/([1-7])) + | (((MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?,)*(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?(C)?) + | ((MON|TUE|WED|THU|FRI|SAT|SUN)/(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?) + | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?) + | (([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?) + | ([\?]) + | ([\*]) + ) + YEAR (OPTIONAL): + ( + [\s]? + ([\*])? + | ((19[7-9][0-9])|(20[0-9][0-9]))? + | (((19[7-9][0-9])|(20[0-9][0-9]))/((19[7-9][0-9])|(20[0-9][0-9])))? + | ((((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?,)*((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?)? + ) + + + + + + + + + + Number of times to repeat the Trigger (-1 for indefinite) + + + + + + + + + + Simple Trigger Misfire Instructions + + + + + + + + + + + + + + Cron Trigger Misfire Instructions + + + + + + + + + + + Date Interval Trigger Misfire Instructions + + + + + + + + + + + Interval Units + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/packages.config b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/packages.config index 130a34b..7ee01a2 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/packages.config +++ b/Samples/Topshelf.SimpleInjector.Quartz.Decorators.Sample/packages.config @@ -2,8 +2,7 @@ - - - - + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Sample/Program.cs b/Samples/Topshelf.SimpleInjector.Quartz.Sample/Program.cs index 28ae2c4..baa54ff 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Sample/Program.cs +++ b/Samples/Topshelf.SimpleInjector.Quartz.Sample/Program.cs @@ -29,7 +29,7 @@ private static void Main(string[] args) new { type, - ctor = _container.Options.ConstructorResolutionBehavior.GetConstructor(typeof(IJob), type) + ctor = _container.Options.ConstructorResolutionBehavior.GetConstructor(type) }) .Select( type => diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Sample/Topshelf.SimpleInjector.Quartz.Sample.csproj b/Samples/Topshelf.SimpleInjector.Quartz.Sample/Topshelf.SimpleInjector.Quartz.Sample.csproj index 8d0536b..8827ce5 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Sample/Topshelf.SimpleInjector.Quartz.Sample.csproj +++ b/Samples/Topshelf.SimpleInjector.Quartz.Sample/Topshelf.SimpleInjector.Quartz.Sample.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.Quartz.Sample Topshelf.SimpleInjector.Quartz.Sample - v4.5 + v4.5.2 512 ..\ + AnyCPU @@ -41,12 +42,11 @@ ..\..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll True - - ..\..\packages\Quartz.2.3.3\lib\net40\Quartz.dll - True + + ..\..\packages\Quartz.2.5.0\lib\net40\Quartz.dll - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -56,9 +56,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -77,6 +76,9 @@ + + Designer + @@ -87,5 +89,4 @@ --> - - + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Sample/app.config b/Samples/Topshelf.SimpleInjector.Quartz.Sample/app.config index 1548c62..e02fbb3 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Sample/app.config +++ b/Samples/Topshelf.SimpleInjector.Quartz.Sample/app.config @@ -12,12 +12,12 @@ - + - + - \ No newline at end of file + diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Sample/job_scheduling_data_2_0.xsd b/Samples/Topshelf.SimpleInjector.Quartz.Sample/job_scheduling_data_2_0.xsd new file mode 100644 index 0000000..d1dabc1 --- /dev/null +++ b/Samples/Topshelf.SimpleInjector.Quartz.Sample/job_scheduling_data_2_0.xsd @@ -0,0 +1,361 @@ + + + + + + + Root level node + + + + + + Commands to be executed before scheduling the jobs and triggers in this file. + + + + + Directives to be followed while scheduling the jobs and triggers in this file. + + + + + + + + + + + + + + Version of the XML Schema instance + + + + + + + + + + Delete all jobs, if any, in the identified group. "*" can be used to identify all groups. Will also result in deleting all triggers related to the jobs. + + + + + Delete all triggers, if any, in the identified group. "*" can be used to identify all groups. Will also result in deletion of related jobs that are non-durable. + + + + + Delete the identified job if it exists (will also result in deleting all triggers related to it). + + + + + + + + + + + Delete the identified trigger if it exists (will also result in deletion of related jobs that are non-durable). + + + + + + + + + + + + + + + + Whether the existing scheduling data (with same identifiers) will be overwritten. If false, and ignore-duplicates is not false, and jobs or triggers with the same names already exist as those in the file, an error will occur. + + + + + If true (and overwrite-existing-data is false) then any job/triggers encountered in this file that have names that already exist in the scheduler will be ignored, and no error will be produced. + + + + + If true trigger's start time is calculated based on earlier run time instead of fixed value. Trigger's start time must be undefined for this to work. + + + + + + + + Define a JobDetail + + + + + + + + + + + + + + + + + Define a JobDataMap + + + + + + + + + Define a JobDataMap entry + + + + + + + + + + Define a Trigger + + + + + + + + + + + Common Trigger definitions + + + + + + + + + + + + + + + + + + + + + + + Define a SimpleTrigger + + + + + + + + + + + + + + + + + Define a CronTrigger + + + + + + + + + + + + + + + Define a DateIntervalTrigger + + + + + + + + + + + + + + + + Cron expression (see JavaDoc for examples) + + Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression! + + Regular expressions are not my strong point but I believe this is complete, + with the caveat that order for expressions like 3-0 is not legal but will pass, + and month and day names must be capitalized. + If you want to examine the correctness look for the [\s] to denote the + seperation of individual regular expressions. This is how I break them up visually + to examine them: + + SECONDS: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + MINUTES: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + HOURS: + ( + ((([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?,)*([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?) + | (([\*]|[0-9]|[0-1][0-9]|[2][0-3])/([0-9]|[0-1][0-9]|[2][0-3])) + | ([\?]) + | ([\*]) + ) [\s] + DAY OF MONTH: + ( + ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?,)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?(C)?) + | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])/([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?) + | (L(-[0-9])?) + | (L(-[1-2][0-9])?) + | (L(-[3][0-1])?) + | (LW) + | ([1-9]W) + | ([1-3][0-9]W) + | ([\?]) + | ([\*]) + )[\s] + MONTH: + ( + ((([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?,)*([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?) + | (([1-9]|0[1-9]|1[0-2])/([1-9]|0[1-9]|1[0-2])) + | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?,)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?) + | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)) + | ([\?]) + | ([\*]) + )[\s] + DAY OF WEEK: + ( + (([1-7](-([1-7]))?,)*([1-7])(-([1-7]))?) + | ([1-7]/([1-7])) + | (((MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?,)*(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?(C)?) + | ((MON|TUE|WED|THU|FRI|SAT|SUN)/(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?) + | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?) + | (([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?) + | ([\?]) + | ([\*]) + ) + YEAR (OPTIONAL): + ( + [\s]? + ([\*])? + | ((19[7-9][0-9])|(20[0-9][0-9]))? + | (((19[7-9][0-9])|(20[0-9][0-9]))/((19[7-9][0-9])|(20[0-9][0-9])))? + | ((((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?,)*((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?)? + ) + + + + + + + + + + Number of times to repeat the Trigger (-1 for indefinite) + + + + + + + + + + Simple Trigger Misfire Instructions + + + + + + + + + + + + + + Cron Trigger Misfire Instructions + + + + + + + + + + + Date Interval Trigger Misfire Instructions + + + + + + + + + + + Interval Units + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Quartz.Sample/packages.config b/Samples/Topshelf.SimpleInjector.Quartz.Sample/packages.config index be44d20..7ee01a2 100644 --- a/Samples/Topshelf.SimpleInjector.Quartz.Sample/packages.config +++ b/Samples/Topshelf.SimpleInjector.Quartz.Sample/packages.config @@ -2,7 +2,7 @@ - - - + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/Topshelf.SimpleInjector.QuartzAsService.Sample.csproj b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/Topshelf.SimpleInjector.QuartzAsService.Sample.csproj index 67db06f..2a5eb00 100644 --- a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/Topshelf.SimpleInjector.QuartzAsService.Sample.csproj +++ b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/Topshelf.SimpleInjector.QuartzAsService.Sample.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.QuartzAsService.Sample Topshelf.SimpleInjector.QuartzAsService.Sample - v4.5 + v4.5.2 512 ..\ + true @@ -42,12 +43,11 @@ ..\..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll True - - ..\..\packages\Quartz.2.3.3\lib\net40\Quartz.dll - True + + ..\..\packages\Quartz.2.5.0\lib\net40\Quartz.dll - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -57,9 +57,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -78,6 +77,9 @@ + + Designer + @@ -88,5 +90,4 @@ --> - - + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/app.config b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/app.config index 2084762..1263855 100644 --- a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/app.config +++ b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/app.config @@ -12,12 +12,12 @@ - + - + - \ No newline at end of file + diff --git a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/job_scheduling_data_2_0.xsd b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/job_scheduling_data_2_0.xsd new file mode 100644 index 0000000..d1dabc1 --- /dev/null +++ b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/job_scheduling_data_2_0.xsd @@ -0,0 +1,361 @@ + + + + + + + Root level node + + + + + + Commands to be executed before scheduling the jobs and triggers in this file. + + + + + Directives to be followed while scheduling the jobs and triggers in this file. + + + + + + + + + + + + + + Version of the XML Schema instance + + + + + + + + + + Delete all jobs, if any, in the identified group. "*" can be used to identify all groups. Will also result in deleting all triggers related to the jobs. + + + + + Delete all triggers, if any, in the identified group. "*" can be used to identify all groups. Will also result in deletion of related jobs that are non-durable. + + + + + Delete the identified job if it exists (will also result in deleting all triggers related to it). + + + + + + + + + + + Delete the identified trigger if it exists (will also result in deletion of related jobs that are non-durable). + + + + + + + + + + + + + + + + Whether the existing scheduling data (with same identifiers) will be overwritten. If false, and ignore-duplicates is not false, and jobs or triggers with the same names already exist as those in the file, an error will occur. + + + + + If true (and overwrite-existing-data is false) then any job/triggers encountered in this file that have names that already exist in the scheduler will be ignored, and no error will be produced. + + + + + If true trigger's start time is calculated based on earlier run time instead of fixed value. Trigger's start time must be undefined for this to work. + + + + + + + + Define a JobDetail + + + + + + + + + + + + + + + + + Define a JobDataMap + + + + + + + + + Define a JobDataMap entry + + + + + + + + + + Define a Trigger + + + + + + + + + + + Common Trigger definitions + + + + + + + + + + + + + + + + + + + + + + + Define a SimpleTrigger + + + + + + + + + + + + + + + + + Define a CronTrigger + + + + + + + + + + + + + + + Define a DateIntervalTrigger + + + + + + + + + + + + + + + + Cron expression (see JavaDoc for examples) + + Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression! + + Regular expressions are not my strong point but I believe this is complete, + with the caveat that order for expressions like 3-0 is not legal but will pass, + and month and day names must be capitalized. + If you want to examine the correctness look for the [\s] to denote the + seperation of individual regular expressions. This is how I break them up visually + to examine them: + + SECONDS: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + MINUTES: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + HOURS: + ( + ((([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?,)*([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?) + | (([\*]|[0-9]|[0-1][0-9]|[2][0-3])/([0-9]|[0-1][0-9]|[2][0-3])) + | ([\?]) + | ([\*]) + ) [\s] + DAY OF MONTH: + ( + ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?,)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?(C)?) + | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])/([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?) + | (L(-[0-9])?) + | (L(-[1-2][0-9])?) + | (L(-[3][0-1])?) + | (LW) + | ([1-9]W) + | ([1-3][0-9]W) + | ([\?]) + | ([\*]) + )[\s] + MONTH: + ( + ((([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?,)*([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?) + | (([1-9]|0[1-9]|1[0-2])/([1-9]|0[1-9]|1[0-2])) + | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?,)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?) + | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)) + | ([\?]) + | ([\*]) + )[\s] + DAY OF WEEK: + ( + (([1-7](-([1-7]))?,)*([1-7])(-([1-7]))?) + | ([1-7]/([1-7])) + | (((MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?,)*(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?(C)?) + | ((MON|TUE|WED|THU|FRI|SAT|SUN)/(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?) + | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?) + | (([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?) + | ([\?]) + | ([\*]) + ) + YEAR (OPTIONAL): + ( + [\s]? + ([\*])? + | ((19[7-9][0-9])|(20[0-9][0-9]))? + | (((19[7-9][0-9])|(20[0-9][0-9]))/((19[7-9][0-9])|(20[0-9][0-9])))? + | ((((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?,)*((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?)? + ) + + + + + + + + + + Number of times to repeat the Trigger (-1 for indefinite) + + + + + + + + + + Simple Trigger Misfire Instructions + + + + + + + + + + + + + + Cron Trigger Misfire Instructions + + + + + + + + + + + Date Interval Trigger Misfire Instructions + + + + + + + + + + + Interval Units + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/packages.config b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/packages.config index be44d20..7ee01a2 100644 --- a/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/packages.config +++ b/Samples/Topshelf.SimpleInjector.QuartzAsService.Sample/packages.config @@ -2,7 +2,7 @@ - - - + + + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Sample/App.config b/Samples/Topshelf.SimpleInjector.Sample/App.config index 8e15646..8227adb 100644 --- a/Samples/Topshelf.SimpleInjector.Sample/App.config +++ b/Samples/Topshelf.SimpleInjector.Sample/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Samples/Topshelf.SimpleInjector.Sample/Topshelf.SimpleInjector.Sample.csproj b/Samples/Topshelf.SimpleInjector.Sample/Topshelf.SimpleInjector.Sample.csproj index bef374a..37368d7 100644 --- a/Samples/Topshelf.SimpleInjector.Sample/Topshelf.SimpleInjector.Sample.csproj +++ b/Samples/Topshelf.SimpleInjector.Sample/Topshelf.SimpleInjector.Sample.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.Sample Topshelf.SimpleInjector.Sample - v4.5 + v4.5.2 512 ..\ + AnyCPU @@ -33,8 +34,8 @@ 4 - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -44,9 +45,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -71,5 +71,4 @@ --> - - + \ No newline at end of file diff --git a/Samples/Topshelf.SimpleInjector.Sample/packages.config b/Samples/Topshelf.SimpleInjector.Sample/packages.config index 5186da8..70dad02 100644 --- a/Samples/Topshelf.SimpleInjector.Sample/packages.config +++ b/Samples/Topshelf.SimpleInjector.Sample/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/Source/Topshelf.FileSystemWatcher/FileSystemEventFactory.cs b/Source/Topshelf.FileSystemWatcher/FileSystemEventFactory.cs index 6386604..09bff44 100644 --- a/Source/Topshelf.FileSystemWatcher/FileSystemEventFactory.cs +++ b/Source/Topshelf.FileSystemWatcher/FileSystemEventFactory.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; namespace Topshelf.FileSystemWatcher { @@ -9,12 +9,17 @@ public static class FileSystemEventFactory { public static TopshelfFileSystemEventArgs CreateNormalFileSystemEvent(FileSystemEventArgs fileSystemEventArgs) { - return new TopshelfFileSystemEventArgs(fileSystemEventArgs.ChangeType, Path.GetDirectoryName(fileSystemEventArgs.FullPath), fileSystemEventArgs.Name, FileSystemEventType.Normal); + return new TopshelfFileSystemEventArgs(fileSystemEventArgs.ChangeType, Path.GetDirectoryName(fileSystemEventArgs.FullPath), fileSystemEventArgs.Name, null, FileSystemEventType.Normal); + } + + public static TopshelfFileSystemEventArgs CreateRenamedFileSystemEvent(RenamedEventArgs fileSystemEventArgs) + { + return new TopshelfFileSystemEventArgs(fileSystemEventArgs.ChangeType, Path.GetDirectoryName(fileSystemEventArgs.FullPath), fileSystemEventArgs.Name, fileSystemEventArgs.OldName, FileSystemEventType.Renamed); } public static TopshelfFileSystemEventArgs CreateCurrentStateFileSystemEvent(string directory, string name) { - return new TopshelfFileSystemEventArgs(WatcherChangeTypes.All, directory, name, FileSystemEventType.CurrentState); + return new TopshelfFileSystemEventArgs(WatcherChangeTypes.All, directory, name, null, FileSystemEventType.CurrentState); } } -} \ No newline at end of file +} diff --git a/Source/Topshelf.FileSystemWatcher/FileSystemEventType.cs b/Source/Topshelf.FileSystemWatcher/FileSystemEventType.cs index 272d205..81ee8e1 100644 --- a/Source/Topshelf.FileSystemWatcher/FileSystemEventType.cs +++ b/Source/Topshelf.FileSystemWatcher/FileSystemEventType.cs @@ -10,9 +10,14 @@ public enum FileSystemEventType /// Normal, + /// + /// A renamed FileSystemChange event + /// + Renamed, + /// /// A CurrentState event (e.g. if service was restarted) /// CurrentState, } -} \ No newline at end of file +} diff --git a/Source/Topshelf.FileSystemWatcher/FileSystemWatcherConfigurator.cs b/Source/Topshelf.FileSystemWatcher/FileSystemWatcherConfigurator.cs index 29b8eb3..4c86786 100644 --- a/Source/Topshelf.FileSystemWatcher/FileSystemWatcherConfigurator.cs +++ b/Source/Topshelf.FileSystemWatcher/FileSystemWatcherConfigurator.cs @@ -18,13 +18,51 @@ public FileSystemWatcherConfigurator AddDirectory(Action public class DirectoryConfiguration { + public DirectoryConfiguration() + { + FileFilter = "*.*"; + ExcludeDuplicateEventsWindowTime = TimeSpan.FromSeconds(2); + } + + /// + /// Watching directory + /// public string Path { get; set; } + /// + /// Include subdirectories + /// public bool IncludeSubDirectories { get; set; } + /// + /// Create directory if not exist + /// public bool CreateDir { get; set; } + /// + /// Filter string used to determine what files are monitored in + /// Default value: "*.*" (Watches all files) + /// public string FileFilter { get; set; } + /// + /// Specifies changes to watch for in a file or folder + /// public NotifyFilters NotifyFilters { get; set; } + /// + /// Activate the return the initial state of watching directory + /// public bool GetInitialStateEvent { get; set; } + /// + /// The size (in bytes) of the FileSystemWatcher internal buffer. + /// public int InternalBufferSize { get; set; } + /// + /// Activate filters to exclude duplicate events + /// + public bool ExcludeDuplicateEvents { get; set; } + /// + /// Window time for excluding duplicate events + /// Default value: 2 seconds + /// + public TimeSpan ExcludeDuplicateEventsWindowTime { get; set; } + } } } \ No newline at end of file diff --git a/Source/Topshelf.FileSystemWatcher/ServiceConfiguratorExtensions.cs b/Source/Topshelf.FileSystemWatcher/ServiceConfiguratorExtensions.cs index 3ef6008..eb46cc6 100644 --- a/Source/Topshelf.FileSystemWatcher/ServiceConfiguratorExtensions.cs +++ b/Source/Topshelf.FileSystemWatcher/ServiceConfiguratorExtensions.cs @@ -1,8 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using System.Reactive.Linq; using Topshelf.Logging; using Topshelf.ServiceConfigurators; @@ -10,17 +11,23 @@ namespace Topshelf.FileSystemWatcher { public static class ServiceConfiguratorExtensions { - private const string _defaultFileFilter = "*.*"; - private static readonly ICollection _watchers = new Collection(); + public static ServiceConfigurator WhenFileSystemRenamed(this ServiceConfigurator configurator, + Action fileSystemWatcherConfigurator, + Action fileSystemRenamed) + where T : class + { + return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, null, null, fileSystemRenamed, null, fileSystemRenamed); + } + public static ServiceConfigurator WhenFileSystemChanged(this ServiceConfigurator configurator, Action fileSystemWatcherConfigurator, Action fileSystemChanged) where T : class { - return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, fileSystemChanged, null, null, fileSystemChanged); + return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, fileSystemChanged, null, null, null, fileSystemChanged); } public static ServiceConfigurator WhenFileSystemCreated(this ServiceConfigurator configurator, @@ -28,7 +35,7 @@ public static class ServiceConfiguratorExtensions Action fileSystemCreated) where T : class { - return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, null, fileSystemCreated, null, fileSystemCreated); + return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, null, fileSystemCreated, null, null, fileSystemCreated); } public static ServiceConfigurator WhenFileSystemDeleted(this ServiceConfigurator configurator, @@ -36,13 +43,14 @@ public static class ServiceConfiguratorExtensions Action fileSystemDeleted) where T : class { - return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, null, null, fileSystemDeleted, fileSystemDeleted); + return WhenFileSystemChanged(configurator, fileSystemWatcherConfigurator, null, null, null, fileSystemDeleted, fileSystemDeleted); } public static ServiceConfigurator WhenFileSystemChanged(this ServiceConfigurator configurator, Action fileSystemWatcherConfigurator, Action fileSystemChanged, Action fileSystemCreated, + Action fileSystemRenamed, Action fileSystemDeleted, Action fileSystemInitialState) where T : class @@ -63,11 +71,12 @@ public static class ServiceConfiguratorExtensions FileSystemEventHandler watcherOnChanged = CreateEventHandler(fileSystemChanged); FileSystemEventHandler watcherOnCreated = CreateEventHandler(fileSystemCreated); + RenamedEventHandler watcherOnRenamed = CreateRenamedEventHandler(fileSystemRenamed); FileSystemEventHandler watcherOnDeleted = CreateEventHandler(fileSystemDeleted); if (configs.Any()) { - BeforeStartingService(configurator, configs, log, watcherOnChanged, watcherOnCreated, watcherOnDeleted); + BeforeStartingService(configurator, configs, log, watcherOnChanged, watcherOnCreated, watcherOnRenamed, watcherOnDeleted); AfterStartingService(configurator, configs, log, fileSystemInitialState); BeforeStoppingService(configurator, log, watcherOnChanged); } @@ -88,10 +97,24 @@ private static FileSystemEventHandler CreateEventHandler(Action fileSystemAction) + { + RenamedEventHandler eventHandler = null; + + if (fileSystemAction != null) + { + eventHandler = + (sender, args) => fileSystemAction(FileSystemEventFactory.CreateRenamedFileSystemEvent(args)); + } + + return eventHandler; + } + private static void BeforeStartingService(ServiceConfigurator configurator, IEnumerable configs, LogWriter log, FileSystemEventHandler watcherOnChanged, FileSystemEventHandler watcherOnCreated, + RenamedEventHandler watcherOnRenamed, FileSystemEventHandler watcherOnDeleted) where T : class { configurator.BeforeStartingService(() => @@ -113,23 +136,62 @@ private static FileSystemEventHandler CreateEventHandler(Action( + h => fileSystemWatcher.Changed += h, + h => fileSystemWatcher.Changed -= h). + Window(config.ExcludeDuplicateEventsWindowTime). + SelectMany(x => x.Distinct(z => z.EventArgs.FullPath)). + Subscribe(pattern => { lock (_watchers) { watcherOnChanged(pattern.Sender, pattern.EventArgs); } }); - _watchers.Add(fileSystemWatcher); + if (watcherOnCreated != null) + Observable.FromEventPattern( + h => { fileSystemWatcher.Created += h; fileSystemWatcher.Changed += h; }, + h => { fileSystemWatcher.Created -= h; fileSystemWatcher.Changed += h; }). + Window(config.ExcludeDuplicateEventsWindowTime). + SelectMany(x => x.Distinct(z => z.EventArgs.FullPath)). + Subscribe(pattern => { lock (_watchers) { watcherOnCreated(pattern.Sender, pattern.EventArgs); } }); - log.Info($"[Topshelf.FileSystemWatcher] configured to listen for events in {config.Path}"); + if (watcherOnRenamed != null) + Observable.FromEventPattern( + h => fileSystemWatcher.Renamed += h, + h => fileSystemWatcher.Renamed -= h). + Window(config.ExcludeDuplicateEventsWindowTime). + SelectMany(x => x.Distinct(z => z.EventArgs.FullPath)). + Subscribe(pattern => { lock (_watchers) { watcherOnRenamed(pattern.Sender, pattern.EventArgs); } }); - foreach (System.IO.FileSystemWatcher watcher in _watchers) + if (watcherOnDeleted != null) + Observable.FromEventPattern( + h => fileSystemWatcher.Deleted += h, + h => fileSystemWatcher.Deleted -= h). + Window(config.ExcludeDuplicateEventsWindowTime). + SelectMany(x => x.Distinct(z => z.EventArgs.FullPath)). + Subscribe(pattern => { lock (_watchers) { watcherOnDeleted(pattern.Sender, pattern.EventArgs); } }); + } + else { - watcher.EnableRaisingEvents = true; + if (watcherOnChanged != null) + fileSystemWatcher.Changed += watcherOnChanged; + if (watcherOnCreated != null) + fileSystemWatcher.Created += watcherOnCreated; + if (watcherOnRenamed != null) + fileSystemWatcher.Renamed += watcherOnRenamed; + if (watcherOnDeleted != null) + fileSystemWatcher.Deleted += watcherOnDeleted; } - log.Info("[Topshelf.FileSystemWatcher] listening for events"); + _watchers.Add(fileSystemWatcher); + + log.Info($"[Topshelf.FileSystemWatcher] configured to listen for events in {config.Path}"); + + //foreach (System.IO.FileSystemWatcher watcher in _watchers) + //{ + // watcher.EnableRaisingEvents = true; + //} + + //log.Info("[Topshelf.FileSystemWatcher] listening for events"); } }); } @@ -195,16 +257,9 @@ private static System.IO.FileSystemWatcher CreateFileSystemWatcher(string path, EnableRaisingEvents = true, IncludeSubdirectories = includeSubDirectories, NotifyFilter = notifyFilters, + Filter = fileFilter, }; - if (!string.IsNullOrWhiteSpace(fileFilter)) - { - watcher.Filter = fileFilter; - } - else - { - watcher.Filter = _defaultFileFilter; - } if (internalBufferSize > 0) { watcher.InternalBufferSize = internalBufferSize; @@ -213,4 +268,4 @@ private static System.IO.FileSystemWatcher CreateFileSystemWatcher(string path, return watcher; } } -} \ No newline at end of file +} diff --git a/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.csproj b/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.csproj index 98879ed..4565734 100644 --- a/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.csproj +++ b/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.csproj @@ -9,7 +9,7 @@ Properties Topshelf.FileSystemWatcher Topshelf.FileSystemWatcher - v4.0 + v4.5.2 512 ..\ @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -30,17 +31,30 @@ TRACE prompt 4 + false + + ..\..\packages\System.Reactive.Core.3.1.1\lib\net45\System.Reactive.Core.dll + True + + + ..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll + True + + + ..\..\packages\System.Reactive.Linq.3.1.1\lib\net45\System.Reactive.Linq.dll + True + - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll True @@ -64,5 +78,4 @@ --> - - + \ No newline at end of file diff --git a/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.nuspec b/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.nuspec index 35dbfc4..b17ae7a 100644 --- a/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.nuspec +++ b/Source/Topshelf.FileSystemWatcher/Topshelf.FileSystemWatcher.nuspec @@ -14,7 +14,7 @@ Copyright $author$ 2014 Topshelf FileSystemWatcher Service WindowsService Host FileSystem Events FileSystemEvent - + \ No newline at end of file diff --git a/Source/Topshelf.FileSystemWatcher/TopshelfFileSystemEventArgs.cs b/Source/Topshelf.FileSystemWatcher/TopshelfFileSystemEventArgs.cs index f90fa0f..149e7c5 100644 --- a/Source/Topshelf.FileSystemWatcher/TopshelfFileSystemEventArgs.cs +++ b/Source/Topshelf.FileSystemWatcher/TopshelfFileSystemEventArgs.cs @@ -2,7 +2,7 @@ namespace Topshelf.FileSystemWatcher { - public class TopshelfFileSystemEventArgs : FileSystemEventArgs + public class TopshelfFileSystemEventArgs : RenamedEventArgs { /// /// Determine whether this event was raised upon initial state check @@ -16,11 +16,12 @@ public class TopshelfFileSystemEventArgs : FileSystemEventArgs /// /// /// + /// /// - public TopshelfFileSystemEventArgs(WatcherChangeTypes changeType, string directory, string name, FileSystemEventType fileSystemEventType) - : base(changeType, directory, name) + public TopshelfFileSystemEventArgs(WatcherChangeTypes changeType, string directory, string name, string oldName, FileSystemEventType fileSystemEventType) + : base(changeType, directory, name, oldName) { FileSystemEventType = fileSystemEventType; } } -} \ No newline at end of file +} diff --git a/Source/Topshelf.FileSystemWatcher/packages.config b/Source/Topshelf.FileSystemWatcher/packages.config index 124e50e..815532a 100644 --- a/Source/Topshelf.FileSystemWatcher/packages.config +++ b/Source/Topshelf.FileSystemWatcher/packages.config @@ -1,4 +1,7 @@  - + + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.CI/Topshelf.SimpleInjector.CI.csproj b/Source/Topshelf.SimpleInjector.CI/Topshelf.SimpleInjector.CI.csproj index 75023c7..81aa6c9 100644 --- a/Source/Topshelf.SimpleInjector.CI/Topshelf.SimpleInjector.CI.csproj +++ b/Source/Topshelf.SimpleInjector.CI/Topshelf.SimpleInjector.CI.csproj @@ -9,7 +9,7 @@ Properties Topshelf.SimpleInjector.CI Topshelf.SimpleInjector.CI - v4.0 + v4.5.2 512 @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -29,6 +30,7 @@ TRACE prompt 4 + false diff --git a/Source/Topshelf.SimpleInjector.CI/packages.config b/Source/Topshelf.SimpleInjector.CI/packages.config index 9871a85..4712b21 100644 --- a/Source/Topshelf.SimpleInjector.CI/packages.config +++ b/Source/Topshelf.SimpleInjector.CI/packages.config @@ -1,7 +1,13 @@  - - - - + + + + + + + + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.Quartz/Factory/SimpleInjectorDecoratorJobFactory.cs b/Source/Topshelf.SimpleInjector.Quartz/Factory/SimpleInjectorDecoratorJobFactory.cs index db5194e..0b1615f 100644 --- a/Source/Topshelf.SimpleInjector.Quartz/Factory/SimpleInjectorDecoratorJobFactory.cs +++ b/Source/Topshelf.SimpleInjector.Quartz/Factory/SimpleInjectorDecoratorJobFactory.cs @@ -33,7 +33,7 @@ public SimpleInjectorDecoratorJobFactory(Container container, params Assembly[] from type in assembly.GetTypes() where typeof(IJob).IsAssignableFrom(type) where !type.IsAbstract && !type.IsGenericTypeDefinition - let ctor = container.Options.ConstructorResolutionBehavior.GetConstructor(typeof(IJob), type) + let ctor = container.Options.ConstructorResolutionBehavior.GetConstructor(type) let typeIsDecorator = ctor.GetParameters().Any(p => p.ParameterType == typeof(IJob)) let typeIsDecorateeFactory = ctor.GetParameters().Any(p => p.ParameterType == typeof(Func)) where !typeIsDecorator && !typeIsDecorateeFactory diff --git a/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.csproj b/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.csproj index a3bc0f6..2a436e2 100644 --- a/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.csproj +++ b/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.csproj @@ -9,7 +9,7 @@ Properties Topshelf.SimpleInjector.Quartz Topshelf.SimpleInjector.Quartz - v4.0 + v4.5.2 512 ..\ @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -32,6 +33,7 @@ TRACE prompt 4 + false @@ -45,12 +47,11 @@ ..\..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll True - - ..\..\packages\Quartz.2.3.3\lib\net40\Quartz.dll - True + + ..\..\packages\Quartz.2.5.0\lib\net40\Quartz.dll - - ..\..\packages\SimpleInjector.3.1.2\lib\net40-client\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net40\SimpleInjector.dll True @@ -60,13 +61,11 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll - - ..\..\packages\Topshelf.SimpleInjector.1.0.0.16\lib\net40\Topshelf.SimpleInjector.dll - True + + ..\..\packages\Topshelf.SimpleInjector.1.0.0.17\lib\net40\Topshelf.SimpleInjector.dll @@ -81,6 +80,10 @@ + + + Designer + Designer diff --git a/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.nuspec b/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.nuspec index 09107af..5857ce3 100644 --- a/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.nuspec +++ b/Source/Topshelf.SimpleInjector.Quartz/Topshelf.SimpleInjector.Quartz.nuspec @@ -15,7 +15,7 @@ Topshelf SimpleInjector IoC Inversion-of-control Service WindowsService Dependency Injection DI Host Quartz Quartz.NET Scheduling Schedule Cron - + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.Quartz/app.config b/Source/Topshelf.SimpleInjector.Quartz/app.config new file mode 100644 index 0000000..25a7083 --- /dev/null +++ b/Source/Topshelf.SimpleInjector.Quartz/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.Quartz/job_scheduling_data_2_0.xsd b/Source/Topshelf.SimpleInjector.Quartz/job_scheduling_data_2_0.xsd new file mode 100644 index 0000000..d1dabc1 --- /dev/null +++ b/Source/Topshelf.SimpleInjector.Quartz/job_scheduling_data_2_0.xsd @@ -0,0 +1,361 @@ + + + + + + + Root level node + + + + + + Commands to be executed before scheduling the jobs and triggers in this file. + + + + + Directives to be followed while scheduling the jobs and triggers in this file. + + + + + + + + + + + + + + Version of the XML Schema instance + + + + + + + + + + Delete all jobs, if any, in the identified group. "*" can be used to identify all groups. Will also result in deleting all triggers related to the jobs. + + + + + Delete all triggers, if any, in the identified group. "*" can be used to identify all groups. Will also result in deletion of related jobs that are non-durable. + + + + + Delete the identified job if it exists (will also result in deleting all triggers related to it). + + + + + + + + + + + Delete the identified trigger if it exists (will also result in deletion of related jobs that are non-durable). + + + + + + + + + + + + + + + + Whether the existing scheduling data (with same identifiers) will be overwritten. If false, and ignore-duplicates is not false, and jobs or triggers with the same names already exist as those in the file, an error will occur. + + + + + If true (and overwrite-existing-data is false) then any job/triggers encountered in this file that have names that already exist in the scheduler will be ignored, and no error will be produced. + + + + + If true trigger's start time is calculated based on earlier run time instead of fixed value. Trigger's start time must be undefined for this to work. + + + + + + + + Define a JobDetail + + + + + + + + + + + + + + + + + Define a JobDataMap + + + + + + + + + Define a JobDataMap entry + + + + + + + + + + Define a Trigger + + + + + + + + + + + Common Trigger definitions + + + + + + + + + + + + + + + + + + + + + + + Define a SimpleTrigger + + + + + + + + + + + + + + + + + Define a CronTrigger + + + + + + + + + + + + + + + Define a DateIntervalTrigger + + + + + + + + + + + + + + + + Cron expression (see JavaDoc for examples) + + Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression! + + Regular expressions are not my strong point but I believe this is complete, + with the caveat that order for expressions like 3-0 is not legal but will pass, + and month and day names must be capitalized. + If you want to examine the correctness look for the [\s] to denote the + seperation of individual regular expressions. This is how I break them up visually + to examine them: + + SECONDS: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + MINUTES: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + HOURS: + ( + ((([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?,)*([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?) + | (([\*]|[0-9]|[0-1][0-9]|[2][0-3])/([0-9]|[0-1][0-9]|[2][0-3])) + | ([\?]) + | ([\*]) + ) [\s] + DAY OF MONTH: + ( + ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?,)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?(C)?) + | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])/([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?) + | (L(-[0-9])?) + | (L(-[1-2][0-9])?) + | (L(-[3][0-1])?) + | (LW) + | ([1-9]W) + | ([1-3][0-9]W) + | ([\?]) + | ([\*]) + )[\s] + MONTH: + ( + ((([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?,)*([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?) + | (([1-9]|0[1-9]|1[0-2])/([1-9]|0[1-9]|1[0-2])) + | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?,)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?) + | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)) + | ([\?]) + | ([\*]) + )[\s] + DAY OF WEEK: + ( + (([1-7](-([1-7]))?,)*([1-7])(-([1-7]))?) + | ([1-7]/([1-7])) + | (((MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?,)*(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?(C)?) + | ((MON|TUE|WED|THU|FRI|SAT|SUN)/(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?) + | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?) + | (([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?) + | ([\?]) + | ([\*]) + ) + YEAR (OPTIONAL): + ( + [\s]? + ([\*])? + | ((19[7-9][0-9])|(20[0-9][0-9]))? + | (((19[7-9][0-9])|(20[0-9][0-9]))/((19[7-9][0-9])|(20[0-9][0-9])))? + | ((((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?,)*((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?)? + ) + + + + + + + + + + Number of times to repeat the Trigger (-1 for indefinite) + + + + + + + + + + Simple Trigger Misfire Instructions + + + + + + + + + + + + + + Cron Trigger Misfire Instructions + + + + + + + + + + + Date Interval Trigger Misfire Instructions + + + + + + + + + + + Interval Units + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.Quartz/packages.config b/Source/Topshelf.SimpleInjector.Quartz/packages.config index 29187d1..96bbca5 100644 --- a/Source/Topshelf.SimpleInjector.Quartz/packages.config +++ b/Source/Topshelf.SimpleInjector.Quartz/packages.config @@ -2,8 +2,8 @@ - - - - + + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector.QuickStart/Topshelf.SimpleInjector.QuickStart.csproj b/Source/Topshelf.SimpleInjector.QuickStart/Topshelf.SimpleInjector.QuickStart.csproj index bc6f1ac..ec6563e 100644 --- a/Source/Topshelf.SimpleInjector.QuickStart/Topshelf.SimpleInjector.QuickStart.csproj +++ b/Source/Topshelf.SimpleInjector.QuickStart/Topshelf.SimpleInjector.QuickStart.csproj @@ -9,7 +9,7 @@ Properties Topshelf.SimpleInjector.QuickStart Topshelf.SimpleInjector.QuickStart - v4.0 + v4.5.2 512 ..\ @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -32,11 +33,12 @@ TRACE prompt 4 + false - - ..\..\packages\SimpleInjector.3.1.2\lib\net40-client\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net40\SimpleInjector.dll True @@ -46,13 +48,11 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll - - ..\..\packages\Topshelf.SimpleInjector.1.0.0.16\lib\net40\Topshelf.SimpleInjector.dll - True + + ..\..\packages\Topshelf.SimpleInjector.1.0.0.17\lib\net40\Topshelf.SimpleInjector.dll @@ -63,6 +63,7 @@ + diff --git a/Source/Topshelf.SimpleInjector.QuickStart/app.config b/Source/Topshelf.SimpleInjector.QuickStart/app.config new file mode 100644 index 0000000..9863051 --- /dev/null +++ b/Source/Topshelf.SimpleInjector.QuickStart/app.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Source/Topshelf.SimpleInjector.QuickStart/packages.config b/Source/Topshelf.SimpleInjector.QuickStart/packages.config index 96b5794..5907f27 100644 --- a/Source/Topshelf.SimpleInjector.QuickStart/packages.config +++ b/Source/Topshelf.SimpleInjector.QuickStart/packages.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.csproj b/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.csproj index a8889da..07112a5 100644 --- a/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.csproj +++ b/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.csproj @@ -9,7 +9,7 @@ Properties Topshelf.SimpleInjector Topshelf.SimpleInjector - v4.0 + v4.5.2 512 ..\ @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -30,10 +31,11 @@ TRACE prompt 4 + false - - ..\..\packages\SimpleInjector.3.1.2\lib\net40-client\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net40\SimpleInjector.dll True @@ -43,9 +45,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -66,5 +67,4 @@ --> - - + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.nuspec b/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.nuspec index 40d8bbc..ef40acb 100644 --- a/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.nuspec +++ b/Source/Topshelf.SimpleInjector/Topshelf.SimpleInjector.nuspec @@ -14,8 +14,8 @@ Copyright $author$ 2014 Topshelf SimpleInjector IoC Inversion-of-control Service WindowsService Dependency Injection DI Host - - + + \ No newline at end of file diff --git a/Source/Topshelf.SimpleInjector/packages.config b/Source/Topshelf.SimpleInjector/packages.config index b6504f5..52ca703 100644 --- a/Source/Topshelf.SimpleInjector/packages.config +++ b/Source/Topshelf.SimpleInjector/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/Tests/Topshelf.FileSystemWatcher.Test/Topshelf.FileSystemWatcher.Test.csproj b/Tests/Topshelf.FileSystemWatcher.Test/Topshelf.FileSystemWatcher.Test.csproj index 14cb3e6..57c5e68 100644 --- a/Tests/Topshelf.FileSystemWatcher.Test/Topshelf.FileSystemWatcher.Test.csproj +++ b/Tests/Topshelf.FileSystemWatcher.Test/Topshelf.FileSystemWatcher.Test.csproj @@ -9,9 +9,10 @@ Properties Topshelf.FileSystemWatcher.Test Topshelf.FileSystemWatcher.Test - v4.5 + v4.5.2 512 ..\ + true @@ -31,18 +32,20 @@ 4 - - ..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll + + ..\..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll True - - ..\..\packages\NUnit.ApplicationDomain.6.0.0\lib\net40\NUnit.ApplicationDomain.dll - True + + ..\..\packages\Moq.4.7.10\lib\net45\Moq.dll - - ..\..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll + + ..\..\packages\NUnit.ApplicationDomain.10.2.0\lib\net40\NUnit.ApplicationDomain.dll True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll + @@ -50,8 +53,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll True @@ -77,5 +80,4 @@ --> - - + \ No newline at end of file diff --git a/Tests/Topshelf.FileSystemWatcher.Test/TopshelfFileSystemWatcherTest.cs b/Tests/Topshelf.FileSystemWatcher.Test/TopshelfFileSystemWatcherTest.cs index f092b28..7d057bf 100644 --- a/Tests/Topshelf.FileSystemWatcher.Test/TopshelfFileSystemWatcherTest.cs +++ b/Tests/Topshelf.FileSystemWatcher.Test/TopshelfFileSystemWatcherTest.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; using System.Text; using Moq; using NUnit.Framework; @@ -14,14 +14,14 @@ public class TopshelfFileSystemWatcherTest [TearDown] public void TearDown() { - if (Directory.Exists(Directory.GetCurrentDirectory() + _testDir)) - Directory.Delete(Directory.GetCurrentDirectory() + _testDir, true); - if (Directory.Exists(Directory.GetCurrentDirectory() + _testDir2)) - Directory.Delete(Directory.GetCurrentDirectory() + _testDir2, true); + if (Directory.Exists(TestContext.CurrentContext.WorkDirectory + _testDir)) + Directory.Delete(TestContext.CurrentContext.WorkDirectory + _testDir, true); + if (Directory.Exists(TestContext.CurrentContext.WorkDirectory + _testDir2)) + Directory.Delete(TestContext.CurrentContext.WorkDirectory + _testDir2, true); } [Test, RunInApplicationDomain] - public void FileSystemChangeEventIsInvokedWithOneDirectoryTest() + public void FileSystemCreateEventIsInvokedWithOneDirectoryTest() { //Arrange Mock onChanged = new Mock(); @@ -42,7 +42,7 @@ public void FileSystemChangeEventIsInvokedWithOneDirectoryTest() s.WhenStopped((service, host) => true); s.WhenFileSystemCreated(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.NotifyFilters = NotifyFilters.FileName; }), onChanged.Object.FileSystemCreated); @@ -51,6 +51,10 @@ public void FileSystemChangeEventIsInvokedWithOneDirectoryTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Once); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -72,13 +76,13 @@ public void FileSystemDeleteEventIsInvokedWithOneDirectoryTest() s.WhenStarted((service, host) => { CreateFile(_testDir + testDeleteFile); - File.Delete(Directory.GetCurrentDirectory() + _testDir + testDeleteFile); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + testDeleteFile); return true; }); s.WhenStopped((service, host) => true); s.WhenFileSystemDeleted(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.NotifyFilters = NotifyFilters.FileName; }), onChanged.Object.FileSystemDeleted); @@ -89,12 +93,13 @@ public void FileSystemDeleteEventIsInvokedWithOneDirectoryTest() onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Once); onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Never); onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } [Test, RunInApplicationDomain] - public void FileSystemChangeEventIsInvokedWithOneDirectoryTest2() + public void FileSystemChangeEventIsInvokedWithOneDirectoryTest() { //Arrange Mock onChanged = new Mock(); @@ -112,14 +117,14 @@ public void FileSystemChangeEventIsInvokedWithOneDirectoryTest2() s.WhenStarted((service, host) => { CreateFile(_testDir + "testFile.Test"); - WriteToFile(Directory.GetCurrentDirectory() + _testDir + "testFile.Test", "123"); - WriteToFile(Directory.GetCurrentDirectory() + _testDir + "testFile.Test", "321"); + WriteToFile(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test", "123"); + WriteToFile(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test", "321"); return true; }); s.WhenStopped((service, host) => true); s.WhenFileSystemChanged(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.IncludeSubDirectories = true; dir.NotifyFilters = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime; @@ -131,6 +136,50 @@ public void FileSystemChangeEventIsInvokedWithOneDirectoryTest2() onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Exactly(2)); onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Never); onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); + Assert.AreEqual(TopshelfExitCode.Ok, exitCode); + } + + [Test, RunInApplicationDomain] + public void FileSystemRenameEventIsInvokedWithOneDirectoryTest() + { + //Arrange + Mock onChanged = new Mock(); + TopshelfFileSystemEventArgs argsCalled = null; + onChanged.Setup(mock => mock.FileSystemChanged(It.IsAny())).Callback(args => argsCalled = args); + + CreateFile(_testDir + "testFile.Test"); + + //Act + var exitCode = HostFactory.Run(config => + { + config.UseTestHost(); + + config.Service(s => + { + s.ConstructUsing(() => new TopshelfFileSystemWatcherTest()); + s.WhenStarted((service, host) => + { + RenameFile(_testDir + "testFile.Test", _testDir + "testFile2.Test"); + return true; + }); + s.WhenStopped((service, host) => true); + s.WhenFileSystemRenamed(configurator => configurator.AddDirectory(dir => + { + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; + dir.CreateDir = true; + dir.IncludeSubDirectories = true; + dir.NotifyFilters = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime; + }), onChanged.Object.FileSystemRenamed); + }); + }); + + //Assert + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Exactly(1)); onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -160,13 +209,13 @@ public void FileSystemChangeEventsAreInvokedWithMutipleDirectoriesTest() { configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.NotifyFilters = NotifyFilters.FileName; }); configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir2; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir2; dir.CreateDir = true; dir.NotifyFilters = NotifyFilters.FileName; }); @@ -176,10 +225,13 @@ public void FileSystemChangeEventsAreInvokedWithMutipleDirectoriesTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(2)); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } - [Test, RunInApplicationDomain] public void FileSystemInitialStateEventsAreInvokedCorrectlyTest() { @@ -201,7 +253,7 @@ public void FileSystemInitialStateEventsAreInvokedCorrectlyTest() s.WhenStopped((service, host) => true); s.WhenFileSystemCreated(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.GetInitialStateEvent = true; }), onChanged.Object.FileSystemCreated); @@ -210,6 +262,10 @@ public void FileSystemInitialStateEventsAreInvokedCorrectlyTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(3)); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -240,13 +296,13 @@ public void NormalAndInitialFileSystemChangeEventsAreInvokedCorrectlyTest() { configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.GetInitialStateEvent = true; }); configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir2; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir2; dir.CreateDir = true; dir.NotifyFilters = NotifyFilters.FileName; dir.IncludeSubDirectories = true; @@ -258,6 +314,10 @@ public void NormalAndInitialFileSystemChangeEventsAreInvokedCorrectlyTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(4)); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -283,7 +343,7 @@ public void NormalFileSystemChangeEventFilterTest() s.WhenStopped((service, host) => true); s.WhenFileSystemCreated(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test2"; dir.NotifyFilters = NotifyFilters.FileName; @@ -293,6 +353,10 @@ public void NormalFileSystemChangeEventFilterTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -317,20 +381,22 @@ public void NormalAndInitialFileSystemChangeEventFilterTest() CreateFile(_testDir + "testFile.Test2"); CreateFile(_testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test2"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test2"); return true; }); s.WhenStopped((service, host) => true); s.WhenFileSystemChanged(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test2"; dir.NotifyFilters = NotifyFilters.FileName; dir.GetInitialStateEvent = true; - }), onChanged.Object.FileSystemChanged, onChanged.Object.FileSystemCreated, onChanged.Object.FileSystemDeleted, onChanged.Object.FileSystemInitial); + }), onChanged.Object.FileSystemChanged, onChanged.Object.FileSystemCreated, + onChanged.Object.FileSystemRenamed, + onChanged.Object.FileSystemDeleted, onChanged.Object.FileSystemInitial); }); }); @@ -339,6 +405,7 @@ public void NormalAndInitialFileSystemChangeEventFilterTest() onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(1)); onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Exactly(1)); onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Exactly(1)); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -367,10 +434,10 @@ public void NormalAndInitialFileSystemChangeEventMultipleFiltersTest() CreateFile(_testDir + "testFile1.Test2"); CreateFile(_testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test2"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile1.Test2"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test3"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test2"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile1.Test2"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test3"); return true; }); @@ -379,7 +446,7 @@ public void NormalAndInitialFileSystemChangeEventMultipleFiltersTest() { configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test2"; dir.NotifyFilters = NotifyFilters.FileName; @@ -387,13 +454,14 @@ public void NormalAndInitialFileSystemChangeEventMultipleFiltersTest() }); configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test3"; dir.NotifyFilters = NotifyFilters.FileName; dir.GetInitialStateEvent = true; }); }, onChanged.Object.FileSystemChanged, onChanged.Object.FileSystemCreated, + onChanged.Object.FileSystemRenamed, onChanged.Object.FileSystemDeleted, onChanged.Object.FileSystemInitial); }); }); @@ -403,6 +471,7 @@ public void NormalAndInitialFileSystemChangeEventMultipleFiltersTest() onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(3)); onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Exactly(3)); onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Exactly(3)); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -429,9 +498,9 @@ public void NormalAndInitialFileSystemChangeEventMultipleConfiguratorsTest() CreateFile(_testDir + "testFile.Test2"); CreateFile(_testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test2"); - File.Delete(Directory.GetCurrentDirectory() + _testDir + "testFile.Test3"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test2"); + File.Delete(TestContext.CurrentContext.WorkDirectory + _testDir + "testFile.Test3"); return true; }); @@ -440,7 +509,7 @@ public void NormalAndInitialFileSystemChangeEventMultipleConfiguratorsTest() { configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test2"; dir.NotifyFilters = NotifyFilters.FileName; @@ -448,7 +517,7 @@ public void NormalAndInitialFileSystemChangeEventMultipleConfiguratorsTest() }); configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test3"; dir.NotifyFilters = NotifyFilters.FileName; @@ -456,13 +525,14 @@ public void NormalAndInitialFileSystemChangeEventMultipleConfiguratorsTest() }); configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + _testDir; + dir.Path = TestContext.CurrentContext.WorkDirectory + _testDir; dir.CreateDir = true; dir.FileFilter = "*.Test"; dir.NotifyFilters = NotifyFilters.FileName; dir.GetInitialStateEvent = false; }); - }, onChanged.Object.FileSystemChanged, onChanged.Object.FileSystemCreated, + }, onChanged.Object.FileSystemChanged, onChanged.Object.FileSystemCreated, + onChanged.Object.FileSystemRenamed, onChanged.Object.FileSystemDeleted, onChanged.Object.FileSystemInitial); }); }); @@ -472,6 +542,7 @@ public void NormalAndInitialFileSystemChangeEventMultipleConfiguratorsTest() onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Exactly(3)); onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Exactly(3)); onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Exactly(2)); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.Ok, exitCode); } @@ -493,7 +564,7 @@ public void ExceptionIsThrownWhenDirDoesNotExistTest() s.WhenStopped((service, host) => true); s.WhenFileSystemCreated(configurator => configurator.AddDirectory(dir => { - dir.Path = Directory.GetCurrentDirectory() + "TestDirWhichDoesNotExist"; + dir.Path = TestContext.CurrentContext.WorkDirectory + "TestDirWhichDoesNotExist"; dir.CreateDir = false; dir.NotifyFilters = NotifyFilters.FileName; }), onChanged.Object.FileSystemCreated); @@ -502,18 +573,27 @@ public void ExceptionIsThrownWhenDirDoesNotExistTest() //Assert onChanged.Verify(mock => mock.FileSystemCreated(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemChanged(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemDeleted(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemInitial(It.IsAny()), Times.Never); + onChanged.Verify(mock => mock.FileSystemRenamed(It.IsAny()), Times.Never); Assert.AreEqual(TopshelfExitCode.StartServiceFailed, exitCode); } private static void CreateFile(string relativePath) { - if (!Directory.Exists(Path.GetFullPath(Directory.GetCurrentDirectory() + relativePath))) - Directory.CreateDirectory(Directory.GetCurrentDirectory() + Path.GetDirectoryName(relativePath)); - using (FileStream fs = File.Create(Directory.GetCurrentDirectory() + relativePath)) + if (!Directory.Exists(Path.GetFullPath(TestContext.CurrentContext.WorkDirectory + Path.GetDirectoryName(relativePath)))) + Directory.CreateDirectory(TestContext.CurrentContext.WorkDirectory + Path.GetDirectoryName(relativePath)); + using (FileStream fs = File.Create(TestContext.CurrentContext.WorkDirectory + relativePath)) { } } + private static void RenameFile(string relativePath, string newRelativePath) + { + File.Move(TestContext.CurrentContext.WorkDirectory + relativePath, TestContext.CurrentContext.WorkDirectory + newRelativePath); + } + private void WriteToFile(string pathOfFileToWriteTo, string dataToWrite) { using (FileStream fs = File.OpenWrite(pathOfFileToWriteTo)) @@ -524,24 +604,12 @@ private void WriteToFile(string pathOfFileToWriteTo, string dataToWrite) } } - internal class MyService : ServiceControl - { - public bool Start(HostControl hostControl) - { - return true; - } - - public bool Stop(HostControl hostControl) - { - return true; - } - } - public interface IDelegateMock { + void FileSystemRenamed(TopshelfFileSystemEventArgs args); void FileSystemChanged(TopshelfFileSystemEventArgs args); void FileSystemCreated(TopshelfFileSystemEventArgs args); void FileSystemDeleted(TopshelfFileSystemEventArgs args); void FileSystemInitial(TopshelfFileSystemEventArgs args); } -} \ No newline at end of file +} diff --git a/Tests/Topshelf.FileSystemWatcher.Test/app.config b/Tests/Topshelf.FileSystemWatcher.Test/app.config index 2151155..ca31f60 100644 --- a/Tests/Topshelf.FileSystemWatcher.Test/app.config +++ b/Tests/Topshelf.FileSystemWatcher.Test/app.config @@ -4,8 +4,12 @@ - + + + + + - \ No newline at end of file + diff --git a/Tests/Topshelf.FileSystemWatcher.Test/packages.config b/Tests/Topshelf.FileSystemWatcher.Test/packages.config index 0cfdca7..dfa1d3e 100644 --- a/Tests/Topshelf.FileSystemWatcher.Test/packages.config +++ b/Tests/Topshelf.FileSystemWatcher.Test/packages.config @@ -1,7 +1,8 @@  - - - - + + + + + \ No newline at end of file diff --git a/Tests/Topshelf.SimpleInjector.Quartz.Test/Topshelf.SimpleInjector.Quartz.Test.csproj b/Tests/Topshelf.SimpleInjector.Quartz.Test/Topshelf.SimpleInjector.Quartz.Test.csproj index 3168f3b..38e05ee 100644 --- a/Tests/Topshelf.SimpleInjector.Quartz.Test/Topshelf.SimpleInjector.Quartz.Test.csproj +++ b/Tests/Topshelf.SimpleInjector.Quartz.Test/Topshelf.SimpleInjector.Quartz.Test.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.Quartz.Test Topshelf.SimpleInjector.Quartz.Test - v4.5 + v4.5.2 512 ..\ + true @@ -31,6 +32,10 @@ 4 + + ..\..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll + True + ..\..\packages\Common.Logging.3.3.1\lib\net40\Common.Logging.dll True @@ -39,24 +44,20 @@ ..\..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll True - - ..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll - True + + ..\..\packages\Moq.4.7.10\lib\net45\Moq.dll - - ..\..\packages\NUnit.ApplicationDomain.6.0.0\lib\net40\NUnit.ApplicationDomain.dll - True + + ..\..\packages\NUnit.ApplicationDomain.10.2.0\lib\net40\NUnit.ApplicationDomain.dll - - ..\..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll - - ..\..\packages\Quartz.2.3.3\lib\net40\Quartz.dll - True + + ..\..\packages\Quartz.2.5.0\lib\net40\Quartz.dll - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -66,9 +67,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -87,6 +87,9 @@ + + Designer + @@ -97,5 +100,4 @@ --> - - + \ No newline at end of file diff --git a/Tests/Topshelf.SimpleInjector.Quartz.Test/app.config b/Tests/Topshelf.SimpleInjector.Quartz.Test/app.config index 24f81fc..fd6a4b4 100644 --- a/Tests/Topshelf.SimpleInjector.Quartz.Test/app.config +++ b/Tests/Topshelf.SimpleInjector.Quartz.Test/app.config @@ -12,16 +12,20 @@ - + - + - + + + + + - \ No newline at end of file + diff --git a/Tests/Topshelf.SimpleInjector.Quartz.Test/job_scheduling_data_2_0.xsd b/Tests/Topshelf.SimpleInjector.Quartz.Test/job_scheduling_data_2_0.xsd new file mode 100644 index 0000000..d1dabc1 --- /dev/null +++ b/Tests/Topshelf.SimpleInjector.Quartz.Test/job_scheduling_data_2_0.xsd @@ -0,0 +1,361 @@ + + + + + + + Root level node + + + + + + Commands to be executed before scheduling the jobs and triggers in this file. + + + + + Directives to be followed while scheduling the jobs and triggers in this file. + + + + + + + + + + + + + + Version of the XML Schema instance + + + + + + + + + + Delete all jobs, if any, in the identified group. "*" can be used to identify all groups. Will also result in deleting all triggers related to the jobs. + + + + + Delete all triggers, if any, in the identified group. "*" can be used to identify all groups. Will also result in deletion of related jobs that are non-durable. + + + + + Delete the identified job if it exists (will also result in deleting all triggers related to it). + + + + + + + + + + + Delete the identified trigger if it exists (will also result in deletion of related jobs that are non-durable). + + + + + + + + + + + + + + + + Whether the existing scheduling data (with same identifiers) will be overwritten. If false, and ignore-duplicates is not false, and jobs or triggers with the same names already exist as those in the file, an error will occur. + + + + + If true (and overwrite-existing-data is false) then any job/triggers encountered in this file that have names that already exist in the scheduler will be ignored, and no error will be produced. + + + + + If true trigger's start time is calculated based on earlier run time instead of fixed value. Trigger's start time must be undefined for this to work. + + + + + + + + Define a JobDetail + + + + + + + + + + + + + + + + + Define a JobDataMap + + + + + + + + + Define a JobDataMap entry + + + + + + + + + + Define a Trigger + + + + + + + + + + + Common Trigger definitions + + + + + + + + + + + + + + + + + + + + + + + Define a SimpleTrigger + + + + + + + + + + + + + + + + + Define a CronTrigger + + + + + + + + + + + + + + + Define a DateIntervalTrigger + + + + + + + + + + + + + + + + Cron expression (see JavaDoc for examples) + + Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression! + + Regular expressions are not my strong point but I believe this is complete, + with the caveat that order for expressions like 3-0 is not legal but will pass, + and month and day names must be capitalized. + If you want to examine the correctness look for the [\s] to denote the + seperation of individual regular expressions. This is how I break them up visually + to examine them: + + SECONDS: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + MINUTES: + ( + ((([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?,)*([0-9]|[0-5][0-9])(-([0-9]|[0-5][0-9]))?) + | (([\*]|[0-9]|[0-5][0-9])/([0-9]|[0-5][0-9])) + | ([\?]) + | ([\*]) + ) [\s] + HOURS: + ( + ((([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?,)*([0-9]|[0-1][0-9]|[2][0-3])(-([0-9]|[0-1][0-9]|[2][0-3]))?) + | (([\*]|[0-9]|[0-1][0-9]|[2][0-3])/([0-9]|[0-1][0-9]|[2][0-3])) + | ([\?]) + | ([\*]) + ) [\s] + DAY OF MONTH: + ( + ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?,)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(-([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]))?(C)?) + | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])/([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?) + | (L(-[0-9])?) + | (L(-[1-2][0-9])?) + | (L(-[3][0-1])?) + | (LW) + | ([1-9]W) + | ([1-3][0-9]W) + | ([\?]) + | ([\*]) + )[\s] + MONTH: + ( + ((([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?,)*([1-9]|0[1-9]|1[0-2])(-([1-9]|0[1-9]|1[0-2]))?) + | (([1-9]|0[1-9]|1[0-2])/([1-9]|0[1-9]|1[0-2])) + | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?,)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?) + | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)) + | ([\?]) + | ([\*]) + )[\s] + DAY OF WEEK: + ( + (([1-7](-([1-7]))?,)*([1-7])(-([1-7]))?) + | ([1-7]/([1-7])) + | (((MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?,)*(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?(C)?) + | ((MON|TUE|WED|THU|FRI|SAT|SUN)/(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?) + | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?) + | (([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?) + | ([\?]) + | ([\*]) + ) + YEAR (OPTIONAL): + ( + [\s]? + ([\*])? + | ((19[7-9][0-9])|(20[0-9][0-9]))? + | (((19[7-9][0-9])|(20[0-9][0-9]))/((19[7-9][0-9])|(20[0-9][0-9])))? + | ((((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?,)*((19[7-9][0-9])|(20[0-9][0-9]))(-((19[7-9][0-9])|(20[0-9][0-9])))?)? + ) + + + + + + + + + + Number of times to repeat the Trigger (-1 for indefinite) + + + + + + + + + + Simple Trigger Misfire Instructions + + + + + + + + + + + + + + Cron Trigger Misfire Instructions + + + + + + + + + + + Date Interval Trigger Misfire Instructions + + + + + + + + + + + Interval Units + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/Topshelf.SimpleInjector.Quartz.Test/packages.config b/Tests/Topshelf.SimpleInjector.Quartz.Test/packages.config index 2caeee3..c511852 100644 --- a/Tests/Topshelf.SimpleInjector.Quartz.Test/packages.config +++ b/Tests/Topshelf.SimpleInjector.Quartz.Test/packages.config @@ -1,11 +1,12 @@  + - - - - - - + + + + + + \ No newline at end of file diff --git a/Tests/Topshelf.SimpleInjector.Test/Topshelf.SimpleInjector.Test.csproj b/Tests/Topshelf.SimpleInjector.Test/Topshelf.SimpleInjector.Test.csproj index 1bc13af..001d4da 100644 --- a/Tests/Topshelf.SimpleInjector.Test/Topshelf.SimpleInjector.Test.csproj +++ b/Tests/Topshelf.SimpleInjector.Test/Topshelf.SimpleInjector.Test.csproj @@ -9,9 +9,10 @@ Properties Topshelf.SimpleInjector.Test Topshelf.SimpleInjector.Test - v4.5 + v4.5.2 512 ..\ + true @@ -31,16 +32,14 @@ 4 - - ..\..\packages\NUnit.ApplicationDomain.6.0.0\lib\net40\NUnit.ApplicationDomain.dll - True + + ..\..\packages\NUnit.ApplicationDomain.10.2.0\lib\net40\NUnit.ApplicationDomain.dll - - ..\..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll - - ..\..\packages\SimpleInjector.3.1.2\lib\net45\SimpleInjector.dll + + ..\..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll True @@ -50,9 +49,8 @@ - - ..\..\packages\Topshelf.3.3.1\lib\net40-full\Topshelf.dll - True + + ..\..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll @@ -77,5 +75,4 @@ --> - - + \ No newline at end of file diff --git a/Tests/Topshelf.SimpleInjector.Test/app.config b/Tests/Topshelf.SimpleInjector.Test/app.config index 2151155..80fd105 100644 --- a/Tests/Topshelf.SimpleInjector.Test/app.config +++ b/Tests/Topshelf.SimpleInjector.Test/app.config @@ -4,8 +4,8 @@ - + - \ No newline at end of file + diff --git a/Tests/Topshelf.SimpleInjector.Test/packages.config b/Tests/Topshelf.SimpleInjector.Test/packages.config index b0e8221..1da1865 100644 --- a/Tests/Topshelf.SimpleInjector.Test/packages.config +++ b/Tests/Topshelf.SimpleInjector.Test/packages.config @@ -1,7 +1,7 @@  - - - - + + + + \ No newline at end of file diff --git a/appveyor-release.yml b/appveyor-release.yml index 6b0ef21..ee8854f 100644 --- a/appveyor-release.yml +++ b/appveyor-release.yml @@ -30,9 +30,9 @@ after_test: - cmd: >- mkdir reports - IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER packages\OpenCover.4.6.166\tools\OpenCover.Console.exe -mergeoutput -register:user -excludebyattribute:*.ExcludeFromCodeCoverage*^ -target:"packages\NUnit.Console.3.0.1\tools\nunit3-console.exe" "-targetargs:\"Tests\Topshelf.FileSystemWatcher.Test\bin\%CONFIGURATION%\Topshelf.FileSystemWatcher.Test.dll\" \"Tests\Topshelf.SimpleInjector.Quartz.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Quartz.Test.dll\" \"Tests\Topshelf.SimpleInjector.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Test.dll\"" -filter:"+[*]Topshelf.SimpleInjector.* +[*]Topshelf.FileSystemWatcher.* -[*.Test]*" -output:"reports\OpenCoverCoverage.xml" + IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -mergeoutput -register:user -excludebyattribute:*.ExcludeFromCodeCoverage*^ -target:"packages\NUnit.ConsoleRunner.3.6.1\tools\nunit3-console.exe" "-targetargs:\"Tests\Topshelf.FileSystemWatcher.Test\bin\%CONFIGURATION%\Topshelf.FileSystemWatcher.Test.dll\" \"Tests\Topshelf.SimpleInjector.Quartz.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Quartz.Test.dll\" \"Tests\Topshelf.SimpleInjector.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Test.dll\"" -filter:"+[*]Topshelf.SimpleInjector.* +[*]Topshelf.FileSystemWatcher.* -[*.Test]*" -output:"reports\OpenCoverCoverage.xml" - IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER packages\coveralls.net.0.6.0\tools\csmacnz.Coveralls.exe --opencover -i reports\OpenCoverCoverage.xml --repoToken %COVERALLS_REPO_TOKEN% --commitBranch %APPVEYOR_REPO_BRANCH% + IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER packages\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i reports\OpenCoverCoverage.xml --repoToken %COVERALLS_REPO_TOKEN% --commitBranch %APPVEYOR_REPO_BRANCH% artifacts: - path: '*.nupkg' deploy: @@ -48,4 +48,4 @@ notifications: subject: Build Change AppVeyor on_build_success: true on_build_failure: true - on_build_status_changed: true \ No newline at end of file + on_build_status_changed: true diff --git a/appveyor.yml b/appveyor.yml index 506e567..3324e06 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,12 @@ version: 1.0.0-beta-{build} +pull_requests: + do_not_increment_build_number: true branches: only: - dev + - master skip_tags: true -os: Visual Studio 2015 +image: Visual Studio 2015 configuration: Debug assembly_info: patch: true @@ -21,11 +24,13 @@ build: parallel: true verbosity: normal test: - assemblies: '**\*.Test.dll' + assemblies: + only: + - '**\*.Test.dll' after_test: - cmd: >- mkdir reports - packages\OpenCover.4.6.166\tools\OpenCover.Console.exe -mergeoutput -register:user -excludebyattribute:*.ExcludeFromCodeCoverage*^ -target:"packages\NUnit.Console.3.0.1\tools\nunit3-console.exe" "-targetargs:\"Tests\Topshelf.FileSystemWatcher.Test\bin\%CONFIGURATION%\Topshelf.FileSystemWatcher.Test.dll\" \"Tests\Topshelf.SimpleInjector.Quartz.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Quartz.Test.dll\" \"Tests\Topshelf.SimpleInjector.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Test.dll\"" -filter:"+[*]Topshelf.SimpleInjector.* +[*]Topshelf.FileSystemWatcher.* -[*.Test]*" -output:"reports\OpenCoverCoverage.xml" + packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -mergeoutput -register:user -excludebyattribute:*.ExcludeFromCodeCoverage*^ -target:"packages\NUnit.ConsoleRunner.3.6.1\tools\nunit3-console.exe" "-targetargs:\"Tests\Topshelf.FileSystemWatcher.Test\bin\%CONFIGURATION%\Topshelf.FileSystemWatcher.Test.dll\" \"Tests\Topshelf.SimpleInjector.Quartz.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Quartz.Test.dll\" \"Tests\Topshelf.SimpleInjector.Test\bin\%CONFIGURATION%\Topshelf.SimpleInjector.Test.dll\"" -filter:"+[*]Topshelf.SimpleInjector.* +[*]Topshelf.FileSystemWatcher.* -[*.Test]*" -output:"reports\OpenCoverCoverage.xml" - packages\coveralls.net.0.6.0\tools\csmacnz.Coveralls.exe --opencover -i reports\OpenCoverCoverage.xml --repoToken %COVERALLS_REPO_TOKEN% --commitBranch %APPVEYOR_REPO_BRANCH% \ No newline at end of file + packages\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i reports\OpenCoverCoverage.xml --repoToken %COVERALLS_REPO_TOKEN% --commitBranch %APPVEYOR_REPO_BRANCH%