private string CreateAnchorHtml(Uri requestUri, BusinessKindModel e, BusinessMethodModel model, List<string> plist, HttpMethod mode, string format)
        {
            string url = string.Empty;
            if (mode == HttpMethod.GET && plist.Count > 0)
                url = string.Format("/{0}.{1}.{2}?{3}", e.Name, model.Name, format, string.Join("&", plist.ToArray()));
            else
                url = string.Format("/{0}.{1}.{2}", e.Name, model.Name, format);

            if (!string.IsNullOrEmpty(requestUri.Query))
            {
                if (url.IndexOf('?') >= 0)
                    url += "&" + requestUri.Query.Substring(1);
                else
                    url += requestUri.Query;
            }

            if (format == "jsonp")
            {
                if (url.IndexOf('?') >= 0)
                    url += "&callback={callback}";
                else
                    url += "?callback={callback}";
            }

            return string.Format("<a rel=\"operation\" target=\"_blank\" title=\"{0}\" href=\"{0}\">{0}</a> 处的服务", url);
        }
        /// <summary>
        /// 生成API文档
        /// </summary>
        /// <returns></returns>
        public string MakeDocument(Uri requestUri, string kind, string method)
        {
            #region 读取资源

            Assembly assm = this.GetType().Assembly;
            Stream helpStream = assm.GetManifestResourceStream("MySoft.RESTful.Template.help.htm");
            Stream helpitemStream = assm.GetManifestResourceStream("MySoft.RESTful.Template.helpitem.htm");

            StreamReader helpReader = new StreamReader(helpStream);
            StreamReader helpitemReader = new StreamReader(helpitemStream);

            string html = helpReader.ReadToEnd(); helpReader.Close();
            string item = helpitemReader.ReadToEnd(); helpitemReader.Close();

            #endregion

            string uri = string.Format("http://{0}/", requestUri.Authority.Replace("127.0.0.1", DnsHelper.GetIPAddress()));
            html = html.Replace("${uri}", uri);

            var sb = new StringBuilder();
            foreach (BusinessKindModel e in pool.KindMethods.Values.OrderBy(p => p.Name).ToList())
            {
                sb.AppendFormat("<a href='/help/{0}' title='{1}'>{0}</a>", e.Name, e.Description);
                sb.AppendFormat("&nbsp;&nbsp;");
            }

            html = html.Replace("${kind}", sb.ToString());

            StringBuilder table = new StringBuilder();
            List<BusinessKindModel> list = new List<BusinessKindModel>();
            if (string.IsNullOrEmpty(kind))
            {
                list.AddRange(pool.KindMethods.Values);
            }
            else
            {
                var model = pool.GetKindModel(kind);
                if (model != null)
                {
                    if (string.IsNullOrEmpty(method))
                    {
                        list.Add(model);
                    }
                    else
                    {
                        var m = model.MethodModels.Values.Where(p => string.Compare(p.Name, method, true) == 0).FirstOrDefault();
                        if (m != null)
                        {
                            var mod = new BusinessKindModel
                            {
                                Name = model.Name,
                                Description = model.Description
                            };
                            mod.MethodModels.Add(m.Name, m);
                            list.Add(mod);
                        }
                        else
                        {
                            table.Append("<tr><td colspan=\"5\" style=\"padding: 30px 300px 30px 300px; text-align: center;\">没有匹配到指定方法的服务!</td></tr>");
                        }
                    }
                }
                else
                {
                    table.Append("<tr><td colspan=\"5\" style=\"padding: 30px 300px 30px 300px; text-align: center;\">没有匹配到指定类型的服务!</td></tr>");
                }
            }

            var kinds = list.OrderBy(p => p.Name).ToList();
            foreach (BusinessKindModel e in kinds)
            {
                StringBuilder items = new StringBuilder();
                var methods = e.MethodModels.Values.OrderBy(p => p.Name).ToList();
                foreach (BusinessMethodModel model in methods)
                {
                    string template = item;
                    var tempStr = string.Format("<a href='/help/{0}/{1}'>{0}.{2}</a> [<font color='red'>{4}</font>]<br/>{3}", e.Name, model.Name, model.Name, model.Description, model.ParametersCount);
                    template = template.Replace("${method}", tempStr);

                    var plist = new List<string>();
                    foreach (var p in model.Parameters)
                    {
                        if (CoreHelper.CheckPrimitiveType(p.ParameterType))
                        {
                            plist.Add(string.Format("{0}=[{0}]", p.Name.ToLower()).Replace('[', '{').Replace(']', '}'));
                        }
                    }

                    string strParameter = GetMethodParameter(model, kind, method);
                    if (string.IsNullOrEmpty(strParameter))
                        template = template.Replace("${parameter}", "&nbsp;");
                    else
                        template = template.Replace("${parameter}", strParameter);

                    template = template.Replace("${type}", model.HttpMethod == HttpMethod.GET ? "GET<br/>POST" : "<font color='red'>POST</font>");
                    template = template.Replace("${auth}", model.Authorized ? "<font color='red'>是</font>" : "&nbsp;");

                    StringBuilder anchor = new StringBuilder();
                    anchor.Append(CreateAnchorHtml(requestUri, e, model, plist, model.HttpMethod, "xml"));
                    anchor.Append("<br/>");
                    anchor.Append(CreateAnchorHtml(requestUri, e, model, plist, model.HttpMethod, "json"));
                    if (model.HttpMethod == HttpMethod.GET)
                    {
                        anchor.Append("<br/>");
                        anchor.Append(CreateAnchorHtml(requestUri, e, model, plist, model.HttpMethod, "jsonp"));

                        if (model.Method.ReturnType == typeof(string))
                        {
                            anchor.Append("<br/>");
                            anchor.Append(CreateAnchorHtml(requestUri, e, model, plist, model.HttpMethod, "text"));
                            anchor.Append("<br/>");
                            anchor.Append(CreateAnchorHtml(requestUri, e, model, plist, model.HttpMethod, "html"));
                        }
                    }

                    template = template.Replace("${uri}", anchor.ToString());
                    items.Append(template);
                }

                table.Append(items.ToString());
            }

            return html.Replace("${body}", table.ToString());
        }