private static void GenericTest(string inputFile, IDictionary <string, string> dependencies, string outputPackageId) { string projectFolder = VariousUtil.GetProjectFolder(); string ecorePath = Path.Combine(projectFolder, inputFile); if (dependencies != null) { foreach (KeyValuePair <string, string> dependency in dependencies) { // Load dependency using NMF, with a specific URI string dependencyPath = Path.Combine(projectFolder, dependency.Value); ModelRepository repository = (ModelRepository)EcoreInterop.Repository; FileStream depFileStream = new FileInfo(dependencyPath).Open(FileMode.Open); repository.Serializer.Deserialize(depFileStream, new Uri(dependency.Key, UriKind.Absolute), repository, true); depFileStream.Close(); } } // Load ecore using NMF IEPackage package = EcoreInterop.LoadPackageFromFile(ecorePath); ISet <IEPackage> epackages = new HashSet <IEPackage>() { package }; // Load output EnAr project Package outputContainerPackage = Ecore2EnArTestSetUp.Loader.GetEnAarPackage(outputPackageId); // Prepare transformation and start XsdImport.Ecore2EnAr.Ecore2EnAr importer = new XsdImport.Ecore2EnAr.Ecore2EnAr(outputContainerPackage, Ecore2EnArTestSetUp.Loader.Explorer); importer.ConstructMetamodel(epackages); }
/// <summary> /// To initialize EA with a given project file. /// The "Close" method should be called when it is over. /// </summary> /// <param name="fileName"></param> public EnArLoader(string fileName, bool isAbsolute = false, bool makeCopy = true) { if (AbsolutePathToOutput == null) { // Find the model test file in the VS project projectFolder = VariousUtil.GetProjectFolder(); // Create output folder AbsolutePathToOutput = Path.Combine(projectFolder, GeneratorOutputPath); } if (currentLlRepository == null) { // Creates EA instance Repository currentEaRepository = new Repository(); // Opens the model file in the EA instance string absolutePathToModel = isAbsolute ? fileName : Path.Combine(projectFolder, fileName); // and from there we can find the "models" folder if (makeCopy) { string absolutePathToModelCopy = absolutePathToModel; absolutePathToModelCopy = Path.ChangeExtension(absolutePathToModelCopy, ".tmp.eap"); if (File.Exists(absolutePathToModelCopy)) { File.Delete(absolutePathToModelCopy); } File.Copy(absolutePathToModel, absolutePathToModelCopy); absolutePathToModel = absolutePathToModelCopy; } bool openResult = currentEaRepository.OpenFile(absolutePathToModel); Assert.True(openResult, "The file " + absolutePathToModel + "could not be opened"); // Opens the model currentLlRepository = new RepositoryImpl(currentEaRepository); currentLlRepository.ChachingFinished += HybridRepositoryCachingFinished; for (int i = 0; i < 50; i++) { if (dataModelReadyToUse == false) { Thread.Sleep(500); } } if (dataModelReadyToUse == false) { throw new Exception("Timeout when trying to open EnAr file " + fileName); } Explorer = new EnArExplorer(currentLlRepository, currentEaRepository); } }