ToScript() private method

private ToScript ( ) : string
return string
 /// <summary>
 /// Cascades down the component/container heirarchy from this component (passed in the first call), calling the specified function with each component.
 /// </summary>
 /// <param name="fn">The function to call</param>
 public virtual void Cascade(JFunction fn)
 {
     this.Call("cascade", JRawValue.From(fn.ToScript()));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Assigns this button's click handler
 /// </summary>
 /// <param name="function">The function to call when the arrow is clicked</param>
 public virtual void SetArrowHandler(JFunction function)
 {
     this.Call("setArrowHandler", new JRawValue(function.ToScript()));
 }
Exemplo n.º 3
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.AddListener(eventName, TokenUtils.Settings.RawMarker + fn.ToScript(), scope, options);
 }
Exemplo n.º 4
0
 public virtual void On(string eventName, JFunction fn, string scope)
 {
     this.AddListener(eventName, "<raw>" + fn.ToScript(), scope);
 }
Exemplo n.º 5
0
 public virtual void GuaranteeRange(int start, int end, JFunction callback)
 {
     this.Call("guaranteeRange", start, end, JRawValue.From(callback.ToScript()));
 }
Exemplo n.º 6
0
        public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is ComponentDirectEvent)
            {
                ComponentDirectEvent directEvent = (ComponentDirectEvent)value;

                if (!directEvent.IsDefault)
                {
                    Control owner = null;
                    MessageBusDirectEvent busEvent = directEvent as MessageBusDirectEvent;

                    if (this.Owner is BaseItem)
                    {
                        owner = ((BaseItem)this.Owner).Owner;
                    }
                    else if (this.Owner is Control)
                    {
                        owner = (Control)this.Owner;
                    }

                    directEvent.Owner             = owner;
                    directEvent.ExtraParams.Owner = owner;

                    foreach (Parameter param in directEvent.ExtraParams)
                    {
                        param.Owner = owner;
                    }

                    string configObject = new ClientConfig().SerializeInternal(directEvent, directEvent.Owner);

                    StringBuilder cfgObj = new StringBuilder(configObject.Length + 64);

                    cfgObj.Append(configObject);
                    cfgObj.Remove(cfgObj.Length - 1, 1);
                    cfgObj.AppendFormat("{0}control:this", configObject.Length > 2 ? "," : "");

                    if (busEvent != null)
                    {
                        cfgObj.Append(",eventType:'bus'");
                    }

                    if (this.PropertyName != "Click")
                    {
                        cfgObj.AppendFormat(",action:'{0}:'+name", busEvent != null ? busEvent.Name : this.PropertyName);
                    }

                    cfgObj.Append("}");

                    if (this.PropertyName.IsNotEmpty())
                    {
                        directEvent.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));
                    }

                    JFunction     jFunction = new JFunction("Ext.net.directRequest(".ConcatWith(cfgObj.ToString(), ");"), directEvent.ArgumentList.ToArray());
                    HandlerConfig cfg       = directEvent.GetListenerConfig();
                    string        scope     = directEvent.Scope.IsEmpty() || directEvent.Scope == "this" ? "" : directEvent.Scope;

                    StringBuilder sb = new StringBuilder();

                    sb.Append("{");
                    sb.Append("fn:").Append(jFunction.ToScript()).Append(",");

                    if (scope.Length > 0)
                    {
                        sb.Append("scope:").Append(scope).Append(",");
                    }

                    if (busEvent != null)
                    {
                        if (busEvent.Bus.IsNotEmpty())
                        {
                            sb.Append("bus:'").Append(busEvent.Bus).Append("',");
                        }
                        if (busEvent.Name.IsNotEmpty())
                        {
                            sb.Append("name:'").Append(busEvent.Name).Append("',");
                        }
                    }

                    string cfgStr = cfg.Serialize();

                    if (cfgStr != "{}")
                    {
                        sb.Append(cfgStr.Chop());
                    }

                    if (sb[sb.Length - 1] == ',')
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }

                    sb.Append("}");

                    writer.WriteRawValue(sb.ToString());

                    return;
                }
            }

            writer.WriteRawValue("{}");
        }
Exemplo n.º 7
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is ComponentDirectEvent)
            {
                ComponentDirectEvent directEvent = (ComponentDirectEvent)value;
                if (!directEvent.IsDefault)
                {
                    Control owner = null;
                    if (this.Owner is StateManagedItem)
                    {
                        owner = ((StateManagedItem)this.Owner).Owner;
                    }
                    else if (this.Owner is Control)
                    {
                        owner = (Control)this.Owner;
                    }

                    directEvent.Owner = owner;
                    directEvent.ExtraParams.Owner = owner;

                    foreach (Parameter param in directEvent.ExtraParams)
                    {
                        param.Owner = owner;
                    }
                    
                    string configObject = new ClientConfig().SerializeInternal(directEvent, directEvent.Owner);

                    StringBuilder cfgObj = new StringBuilder(configObject.Length + 64);

                    cfgObj.Append(configObject);
                    cfgObj.Remove(cfgObj.Length - 1, 1);
                    cfgObj.AppendFormat("{0}control:this", configObject.Length > 2 ? "," : "");

                    if (this.PropertyName != "Click")
                    {
                        cfgObj.AppendFormat(",action:'{0}'", this.PropertyName);
                    }

                    cfgObj.Append("}");

                    directEvent.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));
                    
                    JFunction jFunction = new JFunction("var params=arguments;Ext.net.DirectEvent.confirmRequest(".ConcatWith(cfgObj.ToString(), ");"), directEvent.ArgumentList.ToArray());
                    HandlerConfig cfg = directEvent.GetListenerConfig();
                    string scope = directEvent.Scope.IsEmpty() || directEvent.Scope == "this" ? "" : directEvent.Scope;

                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");

                    sb.Append("fn:").Append(jFunction.ToScript()).Append(",");

                    if (scope.Length > 0)
                    {
                        sb.Append("scope:").Append(scope).Append(",");
                    }

                    string cfgStr = cfg.ToJsonString();
                    if (cfgStr != "{}")
                    {
                        sb.Append(cfgStr.Chop());
                    }

                    if (sb[sb.Length - 1] == ',')
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }

                    sb.Append("}");

                    writer.WriteRawValue(sb.ToString());
                    return;
                }
            }
            writer.WriteRawValue("{}");
        }
Exemplo n.º 8
0
 public virtual void Each(JFunction fn, string scope)
 {
     this.Call("each", new JRawValue(fn.ToScript()), new JRawValue(scope));
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is ComponentDirectEvent)
            {
                ComponentDirectEvent directEvent = (ComponentDirectEvent)value;
                if (!directEvent.IsDefault)
                {
                    Control owner = null;
                    if (this.Owner is StateManagedItem)
                    {
                        owner = ((StateManagedItem)this.Owner).Owner;
                    }
                    else if (this.Owner is Control)
                    {
                        owner = (Control)this.Owner;
                    }

                    directEvent.Owner             = owner;
                    directEvent.ExtraParams.Owner = owner;

                    foreach (Parameter param in directEvent.ExtraParams)
                    {
                        param.Owner = owner;
                    }

                    string configObject = new ClientConfig().SerializeInternal(directEvent, directEvent.Owner);

                    StringBuilder cfgObj = new StringBuilder(configObject.Length + 64);

                    cfgObj.Append(configObject);
                    cfgObj.Remove(cfgObj.Length - 1, 1);
                    cfgObj.AppendFormat("{0}control:this", configObject.Length > 2 ? "," : "");

                    if (this.PropertyName != "Click")
                    {
                        cfgObj.AppendFormat(",action:'{0}'", this.PropertyName);
                    }

                    cfgObj.Append("}");

                    directEvent.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));

                    JFunction     jFunction = new JFunction("var params=arguments;Ext.net.DirectEvent.confirmRequest(".ConcatWith(cfgObj.ToString(), ");"), directEvent.ArgumentList.ToArray());
                    HandlerConfig cfg       = directEvent.GetListenerConfig();
                    string        scope     = directEvent.Scope.IsEmpty() || directEvent.Scope == "this" ? "" : directEvent.Scope;

                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");

                    sb.Append("fn:").Append(jFunction.ToScript()).Append(",");

                    if (scope.Length > 0)
                    {
                        sb.Append("scope:").Append(scope).Append(",");
                    }

                    string cfgStr = cfg.ToJsonString();
                    if (cfgStr != "{}")
                    {
                        sb.Append(cfgStr.Chop());
                    }

                    if (sb[sb.Length - 1] == ',')
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }

                    sb.Append("}");

                    writer.WriteRawValue(sb.ToString());
                    return;
                }
            }
            writer.WriteRawValue("{}");
        }
Exemplo n.º 11
0
 public virtual Element AddClsOnOver(string className, JFunction testFn, string scope)
 {
     this.Call("addClsOnOver", className, JRawValue.From(testFn.ToScript()), JRawValue.From(scope));
     return this;
 }
Exemplo n.º 12
0
 public virtual Element AddClsOnFocus(string className, JFunction testFn)
 {
     this.Call("addClsOnFocus", className, JRawValue.From(testFn.ToScript()));
     return this;
 }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="fn"></param>
 /// <param name="options"></param>
 public virtual void Subscribe(string name, JFunction fn, HandlerConfig options)
 {
     this.Call("subscribe", name, new JRawValue(fn.ToScript()), new JRawValue(options.Serialize()));
 }
Exemplo n.º 15
0
 public virtual void On(string eventName, JFunction fn, string scope)
 {
     this.Call("on", eventName, JRawValue.From(fn.ToScript()), JRawValue.From(scope));
 }
Exemplo n.º 16
0
 public virtual void On(string eventName, JFunction fn, string scope)
 {
     this.AddListener(eventName, "<raw>" + fn.ToScript(), scope);
 }
Exemplo n.º 17
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.Call("on", eventName, JRawValue.From(fn.ToScript()), JRawValue.From(scope), JRawValue.From(options.Serialize()));
 }
Exemplo n.º 18
0
 public virtual void FilterBy(JFunction fn)
 {
     this.Call("filterBy", new JRawValue(fn.ToScript()));
 }
Exemplo n.º 19
0
        /*  Public Methods
         *  -----------------------------------------------------------------------------------------------*/

        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="fn"></param>
        public virtual void Subscribe(string name, JFunction fn)
        {
            this.Call("subscribe", name, new JRawValue(fn.ToScript()));
        }
Exemplo n.º 20
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.AddListener(eventName, TokenUtils.Settings.RawMarker + fn.ToScript(), scope, options);
 }
Exemplo n.º 21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="fn"></param>
 /// <param name="options"></param>
 public virtual void Subscribe(string name, JFunction fn, HandlerConfig options)
 {
     this.Call("subscribe", name, new JRawValue(fn.ToScript()), new JRawValue(options.Serialize()));
 }
Exemplo n.º 22
0
 public virtual void On(string eventName, JFunction fn)
 {
     this.AddListener(eventName, TokenUtils.Settings.RawMarker + fn.ToScript());
 }
Exemplo n.º 23
0
 public virtual void On(string eventName, JFunction fn, string scope)
 {
     this.Call("on", eventName, JRawValue.From(fn.ToScript()), JRawValue.From(scope));
 }
Exemplo n.º 24
0
 public virtual void AddListener(string eventName, JFunction fn)
 {
     this.AddListener(eventName, fn.ToScript());
 }
Exemplo n.º 25
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.Call("on", eventName, JRawValue.From(fn.ToScript()), JRawValue.From(scope), JRawValue.From(options.Serialize()));
 }
Exemplo n.º 26
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.AddListener(eventName, "<raw>" + fn.ToScript(), scope, options);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Finds the first child by a custom function. The child matches if the function passed returns true.
 /// </summary>
 /// <param name="fn">A function which must return true if the passed Node is the required Node.</param>
 /// <param name="scope">The scope (this reference) in which the function is executed. Defaults to the Node being tested.</param>
 /// <param name="deep">True to search through nodes deeper than the immediate children</param>
 /// <returns></returns>
 public virtual NodeProxy FindChildBy(JFunction fn, string scope, bool deep)
 {
     return new NodeProxy(this.storeObj, "{0}.findChildBy({1},{2},{3})".FormatWith(this.IsArray ? "node" : this.nodeScript, fn.ToScript(), scope, JSON.Serialize(deep)));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Cascades down the component/container heirarchy from this component (passed in the first call), calling the specified function with each component.
 /// </summary>
 /// <param name="fn">The function to call</param>
 /// <param name="scope">The scope of the function (defaults to current component)</param>
 public virtual void Cascade(JFunction fn, string scope)
 {
     this.Call("cascade", JRawValue.From(fn.ToScript()), JRawValue.From(scope));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Finds the first child by a custom function. The child matches if the function passed returns true.
 /// </summary>
 /// <param name="fn">A function which must return true if the passed Node is the required Node.</param>
 /// <returns></returns>
 public virtual NodeProxy FindChildBy(JFunction fn)
 {
     return new NodeProxy(this.storeObj, "{0}.findChildBy({1})".FormatWith(this.IsArray ? "node" : this.nodeScript, fn.ToScript()));
 }
Exemplo n.º 30
0
        /*  Public Methods
            -----------------------------------------------------------------------------------------------*/

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="fn"></param>
        public virtual void Subscribe(string name, JFunction fn)
        {
            this.Call("subscribe", name, new JRawValue(fn.ToScript()));
        }
Exemplo n.º 31
0
 public virtual void NodeOn(string nodeId, string eventName, JFunction fn)
 {
     this.CallNode("on", nodeId, eventName.ToLower(), new JRawValue(TokenUtils.ParseAndNormalize(fn.ToScript(), this)));
 }
Exemplo n.º 32
0
 public virtual void AddListener(string eventName, JFunction fn)
 {
     this.AddListener(eventName, fn.ToScript());
 }
Exemplo n.º 33
0
 public virtual void NodeOn(string nodeId, string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.CallNode("on", nodeId, eventName, new JRawValue(TokenUtils.ParseAndNormalize(fn.ToScript(), this)), new JRawValue(scope), new JRawValue(options.ToJsonString()));
 }
Exemplo n.º 34
0
 public virtual void On(string eventName, JFunction fn, string scope, HandlerConfig options)
 {
     this.AddListener(eventName, "<raw>" + fn.ToScript(), scope, options);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Finds the first child by a custom function. The child matches if the function passed returns true.
 /// </summary>
 /// <param name="fn">A function which must return true if the passed Node is the required Node.</param>
 /// <param name="scope">The scope (this reference) in which the function is executed. Defaults to the Node being tested.</param>
 /// <param name="deep">True to search through nodes deeper than the immediate children</param>
 /// <returns></returns>
 public virtual NodeProxy FindChildBy(JFunction fn, string scope, bool deep)
 {
     return(new NodeProxy(this.storeObj, "{0}.findChildBy({1},{2},{3})".FormatWith(this.IsArray ? "node" : this.nodeScript, fn.ToScript(), scope, JSON.Serialize(deep))));
 }
Exemplo n.º 36
0
 public virtual void Each(JFunction fn)
 {
     this.Call("each", new JRawValue(fn.ToScript()));
 }
Exemplo n.º 37
0
 /// <summary>
 /// Finds the first child by a custom function. The child matches if the function passed returns true.
 /// </summary>
 /// <param name="fn">A function which must return true if the passed Node is the required Node.</param>
 /// <returns></returns>
 public virtual NodeProxy FindChildBy(JFunction fn)
 {
     return(new NodeProxy(this.storeObj, "{0}.findChildBy({1})".FormatWith(this.IsArray ? "node" : this.nodeScript, fn.ToScript())));
 }
Exemplo n.º 38
0
 public virtual void FilterBy(JFunction fn, string scope)
 {
     this.Call("filterBy", new JRawValue(fn.ToScript()), new JRawValue(scope));
 }
        public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is ComponentDirectEvent)
            {
                ComponentDirectEvent directEvent = (ComponentDirectEvent)value;

                if (!directEvent.IsDefault)
                {
                    Control owner = null;
                    MessageBusDirectEvent busEvent = directEvent as MessageBusDirectEvent;

                    if (this.Owner is BaseItem)
                    {
                        owner = ((BaseItem)this.Owner).Owner;
                    }
                    else if (this.Owner is Control)
                    {
                        owner = (Control)this.Owner;
                    }

                    directEvent.Owner = owner;
                    directEvent.ExtraParams.Owner = owner;

                    foreach (Parameter param in directEvent.ExtraParams)
                    {
                        param.Owner = owner;
                    }

                    HandlerConfig cfg = directEvent.GetListenerConfig();
                    if (cfg.Delay == 0 && directEvent.HasOwnDelay)
                    {
                        cfg.Delay = -1;
                    }

                    string deScope = directEvent.Scope;
                    directEvent.ClearListenerConfig();
                    
                    string configObject = new ClientConfig().SerializeInternal(directEvent, directEvent.Owner);

                    StringBuilder cfgObj = new StringBuilder(configObject.Length + 64);

                    cfgObj.Append(configObject);
                    cfgObj.Remove(cfgObj.Length - 1, 1);
                    cfgObj.AppendFormat("{0}control:this", configObject.Length > 2 ? "," : "");

                    if (busEvent != null)
                    {
                        cfgObj.Append(",eventType:'bus'");
                    }

                    if (busEvent == null)
                    {
                        if (this.PropertyName != "Click")
                        {
                            cfgObj.AppendFormat(",action:'{0}'", this.PropertyName);
                        }
                    }
                    else
                    {
                        cfgObj.AppendFormat(",action:'{0}:'+name", busEvent.Name);
                    }
                    

                    cfgObj.Append("}");

                    if (this.PropertyName.IsNotEmpty())
                    {
                        directEvent.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));
                    }

                    JFunction jFunction = new JFunction("Ext.net.directRequest(".ConcatWith(cfgObj.ToString(), ");"), directEvent.ArgumentList.ToArray());

                    string scope = deScope.IsEmpty() || deScope == "this" ? "" : deScope;

                    StringBuilder sb = new StringBuilder();
                    
                    sb.Append("{");
                    sb.Append("fn:").Append(jFunction.ToScript()).Append(",");

                    if (scope.Length > 0)
                    {
                        sb.Append("scope:").Append(scope).Append(",");
                    }

                    if (busEvent != null)
                    {
                        if (busEvent.Bus.IsNotEmpty())
                        {
                            sb.Append("bus:'").Append(busEvent.Bus).Append("',");
                        }
                        if (busEvent.Name.IsNotEmpty())
                        {
                            sb.Append("name:'").Append(busEvent.Name).Append("',");
                        }                                                
                    }

                    string cfgStr = cfg.Serialize();

                    if (cfgStr != "{}")
                    {
                        sb.Append(cfgStr.Chop());
                    }

                    if (sb[sb.Length - 1] == ',')
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }

                    sb.Append("}");

                    writer.WriteRawValue(sb.ToString());

                    return;
                }
            }

            writer.WriteRawValue("{}");
        }
Exemplo n.º 40
0
 /// <summary>
 /// Assigns this button's click handler
 /// </summary>
 /// <param name="function">The function to call when the arrow is clicked</param>
 public virtual void SetArrowHandler(JFunction function)
 {
     this.Call("setArrowHandler", new JRawValue(function.ToScript()));
 }
Exemplo n.º 41
0
 public virtual void On(string eventName, JFunction fn)
 {
     this.AddListener(eventName, TokenUtils.Settings.RawMarker + fn.ToScript());
 }