コード例 #1
0
        public override void Execute()
        {
            ConvertToCode convert = new ConvertToCode(Context.Model, false);

            _SaveFileDialog.FileName = GetCodeFileNameFor(Context.Model);
            DialogResult dialogResult = _SaveFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                string fileName    = _SaveFileDialog.FileName;
                string genFileName = fileName + ".generated";
                string text        = null;

                bool ok = false;
                if (File.Exists(fileName))
                {
                    try
                    {
                        convert.LoadInformationFromExistingFile(fileName);
                        // regen
                        text = convert.Convert();
                        ok   = true;
                    }
                    catch (Exception ex)
                    {
                        ok = false;
                        MessageBox.Show(ex.Message, "Cannot save generated code file.");
                    }
                }
                else
                {
                    text = convert.Convert();
                    ok   = true;
                }

                if (ok && text != null)
                {
                    using (StreamWriter sw = new StreamWriter(genFileName))
                    {
                        sw.WriteLine(text);
                    }

                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                    File.Move(genFileName, fileName);
                    SaveCodeFileMapping(Context.Model, fileName);
                }
                else
                {
                    MessageBox.Show("CodeFile was not saved", "Cannot save generated code file.");
                }
            }
        }
コード例 #2
0
        public CompilerResults Compile(DiagramModel model)
        {
            ConvertToCode   convert          = new ConvertToCode(model, false);
            string          code             = convert.Convert();
            Type            loggingUtilType  = typeof(LoggingUserBase);
            Type            qf4netType       = typeof(qf4net.QHsm);
            Type            qfExtensionsType = typeof(qf4net.LQHsm);
            CompilerResults results          = Compile(code, new Type[] { loggingUtilType, qf4netType, qfExtensionsType });

            return(results);
        }