public DirectoryViewModel(DirectoryInfo directoryInfo, IDirectoryViewModel parent) : base(new NativeFileInfo(directoryInfo.FullName, true), parent) { _directoryInfo = directoryInfo; var directoryProvider = new SubDirectoriesProvider(_directoryInfo, this); Path = Environment.ExpandEnvironmentVariables(_directoryInfo.FullName); DisplayName = _directoryInfo.Name; if (Parent != null) { VisualPath = Parent.VisualPath + "\\" + DisplayName; } Files = new AsyncLoadCollection <ISystemObjectViewModel>(new FilesProvider(directoryInfo, this)); SubDirectories = new AsyncLoadCollection <IDirectoryViewModel>(directoryProvider); Children = new UnionCollectionEx <IDirectoryViewModel, ISystemObjectViewModel, ISystemObjectViewModel>(SubDirectories, Files); LastModificationDate = _directoryInfo.LastWriteTime; try { UpdateHasItems(); } catch (UnauthorizedAccessException ex) { NoAccess = true; } }
public RootDirectoryViewModel(NativeDirectoryInfo nativeDirectoryInfo, IDirectoryViewModel parent) : base(nativeDirectoryInfo, parent) { NativeSystemInfo = nativeDirectoryInfo; var directoryUnfo = new DirectoryInfo(nativeDirectoryInfo.Path); var subDirectoryProvider = new SubDirectoriesProvider(directoryUnfo, this); var filesProvider = new FilesProvider(directoryUnfo,this); DisplayName = nativeDirectoryInfo.DisplayName; Path = nativeDirectoryInfo.Path; VisualPath = Parent.VisualPath + "\\" + DisplayName; //is drive? DriveInfo driveInfo = Drives.FirstOrDefault(info => PathHelper.NormalizePath(info.Name) == PathHelper.NormalizePath(Path)); HasItems = driveInfo?.IsReady ?? directoryUnfo.EnumerateDirectories().Any(); SubDirectories = new AsyncLoadCollection<IDirectoryViewModel>(subDirectoryProvider); SubDirectories.CollectionChanged += _subDirectories_CollectionChanged; Files = new AsyncLoadCollection<ISystemObjectViewModel>(filesProvider); Children = new UnionCollectionEx<IDirectoryViewModel, ISystemObjectViewModel, ISystemObjectViewModel>(SubDirectories, Files); }
public RootDirectoryViewModel(NativeDirectoryInfo nativeDirectoryInfo, IDirectoryViewModel parent) : base(nativeDirectoryInfo, parent) { NativeSystemInfo = nativeDirectoryInfo; var directoryUnfo = new DirectoryInfo(nativeDirectoryInfo.Path); var subDirectoryProvider = new SubDirectoriesProvider(directoryUnfo, this); var filesProvider = new FilesProvider(directoryUnfo, this); DisplayName = nativeDirectoryInfo.DisplayName; Path = nativeDirectoryInfo.Path; VisualPath = Parent.VisualPath + "\\" + DisplayName; //is drive? DriveInfo driveInfo = Drives.FirstOrDefault(info => PathHelper.NormalizePath(info.Name) == PathHelper.NormalizePath(Path)); HasItems = driveInfo?.IsReady ?? directoryUnfo.EnumerateDirectories().Any(); SubDirectories = new AsyncLoadCollection <IDirectoryViewModel>(subDirectoryProvider); SubDirectories.CollectionChanged += _subDirectories_CollectionChanged; Files = new AsyncLoadCollection <ISystemObjectViewModel>(filesProvider); Children = new UnionCollectionEx <IDirectoryViewModel, ISystemObjectViewModel, ISystemObjectViewModel>(SubDirectories, Files); }
public DirectoryViewModel(DirectoryInfo directoryInfo, IDirectoryViewModel parent) : base(new NativeFileInfo(directoryInfo.FullName,true), parent) { _directoryInfo = directoryInfo; var directoryProvider = new SubDirectoriesProvider(_directoryInfo, this); Path = Environment.ExpandEnvironmentVariables(_directoryInfo.FullName); DisplayName = _directoryInfo.Name; if (Parent != null) VisualPath = Parent.VisualPath + "\\" + DisplayName; Files = new AsyncLoadCollection<ISystemObjectViewModel>(new FilesProvider(directoryInfo,this)); SubDirectories = new AsyncLoadCollection<IDirectoryViewModel>(directoryProvider); Children = new UnionCollectionEx<IDirectoryViewModel, ISystemObjectViewModel, ISystemObjectViewModel>(SubDirectories, Files); LastModificationDate = _directoryInfo.LastWriteTime; try { UpdateHasItems(); } catch (UnauthorizedAccessException ex) { NoAccess = true; } }