Esempio n. 1
0
        private void LoadFromJObject(TypeScriptParameter parameter, JObject jobject)
        {
            if (jobject.TryGetValue("name", out var nameTokent))
            {
                parameter.Name = nameTokent.ToString();
            }

            if (jobject.TryGetValue("flags", out var flagsToken))
            {
                var flagsObj = flagsToken.ToObject <JObject>();

                if (flagsObj.TryGetValue("isOptional", out var isOptionalToken))
                {
                    parameter.IsOptional = isOptionalToken.ToObject <bool>();
                }
            }

            if (jobject.TryGetValue("type", out var typeToken))
            {
                parameter.Type = LoadTypeFromJObject(typeToken.ToObject <JObject>());
            }

            if (jobject.TryGetValue("defaultValue", out var defValToken))
            {
                parameter.DefaultValue = defValToken.ToString();
            }

            if (jobject.TryGetValue("comment", out var commentToken))
            {
                parameter.Comment = new TypeScriptComment();
                LoadFromJObject(parameter.Comment, commentToken.ToObject <JObject>());
            }
        }
Esempio n. 2
0
        private void LoadFromJObject(TypeScriptSignature signature, JObject jobject)
        {
            if (jobject.TryGetValue("name", out var nameToken))
            {
                signature.Name = nameToken.ToString();
            }

            if (jobject.TryGetValue("parameters", out var parametersToken))
            {
                var parameterObjs = parametersToken.ToObject <List <JObject> >();

                foreach (var paramObj in parameterObjs)
                {
                    var parameter = new TypeScriptParameter();
                    LoadFromJObject(parameter, paramObj);
                    signature.Parameters.Add(parameter);
                }
            }

            if (jobject.TryGetValue("type", out var typeToken))
            {
                signature.Type = LoadTypeFromJObject(typeToken.ToObject <JObject>());
            }

            if (jobject.TryGetValue("comment", out var commentToken))
            {
                signature.Comment = new TypeScriptComment();
                LoadFromJObject(signature.Comment, commentToken.ToObject <JObject>());
            }
        }
Esempio n. 3
0
        private string ParameterInfo(TypeScriptParameter param)
        {
            var result = param.Name + ": " + param.Type.Format(_lib);

            if (param.IsOptional)
            {
                result += ", " + MarkdownBuilder.MarkdownItalic("Optional") + " ";
            }
            else if (param.IsRest)
            {
                result += ", " + MarkdownBuilder.MarkdownItalic("Rest") + " ";
            }
            else if (param.DefaultValue != null)
            {
                result += ", " + MarkdownBuilder.MarkdownItalic("Default value") + " = " + MarkdownBuilder.MarkdownCodeQuote(param.DefaultValue);;
            }

            return(result);
        }