当前位置: 首页>>代码示例>>C#>>正文


C# Wrapper.ToString方法代码示例

本文整理汇总了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();
                }
            }
        }
开发者ID:arsaccol,项目名称:SLED,代码行数:101,代码来源:SledProjectAutoFilesAddForm.cs


注:本文中的Wrapper.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。