Esempio n. 1
0
        public MyAppDummyForm(DocumentDummy document)
        {
            InitializeComponent();

            if (document != null)
            {
                this._document = document;
            }
            else
            {
                this._document = new DocumentDummy();
            }
        }
Esempio n. 2
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);
        }