コード例 #1
0
ファイル: NodeUtils.cs プロジェクト: minskowl/MY
        /// <summary> Utility method to interpolate context variables
        /// into string literals. So that the following will
        /// work:
        /// *
        /// #set $name = "candy"
        /// $image.getURI("${name}.jpg")
        /// *
        /// And the string literal argument will
        /// be transformed into "candy.jpg" before
        /// the method is executed.
        /// </summary>
        public static System.String interpolate(System.String argStr, Context vars)
        {
            System.Text.StringBuilder argBuf = new System.Text.StringBuilder();

            for (int cIdx = 0; cIdx < argStr.Length;)
            {
                char ch = argStr[cIdx];

                switch (ch)
                {
                case '$':
                    System.Text.StringBuilder nameBuf = new System.Text.StringBuilder();
                    for (++cIdx; cIdx < argStr.Length; ++cIdx)
                    {
                        ch = argStr[cIdx];
                        if (ch == '_' || ch == '-' || System.Char.IsLetterOrDigit(ch))
                        {
                            nameBuf.Append(ch);
                        }
                        else if (ch == '{' || ch == '}')
                        {
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (nameBuf.Length > 0)
                    {
                        System.Object value_Renamed = vars.Get(nameBuf.ToString());

                        if (value_Renamed == null)
                        {
                            argBuf.Append("$").Append(nameBuf.ToString());
                        }
                        else
                        {
                            //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"'
                            argBuf.Append(value_Renamed.ToString());
                        }
                    }
                    break;



                default:
                    argBuf.Append(ch);
                    ++cIdx;
                    break;
                }
            }

            return(argBuf.ToString());
        }
コード例 #2
0
	public virtual System.Object getVariableValue(IContext context, System.String variable) {
	    return context.Get(variable);
	}
コード例 #3
0
 public object InvalidMethod(NVelocity.Context.IContext context, string reference, object object_Renamed, string method, NVelocity.Util.Introspection.Info info)
 {
     return("InvalidMethod:" + reference);
 }
コード例 #4
0
 public bool InvalidSetMethod(NVelocity.Context.IContext context, string leftreference, string rightreference, NVelocity.Util.Introspection.Info info)
 {
     return(true);
 }
コード例 #5
0
ファイル: NodeUtils.cs プロジェクト: DF-thangld/web_game
	/// <summary> Utility method to interpolate context variables
	/// into string literals. So that the following will
	/// work:
	/// *
	/// #set $name = "candy"
	/// $image.getURI("${name}.jpg")
	/// *
	/// And the string literal argument will
	/// be transformed into "candy.jpg" before
	/// the method is executed.
	/// </summary>
	public static System.String interpolate(System.String argStr, Context vars) {
	    System.Text.StringBuilder argBuf = new System.Text.StringBuilder();

	    for (int cIdx = 0; cIdx < argStr.Length; ) {
		char ch = argStr[cIdx];

		switch (ch) {
		    case '$':
			System.Text.StringBuilder nameBuf = new System.Text.StringBuilder();
			for (++cIdx; cIdx < argStr.Length; ++cIdx) {
			    ch = argStr[cIdx];
			    if (ch == '_' || ch == '-' || System.Char.IsLetterOrDigit(ch))
				nameBuf.Append(ch);
			    else if (ch == '{' || ch == '}')
				continue;
			    else
				break;
			}

			if (nameBuf.Length > 0) {
			    System.Object value_Renamed = vars.Get(nameBuf.ToString());

			    if (value_Renamed == null)
				argBuf.Append("$").Append(nameBuf.ToString());
			    else {
				//UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"'
				argBuf.Append(value_Renamed.ToString());
			    }
			}
			break;



		    default:
			argBuf.Append(ch);
			++cIdx;
			break;

		}
	    }

	    return argBuf.ToString();
	}
コード例 #6
0
 public virtual System.Object getVariableValue(IContext context, System.String variable)
 {
     return(context.Get(variable));
 }