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