using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Collections;
using System.Reflection;
using System.IO;


namespace Westwind.Web.Controls
{
    /// <summary>
    /// wwCallbackHandler is an Http Handler base class that allows you to create a
    ///  class with methods marked up with a [CallbackMethod] attribute which are 
    /// then exposed for remote execution. The handler routes the to the methods 
    /// and executes the call and returns the results - or any errors - as JSON 
    /// strings.
    /// 
    /// To use this service you need to create an HttpHandler (either .ASHX or a 
    /// class registered in web.config's httpHandler section) and then add methods 
    /// with the [CallbackMethod] attribute and that's it. The service accepts 
    /// inputs via query string and POST data.
    /// 
    /// The service automatically supports callbacks by the wwMethodCallback server
    ///  and wwMethodCallback client controls which use a specific POST format. 
    /// Plain REST calls can also be made with the following URL syntax:
    /// 
    /// MyHandler.ashx?Method=MethodToCall
    /// 
    /// POST data can then be passed in to act as parameters:
    /// 
    /// &lt;&lt;ul&gt;&gt;
    /// &lt;&lt;li&gt;&gt; &lt;&lt;b&gt;&gt;Raw Post Buffer&lt;&lt;/b&gt;&gt;
    /// You simply pass raw POST data that you can access with Request.Form in the 
    /// handler
    /// 
    /// &lt;&lt;li&gt;&gt; &lt;&lt;b&gt;&gt;JSON value or object 
    /// string&lt;&lt;/b&gt;&gt;
    /// Alternately you can set the content type to application/json and pass a 
    /// JSON string of a value or object which calls the server method with a 
    /// single parameter of matching type.
    /// &lt;&lt;/ul&gt;&gt;
    /// 
    /// For more information on how to call these handlers see 
    /// <see cref="_24I0VDWUR">Using wwCallbackHandler with REST Calls</see>.
    /// </summary>
    public class CallbackHandler : IHttpHandler
    {
        /// <summary>
        /// This handler is not thread-safe
        /// </summary>
        public bool IsReusable
        {
            get { return true; }
        }


public void ProcessRequest(HttpContext context)
{
    // *** Pass off to the worker Callback Processor
    ICallbackMethodProcessor processor = new JsonCallbackMethodProcessor();
    
    // *** Process the inbound request and execute it on this 
    // *** Http Handler's methods 
    processor.ProcessCallbackMethodCall(this);            
}


    }
}
