从名称中获取插槽名称或插槽的列表

发布于 2025-02-08 04:05:03 字数 712 浏览 0 评论 0原文

使用.NET包装器,我有AC#方法,该方法传递了一个deftemplate名称,并且需要在基于该deftemplate的所有事实上迭代。以下代码有效,但要求我提前知道给定的deftemplate的插槽名称。...

        List<FactAddressValue> resultValues = clipsEnv.FindAllFacts(resultName);
        foreach (FactAddressValue resultValue in resultValues)
        {
            var sv = resultValue.GetSlotValue("InputFieldName");
            Console.WriteLine($"{sv}");
        }

我已经搜索了剪辑网络示例,但是所有这些都使用了deftemplate插槽名称的C#代码中的字符串常数。因此...

  1. 是否存在返回deftemplate(或至少给定deftemplate的属性)的剪贴机方法,该剪辑板接受了deftemplate名称作为参数?
  2. 是否有一种方法可以返回接受FactAddressValue作为参数的Deftemplate(或至少给定Deftemplate的属性)?
  3. 我需要扩展clipsclrwrapper以获取所需的功能吗?
  4. 使用实例而不是事实会让这一简单吗?

Using the .NET wrapper, I have a c# method that is passed a deftemplate name and needs to iterate over all facts which are based on that deftemplate. The following code works but requires that I know the slot names in advance for the given deftemplate....

        List<FactAddressValue> resultValues = clipsEnv.FindAllFacts(resultName);
        foreach (FactAddressValue resultValue in resultValues)
        {
            var sv = resultValue.GetSlotValue("InputFieldName");
            Console.WriteLine(
quot;{sv}");
        }

I have searched through the CLIPSNET examples, but all of them make use of string constants in the c# code for the deftemplate slot names. So...

  1. Is there CLIPSNET method that returns a deftemplate (or at least properties for a given deftemplate) that accepts a deftemplate name as the parameter?
  2. Is there a method that returns a deftemplate (or at least properties for a given deftemplate) that accepts a FactAddressValue as the parameter?
  3. Will I need to extend the CLIPSCLRWrapper to get the functionality I need?
  4. Would using Instances instead of Facts make this any easier?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离线来电— 2025-02-15 04:05:03

您可以使用Eval方法来访问包装器未明确暴露的功能。 For example, at the command prompt or within a CLIPS construct, you can call functions like get-deftemplate-list or deftemplate-slot-names:

CLIPS> (deftemplate point (slot x) (slot y))
CLIPS> (get-deftemplate-list)
(point)
CLIPS> (deftemplate-slot-names point)
(x y)
CLIPS> 

You could invoke these same functions from C# by calling Eval and passing "(get-deftemplate-list )“或”(deftemplate-slot-names点)”。

对于您显示的简单示例,您也可以使用estale并将其传递到“(((?f point))true(println?f:x)))之类的东西”。

有数百个剪辑函数可能会直接通过API暴露出来,但并没有这样做,因此您可以使用它们而无需拥有巨大的API。您还可以使用eval来执行诸如调用片状或将消息发送到实例之类的事情。但是,如果出于某种原因,您确实需要将这些功能成为.NET API的一部分,那么您将必须扩展包装器才能包括它们。

You can use the Eval method to get access to functions that aren't explicitly exposed by the wrapper. For example, at the command prompt or within a CLIPS construct, you can call functions like get-deftemplate-list or deftemplate-slot-names:

CLIPS> (deftemplate point (slot x) (slot y))
CLIPS> (get-deftemplate-list)
(point)
CLIPS> (deftemplate-slot-names point)
(x y)
CLIPS> 

You could invoke these same functions from C# by calling Eval and passing "(get-deftemplate-list)" or "(deftemplate-slot-names point)".

For the simple example you've shown you could also use Eval and pass it something like "(do-for-all-facts ((?f point)) TRUE (println ?f:x))".

There's hundreds of CLIPS functions that could potentially be directly exposed through the API, but rather than do that the Eval function is available so that you have access to them without having a huge API. You can also use Eval to do things like calling a deffunction or sending a message to an instance. But if for whatever reason you do need to have these functions be part of the .NET API, then you would have to extend the wrapper to include them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文