/// <summary>
        /// Tests various aspects of an unordered set.
        /// </summary>
        /// <typeparam name="T">The type of element stored in the set.</typeparam>
        /// <param name="emptySet">The empty set.</param>
        /// <param name="value">A value that could be placed in the set.</param>
        /// <param name="comparer">The comparer used to obtain the empty set, if any.</param>
        private static void EmptyTestHelper <T>(System.Collections.Immutable.IImmutableSet <T> emptySet, T value, IEqualityComparer <T>?comparer)
        {
            Assert.NotNull(emptySet);

            EmptyTestHelper(emptySet);
            Assert.True(IsSame(emptySet, emptySet.ToImmutableSegmentedHashSet(comparer)));
            Assert.Same(comparer ?? EqualityComparer <T> .Default, GetEqualityComparer(emptySet));

            if (comparer == null)
            {
                Assert.True(IsSame(emptySet, ImmutableSegmentedHashSet <T> .Empty));
            }

            var reemptied = emptySet.Add(value).Clear();

            Assert.True(IsSame(reemptied, reemptied.ToImmutableSegmentedHashSet(comparer))); //, "Getting the empty set from a non-empty instance did not preserve the comparer.");
        }
        public Process(Configuration.MonitorElement configuration, System.Action <System.String> log) : base()
        {
            if (null == configuration)
            {
                throw new System.ArgumentNullException("configuration");
            }
            myLog = log;
            this.DestinationPath = configuration.Destination;
            this.Interval        = configuration.Interval * 1000;
            myTimer             = new System.Threading.Timer(this.OnAlarm, this, -1, 0);
            myFilePathName      = System.Collections.Immutable.ImmutableHashSet <System.String> .Empty;
            myState             = 0;
            myFileSystemWatcher = System.Collections.Immutable.ImmutableHashSet <System.IO.FileSystemWatcher> .Empty;
            var exec = configuration.Execute;

            if (null != exec)
            {
                this.Arguments        = exec.Arguments;
                this.PathName         = exec.Executable;
                this.WorkingDirectory = exec.WorkingDirectory;
            }
            System.IO.FileSystemWatcher fsw;
            foreach (var path in configuration.Paths.OfType <Configuration.PathElement>())
            {
                foreach (var filter  in path.Filters.OfType <Configuration.FilterElement>())
                {
                    try {
                        fsw = new System.IO.FileSystemWatcher(System.Environment.ExpandEnvironmentVariables(path.Path), System.Environment.ExpandEnvironmentVariables(filter.Filter));
                    } catch (System.Exception e) {
                        myLog(System.String.Format("Exception: {0}\r\n{1}\r\nStack Trace follows:\r\n{2}", e.GetType().ToString(), e.Message, e.StackTrace));
                        throw;
                    }
                    fsw.IncludeSubdirectories = false;
                    fsw.Created        += this.OnCreated;
                    fsw.Renamed        += this.OnRename;
                    fsw.Deleted        += this.OnDeleted;
                    fsw.NotifyFilter    = (System.IO.NotifyFilters.CreationTime | System.IO.NotifyFilters.FileName | System.IO.NotifyFilters.LastWrite | System.IO.NotifyFilters.Size);
                    myFileSystemWatcher = myFileSystemWatcher.Add(fsw);
                }
            }
        }
Beispiel #3
0
        private static void AddRemoveLoadTestHelper <T>(System.Collections.Immutable.IImmutableSet <T> set, T[] data)
        {
            Assert.NotNull(set);
            Assert.NotNull(data);

            foreach (T value in data)
            {
                var newSet = set.Add(value);
                Assert.NotSame(set, newSet);
                set = newSet;
            }

            foreach (T value in data)
            {
                Assert.True(set.Contains(value));
            }

            foreach (T value in data)
            {
                var newSet = set.Remove(value);
                Assert.NotSame(set, newSet);
                set = newSet;
            }
        }
 private void AddFileToList(System.String file)
 {
     System.Collections.Immutable.IImmutableSet <System.String> res;
     System.Collections.Immutable.IImmutableSet <System.String> original;
     while (!myFilePathName.Contains(file))
     {
         do
         {
             original = myFilePathName;
             res      = System.Threading.Interlocked.CompareExchange <System.Collections.Immutable.IImmutableSet <System.String> >(ref myFilePathName, myFilePathName.Add(file), original);
         } while (!myFilePathName.Contains(file));
     }
 }