public static void Main(String[] args)
{
if (!SBMLExtensionRegistry.isPackageEnabled("comp"))
{
Console.WriteLine("This copy of libSBML does not contain the 'comp' extension");
Console.WriteLine("Unable to proceed with the resolver example the model.");
Environment.Exit(2);
}
// create custom resolver
CustomResolver resolver = new CustomResolver();
// add the resolver and store its index, so we can free it later.
int index = SBMLResolverRegistry.getInstance().addResolver(resolver);
// create a new document with comp enabled
SBMLDocument doc = new SBMLDocument(new CompPkgNamespaces());
// get a hold of a plugin object
CompSBMLDocumentPlugin plugin = (CompSBMLDocumentPlugin)doc.getPlugin("comp");
// create an external model definition
ExternalModelDefinition external = plugin.createExternalModelDefinition();
// set the source to the URI
external.setSource("http://www.ebi.ac.uk/biomodels-main/download?mid=BMID000000063853");
// resolve the model
Model model = external.getReferencedModel();
if (model == null)
{
Console.Error.WriteLine("couldn't resolve");
Environment.Exit(2);
}
// model is ready to be used now, however, only as long and the document
// holding the external model definition is still alive and referenced
Console.WriteLine("Model id: " + model.getId());
Console.WriteLine("# species: " + model.getNumSpecies());
Console.WriteLine("# reactions: " + model.getNumReactions());
// now that we are done get rid of the resolver
SBMLResolverRegistry.getInstance().removeResolver(index);
// also clear the resolver instance, just to be sure that it has
// no more references to the C# resolver
SBMLResolverRegistry.deleteResolerRegistryInstance();
// finally we can get rid of the C# resolver
resolver = null;
}