Skip to content

Add sender in events handlers #9

@E-Mans-Application

Description

@E-Mans-Application

Hello,

I would need to retrieve which EventHandler did fire the events when I handle them.
Could you add a "sender" argument in the event signature in further releases? This only requires a very few changes in the code:

public delegate void FileEventHandler(EventWatcher sender, string name, ulong processId);
    public delegate void MoveEventHandler(EventWatcher sender, string name, string oldName, ulong processId);

 private void DeliverEvent(FileSystemEvent fileEvent, bool postponeDelivery)
        {
            switch (fileEvent.Type)
            {
                case EventType.Change:
                    OnChange?.Invoke(this,fileEvent.Filename, fileEvent.ProcessId);
                    break;
                case EventType.Create:
                    OnCreate?.Invoke(this,fileEvent.Filename, fileEvent.ProcessId);
                    break;
                case EventType.Delete:
                    OnDelete?.Invoke(this,fileEvent.Filename, fileEvent.ProcessId);
                    break;
                case EventType.Move:
                    OnRenameOrMove?.Invoke(this,fileEvent.Filename, ((RenameOrMoveEvent) fileEvent).OldFilename, fileEvent.ProcessId);
                    break;
                default:
                    break;
            }
        }

I made the change by myself for now and I built the library locally, but this prevents me from being synchronized with the NuGet package and from getting the updates.

Also, could you add a public property to indicate which paths are being watched (like the Path property of the standard FileSystemWatcher)? Maybe you could create a list populated when calling WatchPath.
Or, easier, you could create a "Tag" object field to be set manually with the watched path(s) (or any other useful data).

Sincerely,
E__Man.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions