Пример #1
0
        public static void Main(string[] args)
        {
            PrintHeader();
            TLSchema schema = FetchJsonAsync().Result;

            schema.Constructors.RemoveAll(x => Values.IgnoredConstructors.Contains(x.Predicate));

            Console.ReadLine();
        }
Пример #2
0
        public static Tuple <string, TLObject[]> ParseEntities(string Message)
        {
            using dynamic schema = new TLSchema();
            var Tags       = new List <TLObject>();
            var ParsedText = "";

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(Message);

            foreach (var e in htmlDoc.DocumentNode.ChildNodes)
            {
                switch (e.Name)
                {
                case "b":
                    Tags.Add(schema.messageEntityBold(new
                    {
                        offset = ParsedText.Length,
                        length = e.InnerLength
                    }));

                    break;

                case "i":
                    Tags.Add(schema.messageEntityItalic(new
                    {
                        offset = ParsedText.Length,
                        length = e.InnerLength
                    }));

                    break;

                case "code":
                    Tags.Add(schema.messageEntityCode(new
                    {
                        offset = ParsedText.Length,
                        length = e.InnerLength
                    }));

                    break;
                }

                ParsedText += e.InnerText;
            }
            return(new Tuple <string, TLObject[]>(ParsedText, Tags.Count() == 0 ? null : Tags.ToArray()));
        }
Пример #3
0
        public static void Compile(CompileArgs args)
        {
            Console.WriteLine("Compiling...");
            string source = File.ReadAllText(args.Source);
            string outputSchemaFileName            = string.Format("{0}.cs", args.Namespace);
            string outputSchemaMethodsImplFileName = string.Format("{0}.MethodsImpl.cs", args.Namespace);

            var compilationParams = new CompilationParams(args.Namespace, args.MethodsInterfaceName);

            TLSchema schema = TLSchema.Build(args.SourceType, source);

            string compiledSchema = schema.Compile(compilationParams);

            File.WriteAllText(outputSchemaFileName, compiledSchema);

            if (args.IncludeMethodsImplementation)
            {
                string compiledSchemaMethodsImpl = schema.CompileMethodsImpl(compilationParams);
                File.WriteAllText(outputSchemaMethodsImplFileName, compiledSchemaMethodsImpl);
            }

            Console.WriteLine("Compilation done successfully.");
        }
Пример #4
0
        public void Should_compile_TL_schema()
        {
            string sharpTLSchemaCode = TLSchema.CompileFromJson(GetTestTLJsonSchema(), new CompilationParams("SharpTL.TestNamespace"));

            sharpTLSchemaCode.Should().NotBeNullOrEmpty();
        }