c# - 使用 ROLEX 以编程方式从 OWL 文件生成装配体

标签 c# .net rdf owl rowlex

我一直在使用 ROWLEX处理 RDF-s 的库。它附带了一个名为 OwlGrinder.exe 的设计时 GUI 工具,该工具可以从我的 OWL 本体生成 C# 帮助程序类(准确地说是 .NET 程序集)。我想知道是否有人知道我是否可以在运行时以编程方式执行相同的操作。

最佳答案

ROWLEX 刚刚开源,所以现在您有机会实际查看 OwlGrinder.exe 的代码并从那里复制代码。但是,这里有一个简短的示例:

    private NC3A.SI.Rowlex.AssemblyGenerator generator;

    private void RunAssemblyGeneration(XmlDocument ontologyFileInRdfXml)
    {
        this.generator = new NC3A.SI.Rowlex.AssemblyGenerator();
        this.generator.GenerateAsync(ontologyFileInRdfXml, "myAssemblyName", 
                                        null, this.OnGenerationFinished);
    }

    private void OnGenerationFinished(string errorMessage)
    {
        if (errorMessage == null)
        {
            // Success
            // Displaying warnings and saving result
            string[] warnings = this.generator.Warnings;
            this.generator.SaveResult(@"C:\myAssemblyName.dll");
                // Important! One generator instance can be executed only once. 
                this.generator = null; 
                this.RejoiceOverSuccess();
            }
        else
        {
                // Failure
                this.MournOverFailure();
            }

    }

如果您想在运行时生成程序集,我假设您可能希望根据用户的要求一遍又一遍地重复该操作。您必须注意这里,因为.NET 不允许您卸载程序集。因此,您无法删除之前运行中的程序集。解决方案是每次在可以卸载的新 AppDomain 中执行生成代码。 OwlGrinder.exe 正是这样做的,您可能希望在 MainForm.cs 中达到峰值

关于c# - 使用 ROLEX 以编程方式从 OWL 文件生成装配体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/865052/

相关文章:

c# - 在 C# 中创建深拷贝

c# - 在 C# 中的图表区域内停靠图例

c# - 是否可以对泛型方法进行不安全的协变调用?

c# - 错误 : 50 - Local Database Runtime error occurred, 但如果我发布该项目,它可以正常工作

.net - 垃圾收集器会为我调用 IDisposable.Dispose 吗?

c# - 如何让 DirectoryModuleCatalog 工作?

rdf - 如何使用 SPARQL 获取 OWL 类的数据和对象属性?

c# - 在 C# 中使用自动实现的属性是正确的方法吗

rdf - 如何连接sparql中的值列表?

rdf - 是rdfs :subClassOf really transitive?