예제 #1
0
        /// <summary>
        /// Determines whether the other FileWatchEvent is a duplicate to the current FileWatchEvent.
        /// </summary>
        /// <param name="other">The other FileWatchEvent, to compare with the current FileWatchEvent.</param>
        /// <returns>True, if the other FileWatchEvent is a duplicate. False, if not.</returns>
        public virtual bool IsDuplicate(FileWatchEvent other)
        {
            // This is not null, but is other null?
            if (other == null)
            {
                return(false);
            }
            // Are the affected paths the same?
            if (_path != other._path)
            {
                return(false);
            }
            if (_oldPath != other._oldPath)
            {
                return(false);
            }
            // Figure out which event was created first.
            FileWatchEvent firstEvent;
            FileWatchEvent lastEvent;

            if (_eventMoment < other._eventMoment)
            {
                firstEvent = this;
                lastEvent  = other;
            }
            else
            {
                firstEvent = other;
                lastEvent  = this;
            }
            // Now we know that the paths are the same.
            // Lets check if the file is growing/shrinking? If true, make sure to delay both events again.
            if (firstEvent._fileSize != lastEvent._fileSize)
            {
                // If the filesize is not the same, delay the events again.
                firstEvent._delayed = lastEvent._delayed = false;
                // Update the filesize to avoid an endless delay.
                firstEvent._fileSize = lastEvent._fileSize = GetFileSize(firstEvent._path);
            }
            // Are the types the same,
            // OR could the last event be a Changed-event caused by a the first event, which is a Created-event?
            if (firstEvent._type == lastEvent._type ||
                (firstEvent._type == FileWatchChangeType.Created && lastEvent._type == FileWatchChangeType.Changed))
            {
                // The events are a duplicate.
                return(true);
            }
            // Both events are different.
            return(false);
        }
 public FileWatchEventArgs(FileWatchEvent fileWatchEvent)
     : this(fileWatchEvent.ChangeType, fileWatchEvent.Path, fileWatchEvent.OldPath)
 {
 }
예제 #3
0
 public FileWatchEventArgs(FileWatchEvent fileWatchEvent)
   : this(fileWatchEvent.ChangeType, fileWatchEvent.Path, fileWatchEvent.OldPath)
 {
 }
예제 #4
0
 /// <summary>
 /// Determines whether the other FileWatchEvent is a duplicate to the current FileWatchEvent.
 /// </summary>
 /// <param name="other">The other FileWatchEvent, to compare with the current FileWatchEvent.</param>
 /// <returns>True, if the other FileWatchEvent is a duplicate. False, if not.</returns>
 public virtual bool IsDuplicate(FileWatchEvent other)
 {
   // This is not null, but is other null?
   if (other == null)
     return false;
   // Are the affected paths the same?
   if (_path != other._path)
     return false;
   if (_oldPath != other._oldPath)
     return false;
   // Figure out which event was created first.
   FileWatchEvent firstEvent;
   FileWatchEvent lastEvent;
   if (_eventMoment < other._eventMoment)
   {
     firstEvent = this;
     lastEvent = other;
   }
   else
   {
     firstEvent = other;
     lastEvent = this;
   }
   // Now we know that the paths are the same.
   // Lets check if the file is growing/shrinking? If true, make sure to delay both events again.
   if (firstEvent._fileSize != lastEvent._fileSize)
   {
     // If the filesize is not the same, delay the events again.
     firstEvent._delayed = lastEvent._delayed = false;
     // Update the filesize to avoid an endless delay.
     firstEvent._fileSize = lastEvent._fileSize = GetFileSize(firstEvent._path);
   }
   // Are the types the same,
   // OR could the last event be a Changed-event caused by a the first event, which is a Created-event?
   if (firstEvent._type == lastEvent._type
       || (firstEvent._type == FileWatchChangeType.Created && lastEvent._type == FileWatchChangeType.Changed))
   {
     // The events are a duplicate.
     return true;
   }
   // Both events are different.
   return false;
 }