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($"{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...
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.