本文整理汇总了C#中Wrapper.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Wrapper.ToString方法的具体用法?C# Wrapper.ToString怎么用?C# Wrapper.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wrapper
的用法示例。
在下文中一共展示了Wrapper.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScanDirectories
//.........这里部分代码省略.........
Func<FileSystemInfo, bool> isHidden =
fsi => (fsi.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
using (var dialog = new SledAsyncTaskForm())
{
const string scanning = "Scanning for files and folders...";
// This task runs in a separate thread so make sure to avoid
// cross-thread LINQ queries or exceptions get thrown
Func<SledUtil.BoolWrapper, bool> asyncTask =
cancel =>
{
Func<FileInfo, bool> filePredicate = fi => !isHidden(fi);
Func<DirectoryInfo, bool> dirPredicate =
di =>
{
// Sometimes the root directory can show up
// as hidden... depending on what path is
// passed into the DirectoryInfo upon creation
if (di.Parent == null)
return true;
var hidden = isHidden(di);
// ReSharper disable AccessToDisposedClosure
if (!hidden)
dialog.Label = string.Format("{0} ({1})", scanning, di.Name);
// ReSharper restore AccessToDisposedClosure
return !hidden;
};
foreach (var di in localDirectories)
{
try
{
// Gather files and folders recursively from the directory
var tree = di.GetFilesAndDirectoriesTree(SearchOption.AllDirectories, filePredicate, dirPredicate, cancel);
if (tree == null)
continue;
localMappings.Add(di, tree);
}
catch (Exception ex)
{
SledOutDevice.OutLine(
SledMessageType.Error,
"{0}: Exception enumerating directory \"{1}\": {2}",
this, di.FullName, ex.Message);
}
}
return true;
};
dialog.Task = asyncTask;
dialog.Text = string.Format("SLED - {0}", scanning);
dialog.Label = scanning;
// 'DialogResult.Yes' means task ran to completion and returned 'true'
if (dialog.ShowDialog(this) != DialogResult.Yes)
return;
var newWrappers = new List<Wrapper>();
foreach (var kv in localMappings)
{
var wrapper = new Wrapper(kv.Key, kv.Value);
newWrappers.Add(wrapper);
m_wrappers.Add(wrapper);
m_lstDirUsed.Items.Add(wrapper);
}
try
{
m_treeCheckedFiles.BeginUpdate();
foreach (var wrapper in newWrappers)
{
var rootDirNode =
new TreeNode(wrapper.ToString())
{
Tag = wrapper.FilesAndFolders.Value,
ToolTipText = wrapper.FilesAndFolders.Value.FullName
};
m_treeCheckedFiles.Nodes.Add(rootDirNode);
m_wrapperRootNodes.Add(wrapper, rootDirNode);
AddFilesAndFoldersToRoot(rootDirNode, wrapper.FilesAndFolders);
rootDirNode.ImageIndex = s_folderImageIdx;
rootDirNode.SelectedImageIndex = rootDirNode.ImageIndex;
}
}
finally
{
m_treeCheckedFiles.EndUpdate();
}
}
}