Beispiel #1
0
        private static void EmptyAndNullParametersTestHelper( DynamicInvoker dynamicInvoker, string parameters )
        {
            var callStatement = new CallStatement( Helper.EmptyPosition, "Name", parameters );

            var invokeCodeWriter = dynamicInvoker.Invoke<CodeWriter>( "GenerateInvoke", callStatement );

            Assert.IsNotNull( invokeCodeWriter );

            var invokeText = invokeCodeWriter.ToString().Replace( " ", "" );

            Assert.That( invokeText, Is.EqualTo( "this.Invoke(\"Name\")" ) );
        }
        public CodeWriter JoinStatement( CallStatement statement, string tempWriter, string list )
        {
            var writer = new CodeWriter();

            writer.AppendText( list );
            writer.Indent = 0;
            writer.Append( ".Add( " );
            writer.Append( this.Invoke( "GenerateInvoke", statement ) );
            writer.Indent = 0;
            writer.Append( " );" );

            return writer;
        }
        public CodeWriter Statement( CallStatement call, string writerName )
        {
            var writer = new CodeWriter();

            writer.AppendText( writerName );
            writer.Indent = 0;
            writer.Append( ".Append( " );
            writer.Append( this.Invoke( "GenerateInvoke", call ) );
            writer.Indent = 0;
            writer.Append( " );" );

            return writer;
        }
Beispiel #4
0
        public void SimpleTest()
        {
            var generator = new Generator();
            var dynamicInvoker = new DynamicInvoker( generator );

            var callStatement = new CallStatement( Helper.EmptyPosition, "Name", "param1, param2" );

            var invokeCodeWriter = dynamicInvoker.Invoke<CodeWriter>( "GenerateInvoke", callStatement );

            Assert.IsNotNull( invokeCodeWriter );

            var invokeText = invokeCodeWriter.ToString().Replace( " ", "" );

            Assert.That( invokeText, Is.EqualTo( "this.Invoke(\"Name\",param1,param2)" ) );
        }
Beispiel #5
0
 private bool Match_GenerateInvoke_IsNotEmpty( CallStatement call )
 {
     return !IsNullOrWhiteSpace( call.Parameters );
 }
Beispiel #6
0
        public CodeWriter GenerateInvoke_IsNotEmpty( CallStatement call )
        {
            var writer = new CodeWriter();

            writer.Indent = 0;
            writer.Append( "this.Invoke( \"" );
            writer.AppendText( call.Name );
            writer.Indent = 0;
            writer.Append( "\", " );
            writer.AppendText( call.Parameters );
            writer.Indent = 0;
            writer.Append( " )" );

            return writer;
        }
Beispiel #7
0
 void Call(out CallStatement callStatement)
 {
     string methodName; string parameters = null;
     while (!(la.kind == 0 || la.kind == 6)) {SynErr(49); Get();}
     Expect(6);
     Token start = t;
     Expect(1);
     methodName = t.val;
     int startPos = -1; int endPos = -1;
     if (la.kind == 24) {
     Get();
     startPos = t.pos + t.val.Length;
     while (StartOf(11)) {
         Get();
     }
     endPos = la.pos;
     Expect(25);
     } else if (la.kind == 22) {
     Get();
     startPos = t.pos + t.val.Length;
     while (StartOf(12)) {
         Get();
     }
     endPos = la.pos;
     Expect(23);
     } else SynErr(50);
     if (startPos > 0 && endPos > 0)
        parameters = scanner.buffer.GetString( startPos, endPos ).Trim();
     while (!(la.kind == 0 || la.kind == 10)) {SynErr(51); Get();}
     Expect(10);
     callStatement = new CallStatement( new StatementPosition( start, t ), methodName, parameters );
 }