本文整理汇总了C#中Utils.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.Clone方法的具体用法?C# Utils.Clone怎么用?C# Utils.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleRenamed
private void handleRenamed(Utils.LinkedListIterator<FileSystemEventArgs> iterator)
{
Utils.LinkedListIterator<FileSystemEventArgs> innerIterator = iterator.Clone();
while (innerIterator.HasPrevious())
{
FileSystemEventArgs previousChange = innerIterator.Previous();
if (Object.Equals(iterator.Current.FullPath, previousChange.FullPath))
{
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Changed:
handleChanged(innerIterator);
break;
case WatcherChangeTypes.Created:
innerIterator.Current = new FileSystemEventArgs(
WatcherChangeTypes.Created,
Path.GetDirectoryName(iterator.Current.FullPath),
Path.GetFileName(iterator.Current.FullPath));
previousChange = innerIterator.Current;
iterator.Remove();
return;
case WatcherChangeTypes.Deleted:
//ok, the old file with the same name has been deleted
break;
case WatcherChangeTypes.Renamed:
throw new InvalidOperationException();
default:
Logger.Warn("Unattended WatcherChangeTypes:" + iterator.Current.ChangeType);
continue;
}
}
}
}
示例2: handleCreated
private void handleCreated(Utils.LinkedListIterator<FileSystemEventArgs> iterator)
{
Utils.LinkedListIterator<FileSystemEventArgs> innerIterator = iterator.Clone();
while (innerIterator.HasPrevious())
{
FileSystemEventArgs previousChange = innerIterator.Previous();
if (iterator.Current.FullPath.Equals(previousChange.FullPath))
{
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Changed:
Logger.Warn("Found Changed ChangeType before a Created for file '" + iterator.Current.FullPath + "': will be ignored (probably some changes had been lost)");
innerIterator.Remove();
break;
case WatcherChangeTypes.Created:
Logger.Warn("Found duplicated Created ChangeType for file '" + iterator.Current.FullPath + "': will be ignored (probably some changes had been lost)");
break;
case WatcherChangeTypes.Deleted:
iterator.Current = new FileSystemEventArgs(
WatcherChangeTypes.Changed,
Path.GetDirectoryName(iterator.Current.FullPath),
Path.GetFileName(iterator.Current.FullPath));
innerIterator.Remove();
break;
case WatcherChangeTypes.Renamed:
//ok
Logger.Warn("Found Renamed ChangeType before Create for file '" + iterator.Current.FullPath + "': will be ignored (probably some changes had been lost)");
break;
default:
Logger.Warn("Unattended WatcherChangeTypes:" + iterator.Current.ChangeType);
continue;
}
}
else // ! change.FullPath.Equals(previousChange.FullPath)
{
string fileName = System.IO.Path.GetFileName(iterator.Current.FullPath);
string dirPath = System.IO.Path.GetDirectoryName(iterator.Current.FullPath);
string previousName = System.IO.Path.GetFileName(previousChange.FullPath);
string previousDirPath = System.IO.Path.GetDirectoryName(previousChange.FullPath);
if (previousName.Equals(fileName) && !previousDirPath.Equals(dirPath))
{
//Move detected...
iterator.Current = new MovedEventArgs(WatcherChangeTypes.Renamed, previousDirPath, dirPath, fileName);
innerIterator.Remove();
break;
}
}
}
}
示例3: handleDeleted
private void handleDeleted(Utils.LinkedListIterator<FileSystemEventArgs> iterator)
{
Utils.LinkedListIterator<FileSystemEventArgs> innerIterator = iterator.Clone();
while (innerIterator.HasPrevious())
{
FileSystemEventArgs previousChange = innerIterator.Previous();
if (Object.Equals(iterator.Current.FullPath, previousChange.FullPath))
{
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Changed:
innerIterator.Remove();
break;
case WatcherChangeTypes.Created:
innerIterator.Remove();
iterator.Remove();
return;
case WatcherChangeTypes.Deleted:
Logger.Warn("Found duplicated Delete for file '" + iterator.Current.FullPath + "': will be ignored");
innerIterator.Remove();
break;
case WatcherChangeTypes.Renamed:
//check for file swap: first check for another rename between this and the delete
handleFileSwap(innerIterator, iterator);
if (innerIterator.Current != null)
{
handleRenamed(innerIterator);
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Created:
innerIterator.Remove();
iterator.Remove();
return;
case WatcherChangeTypes.Renamed:
innerIterator.Remove();
RenamedEventArgs rename = previousChange as RenamedEventArgs;
iterator.Current = new FileSystemEventArgs(
WatcherChangeTypes.Deleted,
Path.GetDirectoryName(rename.OldFullPath),
Path.GetFileName(rename.OldFullPath));
return;
default:
throw new InvalidOperationException("Unattended change type: " + previousChange.ChangeType);
}
}
break;
default:
Logger.Warn("Unattended WatcherChangeTypes:" + iterator.Current.ChangeType);
continue;
}
}
}
}
示例4: handleChanged
private void handleChanged(Utils.LinkedListIterator<FileSystemEventArgs> iterator)
{
Utils.LinkedListIterator<FileSystemEventArgs> innerIterator = iterator.Clone();
while (innerIterator.HasPrevious())
{
FileSystemEventArgs previousChange = innerIterator.Previous();
//Iterate backwards through the list of changes, find any prior operations on this specific file
if (iterator.Current.FullPath.Equals(previousChange.FullPath))
{
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Changed:
handleChanged(innerIterator);
//now this is the last prior Changed event
//remove it, keep the recent one (node)
if (innerIterator.Current != null)
{
innerIterator.Remove();
}
return;
case WatcherChangeTypes.Created:
handleCreated(innerIterator);
switch (previousChange.ChangeType)
{
case WatcherChangeTypes.Changed:
innerIterator.Remove();
break;
case WatcherChangeTypes.Created:
iterator.Remove();
return;
default:
throw new InvalidOperationException("Unattended change type: " + previousChange.ChangeType);
}
return;
case WatcherChangeTypes.Deleted:
Logger.Warn("Found Deleted ChangeType before a Changed widouth a Create for file '" + iterator.Current.FullPath + "': will be ignored (probably the Created has been lost)");
innerIterator.Remove();
break;
case WatcherChangeTypes.Renamed:
//FullPath is the newPath of the renamed file.
//keep the event
break;
default:
Logger.Warn("Unattended WatcherChangeTypes:" + iterator.Current.ChangeType);
continue;
}
}
}
}