public static TLSchema FromJson(string schemaText)
        {
            var typesBox = new TLTypesBox();

            JsonObject tlSchemaJsonObject = JsonObject.Parse(schemaText);

            IEnumerable<TLCombinator> constructors = CreateConstructorsFromJsonArrayObjects(tlSchemaJsonObject.ArrayObjects("constructors"), typesBox);
            IEnumerable<TLCombinator> methods = CreateMethodsFromJsonArrayObjects(tlSchemaJsonObject.ArrayObjects("methods"), typesBox);

            return new TLSchema(constructors, methods);
        }
        private static IEnumerable<TLCombinator> CreateCombinatorsFromJsonArrayObjects(JsonArrayObjects objects, string nameKey, TLTypesBox typesBox)
        {
            return
                objects.ConvertAll(
                    x =>
                        new TLCombinator(x.Get(nameKey))
                        {
                            Number = (uint) x.JsonTo<int>("id"),
                            Parameters =
                                x.ArrayObjects("params")
								.ConvertAll(param => new TLCombinatorParameter(param.Get("name"),param.Get("type")) {Type = typesBox[param.Get("type")]}),
                            Type = typesBox[x.Get("type")]
                        }).Where(combinator => !HasBuiltInSerializer(combinator.Number)).ToList();
        }
        /// <summary>
        ///     Compile TL-schema to C# object model.
        /// </summary>
        /// <param name="schemaText">TL-schema.</param>
        /// <returns>Compiled TL-schema.</returns>
        public static TLSchema FromTL(string schemaText)
        {
            // TODO: implement.
            throw new NotImplementedException();

            var typesCache = new TLTypesBox();

            IEnumerable<TLCombinator> constructors = new List<TLCombinator>();
            IEnumerable<TLCombinator> methods = new List<TLCombinator>();

            schemaText = RemoveComments(schemaText);
            schemaText = RemoveNewlines(schemaText);

            Match partsMatch = TLSchemaPartsRegex.Match(schemaText);
            if (!partsMatch.Success)
            {
                throw new InvalidTLSchemaException();
            }
            string typesPart = partsMatch.Groups["Types"].Value.Trim();
            string functionsPart = partsMatch.Groups["Functions"].Value.Trim();

            foreach (Match declarationMatch in DeclarationRegex.Matches(typesPart))
            {
                string declarationText = declarationMatch.Groups["Declaration"].Value.Trim();
                uint combinatorNumber = Crc32.Compute(declarationText, Encoding.UTF8);

                var declaration = new TLCombinator(declarationMatch.Groups["CombinatorName"].Value.Trim());

                Group combinatorNumberMatch = declarationMatch.Groups["CombinatorNumber"];
                declaration.Number = combinatorNumberMatch.Success ? Convert.ToUInt32(combinatorNumberMatch.Value, 16) : combinatorNumber;

                Group parametersMatch = declarationMatch.Groups["Parameters"];
                if (parametersMatch.Success)
                {
                }
            }

            return new TLSchema(constructors, methods);
        }
 private static IEnumerable<TLCombinator> CreateMethodsFromJsonArrayObjects(JsonArrayObjects objects, TLTypesBox typesBox)
 {
     return CreateCombinatorsFromJsonArrayObjects(objects, "method", typesBox);
 }
 private static IEnumerable<TLCombinator> CreateConstructorsFromJsonArrayObjects(JsonArrayObjects objects, TLTypesBox typesBox)
 {
     return CreateCombinatorsFromJsonArrayObjects(objects, "predicate", typesBox);
 }