예제 #1
0
        public bool RunCommand(CommandReceiver runner)
        {
            log.Debug("Running LoadAssemblies command.");
            log.InfoFormat("Project File: {0}", ArchAngelProjectFileLocation);
            log.InfoFormat("Current File Path: {0}", CurrentFilePath);

            log.Info("The following assemblies were added to the AssemblySearchPaths:");
            if (log.IsInfoEnabled)
            {
                foreach (var path in AssemblySearchPaths)
                {
                    log.Info(path);
                }
            }

            SharedData.AddAssemblySearchPaths(AssemblySearchPaths);

            runner.CurrentProject = new WorkbenchProject();

            string fakeProjectDirectory     = PathHelper.GetTempFilePathFor("ArchAngel", ArchAngelProjectFileLocation, ComponentKey.Debugger_FakeProjectDirectory);
            IVerificationIssueSolver solver = new CustomVerificationIssueSolver("", fakeProjectDirectory);
            bool result = runner.CurrentProject.Load(ArchAngelProjectFileLocation, solver, true, null);

            if (result)
            {
                runner.Loaded = true;
                return(runner.Loaded);
            }

            log.ErrorFormat("Could not load the project: {0}", solver.GetValidTemplateFilePath("", ""));
            throw new Exception("Could not load the project.");

            /*
             * foreach (string assemblyFullname in AssemblyFullNames)
             * {
             *      Assembly assembly = Assembly.LoadFrom(assemblyFullname);
             *
             *      if (ProviderInfo.IsProvider(assembly))
             *      {
             *              // Unzip .aaproj file
             *              XmlDocument doc = new XmlDocument();
             *              doc.Load(projectFilename);
             *
             *              NodeProcessor proc = new NodeProcessor(doc.DocumentElement);
             *              string folder = proc.GetString("Folder");
             *              tempFolder = RelativePaths.RelativeToAbsolutePath(Path.GetDirectoryName(projectFilename), folder);
             *
             *
             *              string tempFolder = PathHelper.GetTempFilePathFor("ArchAngel", ArchAngelProjectFileLocation, ComponentKey.Debugger_LoadAssemblies);
             *              Directory.CreateDirectory(tempFolder);
             *              Utility.UnzipFile(ArchAngelProjectFileLocation, tempFolder);
             *              string zipFile = tempFolder.PathSlash(assembly.GetName().Name.Replace(".", "_") + "_data.zip");
             *              string tempProviderFolder = Path.Combine(Path.GetTempPath(), assembly.GetName().Name.Replace(".", "_") + "Temp");
             *
             *              if (Directory.Exists(tempProviderFolder))
             *              {
             *                      Utility.DeleteDirectoryBrute(tempProviderFolder);
             *              }
             *              Directory.CreateDirectory(tempProviderFolder);
             *
             *              if (File.Exists(zipFile))
             *              {
             *                      Utility.UnzipFile(zipFile, tempProviderFolder);
             *
             *                      ProviderInfo providerInfo = ProviderInfo.GetProviderInfo(assembly);
             *                      if (providerInfo == null)
             *                      {
             *                              throw new Exception("ProviderInfo type not found in assembly: " + assembly.GetName().Name);
             *                      }
             *
             *                      providerInfo.Open(tempProviderFolder);
             *                      runner.CurrentProvider = providerInfo;
             *                      runner.Loaded = true;
             *              }
             *              //else
             *              //	throw new Exception("Could not find the Provider data zip file in the temp directory: " + zipFile);
             *      }
             *      //runner.Loaded = true;
             * }
             */
        }