Ejemplo n.º 1
0
        public AreaDto GetArea(string directory)
        {
            AreaDto area   = null;
            bool    isPath = directory.Contains(Path.DirectorySeparatorChar);
            string  path   = isPath ? directory : PathUtils.FinalizePath(DirectoryPath + directory);

            if (!Directory.Exists(path))
            {
                return(null);
            }
            string directoryName = isPath ? Path.GetFileName(directory) : directory;

            if (Areas.ContainsKey(directoryName))
            {
                area = Areas[directoryName];
            }
            if (area == null)
            {
                area = AreaProcessor.BuildDto(path);
            }
            area.Type = Type;
            AreaProcessor.RefreshDto(area);
            Areas[area.Directory] = area;
            return(area);
        }
Ejemplo n.º 2
0
        protected virtual void RefreshAreas()
        {
            Stopwatch w = new();

            w.Start();
            foreach (var path in Directory.GetDirectories(DirectoryPath))
            {
                if (cancelRefresh != null && cancelRefresh.Token.IsCancellationRequested)
                {
                    Debug.WriteLine("====================================================");
                    Debug.WriteLine(String.Format("Refresh Areas canceled: {0}, after: {1} ms", Type, w.ElapsedMilliseconds));
                    cancelRefresh.Token.ThrowIfCancellationRequested();
                }
                AreaDto Area = AreaProcessor.BuildDto(path);
                if (Areas.TryGetValue(Area.Directory, out var existingArea) && existingArea != null)
                {
                    Area = existingArea;
                }
                Area.Type = Type;
                AreaProcessor.RefreshDto(Area);
                Areas[Area.Directory] = Area;
            }
            Debug.WriteLine("====================================================");
            Debug.WriteLine(String.Format("Refresh Areas complete: {0}, after: {1} ms", Type, w.ElapsedMilliseconds));
            InvokeDataChanged();
            cancelRefresh = null;
        }