Ejemplo n.º 1
0
        public static bool GenRDTemplates(string outputtemplatefilename, string basenamespace, out string code, params string[] inputfiles)
        {
            code = string.Empty;
            // tokenize data
            bool tokok = true;

            for (int i = 0; i < inputfiles.Length; i++)
            {
                var source    = inputfiles[i];
                var inputcode = h.getfile(source, null);
                tokok &= createstream(source, inputcode, i == 0);
            }

            if (!tokok)
            {
                return(false);
            }

            // generate constants
            GenericTracker <Token[]> const2consttoks = getcodeconstants();

            // generate helpers

            GenericTracker <List <Token> > function2ftoks = new GenericTracker <List <Token> >();
            bool helperok = transform_assist_helpers(getallsourcetypes(basenamespace, inputfiles), const2consttoks, ref function2ftoks);


            // generate classes
            string        assistcode;
            List <string> typenames;
            var           assistok = transform_assist_calls(outputtemplatefilename, getsourcetype(basenamespace, inputfiles[0]),
                                                            function2ftoks, const2consttoks, out assistcode, out typenames);

            if (helperok && assistok)
            {
                // generate method to get all the types as params
                var getallmethod = gencode_gettypes_fromnames(outputtemplatefilename, typenames);

                // add to global RD listing class
                var rdlisting_class = TargetMap.GetClass(outputtemplatefilename, string.Empty, getallmethod);

                // wrap it all together
                code = RD_AssistTemplate.GetTemplateFile(rdlisting_class + assistcode);

                // save class if required
                bool savefile = !string.IsNullOrWhiteSpace(outputtemplatefilename);
                //var folder = h.gf();
                var folder = Environment.CurrentDirectory + "\\";
                var fn     = folder + outputtemplatefilename + ".cs";
                if (savefile && !string.IsNullOrWhiteSpace(code) && h.setfile(fn, code))
                {
                }


                return(true);
            }

            return(false);
        }