using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Web.SessionState;

namespace FactoriesWeb
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class SaveDataBase : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/xml";
            context.Response.AppendHeader("Content-Disposition", "attachment; filename=database.xml");
            var serializer = new XmlSerializer(typeof(DataBase));
            serializer.Serialize(context.Response.Output, DataBase.GetInstance(context));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
