﻿namespace NCombinr.HttpHandler
{
    using System;
    using System.Threading.Tasks;
    using System.Web;

    public abstract class BaseHttpTaskAsyncHandler
        : HttpTaskAsyncHandler
    {
        public override bool IsReusable
        {
            get { return true; }
        }

        public abstract Task HandleRequestAsync(HttpContextBase context);

        public override async Task ProcessRequestAsync(HttpContext context)
        {
            var ctx = new HttpContextWrapper(context);
            await this.HandleRequestAsync(ctx);
        }

        public override void ProcessRequest(HttpContext context)
        {
            throw new NotImplementedException("The synchronous method ProcessRequest is not implemented. Use ProcessRequestAsync instead.");
        }
    }
}