Пример #1
0
            public long freemem()
            {
                string script = ScriptBuilder.Build(
                    "return {0}.freemem();",
                    Script.GetObject(API.id)
                    );

                return(SocketronClient.ExecuteBlocking <long>(script));
            }
Пример #2
0
            public string homedir()
            {
                string script = ScriptBuilder.Build(
                    "return {0}.homedir();",
                    Script.GetObject(API.id)
                    );

                return(SocketronClient.ExecuteBlocking <string>(script));
            }
Пример #3
0
            public JsonObject userInfo()
            {
                string script = ScriptBuilder.Build(
                    "return {0}.userInfo();",
                    Script.GetObject(API.id)
                    );
                object result = SocketronClient.ExecuteBlocking <object>(script);

                return(new JsonObject(result));
            }
Пример #4
0
        public static bool isEncoding(string encoding)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "return Buffer.isEncoding({0});"
                    ),
                encoding.Escape()
                );

            return(SocketronClient.ExecuteBlocking <bool>(script));
        }
Пример #5
0
        public static bool isBuffer(JSObject obj)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "return Buffer.isBuffer({0});"
                    ),
                Script.GetObject(obj.API.id)
                );

            return(SocketronClient.ExecuteBlocking <bool>(script));
        }
Пример #6
0
        public static long byteLength(Buffer value)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "return Buffer.byteLength({0});"
                    ),
                Script.GetObject(value.API.id)
                );

            return(SocketronClient.ExecuteBlocking <long>(script));
        }
Пример #7
0
        public static long byteLength(string value, string encoding = "utf8")
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "return Buffer.byteLength({0},{1});"
                    ),
                value.Escape(),
                encoding
                );

            return(SocketronClient.ExecuteBlocking <long>(script));
        }
Пример #8
0
        public static long compare(Buffer buf1, Buffer buf2)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "return Buffer.compare({0},{1});"
                    ),
                Script.GetObject(buf1.API.id),
                Script.GetObject(buf2.API.id)
                );

            return(SocketronClient.ExecuteBlocking <long>(script));
        }
Пример #9
0
            public string format(JsonObject pathObject)
            {
                string script = ScriptBuilder.Build(
                    ScriptBuilder.Script(
                        "var path = {0};",
                        "return path.format({1});"
                        ),
                    Script.GetObject(API.id),
                    pathObject.Stringify()
                    );

                return(SocketronClient.ExecuteBlocking <string>(script));
            }
Пример #10
0
            public string resolve(params string[] paths)
            {
                string script = ScriptBuilder.Build(
                    ScriptBuilder.Script(
                        "var path = {0};",
                        "return path.resolve({1});"
                        ),
                    Script.GetObject(API.id),
                    paths.Escape()
                    );

                return(SocketronClient.ExecuteBlocking <string>(script));
            }
Пример #11
0
            public string extname(string path)
            {
                string script = ScriptBuilder.Build(
                    ScriptBuilder.Script(
                        "var path = {0};",
                        "return path.extname({1});"
                        ),
                    Script.GetObject(API.id),
                    path.Escape()
                    );

                return(SocketronClient.ExecuteBlocking <string>(script));
            }
Пример #12
0
            /*
             * public JsonObject posix {
             *      get {
             *              string script = ScriptBuilder.Build(
             *                      ScriptBuilder.Script(
             *                              "var path = {0};",
             *                              "return path.posix;"
             *                      ),
             *                      Script.GetObject(id)
             *              );
             *              object result = SocketronClient.ExecuteBlocking<object>(script);
             *              return new JsonObject(result);
             *      }
             * }
             * //*/

            public string relative(string from, string to)
            {
                string script = ScriptBuilder.Build(
                    ScriptBuilder.Script(
                        "var path = {0};",
                        "return path.relative({1},{2});"
                        ),
                    Script.GetObject(API.id),
                    from.Escape(),
                    to.Escape()
                    );

                return(SocketronClient.ExecuteBlocking <string>(script));
            }
Пример #13
0
            public JsonObject parse(string path)
            {
                string script = ScriptBuilder.Build(
                    ScriptBuilder.Script(
                        "var path = {0};",
                        "return path.parse({1});"
                        ),
                    Script.GetObject(API.id),
                    path.Escape()
                    );
                object result = SocketronClient.ExecuteBlocking <object>(script);

                return(new JsonObject(result));
            }
Пример #14
0
        public static Buffer alloc(long size)
        {
            SocketronClient client = SocketronClient.GetCurrent();
            string          script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "var buf = Buffer.alloc({0});",
                    "return {1};"
                    ),
                size,
                Script.AddObject("buf")
                );
            int result = client.ExecuteJavaScriptBlocking <int>(script);

            return(new Buffer(client, result));
        }
Пример #15
0
        public static Buffer from(LocalBuffer buffer)
        {
            SocketronClient client = SocketronClient.GetCurrent();
            string          script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "var buf = Buffer.from({0});",
                    "return {1};"
                    ),
                buffer.Stringify(),
                Script.AddObject("buf")
                );
            int result = client.ExecuteJavaScriptBlocking <int>(script);

            return(new Buffer(client, result));
        }
Пример #16
0
        public static Buffer from(string str, string encoding = "utf8")
        {
            SocketronClient client = SocketronClient.GetCurrent();
            string          script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "var buf = Buffer.from({0},{1});",
                    "return {2};"
                    ),
                str.Escape(),
                encoding.Escape(),
                Script.AddObject("buf")
                );
            int result = client.ExecuteJavaScriptBlocking <int>(script);

            return(new Buffer(client, result));
        }
Пример #17
0
        public static Buffer transcode(Buffer source, string fromEnc, string toEnc)
        {
            if (source == null)
            {
                return(null);
            }
            string script = ScriptBuilder.Build(
                "return this.require('buffer').transcode({0},{1},{2});",
                Script.GetObject(source.API.id),
                fromEnc.Escape(),
                toEnc.Escape()
                );
            int result = SocketronClient.ExecuteBlocking <int>(script);

            return(new Buffer(SocketronClient.GetCurrent(), result));
        }
Пример #18
0
        public static Buffer from(params object[] array)
        {
            if (array == null)
            {
                return(null);
            }
            SocketronClient client = SocketronClient.GetCurrent();
            string          script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "var buf = Buffer.from([{0}]);",
                    "return {1};"
                    ),
                Script.GetObjectList(array),
                Script.AddObject("buf")
                );
            int result = client.ExecuteJavaScriptBlocking <int>(script);

            return(new Buffer(client, result));
        }
Пример #19
0
        public static T ExecuteBlocking <T>(string script)
        {
            SocketronClient client = GetCurrent();

            return(client.ExecuteJavaScriptBlocking <T>(script));
        }
Пример #20
0
 public Buffer(SocketronClient client, int id)
 {
     API.client = client;
     API.id     = id;
 }
Пример #21
0
 public virtual void Init(SocketronClient client)
 {
     console = require <NodeModules.Console>("console");
     process = require <NodeModules.Process>("process");
 }
Пример #22
0
        public static void Execute(string script)
        {
            SocketronClient client = GetCurrent();

            client.Main.ExecuteJavaScript(script);
        }
Пример #23
0
 public void Init(SocketronClient client, WebContents webContents)
 {
     API.client = client;
     (API as SocketronDOMAPI).webContentsId = webContents.id;
     API.id = _GetWindowObjectId();
 }
Пример #24
0
 public override void Init(SocketronClient client)
 {
     base.Init(client);
     API.client = client;
     electron   = require <ElectronModule>("electron");
 }