Exemple #1
0
        public static JsonType GetCommonType(IJsonClassGeneratorConfig generator, JToken[] tokens)
        {
            if (tokens.Length == 0)
            {
                return(new JsonType(generator, JsonTypeEnum.NonConstrained));
            }

            var common = new JsonType(generator, tokens[0]).MaybeMakeNullable(generator);

            for (int i = 1; i < tokens.Length; i++)
            {
                var current = new JsonType(generator, tokens[i]);
                common = common.GetCommonType(current);
            }

            return(common);
        }
Exemple #2
0
        public static JsonType GetCommonType(IJsonClassGeneratorConfig generator, JToken[] tokens)
        {
            if (tokens.Length == 0) return new JsonType(generator, JsonTypeEnum.NonConstrained);

            var common = new JsonType(generator, tokens[0]).MaybeMakeNullable(generator);

            for (int i = 1; i < tokens.Length; i++)
            {
                var current = new JsonType(generator, tokens[i]);
                common = common.GetCommonType(current);
            }

            return common;
        }