public void PopulateItem(Type type) { var assemblyName = type.Assembly.GetName().Name; TreeListItem attachPoint = RootItem.FindItemByName(assemblyName); if (attachPoint == null) { attachPoint = RootItem.AddItem(assemblyName, false, true, new SystemTypeTreeInfo(assemblyName)); AddHandlerEvents(attachPoint); } var namespaces = type.Namespace.Split('.'); foreach (var ns in namespaces) { var next = attachPoint.FindItemByName(ns); if (next == null) { attachPoint = attachPoint.AddItem(ns, false, false, new SystemTypeTreeInfo(ns)); AddHandlerEvents(attachPoint); } else { attachPoint = next; } } var t = attachPoint.AddItem(type.Name, true, false, new SystemTypeTreeInfo(type)); AddHandlerEvents(t); }
/// <summary>Runs the actual scan on any number of root paths.</summary> /// /// <param name="rootPaths">The root paths to scan.</param> /// <param name="token">The token for cleanly cancelling the operations.</param> protected void Scan(string[] rootPaths, CancellationToken token) { // See if we can perform a single scan if (rootPaths.Length == 1) { Scan(rootPaths[0], token); return; } scanningStates = rootPaths.Select(p => CreateState(p, false)).ToList(); CanDisplayProgress = !scanningStates.Any(s => !s.IsDrive); TotalSize = scanningStates.Sum(s => s.TotalSize); TotalFreeSpace = scanningStates.Sum(s => s.FreeSpace); // Computer Root RootItem computerRoot = new RootItem(this); foreach (ScanningState state in scanningStates) { computerRoot.AddItem(state.Root); } RootItem = computerRoot; ProgressState = ScanProgressState.Started; // Master file tables cannot be scanned inline, so scan them one at a time first for (int i = 0; i < scanningStates.Count; i++) { ScanningState state = scanningStates[i]; try { ScanMtf(state, token); scanningStates.RemoveAt(i--); } catch (Exception) { // We don't have permission, are not elevated, or path is not an NTFS drive // We'll scan this path normally instead } } // Are there any leftover states to work on? if (scanningStates.Any()) { ScanNative(token); } FinishScan(token); }