ParseAndNormalize() приватный Метод

private ParseAndNormalize ( string script ) : string
script string
Результат string
Пример #1
0
 /// <summary>
 /// Initializes the drag drop object's constraints to restrict movement to a certain element.
 /// </summary>
 /// <param name="constrainTo">The element to constrain to.</param>
 /// <param name="pad">Pad provides a way to specify "padding" of the constraints</param>
 /// <param name="inContent">Constrain the draggable in the content box of the element (inside padding and borders)</param>
 public void ConstrainTo(string constrainTo, Paddings pad, bool inContent)
 {
     this.Call("constrainTo",
               new JRawValue(string.Concat("Ext.net.getEl(", TokenUtils.ParseAndNormalize(constrainTo), ")")),
               new JRawValue(pad.ToString()),
               inContent);
 }
Пример #2
0
        protected virtual void CallTemplate(ScriptPosition position, string template, string name, params object[] args)
        {
            IDMode mode = this.IDMode;

            if (((mode == Ext.Net.IDMode.Explicit || mode == Ext.Net.IDMode.Static) && !this.IsIdRequired) || mode == Ext.Net.IDMode.Ignore)
            {
                throw new Exception("You have to set widget's ID to call its methods");
            }

            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.SafeResourceManager));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConvertersInternal));
                    }
                }
            }

            string script = template.FormatWith(this.CallID, name, sb.ToString().LeftOfRightmostOf(','));

            switch (position)
            {
            case ScriptPosition.BeforeInit:
                this.ResourceManager.RegisterBeforeClientInitScript(script);
                break;

            case ScriptPosition.AfterInit:
                this.ResourceManager.RegisterAfterClientInitScript(script);
                break;

            default:
                this.AddScript(script);
                break;
            }
        }
Пример #3
0
        private static string FormatArgs(object[] args)
        {
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), ResourceManager.GetInstance(HttpContext.Current)));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg));
                    }
                }
            }
            return(sb.ToString().LeftOfRightmostOf(','));
        }
Пример #4
0
        protected virtual string FormatArgs(object[] args)
        {
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.ResourceManager));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg));
                    }
                }
            }

            return(sb.ToString().LeftOfRightmostOf(','));
        }
Пример #5
0
        protected virtual void CallTemplate(ScriptPosition position, string template, string name, params object[] args)
        {
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.SafeResourceManager));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.AltConvertersInternal));
                    }
                }
            }

            string script = template.FormatWith(this.CallID, name, sb.ToString().LeftOfRightmostOf(','));

            switch (position)
            {
            case ScriptPosition.BeforeInit:
                this.ResourceManager.RegisterBeforeClientInitScript(script);
                break;

            case ScriptPosition.AfterInit:
                this.ResourceManager.RegisterAfterClientInitScript(script);
                break;

            default:
                this.AddScript(script);
                break;
            }
        }
Пример #6
0
 public virtual void AddManagedListener(string item, string eventName, string fn)
 {
     fn = TokenUtils.ParseAndNormalize(fn, this).Trim('"');
     this.Call("addManagedListener", new JRawValue(item), eventName, new JRawValue(fn));
 }
Пример #7
0
 public virtual void AddManagedListener(string item, string eventName, string fn, string scope, HandlerConfig options)
 {
     fn = TokenUtils.ParseAndNormalize(fn, this).Trim('"');
     this.Call("addManagedListener", new JRawValue(item), eventName, new JRawValue(fn), new JRawValue(scope), new JRawValue(options.Serialize()));
 }
Пример #8
0
 public virtual void AddListener(string eventName, string fn, string scope)
 {
     fn = TokenUtils.ParseAndNormalize(fn, this).Trim('"');
     this.Call("on", eventName.ToLowerInvariant(), new JRawValue(fn), new JRawValue(scope));
 }
Пример #9
0
 /// <summary>
 /// Sets the element to the location of the mousedown or click event, maintaining the cursor location relative to the location on the element that was clicked. Override this if you want to place the element in a location other than where the cursor is.
 /// </summary>
 /// <param name="el">the element to move</param>
 /// <param name="iPageX">the X coordinate of the mousedown or drag event</param>
 /// <param name="iPageY">the Y coordinate of the mousedown or drag event</param>
 public void AlignElWithMouse(string el, int iPageX, int iPageY)
 {
     this.Call("alignElWithMouse", new JRawValue(string.Concat("Ext.net.getEl(", TokenUtils.ParseAndNormalize(el), ".dom")), iPageX, iPageY);
 }
Пример #10
0
        public void GenerateProxy(StringBuilder sb, string controlID)
        {
            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\"");
                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().ToLower()));
                }

                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("}));}");
        }
Пример #11
0
 /// <summary>
 /// Initializes the drag drop object's constraints to restrict movement to a certain element.
 /// </summary>
 /// <param name="constrainTo">The element to constrain to.</param>
 public void ConstrainTo(string constrainTo)
 {
     this.Call("constrainTo", new JRawValue(string.Concat("Ext.net.getEl(", TokenUtils.ParseAndNormalize(constrainTo), ")")));
 }
Пример #12
0
 public static string ParseAndNormalize(string script)
 {
     return(TokenUtils.ParseAndNormalize(script, null));
 }
Пример #13
0
 public virtual void Unregister(string target)
 {
     target = "Ext.net.getEl({0})".FormatWith(TokenUtils.ParseAndNormalize(target));
     this.Call("unregister", new JRawValue(target));
 }
Пример #14
0
 public virtual void AddListener(string eventName, string fn, string scope, HandlerConfig options)
 {
     fn = TokenUtils.ParseAndNormalize(fn, this).Trim('"');
     this.Call("on", eventName, new JRawValue(fn), new JRawValue(scope), new JRawValue(options.ToJsonString()));
 }