public MessageRecipeParser()
 {
     fragment_root_      = new FragmentManager();
     fragment_factory_   = new FragmentFactory();
     guide_book_file_    = string.Empty;
     material_path_      = string.Empty;
     order_list_         = new List<HppFileDescrption>();
 }
示例#2
0
        // Test for using the fragments in relection way
        static void ReflectionTest()
        {
            FragmentManager cppWriter = new FragmentManager();

            FragmentFactory fragmentFactory = new FragmentFactory();

            IFragment codeDescription = fragmentFactory.Creat( "CodeGenerator.Description" );
            cppWriter.AddChild( codeDescription );

            IFragment defineGuards = fragmentFactory.Creat( "CodeGenerator.DefineGuards" );
            MethodInfo tempMethod = defineGuards.GetType().GetMethod( "AddGuardMark" );
            List<object> lis = new List<object>();
            lis.Add( "SOME_HPP_" );
            tempMethod.Invoke( defineGuards , lis.ToArray() );
            cppWriter.AddChild( defineGuards );

            IFragment headers = fragmentFactory.Creat( "CodeGenerator.Headers" );
            MethodInfo addHeader = headers.GetType().GetMethod( "AddHeader" );
            List<object> headername = new List<object>();
            headername.Add( "<iostream>" );
            headername.Add( false );
            addHeader.Invoke( headers , headername.ToArray() );
            headername.Clear();
            headername.Add( "fstream" );
            headername.Add( false );
            addHeader.Invoke( headers , headername.ToArray() );
            headername.Clear();
            headername.Add( "json.hpp" );
            headername.Add( true );
            addHeader.Invoke( headers , headername.ToArray() );
            headername.Clear();
            cppWriter.AddChildTo( defineGuards , headers , 0 );

            IFragment NameSpace = fragmentFactory.Creat( "CodeGenerator.NameSpace" );
            MethodInfo addNS = NameSpace.GetType().GetMethod( "AddNameSpace" );
            lis.Clear();
            lis.Add( "maratonprotocol" );
            addNS.Invoke( NameSpace , lis.ToArray() );
            cppWriter.AddChildTo( defineGuards , NameSpace , 0 );

            IFragment ClassName = fragmentFactory.Creat( "CodeGenerator.Class" );
            MethodInfo addClass = ClassName.GetType().GetMethod( "AddClass" );
            lis.Clear();
            lis.Add( "MessageXXX" );
            lis.Add( "Message" );
            addClass.Invoke( ClassName , lis.ToArray() );
            cppWriter.AddChildTo( NameSpace , ClassName , 1 );
            cppWriter.GenerateAll();
        }