Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
        public override object Invoke(object proxy, System.Reflection.MethodInfo method, object[] args)
        {
            if (_open)
            {
                if (method.ReturnType.Equals(Void.TYPE))
                {
                    // formatln invocation start
                    Format(_output, "        visitor.%s(", method.Name);

                    // formatln arguments
                    for (int i = 0; i < args.Length; i++)
                    {
                        object arg = args[i];

                        if (i > 0)
                        {
                            Format(_output, ", ");
                        }
                        else
                        {
                            Format(_output, " ");
                        }

                        _argumentFormatter.formatArgument(_output, arg);
                    }

                    // formatln invocation end
                    if (args.Length == 0)
                    {
                        Formatln(_output, ");");
                    }
                    else
                    {
                        Formatln(_output, " );");
                    }

                    return(null);
                }
                else
                {
                    throw new System.ArgumentException("InvocationTraceGenerator only works with void methods");
                }
            }
            else
            {
                throw new System.InvalidOperationException("Tracer already closed");
            }
        }