private static IEnumerable <IFileSystemInfo> GetFiles(string path, IDepth depth, IFileSystemDirectory parent, IMessenger messenger, ILoggingService log) { var result = new List <IFileSystemInfo>(); try { var files = Directory.GetFiles(path) .Select(p => new FileInfo(p)) .Where(p => !p.Attributes.HasFlag(FileAttributes.Directory) && !p.Attributes.HasFlag(FileAttributes.Hidden) && !p.Attributes.HasFlag(FileAttributes.System) && !p.Attributes.HasFlag(FileAttributes.Offline) && !p.Attributes.HasFlag(FileAttributes.Encrypted)) .Select(p => new MapleFile(p, depth, parent, messenger)) .ToList(); result.AddRange(files); } catch (UnauthorizedAccessException ex) { Debug.WriteLine($"{nameof(UnauthorizedAccessException)} occured during reading off {path}"); Debug.WriteLine(ex.Message); log.Error(ex); } return(result); }
protected MapleFileSystemBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent) : this() { if (string.IsNullOrEmpty(name)) { throw new ArgumentException($"{nameof(Name)} can't be empty.", nameof(Name)); } if (string.IsNullOrEmpty(fullName)) { throw new ArgumentException($"{nameof(FullName)} can't be empty.", nameof(FullName)); } if (depth == null) { throw new ArgumentException($"{nameof(Depth)} can't be empty.", nameof(Depth)); } if (!(this is IFileSystemDrive) && parent == null) { throw new ArgumentException($"{nameof(Parent)} can't be empty.", nameof(Parent)); } using (_busyStack.GetToken()) { Depth = depth; Depth.Current++; Name = name; FullName = fullName; Parent = parent; } }
private static List <IFileSystemInfo> GetDirectories(string path, IDepth depth, IFileSystemDirectory parent) { var result = new List <IFileSystemInfo>(); try { var directories = Directory.GetDirectories(path) .Select(p => new DirectoryInfo(p)) .Where(p => p.Attributes.HasFlag(FileAttributes.Directory) && !p.Attributes.HasFlag(FileAttributes.Hidden) && !p.Attributes.HasFlag(FileAttributes.System) && !p.Attributes.HasFlag(FileAttributes.Offline) && !p.Attributes.HasFlag(FileAttributes.Encrypted)) .Select(p => new MapleDirectory(p, depth, parent)) .ToList(); result.AddRange(directories); } catch (UnauthorizedAccessException ex) { Debug.WriteLine($"{nameof(UnauthorizedAccessException)} occured during reading off {path}"); Debug.WriteLine(ex.Message); } return(result); }
protected MapleFileSystemBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent, IMessenger messenger) : this(messenger) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), $"{nameof(name)} {Resources.IsRequired}"); } if (string.IsNullOrEmpty(fullName)) { throw new ArgumentNullException(nameof(fullName), $"{nameof(fullName)} {Resources.IsRequired}"); } if (depth == null) { throw new ArgumentNullException(nameof(depth), $"{nameof(depth)} {Resources.IsRequired}"); } if (!(this is IFileSystemDrive) && parent == null) { throw new ArgumentNullException(nameof(parent), $"{nameof(parent)} {Resources.IsRequired}"); } using (BusyStack.GetToken()) { Depth = depth; Depth.Current++; Name = name; FullName = fullName; Parent = parent; } }
public HomeController(ISize sizeService, IDepth depthService, ITopping toppingService, IPizza pizzaService, IPizzaTopping pizzaToppingService) { _sizeService = sizeService; _depthService = depthService; _toppingService = toppingService; _pizzaService = pizzaService; _pizzaToppingService = pizzaToppingService; }
private void button2_Click(object sender, EventArgs e) ///increses depth { if (listOfAdded.SelectedItem is IDepth) { IDepth dept = (IDepth)listOfAdded.SelectedItem; depthBox.Text = dept.Deeper().ToString(); } }
public MapleDirectory(DirectoryInfo info, IDepth depth, IFileSystemDirectory parent) : base(info.Name, info.FullName, depth, parent) { using (_busyStack.GetToken()) { if (!Depth.IsMaxReached) { Refresh(); } } }
/// <summary> /// Initializes a new instance of the <see cref="MapleDrive"/> class. /// </summary> /// <param name="info">The information.</param> /// <param name="depth">The depth.</param> /// <autogeneratedoc /> public MapleDrive(DriveInfo info, IDepth depth) : base(info.Name, info.Name, depth, null) { using (_busyStack.GetToken()) { if (!Depth.IsMaxReached) { Refresh(); } } }
/// <summary> /// Initializes a new instance of the <see cref="MapleDrive"/> class. /// </summary> /// <param name="info">The information.</param> /// <param name="depth">The depth.</param> /// <autogeneratedoc /> public MapleDrive(DriveInfo info, IDepth depth, IMessenger messenger, ILoggingService loggingService) : base(info.Name, info.Name, depth, null, messenger, loggingService) { using (BusyStack.GetToken()) { if (!Depth.IsMaxReached) { Refresh(); } } }
public MapleDirectory(DirectoryInfo info, IDepth depth, IFileSystemDirectory parent, IMessenger messenger, ILoggingService loggingService) : base(info.Name, info.FullName, depth, parent, messenger, loggingService) { using (BusyStack.GetToken()) { if (!Depth.IsMaxReached) { Refresh(); } } }
public MapleFile(FileInfo info, IDepth depth, IFileSystemDirectory parent, IMessenger messenger) : base(info.Name, info.FullName, depth, parent, messenger) { using (BusyStack.GetToken()) { if (!Depth.IsMaxReached) { Refresh(); IsExpanded = true; } } }
protected MapleFileSystemContainerBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent) : base(name, fullName, depth, parent) { using (_busyStack.GetToken()) { IsContainer = true; Children = new RangeObservableCollection <IFileSystemInfo>(); NoFilesCollectionView = CollectionViewSource.GetDefaultView(Children); DefaultCollectionView = CollectionViewSource.GetDefaultView(Children); using (NoFilesCollectionView.DeferRefresh()) NoFilesCollectionView.Filter = NoFilesFilter; using (DefaultCollectionView.DeferRefresh()) DefaultCollectionView.Filter = SearchFilter; } }
private void listOfAdded_SelectedIndexChanged(object sender, EventArgs e) { riseBox.Enabled = false; heightBox.Clear(); accBox.Enabled = false; speedBx.Clear(); deepBox.Enabled = false; depthBox.Clear(); if (listOfAdded.SelectedItem is IAccelerate) { accBox.Enabled = true; heightBox.Clear(); depthBox.Clear(); IAccelerate sped = (IAccelerate)listOfAdded.SelectedItem; speedBx.Text = sped.getSpeed().ToString(); } if (listOfAdded.SelectedItem is IDepth) { deepBox.Enabled = true; heightBox.Clear(); IDepth depf = (IDepth)listOfAdded.SelectedItem; depthBox.Text = depf.getDepth().ToString(); } if (listOfAdded.SelectedItem is IHeight) { riseBox.Enabled = true; depthBox.Clear(); IHeight hajt = (IHeight)listOfAdded.SelectedItem; heightBox.Text = hajt.getHeight().ToString(); } }
protected MapleFileSystemContainerBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent, IMessenger messenger, ILoggingService loggingService) : base(name, fullName, depth, parent, messenger) { using (BusyStack.GetToken()) { IsContainer = true; Children = new RangeObservableCollection <IFileSystemInfo>(); NoFilesCollectionView = CollectionViewSource.GetDefaultView(Children); DefaultCollectionView = CollectionViewSource.GetDefaultView(Children); using (NoFilesCollectionView.DeferRefresh()) NoFilesCollectionView.Filter = NoFilesFilter; using (DefaultCollectionView.DeferRefresh()) DefaultCollectionView.Filter = SearchFilter; _loggingService = loggingService ?? throw new ArgumentNullException(nameof(loggingService), $"{nameof(loggingService)} {Resources.IsRequired}"); } }
public static IEnumerable <IFileSystemInfo> GetChildren(this MapleFileSystemContainerBase directory, IDepth depth, IMessenger messenger, ILoggingService log) { var result = new List <IFileSystemInfo>(); if (!CanAccess(directory.FullName, log) && directory.DirectoryIsEmpty()) { return(result); } result.AddRange(GetDirectories(directory.FullName, depth, directory, messenger, log)); result.AddRange(GetFiles(directory.FullName, depth, directory, messenger, log)); return(result); }
public static List <IFileSystemInfo> GetChildren(this MapleFileSystemContainerBase directory, IDepth depth) { var result = new List <IFileSystemInfo>(); if (!CanAccess(directory.FullName) && directory.DirectoryIsEmpty()) { return(result); } result.AddRange(GetDirectories(directory.FullName, depth, directory)); result.AddRange(GetFiles(directory.FullName, depth, directory)); return(result); }