Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -375,60 +375,54 @@ namespace System.IO {
ErrorEvent,
RenameEvent
}
protected void OnChanged (FileSystemEventArgs e)
private void RaiseEvent (Delegate ev, EventArgs arg, EventType evtype)
{
if (Changed == null)
if (ev == null)
return;
if (synchronizingObject == null)
Changed (this, e);
else
synchronizingObject.BeginInvoke (Changed, new object[] { this, e });
if (synchronizingObject == null) {
foreach (var target in ev.GetInvocationList()) {
switch (evtype) {
case EventType.RenameEvent:
((RenamedEventHandler)target).BeginInvoke (this, (RenamedEventArgs)arg, null, null);
break;
case EventType.ErrorEvent:
((ErrorEventHandler)target).BeginInvoke (this, (ErrorEventArgs)arg, null, null);
break;
case EventType.FileSystemEvent:
((FileSystemEventHandler)target).BeginInvoke (this, (FileSystemEventArgs)arg, null, null);
break;
}
}
return;
}
synchronizingObject.BeginInvoke (ev, new object [] {this, arg});
}
protected void OnChanged (FileSystemEventArgs e)
{
RaiseEvent (Changed, e, EventType.FileSystemEvent);
}
protected void OnCreated (FileSystemEventArgs e)
{
if (Created == null)
return;
if (synchronizingObject == null)
Created (this, e);
else
synchronizingObject.BeginInvoke (Created, new object[] { this, e });
RaiseEvent (Created, e, EventType.FileSystemEvent);
}
protected void OnDeleted (FileSystemEventArgs e)
{
if (Deleted == null)
return;
if (synchronizingObject == null)
Deleted (this, e);
else
synchronizingObject.BeginInvoke (Deleted, new object[] { this, e });
RaiseEvent (Deleted, e, EventType.FileSystemEvent);
}
internal void OnError (ErrorEventArgs e)
protected void OnError (ErrorEventArgs e)
{
if (Error == null)
return;
if (synchronizingObject == null)
Error (this, e);
else
synchronizingObject.BeginInvoke (Error, new object[] { this, e });
RaiseEvent (Error, e, EventType.ErrorEvent);
}
protected void OnRenamed (RenamedEventArgs e)
{
if (Renamed == null)
return;
if (synchronizingObject == null)
Renamed (this, e);
else
synchronizingObject.BeginInvoke (Renamed, new object[] { this, e });
RaiseEvent (Renamed, e, EventType.RenameEvent);
}
public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType)
@ -458,6 +452,11 @@ namespace System.IO {
return result;
}
internal void DispatchErrorEvents (ErrorEventArgs args)
{
OnError (args);
}
internal void DispatchEvents (FileAction act, string filename, ref RenamedEventArgs renamed)
{
if (waiting) {