Пример #1
0
        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);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
 public HomeController(ISize sizeService, IDepth depthService, ITopping toppingService, IPizza pizzaService, IPizzaTopping pizzaToppingService)
 {
     _sizeService         = sizeService;
     _depthService        = depthService;
     _toppingService      = toppingService;
     _pizzaService        = pizzaService;
     _pizzaToppingService = pizzaToppingService;
 }
Пример #6
0
 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();
     }
 }
Пример #7
0
 public MapleDirectory(DirectoryInfo info, IDepth depth, IFileSystemDirectory parent) : base(info.Name, info.FullName, depth, parent)
 {
     using (_busyStack.GetToken())
     {
         if (!Depth.IsMaxReached)
         {
             Refresh();
         }
     }
 }
Пример #8
0
 /// <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();
         }
     }
 }
Пример #9
0
 /// <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();
         }
     }
 }
Пример #10
0
 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();
         }
     }
 }
Пример #11
0
 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;
         }
     }
 }
Пример #12
0
        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;
            }
        }
Пример #13
0
        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();
            }
        }
Пример #14
0
        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}");
            }
        }
Пример #15
0
        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);
        }
Пример #16
0
        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);
        }