Generator: start rename of TeleSharp.TL->TgSharp.TL assembly (1/5)

This commit is contained in:
Andres G. Aragoneses 2020-04-16 17:20:26 +08:00
parent 8c3ddeb1b2
commit dfb8b52bb0
4 changed files with 17 additions and 14 deletions

View file

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TeleSharp.TL; using TgSharp.TL;
namespace /* NAMESPACE */ namespace /* NAMESPACE */
{ {

View file

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TeleSharp.TL; using TgSharp.TL;
namespace /* NAMESPACE */ namespace /* NAMESPACE */
{ {

View file

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TeleSharp.TL; using TgSharp.TL;
namespace /* NAMESPACE */ namespace /* NAMESPACE */
{ {

View file

@ -18,6 +18,8 @@ namespace TgSharp.Generator
static string constructorTemplate = "Constructor.tmp"; static string constructorTemplate = "Constructor.tmp";
static string methodTemplate = "Method.tmp"; static string methodTemplate = "Method.tmp";
static string rootNamespace = "TgSharp";
static List<string> templateFiles = new List<string> (new [] { static List<string> templateFiles = new List<string> (new [] {
constructorAbsTemplate, constructorAbsTemplate,
constructorTemplate, constructorTemplate,
@ -102,7 +104,7 @@ namespace TgSharp.Generator
{ {
string path = string path =
(GetNameSpace(c.Type) (GetNameSpace(c.Type)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "") + Path.DirectorySeparatorChar + .Replace(".", "") + Path.DirectorySeparatorChar +
GetNameofClass(c.Type, true) + ".cs") GetNameofClass(c.Type, true) + ".cs")
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()); .Replace("\\\\", Path.DirectorySeparatorChar.ToString());
@ -111,13 +113,13 @@ namespace TgSharp.Generator
{ {
string nspace = string nspace =
(GetNameSpace(c.Type) (GetNameSpace(c.Type)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "")) .Replace(".", ""))
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()) .Replace("\\\\", Path.DirectorySeparatorChar.ToString())
.Replace(Path.DirectorySeparatorChar, '.'); .Replace(Path.DirectorySeparatorChar, '.');
if (nspace.EndsWith(".")) if (nspace.EndsWith("."))
nspace = nspace.Remove(nspace.Length - 1, 1); nspace = nspace.Remove(nspace.Length - 1, 1);
string temp = absStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace); string temp = absStyle.Replace("/* NAMESPACE */", rootNamespace + "." + nspace);
temp = temp.Replace("/* NAME */", GetNameofClass(c.Type, true)); temp = temp.Replace("/* NAME */", GetNameofClass(c.Type, true));
writer.Write(temp); writer.Write(temp);
writer.Close(); writer.Close();
@ -134,7 +136,7 @@ namespace TgSharp.Generator
{ {
string path = string path =
(GetNameSpace(c.Predicate) (GetNameSpace(c.Predicate)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "") + Path.DirectorySeparatorChar + .Replace(".", "") + Path.DirectorySeparatorChar +
GetNameofClass(c.Predicate, false) + ".cs") GetNameofClass(c.Predicate, false) + ".cs")
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()); .Replace("\\\\", Path.DirectorySeparatorChar.ToString());
@ -144,13 +146,13 @@ namespace TgSharp.Generator
#region About Class #region About Class
string nspace = string nspace =
(GetNameSpace(c.Predicate) (GetNameSpace(c.Predicate)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "")) .Replace(".", ""))
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()) .Replace("\\\\", Path.DirectorySeparatorChar.ToString())
.Replace(Path.DirectorySeparatorChar, '.'); .Replace(Path.DirectorySeparatorChar, '.');
if (nspace.EndsWith(".")) if (nspace.EndsWith("."))
nspace = nspace.Remove(nspace.Length - 1, 1); nspace = nspace.Remove(nspace.Length - 1, 1);
string temp = normalStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace); string temp = normalStyle.Replace("/* NAMESPACE */", rootNamespace + "." + nspace);
temp = (c.Type == "himself") ? temp.Replace("/* PARENT */", "TLObject") : temp.Replace("/* PARENT */", GetNameofClass(c.Type, true)); temp = (c.Type == "himself") ? temp.Replace("/* PARENT */", "TLObject") : temp.Replace("/* PARENT */", GetNameofClass(c.Type, true));
temp = temp.Replace("/*Constructor*/", c.Id.ToString()); temp = temp.Replace("/*Constructor*/", c.Id.ToString());
temp = temp.Replace("/* NAME */", GetNameofClass(c.Predicate, false)); temp = temp.Replace("/* NAME */", GetNameofClass(c.Predicate, false));
@ -241,7 +243,7 @@ namespace TgSharp.Generator
{ {
string path = string path =
(GetNameSpace(c.Method) (GetNameSpace(c.Method)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "") + Path.DirectorySeparatorChar + .Replace(".", "") + Path.DirectorySeparatorChar +
GetNameofClass(c.Method, false, true) + ".cs") GetNameofClass(c.Method, false, true) + ".cs")
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()); .Replace("\\\\", Path.DirectorySeparatorChar.ToString());
@ -251,13 +253,13 @@ namespace TgSharp.Generator
#region About Class #region About Class
string nspace = string nspace =
(GetNameSpace(c.Method) (GetNameSpace(c.Method)
.Replace("TeleSharp.TL", "TL" + Path.DirectorySeparatorChar) .Replace(rootNamespace + ".TL", "TL" + Path.DirectorySeparatorChar)
.Replace(".", "")) .Replace(".", ""))
.Replace("\\\\", Path.DirectorySeparatorChar.ToString()) .Replace("\\\\", Path.DirectorySeparatorChar.ToString())
.Replace(Path.DirectorySeparatorChar, '.'); .Replace(Path.DirectorySeparatorChar, '.');
if (nspace.EndsWith(".")) if (nspace.EndsWith("."))
nspace = nspace.Remove(nspace.Length - 1, 1); nspace = nspace.Remove(nspace.Length - 1, 1);
string temp = methodStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace); string temp = methodStyle.Replace("/* NAMESPACE */", rootNamespace + "." + nspace);
temp = temp.Replace("/* PARENT */", "TLMethod"); temp = temp.Replace("/* PARENT */", "TLMethod");
temp = temp.Replace("/*Constructor*/", c.Id.ToString()); temp = temp.Replace("/*Constructor*/", c.Id.ToString());
temp = temp.Replace("/* NAME */", GetNameofClass(c.Method, false, true)); temp = temp.Replace("/* NAME */", GetNameofClass(c.Method, false, true));
@ -421,10 +423,11 @@ namespace TgSharp.Generator
public static string GetNameSpace(string type) public static string GetNameSpace(string type)
{ {
var baseNamespace = rootNamespace + ".TL";
if (type.IndexOf('.') != -1) if (type.IndexOf('.') != -1)
return "TeleSharp.TL" + FormatName(type.Split('.')[0]); return baseNamespace + FormatName(type.Split('.')[0]);
else else
return "TeleSharp.TL"; return baseNamespace;
} }
public static string CheckForFlagBase(string type, string result) public static string CheckForFlagBase(string type, string result)