Microsoft.ServiceModel.Web.HelpPageInvoker.GetFeed C# (CSharp) Method

GetFeed() public method

public GetFeed ( ) : System.ServiceModel.Syndication.Atom10FeedFormatter
return System.ServiceModel.Syndication.Atom10FeedFormatter
        public Atom10FeedFormatter GetFeed()
        {
            List<SyndicationItem> items = new List<SyndicationItem>();
            foreach (OperationDescription od in this.Description.Operations)
            {
                WebGetAttribute get;
                WebInvokeAttribute invoke;
                GetWebGetAndInvoke(od, out get, out invoke);    
                string method = GetMethod(get, invoke);
                string requestFormat = null;
                if (invoke != null)
                {
                    requestFormat = GetRequestFormat(invoke, od);
                }
                string responseFormat = GetResponseFormat(get, invoke, od);
                string uriTemplate = GetUriTemplate(get, invoke, od);
                WebMessageBodyStyle bodyStyle = GetBodyStyle(get, invoke);

                string requestSchemaLink = null;
                string responseSchemaLink = null;
                string requestExampleLink = null;
                string responseExampleLink = null;

                if (bodyStyle == WebMessageBodyStyle.Bare)
                {
                    UriTemplate responseSchemaTemplate = new UriTemplate(OperationResponseSchemaTemplate);
                    responseSchemaLink = responseSchemaTemplate.BindByPosition(this.BaseUri, od.Name).AbsoluteUri;

                    UriTemplate responseExampleTemplate = new UriTemplate(OperationResponseExampleTemplate);
                    responseExampleLink = responseExampleTemplate.BindByPosition(this.BaseUri, od.Name).AbsoluteUri;
                    if (invoke != null)
                    {
                        UriTemplate requestSchemaTemplate = new UriTemplate(OperationRequestSchemaTemplate);
                        requestSchemaLink = requestSchemaTemplate.BindByPosition(this.BaseUri, od.Name).AbsoluteUri;

                        UriTemplate requestExampleTemplate = new UriTemplate(OperationRequestExampleTemplate);
                        requestExampleLink = requestExampleTemplate.BindByPosition(this.BaseUri, od.Name).AbsoluteUri;
                    }
                }

                uriTemplate = String.Format("{0}/{1}", this.BaseUri.AbsoluteUri, uriTemplate);
                uriTemplate = HttpUtility.HtmlEncode(uriTemplate);

                string xhtmlDescription = String.Format("<div xmlns=\"http://www.w3.org/1999/xhtml\"><table border=\"5\"><tr><td>UriTemplate</td><td>{0}</td></tr><tr><td>Method</td><td>{1}</td></tr>", uriTemplate, method);
                if (!string.IsNullOrEmpty(requestFormat))
                {
                    xhtmlDescription += String.Format("<tr><td>Request Format</td><td>{0}</td></tr>", requestFormat);
                }
                if (requestSchemaLink != null)
                {
                    xhtmlDescription += String.Format("<tr><td>Request Schema</td><td><a href=\"{0}\">{0}</a></td></tr>", HttpUtility.HtmlEncode(requestSchemaLink));
                }
                if (requestExampleLink != null)
                {
                    xhtmlDescription += String.Format("<tr><td>Request Example</td><td><a href=\"{0}\">{0}</a></td></tr>", HttpUtility.HtmlEncode(requestExampleLink));
                }
                xhtmlDescription += String.Format("<tr><td>Response Format</td><td>{0}</td></tr>", responseFormat);
                if (responseSchemaLink != null)
                {
                    xhtmlDescription += String.Format("<tr><td>Response Schema</td><td><a href=\"{0}\">{0}</a></td></tr>", HttpUtility.HtmlEncode(responseSchemaLink));
                }
                if (responseExampleLink != null)
                {
                    xhtmlDescription += String.Format("<tr><td>Response Example</td><td><a href=\"{0}\">{0}</a></td></tr>", HttpUtility.HtmlEncode(responseExampleLink));
                }
                WebHelpAttribute help = od.Behaviors.Find<WebHelpAttribute>();
                if (help != null && !string.IsNullOrEmpty(help.Comment))
                {
                    xhtmlDescription += String.Format("<tr><td>Description</td><td>{0}</td></tr>", help.Comment);
                }
                xhtmlDescription += "</table></div>";
                SyndicationItem item = new SyndicationItem()
                {
                    Id = "http://tmpuri.org/" + od.Name,
                    Content = new TextSyndicationContent(xhtmlDescription, TextSyndicationContentKind.XHtml),
                    LastUpdatedTime = DateTime.UtcNow,
                    Title = new TextSyndicationContent(String.Format("{0}: {1}", Description.Name, od.Name)),
                };
                items.Add(item);
            }

            SyndicationFeed feed = new SyndicationFeed()
            {
                Title = new TextSyndicationContent("Service help page"),
                Id = feedId,
                LastUpdatedTime = DateTime.UtcNow,
                Items = items
            };
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/atom+xml";
            return feed.GetAtom10Formatter();
        }