Esempio n. 1
0
        private static CSharpFormattingOptions CreateOptionSet(FormattingOptionSet defaultOptionSet)
        {
            switch (defaultOptionSet)
            {
            case FormattingOptionSet.Orcomp:
                return(CreateOrcompOptions());

            case FormattingOptionSet.KRStyle:
                return(FormattingOptionsFactory.CreateKRStyle());

            case FormattingOptionSet.Mono:
                return(FormattingOptionsFactory.CreateMono());

            case FormattingOptionSet.SharpDevelop:
                return(FormattingOptionsFactory.CreateSharpDevelop());

            case FormattingOptionSet.VisualStudio:
                return(FormattingOptionsFactory.CreateAllman());

            case FormattingOptionSet.GNU:
                return(FormattingOptionsFactory.CreateGNU());

            case FormattingOptionSet.Whitesmiths:
                return(FormattingOptionsFactory.CreateWhitesmiths());

            default:
                return(FormattingOptionsFactory.CreateAllman());
            }
        }
        private void GenerateCSharpFile(string projectName, string outputDirectory, bool xmlDocFood, bool generetaNUnit, FormatStyleEnum formatIndex, string formatFile, bool sortUsing, int templateIndex)
        {
            // To DO
            // For each file
            // http://msdn.microsoft.com/en-us/library/ee844259.aspx
            //TemplateStandard page = new TemplateStandard(xmlDocFood, sortUsing);
            //String pageContent = page.TransformText();
            //System.IO.File.WriteAllText("outputPage.cs", pageContent);

            // Format this new C# source file
            CSharpFormattingOptions format;

            switch (formatIndex)
            {
            case FormatStyleEnum.Empty:
                // Nothing to do!
                // format = FormattingOptionsFactory.CreateEmpty();
                break;

            case FormatStyleEnum.Mono:
                format = FormattingOptionsFactory.CreateMono();
                break;

            case FormatStyleEnum.KR_style:
                format = FormattingOptionsFactory.CreateKRStyle();
                break;

            case FormatStyleEnum.Allman_Visual_Studio:
                format = FormattingOptionsFactory.CreateAllman();
                break;

            case FormatStyleEnum.Whitesmiths:
                format = FormattingOptionsFactory.CreateWhitesmiths();
                break;

            case FormatStyleEnum.GNU:
                format = FormattingOptionsFactory.CreateGNU();
                break;

            case FormatStyleEnum.Custom:
                format = (CSharpFormattingOptions)CSharpFormattingOptionsUI.Load(formatFile);
                break;

            default:
                // unknow value!
                // TO DO : Throw an error
                break;
            }

            // Genereta NUnit test class
            if (generetaNUnit == true)
            {
                // Generate the project
                NStub.CSharp.CSharpProjectGenerator gen = new NStub.CSharp.CSharpProjectGenerator(String.Format("{0}_unitary_tests", projectName), outputDirectory);
                // gen.ReferencedAssemblies

                gen.GenerateProjectFile();

                /*
                 * // Generate the test case file
                 * foreach(string origFile in )
                 * {
                 *  CSharpCodeGenerator unitFile = new CSharpCodeGenerator(origFile, origFile);
                 *  unitFile.GenerateCode();
                 * }
                 */
            }
        }