in OWL2DTDL/Program.cs [154:230]
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed(o =>
{
_outputPath = o.OutputPath;
_noImports = o.NoImports;
_mergedOutput = o.MergedOutput;
if (o.FilePath != null)
{
_localOntology = true;
_ontologyPath = o.FilePath;
}
else
{
_localOntology = false;
_ontologyPath = o.UriPath;
}
// Parse ignored namespaces from ignorefile
if (o.IgnoreFile != null)
{
using (var reader = new StreamReader(o.IgnoreFile))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(';');
ignoredUris.Add(values[0]);
}
}
}
if (o.OntologySource != null)
{
_ontologySource = o.OntologySource;
}
})
.WithNotParsed((errs) =>
{
Environment.Exit(1);
});
// Turn off caching
UriLoader.CacheDuration = TimeSpan.MinValue;
// Load ontology graph from local or remote path
Console.WriteLine($"Loading {_ontologyPath}.");
if (_localOntology)
{
FileLoader.Load(_ontologyGraph, _ontologyPath);
}
else
{
UriLoader.Load(_ontologyGraph, new Uri(_ontologyPath));
}
// Get the main ontology defined in the graph and add it to the namespace mapper
rootOntology = _ontologyGraph.GetOntology();
namespacePrefixes.Add(rootOntology.GetUri(), rootOntology.GetShortName());
// If configured for it, parse owl:Imports transitively
if (!_noImports)
{
foreach (Ontology import in rootOntology.Imports)
{
LoadImport(import);
}
}
// Execute the main logic that generates DTDL interfaces.
GenerateInterfaces();
// Execute DTDL parser-based validation of generated interfaces.
// TODO commented out due to incompatible DotNetRdf in Microsoft.Azure.DigitalTwins.Parser
// ValidateInterfaces();
}