mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-05 23:52:00 +01:00
Generator: default to a schema filename in line to online resource
The schema is in https://core.telegram.org/schema/json so it's more logical to expect the file to be named `json`, which is what would happen if you download it with wget, for example.
This commit is contained in:
parent
9a6e391cae
commit
bca8bc5631
|
|
@ -20,10 +20,21 @@ namespace TeleSharp.Generator
|
|||
string MethodStyle = File.ReadAllText("Method.tmp");
|
||||
//string method = File.ReadAllText("constructor.tt");
|
||||
string Json = "";
|
||||
string url;
|
||||
if (args.Count() == 0) url = "tl-schema.json"; else url = args[0];
|
||||
|
||||
Json = File.ReadAllText(url);
|
||||
string url;
|
||||
if (!args.Any())
|
||||
url = "json";
|
||||
else
|
||||
url = args[0];
|
||||
|
||||
try
|
||||
{
|
||||
Json = File.ReadAllText(url);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
throw new Exception ("Couldn't find schema JSON file, did you download it first e.g. with `wget https://core.telegram.org/schema/json`?", ex);
|
||||
}
|
||||
FileStream file = File.OpenWrite("Result.cs");
|
||||
StreamWriter sw = new StreamWriter(file);
|
||||
TlSchema schema = JsonConvert.DeserializeObject<TlSchema>(Json);
|
||||
|
|
|
|||
Loading…
Reference in a new issue