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;
        }
        public virtual IContext GetContext(IDomainMap domainMap, ref bool hasSource)
        {
            IContext context = null;

            if (domainMap != null)
            {
                context = new Context(domainMap);
                if (!GenerateAssembly(context))
                {
                    return null;
                }
            }
            else
            {
                if (this.domainConfig.MapPath.Length > 0)
                {
                    context = new Context(this.domainConfig.MapPath);

                    if (this.domainConfig.UseCustomDataSource)
                    {
                        if (this.domainConfig.PersistenceType == PersistenceType.ObjectRelational)
                        {
                            context.DomainMap.UnFixate() ;
                            ISourceMap sourceMap = context.GetSourceMap();
                            sourceMap.ConnectionString = this.domainConfig.ConnectionString;
                            sourceMap.SourceType = this.domainConfig.SourceType;
                            sourceMap.ProviderType = this.domainConfig.ProviderType;
                            context.DomainMap.Fixate() ;
                            hasSource = true;
                        }
                        else if (this.domainConfig.PersistenceType == PersistenceType.ObjectService)
                        {
                            IPersistenceEngine remotingEngine = new WebServiceRemotingEngine(new XmlFormatter(), this.domainConfig.Url, this.domainConfig.DomainKey, new DefaultWebServiceCompressor(), true);
                            context.PersistenceEngine = remotingEngine;
                            hasSource = true;
                        }
                        else if (this.domainConfig.PersistenceType == PersistenceType.ObjectDocument)
                        {

                            hasSource = true;
                        }
                    }
                }
                else if (this.domainConfig.Url.Length > 0)
                {
                    context = new Context(this.domainConfig.Url, this.domainConfig.DomainKey);
                    hasSource = true;
                }
                else if (this.domainConfig.ConnectionString.Length > 0)
                {
                    //Wrap db on the fly
                    WrapDatabase();
                    hasSource = true;
                }
                else
                {
                    return null;
                }

                if (this.domainConfig.AssemblyPath.Length > 0)
                {
                    domain = System.Reflection.Assembly.LoadFrom(this.domainConfig.AssemblyPath);
                }
                else
                {
                    GenerateAssembly(context);
                }
            }

            context.ValidateBeforeCommit = false;

            if (domain != null)
            {
                context.AssemblyManager.RegisterAssembly(domain);

                context.ExecutingSql += new ExecutingSqlEventHandler(this.HandleExecutingSql) ;
                context.CallingWebService += new CallingWebServiceEventHandler(this.HandleCallingWebService) ;
            }

            SyntaxBoxConfigurator config = new SyntaxBoxConfigurator(npathTextBox.SyntaxBoxControl) ;
            config.SetupNPath() ;

            return context;
        }
 public void SetupSqlServerSql()
 {
     SyntaxBoxConfigurator syntaxBoxConfigurator = new SyntaxBoxConfigurator(syntaxBoxControl1);
     syntaxBoxConfigurator.SetupSqlServer2KSql() ;
 }
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            SyntaxBoxConfigurator config = new SyntaxBoxConfigurator(sqlLogTextBox.SyntaxBoxControl) ;
            config.SetupSqlServer2KSql() ;

            config = new SyntaxBoxConfigurator(webServiceLogTextBox.SyntaxBoxControl) ;
            config.SetupText() ;
        }
 //this.syntaxBoxControl1.ActiveView = Puzzle.Windows.Forms.SyntaxBox.ActiveView.BottomRight;
 //            this.syntaxBoxControl1.ShowScopeIndicator = false;		//disappeared
 //            this.syntaxBoxControl1.BorderStyle = Puzzle.Windows.Forms.BorderStyle.None;
 public void SetupNPath()
 {
     SyntaxBoxConfigurator syntaxBoxConfigurator = new SyntaxBoxConfigurator(syntaxBoxControl1);
     syntaxBoxConfigurator.SetupNPath() ;
 }