Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (48 loc) · 1.94 KB
/
Copy pathProgram.cs
File metadata and controls
56 lines (48 loc) · 1.94 KB
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
using ICSharpCore.Script;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Linq;
namespace ICSharpCore
{
public class Program
{
public static void Main(string[] args)
{
// We introduced DependencyInjection only for logging;
// It is not needed in .NET Core 3.0
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder =>
{
builder.AddConsole();
builder.SetMinimumLevel(LogLevel.Information);
});
var serviceProvider = serviceCollection.BuildServiceProvider();
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
// Connection files
// When Jupyter starts a kernel, it passes it a connection file.
// This specifies how to set up communications with the frontend.
Console.WriteLine("Kernel connecting...");
for (int i = 0; i < args.Length; i++)
Console.WriteLine($"arg {i}: {args[i]}");
// Create the connection model
string json = File.ReadAllText(args[0]);
var connInfo = JsonConvert.DeserializeObject<ConnInfo>(json);
Console.WriteLine(JsonConvert.SerializeObject(connInfo));
if (args.Length > 1)
{
InteractiveScriptEngine.RefsFilePath = args[1];
}
// Handling messages
// After reading the connection file and binding to the necessary sockets,
// the kernel should go into an event loop,
// listening on the hb (heartbeat),
// control and shell sockets.
var kernel = new Kernel(connInfo, loggerFactory);
kernel.Start();
}
}
}