public void The_Load_Method_Loads_ReferencedFiles_Correctly() { ProjectDeserialiserV1 deserialiser = new ProjectDeserialiserV1(fileController); IDesignerProject project = new ProjectBase(); //MockRepository.GenerateStub<IDesignerProject>(); deserialiser.ReadProject(ExpectedXml.GetXmlDocRoot(), project, "Folder\\Project.aad"); Assert.That(project.References, Has.Count(1)); Assert.That(project.References[0].FileName, Is.EqualTo("Folder\\file.dll")); Assert.That(project.References[0].MergeWithAssembly, Is.True); Assert.That(project.References[0].UseInWorkbench, Is.True); }
public void LoadFromSingleXmlFile(ProjectBase project, XmlDocument document, string templateFilename) { XmlElement root = document.DocumentElement; if (root == null) throw new DeserialisationException("Designer Project XML does not contain MegaProject root node."); // Get each of the XmlElements corresponding to the individual files. var projectNode = root.SelectSingleNode("Project"); var apiExtensions = root.SelectSingleNode("AllApiExtensions"); var functions = root.SelectSingleNode("Functions"); var userOptions = root.SelectSingleNode("UserOptions"); var staticFiles = root.SelectSingleNode("StaticFiles"); var outputs = root.SelectSingleNode("Outputs"); ReadProject(projectNode, project, templateFilename); // force the project to load its references #pragma warning disable 168 var list = project.ReferencedAssemblies; #pragma warning restore 168 ReadFunctions(functions, project); ReadAllApiExtensions(apiExtensions, project); ReadUserOptions(userOptions, project); project.AddIncludedFiles(ReadStaticFilesDetails(staticFiles)); project.RootOutput = ReadOutputs(outputs); project.SetupDynamicfilesAndFolders(); }
public void InitFromDesignerProjectXml(XmlDocument doc) { log.DebugFormat("Loading Designer Project Info from Xml Document"); if (doc.DocumentElement == null) throw new DeserialisationException("Could not load designer project info - xml document is empty"); if (doc.DocumentElement.Name == "ROOT") { LoadOldDesignerProjectXml(doc); return; } // New loading code ProjectBase designerProject = new ProjectBase(); ProjectDeserialiserV1 deserialiserV1 = new ProjectDeserialiserV1(new FileController()); deserialiserV1.LoadFromSingleXmlFile(designerProject, doc, ProjectFile); TemplateName = designerProject.ProjectName; TemplateDescription = designerProject.ProjectDescription; // Providers and referenced files ProvidersToBeDisplayed.Clear(); foreach (var referencedFile in designerProject.References) { if (referencedFile.IsProvider && referencedFile.UseInWorkbench) { ProvidersToBeDisplayed.Add(Path.GetFileName(referencedFile.FileName)); } string pathsSearched = ""; string currentPath = Path.GetFileName(referencedFile.FileName); bool assemblyFound = false; foreach (string searchPath in SharedData.AssemblySearchPaths) { pathsSearched += searchPath + Environment.NewLine; string filePath = Path.Combine(searchPath, currentPath); if (File.Exists(filePath)) { log.DebugFormat("Loading Provider from {0}", filePath); assemblyFound = true; ReferencedAssemblyPaths.Add(filePath); break; } } if (!assemblyFound) { if (MessageBox.Show(string.Format("'{0}' can't be located. The following folders have been searched: \n\n{1}\nDo you want to locate this file?", currentPath, pathsSearched), "File not found - Loading Project", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.FileName = currentPath; if (openFileDialog.ShowDialog() == DialogResult.OK) { if (File.Exists(openFileDialog.FileName)) { // Add this path to the search paths, because related assemblies might be in here as well. SharedData.AddAssemblySearchPath(Path.GetDirectoryName(openFileDialog.FileName)); ReferencedAssemblyPaths.Add(openFileDialog.FileName); assemblyFound = true; } } } if (!assemblyFound) { throw new FileNotFoundException(string.Format("Referenced assembly not found: {0}\n\nPlease make sure the assembly exists in one of these folders:{1}", currentPath, pathsSearched)); } } } // User Options var options = designerProject.UserOptions.Select(uo => uo.ToOption()); _Options.AddRange(options); log.DebugFormat("Loaded up {0} UserOptions", _Options.Count); _Options.ForEach(o => log.DebugFormat("UserOption {0} | On Type {1}", o.VariableName, o.IteratorName)); LoadReferencedAssemblies(); LoadAndFillProviders(); CombinedOutput = designerProject.RootOutput.ToCombinedOutput(); // I am not handling Default Value Functions. I think they no longer exist. FillVirtualProperties(); }