-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
app.js
115 lines (97 loc) · 3.41 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const { ipcMain} = require("electron");
const path = require('path');
var net = process.argv[1].replace('--', '');
var framework = net.charAt(0).toUpperCase() + net.substr(1);
var namespace = 'QuickStart.' + framework;
if(net === 'core') net = '';
var version = net === 'standard' ? '2.0' : '8.0'
const baseNetAppPath = path.join(__dirname, '/src/'+ namespace +'/bin/Debug/net' + net + version);
//const baseNetAppPath = path.join(__dirname, '/src/QuickStart.Core/bin/Release/net8.0/win-x64/publish');
process.env.EDGE_USE_CORECLR = 1;
if(net !== 'standard')
{
process.env.EDGE_APP_ROOT = baseNetAppPath;
}
var edge = require('electron-edge-js');
var baseDll = path.join(baseNetAppPath, namespace + '.dll');
var localTypeName = 'QuickStart.LocalMethods';
var externalTypeName = 'QuickStart.ExternalMethods';
var getAppDomainDirectory = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetAppDomainDirectory'
});
var getCurrentTime = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetCurrentTime'
});
var useDynamicInput = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'UseDynamicInput'
});
var getPerson = edge.func({
assemblyFile: baseDll,
typeName: externalTypeName,
methodName: 'GetPersonInfo'
});
var handleException = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'ThrowException'
});
var getInlinePerson = edge.func({
source: function () {/*
using System.Threading.Tasks;
using System;
public class Person
{
public Person(string name, string email, int age)
{
Id = Guid.NewGuid();
Name = name;
Email = email;
Age = age;
}
public Guid Id {get;}
public string Name {get;set;}
public string Email {get;set;}
public int Age {get;set;}
}
public class Startup
{
public async Task<object> Invoke(dynamic input)
{
return new Person(input.name, input.email, input.age);
}
}
*/}
});
exports.run = function (window) {
getInlinePerson({name: 'Peter Smith', email: '[email protected]', age: 30}, function(error, result) {
if (error) throw error;
window.webContents.send("fromMain", 'getItem', JSON.stringify( result, null, 2 ));
});
getAppDomainDirectory('', function(error, result) {
if (error) throw error;
window.webContents.send("fromMain", 'getAppDomainDirectory', result);
});
getCurrentTime('', function(error, result) {
if (error) throw error;
window.webContents.send("fromMain", 'getCurrentTime', result);
});
useDynamicInput({framework: framework, node: 'Node.Js'}, function(error, result) {
if (error) throw error;
window.webContents.send("fromMain", 'useDynamicInput', result);
});
try{
handleException('', function(error, result) { });
}catch(e){
window.webContents.send("fromMain", 'handleException', e.Message);
}
getPerson({name: 'John Smith', email: '[email protected]', age: 35}, function(error, result) {
if (error) throw error;
window.webContents.send("fromMain", 'getPerson', JSON.stringify( result, null, 2 ));
});
}