Example #1
0
        private void buttonInteract_Click(object sender, EventArgs e)
        {
            //
            // Demo, inject variables and personalized api library
            //

            var kntScript = new KntSEngine(new InOutDeviceForm(), new MyLibrary());

            var a = new DocumentDummy();

            a.Description = "My object, to inject in script.";

            // inject variable
            kntScript.AddVar("_a", a);

            var code = @"printline ""Demo external variables / MyLibrary injected"";

                        ' This variable (_a) comes from the host application
                        printline _a.Description;
                        printline _a.IdDocument;
                        printline _a.CreationDateTime;
                        printline _a.Folder.Name;
                        _a.DocumentTestMethodA("" param A "");
                        var b = _a.DocumentTestMethodB("" == param C =="");
                        printline b;

                        ' Test MyLibrary (injected library)
                        printline """";
                        printline ""Test MyLibrary"";
                        var colec = ColecDocDemo();
                        foreach x in colec
                            printline x.Description;
                        end foreach;

                        printline """";
                        _a.Description = ""KntScript - changed description property !!"";                                                
                        printline _a.Description;
                        printline """";

                        printline ""<< end >>""; 
                        ";

            kntScript.Run(code);

            var b = (DocumentDummy)kntScript.GetVar("_a");  // -> a

            MessageBox.Show(a.Description + " <==> " + b.Description);
        }
Example #2
0
    private void buttonInteract_Click(object sender, EventArgs e)
    {
        //
        // Demo, inject variables and personalized api library
        //

        var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        var a = new FolderDto();

        a.Name             = "My folder, to inject in script.";
        a.Tags             = "my tags";
        a.CreationDateTime = DateTime.Now;

        // inject variable
        kntScript.AddVar("_a", a);

        var code = @"printline ""Demo external variables / KNoteScriptLibrary injected"";

                    ' This variable (_a) comes from the host application
                    printline _a.Name;
                    printline _a.Tags;
                    printline _a.CreationDateTime;                        

                    _a.Name = ""KntScript - changed description property !!"";                                                
                    printline _a.Name;
                    printline """";

                    printline ""<< end >>""; 
                    ";

        kntScript.Run(code);

        var b = (FolderDto)kntScript.GetVar("_a");  // -> a

        MessageBox.Show(a.Name + " <==> " + b.Name);
    }