예제 #1
0
        /// <summary>Create a main entry point code unit to compile.</summary>
        /// <returns>
        ///     <see cref="CodeCompileUnit" />
        /// </returns>
        public static CodeCompileUnit CreateMainEntryPoint()
        {
            CodeCompileUnit _codeUnit = new CodeCompileUnit();

            // References
            _codeUnit.ReferencedAssemblies.Add("System.dll");
            _codeUnit.ReferencedAssemblies.Add("Comet.dll");

            // Namespace
            CodeNamespace _namespace = new CodeNamespace("Installer");

            // Using/s
            _namespace.Imports.Add(new CodeNamespaceImport("System"));
            _namespace.Imports.Add(new CodeNamespaceImport("Comet"));

            _codeUnit.Namespaces.Add(_namespace);

            // Class
            CodeTypeDeclaration _class = new CodeTypeDeclaration("CometInstall")
            {
                Attributes = MemberAttributes.Public
            };

            _class.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The main class."));

            // Create entry point method
            _class.Members.Add(CodeGeneration.MainEntryPointMethod());

            _namespace.Types.Add(_class);
            return(_codeUnit);
        }
예제 #2
0
        /// <summary>Create a installer code unit to compile.</summary>
        /// <returns>
        ///     <see cref="CodeCompileUnit" />
        /// </returns>
        public static CodeCompileUnit CreateInstallerCode()
        {
            CodeCompileUnit _codeUnit = new CodeCompileUnit();

            // References
            _codeUnit.ReferencedAssemblies.Add("System.dll");
            _codeUnit.ReferencedAssemblies.Add("Comet.dll");

            // Namespace
            CodeNamespace _namespace = new CodeNamespace("Installer");

            // Using/s
            _namespace.Imports.Add(new CodeNamespaceImport("System"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
            _namespace.Imports.Add(new CodeNamespaceImport("Comet"));

            _codeUnit.Namespaces.Add(_namespace);

            // Class
            CodeTypeDeclaration _class = new CodeTypeDeclaration("CometInstall");

            _class.Attributes = MemberAttributes.Public;
            _class.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The main class."));

            // if (false)
            // {
            // _class.BaseTypes.Add(new CodeTypeReference("Base"));
            // }

            // Create entry point method
            CodeEntryPointMethod _entryPointMethod = CodeGeneration.MainEntryPointMethod();

            _entryPointMethod.Statements.Add(CodeGeneration.InvokeMethod(ReferenceLibrary.InstallerType(), "Initialize"));
            _class.Members.Add(_entryPointMethod);

            // Create public variables
            _class.Members.Add(CodeGeneration.CreatePublicProperty("InstallPath", typeof(string)));
            _class.Members.Add(CodeGeneration.CreatePublicProperty("DownloadLink", typeof(string)));

            CodeMemberMethod _initializeMethod = InitializeMethod();

            _class.Members.Add(_initializeMethod);

            _namespace.Types.Add(_class);

            return(_codeUnit);
        }
예제 #3
0
        ///// <summary>Create a installer code unit to compile.</summary>
        ///// <returns>
        /////     <see cref="CodeCompileUnit" />
        ///// </returns>
        // public static CodeCompileUnit CreateInstallerCode()
        // {
        // CodeCompileUnit _codeUnit = new CodeCompileUnit();

        // // References
        // _codeUnit.ReferencedAssemblies.Add("System.dll");
        // _codeUnit.ReferencedAssemblies.Add("Comet.dll");

        // // Namespace
        // CodeNamespace _namespace = new CodeNamespace("Installer");

        // // Using/s
        // _namespace.Imports.Add(new CodeNamespaceImport("System"));
        // _namespace.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
        // _namespace.Imports.Add(new CodeNamespaceImport("Comet"));

        // _codeUnit.Namespaces.Add(_namespace);

        // // Class
        // CodeTypeDeclaration _class = new CodeTypeDeclaration("CometInstall");
        // _class.Attributes = MemberAttributes.Public;
        // _class.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The main class."));

        // // if (false)
        // // {
        // // _class.BaseTypes.Add(new CodeTypeReference("Base"));
        // // }

        // // Create entry point method
        // CodeEntryPointMethod _entryPointMethod = CodeGeneration.MainEntryPointMethod();
        // _entryPointMethod.Statements.Add(CodeGeneration.InvokeMethod(ReferenceLibrary.InstallerType(), "Initialize"));
        // _class.Members.Add(_entryPointMethod);

        // // Create public variables
        // _class.Members.Add(CodeGeneration.CreatePublicProperty("InstallPath", typeof(string)));
        // _class.Members.Add(CodeGeneration.CreatePublicProperty("DownloadLink", typeof(string)));

        // CodeMemberMethod _initializeMethod = InitializeMethod();
        // _class.Members.Add(_initializeMethod);

        // _namespace.Types.Add(_class);

        // return _codeUnit;
        // }

        /// <summary>Create a main entry point code unit to compile.</summary>
        /// <returns>
        ///     <see cref="CodeCompileUnit" />
        /// </returns>
        public static CodeCompileUnit CreateMainEntryPoint()
        {
            CodeCompileUnit _codeUnit = new CodeCompileUnit();

            // References
            _codeUnit.ReferencedAssemblies.Add("System.dll");
            _codeUnit.ReferencedAssemblies.Add("System.Windows.Forms.dll");

            // Namespace
            CodeNamespace _namespace = new CodeNamespace("Installer");

            // Using/s
            _namespace.Imports.Add(new CodeNamespaceImport("System"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Globalization"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.IO"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Reflection"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Resources"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Windows.Forms"));

            _codeUnit.Namespaces.Add(_namespace);

            // Class
            CodeTypeDeclaration _class = new CodeTypeDeclaration("CometInstaller")
            {
                Attributes = MemberAttributes.Public
            };

            _class.Comments.Add(CodeGeneration.CreateFlatSummaryTag("The main class."));

            // Create entry point method
            var _list = new List <CodeExpression>
            {
                CodeGeneration.ReadLineExpression()
            };

            _class.Members.Add(CodeGeneration.MainEntryPointMethod(null, _list));

            _namespace.Types.Add(_class);
            return(_codeUnit);
        }