Skip to content

Библиотека "cs" (Работа с DLL написанные на C# и JavaScript)

bas1c edited this page Oct 17, 2022 · 5 revisions

В Onion есть возможность импортировать DLL написанные на Visual C# и на JavaScript

Пример:

Код на C#:

//first.dll
using System;

public class eng {
    public void test(string ok, int ok2) {
        Console.WriteLine(ok);
        Console.Write(ok2);
    }
}

Код на Onion:

use "std"
use "cs" /* Библиотека для использования DLL */

stack = new_stack()

append("stack", to_string("123"))
append("stack", to_int(32))

//first - название DLL

im = import_cs_class("first", "eng")
ins = get_cs_class_inst("first", "eng")
exec_cs_method(im, ins, "test", stack)

/*Output:
123
32
*/

stop()

Clone this wiki locally