Ejemplo n.º 1
0
        public void Test_UnderlineToUpper()
        {
            var str = "a_bc_de_f";
            var r   = ConvertExtend.UnderlineToUpper(str);

            _output.WriteLine(r);
            Assert.True(r == "ABcDeF");
        }
Ejemplo n.º 2
0
        static void GetPddParamStereoscopic(
            PddRequestparamlist item,
            PddRequestparamlist[] all,
            string className,
            string spacing,
            bool isRequest,
            ref StringBuilder code)
        {
            code.AppendLine($"{spacing}/// <summary>");
            if (item.isMust != -1 && isRequest)
            {
                code.AppendLine($"{spacing}/// {(item.isMust == 0 ? "不必填" : "必填")}");
            }
            code.AppendLine($"{spacing}/// {item.paramDesc}");
            if (isRequest && !string.IsNullOrWhiteSpace(item.defaultValue))
            {
                code.AppendLine($"{spacing}/// 默认值:{item.defaultValue}");
            }
            if (!string.IsNullOrWhiteSpace(item.example))
            {
                code.AppendLine($"{spacing}/// 例如:{item.example}");
            }
            code.AppendLine($"{spacing}/// </summary>");

            var currentNodes = all.Where(x => x.parentId == item.id).ToArray();

            if (currentNodes.Any())
            {
                var tempName   = string.Join("", item.paramName.Split('_').Select(UpperFirst));
                var tempSymbol = item.paramType.Replace("OBJECT", "");
                if (!isRequest)
                {
                    code.AppendLine($"{spacing}[JsonProperty(\"{item.paramName}\")]");
                }
                code.AppendLine($"{spacing}public {className}_{tempName}{tempSymbol} {ConvertExtend.UnderlineToUpper(item.paramName)} {{ get; set; }}");
                code.AppendLine($"{spacing}/// <summary>");
                code.AppendLine($"{spacing}/// {item.paramDesc}");
                code.AppendLine($"{spacing}/// </summary>");
                code.AppendLine($"{spacing}public class {className}_{tempName}");
                code.AppendLine($"{spacing}{{");
                foreach (var that in currentNodes)
                {
                    GetPddParamStereoscopic(
                        that,
                        all,
                        className,
                        spacing + "    ",
                        isRequest,
                        ref code);
                }
                code.AppendLine($"{spacing}}}");
            }
            else
            {
                if (!isRequest)
                {
                    code.AppendLine($"{spacing}[JsonProperty(\"{item.paramName}\")]");
                }
                code.AppendLine($"{spacing}public {SwitchType(item.paramType)} {ConvertExtend.UnderlineToUpper(item.paramName)} {{ get; set; }}");
            }
        }