Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public override void ExecuteResult(ControllerContext context)
        {
            if (HttpContext.Current != null)
            {
                var instanceScript = HttpContext.Current.Items[ResourceManager.INSTANCESCRIPT];
                if (instanceScript != null)
                {
                    this.Script = instanceScript.ToString() + (this.Script ?? "");
                }
            }

            if (!string.IsNullOrEmpty(this.Script))
            {
                this.Script = string.Concat("<string>", this.Script);
            }

            if (this.IsUpload)
            {
                context.HttpContext.Response.Write("<textarea>{0}</textarea>".FormatWith(new ClientConfig().Serialize(this)));
            }
            else
            {
                CompressionUtils.GZipAndSend(new ClientConfig().Serialize(this));
            }
        }
Example #2
0
 public virtual void Return()
 {
     if (!this.IsUpload && !this.NativeUpload)
     {
         CompressionUtils.GZipAndSend(this);
     }
     else
     {
         HttpContext.Current.Response.Write(this.ToString());
     }
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public override void ExecuteResult(ControllerContext context)
 {
     if (this.IsUpload)
     {
         context.HttpContext.Response.Write("<textarea>{0}</textarea>".FormatWith(new ClientConfig().Serialize(this)));
     }
     else
     {
         CompressionUtils.GZipAndSend(new ClientConfig().Serialize(this));
     }
 }
 public virtual void Return()
 {
     if (!this.IsUpload && !this.NativeUpload)
     {
         CompressionUtils.GZipAndSend(this.ToString(), "application/json");
     }
     else
     {
         HttpContext.Current.Response.ContentType = "text/html";
         HttpContext.Current.Response.Write(this.ToString());
     }
 }
Example #5
0
        public override void ExecuteResult(ControllerContext context)
        {
            JObject result   = new JObject();
            JObject response = new JObject();

            result["actionSuccess"] = this.Accept;

            if (this.RefusalMessage.IsNotEmpty())
            {
                result["message"] = this.RefusalMessage;
            }

            if (this.Attributes != null)
            {
                response["attributes"] = new JRaw(JSON.Serialize(this.Attributes));
            }

            if (this.Value != null)
            {
                if (this.Value is string)
                {
                    response["value"] = this.Value.ToString();
                }
                else
                {
                    response["value"] = new JRaw(JSON.Serialize(this.Value));
                }
            }

            if (this.NodeID != null)
            {
                response["id"] = this.NodeID;
            }

            if (response.Count > 0)
            {
                result["response"] = response;
            }

            CompressionUtils.GZipAndSend(result.ToString(Newtonsoft.Json.Formatting.None));
        }
Example #6
0
 public static void Render(AbstractComponent component)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToConfig(component, true));
 }
Example #7
0
        public override void ProcessRequest(HttpContext context)
        {
            this.context = context;

            string file = this.context.Request.RawUrl;

            bool isInitScript = file.Contains("extnet/extnet-init-js/ext.axd?");

            if ((!isInitScript && !ResourceHandler.IsSourceModified(context.Request)) || (isInitScript && !string.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"])))
            {
                context.Response.SuppressContent   = true;
                context.Response.StatusCode        = 304;
                context.Response.StatusDescription = "Not Modified";
                context.Response.AddHeader("Content-Length", "0");
                return;
            }

            this.SetResponseCache(context);

            if (isInitScript)
            {
                string key = file.RightOfRightmostOf('?');

                if (key.IsNotEmpty())
                {
                    try
                    {
                        string script = this.context.Application[key].ToString();
                        this.context.Application.Remove(key);
                        CompressionUtils.GZipAndSend(script);
                    }
                    catch (NullReferenceException)
                    {
                        throw new InitializationScriptNotFoundException("The Ext.NET initialization script was not found.");
                    }
                }
            }
            else
            {
                try
                {
                    this.sm       = new ResourceManager();
                    this.compress = CompressionUtils.IsGZipSupported && this.sm.GZip;

                    this.SetWebResourceName(file);

                    this.stream = this.GetType().Assembly.GetManifestResourceStream(this.webResource);
                    string ext = this.webResource.RightOfRightmostOf('.');
                    this.compress = this.compress && !this.IsImage(ext);

                    switch (ext)
                    {
                    case "js":
                        this.WriteFile("text/javascript");
                        break;

                    case "css":
                        this.WriteFile("text/css");
                        break;

                    case "gif":
                        this.WriteImage("image/gif");
                        break;

                    case "png":
                        this.WriteImage("image/png");
                        break;

                    case "jpg":
                    case "jpeg":
                        this.WriteImage("image/jpg");
                        break;
                    }
                }
                catch (Exception e)
                {
                    string s = this.IsDebugging ? e.ToString() : e.Message;
                    context.Response.StatusDescription = s.Substring(0, Math.Min(s.Length, 512));
                    this.context.Response.Redirect(Page.ClientScript.GetWebResourceUrl(this.sm.GetType(), this.webResource));
                }
                finally
                {
                    if (this.stream != null)
                    {
                        this.stream.Close();
                    }
                }
            }
        }
Example #8
0
 public override void ExecuteResult(ControllerContext context)
 {
     CompressionUtils.GZipAndSend(new ClientConfig().Serialize(this));
 }
 public static void Render(UserControl userControl)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToJson(userControl));
 }
Example #10
0
 public static void Render(IEnumerable <AbstractComponent> components, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender, bool registerResources)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToConfig(components, componentPreRender, registerResources));
 }
Example #11
0
 public virtual void Return()
 {
     CompressionUtils.GZipAndSend(this.Serialize());
 }
Example #12
0
        public override void ProcessRequest(HttpContext context)
        {
            this.context = context;

            string file = this.context.Request.RawUrl;

            if (file.Contains("coolite/coolite-init-js/coolite.axd?"))
            {
                string key = StringUtils.RightOfRightmostOf(file, '?');

                if (!string.IsNullOrEmpty(key))
                {
                    try
                    {
                        string script = this.context.Session[key].ToString();
                        this.context.Session.Remove(key);
                        CompressionUtils.GZipAndSend(script);
                    }
                    catch (NullReferenceException)
                    {
                        throw new InitializationScriptNotFoundException("The Coolite initialization script was not found.");
                    }
                }
            }
            else
            {
                this.SetResponseCache(context);

                this.sm = new ScriptManager();

                this.SetWebResourceName(file);

                if (CompressionUtils.IsGZipSupported && this.sm.GZip)
                {
                    try
                    {
                        this.stream = this.GetType().Assembly.GetManifestResourceStream(this.webResource);

                        switch (StringUtils.RightOfRightmostOf(this.webResource, '.'))
                        {
                        case "js":
                            this.WriteFile("text/javascript");
                            break;

                        case "css":
                            this.WriteFile("text/css");
                            break;

                        case "gif":
                            this.WriteImage("image/gif");
                            break;

                        case "png":
                            this.WriteImage("image/png");
                            break;

                        case "jpg":
                        case "jpeg":
                            this.WriteImage("image/jpg");
                            break;
                        }
                    }
                    catch
                    {
                        this.context.Response.Redirect(Page.ClientScript.GetWebResourceUrl(this.sm.GetType(), this.webResource));
                    }
                    finally
                    {
                        if (this.stream != null)
                        {
                            this.stream.Close();
                        }
                    }
                }
                else
                {
                    this.context.Response.Redirect(Page.ClientScript.GetWebResourceUrl(this.sm.GetType(), this.webResource));
                }
            }
        }
Example #13
0
 public virtual void Return()
 {
     CompressionUtils.GZipAndSend(new ClientConfig().Serialize(this));
 }
Example #14
0
 public static void Render(AbstractComponent component, bool registerResources)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToConfig(component, registerResources));
 }
 public static void Render(AbstractComponent component)
 {
     CompressionUtils.GZipAndSend(component.ToConfig());
 }
Example #16
0
 public static void Render(IEnumerable <AbstractComponent> components, bool registerResources)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToConfig(components, registerResources));
 }
Example #17
0
 public virtual void Return()
 {
     CompressionUtils.GZipAndSend(this);
 }
Example #18
0
 public static void Render(UserControl userControl, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender, bool registerResources)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToConfig(userControl, componentPreRender, registerResources));
 }
 public static void Render(IEnumerable <AbstractComponent> components)
 {
     CompressionUtils.GZipAndSend(ComponentLoader.ToJson(components));
 }