forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
69 lines (59 loc) · 1.73 KB
/
Copy pathProgram.cs
File metadata and controls
69 lines (59 loc) · 1.73 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
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.Xml.Xsl;
using Waher.Content.Xsl;
using Waher.Events;
using Waher.Events.Console;
using Waher.Networking;
namespace Waher.Utility.GetEmojiCatalog
{
class Program
{
static void Main(string[] _)
{
string Html;
Log.Register(new ConsoleEventSink(false));
Log.RegisterExceptionToUnnest(typeof(System.Runtime.InteropServices.ExternalException));
Log.RegisterExceptionToUnnest(typeof(System.Security.Authentication.AuthenticationException));
try
{
if (!File.Exists("table.htm") || (DateTime.Now - File.GetLastWriteTime("table.htm")).TotalHours >= 1.0)
{
Log.Informational("Downloading table.");
WebClient Client = new WebClient();
Client.DownloadFile("http://unicodey.com/emoji-data/table.htm", "table.htm");
Log.Informational("Loading table");
Html = File.ReadAllText("table.htm");
Log.Informational("Fixing encoding errors.");
Html = Html.
Replace("<td><3</td>", "<td><3</td>").
Replace("<td></3</td>", "<td></3</td>").
Replace("</body>\n<html>", "</body>\n</html>");
File.WriteAllText("table.htm", Html);
}
else
{
Log.Informational("Loading table");
Html = File.ReadAllText("table.htm");
}
Log.Informational("Transforming to C#.");
XslCompiledTransform Transform = XSL.LoadTransform("Waher.Utility.GetEmojiCatalog.Transforms.HtmlToCSharp.xslt");
string CSharp = XSL.Transform(Html, Transform);
Log.Informational("Saving C#.");
File.WriteAllText("EmojiUtilities.cs", CSharp);
}
catch (Exception ex)
{
Log.Critical(ex);
}
finally
{
Log.Terminate();
}
}
}
}