public void CaseWriter() { CaseWriter writer = new CaseWriter(); CaseTemplate template = new CaseTemplate(Code.String("test")); template.Code.AddLine(Code.Comment("code here")); writer.Write(template, this.output); Assert.AreEqual("case \"test\":\r\n // code here\r\n break;", this.output.ToString()); }
public MethodNameSwitch() { CaseWriter = new CaseWriter(); }
public MainForm() { caseReader = new CaseReader(); caseWriter = new CaseWriter(); caseConvertor = new CaseConvertor(); caseReader.OnTaskStarted += OnOpenCaseStart; caseReader.OnTaskFinished += OnOpenCaseFinished; caseWriter.OnTaskStarted += OnWriteCaseStart; caseWriter.OnTaskFinished += OnWriteCaseFinished; caseConvertor.OnTaskStarted += OnConvertCaseStart; caseConvertor.OnTaskFinished += OnConvertCaseFinished; currentTreeNode = null; if (!File.Exists(configFileName)) { foamConfig = GlobalConfig.Default; foamConfig.Write(configFileName); } else { foamConfig = GlobalConfig.Read(configFileName); } if (!File.Exists(logFileName)) { File.Create(logFileName).Close(); } commonLogWriter = new StreamWriter(logFileName, true, new UTF8Encoding(false)); runner = new FoamRunner(foamConfig); InitializeComponent(); runner.OnOutput = this.OnRunnerOutput; runner.OnError = this.OnRunnerError; runner.OnExit = this.OnRunnerExit; runner.IsWriteErr = true; runner.IsWriteLog = true; onPlugTypeChange = new OnPlugTypeChange( (me, patchName, from, to) => { if (from == to) { return; } Plug plug = null; switch (to) { case Plug.PLUG_TYPE.BasicPlug: plug = new Plug(patchName); plug.Alpha = me.Alpha; plug.GasVelocity = me.GasVelocity; plug.MeanSlitRadius = me.MeanSlitRadius; plug.Radius = me.Radius; plug.Radius = me.Radius; break; case Plug.PLUG_TYPE.PorousPlug: plug = new PorousPlug(patchName); plug.Alpha = me.Alpha; plug.GasVelocity = me.GasVelocity; plug.MeanSlitRadius = me.MeanSlitRadius; plug.Radius = me.Radius; plug.Radius = me.Radius; break; case Plug.PLUG_TYPE.SlitPlug: plug = new SlitPlug(patchName); break; } if (plug != null) { currentCase.Field.Boundarys.Remove(me); currentCase.Field.Boundarys.Add(plug); currentTreeNode = treeView_main.SelectedNode; UpdateCaseObject(); } } ); onWallHeatTypeChange = new OnWallHeatTypeChange( (me, patchName, from, to) => { if (from == to) { return; } Wall wall = null; switch (to) { case Wall.WALL_TYPE.Adiabat: wall = new AdiabatWall(patchName); wall.Layers = me.Layers; break; case Wall.WALL_TYPE.Coefficent: wall = new HeatTransferWall(patchName); wall.Layers = me.Layers; break; case Wall.WALL_TYPE.Flux: wall = new HeatFluxWall(patchName); wall.Layers = me.Layers; break; case Wall.WALL_TYPE.Power: wall = new PowerWall(patchName); wall.Layers = me.Layers; break; case Wall.WALL_TYPE.Temperature: wall = new TemperatureWall(patchName); wall.Layers = me.Layers; break; } if (wall != null) { currentCase.Field.Boundarys.Remove(me); currentCase.Field.Boundarys.Add(wall); currentTreeNode = treeView_main.SelectedNode; UpdateCaseObject(); } } ); onBoundaryTypeChange = new OnBoundaryTypeChange( (me, patchName, from, to) => { if (from != to) { Boundary bn = null; switch (to) { case Boundary.BOUNDARY_TYPE.Plug: bn = new Plug(patchName); break; case Boundary.BOUNDARY_TYPE.Symmetry: bn = new Symmetry(patchName); break; case Boundary.BOUNDARY_TYPE.Upface: bn = new Upface(patchName); break; case Boundary.BOUNDARY_TYPE.Wall: bn = new AdiabatWall(patchName); break; } if (bn != null) { currentCase.Field.Boundarys.Remove(me); currentCase.Field.Boundarys.Add(bn); currentTreeNode = treeView_main.SelectedNode; UpdateCaseObject(); } } } ); foamViewer_main.OnReadMeshStarted += OnReadMeshStart; foamViewer_main.OnReadMeshFinished += OnReadMeshFinished; foamViewer_main.OnPatchSelected += OnPatchSelected; foamViewer_main.MeshColor = foamConfig.MeshColor; foamViewer_main.HightLightColor = foamConfig.HighLightMeshColor; InitCase(); InitControls(); treeNode_boundary = treeView_main.Nodes["Case"].Nodes["Field"].Nodes["Boundary"]; msgManager = new LflowMsgManager(rtb_log, tb_foamlog); //msgManager.AsyncStartProcesser(); }