Пример #1
0
        /// <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
	/// <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();
	}
Пример #4
0
 public virtual System.Object getVariableValue(IContext context, System.String variable)
 {
     return(context.Get(variable));
 }