/// <summary>
        /// parses the macro.  We need to do this here, at init time, or else
        /// the local-scope template feature is hard to get to work :)
        /// </summary>
        private void parseTree(String[] callArgs)
        {
            try
            {
                //UPGRADE_ISSUE: The equivalent of constructor 'java.io.BufferedReader.BufferedReader' is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
                TextReader br = new StringReader(macroBody);

                /*
                 *  now parse the macro - and don't dump the namespace
                 */

                nodeTree = rsvc.parse(br, namespace_Renamed, false);

                /*
                 *  now, to make null references render as proper schmoo
                 *  we need to tweak the tree and change the literal of
                 *  the appropriate references
                 *
                 *  we only do this at init time, so it's the overhead
                 *  is irrelevant
                 */
                Hashtable hm = new Hashtable();

                for (int i = 1; i < argArray.Length; i++)
                {
                    String arg = callArgs[i - 1];

                    /*
                     *  if the calling arg is indeed a reference
                     *  then we add to the map.  We ignore other
                     *  stuff
                     */
                    if (arg[0] == '$')
                    {
                        hm[argArray[i]] = arg;
                    }
                }

                /*
                 *  now make one of our reference-munging visitor, and
                 *  let 'er rip
                 */
                VMReferenceMungeVisitor v = new VMReferenceMungeVisitor(hm);
                nodeTree.jjtAccept(v, null);
            }
            catch (Exception e)
            {
                rsvc.error("VelocimacroManager.parseTree() : exception " + macroName + " : " + StringUtils.stackTrace(e));
            }
        }
Esempio n. 2
0
        /// <summary> Default constructor: sets up the Velocity
        /// Runtime, creates the visitor for traversing
        /// the node structure and then produces the
        /// visual representation by the visitation.
        /// </summary>
        public TemplateNodeView(System.String template)
        {
            try {
                RuntimeSingleton.init("velocity.properties");

                System.IO.StreamReader isr = new InputStreamReader(new System.IO.FileStream(template, System.IO.FileMode.Open, System.IO.FileAccess.Read), RuntimeSingleton.getString(RuntimeSingleton.INPUT_ENCODING))
                ;

                //UPGRADE_ISSUE: The equivalent of constructor 'java.io.BufferedReader.BufferedReader' is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
                System.IO.StreamReader br = new System.IO.StreamReader(isr.BaseStream);

                document = RuntimeSingleton.parse(br, template)
                ;

                visitor         = new NodeViewMode();
                visitor.Context = null;
                //UPGRADE_ISSUE: The equivalent of parameter java.lang.System.out is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
                visitor.Writer = new System.IO.StreamWriter(System.Console.Out);
                document.jjtAccept(visitor, null);
            } catch (System.Exception e) {
                System.Console.Out.WriteLine(e);
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
Esempio n. 3
0
        /// <summary> Default constructor: sets up the Velocity
        /// Runtime, creates the visitor for traversing
        /// the node structure and then produces the
        /// visual representation by the visitation.
        /// </summary>
        public TemplateNodeView(System.String template)
        {
            try {
            RuntimeSingleton.init("velocity.properties");

            System.IO.StreamReader isr = new InputStreamReader(new System.IO.FileStream(template, System.IO.FileMode.Open, System.IO.FileAccess.Read), RuntimeSingleton.getString(RuntimeSingleton.INPUT_ENCODING))
            ;

            //UPGRADE_ISSUE: The equivalent of constructor 'java.io.BufferedReader.BufferedReader' is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
            System.IO.StreamReader br = new System.IO.StreamReader(isr.BaseStream);

            document = RuntimeSingleton.parse(br, template)
            ;

            visitor = new NodeViewMode();
            visitor.Context = null;
            //UPGRADE_ISSUE: The equivalent of parameter java.lang.System.out is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
            visitor.Writer = new System.IO.StreamWriter(System.Console.Out);
            document.jjtAccept(visitor, null);
            } catch (System.Exception e) {
            System.Console.Out.WriteLine(e);
            SupportClass.WriteStackTrace(e, Console.Error);
            }
        }