Example #1
0
        public void TestFolderDataSourceFactory()
        {
            IDataSourceFactory factory = this.Factories.Single(x => x.GetType() == typeof(FolderDataSourceFactory));
            Dictionary <IConfigurationRequirement, object> inputs =
                factory
                .Requirements
                .Select(
                    requirement =>
            {
                Console.Write(requirement.Name + " - (" + requirement.Description + "): ");
                string input = Console.ReadLine();
                if (input == "null")
                {
                    input = null;
                }

                return(new KeyValuePair <IConfigurationRequirement, object>(requirement, input));
            })
                .ToDictionary(x => x.Key, x => x.Value);

            IConfigurationRequirement rootRequirement = factory.Requirements.Single(x => x.Name == "Root Path");

            inputs[rootRequirement] = new FilePath((string)inputs[rootRequirement]);
            IConfigurationRequirement tickRequirement =
                factory.Requirements.Single(x => x.Name == "Change Filter Ticks");

            inputs[tickRequirement] = inputs[tickRequirement] ==
                                      null ? 0L : long.Parse((string)inputs[tickRequirement]);

            IDataSource dataSource = factory.MakeDataSource(inputs);

            dataSource.OnChange +=
                (obj, e) =>
            {
                DataSourceChangeEventType type        = e.EventType;
                IDataInformation          information = e.GetImageInformation();
                if (type == DataSourceChangeEventType.Added)
                {
                    Console.WriteLine("Added: " + information.Name);
                }
                else if (type == DataSourceChangeEventType.Changed)
                {
                    Console.WriteLine("Changed: " + information.Name);
                }
                else if (type == DataSourceChangeEventType.Removed)
                {
                    Console.WriteLine("Removed: " + information.Name);
                }
                else
                {
                    throw new InvalidOperationException("Unexpected DataSourceChangeEventType value.");
                }
            };

            Console.WriteLine("Monitoring folder '" + dataSource.Name + "'. Press enter to stop.");
            Console.ReadLine();

            dataSource.Dispose();
        }
Example #2
0
 public MockFolderDataChangeEventArgs(
     FilePath path,
     DataSourceChangeEventType type,
     IDataInformation information)
 {
     this.Path        = path;
     this.EventType   = type;
     this.information = information;
 }
Example #3
0
 public MockDataSourceChangeEventArgs(MockData change, DataSourceChangeEventType eventType)
 {
     this.change    = data;
     this.EventType = eventType;
 }