Esempio n. 1
0
        /// <summary>
        /// 保存代码
        /// </summary>
        /// <param name="path"></param>
        /// <param name="codeType"></param>
        public static void Save(string path, CodeType codeType)
        {
            List <Routing> routings = ApiMapping.GetMapping();

            if (codeType == CodeType.Js)
            {
                SaveJs(path, routings);
            }
            else
            {
                SaveCsharp(path, routings);
            }
        }
Esempio n. 2
0
        public ActionResult GetList()
        {
            var routings = ApiMapping.GetMapping();

            StringBuilder sb = new StringBuilder();

            foreach (var routing in routings)
            {
                var pas = "";
                if (routing.ParmaTypes != null && routing.ParmaTypes.Any())
                {
                    foreach (var item in routing.ParmaTypes)
                    {
                        if (item.Value.IsClass && !item.Value.IsSealed)
                        {
                            var ppts = item.Value.GetProperties();
                            foreach (var ppt in ppts)
                            {
                                if (ppt.PropertyType == typeof(string))
                                {
                                    pas += ("'',");
                                }
                                else
                                {
                                    pas += ("0,");
                                }
                            }
                        }
                        else
                        {
                            if (item.Value == typeof(string))
                            {
                                pas += ("'',");
                            }
                            else
                            {
                                pas += ("0,");
                            }
                        }
                    }
                    sb.Append($"<div><a href='javascript:;' onclick=\"new SaeaApiSdk().{routing.Instance.GetType().Name.Replace("Controller", "")}{routing.ActionName}{(routing.IsPost ? "Post" : "Get")}({pas}function(data){{alert(data);}},function(e){{alert(e);}})\">/api/{routing.Instance.GetType().Name.Replace("Controller", "")}/{routing.ActionName}</a></div>");
                }
                else
                {
                    sb.Append($"<div><a href='javascript:;' onclick='new SaeaApiSdk().{routing.Instance.GetType().Name.Replace("Controller", "")}{routing.ActionName}{(routing.IsPost ? "Post" : "Get")}(function(data){{alert(data);}},function(e){{alert(e);}})'>/api/{routing.Instance.GetType().Name.Replace("Controller", "")}/{routing.ActionName}</a></div>");
                }
            }

            return(Content(sb.ToString()));
        }