//---------------------------------------------------------------------------------
// Microsoft (R) .NET Services
// Software Development Kit
// 
// Copyright (c) Microsoft Corporation. All rights reserved.  
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 
//---------------------------------------------------------------------------------

namespace Microsoft.ServiceBus.Samples
{
    using System;
    using System.Collections.Generic;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using System.ServiceModel.Syndication;
    using System.ServiceModel.Web;
    using System.Net;
    
    [ServiceBehavior(Name = "SyndicationService", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
    class SyndicationService : SyndicationContract
    {
        public Rss20FeedFormatter GetFeed()
        {
            string msg = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["msg"];
            if (string.IsNullOrEmpty(msg))
                Console.WriteLine("Empty request");
            else
                Console.WriteLine(msg);

            List<SyndicationItem> list = new List<SyndicationItem>();

            list.Add(new SyndicationItem("Topic 1", "What is a Service Bus?", new Uri("http://azure.com/")));
            list.Add(new SyndicationItem("Topic 2", "Connectivity challenges", new Uri("http://azure.com/")));
            list.Add(new SyndicationItem("Topic 3", "Service Bus naming", new Uri("http://azure.com/")));
            list.Add(new SyndicationItem("Topic 4", "Service registry and discovery", new Uri("http://azure.com/")));
            list.Add(new SyndicationItem("Topic 5", "Messaging, connectivity, and events", new Uri("http://azure.com/")));
            list.Add(new SyndicationItem("Topic 6", "Access Control Service", new Uri("http://azure.com/")));

            SyndicationFeed feed = new SyndicationFeed("Building Federated Solutions on the Service Bus",
                "Software+Services, what can be better?",
                new Uri("http://azure.com/"),
                list);

            return new Rss20FeedFormatter(feed);
        }
    }
}
