public void FormulaTest() { var xmePath = Path.Combine(_exportModelDirectory, "FormulaTest", "InputModel.xme"); string mgaFilename = unpackXme(xmePath); IMgaProject project = (MgaProject)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaProject")); project.OpenEx("MGA=" + mgaFilename, "CyPhyML", null); try { project.BeginTransactionInNewTerr(); try { MgaFCO fco = (MgaFCO)project.RootFolder.ObjectByPath["/@Imported_Components/@FormulaComp"]; Exception e = Assert.Throws(typeof(ApplicationException), () => CyPhyComponentExporter.CyPhyComponentExporterInterpreter.ExportComponentPackage(ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco))); Assert.True(e.Message.Contains("Value assignments for Component Parameters must come from outside the Component itself.")); fco = (MgaFCO)project.RootFolder.ObjectByPath["/@ComponentAssemblies/@ComponentAssembly/@Component"]; CyPhyComponentExporter.CyPhyComponentExporterInterpreter.ExportComponentPackage(ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco)); } finally { project.AbortTransaction(); } } finally { project.Close(true); } }
public void AbortTransaction() { if ((project.ProjectStatus & 8) != 0) { project.AbortTransaction(); } }
private void performInROTransaction(IMgaProject project, voidDelegate d) { IMgaTerritory territory = project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY); try { d(); } finally { try { project.AbortTransaction(); } catch { } try { territory.Destroy(); } catch { } } }
private static Statistics.Statistics Process(IMgaProject project) { Statistics.Statistics stats = new Statistics.Statistics(); if (project == null) { GenerateDummyData(stats); return(stats); } try { IMgaTerritory terr = project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY); // process meta model stats.ParadigmName = project.MetaName; stats.ProjectName = project.Name; stats.MetaModel.RootGUID = GetGUIDFromInt(project.RootMeta.RootFolder.MetaRef); var rfTree = new Dictionary <string, object>(); stats.Model.ContainmentTree[stats.MetaModel.RootGUID] = rfTree; foreach (MgaMetaAttribute attr in project.RootMeta.RootFolder.DefinedAttributes) { string attrType = attr.ValueType.ToString(); int num = 0; if (stats.MetaModel.Attributes.TryGetValue(attrType, out num)) { stats.MetaModel.Attributes[attrType] = num + 1; } else { stats.MetaModel.Attributes[attrType] = 1; } } foreach (MgaMetaFCO meta in project.RootMeta.RootFolder.DefinedFCOs) { rfTree[GetGUIDFromInt(meta.MetaRef)] = new Dictionary <string, object>(); if (meta is MgaMetaModel) { stats.MetaModel.NumberOfModels += 1; } else if (meta is MgaMetaConnection) { stats.MetaModel.NumberOfConnections += 1; } else if (meta is MgaMetaSet) { stats.MetaModel.NumberOfSets += 1; } else if (meta is MgaMetaReference) { stats.MetaModel.NumberOfReferences += 1; } else if (meta is MgaMetaAtom) { stats.MetaModel.NumberOfAtoms += 1; } } foreach (MgaMetaFolder meta in project.RootMeta.RootFolder.DefinedFolders) { rfTree[GetGUIDFromInt(meta.MetaRef)] = new Dictionary <string, object>(); stats.MetaModel.NumberOfFolders += 1; } // process domain model VisitChildren(stats, project.RootFolder, stats.Model.ContainmentTree); } finally { project.AbortTransaction(); } return(stats); }