Esempio n. 1
0
        public static void HandleDrop(Store store, string filename)
        {
            if (store == null || filename == null)
            {
                return;
            }

            try
            {
                StatusDisplay.Show($"Reading {filename}");

                AssemblyProcessor assemblyProcessor = new AssemblyProcessor(store);
                TextFileProcessor textFileProcessor = new TextFileProcessor(store);
                textFileProcessor.LoadCache(filename);

                Process(store, filename, assemblyProcessor, textFileProcessor);
            }
            catch (Exception e)
            {
                ErrorDisplay.Show(e.Message);
            }
            finally
            {
                StatusDisplay.Show(string.Empty);
            }
        }
Esempio n. 2
0
        public static IEnumerable <ModelElement> HandleMultiDrop(Store store, IEnumerable <string> filenames)
        {
            List <ModelElement> newElements  = new List <ModelElement>();
            List <string>       filenameList = filenames?.ToList();

            if (store == null || filenameList == null)
            {
                return(newElements);
            }

            try
            {
                StatusDisplay.Show($"Processing {filenameList.Count} files");

                AssemblyProcessor assemblyProcessor = new AssemblyProcessor(store);
                TextFileProcessor textFileProcessor = new TextFileProcessor(store);

                try
                {
                    // may not work. Might not be a text file
                    textFileProcessor.LoadCache(filenameList);
                }
                catch
                {
                    // if not, no big deal. Either it's not a text file, or we'll just process suboptimally
                }

                foreach (string filename in filenameList)
                {
                    newElements.AddRange(Process(store, filename, assemblyProcessor, textFileProcessor));
                }
            }
            catch (Exception e)
            {
                ErrorDisplay.Show(store, e.Message);
            }
            finally
            {
                StatusDisplay.Show("Ready");
            }

            return(newElements);
        }