Exemple #1
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()));
 }
Exemple #2
0
        public void UpdateData()
        {
            RequestManager.EnsureDirectEvent();

            this.AddScript("{0}={1};", this.ClientID, JSON.Serialize(this.Items));
        }
Exemple #3
0
        public void GenerateProxy(StringBuilder sb, string controlID, string url)
        {
            sb.Append(this.Attribute.Alias.IsEmpty() ? this.Name : this.Attribute.Alias);
            sb.Append(":function(");

            foreach (ParameterInfo parameterInfo in this.Params)
            {
                sb.Append(parameterInfo.Name);
                sb.Append(",");
            }
            sb.Append("config");
            sb.Append("){");
            sb.Append("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(",customTarget:").Append(JSON.Serialize(this.Attribute.CustomTarget));
                }

                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.HasValue)
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("disableCaching:{0}", this.Attribute.DisableCaching.Value.ToString().ToLowerInvariant());
                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.FailureFn.IsNotEmpty())
            {
                sb.Append(needComma ? "," : "");
                sb.AppendFormat("failure:{0}", this.Attribute.FailureFn);
            }

            sb.Append("}));}");
        }
Exemple #4
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);
 }
Exemple #5
0
        /// <summary>
        /// Add required resources and activate console
        /// </summary>
        /// <param name="module">Console type</param>
        /// <param name="callback">callback which fires after console activating</param>
        public static void Activate(DebugConsole module, JFunction callback)
        {
            Debug  debug     = new Debug();
            string scriptUrl = debug.ResourceManager.GetWebResourceUrl(ResourceManager.ASSEMBLYSLUG + ".ux.extensions.debug.Debug.js");
            string activate  = "function(){{Ext.net.Debug.activate({0}{1});}}".FormatWith(new DebugDescriptor(module).Serialize(), callback == null ? "" : "," + callback.ToScript());

            debug.AddScript("Ext.net.ResourceMgr.load({{ url: {0}, callback: {1} }});", JSON.Serialize(scriptUrl), activate);
        }
Exemple #6
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));
 }
Exemple #7
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));
        }
Exemple #8
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));
        }
Exemple #9
0
 public override string ToString()
 {
     return(this.Name.ConcatWith(":", JSON.Serialize(this.Allow)));
 }
Exemple #10
0
 /// <summary>
 /// Selects first element based on the passed CSS selector
 /// </summary>
 /// <param name="selector">The CSS selector</param>
 /// <param name="unique"></param>
 /// <returns>Elements</returns>
 public static Element SingleSelect(string selector, bool unique)
 {
     return(new Element("Ext.get(Ext.select({0},{1}).elements[0])".FormatWith(JSON.Serialize(selector), JSON.Serialize(unique))));
 }
Exemple #11
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);
        }
Exemple #12
0
 /// <summary>
 /// Selects elements based on the passed CSS selector to enable Element methods to be applied to many related elements in one statement
 /// </summary>
 /// <param name="selector">The CSS selector or an array of elements</param>
 /// <returns>Elements</returns>
 public static Element Select(string selector)
 {
     return(new Element("Ext.select({0})".FormatWith(JSON.Serialize(selector))));
 }
        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)
                {
                    var 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 ? ")" : ""));
            }
        }
 /// <summary>
 /// Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
 /// </summary>
 /// <param name="storeId">Store Id</param>
 /// <param name="recordId">Record Id</param>
 public void Show(string storeId, object recordId)
 {
     this.Call("show", new JRawValue("{0}.getById({1})".FormatWith(storeId, JSON.Serialize(recordId))));
 }
 public override string ToString()
 {
     return(JSON.Serialize(this));
 }
Exemple #16
0
 public virtual void Bubble(string function, string scope, object[] args)
 {
     this.Call("bubble", new JRawValue(function), new JRawValue(scope), JSON.Serialize(args));
 }
Exemple #17
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public string Serialize(bool mapping)
 {
     return(JSON.Serialize(this, mapping ? new EventMappingsContractResolver() : null));
 }
Exemple #18
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)));
        }
Exemple #19
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));
     }
 }
Exemple #20
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)));
 }
        public virtual string Serialize()
        {
            if (this.Args.Count == 0)
            {
                return(new ClientConfig().Serialize(this));
            }

            return("{{{0},{1}}}".FormatWith(new ClientConfig().Serialize(this).Chop(), JSON.Serialize(this.Args).Chop()));
        }
Exemple #22
0
 /// <summary>
 ///
 /// </summary>
 public virtual void UnregisterOnClient()
 {
     this.RenderScript("Ext.ModelManager.unregister(Ext.ModelManager.getModel({0}));".FormatWith(JSON.Serialize(this.Name ?? this.ClientID)));
 }
Exemple #23
0
 public string Serialize()
 {
     return(JSON.Serialize(this, new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()));
 }
 public virtual string ToJsonString()
 {
     return(JSON.Serialize(this));
 }
 public virtual string Serialize()
 {
     return(JSON.Serialize(this));
 }
 public virtual string ToJsonString(List <JsonConverter> converters, bool quoteName)
 {
     return(JSON.Serialize(this, converters, quoteName, null));
 }
Exemple #27
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));
        }
 public virtual string ToJsonString(List <JsonConverter> converters, bool quoteName, IContractResolver resolver)
 {
     return(JSON.Serialize(this, converters, quoteName, resolver));
 }
Exemple #29
0
 /// <summary>
 /// Selects elements based on the passed CSS selector to enable Element methods to be applied to many related elements in one statement
 /// </summary>
 /// <param name="selector">The CSS selector or an array of elements</param>
 /// <param name="unique">true to create a unique Ext.Element for each element (defaults to a shared flyweight object)</param>
 /// <param name="root">id of the root</param>
 /// <returns>Elements</returns>
 public static Element Select(string selector, bool unique, string root)
 {
     return(new Element("Ext.select({0},{1},{2})".FormatWith(JSON.Serialize(selector), JSON.Serialize(unique), JSON.Serialize(root))));
 }
Exemple #30
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());
        }