Example #1
0
 public static T Deserialize <T>(string value, List <JsonConverter> converters)
 {
     return((T)JSON.Deserialize(value, typeof(T), converters, null));
 }
 public static Config Deserialize(string config)
 {
     return(JSON.Deserialize <Config>(config));
 }
Example #3
0
        public void SetActive(bool active)
        {
            RequestManager.EnsureDirectEvent();

            this.AddScript("{0}.getFilter({1}).setActive({2});", this.Plugin.ClientID, JSON.Serialize(this.DataIndex), JSON.Serialize(active));
        }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="moduleId"></param>
 /// <param name="hidden"></param>
 public virtual void SetShortcutHidden(string moduleId, bool hidden)
 {
     if (hidden)
     {
         this.AddScript("{0}.desktop.shortcuts.remove({0}.desktop.shortcuts.getById({1}));", this.ClientID, JSON.Serialize(moduleId));
     }
     else
     {
         this.AddScript("{0}.desktop.shortcuts.add({0}.getModule({1}).shortcut);", this.ClientID, JSON.Serialize(moduleId));
     }
 }
Example #5
0
 /// <summary>
 /// Create a cookie with the specified name and value. Additional settings for the cookie may be optionally specified (for example: expiration, access restriction, SSL).
 /// </summary>
 /// <param name="name">The name of the cookie to set.</param>
 /// <param name="value">The value to set for the cookie.</param>
 /// <param name="expires">Specify an expiration date the cookie is to persist until. Note that the specified Date object will be converted to Greenwich Mean Time (GMT).</param>
 /// <param name="path">Setting a path on the cookie restricts access to pages that match that path. Defaults to all pages ('/').</param>
 /// <param name="domain">Setting a domain restricts access to pages on a given domain (typically used to allow cookie access across subdomains). For example, "ext.net" will create a cookie that can be accessed from any subdomain of ext.net, including www.ext.net, support.ext.net, etc.</param>
 /// <param name="secure">Specify true to indicate that the cookie should only be accessible via SSL on a page using the HTTPS protocol. Defaults to false. Note that this will only work if the page calling this code uses the HTTPS protocol, otherwise the cookie will be created with default options.</param>
 public static void Set(string name, object value, DateTime expires, string path, string domain, bool secure)
 {
     new Cookies().Call("set", name, value, new JRawValue(JSON.Serialize(expires, JSON.ScriptConverters)), path, domain, secure);
 }
Example #6
0
        public override void Update(string html)
        {
            string template = "{0}.html={1};if({0}.body){{{0}.body.update({1});}}";

            this.AddScript(template, this.ClientID, JSON.Serialize(html));
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="json"></param>
 /// <param name="mapping"></param>
 /// <returns></returns>
 public static EventModelCollection Deserialize(string json, bool mapping)
 {
     return(JSON.Deserialize <EventModelCollection>(json, mapping ? new EventMappingsContractResolver() : null));
 }
Example #8
0
        public static string ReplaceIDTokens(string script, Control seed)
        {
            script = TokenUtils.ReplaceDirectMethods(script, seed);

            Control control = null;

            string[] parts = null;

            foreach (Match match in ID_Pattern_RE.Matches(script))
            {
                parts = match.Value.Between("{", "}").Split('.');

                control = ControlUtils.FindControl(seed, parts[0]);

                if (control != null)
                {
                    if (parts.Length == 2)
                    {
                        PropertyInfo prop = control.GetType().GetProperty(parts[1]);

                        if (prop != null)
                        {
                            object value = prop.GetValue(control, null);

                            if (value == null)
                            {
                                value = ReflectionUtils.GetDefaultValue(prop);
                            }

                            if (value is string)
                            {
                                string val = TokenUtils.ParseTokens(value.ToString(), control);

                                if (TokenUtils.IsRawToken(val))
                                {
                                    val = JSON.Serialize(TokenUtils.ReplaceRawToken(val)).Chop();
                                }
                                else
                                {
                                    val = JSON.Serialize(val);
                                }

                                script = script.Replace(match.Value, val);
                            }
                            else
                            {
                                script = script.Replace(match.Value, JSON.Serialize(value));
                            }
                        }
                    }
                    else
                    {
                        if (control is Observable || control is UserControl)
                        {
                            script = script.Replace(match.Value, control.ClientID);
                        }
                        else
                        {
                            script = script.Replace(match.Value, "Ext.get(\"" + control.ClientID + "\")");
                        }
                    }
                }
                else
                {
                    script = script.Replace(match.Value, "Ext.get(\"" + parts[0] + "\")");
                }
            }

            return(script);
        }
        public void RaiseAjaxPostBackEvent(string eventArgument, ParameterCollection extraParams)
        {
            bool   success = true;
            string msg     = null;

            Response response = new Response();

            try
            {
                if (eventArgument.IsEmpty())
                {
                    throw new ArgumentNullException("eventArgument");
                }

                string data = null;

                if (this.DirectConfig != null)
                {
                    JToken serviceToken = this.DirectConfig.SelectToken("config.serviceParams", false);

                    if (serviceToken != null)
                    {
                        data = JSON.ToString(serviceToken);
                    }
                }

                switch (eventArgument)
                {
                case "nodeload":
                    //NodeLoadEventArgs e = new NodeLoadEventArgs(extraParams);
                    //PageTreeLoader loader = (PageTreeLoader) this.Loader.Primary;
                    //loader.OnNodeLoad(e);
                    //TreeNodeCollection nodes = e.Nodes;
                    //success = e.Success;
                    //msg = e.ErrorMessage;
                    //response.Data = nodes != null ? nodes.ToJson() : null;
                    break;

                case "submit":
                    SubmitEventArgs se = new SubmitEventArgs(extraParams, JSON.Deserialize <SubmittedNode>(data, new CamelCasePropertyNamesContractResolver()));
                    this.OnSubmit(se);
                    break;

                case "raEdit":
                    RemoteEditEventArgs rr = new RemoteEditEventArgs(data, extraParams);
                    this.OnRemoteEdit(rr);
                    success = rr.Accept;
                    msg     = rr.RefusalMessage;
                    break;

                case "raRemove":
                    RemoteActionEventArgs rrm = new RemoteActionEventArgs(data, extraParams);
                    this.OnRemoteRemove(rrm);
                    success = rrm.Accept;
                    msg     = rrm.RefusalMessage;
                    break;

                case "raInsert":
                case "raAppend":
                    RemoteAppendEventArgs ra = new RemoteAppendEventArgs(eventArgument == "raInsert", data, extraParams);
                    this.OnRemoteAppend(ra);
                    success = ra.Accept;
                    msg     = ra.RefusalMessage;
                    break;

                case "raMove":
                    RemoteMoveEventArgs rm = new RemoteMoveEventArgs(data, extraParams);
                    this.OnRemoteMove(rm);
                    success = rm.Accept;
                    msg     = rm.RefusalMessage;
                    break;
                }
            }
            catch (Exception ex)
            {
                success = false;
                msg     = this.IsDebugging ? ex.ToString() : ex.Message;

                if (this.ResourceManager.RethrowAjaxExceptions)
                {
                    throw;
                }
            }

            response.Success = success;
            response.Message = msg;

            ResourceManager.ServiceResponse = response;
        }
Example #10
0
        public void SetValue(string[] value)
        {
            RequestManager.EnsureDirectEvent();

            this.AddScript("{0}.getFilter({1}).setValue({2});", this.Plugin.ClientID, JSON.Serialize(this.DataIndex), JSON.Serialize(value));
        }
 /// <summary>
 /// Shows the built-in event edit form for the passed in event record. This method automatically hides the calendar views and navigation toolbar. To return to the calendar, call hideEditForm.
 /// </summary>
 /// <param name="id">The event record id to edit</param>
 public void ShowEditForm(object id)
 {
     this.Call("showEditForm", new JRawValue("{1}.store.getById({0})".FormatWith(JSON.Serialize(id), this.ClientID)));
 }
Example #12
0
        public void UpdateOptions(string[] options)
        {
            RequestManager.EnsureDirectEvent();

            this.AddScript("{0}.getFilter({1}).updateOptions({2});", this.Plugin.ClientID, JSON.Serialize(this.DataIndex), JSON.Serialize(options));
        }
Example #13
0
 public static T Deserialize <T>(string value, List <JsonConverter> converters, IContractResolver resolver)
 {
     return((T)JSON.Deserialize(value, typeof(T), converters, resolver));
 }
Example #14
0
 public static T Deserialize <T>(string value, IContractResolver resolver)
 {
     return((T)JSON.Deserialize(value, typeof(T), resolver));
 }
Example #15
0
 /// <summary>
 ///
 /// </summary>
 public virtual void UnregisterOnClient()
 {
     this.RenderScript("Ext.ModelManager.unregister(Ext.ModelManager.getModel({0}));".FormatWith(JSON.Serialize(this.Name ?? this.ClientID)));
 }
Example #16
0
        public void GenerateProxy(StringBuilder sb, string controlID, string url)
        {
            sb.Append(this.Attribute.Alias.IsEmpty() ? this.Name : this.Attribute.Alias);
            sb.Append(":function(");

            ParameterInfo[] parameters = this.PrepareParams(this.Params);

            foreach (ParameterInfo parameterInfo in parameters)
            {
                sb.Append(parameterInfo.Name);
                sb.Append(",");
            }
            sb.Append("config");
            sb.Append("){");
            sb.Append("return Ext.net.DirectMethod.request(\"");
            sb.Append(this.Name);
            sb.Append("\",Ext.applyIf(config || {}, {");

            int  index     = 0;
            bool needComma = false;

            if (this.Params.Length > 0)
            {
                sb.Append("params:{");

                foreach (ParameterInfo parameterInfo in this.Params)
                {
                    sb.Append(parameterInfo.Name);
                    sb.Append(":");
                    sb.AppendFormat(parameterInfo.Name);
                    index++;

                    if (index < this.Params.Length)
                    {
                        sb.Append(",");
                    }
                }
                sb.Append("}");
                needComma = true;
            }

            if (this.Method.IsStatic)
            {
                sb.Append(needComma ? "," : "");
                sb.Append("specifier:\"static\"");
                sb.AppendFormat(",url:{0}", JSON.Serialize(url));
                needComma = true;
            }

            if (controlID.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("control:\"{0}\"", controlID);
                needComma = true;
            }

            if (this.Attribute.Method == HttpMethod.GET)
            {
                sb.Append(needComma ? "," : "");
                sb.Append("method:\"GET\"");
                needComma = true;
            }

            if (this.Attribute.ShowMask)
            {
                sb.Append(needComma ? "," : "");
                sb.Append("eventMask:{showMask:true");

                if (this.Attribute.Msg.IsNotEmpty())
                {
                    sb.Append(",msg:").Append(JSON.Serialize(this.Attribute.Msg));
                }

                if (this.Attribute.MsgCls.IsNotEmpty())
                {
                    sb.Append(",msgCls:").Append(JSON.Serialize(this.Attribute.MsgCls));
                }

                if (this.Attribute.CustomTarget.IsNotEmpty())
                {
                    this.Attribute.Target = MaskTarget.CustomTarget;
                }

                if (this.Attribute.Target != MaskTarget.Page)
                {
                    sb.Append(",target:").Append(JSON.Serialize(this.Attribute.Target.ToString().ToLowerInvariant()));
                }

                if (this.Attribute.Target == MaskTarget.CustomTarget && this.Attribute.CustomTarget.IsNotEmpty())
                {
                    ResourceManager sm = null;

                    if (HttpContext.Current != null)
                    {
                        sm = ResourceManager.GetInstance(HttpContext.Current);
                    }

                    string script = TokenUtils.ReplaceRawToken((sm != null) ? TokenUtils.ParseTokens(this.Attribute.CustomTarget, sm) : TokenUtils.ParseAndNormalize(this.Attribute.CustomTarget));

                    sb.Append(",customTarget:").Append(script);
                }

                sb.Append("}");
                needComma = true;
            }

            if (this.Attribute.Type == DirectEventType.Load)
            {
                sb.Append(needComma ? "," : "");
                sb.Append("type:\"load\"");
                needComma = true;
            }

            if (this.Attribute.ViewStateMode != ViewStateMode.Inherit)
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInvariant());
                needComma = true;
            }

            if (this.Attribute.RethrowException)
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("rethrowException:{0}", this.Attribute.RethrowException.ToString().ToLowerInvariant());
                needComma = true;
            }


            if (this.Attribute.Timeout != 30000)
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("timeout:{0}", this.Attribute.Timeout);
                needComma = true;
            }

            if (!this.Attribute.DisableCaching)
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("disableCaching:{0}", this.Attribute.DisableCaching.ToString().ToLowerInvariant());
                needComma = true;
            }

            if (!this.Attribute.Async)
            {
                sb.Append(needComma ? "," : "");
                sb.Append("async:false");
                needComma = true;
            }

            if (this.Attribute.DisableCachingParam != "_dc")
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("disableCachingParam:{0}", this.Attribute.DisableCachingParam);
                needComma = true;
            }

            if (this.Attribute.SuccessFn.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("success:{0}", this.Attribute.SuccessFn);
                needComma = true;
            }

            if (this.Attribute.CompleteFn.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("complete:{0}", this.Attribute.CompleteFn);
                needComma = true;
            }

            if (this.Attribute.FormID.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("formId:{0}", this.Attribute.FormID);
                needComma = true;
            }

            if (this.Attribute.FailureFn.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("failure:{0}", this.Attribute.FailureFn);
            }

            this.AppendParams(sb, needComma);

            sb.Append("}));}");
        }
Example #17
0
        public virtual void Add(object parameters)
        {
            if (parameters == null)
            {
                return;
            }

            if (parameters is StoreParameter.Builder)
            {
                base.Add(((StoreParameter.Builder)parameters).ToComponent());
                return;
            }

            if (parameters is StoreParameter)
            {
                base.Add((StoreParameter)parameters);
                return;
            }

            var props = parameters.GetType().GetProperties().Select(x => new StoreParameter(x.Name.ToLowerCamelCase(), JSON.Serialize(x.GetValue(parameters, null), new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()), ParameterMode.Raw));

            this.AddRange(props);
        }
Example #18
0
 /// <summary>
 /// Start editing the specified record.
 /// </summary>
 /// <param name="recordId">The Store data record id which backs the row to be edited.</param>
 public virtual void StartEdit(object recordId)
 {
     this.Call("startEdit", new JRawValue("{0}.grid.store.getById({1})".FormatWith(this.ClientID, JSON.Serialize(recordId))), 0);
 }
Example #19
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public string Serialize(bool mapping)
 {
     return(JSON.Serialize(this, mapping ? new EventMappingsContractResolver() : null));
 }
Example #20
0
        public void SetValue(bool?value)
        {
            RequestManager.EnsureDirectEvent();

            if (this.ParentGrid != null)
            {
                this.ParentGrid.AddScript("{0}.getFilterPlugin().getFilter({1}).setValue({2});", this.ParentGrid.ClientID, JSON.Serialize(this.DataIndex), JSON.Serialize(value));
            }
        }
Example #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="moduleId"></param>
 /// <param name="values"></param>
 public virtual void UpdateShortcut(string moduleId, object values)
 {
     this.AddScript("{0}.desktop.shortcuts.getById({1}).set({2});", this.ClientID, JSON.Serialize(moduleId), JSON.Serialize(values));
 }
Example #22
0
        private static string AttachResources(IEnumerable <AbstractComponent> components, string config)
        {
            InsertOrderedDictionary <string, string> scripts = new InsertOrderedDictionary <string, string>();
            InsertOrderedDictionary <string, string> styles  = new InsertOrderedDictionary <string, string>();
            List <string> ns = new List <string>();

            foreach (AbstractComponent seed in components)
            {
                ComponentLoader.FindResources(seed, scripts, styles, ns);
            }

            if (scripts.Count == 0 && styles.Count == 0 && ns.Count == 0)
            {
                return(config);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("{'x.res':{");


            if (ns.Count > 0)
            {
                sb.Append("ns:");
                sb.Append(JSON.Serialize(ns));
            }

            if (scripts.Count == 0 || styles.Count == 0)
            {
                if (ns.Count > 0)
                {
                    sb.Append(",");
                }

                sb.Append("res:[");

                bool comma = false;
                foreach (KeyValuePair <string, string> item in scripts)
                {
                    if (comma)
                    {
                        sb.Append(",");
                    }

                    comma = true;
                    sb.Append("{url:").Append(JSON.Serialize(item.Value)).Append("}");
                }

                foreach (KeyValuePair <string, string> item in styles)
                {
                    if (comma)
                    {
                        sb.Append(",");
                    }

                    comma = true;
                    sb.Append("{mode:\"css\",url:").Append(JSON.Serialize(item.Value)).Append("}");
                }

                sb.Append("]");
            }

            sb.Append("},config:").Append(JSON.Serialize(config));
            sb.Append("}");
            return(sb.ToString());
        }
Example #23
0
        public virtual string Build(RenderMode mode, string element, int?index, bool selfRendering, bool forceResources, string method, bool forceLazy, bool clearContainer)
        {
            this.ForceResources = forceResources;

            if (this.script == null)
            {
                AbstractComponent cmp = this.Control as AbstractComponent;

                bool isLazy = this.Control.IsLazy;

                if (mode == RenderMode.Auto)
                {
                    mode = isLazy ? RenderMode.AddTo : RenderMode.RenderTo;
                }

                switch (mode)
                {
                case RenderMode.RenderTo:
                    if (cmp != null)
                    {
                        if (string.IsNullOrEmpty(element))
                        {
                            element = TokenUtils.RawWrap("Ext.net.ResourceMgr.getRenderTarget()");
                        }

                        if (this.Control.IsLazy)
                        {
                            throw new Exception("Lazy control cannot be rendered with RenderTo mode.");
                        }

                        cmp.RenderTo = element;
                    }
                    break;

                case RenderMode.AddTo:
                case RenderMode.Replace:
                case RenderMode.InsertTo:
                    if (cmp == null)
                    {
                        throw new Exception("AddTo mode can be applied to only a AbstractComponent.");
                    }

                    if (string.IsNullOrEmpty(element))
                    {
                        if (isLazy)
                        {
                            element = this.Control.ParentComponent.ClientID;
                        }
                        else
                        {
                            throw new Exception("You must specify an Element for the AddTo mode.");
                        }
                    }

                    if (mode == RenderMode.InsertTo && index == null)
                    {
                        throw new Exception("You have to provide the index for the InsertTo mode.");
                    }

                    cmp.PreventRenderTo = true;
                    break;
                }

                Page pageHolder = null;
                this.Control.IsDynamicLazy     = isLazy || (mode == RenderMode.AddTo || mode == RenderMode.InsertTo || mode == RenderMode.Replace);
                this.Control.TopDynamicControl = true;
                //this.Control.ForceIdRendering = true;
                this.Control.ForceLazy = forceLazy || this.Control.IsDynamicLazy;
                this.ResourceManager   = Ext.Net.ResourceManager.GetInstance();

                if (selfRendering && this.Control.Page == null)
                {
                    pageHolder = new SelfRenderingPage();

                    ResourceManager newMgr = new ResourceManager(true);
                    newMgr.RenderScripts = ResourceLocationType.None;
                    newMgr.RenderStyles  = ResourceLocationType.None;
                    newMgr.IDMode        = IDMode.Explicit;
                    newMgr.IsDynamic     = true;
                    pageHolder.Controls.Add(newMgr);

                    if (this.ResourceManager == null)
                    {
                        this.ResourceManager = newMgr;
                    }

                    pageHolder.Controls.Add(this.Control);
                }
                else if (selfRendering && this.Control.Page is ISelfRenderingPage)
                {
                    pageHolder = this.Control.Page;
                    ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl <ResourceManager>(pageHolder);
                    if (this.ResourceManager == null)
                    {
                        this.ResourceManager = newMgr;
                    }
                    if (newMgr != null)
                    {
                        newMgr.IsDynamic = true;
                    }
                }

                StringBuilder sb = new StringBuilder();

                if (this.Control.ClientID.IsNotEmpty() && !this.Control.IsGeneratedID)
                {
                    sb.AppendFormat("Ext.net.ResourceMgr.destroyCmp(\"{0}\");", this.Control.ClientID);
                }

                if (clearContainer)
                {
                    if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo)
                    {
                        string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element));
                        sb.AppendFormat("{0}.removeAll();", elementGet);
                    }
                    else if (mode != RenderMode.Replace)
                    {
                        sb.AppendFormat("Ext.net.getEl(\"{0}\").update();", element);
                    }
                }

                List <BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null);
                childControls.Insert(0, this.Control);

                if (selfRendering && pageHolder != null)
                {
                    pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object();
                }

                foreach (BaseControl c in childControls)
                {
                    if (c.Visible || Object.ReferenceEquals(c, this.Control))
                    {
                        if (c.AutoDataBind)
                        {
                            c.DataBind();
                        }
                    }
                }

                if (selfRendering)
                {
                    this.RegisterHtml(sb, pageHolder);

                    if (pageHolder != null)
                    {
                        pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null;
                    }

                    List <BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null);
                    newChildControls.Insert(0, this.Control);

                    foreach (BaseControl c in newChildControls)
                    {
                        if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control)))
                        {
                            if (c.AutoDataBind)
                            {
                                c.DataBind();
                            }
                        }
                    }

                    childControls = newChildControls;
                }

                foreach (BaseControl c in childControls)
                {
                    if (c.Visible || Object.ReferenceEquals(c, this.Control))
                    {
                        c.OnClientInit(true);
                        c.RegisterBeforeAfterScript();
                    }
                }

                string methodTemplate = string.Concat(".", method ?? "add", "(");

                if (mode == RenderMode.InsertTo)
                {
                    methodTemplate = string.Concat(".", method ?? "insert", "(", index.Value, ",");
                }

                foreach (BaseControl c in childControls)
                {
                    if (c.Visible || Object.ReferenceEquals(c, this.Control))
                    {
                        if (Object.ReferenceEquals(c, this.Control) && (this.Control.IsLazy || this.Control.ForceLazy))
                        {
                            this.ScriptClientInitBag.Add(c.ClientInitID + "_BeforeScript", c.BeforeScript);

                            string initScript = c.BuildInitScript();
                            string topScript  = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary <string, string> {
                                { "ref", "top_dynamic_control" },
                                { "index", ResourceManager.ScriptOrderNumber.ToString() }
                            }, initScript);
                            this.ScriptClientInitBag.Add(c.ClientInitID, topScript);

                            this.ScriptClientInitBag.Add(c.ClientInitID + "_AfterScript", c.AfterScript);
                        }
                        else
                        {
                            string tokenValue = ((c is LazyObservable && c.IsIdRequired) ? "window.{0}=".FormatWith(c.ClientID) : "") + c.BuildInitScript();
                            string script     = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary <string, string> {
                                { "ref", c.IsLazy ? c.ClientInitID : "init_script" },
                                { "index", ResourceManager.ScriptOrderNumber.ToString() }
                            }, tokenValue);

                            this.ScriptClientInitBag.Add(c.ClientInitID, script);
                        }

                        c.AlreadyRendered = true;

                        foreach (KeyValuePair <long, string> proxyScript in c.ProxyScripts)
                        {
                            if (proxyScript.Value.IsNotEmpty())
                            {
                                this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value);
                            }
                        }
                    }
                }

                if (this.ScriptClientInitBag.Count > 0)
                {
                    foreach (KeyValuePair <string, string> item in this.ScriptClientInitBag)
                    {
                        sb.Append(this.ScriptClientInitBag[item.Key]);
                    }
                }

                sb.Append(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> {
                    { "id", "init_script" }
                }));

                string topAnchor = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> {
                    { "id", "top_dynamic_control" }
                });

                if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo)
                {
                    string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element));
                    sb.Append(elementGet.ConcatWith(methodTemplate, topAnchor, ");"));
                }
                else if (mode == RenderMode.Replace)
                {
                    sb.Append("Ext.net._renderTo(arguments[0],".ConcatWith(topAnchor, ");"));
                }

                foreach (KeyValuePair <long, string> script in this.ScriptOnReadyBag)
                {
                    sb.Append(script.Value);
                }

                if (mode == RenderMode.Replace)
                {
                    string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element));
                    sb.Insert(0, elementGet + ".replace(function(){");
                    sb.Append("});");
                }

                this.script = this.RegisterResources(sb.ToString());
            }

            this.Control.ForceLazy = false;

            return(Transformer.NET.Html.HtmlTransformer.Transform(this.script));
        }
Example #24
0
 ///<summary>
 /// Load new data from the server.
 ///</summary>
 ///<param name="options">The options for the request. They can be any configuration option that can be specified for the class, with the exception of the target option. Note that any options passed to the method will override any class defaults.</param>
 public virtual void LoadContent(object options)
 {
     this.Call("getLoader().load", JSON.Serialize(options, new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()));
 }
 public virtual string Serialize()
 {
     return(JSON.Serialize(this));
 }
Example #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="owner"></param>
        /// <returns></returns>
        public string ToScript(Control owner)
        {
            string tpl = "Ext.define({0}, {{extend: {3}, {1} }}){2}";
            string id  = this.Name.IsNotEmpty() ? JSON.Serialize(this.Name) : (this.IsGeneratedID ? "Ext.id()" : JSON.Serialize(this.ClientID));

            return(tpl.FormatWith(id, new ClientConfig().Serialize(this, true).Chop(),
                                  this.IsLazy ? "" : ";", JSON.Serialize(this.Extend)));
        }
 public static TConfig Deserialize <TConfig>(string config)
     where TConfig : Config
 {
     return(JSON.Deserialize <TConfig>(config) as TConfig);
 }
Example #28
0
 /// <summary>
 ///
 /// </summary>
 public virtual void RegisterOnClient()
 {
     this.RenderScript("Ext.ModelManager.registerType({0}, {1});".FormatWith(JSON.Serialize(this.Name ?? this.ClientID), new ClientConfig().Serialize(this, true)));
 }
Example #29
0
        public virtual string ToString(bool camelNames)
        {
            //this.EnsureDataBind();

            ParameterMode mode = this.Mode;

            string name = camelNames ? this.Name.ToLowerCamelCase() : this.Name;

            if (this.Params.Count > 0)
            {
                return(this.ToStringInnerParams(name));
            }
            else
            {
                string script = TokenUtils.ParseTokens(this.Value, this.Owner);

                if (TokenUtils.IsRawToken(script))
                {
                    mode   = ParameterMode.Raw;
                    script = TokenUtils.ReplaceRawToken(script);
                }
                else if (mode == ParameterMode.Auto)
                {
                    KeyValuePair <string, ParameterMode> result = this.GetAutoValue(script);

                    mode   = result.Value;
                    script = result.Key;
                }

                return(JSON.Serialize(name).ConcatWith(":", this.Encode ? "Ext.encode(" : "", mode == ParameterMode.Raw ? script : JSON.Serialize(script), this.Encode ? ")" : ""));
            }
        }
Example #30
0
 public static T Deserialize <T>(string value)
 {
     return((T)JSON.Deserialize(value, typeof(T), null, null));
 }