Ejemplo n.º 1
0
 public string[] FindAddedFiles(string[] files)
 {
     return(files.Where(x => ConsoleRunner.Resolvers.ContainsKey(Path.GetExtension(x)) &&
                        ConsoleEntries.All(
                            y => y.LibPath != ConsoleRunner.Resolvers[Path.GetExtension(x)].ResolveLibrary(x)))
            .ToArray());
 }
Ejemplo n.º 2
0
        public bool CheckConsoles()
        {
            bool          changed  = false;
            List <string> allFiles = Directory
                                     .GetFiles(ConsolePaths.AssemblyPath, "*Console.*", SearchOption.AllDirectories)
                                     .Select(x => x.Replace("\\", "/")).ToList();

            string[] removedFiles = FindRemovedFiles(allFiles.ToArray());
            for (int i = ConsoleEntries.Count - 1; i >= 0; i--)
            {
                if (removedFiles.Contains(ConsoleEntries[i].LibPath))
                {
                    changed = true;
                    Console.WriteLine("Removing Missing Console: " + ConsoleEntries[i].ConsoleTitle);
                    ConsoleEntries.RemoveAt(i);
                }
            }

            string[] changedFiles = FindChangedFiles(allFiles.ToArray());
            if (changedFiles.Length != 0)
            {
                changed = true;
                ConsoleEntries.Clear();
            }

            string[] addedFiles = FindAddedFiles(allFiles.ToArray());
            for (int i = 0; i < addedFiles.Length; i++)
            {
                string ext = Path.GetExtension(addedFiles[i]);
                if (!ConsoleRunner.Resolvers.ContainsKey(ext))
                {
                    Console.WriteLine("Can not find Resolver for Extension: " + ext);
                    continue;
                }

                string libPath = ConsoleRunner.Resolvers[ext]
                                 .ResolveLibrary(addedFiles[i]);
                changed = true;
                AppDomainController adc = AppDomainController.Create("LoadingAssembly_" + libPath,
                                                                     new[] { Path.GetDirectoryName(libPath) });
                try
                {
                    Type[] consoleTypes = adc.GetTypes(libPath, typeof(AConsole));
                    foreach (Type consoleType in consoleTypes)
                    {
                        ConsoleItem console = new ConsoleItem(adc, libPath, consoleType);
                        Console.WriteLine("Adding New Console: " + console.ConsoleTitle);
                        ConsoleEntries.Add(console);
                    }

                    adc.Dispose();
                }
                catch (Exception e)
                {
                    adc.Dispose();
                    throw e;
                }
            }


            return(changed);
        }
Ejemplo n.º 3
0
 public ConsoleItem GetConsoleItem(string key)
 {
     return(ConsoleEntries.FirstOrDefault(x => x.ConsoleKey == key));
 }
Ejemplo n.º 4
0
 public string[] FindChangedFiles(string[] files)
 {
     return(files.Where(x => ConsoleEntries.Any(y =>
                                                y.LibPath == x && y.FileHash !=
                                                ConsoleItem.GetHash(ConsoleRunner.Resolvers[Path.GetExtension(x)].ResolveLibrary(x)))).ToArray());
 }