private bool GenerateAssembly(IContext context)
        {
            try
            {
                IDomainMap domainMap = context.DomainMap;
                ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer();
                CodeDomProvider provider = null;
                //if (domainMap.CodeLanguage == CodeLanguage.CSharp)
                //{
                    provider = new CSharpCodeProvider();
                //    config.SetupCSharp();
                //}
                //else if (domainMap.CodeLanguage == CodeLanguage.VB)
                //{
                //    provider = new VBCodeProvider();
                //    config.SetupVBNet();
                //}

                string code = modelToCodeTransformer.ToCode(domainMap, provider);

                CompilerResults cr = modelToCodeTransformer.ToCompilerResults(domainMap, provider);
                if (cr.Errors.Count > 0)
                {
                }
                else
                {
                    domain = cr.CompiledAssembly;
                }
            }
            catch (Exception ex)
            {
                domain = null;
            }
            if (domain == null)
                return false;

            return true;
        }
        private bool GenerateAssembly(IContext context)
        {
            try
            {
                IDomainMap domainMap = context.DomainMap;
                ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer();
                CodeDomProvider provider = null;

                provider = new CSharpCodeProvider();

                string code = modelToCodeTransformer.ToCode(domainMap, provider);

                CompilerResults cr = modelToCodeTransformer.ToCompilerResults(domainMap, provider);
                if (cr.Errors.Count > 0)
                {
                }
                else
                {
                    domain = cr.CompiledAssembly;
                    context.AssemblyManager.RegisterAssembly(domain);
                }
            }
            catch (Exception ex)
            {
                domain = null;
            }
            if (domain == null)
                return false;

            return true;
        }
Esempio n. 3
0
        private bool GenerateAssembly(IContext context)
        {
            try
            {
                IDomainMap domainMap = context.DomainMap;
                ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer() ;
                CodeDomProvider provider = null;
                SyntaxBoxConfigurator config = new SyntaxBoxConfigurator(codeTextBox.SyntaxBoxControl) ;
                if (domainMap.CodeLanguage == CodeLanguage.CSharp)
                {
                    provider = new CSharpCodeProvider();
                    config.SetupCSharp() ;
                }
                else if (domainMap.CodeLanguage == CodeLanguage.VB)
                {
                    provider = new VBCodeProvider();
                    config.SetupVBNet() ;
                }
                else
                    throw new IAmOpenSourcePleaseImplementMeException() ;

                string code = modelToCodeTransformer.ToCode(domainMap, provider);
                codeTextBox.Text = code;

                CompilerResults cr = modelToCodeTransformer.ToCompilerResults(domainMap, provider);
                if (cr.Errors.Count > 0)
                {
                    DisplayCompilerErrors(cr);
                    MessageBox.Show("Domain model could not be compiled! The exceptions given by the compiler can be seen in the Errors list. ");
                    domain = null;
                }
                else
                {
                    domain = cr.CompiledAssembly;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Domain model could not be compiled! The compiler gave the following exception: " + ex.ToString() );
                domain = null;
            }
            if (domain == null)
                return false;

            return true;
        }
        private void GenerateAssembly(IContext context)
        {
            try
            {
                IDomainMap domainMap = context.DomainMap;
                ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer();
                CodeDomProvider provider = null;

                provider = new CSharpCodeProvider();

                string code = modelToCodeTransformer.ToCode(domainMap, provider);

                CompilerResults cr = modelToCodeTransformer.ToCompilerResults(domainMap, provider);
                if (cr.Errors.Count > 0)
                {
                }
                else
                {
                    Assembly domain = cr.CompiledAssembly;
                    context.AssemblyManager.RegisterAssembly(domain);
                    this.DomainAssembly = domain;
                }
            }
            catch (Exception ex)
            {
                this.DomainAssembly = null;
            }
        }
        // Taken from DomainExplorer
        private static Assembly GenerateAssembly(IContext context)
        {
            Assembly domain = null;
            try
            {
                IDomainMap domainMap = context.DomainMap;
                ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer();
                CodeDomProvider provider = null;
                if (domainMap.CodeLanguage == CodeLanguage.CSharp)
                    provider = new CSharpCodeProvider();
                else if (domainMap.CodeLanguage == CodeLanguage.VB)
                    provider = new VBCodeProvider();
                else
                    throw new IAmOpenSourcePleaseImplementMeException();

                string code = modelToCodeTransformer.ToCode(domainMap, provider);

                CompilerResults cr = modelToCodeTransformer.ToCompilerResults(domainMap, provider);
                if (cr.Errors.Count > 0)
                {
                    throw new Exception("Domain model could not be compiled!");
                }
                else
                {
                    domain = cr.CompiledAssembly;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Domain model could not be compiled! The compiler gave the following exception: " + ex.ToString());
            }

            return domain;
        }