mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Rename TeleSharp.Generator->TgSharp.Generator
For consistency.
This commit is contained in:
parent
75fb3c1488
commit
8c3ddeb1b2
|
|
@ -1,14 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace TeleSharp.Generator.Models
|
|
||||||
{
|
|
||||||
internal class TlSchema
|
|
||||||
{
|
|
||||||
[JsonProperty("constructors")]
|
|
||||||
public List<TlConstructor> Constructors { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("methods")]
|
|
||||||
public List<TlMethod> Methods { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TeleSharp.Generator.Models
|
namespace TgSharp.Generator.Models
|
||||||
{
|
{
|
||||||
internal class TlConstructor
|
internal class Constructor
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
@ -12,7 +13,7 @@ namespace TeleSharp.Generator.Models
|
||||||
public string Predicate { get; set; }
|
public string Predicate { get; set; }
|
||||||
|
|
||||||
[JsonProperty("params")]
|
[JsonProperty("params")]
|
||||||
public List<TlParam> Params { get; set; }
|
public List<Param> Params { get; set; }
|
||||||
|
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TeleSharp.Generator.Models
|
namespace TgSharp.Generator.Models
|
||||||
{
|
{
|
||||||
internal class TlMethod
|
//called 'Function' because C# compiler doesn't let a property name == class
|
||||||
|
internal class Function
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
@ -12,7 +14,7 @@ namespace TeleSharp.Generator.Models
|
||||||
public string Method { get; set; }
|
public string Method { get; set; }
|
||||||
|
|
||||||
[JsonProperty("params")]
|
[JsonProperty("params")]
|
||||||
public List<TlParam> Params { get; set; }
|
public List<Param> Params { get; set; }
|
||||||
|
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TeleSharp.Generator.Models
|
namespace TgSharp.Generator.Models
|
||||||
{
|
{
|
||||||
internal class TlParam
|
internal class Param
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
14
src/TgSharp.Generator/Models/Schema.cs
Normal file
14
src/TgSharp.Generator/Models/Schema.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace TgSharp.Generator.Models
|
||||||
|
{
|
||||||
|
internal class Schema
|
||||||
|
{
|
||||||
|
[JsonProperty("constructors")]
|
||||||
|
public List<Constructor> Constructors { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("methods")]
|
||||||
|
public List<Function> Methods { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,9 +3,10 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TeleSharp.Generator.Models;
|
|
||||||
|
|
||||||
namespace TeleSharp.Generator
|
using TgSharp.Generator.Models;
|
||||||
|
|
||||||
|
namespace TgSharp.Generator
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +89,7 @@ namespace TeleSharp.Generator
|
||||||
}
|
}
|
||||||
FileStream file = File.OpenWrite("Result.cs");
|
FileStream file = File.OpenWrite("Result.cs");
|
||||||
StreamWriter sw = new StreamWriter(file);
|
StreamWriter sw = new StreamWriter(file);
|
||||||
TlSchema schema = JsonConvert.DeserializeObject<TlSchema>(Json);
|
Schema schema = JsonConvert.DeserializeObject<Schema>(Json);
|
||||||
foreach (var c in schema.Constructors)
|
foreach (var c in schema.Constructors)
|
||||||
{
|
{
|
||||||
interfacesList.Add(c.Type);
|
interfacesList.Add(c.Type);
|
||||||
|
|
@ -343,7 +344,7 @@ namespace TeleSharp.Generator
|
||||||
#endregion
|
#endregion
|
||||||
#region DeSerializeRespFunc
|
#region DeSerializeRespFunc
|
||||||
var deserializeResp = "";
|
var deserializeResp = "";
|
||||||
TlParam p2 = new TlParam() { Name = "Response", Type = c.Type };
|
var p2 = new Param() { Name = "Response", Type = c.Type };
|
||||||
deserializeResp += WriteReadCode(p2);
|
deserializeResp += WriteReadCode(p2);
|
||||||
temp = temp.Replace("/* DESERIALIZEResp */", deserializeResp);
|
temp = temp.Replace("/* DESERIALIZEResp */", deserializeResp);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -506,7 +507,7 @@ namespace TeleSharp.Generator
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string WriteWriteCode(TlParam p, bool flag = false)
|
public static string WriteWriteCode(Param p, bool flag = false)
|
||||||
{
|
{
|
||||||
switch (p.Type.ToLower())
|
switch (p.Type.ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -534,7 +535,7 @@ namespace TeleSharp.Generator
|
||||||
return $"";
|
return $"";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TlParam p2 = new TlParam() { Name = p.Name, Type = p.Type.Split('?')[1] };
|
Param p2 = new Param() { Name = p.Name, Type = p.Type.Split('?')[1] };
|
||||||
return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" +
|
return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" +
|
||||||
Environment.NewLine + " " +
|
Environment.NewLine + " " +
|
||||||
WriteWriteCode(p2, true);
|
WriteWriteCode(p2, true);
|
||||||
|
|
@ -542,7 +543,7 @@ namespace TeleSharp.Generator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static string WriteReadCode(TlParam p)
|
public static string WriteReadCode(Param p)
|
||||||
{
|
{
|
||||||
switch (p.Type.ToLower())
|
switch (p.Type.ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -575,7 +576,7 @@ namespace TeleSharp.Generator
|
||||||
return $"{CheckForKeywordAndPascalCase(p.Name)} = (Flags & {GetBitMask(p.Type).ToString()}) != 0;";
|
return $"{CheckForKeywordAndPascalCase(p.Name)} = (Flags & {GetBitMask(p.Type).ToString()}) != 0;";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TlParam p2 = new TlParam() { Name = p.Name, Type = p.Type.Split('?')[1] };
|
Param p2 = new Param() { Name = p.Name, Type = p.Type.Split('?')[1] };
|
||||||
return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" +
|
return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" +
|
||||||
Environment.NewLine + " " +
|
Environment.NewLine + " " +
|
||||||
WriteReadCode(p2) + Environment.NewLine + " " +
|
WriteReadCode(p2) + Environment.NewLine + " " +
|
||||||
|
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("TeleSharp.Generator")]
|
[assembly: AssemblyTitle("TgSharp.Generator")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("TeleSharp.Generator")]
|
[assembly: AssemblyProduct("TgSharp.Generator")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
<ProjectGuid>{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}</ProjectGuid>
|
<ProjectGuid>{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>TeleSharp.Generator</RootNamespace>
|
<RootNamespace>TgSharp.Generator</RootNamespace>
|
||||||
<AssemblyName>TeleSharp.Generator</AssemblyName>
|
<AssemblyName>TgSharp.Generator</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
|
@ -48,12 +48,12 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Models\TlMethod.cs" />
|
<Compile Include="Models\Function.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Models\TlConstructor.cs" />
|
<Compile Include="Models\Constructor.cs" />
|
||||||
<Compile Include="Models\TlParam.cs" />
|
<Compile Include="Models\Param.cs" />
|
||||||
<Compile Include="Models\TlSchema.cs" />
|
<Compile Include="Models\Schema.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
|
@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Core", "TgSharp.Cor
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeleSharp.TL", "TeleSharp.TL\TeleSharp.TL.csproj", "{D6144517-91D2-4880-86DF-E9FF5D7F383A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeleSharp.TL", "TeleSharp.TL\TeleSharp.TL.csproj", "{D6144517-91D2-4880-86DF-E9FF5D7F383A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeleSharp.Generator", "TeleSharp.Generator\TeleSharp.Generator.csproj", "{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Generator", "TgSharp.Generator\TgSharp.Generator.csproj", "{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Tests", "TgSharp.Tests\TgSharp.Tests.csproj", "{DE5C0467-EE99-4734-95F2-EFF7A0B99924}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Tests", "TgSharp.Tests\TgSharp.Tests.csproj", "{DE5C0467-EE99-4734-95F2-EFF7A0B99924}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue