//private string WriteCSharpFromAST(IExpression expression) { // SourceEmitterOutputString sourceEmitterOutput = new SourceEmitterOutputString(); // SourceEmitter CSSourceEmitter = new SourceEmitter(sourceEmitterOutput); // ExpressionSimplifier es = new ExpressionSimplifier(); // expression = es.Rewrite(expression); // CSSourceEmitter.Traverse(expression); // return sourceEmitterOutput.Data; //} //private string WriteVBFromAST(IExpression expression) { // var sourceEmitterOutput = new VBSourceEmitter.SourceEmitterOutputString(); // var VBSourceEmitter = new VBSourceEmitter.SourceEmitter(this.host, sourceEmitterOutput); // var es = new ExpressionSimplifier(); // expression = es.Rewrite(expression); // VBSourceEmitter.Traverse(expression); // return sourceEmitterOutput.Data; //} /// <summary> /// Writes the exception thrown by this IPrecondition into an "exception" xml element. /// </summary> public void WriteExceptionTo(XmlWriter writer) { if (String.IsNullOrEmpty(this.exception)) { return; } writer.WriteStartElement("exception"); writer.WriteAttributeString("cref", this.exception); if (!String.IsNullOrEmpty(this.precondition.OriginalSource)) { writer.WriteString(BooleanExpressionHelper.NegatePredicate(this.precondition.OriginalSource)); } else { this.docTracker.WriteLine("Warning: Writing exception, but no OriginalSource found."); //Emit the condition instead of the OriginalSource SourceEmitterOutputString sourceEmitterOutput = new SourceEmitterOutputString(); SourceEmitter CSSourceEmitter = new SourceEmitter(sourceEmitterOutput); ExpressionSimplifier es = new ExpressionSimplifier(); LogicalNot logicalNot = new LogicalNot(); logicalNot.Operand = this.precondition.Condition; var condition = es.Rewrite(logicalNot); CSSourceEmitter.Traverse(condition); writer.WriteString(sourceEmitterOutput.Data); } writer.WriteEndElement(); }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> protected string WriteVBFromAST(IExpression expression) { Contract.Requires(expression != null); var sourceEmitterOutput = new VBSourceEmitter.SourceEmitterOutputString(); var VBSourceEmitter = new VBSourceEmitter.SourceEmitter(this.host, sourceEmitterOutput); var es = new ExpressionSimplifier(); expression = es.Rewrite(expression); VBSourceEmitter.Traverse(expression); return(sourceEmitterOutput.Data); }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> protected string WriteNeutralFromAST(IExpression expression) { Contract.Requires(expression != null); var sourceEmitterOutput = new SourceEmitterOutputString(); var sourceEmitter = new NeutralSourceEmitter(sourceEmitterOutput); var es = new ExpressionSimplifier(); expression = es.Rewrite(expression); sourceEmitter.Traverse(expression); return(sourceEmitterOutput.Data); }
/// <summary> /// /// </summary> /// <param name="expression"></param> /// <returns></returns> protected string WriteCSharpFromAST(IExpression expression) { Contract.Requires(expression != null); SourceEmitterOutputString sourceEmitterOutput = new SourceEmitterOutputString(); SourceEmitter CSSourceEmitter = new SourceEmitter(sourceEmitterOutput); ExpressionSimplifier es = new ExpressionSimplifier(); expression = es.Rewrite(expression); CSSourceEmitter.Traverse(expression); return(sourceEmitterOutput.Data); }