Exemplo n.º 1
0
        /// <summary>
        /// This method writes out the contents of our designer in C# and VB.
        /// It generates code from our codeCompileUnit using CodeRpovider
        /// </summary>
        public string GetCode()
        {
            Flush();
            StringWriter         sw;
            CodeGeneratorOptions options = new CodeGeneratorOptions();

            options.BlankLinesBetweenMembers = false;
            options.BracingStyle             = "C";
            options.ElseOnClosing            = false;
            options.IndentString             = "    ";

            // PABC Code Generation
            sw = new StringWriter();
            DesignerResourceService resourceService = host.GetService(typeof(IResourceService)) as DesignerResourceService;

            if (resourceService.ResourcesFileNames != null && resourceService.ResourcesFileNames.Count > 0)
            {
                for (int i = 0; i < resourceService.ResourcesFileNames.Count; i++)
                {
                    sw.WriteLine("{$resource " + Path.GetFileName(resourceService.ResourcesFileNames[i]) + '}');
                    sw.Write("    ");
                }
            }
            ICodeGenerator    abc  = new PABCCodeGenerator();
            PABCCodeGenerator pabc = abc as PABCCodeGenerator;

            pabc.UnitName = Path.GetFileNameWithoutExtension(unitFile);
            abc.GenerateCodeFromCompileUnit(codeCompileUnit, sw, options);
            PABCCodeGenerator inc_abc = new PABCCodeGenerator();

            inc_abc.own_output = true;
            StreamWriter inc_sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(VisualPascalABC.ProjectFactory.Instance.CurrentProject.Path), /*codeCompileUnit.Namespaces[0].Types[0].Name+".inc"*/ pabc.UnitName + "." + getFormName() + ".inc"));

            (inc_abc as ICodeGenerator).GenerateCodeFromCompileUnit(codeCompileUnit, inc_sw, options);
            inc_sw.Flush();
            inc_sw.Close();
            return(sw.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method writes out the contents of our designer in C# and VB.
		/// It generates code from our codeCompileUnit using CodeRpovider
        /// </summary>
        public string GetCode()
		{
            Flush();
            StringWriter sw;
            CodeGeneratorOptions options = new CodeGeneratorOptions();
            options.BlankLinesBetweenMembers = false;
            options.BracingStyle = "C";
            options.ElseOnClosing = false;
            options.IndentString = "    ";

            // PABC Code Generation
            sw = new StringWriter();
            DesignerResourceService resourceService = host.GetService(typeof(IResourceService)) as DesignerResourceService;
            if (resourceService.ResourcesFileNames != null && resourceService.ResourcesFileNames.Count > 0)
            {
                for (int i = 0; i < resourceService.ResourcesFileNames.Count; i++)
                {
                    sw.WriteLine("{$resource " + Path.GetFileName(resourceService.ResourcesFileNames[i]) + '}');
                    sw.Write("    ");
                }
            }
            ICodeGenerator abc = new PABCCodeGenerator();
            PABCCodeGenerator pabc = abc as PABCCodeGenerator;
            pabc.UnitName = Path.GetFileNameWithoutExtension(unitFile);
            abc.GenerateCodeFromCompileUnit(codeCompileUnit, sw, options);
            PABCCodeGenerator inc_abc = new PABCCodeGenerator();
            inc_abc.own_output = true;
            StreamWriter inc_sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(VisualPascalABC.ProjectFactory.Instance.CurrentProject.Path),/*codeCompileUnit.Namespaces[0].Types[0].Name+".inc"*/pabc.UnitName + "." + getFormName() + ".inc"));
            (inc_abc as ICodeGenerator).GenerateCodeFromCompileUnit(codeCompileUnit, inc_sw, options);
            inc_sw.Flush();
            inc_sw.Close();
            return sw.ToString();
		}