Exemple #1
0
        private bool doCompile()
        {
            if (compiledObject != null)
            {
                //no need to re-compile
                return(true);
            }

            string        code       = hiddenPrefix + lblCodePrefix.Text + txtCode.Text + lblCodeSuffix.Text + hiddenSuffix;
            List <string> references = new List <string>();

            string     appPath = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri     = new UriBuilder(appPath);
            string     path    = Uri.UnescapeDataString(uri.Path);

            path = Path.GetDirectoryName(path);

            references.Add(Path.Combine(path, "GeneticMarket.Base.dll"));
            references.Add(Path.Combine(path, "GeneticMarket.Common.dll"));
            references.Add(Path.Combine(path, "GeneticMarket.Logic.dll"));
            references.Add(Path.Combine(path, "GeneticMarket.BackEnd.dll"));
            references.Add(Path.Combine(path, "GeneticMarket.Core.dll"));



            RuntimeResult rr = RuntimeHelper.CompileCode(code, references);

            if (rr.Success == false)
            {
                MessageBox.Show(rr.ErrorMessage);
                return(false);
            }

            if (rr.CreatedObject == null)
            {
                MessageBox.Show("Error creating object");
                return(false);
            }

            compiledObject = rr.CreatedObject as IStrategyRefiner;

            return(true);
        }