Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SetStreamFunctionRead Method (streamType, function)
SwiPlCs interface ► SbsSW.SwiPlCs ► PlEngine ► SetStreamFunctionRead(PlStreamType, DelegateStreamReadFunction)
TODO
Declaration Syntax
C# | Visual Basic | Visual C++ | F# |
public static void SetStreamFunctionRead( PlStreamType streamType, DelegateStreamReadFunction function )
Public Shared Sub SetStreamFunctionRead ( streamType As PlStreamType, function As DelegateStreamReadFunction )
public: static void SetStreamFunctionRead( PlStreamType streamType, DelegateStreamReadFunction^ function )
static member SetStreamFunctionRead : streamType : PlStreamType * function : DelegateStreamReadFunction -> unit
Parameters
- streamType (PlStreamType)
- Determine which stream to use PlStreamType
- function (DelegateStreamReadFunction)
- A DelegateStreamReadFunction
Examples
Copy | |
---|---|
private const string ValidationStringRead = "hello_dotnet_world_����."; // The last 4 character are German umlauts. static internal long Sread(IntPtr handle, IntPtr buffer, long buffersize) { const string s = ValidationStringRead + "\n"; byte[] array = System.Text.Encoding.Unicode.GetBytes(s); System.Runtime.InteropServices.Marshal.Copy(array, 0, buffer, array.Length); return array.Length; } [TestMethod] public void StreamRead() { var rf = new DelegateStreamReadFunction(Sread); PlEngine.SetStreamFunctionRead(PlStreamType.Input, rf); // NOTE: read/1 needs a dot ('.') at the end PlQuery.PlCall("assert( (test_read(A) :- read(A)) )"); PlTerm t = PlQuery.PlCallQuery("test_read(A)"); Assert.AreEqual(ValidationStringRead, t.ToString()+"."); } |
Assembly: SwiPlCs (Module: SwiPlCs.dll) Version: 1.1.60605.0 (1.1.60605.0)