// // Creates a synchronized wrapper around the Hashtable. // protected Hashtable data = null; /// <summary> /// Each command will execute its action in the constructor. /// After execution, the command must reference itself in the /// Web request context (so that the web site, and the user controls /// can know which command just executed, and what data it holds). /// </summary> /// <param name="ctx"></param> public AbstractWebAction(HttpContext ctx) { context = ctx; singleton = WebLocalSingleton.GetInstance(context); singleton.CurrentAction = this; // data = Hashtable.Synchronized( _data ); }
/// <summary> /// /// </summary> /// <param name="ctx"></param> /// <remarks>Call it with HttpContext.Current.ApplicationInstance.Context.</remarks> /// <returns></returns> public static WebLocalSingleton GetInstance(HttpContext ctx) { WebLocalSingleton singleton = ctx.Items[WebConstants.SINGLETON_KEY] as WebLocalSingleton; if (singleton == null) { lock (_synRoot) { if (singleton == null) { singleton = new WebLocalSingleton(ctx); ctx.Items[WebConstants.SINGLETON_KEY] = singleton; } } } return(singleton); }